soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SScrollbar.h
Go to the documentation of this file.
1/**
2 * Copyright (C) 2014-2050 SOUI团队
3 * All rights reserved.
4 *
5 * @file SScrollBar.h
6 * @brief Scrollbar control
7 * @version v1.0
8 * @author soui
9 * @date 2014-07-08
10 *
11 * Describe Scrollbar control implementation
12 */
13#ifndef __SSCROLLBAR__H__
14#define __SSCROLLBAR__H__
15
16#include <core/SWnd.h>
17#include <core/SScrollBarHandler.h>
18
19SNSBEGIN
20
21/**
22 * @class SScrollBar
23 * @brief Scrollbar control
24 *
25 * Describe This class implements a scrollbar control.
26 */
27class SOUI_EXP SScrollBar
28 : public SWindow
29 , protected IScrollBarHost {
30 DEF_SOBJECT(SWindow, L"scrollbar")
31
32 public:
33 /**
34 * SScrollBar::SScrollBar
35 * @brief Constructor
36 *
37 * Describe Initializes the scrollbar control.
38 */
39 SScrollBar();
40
41 /**
42 * SScrollBar::~SScrollBar
43 * @brief Destructor
44 *
45 * Describe Cleans up the scrollbar control.
46 */
47 virtual ~SScrollBar();
48
49 public:
50 /**
51 * SScrollBar::IsVertical
52 * @brief Checks if the scrollbar is vertical
53 * @return Returns TRUE if the scrollbar is vertical, FALSE otherwise
54 *
55 * Describe Determines the orientation of the scrollbar.
56 */
57 BOOL IsVertical() const;
58
59 /**
60 * SScrollBar::SetPos
61 * @brief Sets the position of the scrollbar
62 * @param int nPos -- New position of the scrollbar
63 * @return Returns the new position of the scrollbar
64 *
65 * Describe Updates the position of the scrollbar thumb.
66 */
67 int SetPos(int nPos);
68
69 /**
70 * SScrollBar::GetPos
71 * @brief Gets the current position of the scrollbar
72 * @return Returns the current position of the scrollbar
73 *
74 * Describe Retrieves the current position of the scrollbar thumb.
75 */
76 int GetPos();
77
78 /**
79 * SScrollBar::GetMax
80 * @brief Gets the maximum position of the scrollbar
81 * @return Returns the maximum position of the scrollbar
82 *
83 * Describe Retrieves the maximum position of the scrollbar thumb.
84 */
85 int GetMax();
86
87 /**
88 * SScrollBar::GetMin
89 * @brief Gets the minimum position of the scrollbar
90 * @return Returns the minimum position of the scrollbar
91 *
92 * Describe Retrieves the minimum position of the scrollbar thumb.
93 */
94 int GetMin();
95
96 protected:
97 STDMETHOD_(CRect, GetScrollBarRect)(CTHIS_ BOOL bVert) SCONST OVERRIDE;
98 STDMETHOD_(ISkinObj *, GetScrollBarSkin)(CTHIS_ BOOL bVert) SCONST OVERRIDE;
99 STDMETHOD_(const SCROLLINFO *, GetScrollBarInfo)(CTHIS_ BOOL bVert) SCONST OVERRIDE;
100 STDMETHOD_(int, GetScrollBarArrowSize)(CTHIS_ BOOL bVert) SCONST OVERRIDE;
101 STDMETHOD_(void, OnScrollUpdatePart)(THIS_ BOOL bVert, int iPart) OVERRIDE;
102 STDMETHOD_(void, OnScrollUpdateThumbTrack)(THIS_ BOOL bVert, int nPos) OVERRIDE;
103 STDMETHOD_(ISwndContainer *, GetScrollBarContainer)(THIS) OVERRIDE;
104 STDMETHOD_(BOOL, IsScrollBarEnable)(THIS_ BOOL bVertical) SCONST OVERRIDE;
105 STDMETHOD_(void, OnScrollCommand)(THIS_ BOOL bVert, int iCmd, int nPos) OVERRIDE;
106 STDMETHOD_(void, OnScrollSetTimer)(THIS_ BOOL bVert, char id, UINT uElapse) OVERRIDE;
107 STDMETHOD_(void, OnScrollKillTimer)(THIS_ BOOL bVert, char id) OVERRIDE;
108 STDMETHOD_(const IInterpolator *, GetScrollInterpolator)(CTHIS) SCONST OVERRIDE;
109 STDMETHOD_(int, GetScrollFadeFrames)(CTHIS) SCONST OVERRIDE;
110 STDMETHOD_(BYTE, GetScrollThumbTrackMinAlpha)(CTHIS) SCONST OVERRIDE;
111
112 protected:
113 /**
114 * SScrollBar::OnInitFinished
115 * @brief Initialization after creation
116 * @param IXmlNode *pNode -- XML node containing initialization data
117 *
118 * Describe Performs additional initialization after the control is created.
119 */
120 virtual void WINAPI OnInitFinished(IXmlNode *pNode);
121
122 /**
123 * SScrollBar::NotifySbCode
124 * @brief Notifies the parent window of scrollbar events
125 * @param int nCode -- Scrollbar notification code
126 * @param int nPos -- Current position of the scrollbar
127 *
128 * Describe Sends notifications to the parent window about scrollbar events.
129 */
130 void NotifySbCode(int nCode, int nPos);
131
132 protected:
133 HRESULT OnAttrVertical(const SStringW &value, BOOL bLoading);
134
135 SOUI_ATTRS_BEGIN()
136 ATTR_SKIN(L"skin", m_pSkin, TRUE) /**< Skin object */
137 ATTR_UINT(L"arrowSize", m_uAllowSize, TRUE) /**< Arrow size */
138 ATTR_INT(L"min", m_si.nMin, TRUE) /**< Minimum position */
139 ATTR_INT(L"max", m_si.nMax, TRUE) /**< Maximum position */
140 ATTR_INT(L"value", m_si.nPos, TRUE) /**< Current position */
141 ATTR_INT(L"page", m_si.nPage, TRUE) /**< Page size */
142 ATTR_CUSTOM(L"vertical", OnAttrVertical) /**< Vertical orientation */
143 ATTR_INT(L"fadeFrames", m_fadeFrames, FALSE) /**< Fade frames */
144 ATTR_INT(L"thumbTrackMinAlpha", m_byThumbTrackMinAlpha, FALSE) /**< Minimum alpha for thumb tracking */
145 ATTR_INTERPOLATOR(L"fadeInterpolator", m_fadeInterpolator, FALSE) /**< Fade interpolator */
146 ATTR_CHAIN_PTR(m_fadeInterpolator, 0) /**< Chain pointer for fade interpolator */
147 SOUI_ATTRS_END()
148
149 protected:
150 /**
151 * SScrollBar::OnPaint
152 * @brief Paints the scrollbar
153 * @param IRenderTarget *pRT -- Rendering target
154 *
155 * Describe Handles the painting of the scrollbar.
156 */
157 void OnPaint(IRenderTarget *pRT);
158
159 /**
160 * SScrollBar::OnLButtonUp
161 * @brief Handles left button up event
162 * @param UINT nFlags -- Virtual key flags
163 * @param CPoint point -- Mouse position
164 *
165 * Describe Handles the left mouse button up event.
166 */
167 void OnLButtonUp(UINT nFlags, CPoint point);
168
169 /**
170 * SScrollBar::OnLButtonDown
171 * @brief Handles left button down event
172 * @param UINT nFlags -- Virtual key flags
173 * @param CPoint point -- Mouse position
174 *
175 * Describe Handles the left mouse button down event.
176 */
177 void OnLButtonDown(UINT nFlags, CPoint point);
178
179 /**
180 * SScrollBar::OnMouseMove
181 * @brief Handles mouse move event
182 * @param UINT nFlags -- Virtual key flags
183 * @param CPoint point -- Mouse position
184 *
185 * Describe Handles the mouse move event.
186 */
187 void OnMouseMove(UINT nFlags, CPoint point);
188
189 /**
190 * SScrollBar::OnTimer
191 * @brief Handles timer event
192 * @param char nIDEvent -- Timer ID
193 *
194 * Describe Handles the timer event.
195 */
196 void OnTimer(char nIDEvent);
197
198 /**
199 * SScrollBar::OnMouseHover
200 * @brief Handles mouse hover event
201 * @param UINT nFlags -- Virtual key flags
202 * @param CPoint ptPos -- Mouse position
203 *
204 * Describe Handles the mouse hover event.
205 */
206 void OnMouseHover(UINT nFlags, CPoint ptPos);
207
208 /**
209 * SScrollBar::OnMouseLeave
210 * @brief Handles mouse leave event
211 *
212 * Describe Handles the mouse leave event.
213 */
214 void OnMouseLeave();
215
216 /**
217 * SScrollBar::OnSetScrollInfo
218 * @brief Handles setting scroll information
219 * @param UINT uMsg -- Message code
220 * @param WPARAM wParam -- Additional message-specific information
221 * @param LPARAM lParam -- Additional message-specific information
222 * @return Returns the result of the message processing
223 *
224 * Describe Handles the setting of scroll information.
225 */
226 LRESULT OnSetScrollInfo(UINT uMsg, WPARAM wParam, LPARAM lParam);
227
228 /**
229 * SScrollBar::OnGetScrollInfo
230 * @brief Handles getting scroll information
231 * @param UINT uMsg -- Message code
232 * @param WPARAM wParam -- Additional message-specific information
233 * @param LPARAM lParam -- Additional message-specific information
234 * @return Returns the result of the message processing
235 *
236 * Describe Handles the retrieval of scroll information.
237 */
238 LRESULT OnGetScrollInfo(UINT uMsg, WPARAM wParam, LPARAM lParam);
239
240 /**
241 * SScrollBar::OnDestroy
242 * @brief Handles destruction of the control
243 *
244 * Describe Cleans up resources when the control is destroyed.
245 */
246 void OnDestroy();
247
248 SOUI_MSG_MAP_BEGIN()
249 MSG_WM_LBUTTONDOWN(OnLButtonDown)
250 MSG_WM_LBUTTONDBLCLK(OnLButtonDown)
251 MSG_WM_LBUTTONUP(OnLButtonUp)
252 MSG_WM_MOUSEMOVE(OnMouseMove)
253 MSG_WM_MOUSELEAVE(OnMouseLeave)
254 MSG_WM_MOUSEHOVER(OnMouseHover)
255 MSG_WM_TIMER_EX(OnTimer)
256 MSG_WM_PAINT_EX(OnPaint)
257 MSG_WM_DESTROY(OnDestroy)
258 MESSAGE_HANDLER_EX(SBM_SETSCROLLINFO, OnSetScrollInfo)
259 MESSAGE_HANDLER_EX(SBM_GETSCROLLINFO, OnGetScrollInfo)
260 SOUI_MSG_MAP_END()
261
262 protected:
263 SAutoRefPtr<ISkinObj> m_pSkin; /**< Skin object */
264 UINT m_uAllowSize; /**< Arrow size */
265
266 SCROLLINFO m_si; /**< Scroll information structure */
267
268 int m_fadeFrames; /**< Number of fade frames */
269 mutable SAutoRefPtr<IInterpolator> m_fadeInterpolator; /**< Fade interpolator */
270 BYTE m_byThumbTrackMinAlpha; /**< Minimum alpha for thumb tracking */
271 SScrollBarHandler m_sbHandler; /**< Scrollbar handler */
272};
273
274SNSEND
275
276#endif // __SSCROLLBAR__H__
SOUI基础DUI窗口模块
Smart pointer class for managing COM-style reference-counted objects.
void OnInitFinished(IXmlNode *xmlNode) OVERRIDE
Definition Sobject.hpp:248
Scrollbar Handler.
LRESULT OnSetScrollInfo(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles setting scroll information.
SScrollBar()
Constructor.
void OnMouseLeave()
Handles mouse leave event.
LRESULT OnGetScrollInfo(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles getting scroll information.
int GetMax()
Gets the maximum position of the scrollbar.
int GetMin()
Gets the minimum position of the scrollbar.
void OnLButtonUp(UINT nFlags, CPoint point)
Handles left button up event.
void OnLButtonDown(UINT nFlags, CPoint point)
Handles left button down event.
void OnMouseHover(UINT nFlags, CPoint ptPos)
Handles mouse hover event.
int m_fadeFrames
Definition SScrollbar.h:268
void OnDestroy()
Handles destruction of the control.
BOOL IsVertical() const
Checks if the scrollbar is vertical.
void OnMouseMove(UINT nFlags, CPoint point)
Handles mouse move event.
int GetPos()
Gets the current position of the scrollbar.
void OnTimer(char nIDEvent)
Handles timer event.
SScrollBarHandler m_sbHandler
Definition SScrollbar.h:271
void OnPaint(IRenderTarget *pRT)
Paints the scrollbar.
SAutoRefPtr< ISkinObj > m_pSkin
Definition SScrollbar.h:263
UINT m_uAllowSize
Definition SScrollbar.h:264
BYTE m_byThumbTrackMinAlpha
Definition SScrollbar.h:270
SCROLLINFO m_si
Definition SScrollbar.h:266
int SetPos(int nPos)
Sets the position of the scrollbar.
SAutoRefPtr< IInterpolator > m_fadeInterpolator
Definition SScrollbar.h:269
void NotifySbCode(int nCode, int nPos)
Notifies the parent window of scrollbar events.
A class representing an ASCII string.
Definition sstringw.h:96
SWindow()
Constructor.
Definition Swnd.cpp:104
Interface for rendering target objects.
Definition SRender-i.h:1440
Interface for scrollbar host.
Interface for Skin Objects.
Definition SSkinobj-i.h:29
SOUI Window Container Interface.
Interface for XML nodes.
Definition sxml-i.h:128