soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SSpinButtonCtrl.h
Go to the documentation of this file.
1/**
2 * @file SSpinButtonCtrl.h
3 * @brief Definition of the SSpinButtonCtrl class.
4 */
5
6#ifndef __SSPINBUTTONCTRL__H__
7#define __SSPINBUTTONCTRL__H__
8
9#include <core/SWnd.h>
10#include <interface/SCtrl-i.h>
11#include <proxy/SWindowProxy.h>
12
13SNSBEGIN
14
15/**
16 * @class SSpinButtonCtrl
17 * @brief A spin button control class derived from TWindowProxy<ISpinButtonCtrl>.
18 *
19 * This class represents a spin button control that can be used to increase or decrease a value within a specified range.
20 */
21class SOUI_EXP SSpinButtonCtrl : public TWindowProxy<ISpinButtonCtrl> {
22 /**
23 * @brief Define the SObject type and name, base class is SWindow, control name is spinButton.
24 */
25 DEF_SOBJECT(SWindow, L"spinButton")
26
27 public:
28 /**
29 * @brief Constructor for SSpinButtonCtrl.
30 */
31 SSpinButtonCtrl(void);
32
33 /**
34 * @brief Destructor for SSpinButtonCtrl.
35 */
36 ~SSpinButtonCtrl(void);
37
38 /**
39 * @brief Retrieves the buddy window associated with the spin button.
40 * @return Pointer to the buddy SWindow object.
41 */
42 SWindow *GetBuddy() const;
43
44 public:
45 /**
46 * @brief Sets the current value of the spin button.
47 * @param nValue The new value to set.
48 */
49 STDMETHOD_(void, SetValue)(THIS_ int nValue) OVERRIDE;
50
51 /**
52 * @brief Sets the range of values for the spin button.
53 * @param nMin The minimum value of the range.
54 * @param nMax The maximum value of the range.
55 */
56 STDMETHOD_(void, SetRange)(THIS_ int nMin, int nMax) OVERRIDE;
57
58 /**
59 * @brief Sets the step size for the spin button.
60 * @param nStep The step size to use when incrementing or decrementing the value.
61 */
62 STDMETHOD_(void, SetStep)(THIS_ UINT nStep) OVERRIDE;
63
64 /**
65 * @brief Retrieves the current value of the spin button.
66 * @return The current value of the spin button.
67 */
68 STDMETHOD_(int, GetValue)(THIS) SCONST OVERRIDE;
69
70 /**
71 * @brief Retrieves the buddy window interface associated with the spin button.
72 * @return Pointer to the buddy IWindow interface.
73 */
74 STDMETHOD_(IWindow *, GetIBuddy)(THIS) SCONST OVERRIDE;
75
76 protected:
77 /**
78 * @brief Calculates the desired size of the control.
79 * @param psz Pointer to the SIZE structure to receive the desired size.
80 * @param nParentWid Width of the parent window.
81 * @param nParentHei Height of the parent window.
82 */
83 STDMETHOD_(void, GetDesiredSize)(THIS_ SIZE *psz, int nParentWid, int nParentHei) OVERRIDE;
84
85 /**
86 * @brief Determines whether the control needs to be redrawn when its state changes.
87 * @return TRUE if the control needs to be redrawn, otherwise FALSE.
88 */
89 virtual BOOL NeedRedrawWhenStateChange() OVERRIDE
90 {
91 return TRUE;
92 }
93
94 /**
95 * @brief Handles colorization of the control.
96 * @param cr Color reference for colorization.
97 */
98 virtual void OnColorize(COLORREF cr);
99
100 protected:
101 /**
102 * @brief Handles value change events.
103 * @param bInit Flag indicating if the change is during initialization.
104 */
105 void OnValueChanged(bool bInit = false);
106
107 /**
108 * @brief Handles scale change events.
109 * @param scale The new scale value.
110 */
111 void OnScaleChanged(int scale);
112
113 /**
114 * @brief Handles left mouse button down events.
115 * @param nFlags Flags associated with the mouse event.
116 * @param point The position of the mouse cursor.
117 */
118 void OnLButtonDown(UINT nFlags, CPoint point);
119
120 /**
121 * @brief Handles left mouse button up events.
122 * @param nFlags Flags associated with the mouse event.
123 * @param point The position of the mouse cursor.
124 */
125 void OnLButtonUp(UINT nFlags, CPoint point);
126
127 /**
128 * @brief Handles mouse move events.
129 * @param nFlags Flags associated with the mouse event.
130 * @param point The position of the mouse cursor.
131 */
132 void OnMouseMove(UINT nFlags, CPoint point);
133
134 /**
135 * @brief Handles paint events.
136 * @param pRT Pointer to the render target.
137 */
138 void OnPaint(IRenderTarget *pRT);
139
140 /**
141 * @brief Handles timer events.
142 * @param cTimerId Identifier for the timer.
143 */
144 void OnTimer(char cTimerId);
145
146 /**
147 * @brief Handles buddy change events.
148 * @param pEvt Pointer to the event arguments.
149 * @return TRUE if the event was handled, otherwise FALSE.
150 */
151 BOOL OnBuddyChange(IEvtArgs *pEvt);
152
153 /**
154 * @brief Handles creation events.
155 * @param lp Create structure.
156 * @return Result of the creation process.
157 */
158 int OnCreate(void *);
159
160 /**
161 * @brief Handles click events.
162 */
163 void OnClick();
164
165 /**
166 * @brief Maps messages to handler functions.
167 */
168 SOUI_MSG_MAP_BEGIN()
169 MSG_WM_CREATE(OnCreate)
170 MSG_WM_LBUTTONDOWN(OnLButtonDown)
171 MSG_WM_LBUTTONDBLCLK(OnLButtonDown)
172 MSG_WM_MOUSEMOVE(OnMouseMove)
173 MSG_WM_LBUTTONUP(OnLButtonUp)
174 MSG_WM_PAINT_EX(OnPaint)
175 MSG_WM_TIMER_EX(OnTimer)
176 SOUI_MSG_MAP_END()
177
178 protected:
179 /**
180 * @brief Handles attribute value changes.
181 * @param strValue The new attribute value.
182 * @param bLoading Flag indicating if the change is during loading.
183 * @return Result of the attribute change process.
184 */
185 HRESULT OnAttrValue(const SStringW &strValue, BOOL bLoading);
186
187 /**
188 * @brief Maps attributes to member variables.
189 */
190 SOUI_ATTRS_BEGIN()
191 ATTR_INT(L"max", m_nMax, FALSE)
192 ATTR_INT(L"min", m_nMin, FALSE)
193 ATTR_CUSTOM(L"value", OnAttrValue)
194 ATTR_UINT(L"step", m_uStep, FALSE)
195 ATTR_INT(L"circle", m_bCircle, FALSE)
196 ATTR_STRINGW(L"buddy", m_strBuddy, FALSE)
197 ATTR_SKIN(L"upskin", m_pUpSkin, TRUE)
198 ATTR_SKIN(L"downSkin", m_pDownSkin, TRUE)
199 SOUI_ATTRS_END()
200
201 protected:
202 int m_nMax; /**< Maximum value of the spin button. */
203 int m_nMin; /**< Minimum value of the spin button. */
204 int m_nValue; /**< Current value of the spin button. */
205 UINT m_uStep; /**< Step size for incrementing or decrementing the value. */
206 BOOL m_bCircle; /**< Flag indicating if the spin button is circular. */
207 SStringW m_strBuddy; /**< Buddy window identifier. */
208
209 SAutoRefPtr<ISkinObj> m_pUpSkin; /**< Skin object for the up button. */
210 SAutoRefPtr<ISkinObj> m_pDownSkin; /**< Skin object for the down button. */
211
212 /**
213 * @enum ActionButton
214 * @brief Enumeration for action buttons.
215 */
217 {
218 ACTION_NULL = -1, /**< No action. */
219 ACTION_UP, /**< Up action. */
220 ACTION_DOWN /**< Down action. */
221 };
222 ActionButton m_iActionBtn; /**< Current action button. */
223};
224
225SNSEND
226
227#endif // __SSPINBUTTONCTRL__H__
SOUI基础DUI窗口模块
Smart pointer class for managing COM-style reference-counted objects.
HRESULT OnAttrValue(const SStringW &strValue, BOOL bLoading)
Maps messages to handler functions.
void SetStep(UINT nStep) OVERRIDE
Sets the step size for the spin button.
SAutoRefPtr< ISkinObj > m_pDownSkin
SAutoRefPtr< ISkinObj > m_pUpSkin
ActionButton m_iActionBtn
int GetValue() SCONST OVERRIDE
Retrieves the current value of the spin button.
SSpinButtonCtrl(void)
Define the SObject type and name, base class is SWindow, control name is spinButton.
SWindow * GetBuddy() const
Retrieves the buddy window associated with the spin button.
void SetRange(int nMin, int nMax) OVERRIDE
Sets the range of values for the spin button.
ActionButton
Enumeration for action buttons.
IWindow * GetIBuddy() SCONST OVERRIDE
Retrieves the buddy window interface associated with the spin button.
void SetValue(int nValue) OVERRIDE
Sets the current value of the spin button.
virtual BOOL NeedRedrawWhenStateChange() OVERRIDE
Determines whether the control needs to be redrawn when its state changes.
void GetDesiredSize(SIZE *psz, int nParentWid, int nParentHei) OVERRIDE
Calculates the desired size of the control.
A class representing an ASCII string.
Definition sstringw.h:96
void OnMouseMove(UINT nFlags, CPoint pt)
Handles the mouse move event.
Definition Swnd.cpp:2131
void OnPaint(IRenderTarget *pRT)
Handles the painting of the window.
Definition Swnd.cpp:1785
virtual void OnScaleChanged(int scale)
Called when the scale of the window changes.
Definition Swnd.cpp:3271
int OnCreate(LPVOID)
Handles the creation of the window.
Definition Swnd.cpp:1654
void OnLButtonUp(UINT nFlags, CPoint pt)
Handles the left mouse button up event.
Definition Swnd.cpp:2105
SWindow()
Constructor.
Definition Swnd.cpp:104
void OnLButtonDown(UINT nFlags, CPoint pt)
Handles the left mouse button down event.
Definition Swnd.cpp:2092
virtual void OnColorize(COLORREF cr)
Adjusts the color tone of the window.
Definition Swnd.cpp:3154
Interface for rendering target objects.
Definition SRender-i.h:1440
Interface for Skin Objects.
Definition SSkinobj-i.h:29