Toolbar.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. //////////////////////////////////////////////////////////////////////
  19. //
  20. // Toolbar.H
  21. //
  22. // Declaration of a 'fancy' toolbar using hi-color buttons
  23. //
  24. #ifndef __FANCYTOOLBAR_H
  25. #define __FANCYTOOLBAR_H
  26. //////////////////////////////////////////////////////////////
  27. //
  28. // Constants
  29. //
  30. const int BUTTON_WIDTH = 42;
  31. const int BUTTON_HEIGHT = 36;
  32. const int BUTTON_MIDDLE = 18;
  33. const int BORDER_LEFT = 8;
  34. const int BORDER_RIGHT = 8;
  35. const int BORDER_TOP = 8;
  36. const int BORDER_BOTTOM = 8;
  37. //////////////////////////////////////////////////////////////
  38. //
  39. // CFancyToolbar
  40. //
  41. class CFancyToolbar : public CControlBar
  42. {
  43. ////////////////////////////////////////////////////////
  44. //
  45. // MFC Junk
  46. //
  47. public:
  48. // ClassWizard generated virtual function overrides
  49. //{{AFX_VIRTUAL(CFancyToolbar)
  50. public:
  51. virtual void OnDraw(CDC* pDC); // overridden to draw this view
  52. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  53. protected:
  54. //}}AFX_VIRTUAL
  55. public:
  56. ////////////////////////////////////////////////////////
  57. //
  58. // Public Data Types
  59. //
  60. typedef enum
  61. {
  62. StateUp = 0,
  63. StateDn = 1
  64. } STATE_INFO;
  65. typedef enum
  66. {
  67. TypeNormal = 0,
  68. Type2State = 1
  69. } BUTTON_TYPE;
  70. ////////////////////////////////////////////////////////
  71. //
  72. // Public Contructors
  73. //
  74. CFancyToolbar ();
  75. virtual ~CFancyToolbar ();
  76. ////////////////////////////////////////////////////////
  77. //
  78. // Public Methods
  79. //
  80. //
  81. // Required methods
  82. //
  83. CSize CalcFixedLayout (BOOL, BOOL)
  84. { return CSize (m_iButtons*BUTTON_WIDTH + BORDER_LEFT + BORDER_RIGHT, BUTTON_HEIGHT + BORDER_TOP + BORDER_BOTTOM); }
  85. CSize CalcDynamicLayout( int nLength, DWORD dwMode )
  86. { return CSize (m_iButtons*BUTTON_WIDTH + BORDER_LEFT + BORDER_RIGHT, BUTTON_HEIGHT + BORDER_TOP + BORDER_BOTTOM); }
  87. void OnUpdateCmdUI (class CFrameWnd*, int) {}
  88. //
  89. // Creation routines
  90. //
  91. void AddButton (UINT iBMPUp, UINT iBMPDn, int iCommandID, BUTTON_TYPE buttonType = TypeNormal);
  92. BOOL Create (LPCTSTR pszWindowName, CWnd *pCParentWnd, UINT uiID);
  93. //
  94. // State management routines
  95. //
  96. void SetButtonState (int iCommandID, STATE_INFO newState, BOOL bRepaint = TRUE);
  97. STATE_INFO GetButtonState (int iCommandID) const;
  98. protected:
  99. ////////////////////////////////////////////////////////
  100. //
  101. // Protected Methods
  102. //
  103. void Paint (void);
  104. void DrawButton (HDC hDC, int iXPos, int iYPos, HBITMAP hBMP);
  105. int ButtonFromPoint (const CPoint &point);
  106. void RegisterFancyToolbarClass (void);
  107. //{{AFX_MSG(CFancyToolbar)
  108. afx_msg void OnPaint();
  109. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  110. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  111. //}}AFX_MSG
  112. DECLARE_MESSAGE_MAP()
  113. ////////////////////////////////////////////////////////
  114. //
  115. // Static Methods
  116. //
  117. static LRESULT CALLBACK fnMessageProc (HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam);
  118. private:
  119. ////////////////////////////////////////////////////////
  120. //
  121. // Private Data Types
  122. //
  123. typedef struct
  124. {
  125. HBITMAP hBMPUp;
  126. HBITMAP hBMPDn;
  127. int iCommandID;
  128. STATE_INFO currentState;
  129. BUTTON_TYPE buttonType;
  130. BOOL bVisible;
  131. } BUTTON_INFO;
  132. ////////////////////////////////////////////////////////
  133. //
  134. // Private Methods
  135. //
  136. BUTTON_INFO m_pButtonArray[10];
  137. int m_iButtons;
  138. int m_iCurrentButton;
  139. };
  140. #endif // __FANCYTOOLBAR_H