Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
7.4 KiB

4 years ago
  1. /*****************************************************************************
  2. *
  3. * Graph.c - This module handles the graphing window.
  4. *
  5. * Microsoft Confidential
  6. * Copyright (c) 1992-1993 Microsoft Corporation
  7. *
  8. *
  9. ****************************************************************************/
  10. /*
  11. File Contents:
  12. This file contains the code for creating and manipulating the graph
  13. window. This window is a child of hWndMain and represents one of the
  14. three "views" of the program. The other views are log and alert.
  15. The graph window is actually just a container window, whose surface
  16. is completely filled by its children: hWndGraphLegend and hWndGraphStatus.
  17. Therefore much of this file is merely calls to the appropriate
  18. functions for these children.
  19. The graph window is responsible for the graph structure itself,
  20. however. Conceptually this should be instance data for the graph
  21. window. Right now, however, there is only one window and only one
  22. graph structure. Nevertheless, we go through the GraphData(hWnd)
  23. function to get a pointer to the graph structure for the graph window.
  24. */
  25. //==========================================================================//
  26. // Includes //
  27. //==========================================================================//
  28. #include "setedit.h"
  29. #include "graph.h"
  30. #include "legend.h"
  31. // #include "valuebar.h"
  32. #include "utils.h" // for WindowShow
  33. #include "grafdata.h" // for InsertGraph, et al.
  34. //==========================================================================//
  35. // Constants //
  36. //==========================================================================//
  37. //=============================//
  38. // Graph Class //
  39. //=============================//
  40. TCHAR szGraphWindowClass[] = TEXT("PerfmonGraphClass") ;
  41. #define dwGraphClassStyle (CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS)
  42. #define iGraphClassExtra (0)
  43. #define iGraphWindowExtra (0)
  44. #define dwGraphWindowStyle (WS_CHILD)
  45. //==========================================================================//
  46. // Local Functions //
  47. //==========================================================================//
  48. void static OnCreate (HWND hWnd)
  49. { // OnCreate
  50. // hWndGraphDisplay = CreateGraphDisplayWindow (hWnd) ;
  51. InsertGraph(0) ;
  52. hWndGraphLegend = CreateGraphLegendWindow (hWnd) ;
  53. // hWndGraphStatus = CreateGraphStatusWindow (hWnd) ;
  54. } // OnCreate
  55. void static OnPaint (HWND hWnd)
  56. {
  57. HDC hDC ;
  58. PAINTSTRUCT ps ;
  59. hDC = BeginPaint (hWnd, &ps) ;
  60. EndPaint (hWnd, &ps) ;
  61. }
  62. void static OnSize (HWND hWnd, int xWidth, int yHeight)
  63. { // OnSize
  64. SizeGraphComponents (hWnd) ;
  65. } // OnSize
  66. //==========================================================================//
  67. // Message Handlers //
  68. //==========================================================================//
  69. LRESULT APIENTRY GraphWndProc (HWND hWnd,
  70. WORD wMsg,
  71. DWORD wParam,
  72. LONG lParam)
  73. { // GraphWndProc
  74. BOOL bCallDefProc ;
  75. LRESULT lReturnValue ;
  76. bCallDefProc = FALSE ;
  77. lReturnValue = 0L ;
  78. switch (wMsg)
  79. { // switch
  80. case WM_CREATE:
  81. OnCreate (hWnd) ;
  82. break ;
  83. case WM_LBUTTONDBLCLK:
  84. SendMessage (hWndMain, WM_LBUTTONDBLCLK, wParam, lParam) ;
  85. break ;
  86. case WM_PAINT:
  87. OnPaint (hWnd) ;
  88. break ;
  89. case WM_SIZE:
  90. OnSize (hWnd, LOWORD (lParam), HIWORD (lParam)) ;
  91. break ;
  92. default:
  93. bCallDefProc = TRUE ;
  94. } // switch
  95. if (bCallDefProc)
  96. lReturnValue = DefWindowProc (hWnd, wMsg, wParam, lParam) ;
  97. return (lReturnValue);
  98. } // GraphWndProc
  99. BOOL GraphInitializeApplication (void)
  100. /*
  101. Note: There is no background brush set for the MainWindow
  102. class so that the main window is never erased. The
  103. client area of MainWindow is always covered by one
  104. of the view windows. If we erase it, it would just
  105. flicker needlessly.
  106. */
  107. { // GraphInitializeApplication
  108. BOOL bSuccess ;
  109. WNDCLASS wc ;
  110. //=============================//
  111. // Register GraphWindow class //
  112. //=============================//
  113. wc.style = dwGraphClassStyle ;
  114. wc.lpfnWndProc = (WNDPROC) GraphWndProc ;
  115. wc.hInstance = hInstance ;
  116. wc.cbClsExtra = iGraphWindowExtra ;
  117. wc.cbWndExtra = iGraphClassExtra ;
  118. wc.hIcon = NULL ;
  119. wc.hCursor = LoadCursor(NULL, IDC_ARROW) ;
  120. wc.hbrBackground = NULL ; // see note above
  121. wc.lpszMenuName = NULL ;
  122. wc.lpszClassName = szGraphWindowClass ;
  123. bSuccess = RegisterClass (&wc) ;
  124. //=============================//
  125. // Register Child classes //
  126. //=============================//
  127. // if (bSuccess)
  128. // bSuccess = GraphDisplayInitializeApplication () ;
  129. if (bSuccess)
  130. bSuccess = GraphLegendInitializeApplication () ;
  131. // if (bSuccess)
  132. // bSuccess = GraphStatusInitializeApplication () ;
  133. return (bSuccess) ;
  134. } // GraphInitializeApplication
  135. HWND CreateGraphWindow (HWND hWndParent)
  136. /*
  137. Effect: Create the graph window. This window is a child of
  138. hWndMain and is a container for the graph data,
  139. graph label, graph legend, and graph status windows.
  140. Note: We dont worry about the size here, as this window
  141. will be resized whenever the main window is resized.
  142. */
  143. {
  144. return (CreateWindow (szGraphWindowClass, // window class
  145. NULL, // caption
  146. dwGraphWindowStyle, // style for window
  147. 0, 0, // initial position
  148. 0, 0, // initial size
  149. hWndParent, // parent
  150. NULL, // menu
  151. hInstance, // program instance
  152. NULL)) ; // user-supplied data
  153. }
  154. void SizeGraphComponents (HWND hWnd)
  155. /*
  156. Effect: Move and show the various components of the graph to
  157. fill the size (xWidth x yHeight).
  158. Called By: OnSize, any other function that may remove or add one
  159. of the graph components.
  160. */
  161. { // SizeGraphComponents
  162. RECT rectClient ;
  163. int xWidth ;
  164. int yHeight ;
  165. GetClientRect (hWnd, &rectClient) ;
  166. xWidth = rectClient.right - rectClient.left ;
  167. yHeight = rectClient.bottom - rectClient.top ;
  168. // if the graph window has no size, neither will its children.
  169. if (!xWidth || !yHeight)
  170. return ;
  171. //=============================//
  172. // Update the legend window //
  173. //=============================//
  174. MoveWindow (hWndGraphLegend,
  175. 0, 0,
  176. xWidth, yHeight,
  177. TRUE) ;
  178. WindowShow (hWndGraphLegend, TRUE) ;
  179. } // SizeGraphComponents