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.

112 lines
2.8 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1993-1995
  4. * TITLE: FUELBAR.H
  5. * VERSION: 1.0
  6. * AUTHOR: jsenior
  7. * DATE: 10/28/1998
  8. *
  9. ********************************************************************************
  10. *
  11. * CHANGE LOG:
  12. *
  13. * DATE REV DESCRIPTION
  14. * ---------- ------- ----------------------------------------------------------
  15. * 10/28/1998 jsenior Original implementation.
  16. *
  17. *******************************************************************************/
  18. #ifndef _FUELBAR_H
  19. #define _FUELBAR_H
  20. #include <windows.h>
  21. #include <commctrl.h>
  22. #include "vec.h"
  23. #ifndef WINNT
  24. #define FUELPROC DLGPROC
  25. #define FuelSetWindowLongPtr SetWindowLong
  26. #define FuelGetWindowLongPtr GetWindowLong
  27. #define FUELLONG_PTR LONG
  28. #define FUELGWLP_USERDATA GWL_USERDATA
  29. #define FUELGWLP_WNDPROC GWL_WNDPROC
  30. #define FUELDWORD_PTR DWORD
  31. #else
  32. #define FUELPROC WNDPROC
  33. #define FuelSetWindowLongPtr SetWindowLongPtr
  34. #define FuelGetWindowLongPtr GetWindowLongPtr
  35. #define FUELLONG_PTR LONG_PTR
  36. #define FUELGWLP_USERDATA GWLP_USERDATA
  37. #define FUELGWLP_WNDPROC GWLP_WNDPROC
  38. #define FUELDWORD_PTR DWORD_PTR
  39. #endif // WINNT
  40. struct FuelBarItem {
  41. LPVOID id;
  42. UINT value;
  43. int imageIndex;
  44. RECT rect;
  45. };
  46. typedef _Vec<FuelBarItem> FuelBarItemList;
  47. class FuelBar {
  48. public:
  49. FuelBar();
  50. virtual ~FuelBar();
  51. BOOL SubclassDlgItem(UINT nID, HWND hParent);
  52. static const int NoImage;
  53. static const LPVOID NoID;
  54. // return current total in the bar, ID may be any value but -1
  55. UINT AddItem(UINT Value, LPVOID ID = NoID, int ImageIndex = NoImage);
  56. BOOL RemoveItem(LPVOID ID);
  57. void ClearItems();
  58. BOOL HighlightItem(LPVOID ID);
  59. UINT GetMaxValue() const {return maxValue;}
  60. void SetMaxValue(UINT newMax) {maxValue = newMax; Clear();}
  61. UINT GetCurrentTotalValue() const {return currentTotalValue;}
  62. void SetImageList(HIMAGELIST ImageList);
  63. LPVOID GetHighlightedItem();
  64. protected:
  65. LPVOID highlightID;
  66. int colorIndex;
  67. UINT currentTotalValue, maxValue;
  68. BOOL calcRects;
  69. FuelBarItemList items;
  70. // CToolTipCtrl toolTip;
  71. WNDPROC prevWndProc;
  72. HWND hwnd;
  73. HIMAGELIST hImageList;
  74. int imageWidth, imageHeight;
  75. COLORREF colorFace, colorLight, colorDark, colorUnused;
  76. void CalculateRects(const RECT& ClientRect);
  77. void Clear();
  78. void GetSysColors();
  79. BOOL OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pResult);
  80. void OnPaint();
  81. void OnSysColorChange();
  82. static BOOL APIENTRY StaticWndProc(IN HWND hDlg,
  83. IN UINT uMessage,
  84. IN WPARAM wParam,
  85. IN LPARAM lParam);
  86. };
  87. #endif // _FUELBAR_H