soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SRealWnd.h
1#ifndef __SREALWND__H__
2#define __SREALWND__H__
3
4#include <core/SWnd.h>
5#include <interface/SCtrl-i.h>
6#include <proxy/SWindowProxy.h>
7
8//////////////////////////////////////////////////////////////////////////
9// Real Window Control
10// Binding a real window
11//
12// Usage: <realwnd id=xx wndclass="edit" wndname="name" style="00000001" exstyle="00000000"/>
13//
14
15SNSBEGIN
16
17/**
18 * @class SRealWnd
19 * @brief Real Window Control
20 * @details A control that binds a real Windows window.
21 */
22class SOUI_EXP SRealWnd : public TWindowProxy<IRealWnd> {
23 DEF_SOBJECT(SWindow, L"realwnd")
24
25 public:
26 /**
27 * @brief Constructor
28 */
29 SRealWnd();
30
31 /**
32 * @brief Destructor
33 */
34 virtual ~SRealWnd();
35
36 public:
37 /**
38 * @brief Get the class name of the real window
39 * @return Pointer to the class name
40 */
41 STDMETHOD_(const IStringT *, GetRealClassName)(CTHIS) SCONST OVERRIDE
42 {
43 return &m_strClassName;
44 }
45
46 /**
47 * @brief Get the name of the real window
48 * @return Pointer to the window name
49 */
50 STDMETHOD_(const IStringT *, GetRealWindowName)(CTHIS) SCONST OVERRIDE
51 {
52 return &m_strWindowName;
53 }
54
55 /**
56 * @brief Get the style of the real window
57 * @return Window style
58 */
59 STDMETHOD_(DWORD, GetRealStyle)(CTHIS) SCONST OVERRIDE
60 {
61 return m_dwStyle;
62 }
63
64 /**
65 * @brief Get the extended style of the real window
66 * @return Extended window style
67 */
68 STDMETHOD_(DWORD, GetRealStyleEx)(CTHIS) SCONST OVERRIDE
69 {
70 return m_dwExStyle;
71 }
72
73 /**
74 * @brief Get the parameters of the real window
75 * @return Pointer to the XML node containing parameters
76 */
77 STDMETHOD_(IXmlNode *, GetRealParam)(CTHIS) OVERRIDE
78 {
79 return m_xmlParams.Root();
80 }
81
82 /**
83 * @brief Get the handle of the real window
84 * @param bAutoCreate Whether to automatically create the window if it doesn't exist
85 * @return Handle to the real window
86 */
87 STDMETHOD_(HWND, GetRealHwnd)(THIS_ BOOL bAutoCreate = TRUE) OVERRIDE;
88
89 /**
90 * @brief Set the additional data for the real window
91 * @param lpData Pointer to the additional data
92 */
93 STDMETHOD_(void, SetData)(THIS_ LPVOID lpData)
94 {
95 m_lpData = lpData;
96 }
97
98 /**
99 * @brief Get the additional data for the real window
100 * @return Pointer to the additional data
101 */
102 STDMETHOD_(LPVOID, GetData)(THIS)
103 {
104 return m_lpData;
105 }
106
107 SOUI_ATTRS_BEGIN()
108 ATTR_STRINGT(L"wndclass", m_strClassName, FALSE) /**< Class name of the real window */
109 ATTR_STRINGT(L"wndname", m_strWindowName, FALSE) /**< Name of the real window */
110 ATTR_HEX(L"style", m_dwStyle, FALSE) /**< Style of the real window */
111 ATTR_HEX(L"exstyle", m_dwExStyle, FALSE) /**< Extended style of the real window */
112 ATTR_BOOL(L"init", m_bInit, FALSE) /**< Initialization flag */
113 SOUI_ATTRS_END()
114
115 protected:
116 /**
117 * @brief Determine if the control needs to be redrawn when its state changes
118 * @return TRUE if redraw is needed, FALSE otherwise
119 */
120 virtual BOOL NeedRedrawWhenStateChange();
121
122 /**
123 * @brief Initialize the control from an XML node
124 * @param pNode XML node containing initialization parameters
125 * @return TRUE if initialization is successful, FALSE otherwise
126 */
127 virtual BOOL WINAPI InitFromXml(IXmlNode *pNode);
128
129 /**
130 * @brief Handle layout changes
131 * @param rcWnd New window rectangle
132 * @return TRUE if layout is successful, FALSE otherwise
133 */
134 virtual BOOL OnRelayout(const CRect &rcWnd);
135
136 /**
137 * @brief Handle show window event
138 * @param bShow Whether to show the window
139 * @param nStatus Status code
140 */
141 void OnShowWindow(BOOL bShow, UINT nStatus);
142
143 /**
144 * @brief Handle destroy event
145 */
146 void OnDestroy();
147
148 /**
149 * @brief Paint the control
150 * @param pRT Rendering target handle
151 */
153 {
154 // Implementation can be added here if needed
155 }
156
157 /**
158 * @brief Show the real window
159 */
160 void ShowRealWindow();
161
162 /**
163 * @brief Initialize the real window
164 * @return TRUE if initialization is successful, FALSE otherwise
165 */
166 BOOL InitRealWnd();
167
168 /**
169 * @brief Set the position of the real window
170 * @param hRealWnd Handle to the real window
171 * @param prc Rectangle for the window position
172 */
173 void SetRealWndPos(HWND hRealWnd, const CRect *prc);
174
175 SOUI_MSG_MAP_BEGIN()
176 MSG_WM_PAINT_EX(OnPaint)
177 MSG_WM_DESTROY(OnDestroy)
178 MSG_WM_SHOWWINDOW(OnShowWindow)
179 SOUI_MSG_MAP_END()
180
181 protected:
182 SStringT m_strClassName; /**< Class name of the real window */
183 SStringT m_strWindowName; /**< Name of the real window */
184 DWORD m_dwStyle; /**< Style of the real window */
185 DWORD m_dwExStyle; /**< Extended style of the real window */
186 SXmlDoc m_xmlParams; /**< XML document containing parameters */
187
188 BOOL m_bInit; /**< Initialization flag */
189
190 HWND m_hRealWnd; /**< Handle to the real window */
191 LPVOID m_lpData; /**< Pointer to additional data */
192
193 SAutoRefPtr<IRealWndHandler> m_pRealWndHandler; /**< Pointer to the real window handler */
194};
195
196SNSEND
197
198#endif // __SREALWND__H__
SOUI基础DUI窗口模块
Smart pointer class for managing COM-style reference-counted objects.
const IStringT * GetRealClassName() SCONST OVERRIDE
Get the class name of the real window.
Definition SRealWnd.h:41
void OnDestroy()
Handle destroy event.
Definition SRealWnd.cpp:92
SAutoRefPtr< IRealWndHandler > m_pRealWndHandler
Definition SRealWnd.h:193
DWORD GetRealStyle() SCONST OVERRIDE
Get the style of the real window.
Definition SRealWnd.h:59
virtual BOOL NeedRedrawWhenStateChange()
Determine if the control needs to be redrawn when its state changes.
Definition SRealWnd.cpp:69
void OnPaint(IRenderTarget *pRT)
Paint the control.
Definition SRealWnd.h:152
BOOL m_bInit
Definition SRealWnd.h:188
SRealWnd()
Constructor.
Definition SRealWnd.cpp:48
DWORD m_dwExStyle
Definition SRealWnd.h:185
DWORD GetRealStyleEx() SCONST OVERRIDE
Get the extended style of the real window.
Definition SRealWnd.h:68
virtual BOOL WINAPI InitFromXml(IXmlNode *pNode)
Initialize the control from an XML node.
Definition SRealWnd.cpp:101
void SetData(LPVOID lpData)
Set the additional data for the real window.
Definition SRealWnd.h:93
LPVOID m_lpData
Definition SRealWnd.h:191
DWORD m_dwStyle
Definition SRealWnd.h:184
IXmlNode * GetRealParam() OVERRIDE
Get the parameters of the real window.
Definition SRealWnd.h:77
SStringT m_strWindowName
Definition SRealWnd.h:183
SXmlDoc m_xmlParams
Definition SRealWnd.h:186
const IStringT * GetRealWindowName() SCONST OVERRIDE
Get the name of the real window.
Definition SRealWnd.h:50
HWND m_hRealWnd
Definition SRealWnd.h:190
LPVOID GetData()
Get the additional data for the real window.
Definition SRealWnd.h:102
SStringT m_strClassName
Definition SRealWnd.h:182
virtual BOOL OnRelayout(const CRect &rcWnd)
Handle layout changes.
Definition SRealWnd.cpp:143
void OnShowWindow(BOOL bShow, UINT nStatus)
Handle show window event.
Definition SRealWnd.cpp:86
SWindow()
Constructor.
Definition Swnd.cpp:104
Implementation of IXmlDoc.
Definition SXml.h:912
Interface for handling real window operations.
Interface for rendering target objects.
Definition SRender-i.h:1440
Interface for XML nodes.
Definition sxml-i.h:128