soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SScrollBarHandler.h
1#ifndef __SSCROLLBARHANDLER__H__
2#define __SSCROLLBARHANDLER__H__
3
4SNSBEGIN
5
6/**
7 * @struct IScrollBarHost
8 * @brief Interface for scrollbar host.
9 *
10 * Description: Defines the interface for the scrollbar host, which provides necessary methods for scrollbar operations.
11 */
13{
14 enum kSbConst
15 {
16 Timer_Wait = 100,
17 Timer_Go = 101,
18 kTime_Wait = 200,
19 kTime_Go = 100,
20 };
21
22 /**
23 * @brief Gets the rectangle of the scrollbar.
24 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
25 * @return Rectangle of the scrollbar.
26 */
27 STDMETHOD_(CRect, GetScrollBarRect)(CTHIS_ BOOL bVert) SCONST PURE;
28
29 /**
30 * @brief Gets the skin for the scrollbar.
31 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
32 * @return Pointer to the scrollbar skin.
33 */
34 STDMETHOD_(ISkinObj *, GetScrollBarSkin)(CTHIS_ BOOL bVert) SCONST PURE;
35
36 /**
37 * @brief Gets the scroll information for the scrollbar.
38 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
39 * @return Pointer to the scroll information structure.
40 */
41 STDMETHOD_(const SCROLLINFO *, GetScrollBarInfo)(CTHIS_ BOOL bVert) SCONST PURE;
42
43 /**
44 * @brief Gets the arrow size for the scrollbar.
45 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
46 * @return Arrow size.
47 */
48 STDMETHOD_(int, GetScrollBarArrowSize)(CTHIS_ BOOL bVert) SCONST PURE;
49
50 /**
51 * @brief Updates a part of the scrollbar.
52 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
53 * @param iPart Part to update.
54 */
55 STDMETHOD_(void, OnScrollUpdatePart)(THIS_ BOOL bVert, int iPart) PURE;
56
57 /**
58 * @brief Updates the thumb track of the scrollbar.
59 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
60 * @param nPos New position of the thumb.
61 */
62 STDMETHOD_(void, OnScrollUpdateThumbTrack)(THIS_ BOOL bVert, int nPos) PURE;
63
64 /**
65 * @brief Gets the container for the scrollbar.
66 * @return Pointer to the scrollbar container.
67 */
68 STDMETHOD_(ISwndContainer *, GetScrollBarContainer)(THIS) PURE;
69
70 /**
71 * @brief Checks if the scrollbar is enabled.
72 * @param bVertical TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
73 * @return TRUE if the scrollbar is enabled, FALSE otherwise.
74 */
75 STDMETHOD_(BOOL, IsScrollBarEnable)(THIS_ BOOL bVertical) SCONST PURE;
76
77 /**
78 * @brief Handles scroll commands.
79 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
80 * @param iCmd Command identifier.
81 * @param nPos Position for the command.
82 */
83 STDMETHOD_(void, OnScrollCommand)(THIS_ BOOL bVert, int iCmd, int nPos) PURE;
84
85 /**
86 * @brief Sets a timer for the scrollbar.
87 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
88 * @param id Timer identifier.
89 * @param uElapse Elapse time for the timer.
90 */
91 STDMETHOD_(void, OnScrollSetTimer)(THIS_ BOOL bVert, char id, UINT uElapse) PURE;
92
93 /**
94 * @brief Kills a timer for the scrollbar.
95 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
96 * @param id Timer identifier.
97 */
98 STDMETHOD_(void, OnScrollKillTimer)(THIS_ BOOL bVert, char id) PURE;
99
100 /**
101 * @brief Gets the interpolator for the scrollbar.
102 * @return Pointer to the interpolator.
103 */
104 STDMETHOD_(const IInterpolator *, GetScrollInterpolator)(CTHIS) SCONST PURE;
105
106 /**
107 * @brief Gets the number of fade frames for the scrollbar.
108 * @return Number of fade frames.
109 */
110 STDMETHOD_(int, GetScrollFadeFrames)(CTHIS) SCONST PURE;
111
112 /**
113 * @brief Gets the minimum alpha value for the scrollbar thumb track.
114 * @return Minimum alpha value.
115 */
116 STDMETHOD_(BYTE, GetScrollThumbTrackMinAlpha)(CTHIS) SCONST PURE;
117};
118
119/**
120 * @class SScrollBarHandler
121 * @brief Scrollbar Handler
122 *
123 * Description: Manages the behavior and appearance of scrollbars.
124 */
125class SOUI_EXP SScrollBarHandler : public ITimelineHandler {
126 private:
127 SScrollBarHandler(const SScrollBarHandler &); // Private copy constructor
128 const SScrollBarHandler &operator=(const SScrollBarHandler &); // Private assignment operator
129
130 public:
131 enum
132 {
133 kSbRail = 100,
134 };
135
136 /**
137 * @brief Constructor for SScrollBarHandler.
138 * @param pCB Pointer to the scrollbar host.
139 * @param bVert TRUE for vertical scrollbar, FALSE for horizontal scrollbar.
140 */
141 SScrollBarHandler(IScrollBarHost *pCB, bool bVert = false);
142
143 public:
144 /**
145 * @brief Gets the rectangle of a scrollbar part.
146 * @param iPart Part identifier.
147 * @return Rectangle of the part.
148 */
149 CRect GetPartRect(int iPart) const;
150
151 /**
152 * @brief Gets the hit part of the scrollbar.
153 * @return Hit part identifier.
154 */
155 int GetHitPart() const;
156
157 /**
158 * @brief Gets the clicked part of the scrollbar.
159 * @return Clicked part identifier.
160 */
161 int GetClickPart() const;
162
163 /**
164 * @brief Checks if the scrollbar is vertical.
165 * @return TRUE if vertical, FALSE if horizontal.
166 */
167 bool IsVertical() const;
168
169 /**
170 * @brief Sets the orientation of the scrollbar.
171 * @param bVert TRUE for vertical, FALSE for horizontal.
172 */
173 void SetVertical(bool bVert);
174
175 /**
176 * @brief Handles mouse hover events.
177 * @param pt Point where the mouse is hovering.
178 */
179 void OnMouseHover(CPoint pt);
180
181 /**
182 * @brief Handles mouse down events.
183 * @param pt Point where the mouse button was pressed.
184 * @return TRUE if handled, FALSE otherwise.
185 */
186 bool OnMouseDown(CPoint pt);
187
188 /**
189 * @brief Handles mouse up events.
190 * @param pt Point where the mouse button was released.
191 */
192 void OnMouseUp(CPoint pt);
193
194 /**
195 * @brief Handles mouse move events.
196 * @param pt Point where the mouse moved.
197 */
198 void OnMouseMove(CPoint pt);
199
200 /**
201 * @brief Handles mouse leave events.
202 */
203 void OnMouseLeave();
204
205 /**
206 * @brief Draws a part of the scrollbar.
207 * @param pRT Pointer to the render target.
208 * @param iPart Part identifier to draw.
209 */
210 void OnDraw(IRenderTarget *pRT, int iPart) const;
211
212 /**
213 * @brief Handles timer events.
214 * @param id Timer identifier.
215 */
216 void OnTimer(char id);
217
218 /**
219 * @brief Handles destruction events.
220 */
221 void OnDestroy();
222
223 /**
224 * @brief Performs hit testing on the scrollbar.
225 * @param pt Point to test.
226 * @return Hit part identifier.
227 */
228 int HitTest(CPoint pt) const;
229
230 /**
231 * @brief Handles container change events.
232 * @param pOldContainer Pointer to the old container.
233 * @param pNewContainer Pointer to the new container.
234 */
235 void OnContainerChanged(ISwndContainer *pOldContainer, ISwndContainer *pNewContainer);
236
237 protected:
238 /**
239 * @brief Gets the container for the scrollbar.
240 * @return Pointer to the scrollbar container.
241 */
243
244 /**
245 * @brief Gets the interpolator for the scrollbar.
246 * @return Pointer to the interpolator.
247 */
248 const IInterpolator *GetInterpolator() const;
249
250 /**
251 * @brief Gets the alpha value for a part of the scrollbar.
252 * @param iPart Part identifier.
253 * @return Alpha value.
254 */
255 BYTE GetAlpha(int iPart) const;
256
257 /**
258 * @brief Gets the fade step for the scrollbar.
259 * @return Fade step.
260 */
261 int GetFadeStep() const;
262
263 /**
264 * @brief Gets the state of a part of the scrollbar.
265 * @param iPart Part identifier.
266 * @return State of the part.
267 */
268 DWORD GetPartState(int iPart) const;
269
270 protected:
271 /**
272 * @brief Handles the next frame in the timeline.
273 */
274 STDMETHOD_(void, OnNextFrame)(THIS_) OVERRIDE;
275
276 private:
277 enum FADEMODE
278 {
279 FADEOUT = -1,
280 FADE_STOP = 0,
281 FADEIN = 1,
282 };
283
284 IScrollBarHost *m_pSbHost; // Pointer to the scrollbar host
285 bool m_bVert; // TRUE if vertical, FALSE if horizontal
286 int m_iFrame; // Current frame index
287 FADEMODE m_fadeMode; // Fade mode
288 int m_iHitPart; // Hit part identifier
289 int m_iClickPart; // Clicked part identifier
290 CPoint m_ptClick; // Click point
291 CPoint m_ptCursor; // Cursor point
292 int m_nClickPos; // Click position
293};
294
295SNSEND
296
297#endif // __SSCROLLBARHANDLER__H__
void OnMouseLeave()
Handles mouse leave events.
CRect GetPartRect(int iPart) const
Gets the rectangle of a scrollbar part.
const IInterpolator * GetInterpolator() const
Gets the interpolator for the scrollbar.
void OnContainerChanged(ISwndContainer *pOldContainer, ISwndContainer *pNewContainer)
Handles container change events.
void OnDestroy()
Handles destruction events.
int GetClickPart() const
Gets the clicked part of the scrollbar.
int HitTest(CPoint pt) const
Performs hit testing on the scrollbar.
void OnNextFrame() OVERRIDE
Handles the next frame in the timeline.
void OnMouseHover(CPoint pt)
Handles mouse hover events.
void SetVertical(bool bVert)
Sets the orientation of the scrollbar.
DWORD GetPartState(int iPart) const
Gets the state of a part of the scrollbar.
int GetHitPart() const
Gets the hit part of the scrollbar.
void OnDraw(IRenderTarget *pRT, int iPart) const
Draws a part of the scrollbar.
void OnTimer(char id)
Handles timer events.
void OnMouseUp(CPoint pt)
Handles mouse up events.
bool OnMouseDown(CPoint pt)
Handles mouse down events.
ISwndContainer * GetContainer()
Gets the container for the scrollbar.
bool IsVertical() const
Checks if the scrollbar is vertical.
BYTE GetAlpha(int iPart) const
Gets the alpha value for a part of the scrollbar.
void OnMouseMove(CPoint pt)
Handles mouse move events.
int GetFadeStep() const
Gets the fade step for the scrollbar.
Interface for rendering target objects.
Definition SRender-i.h:1440
Interface for scrollbar host.
BYTE GetScrollThumbTrackMinAlpha() SCONST PURE
Gets the minimum alpha value for the scrollbar thumb track.
void OnScrollKillTimer(BOOL bVert, char id) PURE
Kills a timer for the scrollbar.
int GetScrollFadeFrames() SCONST PURE
Gets the number of fade frames for the scrollbar.
CRect GetScrollBarRect(BOOL bVert) SCONST PURE
Gets the rectangle of the scrollbar.
void OnScrollSetTimer(BOOL bVert, char id, UINT uElapse) PURE
Sets a timer for the scrollbar.
void OnScrollUpdateThumbTrack(BOOL bVert, int nPos) PURE
Updates the thumb track of the scrollbar.
void OnScrollUpdatePart(BOOL bVert, int iPart) PURE
Updates a part of the scrollbar.
const SCROLLINFO * GetScrollBarInfo(BOOL bVert) SCONST PURE
Gets the scroll information for the scrollbar.
int GetScrollBarArrowSize(BOOL bVert) SCONST PURE
Gets the arrow size for the scrollbar.
ISkinObj * GetScrollBarSkin(BOOL bVert) SCONST PURE
Gets the skin for the scrollbar.
ISwndContainer * GetScrollBarContainer() PURE
Gets the container for the scrollbar.
BOOL IsScrollBarEnable(BOOL bVertical) SCONST PURE
Checks if the scrollbar is enabled.
const IInterpolator * GetScrollInterpolator() SCONST PURE
Gets the interpolator for the scrollbar.
void OnScrollCommand(BOOL bVert, int iCmd, int nPos) PURE
Handles scroll commands.
Interface for Skin Objects.
Definition SSkinobj-i.h:29
SOUI Window Container Interface.
时间轴处理接口