soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SCaret.h
1#ifndef __SCARET__H__
2#define __SCARET__H__
3
4#include <interface/scaret-i.h>
5#include <interface/sinterpolator-i.h>
6#include <interface/STimelineHandler-i.h>
7#include <sobject/Sobject.hpp>
8
9SNSBEGIN
10
11/**
12 * @class SCaret
13 * @brief Caret management class
14 *
15 * @details This class manages the caret, including its initialization, positioning, visibility,
16 * drawing, and animation.
17 */
18class SOUI_EXP SCaret
19 : public TObjRefImpl<SObjectImpl<ICaret>>
20 , public ITimelineHandler {
21 DEF_SOBJECT(SObjectImpl<ICaret>, L"caret")
22
23 public:
24 /**
25 * @brief Constructor
26 * @param pContainer Pointer to the container window
27 *
28 * @details Initializes the caret with a container window.
29 */
30 SCaret(ISwndContainer *pContainer);
31
32 /**
33 * @brief Destructor
34 *
35 * @details Cleans up the caret object.
36 */
37 ~SCaret();
38
39 public:
40 // Methods inherited from ICaret
41
42 /**
43 * @brief Initializes the caret
44 * @param hBmp Handle to the bitmap for the caret
45 * @param nWid Width of the caret
46 * @param nHei Height of the caret
47 * @return TRUE if successful, otherwise FALSE
48 *
49 * @details Initializes the caret with a bitmap and specified dimensions.
50 */
51 STDMETHOD_(BOOL, Init)(THIS_ HBITMAP hBmp, int nWid, int nHei) OVERRIDE;
52
53 /**
54 * @brief Sets the position of the caret
55 * @param x X-coordinate of the caret
56 * @param y Y-coordinate of the caret
57 *
58 * @details Sets the position of the caret to the specified coordinates.
59 */
60 STDMETHOD_(void, SetPosition)(THIS_ int x, int y) OVERRIDE;
61
62 /**
63 * @brief Sets the visibility of the caret
64 * @param bVisible TRUE to make the caret visible, FALSE to hide it
65 * @param owner Handle to the owner window
66 * @return TRUE if successful, otherwise FALSE
67 *
68 * @details Sets the visibility of the caret and associates it with the owner window.
69 */
70 STDMETHOD_(BOOL, SetVisible)(THIS_ BOOL bVisible, SWND owner) OVERRIDE;
71
72 /**
73 * @brief Checks if the caret is visible
74 * @return TRUE if the caret is visible, otherwise FALSE
75 *
76 * @details Returns the visibility status of the caret.
77 */
78 STDMETHOD_(BOOL, IsVisible)(THIS) SCONST OVERRIDE;
79
80 /**
81 * @brief Draws the caret
82 * @param pRT Pointer to the rendering target
83 *
84 * @details Draws the caret on the specified rendering target.
85 */
86 STDMETHOD_(void, Draw)(THIS_ IRenderTarget *pRT) OVERRIDE;
87
88 /**
89 * @brief Gets the rectangle of the caret
90 * @return Rectangle of the caret
91 *
92 * @details Returns the bounding rectangle of the caret.
93 */
94 STDMETHOD_(RECT, GetRect)(THIS) SCONST OVERRIDE;
95
96 public:
97 // Method inherited from ITimelineHandler
98
99 /**
100 * @brief Handles the next frame in the timeline
101 *
102 * @details Updates the caret's state for the next frame, handling animation if enabled.
103 */
104 STDMETHOD_(void, OnNextFrame)(THIS_) OVERRIDE;
105
106 public:
107 SOUI_ATTRS_BEGIN()
108 ATTR_BOOL(L"animate", m_bAniCaret, FALSE)
109 ATTR_COLOR(L"color", m_crCaret, FALSE)
110 ATTR_INT(L"fadeTime", m_nAniFrames, FALSE)
111 ATTR_INT(L"showTime", m_nShowFrames, FALSE)
112 ATTR_INTERPOLATOR(L"interpolator", m_AniInterpolator, FALSE)
113 ATTR_CHAIN_PTR(m_AniInterpolator, 0)
114 SOUI_ATTRS_END()
115
116 protected:
117 /**
118 * @brief Invalidates the caret area
119 *
120 * @details Invalidates the area where the caret is drawn to trigger a redraw.
121 */
122 void Invalidate();
123
124 protected:
125 BOOL m_bVisible; /**< TRUE if the caret is currently visible. */
126 CPoint m_ptCaret; /**< Position of the caret. */
127 SAutoRefPtr<IBitmapS> m_bmpCaret; /**< Bitmap representing the caret. */
128 bool m_bDrawCaret; /**< TRUE if the caret is currently drawing. */
129 int m_iFrame; /**< Current frame index for animation. */
130 BYTE m_byAlpha; /**< Alpha value for caret transparency. */
131
132 BOOL m_bAniCaret; /**< TRUE if the caret has animation enabled. */
133 COLORREF m_crCaret; /**< Color of the caret. */
134 int m_nAniFrames; /**< Number of frames for fade animation. */
135 int m_nShowFrames; /**< Number of frames for show/hide animation. */
136 SAutoRefPtr<IInterpolator> m_AniInterpolator; /**< Interpolator for caret animation. */
137 ISwndContainer *m_pContainer; /**< Pointer to the container window. */
138 SWND m_hOwner; /**< Handle to the owner window. */
139};
140
141SNSEND
142
143#endif // __SCARET__H__
Smart pointer class for managing COM-style reference-counted objects.
bool m_bDrawCaret
Definition SCaret.h:128
void Draw(IRenderTarget *pRT) OVERRIDE
Draws the caret.
Definition SCaret.cpp:66
CPoint m_ptCaret
Definition SCaret.h:126
COLORREF m_crCaret
Definition SCaret.h:133
SAutoRefPtr< IInterpolator > m_AniInterpolator
Definition SCaret.h:136
ISwndContainer * m_pContainer
Definition SCaret.h:137
int m_iFrame
Definition SCaret.h:129
SCaret(ISwndContainer *pContainer)
Constructor.
Definition SCaret.cpp:9
BOOL m_bAniCaret
Definition SCaret.h:132
void OnNextFrame() OVERRIDE
Handles the next frame in the timeline.
Definition SCaret.cpp:78
BOOL SetVisible(BOOL bVisible, SWND owner) OVERRIDE
Sets the visibility of the caret.
Definition SCaret.cpp:134
BOOL m_bVisible
Definition SCaret.h:125
SWND m_hOwner
Definition SCaret.h:138
BYTE m_byAlpha
Definition SCaret.h:130
SAutoRefPtr< IBitmapS > m_bmpCaret
Definition SCaret.h:127
BOOL IsVisible() SCONST OVERRIDE
Checks if the caret is visible.
Definition SCaret.cpp:153
int m_nAniFrames
Definition SCaret.h:134
void Invalidate()
Invalidates the caret area.
Definition SCaret.cpp:166
BOOL Init(HBITMAP hBmp, int nWid, int nHei) OVERRIDE
Initializes the caret.
Definition SCaret.cpp:29
RECT GetRect() SCONST OVERRIDE
Gets the rectangle of the caret.
Definition SCaret.cpp:158
void SetPosition(int x, int y) OVERRIDE
Sets the position of the caret.
Definition SCaret.cpp:120
int m_nShowFrames
Definition SCaret.h:135
Interface for rendering target objects.
Definition SRender-i.h:1440
SOUI Window Container Interface.
时间轴处理接口