1#include "include/souistd.h"
2#include "helper/SMenuEx.h"
3#include "helper/SplitString.h"
4#include <layout/SLinearLayout.h>
6#define TIMERID_POPSUBMENU 100
7#define TIME_PUPSUBMENU 500
9#define WIDTH_MENU_INIT 10000
10#define WIDTH_MENU_MAX 2000
11#define WIDTH_MENU_MIN 100.f
13#define Y_MIDFLAG L"-1000px"
14#define Y_IMIDFLAG (-1000)
18 DEF_SOBJECT(
SWindow, L
"menuRoot")
20 friend class SMenuExItem;
23 SAutoRefPtr<ISkinObj> m_pItemSkin;
24 SAutoRefPtr<ISkinObj> m_pIconSkin;
25 SAutoRefPtr<ISkinObj> m_pCheckSkin;
26 SAutoRefPtr<ISkinObj> m_pArrowSkin;
27 SAutoRefPtr<ISkinObj> m_pSepSkin;
31 SLayoutSize m_nItemHei;
32 SLayoutSize m_nIconBarWidth;
33 SLayoutSize m_nTextOffset;
34 SLayoutSize m_iconX, m_iconY;
35 SLayoutSize m_nMinWidth;
36 SLayoutSize m_nSubMenuOffset;
38 DWORD m_dwContextHelpId;
40 void Copy(SMenuExRoot *pNewMenuExRoot)
43 pNewMenuExRoot->m_pItemSkin = m_pItemSkin;
44 pNewMenuExRoot->m_pIconSkin = m_pIconSkin;
45 pNewMenuExRoot->m_pCheckSkin = m_pCheckSkin;
46 pNewMenuExRoot->m_pArrowSkin = m_pArrowSkin;
47 pNewMenuExRoot->m_pSepSkin = m_pSepSkin;
48 pNewMenuExRoot->m_nItemHei = m_nItemHei;
49 pNewMenuExRoot->m_nIconBarWidth = m_nIconBarWidth;
50 pNewMenuExRoot->m_nTextOffset = m_nTextOffset;
51 pNewMenuExRoot->m_iconX = m_iconX;
52 pNewMenuExRoot->m_iconY = m_iconY;
53 pNewMenuExRoot->m_nMinWidth = m_nMinWidth;
54 pNewMenuExRoot->m_nSubMenuOffset = m_nSubMenuOffset;
58 HRESULT OnAttrIconPos(
const SStringW &strValue, BOOL bLoading);
61 ATTR_SKIN(L
"itemSkin", m_pItemSkin, FALSE)
62 ATTR_SKIN(L
"checkSkin", m_pCheckSkin, FALSE)
63 ATTR_SKIN(L
"sepSkin", m_pSepSkin, FALSE)
64 ATTR_SKIN(L
"arrowSkin", m_pArrowSkin, FALSE)
65 ATTR_LAYOUTSIZE(L
"itemHeight", m_nItemHei, FALSE)
66 ATTR_CUSTOM(L
"iconPos", OnAttrIconPos)
67 ATTR_SKIN(L
"iconSkin", m_pIconSkin, FALSE)
68 ATTR_LAYOUTSIZE(L
"iconBarWidth", m_nIconBarWidth, FALSE)
69 ATTR_LAYOUTSIZE(L
"textOffset", m_nTextOffset, FALSE)
70 ATTR_LAYOUTSIZE(L
"minWidth", m_nMinWidth, FALSE)
71 ATTR_LAYOUTSIZE(L
"subMenuOffset", m_nSubMenuOffset, FALSE)
72 ATTR_DWORD(L
"contextHelpId", m_dwContextHelpId, FALSE)
76 SMenuExRoot(SMenuEx *pMenuEx)
77 : m_pItemSkin(GETBUILTINSKIN(SKIN_SYS_MENU_SKIN))
78 , m_pSepSkin(GETBUILTINSKIN(SKIN_SYS_MENU_SEP))
79 , m_pCheckSkin(GETBUILTINSKIN(SKIN_SYS_MENU_CHECK))
80 , m_pArrowSkin(GETBUILTINSKIN(SKIN_SYS_MENU_ARROW))
83 , m_dwContextHelpId(0)
86 m_nItemHei.setSize(26.f, SLayoutSize::dp);
87 m_nIconBarWidth.setSize(24.f, SLayoutSize::dp);
88 m_nMinWidth.setSize(WIDTH_MENU_MIN, SLayoutSize::dp);
93 SMenuExItem *GetNextMenuItem(SMenuExItem *pItem, BOOL bForword,
int nCount = 0);
97 HMONITOR hMonitor = MonitorFromWindow(m_pMenuEx->m_hWnd, MONITOR_DEFAULTTOPRIMARY);
98 MONITORINFO monitorInfo = {
sizeof(MONITORINFO), 0 };
99 GetMonitorInfo(hMonitor, &monitorInfo);
100 int maxHei = monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top;
102 GetDesiredSize(&szRet, -1, maxHei);
106 STDMETHOD_(
void, GetDesiredSize)(THIS_ SIZE *psz,
int wid,
int hei) OVERRIDE
108 __baseCls::GetDesiredSize(psz, wid, hei);
111 if (psz->cx < m_nMinWidth.toPixelSize(
GetScale()))
112 psz->cx = m_nMinWidth.toPixelSize(
GetScale());
115 STDMETHOD_(BOOL, InitFromXml)(THIS_ IXmlNode *pNode) OVERRIDE
117 SXmlNode xmlNode(pNode);
119 SXmlNode xmlRoot = xmlNode.root().first_child();
120 if (xmlNode != xmlRoot)
122 __baseCls::__baseCls::InitFromXml(&xmlRoot);
124 BOOL bRet = __baseCls::InitFromXml(&xmlNode);
129 BOOL CreateChildren(SXmlNode xmlNode) OVERRIDE
131 SXmlNode xmlItem = xmlNode.first_child();
134 SWindow *pMenuItem = CreateMenuItem(xmlItem.
name());
146 STDMETHOD_(
void, UpdateChildrenPosition)(THIS) OVERRIDE
151 virtual void OnScaleChanged(
int nScale)
153 __baseCls::OnScaleChanged(nScale);
161 SWindow *CreateMenuItem(
const SStringW &strItemName);
164HRESULT SMenuExRoot::OnAttrIconPos(
const SStringW &strValue, BOOL bLoading)
167 SplitString(strValue, L
',', values);
168 if (1 == values.GetCount())
171 m_iconX = GETLAYOUTSIZE(values[0]);
172 m_iconY.parseString(Y_MIDFLAG);
175 else if (2 != values.GetCount())
177 m_iconX = GETLAYOUTSIZE(values[0]);
178 m_iconY = GETLAYOUTSIZE(values[1]);
187 SMenuExItem *pRet = NULL;
201 return GetNextMenuItem(pRet, bForword, nCount + 1);
217 , m_pOwnerMenu(pOwnerMenu)
225 m_style.m_bTrackMouseEvent = TRUE;
231 __baseCls::OnPaint(pRT);
234 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
240 if (m_bCheck || m_bRadio)
242 if (pMenuRoot->m_pCheckSkin)
247 nState = m_bCheck ? 1 : 2;
249 if (icoY == Y_IMIDFLAG)
251 icoY = (rc.Height() - pMenuRoot->m_pCheckSkin->
GetSkinSize().cy) / 2;
254 CRect rcIcon(rc.TopLeft(), pMenuRoot->m_pCheckSkin->
GetSkinSize());
255 pMenuRoot->m_pCheckSkin->
DrawByIndex(pRT, rcIcon, nState);
258 else if (pMenuRoot->m_pIconSkin)
260 if (icoY == Y_IMIDFLAG)
262 icoY = (rc.Height() - pMenuRoot->m_pIconSkin->
GetSkinSize().cy) / 2;
265 CRect rcIcon(rc.TopLeft(), pMenuRoot->m_pIconSkin->
GetSkinSize());
266 pMenuRoot->m_pIconSkin->
DrawByIndex(pRT, rcIcon, m_iIcon);
269 if (m_pSubMenu && pMenuRoot->m_pArrowSkin)
272 CSize szArrow = pMenuRoot->m_pArrowSkin->
GetSkinSize();
273 rcArrow.left = rcArrow.right - szArrow.cx;
274 rcArrow.DeflateRect(0, (rcArrow.Height() - szArrow.cy) / 2);
304 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
307 pRect->left += pMenuRoot->m_nIconBarWidth.
toPixelSize(nScale) + pMenuRoot->m_nTextOffset.
toPixelSize(nScale);
309 pRect->right -= pMenuRoot->m_pArrowSkin->
GetSkinSize().cx;
315 __baseCls::GetDesiredSize(&szRet, wid, hei);
316 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
324 szRet.cx += pMenuRoot->m_pArrowSkin->
GetSkinSize().cx;
336 __baseCls::CreateChildren(xmlNode);
340 m_pSubMenu =
new SMenuEx(
this);
341 m_pSubMenu->LoadMenu2(&xmlNode);
352 return __baseCls::CreateChildByName(pszName);
357 m_pOwnerMenu->OnSubMenuHided(bUncheckItem);
369 m_pOwnerMenu->PopupSubMenu(
this, bCheckFirstItem);
376 m_pSubMenu->HideMenu(FALSE);
401 STDMETHOD_(
void, GetDesiredSize)(THIS_ SIZE *psz,
int wid,
int hei) OVERRIDE
403 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
427 BOOL OnEraseBkgnd(IRenderTarget *pRT)
434 void OnPaint(IRenderTarget *pRT)
439 MSG_WM_PAINT_EX(OnPaint)
440 MSG_WM_ERASEBKGND_EX(OnEraseBkgnd)
445SWindow *SMenuExRoot::CreateMenuItem(const SStringW &strItemName)
450 pMenuItem =
new SMenuExItem(m_pMenuEx, m_pItemSkin);
454 pMenuItem =
new SMenuExSep(m_pMenuEx, m_pSepSkin);
463class SMenuExRunData :
public TObjRefImpl<IObjRef> {
464 friend class SMenuEx;
467 SMenuExRunData(HWND hOwner,
int nScale)
475 BOOL IsMenuWnd(HWND hWnd)
477 SPOSITION pos = m_lstMenuEx.GetTailPosition();
480 if (m_lstMenuEx.GetPrev(pos)->m_hWnd == hWnd)
486 void PushMenuEx(SMenuEx *pMenu)
488 m_lstMenuEx.AddTail(pMenu);
493 if (m_lstMenuEx.IsEmpty())
495 return m_lstMenuEx.GetTail();
500 SASSERT(!m_lstMenuEx.IsEmpty());
501 SMenuEx *pMenuEx = m_lstMenuEx.RemoveTail();
505 SMenuEx *SMenuExFromHwnd(HWND hWnd)
507 SPOSITION pos = m_lstMenuEx.GetTailPosition();
510 SMenuEx *pMenuEx = m_lstMenuEx.GetPrev(pos);
511 if (pMenuEx->
m_hWnd == hWnd)
522 void ExitMenu(
int nCmdID)
525 SPOSITION pos = m_lstMenuEx.GetTailPosition();
528 SMenuEx *pMenuEx = m_lstMenuEx.GetPrev(pos);
552 SList<SMenuEx *> m_lstMenuEx;
560static SMenuExRunData *s_MenuData = NULL;
567 , m_bMenuInitialized(FALSE)
576 , m_bMenuInitialized(FALSE)
587 return new SMenuExRoot(
this);
593 BOOL bLoad = LOADXML(xmlMenu, strMenu);
602 SStringT strResId = S_CA2T(resId, CP_UTF8);
621 if (m_pParent == NULL)
626 HWND hWnd =
CreateEx(NULL, WS_POPUP, WS_EX_TOOLWINDOW | WS_EX_TOPMOST | WS_EX_NOACTIVATE, 0, 0, 0, 0, &root);
643 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
645 for (
int i = 0; i < nID && pItem; i++)
649 return sobj_cast<SMenuExItem>(pItem);
671 s_MenuData =
new SMenuExRunData(hOwner, nScale);
673 s_MenuData->AddRef();
675 HWND hActive = hOwner;
676 if (!hOwner || !::IsWindowEnabled(hOwner))
677 hActive = ::GetActiveWindow();
679 HWND hRoot = hActive;
680 while ((::GetWindowLong(hRoot, GWL_STYLE) & WS_CHILD) && ::GetParent(hRoot))
682 hRoot = ::GetParent(hRoot);
684 SetForegroundWindow(hRoot);
694 ::ScreenToClient(hActive, &pt);
695 ::PostMessage(hActive, WM_MOUSEMOVE, 0, MAKELPARAM(pt.x, pt.y));
698 int nRet = s_MenuData->GetCmdID();
699 if (0 == s_MenuData->Release())
703 if (flag & TPM_RETURNCMD)
709 ::SendMessage(hOwner, WM_COMMAND, MAKEWPARAM(nRet, 0), 0);
716 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
722 CSize szMenu = pMenuRoot->CalcMenuSize();
724 pMenuRoot->
Move(CRect(CPoint(), szMenu));
725 if (uFlag & TPM_CENTERALIGN)
729 else if (uFlag & TPM_RIGHTALIGN)
734 if (uFlag & TPM_VCENTERALIGN)
738 else if (uFlag & TPM_BOTTOMALIGN)
743 HMONITOR hMor = MonitorFromWindow(
m_hWnd, MONITOR_DEFAULTTOPRIMARY);
744 MONITORINFO mi = {
sizeof(MONITORINFO), 0 };
745 GetMonitorInfo(hMor, &mi);
746 CRect rcMenu(CPoint(x, y), szMenu);
748 rcInter.IntersectRect(&rcMenu, &mi.rcMonitor);
750 if (rcInter != rcMenu)
754 SMenuEx *pParent = m_pParent->GetOwnerMenu();
756 if (rcMenu.right > mi.rcMonitor.right)
758 rcMenu.MoveToX(x - szMenu.cx - rcParent.Width() - subMenuOffset);
762 rcMenu.MoveToX(x + subMenuOffset);
765 int xOffset = 0, yOffset = 0;
766 if (rcMenu.left < mi.rcMonitor.left)
767 xOffset = mi.rcMonitor.left - rcMenu.left;
768 else if (rcMenu.right > mi.rcMonitor.right)
769 xOffset = mi.rcMonitor.right - rcMenu.right;
770 if (rcMenu.top < mi.rcMonitor.top)
771 yOffset = mi.rcMonitor.top - rcMenu.top;
772 else if (rcMenu.bottom > mi.rcMonitor.bottom)
773 yOffset = mi.rcMonitor.bottom - rcMenu.bottom;
775 rcMenu.OffsetRect(xOffset, yOffset);
780 if (rcMenu.right > mi.rcMonitor.right)
782 rcMenu.MoveToX(x - szMenu.cx - subMenuOffset);
786 rcMenu.MoveToX(x + subMenuOffset);
789 if (rcMenu.top < mi.rcMonitor.top)
791 rcMenu.MoveToY(y + szMenu.cy);
793 if (rcMenu.bottom > mi.rcMonitor.bottom)
795 rcMenu.MoveToY(y - szMenu.cy);
802 rcMenu.MoveToX(x + subMenuOffset);
805 SetWindowPos(HWND_TOPMOST, rcMenu.left, rcMenu.top, szMenu.cx, szMenu.cy, SWP_SHOWWINDOW | SWP_NOACTIVATE);
806 s_MenuData->PushMenuEx(
this);
817 m_pCheckItem->SetCheck(FALSE);
820 s_MenuData->PopMenuEx();
823 m_pParent->OnSubMenuHided(bUncheckParentItem);
830 m_pCheckItem->HideSubMenu();
835 return MA_NOACTIVATE;
842 BOOL bMsgQuit(FALSE);
850 if (s_MenuData->IsMenuExited())
855 if (GetForegroundWindow() != hRoot)
863 if (msgLoop->PeekMsg(&msg, 0, 0, FALSE))
865 if (!CallMsgFilter(&msg, MSGF_MENU))
867 msgLoop->PeekMsg(&msg, msg.message, msg.message, TRUE);
875 if (msg.message == WM_KEYDOWN || msg.message == WM_KEYUP || msg.message == WM_SYSKEYDOWN || msg.message == WM_SYSKEYUP)
877 if (msg.wParam == VK_MENU)
879 s_MenuData->ExitMenu(0);
883 else if (msg.message == WM_LBUTTONDOWN || msg.message == WM_RBUTTONDOWN || msg.message == WM_NCLBUTTONDOWN || msg.message == WM_NCRBUTTONDOWN || msg.message == WM_LBUTTONDBLCLK)
886 if (!s_MenuData->IsMenuWnd(msg.hwnd))
888 s_MenuData->ExitMenu(0);
893 SMenuEx *pMenu = s_MenuData->SMenuExFromHwnd(msg.hwnd);
897 else if (msg.message == WM_QUIT)
903 msgLoop->PeekMsg(&msg, msg.message, msg.message, TRUE);
906 if (msg.message == WM_MOUSEMOVE)
908 if (msg.hwnd != hCurMenu)
912 ::SendMessage(hCurMenu, WM_MOUSELEAVE, 0, 0);
917 SMenuEx *pMenu = s_MenuData->SMenuExFromHwnd(msg.hwnd);
924 msgLoop->OnMsg(&msg);
926 if (msg.message == WM_KEYDOWN || msg.message == WM_KEYUP || msg.message == WM_CHAR)
928 HWND menuWnd = s_MenuData->GetMenuEx()->m_hWnd;
929 ::SendMessage(menuWnd, msg.message, msg.wParam, msg.lParam);
934 PostQuitMessage((
int)msg.wParam);
940class SMenuExEventOwner {
942 SMenuExEventOwner(
SMenuEx *pMenuEx)
951 static SMenuEx *GetEvtOwner()
957 static SMenuEx *s_pMenuEx;
960SMenuEx *SMenuExEventOwner::s_pMenuEx = NULL;
964 return SMenuExEventOwner::GetEvtOwner();
971 SMenuExItem *pMenuItem = sobj_cast<SMenuExItem>(pEvt->Sender());
972 if (pEvt->GetID() == EventSwndMouseHover::EventID)
977 m_pHoverItem = pMenuItem;
982 else if (pEvt->GetID() == EventSwndMouseLeave::EventID)
992 if (pEvt->GetID() != EventCmd::EventID)
1000 else if (pMenuItem->
GetID() == 0)
1004 s_MenuData->ExitMenu(pMenuItem->
GetID());
1007 else if (s_MenuData && ::IsWindow(s_MenuData->GetOwner()))
1009 SMenuExEventOwner evtOwner(
this);
1010 return (BOOL)::SendMessage(s_MenuData->GetOwner(), UM_MENUEVENT, (WPARAM)
this, (LPARAM)pEvt);
1020 if (timeID == TIMERID_POPSUBMENU)
1026 SetMsgHandled(FALSE);
1032 SASSERT(m_pCheckItem);
1035 m_pCheckItem->SetCheck(FALSE);
1036 m_pCheckItem = NULL;
1046 if (!pSubMenu->m_bMenuInitialized)
1060 rcItem.left = rcWnd.left, rcItem.right = rcWnd.right;
1061 ClientToScreen2(&rcItem);
1063 m_pCheckItem = pItem;
1065 pSubMenu->SetWindowLongPtr(GWLP_HWNDPARENT, (ULONG_PTR)
m_hWnd);
1066 pSubMenu->
ShowMenu(0, rcItem.right, rcItem.top);
1067 if (bCheckFirstItem)
1069 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(pSubMenu->
GetRoot());
1071 SMenuExItem *pFirstItem = pMenuRoot->GetNextMenuItem(NULL, TRUE);
1074 pSubMenu->m_pCheckItem = pFirstItem;
1082 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
1089 m_pCheckItem->SetCheck(FALSE);
1090 m_pCheckItem = pMenuRoot->GetNextMenuItem(m_pCheckItem, nChar == VK_DOWN);
1093 m_pCheckItem->SetCheck(TRUE);
1094 m_pCheckItem->Invalidate();
1105 s_MenuData->ExitMenu(0);
1111 m_pCheckItem->ShowSubMenu(TRUE);
1122 nChar = tolower(nChar);
1126 if ((UINT)tolower(pMenuItem->
GetHotKey()) == nChar)
1136 SetMsgHandled(FALSE);
1144 if (m_pParent != NULL)
1146 return m_pParent->GetTrCtx();
1158 return s_MenuData->GetScale();
1165 s_MenuData->ExitMenu(nCmdId);
1166 ::PostMessage(s_MenuData->GetOwner(), WM_NULL, 0, 0);
1169EXTERN_C
void EndMenuEx(
int nCmdId)
1176 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
1180 if (uFlag & MF_BYPOSITION)
1186 while (i < uPos && p)
1203 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
1207 if (uFlag & MF_BYCOMMAND && !pItemRef)
1228 if (!(uFlag & MF_SEPARATOR))
1231 if (uFlag & MF_POPUP)
1233 pMenuItem->m_pSubMenu =
new SMenuEx(pMenuItem);
1237 pMenuItem->SetAttribute(L
"ID",
SStringW().Format(L
"%d", nId));
1238 pMenuItem->SetAttribute(L
"icon",
SStringW().Format(L
"%d", iIcon));
1239 if (uFlag & MF_CHECKED)
1241 pMenuItem->SetAttribute(L
"check", L
"1");
1250 return InsertMenu(-1, uFlags, uIDNewItem, lpNewItem, iIcon);
1255 HWND hWnd =
CreateEx(NULL, WS_POPUP, WS_EX_TOOLWINDOW | WS_EX_TOPMOST, 0, 0, 0, 0);
1262 SMenuExRoot *pMenuRoot =
new SMenuExRoot(
this);
1266 ParentRoot->Copy(pMenuRoot);
1276 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
1287 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
1293 if (uFlag & MF_CHECKED)
1295 pItemRef->SetAttribute(L
"check", L
"1");
1299 pItemRef->SetAttribute(L
"check", L
"0");
1306 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
1312 if (!pItemRefFirst || !pItemRefLast || !pItemRefCheck)
1323 if (pChild == pItemRefFirst)
1325 else if (pChild == pItemRefCheck)
1327 else if (pChild == pItemRefLast)
1332 if (idxFirst == -1 || idxLast == -1 || idxCheck == -1)
1334 if (idxFirst < idxLast)
1337 pItemRefFirst = pItemRefLast;
1339 int tIdx = idxFirst;
1344 if (idxFirst > idxCheck || idxLast < idxCheck)
1347 pChild = pItemRefFirst;
1350 pChild->SetAttribute(L
"radio", L
"1");
1351 if (pChild == pItemRefCheck)
1353 pChild->SetAttribute(L
"check", L
"1");
1357 pChild->SetAttribute(L
"check", L
"0");
1359 if (pChild == pItemRefLast)
1369 if (m_bMenuInitialized)
1372 if (::IsWindow(s_MenuData->GetOwner()))
1374 ::SendMessage(s_MenuData->GetOwner(), WM_INITMENUPOPUP, (WPARAM)
this, (LPARAM)idx);
1376 m_bMenuInitialized = TRUE;
1381 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
1383 return pMenuRoot->m_dwContextHelpId;
1388 SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(
GetRoot());
1390 pMenuRoot->m_dwContextHelpId = dwId;
1431 lpItemString->Copy(&strText);
IMsgLoopFactory * GetMsgLoopFactory() OVERRIDE
Get the message loop factory.
Smart pointer class for managing COM-style reference-counted objects.
BOOL ShowWindow(int nCmdShow) OVERRIDE
Shows or hides the host window.
BOOL InitFromXml(IXmlNode *pNode) OVERRIDE
Initializes the host window from an XML node.
CRect GetWindowRect() const
Gets the window rectangle.
BOOL DestroyWindow() OVERRIDE
Destroys the host window.
SWindow * GetRoot() const
Gets the root window.
LPCWSTR GetTranslatorContext() const OVERRIDE
Gets the translator context for the container.
T * FindChildByID2(int nID, int nDeep=-1)
Finds a child window by its ID with template support.
IMessageLoop * GetMsgLoop() OVERRIDE
Gets the message loop interface.
HWND CreateEx(HWND hWndParent, DWORD dwStyle, DWORD dwExStyle, int x, int y, int nWidth, int nHeight, IXmlNode *xmlInit=NULL) OVERRIDE
Creates the host window with extended styles.
int toPixelSize(int scale) const
将大小转换为像素值
BOOL IsWindowVisible() SCONST OVERRIDE
Checks if the window is visible.
UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse, void(CALLBACK *lpfnTimer)(HWND, UINT, UINT_PTR, DWORD)=NULL) OVERRIDE
Sets a timer for the window.
BOOL KillTimer(UINT_PTR nIDEvent) OVERRIDE
Kills a timer for the window.
HWND m_hWnd
Handle to the window.
int GetID() SCONST OVERRIDE
Retrieves the object's ID.
static LPCWSTR GetClassName()
Root window class derived from SWindow.
SRootWindow(SHostWnd *pHostWnd)
Constructor for SRootWindow.
static SApplication & getSingleton(void)
static SApplication * getSingletonPtr(void)
A class representing an ASCII string.
Base class for SOUI DUI windows.
SAutoRefPtr< ISkinObj > m_pNcSkin
BOOL DestroyChild(SWindow *pChild)
Destroys a child window.
SWindow * GetParent() const
Retrieves the parent window.
DWORD GetState() SCONST OVERRIDE
Retrieves the current state of the window.
ULONG_PTR GetUserData() SCONST OVERRIDE
Retrieves the user data associated with the window.
int GetWindowText(TCHAR *pBuf, int nBufLen, BOOL bRawText) OVERRIDE
Retrieves the window text.
UINT GetChildrenCount() SCONST OVERRIDE
Retrieves the number of child windows.
void SDispatchMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0) OVERRIDE
Dispatches a message to the window.
int GetScale() SCONST OVERRIDE
Retrieves the scale factor of the window.
T * FindChildByID2(int nID, int nDeep=-1)
Finds a child window by its ID and casts it to a specific type.
HRESULT OnAttrLayout(const SStringW &strValue, BOOL bLoading)
Handles the 'layout' attribute.
virtual CRect GetClientRect() const
Retrieves the client rectangle of the window.
void InsertChild(SWindow *pNewChild, SWindow *pInsertAfter=NULL)
Inserts a child window into the window tree.
SWindow * GetRoot() const
Retrieves the root window in the hierarchy.
LRESULT SSendMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0, BOOL *pbMsgHandled=NULL) OVERRIDE
Sends a message to the window.
void SetCheck(BOOL bCheck) OVERRIDE
Sets the check state of the window.
ILayoutParam * GetLayoutParam() SCONST OVERRIDE
Retrieves the layout parameter object associated with the window.
SWindow * GetWindow(int uCode) const
Retrieves a window based on a given code.
BOOL IsDisabled(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if the window is disabled.
SAutoRefPtr< ISkinObj > m_pBgSkin
void SetWindowText(LPCTSTR lpszText) OVERRIDE
Sets the window text.
void GetWindowRect(LPRECT prect) SCONST OVERRIDE
Retrieves the bounding rectangle of the window.
ILayout * GetLayout() OVERRIDE
Retrieves the layout object associated with the window.
ULONG_PTR SetUserData(ULONG_PTR uData) OVERRIDE
Sets the user data for the window.
void GetScaleSkin(SAutoRefPtr< ISkinObj > &pSkin, int nScale)
Retrieves a scaled skin object based on the current scale factor.
BOOL InitFromXml(IXmlNode *pNode) OVERRIDE
Initializes the window from an XML node.
BOOL FireCommand() OVERRIDE
Fires a command event.
void Move(LPCRECT prect) OVERRIDE
Moves the window to a new position and size.
bool set_value(const wchar_t *rhs)
Sets the attribute value.
const wchar_t * value() const
Gets the attribute value.
Implementation of IXmlDoc.
SXmlNode root() const
Retrieves the root node of the document.
Class representing an XML node.
SXmlNode next_sibling() const
Gets the next sibling node in the children list of the parent node.
SXmlNode first_child() const
Gets the first child node of the node.
const wchar_t * name() const
Gets the name of the node.
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
SXmlAttr append_attribute(const wchar_t *name)
Adds an attribute with the specified name.
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
SXmlNode append_child(XmlNodeType type=node_element)
Adds a child node with the specified type.
HRESULT CreateMsgLoop(IMessageLoop **ppMsgLoop, IMessageLoop *pParentLoop=NULL) PURE
Creates a message loop.
Interface for rendering target objects.
Interface for Skin Objects.
void DrawByIndex(IRenderTarget *pRT, LPCRECT rcDraw, int iState) SCONST PURE
Draws the skin object to the specified render target with a given index.
SIZE GetSkinSize() SCONST PURE
Retrieves the default size of the skin object.