Source code of Windows XP (NT5)
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.

247 lines
7.3 KiB

  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
  70. APIENTRY
  71. GraphWndProc (
  72. HWND hWnd,
  73. UINT wMsg,
  74. WPARAM wParam,
  75. LPARAM lParam)
  76. { // GraphWndProc
  77. BOOL bCallDefProc ;
  78. LRESULT lReturnValue ;
  79. bCallDefProc = FALSE ;
  80. lReturnValue = 0L ;
  81. switch (wMsg) { // switch
  82. case WM_CREATE:
  83. OnCreate (hWnd) ;
  84. break ;
  85. case WM_LBUTTONDBLCLK:
  86. SendMessage (hWndMain, WM_LBUTTONDBLCLK, wParam, lParam) ;
  87. break ;
  88. case WM_PAINT:
  89. OnPaint (hWnd) ;
  90. break ;
  91. case WM_SIZE:
  92. OnSize (hWnd, LOWORD (lParam), HIWORD (lParam)) ;
  93. break ;
  94. default:
  95. bCallDefProc = TRUE ;
  96. } // switch
  97. if (bCallDefProc)
  98. lReturnValue = DefWindowProc (hWnd, wMsg, wParam, lParam) ;
  99. return (lReturnValue);
  100. } // GraphWndProc
  101. BOOL GraphInitializeApplication (void)
  102. /*
  103. Note: There is no background brush set for the MainWindow
  104. class so that the main window is never erased. The
  105. client area of MainWindow is always covered by one
  106. of the view windows. If we erase it, it would just
  107. flicker needlessly.
  108. */
  109. { // GraphInitializeApplication
  110. BOOL bSuccess ;
  111. WNDCLASS wc ;
  112. //=============================//
  113. // Register GraphWindow class //
  114. //=============================//
  115. wc.style = dwGraphClassStyle ;
  116. wc.lpfnWndProc = GraphWndProc ;
  117. wc.hInstance = hInstance ;
  118. wc.cbClsExtra = iGraphWindowExtra ;
  119. wc.cbWndExtra = iGraphClassExtra ;
  120. wc.hIcon = NULL ;
  121. wc.hCursor = LoadCursor(NULL, IDC_ARROW) ;
  122. wc.hbrBackground = NULL ; // see note above
  123. wc.lpszMenuName = NULL ;
  124. wc.lpszClassName = szGraphWindowClass ;
  125. bSuccess = RegisterClass (&wc) ;
  126. //=============================//
  127. // Register Child classes //
  128. //=============================//
  129. // if (bSuccess)
  130. // bSuccess = GraphDisplayInitializeApplication () ;
  131. if (bSuccess)
  132. bSuccess = GraphLegendInitializeApplication () ;
  133. // if (bSuccess)
  134. // bSuccess = GraphStatusInitializeApplication () ;
  135. return (bSuccess) ;
  136. } // GraphInitializeApplication
  137. HWND CreateGraphWindow (HWND hWndParent)
  138. /*
  139. Effect: Create the graph window. This window is a child of
  140. hWndMain and is a container for the graph data,
  141. graph label, graph legend, and graph status windows.
  142. Note: We dont worry about the size here, as this window
  143. will be resized whenever the main window is resized.
  144. */
  145. {
  146. return (CreateWindow (szGraphWindowClass, // window class
  147. NULL, // caption
  148. dwGraphWindowStyle, // style for window
  149. 0, 0, // initial position
  150. 0, 0, // initial size
  151. hWndParent, // parent
  152. NULL, // menu
  153. hInstance, // program instance
  154. NULL)) ; // user-supplied data
  155. }
  156. void SizeGraphComponents (HWND hWnd)
  157. /*
  158. Effect: Move and show the various components of the graph to
  159. fill the size (xWidth x yHeight).
  160. Called By: OnSize, any other function that may remove or add one
  161. of the graph components.
  162. */
  163. { // SizeGraphComponents
  164. RECT rectClient ;
  165. int xWidth ;
  166. int yHeight ;
  167. GetClientRect (hWnd, &rectClient) ;
  168. xWidth = rectClient.right - rectClient.left ;
  169. yHeight = rectClient.bottom - rectClient.top ;
  170. // if the graph window has no size, neither will its children.
  171. if (!xWidth || !yHeight)
  172. return ;
  173. //=============================//
  174. // Update the legend window //
  175. //=============================//
  176. MoveWindow (hWndGraphLegend,
  177. 0, 0,
  178. xWidth, yHeight,
  179. TRUE) ;
  180. WindowShow (hWndGraphLegend, TRUE) ;
  181. } // SizeGraphComponents