ColorBar.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. #if !defined(AFX_COLORBAR_H__D1243F40_D4D2_11D2_8DDF_00104B6FD9E3__INCLUDED_)
  19. #define AFX_COLORBAR_H__D1243F40_D4D2_11D2_8DDF_00104B6FD9E3__INCLUDED_
  20. #if _MSC_VER >= 1000
  21. #pragma once
  22. #endif // _MSC_VER >= 1000
  23. // ColorBar.h : header file
  24. //
  25. /////////////////////////////////////////////////////////////////////////////
  26. //
  27. // Constants
  28. //
  29. const int MAX_COLOR_POINTS = 15;
  30. //
  31. // Window styles
  32. //
  33. #define CBRS_SUNKEN 0x00000001
  34. #define CBRS_RAISED 0x00000002
  35. #define CBRS_FRAME 0x00000004
  36. #define CBRS_FRAME_MASK CBRS_FRAME | CBRS_RAISED | CBRS_SUNKEN
  37. #define CBRS_HORZ 0x00000008
  38. #define CBRS_VERT 0x00000010
  39. #define CBRS_HAS_SEL 0x00000020
  40. #define CBRS_SHOW_FRAMES 0x00000040
  41. #define CBRS_PAINT_GRAPH 0x00000080
  42. //
  43. // Window messages and notifications
  44. //
  45. #define CBRN_MOVED_POINT 0x0001
  46. #define CBRN_MOVING_POINT 0x0002
  47. #define CBRN_DBLCLK_POINT 0x0003
  48. #define CBRN_SEL_CHANGED 0x0004
  49. #define CBRN_DEL_POINT 0x0005
  50. #define CBRN_DELETED_POINT 0x0006
  51. #define CBRN_INSERTED_POINT 0x0007
  52. #define CBRM_GETCOLOR (WM_USER+101)
  53. #define CBRM_SETCOLOR ( WM_USER+102)
  54. //
  55. // Point styles
  56. //
  57. #define POINT_VISIBLE 0x00000001
  58. #define POINT_CAN_MOVE 0x00000002
  59. //
  60. // Return values for WM_NOTIFY
  61. //
  62. #define STOP_EVENT 0x00000077
  63. /////////////////////////////////////////////////////////////////////////////
  64. //
  65. // Structures
  66. //
  67. // Structure used to send notifications via WM_NOTIFY
  68. typedef struct
  69. {
  70. NMHDR hdr;
  71. int key_index;
  72. float red;
  73. float green;
  74. float blue;
  75. float position;
  76. } CBR_NMHDR;
  77. /////////////////////////////////////////////////////////////////////////////
  78. //
  79. // ColorBarClass
  80. //
  81. class ColorBarClass : public CWnd
  82. {
  83. // Construction
  84. public:
  85. ColorBarClass();
  86. // Attributes
  87. public:
  88. // Operations
  89. public:
  90. // Overrides
  91. // ClassWizard generated virtual function overrides
  92. //{{AFX_VIRTUAL(ColorBarClass)
  93. public:
  94. virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
  95. //}}AFX_VIRTUAL
  96. // Implementation
  97. public:
  98. virtual ~ColorBarClass();
  99. // Generated message map functions
  100. protected:
  101. //{{AFX_MSG(ColorBarClass)
  102. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  103. afx_msg void OnSize(UINT nType, int cx, int cy);
  104. afx_msg void OnPaint();
  105. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  106. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  107. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  108. afx_msg void OnKillFocus(CWnd* pNewWnd);
  109. afx_msg void OnSetFocus(CWnd* pOldWnd);
  110. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  111. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  112. //}}AFX_MSG
  113. DECLARE_MESSAGE_MAP()
  114. friend LRESULT WINAPI fnColorBarProc (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
  115. public:
  116. /////////////////////////////////////////////////////////////////////////
  117. //
  118. // Public methods
  119. //
  120. bool Insert_Point (int index, float position, float red, float green, float blue, DWORD flags = POINT_VISIBLE | POINT_CAN_MOVE);
  121. bool Insert_Point (CPoint point, DWORD flags = POINT_VISIBLE | POINT_CAN_MOVE);
  122. bool Modify_Point (int index, float position, float red, float green, float blue, DWORD flags = POINT_VISIBLE | POINT_CAN_MOVE);
  123. bool Set_User_Data (int index, DWORD data);
  124. DWORD Get_User_Data (int index);
  125. bool Set_Graph_Percent (int index, float percent);
  126. float Get_Graph_Percent (int index);
  127. bool Delete_Point (int index);
  128. void Clear_Points (void);
  129. int Get_Point_Count (void) const { return m_iColorPoints; }
  130. bool Get_Point (int index, float *position, float *red, float *green, float *blue);
  131. int Marker_From_Point (CPoint point);
  132. void Set_Selection_Pos (float pos);
  133. float Get_Selection_Pos (void) const { return m_SelectionPos; }
  134. void Get_Color (float position, float *red, float *green, float *blue);
  135. void Get_Range (float &min, float &max) const { min = m_MinPos; max = m_MaxPos; }
  136. void Set_Range (float min, float max);
  137. void Set_Redraw (bool redraw = true);
  138. LRESULT Send_Notification (int code, int key);
  139. //////////////////////////////////////////////////////////////////////////
  140. // Static members
  141. //////////////////////////////////////////////////////////////////////////
  142. static ColorBarClass *Get_Color_Bar (HWND window_handle) { return (ColorBarClass *)::GetProp (window_handle, "CLASSPOINTER"); }
  143. protected:
  144. /////////////////////////////////////////////////////////////////////////
  145. //
  146. // Protected data types
  147. //
  148. typedef struct
  149. {
  150. float PosPercent;
  151. int StartPos;
  152. int EndPos;
  153. float StartGraphPercent;
  154. float GraphPercentInc;
  155. float StartRed;
  156. float StartGreen;
  157. float StartBlue;
  158. float RedInc;
  159. float GreenInc;
  160. float BlueInc;
  161. DWORD user_data;
  162. int flags;
  163. } COLOR_POINT;
  164. /////////////////////////////////////////////////////////////////////////
  165. //
  166. // Protected methods
  167. //
  168. void Paint_DIB (void);
  169. void Create_Bitmap (void);
  170. void Free_Bitmap (void);
  171. void Free_Marker_Bitmap (void);
  172. void Paint_Bar_Horz (int x_pos, int y_pos, int width, int height, UCHAR *pbits);
  173. void Paint_Bar_Vert (int x_pos, int y_pos, int width, int height, UCHAR *pbits);
  174. void Update_Point_Info (void);
  175. void Load_Key_Frame_BMP (void);
  176. void Paint_Key_Frame (int x_pos, int y_pos);
  177. void Paint_Screen (HDC hwnd_dc);
  178. void Get_Selection_Rectangle (CRect &rect);
  179. void Move_Selection (CPoint point, bool send_notify = true);
  180. void Move_Selection (float new_pos, bool send_notify = true);
  181. void Repaint (void);
  182. private:
  183. /////////////////////////////////////////////////////////////////////////
  184. //
  185. // Private member data
  186. //
  187. HBITMAP m_hBitmap;
  188. HBITMAP m_KeyFrameDIB;
  189. HDC m_hMemDC;
  190. UCHAR * m_pBits;
  191. UCHAR * m_pKeyFrameBits;
  192. int m_iColorWidth;
  193. int m_iColorHeight;
  194. int m_iBMPWidth;
  195. int m_iBMPHeight;
  196. int m_iMarkerWidth;
  197. int m_iMarkerHeight;
  198. int m_iScanlineSize;
  199. int m_iColorPoints;
  200. float m_MinPos;
  201. float m_MaxPos;
  202. COLOR_POINT m_ColorPoints[MAX_COLOR_POINTS];
  203. CRect m_ColorArea;
  204. int m_iCurrentKey;
  205. bool m_bMoving;
  206. bool m_bMoved;
  207. bool m_bRedraw;
  208. float m_SelectionPos;
  209. };
  210. /////////////////////////////////////////////////////////////////////////////
  211. //{{AFX_INSERT_LOCATION}}
  212. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  213. #endif // !defined(AFX_COLORBAR_H__D1243F40_D4D2_11D2_8DDF_00104B6FD9E3__INCLUDED_)