soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SHostWnd.h
1//////////////////////////////////////////////////////////////////////////
2// Class Name: SHostWnd
3// Description: Real Container of SWindow
4//////////////////////////////////////////////////////////////////////////
5
6#ifndef __SHOSTWND__H__
7#define __SHOSTWND__H__
8
10#include <core/SNativeWnd.h>
12#include <event/SEventCrack.h>
14#include <interface/shostwnd-i.h>
15#include <interface/SHostPresenter-i.h>
16#include <core/SCaret.h>
17#include <core/SNcPainter.h>
18#include <layout/SLayoutSize.h>
19#include <helper/SplitString.h>
20#include <helper/swndspy.h>
21#include <helper/STimerGenerator.h>
22#include <proxy/SNativeWndProxy.h>
23SNSBEGIN
24
25/**
26 * @brief Macro to disable SWnd spy for release builds.
27 */
28#ifndef DISABLE_SWNDSPY
29#ifndef _DEBUG
30#define DISABLE_SWNDSPY 1
31#else
32#define DISABLE_SWNDSPY 0
33#endif
34#endif
35
36/**
37 * @class SHostWndAttr
38 * @brief Class defining attributes for the host window.
39 *
40 * This class manages and configures the appearance and behavior of the host window.
41 */
42class SOUI_EXP SHostWndAttr : public TObjRefImpl<SObject> {
43 DEF_SOBJECT(TObjRefImpl<SObject>, L"SHostWndAttr")
44
45 /**
46 * @enum WndType
47 * @brief Enumeration for different types of windows.
48 */
49 enum WndType {
50 WT_UNDEFINE = 0, /**< Undefined window type */
51 WT_APPMAIN = 1, /**< Application main window */
52 WT_NORMAL = 2 /**< Normal window */
53 };
54
55 /**
56 * @brief Friend class declaration allowing access to private members.
57 */
58 friend class SHostWnd;
59 friend class SRootWindow;
60 friend class SNcPainter;
61 friend class SHostPresenter;
62
63public:
64 /**
65 * @brief Constructor for SHostWndAttr.
66 */
67 SHostWndAttr(void);
68
69 /**
70 * @brief Destructor for SHostWndAttr.
71 */
73
74 /**
75 * @brief Initializes the window attributes.
76 */
77 void Init();
78
79 /**
80 * @brief Gets the translation context.
81 *
82 * @return Translation context string.
83 */
84 virtual LPCWSTR GetTrCtx() const;
85
86 /**
87 * @brief Gets the maximum inset size of the window.
88 *
89 * @param nScale Scale factor.
90 * @return Maximum inset rectangle.
91 */
92 CRect GetMaxInset(int nScale) const;
93
94 /**
95 * @brief Gets the margin of the window.
96 *
97 * @param nScale Scale factor.
98 * @return Margin rectangle.
99 */
100 CRect GetMargin(int nScale) const;
101
102 /**
103 * @brief Gets the minimum size of the window.
104 *
105 * @param nScale Scale factor.
106 * @return Minimum size.
107 */
108 CSize GetMinSize(int nScale) const;
109
110 /**
111 * @brief Sets whether the window is translucent.
112 *
113 * @param bTranslucent TRUE if the window is translucent, FALSE otherwise.
114 */
115 void SetTranslucent(bool bTranslucent);
116
117 /**
118 * @brief Sets the translation context.
119 *
120 * @param strTrCtx Translation context string.
121 */
122 void SetTrCtx(const SStringW &strTrCtx);
123
124 /**
125 * @brief Sets whether wheel messages are sent to the hover window.
126 *
127 * @param value TRUE to send wheel messages to the hover window, FALSE otherwise.
128 */
129 void SetSendWheel2Hover(bool value);
130
131 /**
132 * @brief Defines the attribute list for serialization and deserialization.
133 */
134 SOUI_ATTRS_BEGIN()
135 ATTR_STRINGW(L"trCtx", m_strTrCtx, FALSE)
136 ATTR_STRINGW(L"title", m_strTitle, FALSE)
137 ATTR_LAYOUTSIZE4(L"maxInset", m_rcMaxInset, FALSE)
138 ATTR_LAYOUTSIZE4(L"margin", m_rcMargin, FALSE)
139 ATTR_LAYOUTSIZE2(L"minsize", m_szMin, FALSE)
140 ATTR_DWORD(L"wndStyle", m_dwStyle, FALSE)
141 ATTR_DWORD(L"wndStyleEx", m_dwExStyle, FALSE)
142 ATTR_BOOL(L"resizable", m_bResizable, FALSE)
143 ATTR_BOOL(L"translucent", m_bTranslucent, FALSE)
144 ATTR_BOOL(L"autoShape", m_bAutoShape, FALSE)
145 ATTR_BOOL(L"sendWheel2Hover", m_bSendWheel2Hover, FALSE)
146 ATTR_BOOL(L"appWnd", m_bAppWnd, FALSE)
147 ATTR_BOOL(L"toolWindow", m_bToolWnd, FALSE)
148 ATTR_ICON(L"smallIcon", m_hAppIconSmall, FALSE)
149 ATTR_ICON(L"bigIcon", m_hAppIconBig, FALSE)
150 ATTR_BOOL(L"allowSpy", m_bAllowSpy, FALSE)
151 ATTR_BOOL(L"hasMsgLoop", m_bHasMsgLoop, FALSE)
152 ATTR_ENUM_BEGIN(L"wndType", WndType, FALSE)
153 ATTR_ENUM_VALUE(L"undefine", WT_UNDEFINE)
154 ATTR_ENUM_VALUE(L"appMain", WT_APPMAIN)
155 ATTR_ENUM_VALUE(L"normal", WT_NORMAL)
156 ATTR_ENUM_END(m_wndType)
157 SOUI_ATTRS_END()
158
159protected:
160 SLayoutSize m_rcMargin[4]; /**< Window stretch edge detection size */
161 SLayoutSize m_szMin[2]; /**< Window minimum size */
162 SLayoutSize m_rcMaxInset[4]; /**< Window maximum inset size when maximized. WS_OVERLAPPED style windows ignore this attribute */
163
164 WndType m_wndType; /**< Main window flag, if set, the window sends WM_QUIT on close */
165 BOOL m_bResizable; /**< Flag indicating if the window is resizable */
166 BOOL m_bAppWnd; /**< Flag indicating if the window is an APP window (shown in taskbar) */
167 BOOL m_bToolWnd; /**< Flag indicating if the window has WS_ES_TOOLWINDOW style */
168 BOOL m_bTranslucent; /**< Flag indicating if the window is translucent */
169 BOOL m_bAutoShape; /**< Flag indicating if the window should auto-build shape for translucency (valid for Linux) */
170 BOOL m_bAllowSpy; /**< Flag indicating if spy is allowed */
171 BOOL m_bSendWheel2Hover; /**< Flag indicating if wheel messages should be sent to the hover window */
172 BOOL m_bHasMsgLoop; /**< Flag indicating if the window has a message loop, affecting tooltip RelayEvent timing */
173 DWORD m_dwStyle;
174 DWORD m_dwExStyle;
175
176 SStringW m_strTrCtx; /**< Translation context used in language translation */
177 SStringW m_strTitle;
178 HICON m_hAppIconSmall;
179 HICON m_hAppIconBig;
180};
181/**
182 * @class SRootWindow
183 * @brief Root window class derived from SWindow.
184 *
185 * This class represents the root window in the SOUI framework and manages various window behaviors and events.
186 */
187class SOUI_EXP SRootWindow : public SWindow {
188 // DEF_SOBJECT macro defines the type name of the class
189 DEF_SOBJECT(SWindow, L"root")
190 // Declare SHostWnd as a friend class to allow access to private members
191 friend class SHostWnd;
192
193public:
194 /**
195 * @brief Constructor for SRootWindow.
196 *
197 * Initializes the SRootWindow object with a pointer to the host window.
198 *
199 * @param pHostWnd Pointer to the host window.
200 */
201 SRootWindow(SHostWnd *pHostWnd);
202
203public:
204 /**
205 * @brief Gets the pointer to the host window.
206 *
207 * @return Pointer to the host window.
208 */
209 SHostWnd *GetHostWnd() const;
210
211 /**
212 * @brief Fires a menu command event.
213 *
214 * @param menuID ID of the menu command to trigger.
215 */
216 void FireMenuCmd(int menuID);
217
218public:
219 /**
220 * @brief Updates the layout of the window.
221 *
222 * Overrides the base class method to update the layout.
223 */
224 STDMETHOD_(void, UpdateLayout)(THIS) OVERRIDE;
225
226protected:
227 /**
228 * @brief Called when an animation stops.
229 *
230 * Overrides the base class method to handle animation stop events.
231 *
232 * @param pAni Pointer to the animation object.
233 */
234 STDMETHOD_(void, OnAnimationStop)(THIS_ IAnimation *pAni) OVERRIDE;
235
236 /**
237 * @brief Called when an animation is invalidated.
238 *
239 * @param pAni Pointer to the animation object.
240 * @param bErase Flag indicating whether to erase the animation.
241 */
242 virtual void OnAnimationInvalidate(IAnimation *pAni, bool bErase);
243
244protected: // SWindow virtual methods
245 /**
246 * @brief Called before painting the window.
247 *
248 * @param pRT Pointer to the render target.
249 * @param painter Painter object.
250 */
251 virtual void BeforePaint(IRenderTarget *pRT, SPainter &painter);
252
253 /**
254 * @brief Called after painting the window.
255 *
256 * @param pRT Pointer to the render target.
257 * @param painter Painter object.
258 */
259 virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter);
260
261 /**
262 * @brief Checks if the window is a layered window.
263 *
264 * @return TRUE if the window is a layered window, FALSE otherwise.
265 */
266 virtual BOOL IsLayeredWindow() const {
267 return FALSE;
268 }
269
270 /**
271 * @brief Called when the language changes.
272 *
273 * @return HRESULT indicating the success or failure of the operation.
274 */
275 virtual HRESULT OnLanguageChanged();
276
277 /**
278 * @brief Called when the scale changes.
279 *
280 * @param scale New scale factor.
281 */
282 virtual void OnScaleChanged(int scale);
283
284 /**
285 * @brief Requests a relayout of the window.
286 *
287 * @param hSource Source window handle.
288 * @param bSourceResizable Flag indicating if the source window is resizable.
289 */
290 virtual void RequestRelayout(SWND hSource, BOOL bSourceResizable);
291
292public:
293 // Define attributes for enter and exit animations
294 SOUI_ATTRS_BEGIN()
295 ATTR_ANIMATION(L"enterAnimation", m_aniEnter, FALSE)
296 ATTR_ANIMATION(L"exitAnimation", m_aniExit, FALSE)
297 SOUI_ATTRS_END()
298
299protected:
300 // Auto-managed pointers for enter and exit animations
301 SAutoRefPtr<IAnimation> m_aniEnter, m_aniExit;
302 // Pointer to the host window
303 SHostWnd *m_pHostWnd;
304};
305class SDummyWnd;
306
307/**
308 * @class SHostWnd
309 * @brief The main host window class responsible for managing the layout, events, and rendering of SOUI windows.
310 *
311 * This class acts as a container for SWindow objects and provides functionality for creating, destroying, and managing
312 * child windows. It also handles various Windows messages and animations.
313 *
314 * @note Inherits from TNativeWndProxy<IHostWnd> and SwndContainerImpl.
315 */
316class SOUI_EXP SHostWnd
317 : public TNativeWndProxy<IHostWnd>
318 , public SwndContainerImpl {
319 friend class SDummyWnd; /**< Friend class used for handling WM_PAINT messages in translucent windows. */
320 friend class SRootWindow; /**< Friend class representing the root window. */
321 friend class SNcPainter; /**< Friend class for non-client area painting. */
322
323 protected:
324 SDummyWnd *m_dummyWnd; /**< A dummy window used to handle WM_PAINT messages for translucent windows. */
325 SHostWndAttr m_hostAttr; /**< Host attributes corresponding to the SOUI node in XML. */
326 SStringT m_strXmlLayout; /**< Layout resource name (e.g., xml:main_wnd). */
327
328 BOOL m_bTrackFlag; /**< Mouse tracking flag. */
329 BOOL m_bNeedRepaint; /**< Indicates if a repaint is required. */
330 BOOL m_bNeedAllRepaint; /**< Indicates if a full repaint is required. */
331
332 IToolTip *m_pTipCtrl; /**< Interface for tooltip control. */
333
334 SAutoRefPtr<IRegionS> m_rgnInvalidate; /**< Invalid region requiring redraw. */
335 SAutoRefPtr<IRenderTarget> m_memRT; /**< Rendering cache. */
336 SAutoRefPtr<IUiDefInfo> m_privateUiDefInfo; /**< Local UI definition information. */
337 int m_cEnableUiDefCount; /**< Count of enabled local UI definitions. */
338 SAutoRefPtr<IScriptModule> m_pScriptModule; /**< Script module for executing scripts. */
339 SAutoRefPtr<SNcPainter> m_pNcPainter; /**< Non-client area painter. */
340
341 MSG m_msgMouse; /**< Last mouse press message. */
342 CSize m_szAppSetted; /**< Window size set by the application layer. */
343 CSize m_szPrev; /**< Previous window size. */
344 int m_nAutoSizing; /**< Auto-sizing trigger count for WM_SIZE messages. */
345 bool m_bResizing; /**< Indicates if resizing is in progress. */
346
347 SAutoRefPtr<IAnimation> m_hostAnimation; /**< Host animation object. */
348 DWORD m_AniState; /**< Animation state. */
349 BOOL m_bFirstShow; /**< Indicates if it's the first time the window is shown. */
350 tid_t m_dwThreadID; /**< Thread ID. */
351 SRootWindow *m_pRoot; /**< Pointer to the root window. */
352
353 EventHandlerInfo m_evtHandler; /**< Event handler information. */
354 SAutoRefPtr<IHostPresenter> m_presenter; /**< Presenter for rendering. */
355
356 SCriticalSection m_cs; /**< Critical section for thread synchronization. */
357 SList<IRunnable *> m_runnables; /**< List of runnable tasks. */
358 SCriticalSection m_csRunningQueue; /**< Critical section for running queue synchronization. */
359 SList<IRunnable *> m_runningQueue; /**< Queue of currently running tasks. */
360 IXmlNode *m_xmlInit; /**< Initial XML node. */
361 static BOOL s_HideLocalUiDef; /**< Global flag to hide local UI definitions. */
362 static int s_TaskQueueBufSize; /**< Buffer size for asynchronous task queues (default: 5). */
363
364 public:
365 /**
366 * @brief Constructs a SHostWnd object with an optional resource name.
367 * @param pszResName Resource name for the layout (can be NULL).
368 */
369 SHostWnd(LPCWSTR pszResName = NULL);
370
371 /**
372 * @brief Constructs a SHostWnd object with an optional resource name (ANSI version).
373 * @param pszResName Resource name for the layout (can be NULL).
374 */
375 SHostWnd(LPCSTR pszResName);
376
377 /**
378 * @brief Destructor for SHostWnd.
379 */
380 virtual ~SHostWnd();
381
382 /**
383 * @brief Sets whether to hide local UI definitions globally.
384 * @param bHide TRUE to hide, FALSE otherwise.
385 */
386 static void SetHideLocalUiDef(BOOL bHide);
387
388 /**
389 * @brief Sets the buffer size for asynchronous task queues.
390 * @param nBufSize Buffer size for task queues.
391 */
392 static void SetTaskQueueBufSize(int nBufSize);
393
394 public:
395 enum {
396 kPulseTimer = 4321, /**< SOUI timer ID (do not use in applications). */
397 kPulseInterval = 10, /**< Pulse interval in milliseconds. */
398 kNcCheckTimer = 4322, /**< Timer ID for non-client area checks. */
399 kNcCheckInterval = 50, /**< Interval for non-client area checks in milliseconds. */
400 kTaskTimer = 4323, /**< Timer ID for task execution. */
401 kTaskInterval = 100 /**< Interval for task execution in milliseconds. */
402 };
403
404 /**
405 * @brief Initializes the host window from an XML node.
406 * @param pNode Pointer to the XML node.
407 * @return TRUE if initialization succeeds, FALSE otherwise.
408 */
409 STDMETHOD_(BOOL, InitFromXml)(THIS_ IXmlNode *pNode) OVERRIDE;
410
411 /**
412 * @brief Destroys the host window.
413 * @return TRUE if destruction succeeds, FALSE otherwise.
414 */
415 STDMETHOD_(BOOL, DestroyWindow)(THIS) OVERRIDE;
416
417 /**
418 * @brief Sets the layout ID for the host window.
419 * @param pszLayoutId Layout resource identifier.
420 */
421 STDMETHOD_(void, SetLayoutId)(THIS_ LPCTSTR pszLayoutId) OVERRIDE {
422 m_strXmlLayout = pszLayoutId;
423 }
424
425 /**
426 * @brief Gets the root window interface.
427 * @return Pointer to the root window interface.
428 */
429 STDMETHOD_(IWindow *, GetIRoot)(THIS) OVERRIDE {
430 return m_pRoot;
431 }
432
433 /**
434 * @brief Checks if the host window is translucent.
435 * @return TRUE if translucent, FALSE otherwise.
436 */
437 STDMETHOD_(BOOL, IsTranslucent)(CTHIS) SCONST OVERRIDE;
438
439 /**
440 * @brief Gets the presenter interface for rendering.
441 * @return Pointer to the presenter interface.
442 */
443 STDMETHOD_(IHostPresenter *, GetPresenter)(THIS) OVERRIDE;
444
445 /**
446 * @brief Sets the presenter for rendering.
447 * @param pPresenter Pointer to the presenter interface.
448 */
449 STDMETHOD_(void, SetPresenter)(THIS_ IHostPresenter *pPresenter) OVERRIDE;
450
451 /**
452 * @brief Gets the message loop interface.
453 * @return Pointer to the message loop interface.
454 */
455 STDMETHOD_(IMessageLoop *, GetMsgLoop)(THIS) OVERRIDE;
456
457/**
458 * @brief Finds a child window by its ID.
459 *
460 * @param nId The ID of the child window to find.
461 * @return Pointer to the found child window, or NULL if not found.
462 */
463STDMETHOD_(IWindow *, FindIChildByID)(THIS_ int nId) OVERRIDE
464{
465 return m_pRoot->FindIChildByID(nId);
466}
467
468/**
469 * @brief Finds a child window by its name (Unicode version).
470 *
471 * @param pszName The name of the child window to find.
472 * @return Pointer to the found child window, or NULL if not found.
473 */
474STDMETHOD_(IWindow *, FindIChildByName)(THIS_ LPCWSTR pszName) OVERRIDE
475{
476 return m_pRoot->FindIChildByName(pszName);
477}
478
479/**
480 * @brief Finds a child window by its name (ANSI version).
481 *
482 * @param pszName The name of the child window to find.
483 * @return Pointer to the found child window, or NULL if not found.
484 */
485STDMETHOD_(IWindow *, FindIChildByNameA)(THIS_ LPCSTR pszName) OVERRIDE
486{
487 return m_pRoot->FindIChildByNameA(pszName);
488}
489
490/**
491 * @brief Gets the non-client area painter for the host window.
492 *
493 * @return Pointer to the non-client area painter.
494 */
495STDMETHOD_(INcPainter *, GetNcPainter)(THIS) OVERRIDE
496{
497 return m_pNcPainter;
498}
499
500/**
501 * @brief Shows or hides the host window.
502 *
503 * @param nCmdShow Command to show or hide the window.
504 * @return TRUE if successful, FALSE otherwise.
505 */
506STDMETHOD_(BOOL, ShowWindow)(THIS_ int nCmdShow) OVERRIDE;
507
508/**
509 * @brief Creates the host window with extended styles.
510 *
511 * @param hWndParent Handle to the parent window.
512 * @param dwStyle Window style.
513 * @param dwExStyle Extended window style.
514 * @param x X position of the window.
515 * @param y Y position of the window.
516 * @param nWidth Width of the window.
517 * @param nHeight Height of the window.
518 * @param xmlInit Optional XML node for initialization.
519 * @return Handle to the created window.
520 */
521STDMETHOD_(HWND, CreateEx)
522(THIS_ HWND hWndParent, DWORD dwStyle, DWORD dwExStyle, int x, int y, int nWidth, int nHeight, IXmlNode *xmlInit DEF_VAL(NULL)) OVERRIDE;
523
524/**
525 * @brief Creates the host window.
526 *
527 * @param hWndParent Handle to the parent window.
528 * @param x X position of the window (default: 0).
529 * @param y Y position of the window (default: 0).
530 * @param nWidth Width of the window (default: 0).
531 * @param nHeight Height of the window (default: 0).
532 * @return Handle to the created window.
533 */
534STDMETHOD_(HWND, Create)
535(THIS_ HWND hWndParent, int x = 0, int y = 0, int nWidth = 0, int nHeight = 0) OVERRIDE;
536
537/**
538 * @brief Sets the event handler for the host window.
539 *
540 * @param fun Callback function for handling events.
541 * @param ctx Context pointer passed to the callback function.
542 */
543STDMETHOD_(void, SetEventHandler)(THIS_ FunCallback fun, void *ctx) OVERRIDE;
544
545/**
546 * @brief Gets the event handler information for the host window.
547 *
548 * @return Pointer to the event handler information.
549 */
550STDMETHOD_(EventHandlerInfo *, GetEventHandler)(THIS) OVERRIDE;
551
552/**
553 * @brief Animates the host window.
554 *
555 * @param dwTime Duration of the animation in milliseconds.
556 * @param dwFlags Animation flags.
557 * @return TRUE if successful, FALSE otherwise.
558 */
559STDMETHOD_(BOOL, AnimateHostWindow)(THIS_ DWORD dwTime, DWORD dwFlags) OVERRIDE;
560
561/**
562 * @brief Enables drag-and-drop functionality for the host window.
563 */
564STDMETHOD_(void, EnableDragDrop)(THIS) OVERRIDE;
565
566/**
567 * @brief Shows the host window with optional animation.
568 *
569 * @param uShowCmd Command to show the window.
570 * @param bWaitAniDone Wait for the animation to complete before returning.
571 */
572STDMETHOD_(void, ShowHostWnd)(THIS_ int uShowCmd, BOOL bWaitAniDone) OVERRIDE;
573
574/**
575 * @brief Enables or disables private UI definitions for the host window.
576 *
577 * @param bEnable TRUE to enable, FALSE to disable.
578 */
579STDMETHOD_(void, EnablePrivateUiDef)(THIS_ BOOL bEnable) OVERRIDE;
580
581/**
582 * @brief Sets the scale factor for the host window.
583 *
584 * @param nScale Scale factor.
585 * @param pDestRect Destination rectangle.
586 */
587STDMETHOD_(void, SetScale)(THIS_ int nScale, LPCRECT pDestRect) OVERRIDE;
588
589/**
590 * @brief Finds a child window by its name (Unicode version).
591 *
592 * @param strName The name of the child window to find.
593 * @param nDeep Depth of the search (default: -1, search all levels).
594 * @return Pointer to the found child window, or NULL if not found.
595 */
596SWindow *FindChildByName(LPCWSTR strName, int nDeep = -1)
597{
598 return GetRoot()->FindChildByName(strName, nDeep);
599}
600
601/**
602 * @brief Finds a child window by its name (ANSI version).
603 *
604 * @param strName The name of the child window to find.
605 * @param nDeep Depth of the search (default: -1, search all levels).
606 * @return Pointer to the found child window, or NULL if not found.
607 */
608SWindow *FindChildByName(LPCSTR strName, int nDeep = -1)
609{
610 return GetRoot()->FindChildByName(strName, nDeep);
611}
612
613/**
614 * @brief Finds a child window by its name (Unicode version) with template support.
615 *
616 * @tparam T Type of the child window to find.
617 * @param pszName The name of the child window to find.
618 * @param nDeep Depth of the search (default: -1, search all levels).
619 * @return Pointer to the found child window, or NULL if not found.
620 */
621template <class T>
622T *FindChildByName2(LPCWSTR pszName, int nDeep = -1)
623{
624 return GetRoot()->FindChildByName2<T>(pszName, nDeep);
625}
626
627/**
628 * @brief Finds a child window by its name (ANSI version) with template support.
629 *
630 * @tparam T Type of the child window to find.
631 * @param pszName The name of the child window to find.
632 * @param nDeep Depth of the search (default: -1, search all levels).
633 * @return Pointer to the found child window, or NULL if not found.
634 */
635template <class T>
636T *FindChildByName2(LPCSTR pszName, int nDeep = -1)
637{
638 return GetRoot()->FindChildByName2<T>(pszName, nDeep);
639}
640
641/**
642 * @brief Finds a child window by its ID.
643 *
644 * @param nID The ID of the child window to find.
645 * @param nDeep Depth of the search (default: -1, search all levels).
646 * @return Pointer to the found child window, or NULL if not found.
647 */
648SWindow *FindChildByID(int nID, int nDeep = -1)
649{
650 return GetRoot()->FindChildByID(nID, nDeep);
651}
652
653/**
654 * @brief Finds a child window by its ID with template support.
655 *
656 * @tparam T Type of the child window to find.
657 * @param nID The ID of the child window to find.
658 * @param nDeep Depth of the search (default: -1, search all levels).
659 * @return Pointer to the found child window, or NULL if not found.
660 */
661template <class T>
662T *FindChildByID2(int nID, int nDeep = -1)
663{
664 return GetRoot()->FindChildByID2<T>(nID, nDeep);
665}
666
667/**
668 * @brief Finds a child window by its class.
669 *
670 * @tparam T Type of the child window to find.
671 * @param nDeep Depth of the search (default: -1, search all levels).
672 * @return Pointer to the found child window, or NULL if not found.
673 */
674template <class T>
675T *FindChildByClass(int nDeep = -1) const
676{
677 return GetRoot()->FindChildByClass<T>(nDeep);
678}
679
680/**
681 * @brief Gets the root window.
682 *
683 * @return Pointer to the root window.
684 */
686{
687 return m_pRoot;
688}
689
690/**
691 * @brief Gets the native window interface.
692 *
693 * @return Pointer to the native window interface.
694 */
695SNativeWnd *GetNative()
696{
697 return this;
698}
699
700/**
701 * @brief Gets the window rectangle.
702 *
703 * @return Rectangle representing the window's position and size.
704 */
705CRect GetWindowRect() const;
706
707/**
708 * @brief Gets the client rectangle.
709 *
710 * @return Rectangle representing the client area's position and size.
711 */
712CRect GetClientRect() const;
713
714/**
715 * @brief Gets the host window attributes.
716 *
717 * @return Reference to the host window attributes.
718 */
720{
721 return m_hostAttr;
722}
723
724/**
725 * @brief Gets the tooltip interface.
726 *
727 * @return Pointer to the tooltip interface.
728 */
730{
731 return m_pTipCtrl;
732}
733
734/**
735 * @brief Starts an animation for the host window.
736 *
737 * @param pAni Pointer to the animation object.
738 * @return TRUE if successful, FALSE otherwise.
739 */
740bool StartHostAnimation(IAnimation *pAni);
741
742/**
743 * @brief Stops the current animation for the host window.
744 *
745 * @return TRUE if successful, FALSE otherwise.
746 */
747bool StopHostAnimation();
748
749/**
750 * @brief Updates the auto-size count.
751 *
752 * @param bInc TRUE to increment, FALSE to decrement.
753 */
754void UpdateAutoSizeCount(bool bInc);
755
756protected:
757 /**
758 * @brief Handler class for host window animations.
759 *
760 * This class implements the ITimelineHandler interface to handle animation frames.
761 */
763 public:
764 /**
765 * @brief Pointer to the host window.
766 */
768
769 /**
770 * @brief Initial rectangle of the host window.
771 */
772 CRect m_rcInit;
773
774 protected:
775 /**
776 * @brief Called on each frame of the animation.
777 */
778 STDMETHOD_(void, OnNextFrame)(THIS_) OVERRIDE;
779 } m_hostAnimationHandler;
780
781 /**
782 * @brief Called when the host window animation starts.
783 *
784 * @param pAni Pointer to the animation object.
785 */
786 virtual void OnHostAnimationStarted(IAnimation *pAni);
787
788 /**
789 * @brief Called when the host window animation stops.
790 *
791 * @param pAni Pointer to the animation object.
792 */
793 virtual void OnHostAnimationStoped(IAnimation *pAni);
794
795protected: // 辅助函数
796 /**
797 * @brief Redraws a specific region of the window.
798 *
799 * @param pRgn Region to redraw.
800 * @param rcInvalid Invalid rectangle.
801 */
802 void _RedrawRegion(IRegionS *pRgn, CRect &rcInvalid);
803
804 /**
805 * @brief Redraws the entire window.
806 */
807 void _Redraw();
808
809 /**
810 * @brief Restores the click state of the window.
811 */
812 void _RestoreClickState();
813
814 /**
815 * @brief Invalidates a specific region of the window.
816 *
817 * @param prc Rectangle to invalidate.
818 */
819 void _Invalidate(LPCRECT prc);
820
821 /**
822 * @brief Sets tooltip information for the window.
823 *
824 * @param info Tooltip information.
825 * @param bNcTip Flag indicating if the tooltip is for the non-client area.
826 */
827 void _SetToolTipInfo(const SwndToolTipInfo *info, BOOL bNcTip);
828
829 /**
830 * @brief Initializes the host window.
831 */
832 void _Init();
833
834 /**
835 * @brief Excludes the video canvas from painting.
836 *
837 * @param pRT Render target.
838 */
840
841 /**
842 * @brief Paints the video canvas in the foreground.
843 *
844 * @param pRT Render target.
845 */
847
848protected:
849 //////////////////////////////////////////////////////////////////////////
850 // 消息处理
851
852 /**
853 * @brief Handles the WM_PRINT message.
854 *
855 * @param dc Device context.
856 * @param uFlags Print flags.
857 */
858 void OnPrint(HDC dc, UINT uFlags = 0);
859
860 /**
861 * @brief Handles the WM_PAINT message.
862 *
863 * @param dc Device context.
864 */
865 void OnPaint(HDC dc);
866
867 /**
868 * @brief Handles the WM_ERASEBKGND message.
869 *
870 * @param dc Device context.
871 * @return TRUE if the background is erased, FALSE otherwise.
872 */
873 BOOL OnEraseBkgnd(HDC dc);
874
875 /**
876 * @brief Handles the WM_CREATE message.
877 *
878 * @param lpCreateStruct Create structure.
879 * @return 0 on success, non-zero on failure.
880 */
881 int OnCreate(LPCREATESTRUCT lpCreateStruct);
882
883 /**
884 * @brief Handles the WM_DESTROY message.
885 */
886 void OnDestroy();
887
888 /**
889 * @brief Handles the WM_SIZE message.
890 *
891 * @param nType Size type.
892 * @param size New size of the window.
893 */
894 void OnSize(UINT nType, CSize size);
895
896 /**
897 * @brief Handles the WM_MOUSEMOVE message.
898 *
899 * @param nFlags Mouse flags.
900 * @param point Mouse position.
901 */
902 void OnMouseMove(UINT nFlags, CPoint point);
903
904 /**
905 * @brief Handles the WM_MOUSELEAVE message.
906 */
907 void OnMouseLeave();
908
909 /**
910 * @brief Handles the WM_SETCURSOR message.
911 *
912 * @param hWnd Handle to the window.
913 * @param nHitTest Hit test code.
914 * @param message Message identifier.
915 * @return TRUE if the cursor is set, FALSE otherwise.
916 */
917 BOOL OnSetCursor(HWND hWnd, UINT nHitTest, UINT message);
918
919 /**
920 * @brief Handles the WM_TIMER message.
921 *
922 * @param idEvent Timer identifier.
923 */
924 void OnTimer(UINT_PTR idEvent);
925
926 /**
927 * @brief Handles mouse events.
928 *
929 * @param uMsg Message identifier.
930 * @param wParam WPARAM.
931 * @param lParam LPARAM.
932 * @return LRESULT.
933 */
934 LRESULT OnMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
935
936 /**
937 * @brief Handles key events.
938 *
939 * @param uMsg Message identifier.
940 * @param wParam WPARAM.
941 * @param lParam LPARAM.
942 * @return LRESULT.
943 */
944 LRESULT OnKeyEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
945
946 /**
947 * @brief Handles the WM_ACTIVATEAPP message.
948 *
949 * @param uMsg Message identifier.
950 * @param wParam WPARAM.
951 * @param lParam LPARAM.
952 * @return LRESULT.
953 */
954 LRESULT OnActivateApp(UINT uMsg, WPARAM wParam, LPARAM lParam);
955
956 /**
957 * @brief Handles the WM_MOUSEWHEEL message.
958 *
959 * @param nFlags Mouse flags.
960 * @param zDelta Wheel delta.
961 * @param pt Mouse position.
962 * @return TRUE if handled, FALSE otherwise.
963 */
964 BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
965
966 /**
967 * @brief Handles the WM_ACTIVATE message.
968 *
969 * @param nState Activation state.
970 * @param bMinimized Minimized flag.
971 * @param wndOther Other window handle.
972 */
973 void OnActivate(UINT nState, BOOL bMinimized, HWND wndOther);
974
975 /**
976 * @brief Handles the WM_GETMINMAXINFO message.
977 *
978 * @param lpMMI Min-max information.
979 */
980 void OnGetMinMaxInfo(LPMINMAXINFO lpMMI);
981
982 /**
983 * @brief Handles the WM_SETFOCUS message.
984 *
985 * @param wndOld Previous window handle.
986 */
987 void OnSetFocus(HWND wndOld);
988
989 /**
990 * @brief Handles the WM_KILLFOCUS message.
991 *
992 * @param wndFocus New focus window handle.
993 */
994 void OnKillFocus(HWND wndFocus);
995
996 /**
997 * @brief Updates the presenter.
998 *
999 * @param dc Device context.
1000 * @param pRT Render target.
1001 * @param rc Rectangle.
1002 * @param byAlpha Alpha value.
1003 * @param uFlag Flags.
1004 */
1005 void UpdatePresenter(HDC dc, IRenderTarget *pRT, LPCRECT rc, BYTE byAlpha = 255, UINT uFlag = 0);
1006
1007 /**
1008 * @brief Handles the WM_CAPTURECHANGED message.
1009 *
1010 * @param wnd New capture window handle.
1011 */
1012 void OnCaptureChanged(HWND wnd);
1013
1014 /**
1015 * @brief Handles custom menu events.
1016 *
1017 * @param uMsg Message identifier.
1018 * @param wParam WPARAM.
1019 * @param lParam LPARAM.
1020 * @return LRESULT.
1021 */
1022 LRESULT OnMenuExEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
1023
1024 /**
1025 * @brief Handles the WM_WINDOWPOSCHANGING message.
1026 *
1027 * @param lpWndPos Window position structure.
1028 */
1029 void OnWindowPosChanging(LPWINDOWPOS lpWndPos);
1030
1031 /**
1032 * @brief Handles the WM_WINDOWPOSCHANGED message.
1033 *
1034 * @param lpWndPos Window position structure.
1035 */
1036 void OnWindowPosChanged(LPWINDOWPOS lpWndPos);
1037
1038 /**
1039 * @brief Handles the WM_GETOBJECT message.
1040 *
1041 * @param uMsg Message identifier.
1042 * @param wParam WPARAM.
1043 * @param lParam LPARAM.
1044 * @return LRESULT.
1045 */
1046 LRESULT OnGetObject(UINT uMsg, WPARAM wParam, LPARAM lParam);
1047
1048 /**
1049 * @brief Handles the WM_SYSCOMMAND message.
1050 *
1051 * @param nID System command identifier.
1052 * @param lParam LPARAM.
1053 */
1054 void OnSysCommand(UINT nID, CPoint lParam);
1055
1056 /**
1057 * @brief Handles the WM_COMMAND message.
1058 *
1059 * @param uNotifyCode Notification code.
1060 * @param nID Control ID.
1061 * @param wndCtl Control window handle.
1062 */
1063 void OnCommand(UINT uNotifyCode, int nID, HWND wndCtl);
1064
1065#if (!DISABLE_SWNDSPY)
1066protected:
1067 /**
1068 * @brief Handles the SPYMSG_SETSPY message.
1069 *
1070 * @param uMsg Message identifier.
1071 * @param wParam WPARAM.
1072 * @param lParam LPARAM.
1073 * @return LRESULT.
1074 */
1075 LRESULT OnSpyMsgSetSpy(UINT uMsg, WPARAM wParam, LPARAM lParam);
1076
1077 /**
1078 * @brief Handles the SPYMSG_SWNDENUM message.
1079 *
1080 * @param uMsg Message identifier.
1081 * @param wParam WPARAM.
1082 * @param lParam LPARAM.
1083 * @return LRESULT.
1084 */
1085 LRESULT OnSpyMsgSwndEnum(UINT uMsg, WPARAM wParam, LPARAM lParam);
1086
1087 /**
1088 * @brief Handles the SPYMSG_SWNDINFO message.
1089 *
1090 * @param uMsg Message identifier.
1091 * @param wParam WPARAM.
1092 * @param lParam LPARAM.
1093 * @return LRESULT.
1094 */
1095 LRESULT OnSpyMsgSwndSpy(UINT uMsg, WPARAM wParam, LPARAM lParam);
1096
1097 /**
1098 * @brief Handles the SPYMSG_HITTEST message.
1099 *
1100 * @param uMsg Message identifier.
1101 * @param wParam WPARAM.
1102 * @param lParam LPARAM.
1103 * @return LRESULT.
1104 */
1105 LRESULT OnSpyMsgHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam);
1106
1107 /**
1108 * @brief Handle to the spy window.
1109 */
1110 HWND m_hSpyWnd;
1111#endif
1112
1113public: // IContainer
1114 /**
1115 * @brief Fires an event in the container.
1116 *
1117 * @param evt Pointer to the event arguments.
1118 * @return TRUE if the event was handled, FALSE otherwise.
1119 */
1120 STDMETHOD_(BOOL, OnFireEvent)(IEvtArgs *evt) OVERRIDE;
1121
1122 /**
1123 * @brief Gets the rectangle of the container.
1124 *
1125 * @param ret Pointer to the rectangle to be filled.
1126 */
1127 STDMETHOD_(void, GetContainerRect)(CTHIS_ RECT *ret) const OVERRIDE;
1128
1129 /**
1130 * @brief Gets the handle to the host window.
1131 *
1132 * @return Handle to the host window.
1133 */
1134 STDMETHOD_(HWND, GetHostHwnd)() OVERRIDE;
1135
1136 /**
1137 * @brief Gets the translator context for the container.
1138 *
1139 * @return Pointer to the translator context string.
1140 */
1141 STDMETHOD_(LPCWSTR, GetTranslatorContext)() const OVERRIDE;
1142
1143 /**
1144 * @brief Updates the specified region in the container.
1145 *
1146 * @param rgn Pointer to the region to update.
1147 */
1148 STDMETHOD_(void, UpdateRegion)(IRegionS *rgn) OVERRIDE;
1149
1150 /**
1151 * @brief Redraws the specified rectangle in the container.
1152 *
1153 * @param rc Pointer to the rectangle to redraw.
1154 * @param bClip Flag indicating whether to clip the redraw.
1155 */
1156 STDMETHOD_(void, OnRedraw)(LPCRECT rc, BOOL bClip) OVERRIDE;
1157
1158 /**
1159 * @brief Releases the capture from the container.
1160 *
1161 * @return TRUE if the capture was released, FALSE otherwise.
1162 */
1163 STDMETHOD_(BOOL, OnReleaseSwndCapture)() OVERRIDE;
1164
1165 /**
1166 * @brief Sets the capture to the specified window.
1167 *
1168 * @param swnd Handle to the window to capture.
1169 * @return Handle to the previously captured window.
1170 */
1171 STDMETHOD_(SWND, OnSetSwndCapture)(SWND swnd) OVERRIDE;
1172
1173 /**
1174 * @brief Checks if wheel messages are sent to the hover window.
1175 *
1176 * @return TRUE if wheel messages are sent to the hover window, FALSE otherwise.
1177 */
1178 STDMETHOD_(BOOL, IsSendWheel2Hover)() const OVERRIDE;
1179
1180 /**
1181 * @brief Updates the window.
1182 *
1183 * @param bForce Flag indicating whether to force the update.
1184 * @return TRUE if the update was successful, FALSE otherwise.
1185 */
1186 STDMETHOD_(BOOL, UpdateWindow)(BOOL bForce DEF_VAL(TRUE)) OVERRIDE;
1187
1188 /**
1189 * @brief Updates the tooltip for the container.
1190 */
1191 STDMETHOD_(void, UpdateTooltip)() OVERRIDE;
1192
1193 /**
1194 * @brief Sets the tooltip for the container.
1195 *
1196 * @param rc Rectangle for the tooltip.
1197 * @param tipAlign Alignment of the tooltip.
1198 * @param pszTip Tooltip text.
1199 */
1200 STDMETHOD_(void, SetToolTip)(THIS_ LPCRECT rc, UINT tipAlign, LPCTSTR pszTip) OVERRIDE;
1201
1202 /**
1203 * @brief Registers a timeline handler.
1204 *
1205 * @param pHandler Pointer to the timeline handler.
1206 * @return TRUE if the handler was registered, FALSE otherwise.
1207 */
1208 STDMETHOD_(BOOL, RegisterTimelineHandler)(THIS_ ITimelineHandler *pHandler) OVERRIDE;
1209
1210 /**
1211 * @brief Unregisters a timeline handler.
1212 *
1213 * @param pHandler Pointer to the timeline handler.
1214 * @return TRUE if the handler was unregistered, FALSE otherwise.
1215 */
1216 STDMETHOD_(BOOL, UnregisterTimelineHandler)(THIS_ ITimelineHandler *pHandler) OVERRIDE;
1217
1218 /**
1219 * @brief Enables or disables host private UI definitions.
1220 *
1221 * @param bEnable TRUE to enable, FALSE to disable.
1222 */
1223 STDMETHOD_(void, EnableHostPrivateUiDef)(THIS_ BOOL bEnable) OVERRIDE;
1224
1225 /**
1226 * @brief Gets the script module for the container.
1227 *
1228 * @return Pointer to the script module.
1229 */
1230 STDMETHOD_(IScriptModule *, GetScriptModule)() OVERRIDE;
1231
1232 /**
1233 * @brief Gets the scale factor for the container.
1234 *
1235 * @return Scale factor.
1236 */
1237 STDMETHOD_(int, GetScale)() const OVERRIDE;
1238
1239 /**
1240 * @brief Enables or disables IME (Input Method Editor).
1241 *
1242 * @param bEnable TRUE to enable, FALSE to disable.
1243 */
1244 STDMETHOD_(void, EnableIME)(BOOL bEnable) OVERRIDE;
1245
1246 /**
1247 * @brief Updates the cursor for the container.
1248 */
1249 STDMETHOD_(void, OnUpdateCursor)() OVERRIDE;
1250
1251 /**
1252 * @brief Posts a task to the container.
1253 *
1254 * @param runable Pointer to the runnable task.
1255 * @param bAsync Flag indicating whether the task should be run asynchronously.
1256 * @return TRUE if the task was posted, FALSE otherwise.
1257 */
1258 STDMETHOD_(BOOL, PostTask)(THIS_ IRunnable *runable, BOOL bAsync DEF_VAL(TRUE)) OVERRIDE;
1259
1260 /**
1261 * @brief Removes tasks for the specified object.
1262 *
1263 * @param pObj Pointer to the object.
1264 * @return Number of tasks removed.
1265 */
1266 STDMETHOD_(int, RemoveTasksForObject)(THIS_ void *pObj) OVERRIDE;
1267
1268protected:
1269 /**
1270 * @brief Creates a tooltip for the container.
1271 *
1272 * @return Pointer to the created tooltip.
1273 */
1274 virtual IToolTip *CreateTooltip() const;
1275
1276 /**
1277 * @brief Destroys the specified tooltip.
1278 *
1279 * @param pTooltip Pointer to the tooltip to destroy.
1280 */
1281 virtual void DestroyTooltip(IToolTip *pTooltip) const;
1282
1283protected:
1284 /**
1285 * @brief Loads the layout from a resource ID.
1286 *
1287 * @param xmlDoc XML document.
1288 * @return TRUE if the layout was loaded successfully, FALSE otherwise.
1289 */
1290 virtual BOOL OnLoadLayoutFromResourceID(SXmlDoc &xmlDoc);
1291
1292 /**
1293 * @brief Gets the initial XML node.
1294 *
1295 * @param xmlDoc XML document.
1296 * @return Initial XML node.
1297 */
1298 virtual SXmlNode OnGetInitXmlNode(SXmlDoc &xmlDoc);
1299
1300 /**
1301 * @brief Handles user-defined XML node.
1302 *
1303 * @param xmlUser User-defined XML node.
1304 */
1305 virtual void OnUserXmlNode(SXmlNode xmlUser);
1306
1307 /**
1308 * @brief Creates the root window.
1309 *
1310 * @return Pointer to the created root window.
1311 */
1312 virtual SRootWindow *CreateRoot();
1313
1314public:
1315 /**
1316 * @brief Handles the resize event of the root window.
1317 *
1318 * @param e Pointer to the event arguments.
1319 * @return TRUE if the event was handled, FALSE otherwise.
1320 */
1321 virtual BOOL onRootResize(IEvtArgs *e);
1322
1323public: // 事件处理接口
1324 /**
1325 * @brief Handles an event.
1326 *
1327 * @param pEvt Pointer to the event arguments.
1328 * @return TRUE if the event was handled, FALSE otherwise.
1329 */
1330 virtual BOOL _HandleEvent(IEvtArgs *pEvt);
1331
1332protected:
1333 /**
1334 * @brief Handles the WM_SETLANGUAGE message.
1335 *
1336 * @param uMsg Message identifier.
1337 * @param wp WPARAM.
1338 * @param lp LPARAM.
1339 * @return LRESULT.
1340 */
1341 LRESULT OnSetLanguage(UINT uMsg, WPARAM wp, LPARAM lp);
1342
1343 /**
1344 * @brief Handles the WM_UPDATEFONT message.
1345 *
1346 * @param uMsg Message identifier.
1347 * @param wp WPARAM.
1348 * @param lp LPARAM.
1349 * @return LRESULT.
1350 */
1351 LRESULT OnUpdateFont(UINT uMsg, WPARAM wp, LPARAM lp);
1352
1353 /**
1354 * @brief Handles the UM_RUN_TASKS message.
1355 *
1356 * @param uMsg Message identifier.
1357 * @param wp WPARAM.
1358 * @param lp LPARAM.
1359 * @return LRESULT.
1360 */
1361 LRESULT OnRunTasks(UINT uMsg, WPARAM wp, LPARAM lp);
1362
1363
1364 BEGIN_MSG_MAP_EX(SHostWnd)
1365 MSG_WM_SIZE(OnSize)
1366 MSG_WM_PRINT(OnPrint)
1367 MSG_WM_PAINT(OnPaint)
1368 MSG_WM_CREATE(OnCreate)
1369 MSG_WM_DESTROY(OnDestroy)
1370 MSG_WM_ERASEBKGND(OnEraseBkgnd)
1371 MSG_WM_MOUSELEAVE(OnMouseLeave)
1372 MSG_WM_MOUSEMOVE(OnMouseMove)
1373 MSG_WM_MOUSEWHEEL(OnMouseWheel)
1374 MSG_WM_ACTIVATE(OnActivate)
1375 MSG_WM_SETFOCUS(OnSetFocus)
1376 MSG_WM_KILLFOCUS(OnKillFocus)
1377 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseEvent)
1378 MESSAGE_RANGE_HANDLER_EX(WM_KEYFIRST, WM_KEYLAST, OnKeyEvent)
1379 MESSAGE_RANGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, WM_IME_KEYLAST, OnKeyEvent)
1380 MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent)
1381 MESSAGE_HANDLER_EX(WM_IME_REQUEST, OnKeyEvent)
1382 MESSAGE_HANDLER_EX(WM_ACTIVATEAPP, OnActivateApp)
1383 MSG_WM_SETCURSOR(OnSetCursor)
1384 MSG_WM_TIMER(OnTimer)
1385 MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo)
1386 MSG_WM_CAPTURECHANGED(OnCaptureChanged)
1387 MESSAGE_HANDLER_EX(UM_MENUEVENT, OnMenuExEvent)
1388 MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging)
1389 MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged)
1390 MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
1391 MSG_WM_COMMAND(OnCommand)
1392 MSG_WM_SYSCOMMAND(OnSysCommand)
1393 MESSAGE_HANDLER_EX(UM_UPDATEFONT, OnUpdateFont)
1394 MESSAGE_HANDLER_EX(UM_SETLANGUAGE, OnSetLanguage)
1395 MESSAGE_HANDLER_EX(UM_RUN_TASKS, OnRunTasks)
1396 CHAIN_MSG_MAP_MEMBER(*m_pNcPainter)
1397#if (!DISABLE_SWNDSPY)
1398 MESSAGE_HANDLER_EX(SPYMSG_SETSPY, OnSpyMsgSetSpy)
1399 MESSAGE_HANDLER_EX(SPYMSG_SWNDENUM, OnSpyMsgSwndEnum)
1400 MESSAGE_HANDLER_EX(SPYMSG_SWNDINFO, OnSpyMsgSwndSpy)
1401 MESSAGE_HANDLER_EX(SPYMSG_HITTEST, OnSpyMsgHitTest)
1402#endif // DISABLE_SWNDSPY
1403 REFLECT_NOTIFY_CODE(NM_CUSTOMDRAW)
1404 END_MSG_MAP()
1405};
1406
1407SNSEND
1408#endif // __SHOSTWND__H__
Drag-and-drop target dispatcher module.
Interface and Implementation for Native Window Handling.
SOUI窗口容器的实现
Smart pointer class for managing COM-style reference-counted objects.
Wrapper class for a critical section.
Handler class for host window animations.
Definition SHostWnd.h:762
SHostWnd * m_pHostWnd
Pointer to the host window.
Definition SHostWnd.h:767
void OnNextFrame() OVERRIDE
Called on each frame of the animation.
CRect m_rcInit
Initial rectangle of the host window.
Definition SHostWnd.h:772
Class defining attributes for the host window.
Definition SHostWnd.h:42
void SetSendWheel2Hover(bool value)
Sets whether wheel messages are sent to the hover window.
Definition shostwnd.cpp:135
BOOL m_bResizable
Definition SHostWnd.h:165
SLayoutSize m_rcMaxInset[4]
Definition SHostWnd.h:162
void SetTranslucent(bool bTranslucent)
Sets whether the window is translucent.
Definition shostwnd.cpp:125
CSize GetMinSize(int nScale) const
Gets the minimum size of the window.
Definition shostwnd.cpp:117
SLayoutSize m_rcMargin[4]
Definition SHostWnd.h:160
WndType m_wndType
Definition SHostWnd.h:164
BOOL m_bSendWheel2Hover
Definition SHostWnd.h:171
virtual LPCWSTR GetTrCtx() const
Gets the translation context.
Definition shostwnd.cpp:92
SLayoutSize m_szMin[2]
Definition SHostWnd.h:161
BOOL m_bHasMsgLoop
Definition SHostWnd.h:172
BOOL m_bAllowSpy
Definition SHostWnd.h:170
void SetTrCtx(const SStringW &strTrCtx)
Sets the translation context.
Definition shostwnd.cpp:130
BOOL m_bTranslucent
Definition SHostWnd.h:168
CRect GetMaxInset(int nScale) const
Gets the maximum inset size of the window.
Definition shostwnd.cpp:97
void Init()
Initializes the window attributes.
Definition shostwnd.cpp:71
friend class SHostWnd
Friend class declaration allowing access to private members.
Definition SHostWnd.h:58
BOOL m_bAutoShape
Definition SHostWnd.h:169
BOOL m_bToolWnd
Definition SHostWnd.h:167
CRect GetMargin(int nScale) const
Gets the margin of the window.
Definition shostwnd.cpp:107
SHostWndAttr(void)
Constructor for SHostWndAttr.
Definition shostwnd.cpp:56
SStringW m_strTrCtx
Definition SHostWnd.h:176
BOOL m_bAppWnd
Definition SHostWnd.h:166
The main host window class responsible for managing the layout, events, and rendering of SOUI windows...
Definition SHostWnd.h:318
BOOL OnSetCursor(HWND hWnd, UINT nHitTest, UINT message)
Handles the WM_SETCURSOR message.
Definition shostwnd.cpp:998
BOOL UnregisterTimelineHandler(ITimelineHandler *pHandler) OVERRIDE
Unregisters a timeline handler.
LRESULT OnKeyEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles key events.
BOOL RegisterTimelineHandler(ITimelineHandler *pHandler) OVERRIDE
Registers a timeline handler.
void OnDestroy()
Handles the WM_DESTROY message.
Definition shostwnd.cpp:901
virtual void OnHostAnimationStoped(IAnimation *pAni)
Called when the host window animation stops.
void _Init()
Initializes the host window.
Definition shostwnd.cpp:327
static void SetHideLocalUiDef(BOOL bHide)
Sets whether to hide local UI definitions globally.
Definition shostwnd.cpp:303
BOOL m_bNeedAllRepaint
Definition SHostWnd.h:330
void EnableHostPrivateUiDef(BOOL bEnable) OVERRIDE
Enables or disables host private UI definitions.
void OnRedraw(LPCRECT rc, BOOL bClip) OVERRIDE
Redraws the specified rectangle in the container.
void UpdatePresenter(HDC dc, IRenderTarget *pRT, LPCRECT rc, BYTE byAlpha=255, UINT uFlag=0)
Updates the presenter.
LRESULT OnActivateApp(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles the WM_ACTIVATEAPP message.
EventHandlerInfo m_evtHandler
Definition SHostWnd.h:353
SAutoRefPtr< IUiDefInfo > m_privateUiDefInfo
Definition SHostWnd.h:336
int m_nAutoSizing
Definition SHostWnd.h:344
CSize m_szPrev
Definition SHostWnd.h:343
SWindow * FindChildByID(int nID, int nDeep=-1)
Finds a child window by its ID.
Definition SHostWnd.h:648
void OnSysCommand(UINT nID, CPoint lParam)
Handles the WM_SYSCOMMAND message.
void _Invalidate(LPCRECT prc)
Invalidates a specific region of the window.
BOOL m_bTrackFlag
Definition SHostWnd.h:328
SNativeWnd * GetNative()
Gets the native window interface.
Definition SHostWnd.h:695
BOOL OnEraseBkgnd(HDC dc)
Handles the WM_ERASEBKGND message.
Definition shostwnd.cpp:812
virtual BOOL onRootResize(IEvtArgs *e)
Handles the resize event of the root window.
Definition shostwnd.cpp:410
virtual IToolTip * CreateTooltip() const
Creates a tooltip for the container.
Definition shostwnd.cpp:817
void SetLayoutId(LPCTSTR pszLayoutId) OVERRIDE
Sets the layout ID for the host window.
Definition SHostWnd.h:421
LRESULT OnGetObject(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles the WM_GETOBJECT message.
void _RedrawRegion(IRegionS *pRgn, CRect &rcInvalid)
Redraws a specific region of the window.
Definition shostwnd.cpp:725
SDummyWnd * m_dummyWnd
Definition SHostWnd.h:324
virtual SRootWindow * CreateRoot()
Creates the root window.
Definition shostwnd.cpp:843
BOOL OnFireEvent(IEvtArgs *evt) OVERRIDE
Fires an event in the container.
BOOL m_bNeedRepaint
Definition SHostWnd.h:329
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
Handles the WM_MOUSEWHEEL message.
void SetToolTip(LPCRECT rc, UINT tipAlign, LPCTSTR pszTip) OVERRIDE
Sets the tooltip for the container.
SList< IRunnable * > m_runnables
Definition SHostWnd.h:357
IWindow * FindIChildByID(int nId) OVERRIDE
Finds a child window by its ID.
Definition SHostWnd.h:463
IToolTip * m_pTipCtrl
Definition SHostWnd.h:332
SAutoRefPtr< IRenderTarget > m_memRT
Definition SHostWnd.h:335
void _RestoreClickState()
Restores the click state of the window.
SHostWnd(LPCWSTR pszResName=NULL)
Constructs a SHostWnd object with an optional resource name.
Definition shostwnd.cpp:313
SWindow * FindChildByName(LPCWSTR strName, int nDeep=-1)
Finds a child window by its name (Unicode version).
Definition SHostWnd.h:596
void OnCommand(UINT uNotifyCode, int nID, HWND wndCtl)
Handles the WM_COMMAND message.
virtual void OnUserXmlNode(SXmlNode xmlUser)
Handles user-defined XML node.
static void SetTaskQueueBufSize(int nBufSize)
Sets the buffer size for asynchronous task queues.
Definition shostwnd.cpp:308
LRESULT OnUpdateFont(UINT uMsg, WPARAM wp, LPARAM lp)
Handles the WM_UPDATEFONT message.
LRESULT OnRunTasks(UINT uMsg, WPARAM wp, LPARAM lp)
Handles the UM_RUN_TASKS message.
tid_t m_dwThreadID
Definition SHostWnd.h:350
void OnSize(UINT nType, CSize size)
Handles the WM_SIZE message.
Definition shostwnd.cpp:948
virtual BOOL _HandleEvent(IEvtArgs *pEvt)
Handles an event.
T * FindChildByName2(LPCWSTR pszName, int nDeep=-1)
Finds a child window by its name (Unicode version) with template support.
Definition SHostWnd.h:622
SCriticalSection m_cs
Definition SHostWnd.h:356
BOOL IsSendWheel2Hover() const OVERRIDE
Checks if wheel messages are sent to the hover window.
SAutoRefPtr< IAnimation > m_hostAnimation
Definition SHostWnd.h:347
friend class SNcPainter
Definition SHostWnd.h:321
void _PaintVideoCanvasForeground(IRenderTarget *pRT)
Paints the video canvas in the foreground.
void OnGetMinMaxInfo(LPMINMAXINFO lpMMI)
Handles the WM_GETMINMAXINFO message.
BOOL OnReleaseSwndCapture() OVERRIDE
Releases the capture from the container.
SAutoRefPtr< IRegionS > m_rgnInvalidate
Definition SHostWnd.h:334
SStringT m_strXmlLayout
Definition SHostWnd.h:326
T * FindChildByClass(int nDeep=-1) const
Finds a child window by its class.
Definition SHostWnd.h:675
CSize m_szAppSetted
Definition SHostWnd.h:342
SHostWndAttr & GetHostAttr()
Gets the host window attributes.
Definition SHostWnd.h:719
void OnMouseLeave()
Handles the WM_MOUSELEAVE message.
Definition shostwnd.cpp:992
virtual void OnHostAnimationStarted(IAnimation *pAni)
Called when the host window animation starts.
SWindow * FindChildByName(LPCSTR strName, int nDeep=-1)
Finds a child window by its name (ANSI version).
Definition SHostWnd.h:608
SCriticalSection m_csRunningQueue
Definition SHostWnd.h:358
LRESULT OnMenuExEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles custom menu events.
void _ExcludeVideoCanvasFromPaint(IRenderTarget *pRT)
Excludes the video canvas from painting.
MSG m_msgMouse
Definition SHostWnd.h:341
void OnUpdateCursor() OVERRIDE
Updates the cursor for the container.
SRootWindow * m_pRoot
Definition SHostWnd.h:351
SWND OnSetSwndCapture(SWND swnd) OVERRIDE
Sets the capture to the specified window.
SAutoRefPtr< SNcPainter > m_pNcPainter
Definition SHostWnd.h:339
virtual SXmlNode OnGetInitXmlNode(SXmlDoc &xmlDoc)
Gets the initial XML node.
Definition shostwnd.cpp:827
int RemoveTasksForObject(void *pObj) OVERRIDE
Removes tasks for the specified object.
void UpdateTooltip() OVERRIDE
Updates the tooltip for the container.
void OnWindowPosChanged(LPWINDOWPOS lpWndPos)
Handles the WM_WINDOWPOSCHANGED message.
BOOL UpdateWindow(BOOL bForce=TRUE) OVERRIDE
Updates the window.
int m_cEnableUiDefCount
Definition SHostWnd.h:337
IWindow * FindIChildByName(LPCWSTR pszName) OVERRIDE
Finds a child window by its name (Unicode version).
Definition SHostWnd.h:474
SWindow * GetRoot() const
Gets the root window.
Definition SHostWnd.h:685
void OnKillFocus(HWND wndFocus)
Handles the WM_KILLFOCUS message.
void UpdateRegion(IRegionS *rgn) OVERRIDE
Updates the specified region in the container.
void OnCaptureChanged(HWND wnd)
Handles the WM_CAPTURECHANGED message.
LRESULT OnSetLanguage(UINT uMsg, WPARAM wp, LPARAM lp)
Handles the WM_SETLANGUAGE message.
@ kNcCheckTimer
Definition SHostWnd.h:398
@ kPulseInterval
Definition SHostWnd.h:397
@ kTaskTimer
Definition SHostWnd.h:400
@ kTaskInterval
Definition SHostWnd.h:401
@ kPulseTimer
Definition SHostWnd.h:396
@ kNcCheckInterval
Definition SHostWnd.h:399
SHostWndAttr m_hostAttr
Definition SHostWnd.h:325
SAutoRefPtr< IScriptModule > m_pScriptModule
Definition SHostWnd.h:338
void OnPrint(HDC dc, UINT uFlags=0)
Handles the WM_PRINT message.
Definition shostwnd.cpp:761
void OnPaint(HDC dc)
Handles the WM_PAINT message.
Definition shostwnd.cpp:800
static int s_TaskQueueBufSize
Definition SHostWnd.h:362
static BOOL s_HideLocalUiDef
Definition SHostWnd.h:361
void EnableIME(BOOL bEnable) OVERRIDE
Enables or disables IME (Input Method Editor).
T * FindChildByName2(LPCSTR pszName, int nDeep=-1)
Finds a child window by its name (ANSI version) with template support.
Definition SHostWnd.h:636
friend class SRootWindow
Definition SHostWnd.h:320
virtual void DestroyTooltip(IToolTip *pTooltip) const
Destroys the specified tooltip.
Definition shostwnd.cpp:822
bool m_bResizing
Definition SHostWnd.h:345
HWND GetHostHwnd() OVERRIDE
Gets the handle to the host window.
IWindow * GetIRoot() OVERRIDE
Gets the root window interface.
Definition SHostWnd.h:429
void OnSetFocus(HWND wndOld)
Handles the WM_SETFOCUS message.
IWindow * FindIChildByNameA(LPCSTR pszName) OVERRIDE
Finds a child window by its name (ANSI version).
Definition SHostWnd.h:485
LPCWSTR GetTranslatorContext() const OVERRIDE
Gets the translator context for the container.
void GetContainerRect(RECT *ret) const OVERRIDE
Gets the rectangle of the container.
void OnMouseMove(UINT nFlags, CPoint point)
Handles the WM_MOUSEMOVE message.
Definition shostwnd.cpp:978
BOOL PostTask(IRunnable *runable, BOOL bAsync=TRUE) OVERRIDE
Posts a task to the container.
LRESULT OnMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles mouse events.
virtual BOOL OnLoadLayoutFromResourceID(SXmlDoc &xmlDoc)
Loads the layout from a resource ID.
Definition shostwnd.cpp:833
int GetScale() const OVERRIDE
Gets the scale factor for the container.
void OnTimer(UINT_PTR idEvent)
Handles the WM_TIMER message.
T * FindChildByID2(int nID, int nDeep=-1)
Finds a child window by its ID with template support.
Definition SHostWnd.h:662
SAutoRefPtr< IHostPresenter > m_presenter
Definition SHostWnd.h:354
void _SetToolTipInfo(const SwndToolTipInfo *info, BOOL bNcTip)
Sets tooltip information for the window.
BOOL m_bFirstShow
Definition SHostWnd.h:349
IScriptModule * GetScriptModule() OVERRIDE
Gets the script module for the container.
DWORD m_AniState
Definition SHostWnd.h:348
int OnCreate(LPCREATESTRUCT lpCreateStruct)
Handles the WM_CREATE message.
Definition shostwnd.cpp:848
void _Redraw()
Redraws the entire window.
Definition shostwnd.cpp:718
SList< IRunnable * > m_runningQueue
Definition SHostWnd.h:359
IXmlNode * m_xmlInit
Definition SHostWnd.h:360
void OnActivate(UINT nState, BOOL bMinimized, HWND wndOther)
Handles the WM_ACTIVATE message.
IToolTip * GetToolTip() const
Gets the tooltip interface.
Definition SHostWnd.h:729
INcPainter * GetNcPainter() OVERRIDE
Gets the non-client area painter for the host window.
Definition SHostWnd.h:495
friend class SDummyWnd
Definition SHostWnd.h:319
void OnWindowPosChanging(LPWINDOWPOS lpWndPos)
Handles the WM_WINDOWPOSCHANGING message.
布局大小类
Definition SLayoutSize.h:10
Helper class for painting.
Definition SWnd.h:178
virtual void OnAnimationInvalidate(IAnimation *pAni, bool bErase)
Called when an animation is invalidated.
Definition shostwnd.cpp:168
virtual BOOL IsLayeredWindow() const
Checks if the window is a layered window.
Definition SHostWnd.h:266
virtual void BeforePaint(IRenderTarget *pRT, SPainter &painter)
Called before painting the window.
Definition shostwnd.cpp:202
SRootWindow(SHostWnd *pHostWnd)
Constructor for SRootWindow.
Definition shostwnd.cpp:160
void OnAnimationStop(IAnimation *pAni) OVERRIDE
Called when an animation stops.
Definition shostwnd.cpp:182
SHostWnd * GetHostWnd() const
Gets the pointer to the host window.
Definition shostwnd.cpp:284
virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter)
Called after painting the window.
Definition shostwnd.cpp:219
void FireMenuCmd(int menuID)
Fires a menu command event.
Definition shostwnd.cpp:289
void UpdateLayout() OVERRIDE
Updates the layout of the window.
Definition shostwnd.cpp:224
A class representing an ASCII string.
Definition sstringw.h:96
Base class for SOUI DUI windows.
Definition SWnd.h:286
SWindow()
Constructor.
Definition Swnd.cpp:104
Implementation of IXmlDoc.
Definition SXml.h:912
Class representing an XML node.
Definition SXml.h:352
SwndContainerImpl()
Constructor.
Interface for Tooltip Objects.
Interface for message loops.
Definition SMsgLoop-i.h:42
Region object interface.
Definition SRender-i.h:792
Interface for rendering target objects.
Definition SRender-i.h:1440
时间轴处理接口
Interface for Tooltip Objects.
Definition stooltip-i.h:61
Interface for XML nodes.
Definition sxml-i.h:128
Information for window tooltips.
Definition SWnd.h:208