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.

122 lines
6.2 KiB

4 years ago
  1. /***************************************************************************\
  2. * lgraph.h
  3. *
  4. * Microsoft Confidential
  5. * Copyright (c) 1991 Microsoft Corporation
  6. *
  7. * Structure definitions for line graph display, and some #defines
  8. *
  9. * History:
  10. * Written by Hadi Partovi (t-hadip) summer 1991
  11. *
  12. * Re-written and adapted for NT by Fran Borda (v-franb) Nov.1991
  13. * for Newman Consulting
  14. * Took out all WIN-specific and bargraph code. Added 3 new
  15. * linegraphs (Mem/Paging, Process/Threads/Handles, IO), and
  16. * tailored info to that available under NT.
  17. \***************************************************************************/
  18. /*
  19. * A line graph is a regular graph with two axes, with variable calibrations.
  20. * The bottom axis is going to be a measure of TIME. That is, the
  21. * graph will be used to display various values as a function of time. It
  22. * can handle more than one line drawn within the same set of axes. Since
  23. * The graph must be able to redraw itself in case of window resizing,
  24. * etc, it must remember all the points (or at least Y values) on the
  25. * display. To make things nicer, it will also remember a limited number
  26. * of values off screen, to allow the user to scroll back and forth to
  27. * see values that have been entered but have scrolled by with time.
  28. * this display can be used to measure various system global values as
  29. * functions of time. The axis calibration, etc, are all user settable.
  30. * the data will be stored as ints, and then converted to X and Y
  31. * coordinates depending on the axis calibration and the sampling interval,
  32. * and so on. What follows is the structure definition for a line graph
  33. * The general database will be a linked list of linegraphs (with only one
  34. * displayed on screen at a time). Each line graph has its own linked list
  35. * of lines to display on that set of axes.
  36. *
  37. *********
  38. * NOTE: THERE IS A CLEAR DISTINCTION BETWEEN "y"s and "Value"s:
  39. * A "y" IS THE ACTUAL COORDINATE DRAWN ON THE DISPLAY. A "value" IS THE
  40. * GIVEN DATA TO BE DRAWN AND IS CONVERTED TO A "y" USING THE CALIBRATION
  41. * NUMBERS. ALL "value"s ARE SAVED. "y"s ARE DISPLAYED ONLY.
  42. * FOR CLARITY, "value"s WILL BE GIVEN THE HUNGARIAN PREFIX "val"
  43. * A new type VALUE will be defined, and set to DWORD, just ofr clarity
  44. *********
  45. * NOTE:
  46. * The rcGraph field of the PLGRAPH structure is very misleading and should
  47. * eventually be changed (throughout the lgraph module) to act nicer.
  48. * currently, rcGraph.left-1, rcGraph.top, rcGraph.right, and rcGraph.bottom
  49. * are coordinates on which graph axes are drawn
  50. * However, rcGraph.bottom also includes some actual graph points drawn
  51. * onto it (for values == valBottom).
  52. * This should be modified so that rcGraph.top-1 is actually where the axis is
  53. * drawn. Also, values should not be drawn on rcGraph.bottom, but just up to
  54. * it. That way, rcGraph will completely enclose the drawn points, and can be
  55. * used as a clipping rectangle, or a scroll rectangle, etc.
  56. */
  57. // general type for values to be graphed
  58. typedef DWORD VALUE;
  59. // structure for values data for one line in a line graph,
  60. // include brush to draw with, as well as array of points
  61. // (array will be circular, to allow scrolling after it is filled)
  62. typedef struct _GraphData {
  63. int iColor; // index into color palette - line color
  64. VALUE far *pValues; // pointer to data (array of size = nMaxValues)
  65. VALUE (*valNext)(void); // function to return next data value
  66. LPSTR lpszDescription; // description of this line
  67. struct _GraphData far *plgdNext;// pointer to data for next line
  68. } LGDATA, far *PLGDATA;
  69. // Structure for general line graph
  70. typedef struct _LineGraphInfo {
  71. LPSTR lpszTitle; // graph title
  72. RECT rcGraph; // graph region (changes with window size)
  73. RECT rcLegend; // legend region
  74. RECT rcCalibration; // calibration region
  75. int cxGraph; // width of graph, maintained as right-left
  76. int cxPerValue; // x width between values
  77. VALUE valBottom; // calibration values (value at bottom)
  78. VALUE dvalAxisHeight; // (height of axis, as displayed value)
  79. VALUE dvalCalibration; // distance between calibration marks
  80. int nMaxValues; // maximum values to remember in history
  81. int nDisplayValues; // # of values displayed
  82. // (< Pixel width, > nMaxValues)
  83. int nLines; // # of separate lines on same axes
  84. int iLeftValue; // index of value at left of display
  85. int iNewLeftValue; // index of new left value for drawing
  86. int iFirstValue; // index of First value in graph history
  87. int iKnownValue; // index of last value known
  88. int iDrawnValue; // index of last value drawn
  89. PLGDATA plgd; // pointer to graph data
  90. struct _LineGraphInfo far *plgNext; // pointer to the next linegraph
  91. } LGRAPH, far *PLGRAPH;
  92. // DEFINITIONS FOR LINEGRAPH GRAPHICS
  93. #define NO_VALUES_YET -1
  94. // initial value for index to known and drawn values
  95. #define MIN_NMAXVALUES 10
  96. // minimum number of values that a graph needs to be displayed ( >1 )
  97. #define DY_AXIS_NUMBER (g.cyChar/2)
  98. // y distance between the calibration marks and the numbers
  99. // calibration label is centered vertically around horiz. lines
  100. #define DX_CALIBRATION_LEFT 1
  101. // space between calibration value and left window edge
  102. #define DX_LEGEND_RIGHT 1
  103. // space between right window edge and legend
  104. #define DX_LEGEND_INDENT (g.cxChar)
  105. // indent within legend box
  106. #define DX_AXIS_LEFT (g.cxChar/2)
  107. // space between vertical axis and calibration value
  108. #define DX_AXIS_RIGHT (g.cxChar/2)
  109. // space to allow to right of graph
  110. #define DY_AXIS_TOP 2
  111. // space to allow at top of graph
  112. #define DY_AXIS_BOTTOM 2
  113. // space to allow at bottom of graph
  114. #define LG_TO_CALIBRATION_RATIO 5
  115. // width of calibration values * this number can't exceed screen width
  116. #define LG_TO_LEGEND_RATIO 2
  117. // width of legend * this number can't exceed screen width