ColorBar.h 7.3 KB

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