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>
28#ifndef DISABLE_SWNDSPY
30#define DISABLE_SWNDSPY 1
32#define DISABLE_SWNDSPY 0
59 friend class SRootWindow;
60 friend class SNcPainter;
61 friend class SHostPresenter;
136 ATTR_STRINGW(L
"title", m_strTitle, 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)
148 ATTR_ICON(L
"smallIcon", m_hAppIconSmall, FALSE)
149 ATTR_ICON(L
"bigIcon", m_hAppIconBig, 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)
178 HICON m_hAppIconSmall;
191 friend class SHostWnd;
275 virtual HRESULT OnLanguageChanged();
282 virtual void OnScaleChanged(
int scale);
290 virtual void RequestRelayout(SWND hSource, BOOL bSourceResizable);
295 ATTR_ANIMATION(L
"enterAnimation", m_aniEnter, FALSE)
296 ATTR_ANIMATION(L
"exitAnimation", m_aniExit, FALSE)
317 : public TNativeWndProxy<IHostWnd>
369 SHostWnd(LPCWSTR pszResName = NULL);
409 STDMETHOD_(BOOL, InitFromXml)(THIS_
IXmlNode *pNode) OVERRIDE;
415 STDMETHOD_(BOOL, DestroyWindow)(THIS) OVERRIDE;
421 STDMETHOD_(
void,
SetLayoutId)(THIS_ LPCTSTR pszLayoutId) OVERRIDE {
437 STDMETHOD_(BOOL, IsTranslucent)(CTHIS) SCONST OVERRIDE;
443 STDMETHOD_(IHostPresenter *, GetPresenter)(THIS) OVERRIDE;
449 STDMETHOD_(
void, SetPresenter)(THIS_ IHostPresenter *pPresenter) OVERRIDE;
465 return m_pRoot->FindIChildByID(nId);
476 return m_pRoot->FindIChildByName(pszName);
487 return m_pRoot->FindIChildByNameA(pszName);
506STDMETHOD_(BOOL, ShowWindow)(THIS_
int nCmdShow) OVERRIDE;
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;
534STDMETHOD_(HWND, Create)
535(THIS_ HWND hWndParent,
int x = 0,
int y = 0,
int nWidth = 0,
int nHeight = 0) OVERRIDE;
543STDMETHOD_(
void, SetEventHandler)(THIS_ FunCallback fun,
void *ctx) OVERRIDE;
550STDMETHOD_(EventHandlerInfo *, GetEventHandler)(THIS) OVERRIDE;
559STDMETHOD_(BOOL, AnimateHostWindow)(THIS_ DWORD dwTime, DWORD dwFlags) OVERRIDE;
564STDMETHOD_(
void, EnableDragDrop)(THIS) OVERRIDE;
572STDMETHOD_(
void, ShowHostWnd)(THIS_
int uShowCmd, BOOL bWaitAniDone) OVERRIDE;
579STDMETHOD_(
void, EnablePrivateUiDef)(THIS_ BOOL bEnable) OVERRIDE;
587STDMETHOD_(
void, SetScale)(THIS_
int nScale, LPCRECT pDestRect) OVERRIDE;
598 return GetRoot()->FindChildByName(strName, nDeep);
610 return GetRoot()->FindChildByName(strName, nDeep);
624 return GetRoot()->FindChildByName2<T>(pszName, nDeep);
638 return GetRoot()->FindChildByName2<T>(pszName, nDeep);
650 return GetRoot()->FindChildByID(nID, nDeep);
664 return GetRoot()->FindChildByID2<T>(nID, nDeep);
677 return GetRoot()->FindChildByClass<T>(nDeep);
705CRect GetWindowRect()
const;
712CRect GetClientRect()
const;
740bool StartHostAnimation(IAnimation *pAni);
747bool StopHostAnimation();
754void UpdateAutoSizeCount(
bool bInc);
779 } m_hostAnimationHandler;
858 void OnPrint(HDC dc, UINT uFlags = 0);
881 int OnCreate(LPCREATESTRUCT lpCreateStruct);
894 void OnSize(UINT nType, CSize size);
917 BOOL
OnSetCursor(HWND hWnd, UINT nHitTest, UINT message);
924 void OnTimer(UINT_PTR idEvent);
934 LRESULT
OnMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
944 LRESULT
OnKeyEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
954 LRESULT
OnActivateApp(UINT uMsg, WPARAM wParam, LPARAM lParam);
964 BOOL
OnMouseWheel(UINT nFlags,
short zDelta, CPoint pt);
973 void OnActivate(UINT nState, BOOL bMinimized, HWND wndOther);
1022 LRESULT
OnMenuExEvent(UINT uMsg, WPARAM wParam, LPARAM lParam);
1046 LRESULT
OnGetObject(UINT uMsg, WPARAM wParam, LPARAM lParam);
1063 void OnCommand(UINT uNotifyCode,
int nID, HWND wndCtl);
1065#if (!DISABLE_SWNDSPY)
1075 LRESULT OnSpyMsgSetSpy(UINT uMsg, WPARAM wParam, LPARAM lParam);
1085 LRESULT OnSpyMsgSwndEnum(UINT uMsg, WPARAM wParam, LPARAM lParam);
1095 LRESULT OnSpyMsgSwndSpy(UINT uMsg, WPARAM wParam, LPARAM lParam);
1105 LRESULT OnSpyMsgHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam);
1120 STDMETHOD_(BOOL,
OnFireEvent)(IEvtArgs *evt) OVERRIDE;
1156 STDMETHOD_(
void,
OnRedraw)(LPCRECT rc, BOOL bClip) OVERRIDE;
1186 STDMETHOD_(BOOL,
UpdateWindow)(BOOL bForce DEF_VAL(TRUE)) OVERRIDE;
1200 STDMETHOD_(
void,
SetToolTip)(THIS_ LPCRECT rc, UINT tipAlign, LPCTSTR pszTip) OVERRIDE;
1237 STDMETHOD_(
int,
GetScale)()
const OVERRIDE;
1244 STDMETHOD_(
void,
EnableIME)(BOOL bEnable) OVERRIDE;
1258 STDMETHOD_(BOOL,
PostTask)(THIS_ IRunnable *runable, BOOL bAsync DEF_VAL(TRUE)) OVERRIDE;
1361 LRESULT
OnRunTasks(UINT uMsg, WPARAM wp, LPARAM lp);
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)
1381 MESSAGE_HANDLER_EX(WM_IME_REQUEST,
OnKeyEvent)
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)
1403 REFLECT_NOTIFY_CODE(NM_CUSTOMDRAW)
Drag-and-drop target dispatcher module.
Interface and Implementation for Native Window Handling.
Smart pointer class for managing COM-style reference-counted objects.
Wrapper class for a critical section.
Handler class for host window animations.
SHostWnd * m_pHostWnd
Pointer to the host window.
void OnNextFrame() OVERRIDE
Called on each frame of the animation.
CRect m_rcInit
Initial rectangle of the host window.
Class defining attributes for the host window.
void SetSendWheel2Hover(bool value)
Sets whether wheel messages are sent to the hover window.
SLayoutSize m_rcMaxInset[4]
void SetTranslucent(bool bTranslucent)
Sets whether the window is translucent.
CSize GetMinSize(int nScale) const
Gets the minimum size of the window.
SLayoutSize m_rcMargin[4]
virtual LPCWSTR GetTrCtx() const
Gets the translation context.
void SetTrCtx(const SStringW &strTrCtx)
Sets the translation context.
CRect GetMaxInset(int nScale) const
Gets the maximum inset size of the window.
void Init()
Initializes the window attributes.
friend class SHostWnd
Friend class declaration allowing access to private members.
CRect GetMargin(int nScale) const
Gets the margin of the window.
SHostWndAttr(void)
Constructor for SHostWndAttr.
The main host window class responsible for managing the layout, events, and rendering of SOUI windows...
BOOL OnSetCursor(HWND hWnd, UINT nHitTest, UINT message)
Handles the WM_SETCURSOR message.
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.
virtual void OnHostAnimationStoped(IAnimation *pAni)
Called when the host window animation stops.
void _Init()
Initializes the host window.
static void SetHideLocalUiDef(BOOL bHide)
Sets whether to hide local UI definitions globally.
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
SAutoRefPtr< IUiDefInfo > m_privateUiDefInfo
SWindow * FindChildByID(int nID, int nDeep=-1)
Finds a child window by its ID.
void OnSysCommand(UINT nID, CPoint lParam)
Handles the WM_SYSCOMMAND message.
void _Invalidate(LPCRECT prc)
Invalidates a specific region of the window.
SNativeWnd * GetNative()
Gets the native window interface.
BOOL OnEraseBkgnd(HDC dc)
Handles the WM_ERASEBKGND message.
virtual BOOL onRootResize(IEvtArgs *e)
Handles the resize event of the root window.
virtual IToolTip * CreateTooltip() const
Creates a tooltip for the container.
void SetLayoutId(LPCTSTR pszLayoutId) OVERRIDE
Sets the layout ID for the host window.
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.
virtual SRootWindow * CreateRoot()
Creates the root window.
BOOL OnFireEvent(IEvtArgs *evt) OVERRIDE
Fires an event in the container.
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
IWindow * FindIChildByID(int nId) OVERRIDE
Finds a child window by its ID.
SAutoRefPtr< IRenderTarget > m_memRT
void _RestoreClickState()
Restores the click state of the window.
SHostWnd(LPCWSTR pszResName=NULL)
Constructs a SHostWnd object with an optional resource name.
SWindow * FindChildByName(LPCWSTR strName, int nDeep=-1)
Finds a child window by its name (Unicode version).
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.
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.
void OnSize(UINT nType, CSize size)
Handles the WM_SIZE message.
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.
BOOL IsSendWheel2Hover() const OVERRIDE
Checks if wheel messages are sent to the hover window.
SAutoRefPtr< IAnimation > m_hostAnimation
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
T * FindChildByClass(int nDeep=-1) const
Finds a child window by its class.
SHostWndAttr & GetHostAttr()
Gets the host window attributes.
void OnMouseLeave()
Handles the WM_MOUSELEAVE message.
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).
SCriticalSection m_csRunningQueue
LRESULT OnMenuExEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles custom menu events.
void _ExcludeVideoCanvasFromPaint(IRenderTarget *pRT)
Excludes the video canvas from painting.
void OnUpdateCursor() OVERRIDE
Updates the cursor for the container.
SWND OnSetSwndCapture(SWND swnd) OVERRIDE
Sets the capture to the specified window.
SAutoRefPtr< SNcPainter > m_pNcPainter
virtual SXmlNode OnGetInitXmlNode(SXmlDoc &xmlDoc)
Gets the initial XML node.
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.
IWindow * FindIChildByName(LPCWSTR pszName) OVERRIDE
Finds a child window by its name (Unicode version).
SWindow * GetRoot() const
Gets the root window.
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.
SAutoRefPtr< IScriptModule > m_pScriptModule
void OnPrint(HDC dc, UINT uFlags=0)
Handles the WM_PRINT message.
void OnPaint(HDC dc)
Handles the WM_PAINT message.
static int s_TaskQueueBufSize
static BOOL s_HideLocalUiDef
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.
virtual void DestroyTooltip(IToolTip *pTooltip) const
Destroys the specified tooltip.
HWND GetHostHwnd() OVERRIDE
Gets the handle to the host window.
IWindow * GetIRoot() OVERRIDE
Gets the root window interface.
void OnSetFocus(HWND wndOld)
Handles the WM_SETFOCUS message.
IWindow * FindIChildByNameA(LPCSTR pszName) OVERRIDE
Finds a child window by its name (ANSI version).
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.
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.
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.
SAutoRefPtr< IHostPresenter > m_presenter
void _SetToolTipInfo(const SwndToolTipInfo *info, BOOL bNcTip)
Sets tooltip information for the window.
IScriptModule * GetScriptModule() OVERRIDE
Gets the script module for the container.
int OnCreate(LPCREATESTRUCT lpCreateStruct)
Handles the WM_CREATE message.
void _Redraw()
Redraws the entire window.
SList< IRunnable * > m_runningQueue
void OnActivate(UINT nState, BOOL bMinimized, HWND wndOther)
Handles the WM_ACTIVATE message.
IToolTip * GetToolTip() const
Gets the tooltip interface.
INcPainter * GetNcPainter() OVERRIDE
Gets the non-client area painter for the host window.
void OnWindowPosChanging(LPWINDOWPOS lpWndPos)
Handles the WM_WINDOWPOSCHANGING message.
Helper class for painting.
virtual void OnAnimationInvalidate(IAnimation *pAni, bool bErase)
Called when an animation is invalidated.
virtual BOOL IsLayeredWindow() const
Checks if the window is a layered window.
virtual void BeforePaint(IRenderTarget *pRT, SPainter &painter)
Called before painting the window.
SRootWindow(SHostWnd *pHostWnd)
Constructor for SRootWindow.
void OnAnimationStop(IAnimation *pAni) OVERRIDE
Called when an animation stops.
SHostWnd * GetHostWnd() const
Gets the pointer to the host window.
virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter)
Called after painting the window.
void FireMenuCmd(int menuID)
Fires a menu command event.
void UpdateLayout() OVERRIDE
Updates the layout of the window.
A class representing an ASCII string.
Base class for SOUI DUI windows.
Implementation of IXmlDoc.
Class representing an XML node.
SwndContainerImpl()
Constructor.
Interface for message loops.
Interface for rendering target objects.