soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
Swnd.cpp
1#include "souistd.h"
2#include "core/SWnd.h"
3#include "core/SNcPainter.h"
4#include "helper/SColor.h"
5#include "helper/SplitString.h"
6#include "layout/SouiLayout.h"
7#include "interface/sacchelper-i.h"
8#include "helper/SwndFinder.h"
9#include "helper/STime.h"
10#include "animation/STransformation.h"
11#include "core/SCaret.h"
12#include <atl.mini/SComCli.h>
13
14SNSBEGIN
15
16//////////////////////////////////////////////////////////////////////////
17// STextTr
18//////////////////////////////////////////////////////////////////////////
19STrText::STrText(SWindow *pOwner_ /*= NULL*/)
20 : pOwner(pOwner_)
21 , bAutoEscape(true)
22{
23}
24
26{
27 pOwner = pOwner_;
28}
29
30SStringT STrText::GetText(BOOL bRawText) const
31{
32 return bRawText ? strRaw : strTr;
33}
34
35void STrText::SetText(const SStringT &strText, bool bEscape /*=true*/)
36{
37 strRaw = strText;
38 bAutoEscape = bEscape;
40}
41
43{
44 if (pOwner == NULL)
45 return;
46 SStringW str = pOwner->tr(S_CT2W(strRaw));
47 if (bAutoEscape)
48 str = EscapeString(str);
49 strTr = S_CW2T(str);
50}
51
53{
54 if (strValue.IsEmpty())
55 return strValue;
56 SStringW strText = strValue;
57 SStringW strCvt;
58 LPCWSTR pszBuf = strText;
59 int i = 0;
60 int iBegin = i;
61 while (i < strText.GetLength())
62 {
63 if (pszBuf[i] == L'\\' && i + 1 < strText.GetLength())
64 {
65 if (pszBuf[i + 1] == L'n')
66 {
67 strCvt += strText.Mid(iBegin, i - iBegin);
68 strCvt += L"\n";
69 i += 2;
70 iBegin = i;
71 }
72 else if (pszBuf[i + 1] == L't')
73 {
74 strCvt += strText.Mid(iBegin, i - iBegin);
75 strCvt += L"\t";
76 i += 2;
77 iBegin = i;
78 }
79 else if (pszBuf[i + 1] == L'\\')
80 {
81 strCvt += strText.Mid(iBegin, i - iBegin);
82 strCvt += L"\\";
83 i += 2;
84 iBegin = i;
85 }
86 else
87 {
88 i += 1;
89 }
90 }
91 else
92 {
93 i += 1;
94 }
95 }
96 strCvt += strText.Mid(iBegin);
97 return strCvt;
98}
99
100//////////////////////////////////////////////////////////////////////////
101// SWindow Implement
102//////////////////////////////////////////////////////////////////////////
103
105 : m_swnd(SWindowMgr::NewWindow(this))
106 , m_pContainer(NULL)
107 , m_pParent(NULL)
108 , m_pFirstChild(NULL)
109 , m_pLastChild(NULL)
110 , m_pNextSibling(NULL)
111 , m_pPrevSibling(NULL)
113 , m_uZorder(0)
115 , m_bMsgTransparent(FALSE)
116 , m_bVisible(TRUE)
117 , m_bDisplay(TRUE)
118 , m_bDisable(FALSE)
120 , m_bClipClient(FALSE)
121 , m_bFocusable(FALSE)
122 , m_bDrawFocusRect(TRUE)
123 , m_bCacheDraw(FALSE)
124 , m_bCacheDirty(TRUE)
125 , m_layoutDirty(dirty_self)
126 , m_bHoverAware(TRUE)
127 , m_bLayeredWindow(FALSE)
128 , m_bMsgHandled(FALSE)
129 , m_uData(0)
130 , m_pOwner(NULL)
131 , m_pCurMsg(NULL)
132 , m_pBgSkin(NULL)
133 , m_pNcSkin(NULL)
134 , m_pGetRTData(NULL)
135 , m_bFloat(FALSE)
136 , m_crColorize(0)
137 , m_strText(this)
138 , m_strToolTipText(this)
139 , m_animationHandler(this)
140 , m_isAnimating(false)
141 , m_isDestroying(false)
142 , m_isLoading(false)
143 , m_funSwndProc(NULL)
144#ifdef _DEBUG
145 , m_nMainThreadId(::GetCurrentThreadId()) // 初始化对象的线程不一定是主线程
146#endif
147{
148 m_nMaxWidth.setWrapContent();
149
150 m_pLayout.Attach(new SouiLayout());
151 m_pLayoutParam.Attach(new SouiLayoutParam());
152 m_pLayoutParam->SetMatchParent(Both);
153
154 m_evtSet.addEvent(EVENTID(EventGetCaret));
155 m_evtSet.addEvent(EVENTID(EventSwndCreate));
156 m_evtSet.addEvent(EVENTID(EventSwndInitFinish));
157 m_evtSet.addEvent(EVENTID(EventSwndDestroy));
158 m_evtSet.addEvent(EVENTID(EventSwndSize));
159 m_evtSet.addEvent(EVENTID(EventSwndPos));
160 m_evtSet.addEvent(EVENTID(EventSwndMouseHover));
161 m_evtSet.addEvent(EVENTID(EventSwndMouseLeave));
162 m_evtSet.addEvent(EVENTID(EventSwndStateChanged));
163 m_evtSet.addEvent(EVENTID(EventSwndVisibleChanged));
164 m_evtSet.addEvent(EVENTID(EventSwndCaptureChanged));
165 m_evtSet.addEvent(EVENTID(EventSwndUpdateTooltip));
166 m_evtSet.addEvent(EVENTID(EventMouseClick));
167 m_evtSet.addEvent(EVENTID(EventCmd));
168 m_evtSet.addEvent(EVENTID(EventCtxMenu));
169 m_evtSet.addEvent(EVENTID(EventSetFocus));
170 m_evtSet.addEvent(EVENTID(EventKillFocus));
171
172 m_evtSet.addEvent(EVENTID(EventSwndAnimationStart));
173 m_evtSet.addEvent(EVENTID(EventSwndAnimationStop));
174 m_evtSet.addEvent(EVENTID(EventSwndAnimationRepeat));
175
176 IAttrStorageFactory *pAttrFac = SApplication::getSingleton().GetAttrStorageFactory();
177 if (pAttrFac)
178 {
179 pAttrFac->CreateAttrStorage(this, &m_attrStorage);
180 }
181}
182
184{
185#ifdef SOUI_ENABLE_ACC
186 if (m_pAcc)
187 {
188 SComPtr<IAccHelper> accHelper;
189 if (m_pAcc->QueryInterface(__uuidof(IAccHelper), (void **)&accHelper) == S_OK)
190 {
191 SASSERT(accHelper->GetOwner() == NULL);
192 }
193 }
194#endif
196}
197
199{
200 if (m_funSwndProc)
201 {
202 m_funSwndProc(this, WM_NCDESTROY, 0, 0, NULL);
203 }
204 delete this;
205}
206
208{
209 return m_bMsgHandled;
210}
211
212void SWindow::SetMsgHandled(BOOL bHandled)
213{
214 m_bMsgHandled = bHandled ? 1 : 0;
215}
216
217// Get align
219{
220 return GetStyle().GetTextAlign();
221}
222
223void SWindow::GetWindowRect(LPRECT prect) const
224{
225 SASSERT(prect);
226 CRect rcWnd = GetWindowRect();
227 memcpy(prect, &rcWnd, sizeof(RECT));
228}
229
231{
232 return m_rcWindow;
233}
234
235void SWindow::GetClientRect(LPRECT pRect) const
236{
237 SASSERT(pRect);
238 CRect rc = GetWindowRect();
239 rc.DeflateRect(GetStyle().GetMargin());
240 *pRect = rc;
241}
242
244{
245 CRect rc;
247 return rc;
248}
249
250SStringT SWindow::GetWindowText(BOOL bRawText /*=FALSE*/)
251{
252 return m_strText.GetText(bRawText);
253}
254
255int SWindow::GetWindowTextU8(THIS_ IStringA *pStr, BOOL bRawText)
256{
257 SStringT strText = GetWindowText(bRawText);
258 SStringA strA = S_CT2A(strText, CP_UTF8);
259 pStr->Copy(&strA);
260 return pStr->GetLength();
261}
262
263int SWindow::GetWindowText(TCHAR *pBuf, int nBufLen, BOOL bRawText)
264{
265 SStringT str = GetWindowText(bRawText);
266 if (!pBuf)
267 return str.GetLength();
268 int nRet = smin(nBufLen, str.GetLength());
269 _tcsncpy(pBuf, str.c_str(), nRet);
270 if (nBufLen > nRet)
271 {
272 pBuf[nRet] = 0;
273 }
274 return nRet;
275}
276
278{
279 tipInfo.swnd = m_swnd;
280 tipInfo.dwCookie = 0;
281 tipInfo.rcTarget = GetWindowRect();
282
283 SMatrix mtx = _GetMatrixEx();
284 if (!mtx.isIdentity())
285 {
286 SRect src = SRect::IMake(tipInfo.rcTarget);
287 mtx.mapRect(&src);
288 tipInfo.rcTarget = src.toRect();
289 }
290
291 SStringT strTip;
292 EventSwndUpdateTooltip evt(this);
293 evt.bUpdated = FALSE;
294 evt.strToolTip = &strTip;
295 FireEvent(&evt);
296
297 if (evt.bUpdated)
298 {
299 tipInfo.strTip = strTip;
300 return !tipInfo.strTip.IsEmpty();
301 }
302 else
303 {
304 if (m_strToolTipText.GetText(FALSE).IsEmpty())
305 return FALSE;
306 tipInfo.strTip = m_strToolTipText.GetText(FALSE);
307 }
308 return TRUE;
309}
310
311void SWindow::SetWindowText(LPCTSTR lpszText)
312{
313 m_strText.SetText(lpszText, false);
314 accNotifyEvent(EVENT_OBJECT_NAMECHANGE);
316}
317
318void SWindow::SetWindowTextU8(THIS_ LPCSTR lpszText)
319{
320 SStringT str = S_CA2T(lpszText, CP_UTF8);
321 return SetWindowText(str);
322}
323
324void SWindow::SetEventMute(BOOL bMute)
325{
326 GetEventSet()->setMutedState(!!bMute);
327}
328
330{
331 if (IsVisible(TRUE))
332 Invalidate();
333 if (GetLayoutParam()->IsWrapContent(Any))
334 {
336 if (IsVisible(TRUE))
337 Invalidate();
338 }
339 else if (GetLayoutParam()->IsMatchParent(Any) && GetParent())
340 {
342 }
343}
344
346{
347#ifdef _DEBUG
348 if (IsBadWritePtr(this, sizeof(SWindow)))
349 {
350 SASSERT_MSGA(FALSE, "this is null!!!");
351 }
352 else
353 {
354 // 当你看到这个东西的时候,我不幸的告诉你,你的其他线程在刷界面
355 // 这是一件很危险的事情
356 tid_t dwCurThreadID = GetCurrentThreadId();
357 DWORD dwProcID = GetCurrentProcessId();
358 SASSERT_FMTW(m_nMainThreadId == dwCurThreadID, L"ProcessID:%d,请准备好红包再到群里提问", dwProcID);
359 }
360#endif
361}
362
363// Send a message to SWindow
364LRESULT SWindow::SSendMessage(UINT uMsg, WPARAM wParam /*= 0*/, LPARAM lParam /*= 0*/, BOOL *pbMsgHandled /*=NULL*/)
365{
366 LRESULT lResult = 0;
367
368 ASSERT_UI_THREAD();
369 SWindow *pOwner = GetOwner();
370 if (pOwner && uMsg != WM_DESTROY)
371 pOwner->AddRef();
372 AddRef();
373 SWNDMSG msgCur = { uMsg, wParam, lParam };
374 SWNDMSG *pOldMsg = m_pCurMsg;
375 m_pCurMsg = &msgCur;
376
377 BOOL bMsgHandled = SwndProc(uMsg, wParam, lParam, &lResult);
378 if (pbMsgHandled)
379 *pbMsgHandled = bMsgHandled;
380
381 m_pCurMsg = pOldMsg;
382 Release();
383 if (pOwner && uMsg != WM_DESTROY)
384 pOwner->Release();
385 return lResult;
386}
387
388void SWindow::SDispatchMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
389{
390 SSendMessage(uMsg, wParam, lParam);
392 while (pChild)
393 {
394 pChild->SDispatchMessage(uMsg, wParam, lParam);
395 pChild = pChild->GetWindow(GSW_NEXTSIBLING);
396 }
397}
398
399void SWindow::Move(LPCRECT prect)
400{
401 ASSERT_UI_THREAD();
402
403 if (prect)
404 {
405 m_bFloat = TRUE; //使用Move后,程序不再自动计算窗口坐标
406 OnRelayout(*prect);
407 }
408 else if (GetParent())
409 {
410 //恢复自动计算位置
411 m_bFloat = FALSE;
412 //重新计算自己及兄弟窗口的坐标
414 }
415}
416
417void SWindow::Move2(int x, int y, int cx /*=-1*/, int cy /*=-1*/)
418{
419 CRect rcWnd = GetWindowRect();
420 if (cx == -1)
421 cx = rcWnd.Width();
422 if (cy == -1)
423 cy = rcWnd.Height();
424 CRect rcNew(x, y, x + cx, y + cy);
425 Move(&rcNew);
426}
427
428// Set current cursor, when hover
429BOOL SWindow::OnSetCursor(const CPoint &pt)
430{
431 HCURSOR hCursor = GETRESPROVIDER->LoadCursor(GetStyle().m_strCursor);
432 ::SetCursor(hCursor);
433 return TRUE;
434}
435
436// Get SWindow state
437DWORD SWindow::GetState(void) const
438{
439 return m_dwState;
440}
441
442// Modify SWindow state
443DWORD SWindow::ModifyState(DWORD dwStateAdd, DWORD dwStateRemove, BOOL bUpdate /*=FALSE*/)
444{
445 ASSERT_UI_THREAD();
446
447 DWORD dwOldState = m_dwState;
448
449 DWORD dwNewState = m_dwState;
450 dwNewState &= ~dwStateRemove;
451 dwNewState |= dwStateAdd;
452
453 OnStateChanging(dwOldState, dwNewState);
454 m_dwState = dwNewState;
455 OnStateChanged(dwOldState, dwNewState);
456
457 if (bUpdate && NeedRedrawWhenStateChange())
458 {
459 MarkCacheDirty(true);
461 }
462 return dwOldState;
463}
464
465ULONG_PTR SWindow::GetUserData() const
466{
467 return m_uData;
468}
469
470ULONG_PTR SWindow::SetUserData(ULONG_PTR uData)
471{
472 ULONG_PTR uOld = m_uData;
473 m_uData = uData;
474 return uOld;
475}
476
477BOOL SWindow::SetTimer(char id, UINT uElapse)
478{
479 STimerID timerID(m_swnd, id);
480 return (BOOL)::SetTimer(GetContainer()->GetHostHwnd(), DWORD(timerID), uElapse, NULL);
481}
482
484{
485 STimerID timerID(m_swnd, id);
486 return ::KillTimer(GetContainer()->GetHostHwnd(), DWORD(timerID));
487}
488
490{
491 return m_swnd;
492}
493
494IWindow *SWindow::GetIParent() const
495{
496 return GetParent();
497}
498
499IWindow *SWindow::GetIRoot() const
500{
501 return GetRoot();
502}
503
505{
506 ASSERT_UI_THREAD();
507 if (!GetParent())
508 {
509 SSendMessage(WM_DESTROY);
510 Release();
511 }
512 else
513 {
514 GetParent()->DestroyChild(this);
515 }
516 return TRUE;
517}
518
520{
521 ASSERT_UI_THREAD();
522 if (this != pChild->GetParent())
523 return FALSE;
524 if (pChild->m_isDestroying)
525 return FALSE;
526 pChild->InvalidateRect(NULL);
527 pChild->SSendMessage(WM_DESTROY);
528 RemoveChild(pChild);
529 pChild->Release();
530 return TRUE;
531}
532
534{
535 return m_nChildrenCount;
536}
537
538void SWindow::InsertChild(SWindow *pNewChild, SWindow *pInsertAfter /*=ICWND_LAST*/)
539{
540 ASSERT_UI_THREAD();
541 if (pNewChild->GetParent() == this)
542 return;
543 OnBeforeInsertChild(pNewChild);
544 pNewChild->SetContainer(GetContainer());
545 pNewChild->m_pParent = this;
546 pNewChild->m_pPrevSibling = pNewChild->m_pNextSibling = NULL;
547
548 if (pInsertAfter == m_pLastChild)
549 pInsertAfter = ICWND_LAST;
550
551 if (pInsertAfter == ICWND_LAST)
552 {
553 // insert window at head
554 pNewChild->m_pPrevSibling = m_pLastChild;
555 if (m_pLastChild)
556 m_pLastChild->m_pNextSibling = pNewChild;
557 else
558 m_pFirstChild = pNewChild;
559 m_pLastChild = pNewChild;
560 }
561 else if (pInsertAfter == ICWND_FIRST)
562 {
563 // insert window at tail
564 pNewChild->m_pNextSibling = m_pFirstChild;
565 if (m_pFirstChild)
566 m_pFirstChild->m_pPrevSibling = pNewChild;
567 else
568 m_pLastChild = pNewChild;
569 m_pFirstChild = pNewChild;
570 }
571 else
572 {
573 // insert window at middle
574 SASSERT(pInsertAfter->m_pParent == this);
575 SASSERT(m_pFirstChild && m_pLastChild);
576 SWindow *pNext = pInsertAfter->m_pNextSibling;
577 SASSERT(pNext);
578 pInsertAfter->m_pNextSibling = pNewChild;
579 pNewChild->m_pPrevSibling = pInsertAfter;
580 pNewChild->m_pNextSibling = pNext;
581 pNext->m_pPrevSibling = pNewChild;
582 }
584
585 m_layoutDirty = dirty_self;
586
587 if (!GetLayout()->IsParamAcceptable(pNewChild->GetLayoutParam()))
588 { //检查子窗口原有的布局属性是不是和当前窗口的布局类型是否匹配
589 ILayoutParam *pLayoutParam = GetLayout()->CreateLayoutParam();
590 pNewChild->SetLayoutParam(pLayoutParam);
591 pLayoutParam->Release();
592 }
593
594 //继承父窗口的disable状态
595 pNewChild->OnEnable(!IsDisabled(TRUE), ParentEnable);
596
597 //只在插入新控件时需要标记zorder失效,删除控件不需要标记
599 OnAfterInsertChild(pNewChild);
600}
601
603{
604 ASSERT_UI_THREAD();
605 if (this != pChild->GetParent())
606 return FALSE;
607
608 OnBeforeRemoveChild(pChild);
609 pChild->SetContainer(NULL);
610
611 SWindow *pPrevSib = pChild->m_pPrevSibling;
612 SWindow *pNextSib = pChild->m_pNextSibling;
613
614 if (pPrevSib)
615 pPrevSib->m_pNextSibling = pNextSib;
616 else
617 m_pFirstChild = pNextSib;
618
619 if (pNextSib)
620 pNextSib->m_pPrevSibling = pPrevSib;
621 else
622 m_pLastChild = pPrevSib;
623
624 pChild->m_pParent = NULL;
625 pChild->m_pNextSibling = NULL;
626 pChild->m_pPrevSibling = NULL;
628
629 OnAfterRemoveChild(pChild);
630 return TRUE;
631}
632
634{
636}
637
638BOOL SWindow::IsDisabled(BOOL bCheckParent /*= FALSE*/) const
639{
640 if (bCheckParent)
642 else
643 return m_bDisable;
644}
645
646BOOL SWindow::IsVisible(BOOL bCheckParent /*= FALSE*/) const
647{
648 if (bCheckParent)
649 return (0 == (m_dwState & WndState_Invisible));
650 else
651 return m_bVisible;
652}
653
654//因为NotifyInvalidateRect只有窗口可见时再通知刷新,这里在窗口可见状态改变前后都执行一次通知。
655void SWindow::SetVisible(BOOL bVisible, BOOL bUpdate /*=FALSE*/)
656{
657 if (bUpdate)
659 SSendMessage(WM_SHOWWINDOW, bVisible);
660 if (bUpdate)
662}
663
664void SWindow::EnableWindow(BOOL bEnable, BOOL bUpdate)
665{
666 SSendMessage(WM_ENABLE, bEnable);
667 if (bUpdate)
669}
670
671void SWindow::SetCheck(BOOL bCheck)
672{
673 if (bCheck)
674 ModifyState(WndState_Check, 0, TRUE);
675 else
676 ModifyState(0, WndState_Check, TRUE);
677}
678
683
685{
686 return m_pContainer;
687}
688
690{
691 ASSERT_UI_THREAD();
692 OnContainerChanged(m_pContainer, pContainer);
694 while (pChild)
695 {
696 pChild->SetContainer(m_pContainer);
697 pChild = pChild->GetWindow(GSW_NEXTSIBLING);
698 }
699}
700
702{
703 m_pOwner = pOwner;
704}
705
707{
708 return m_pOwner;
709}
710
712{
713 return m_bMsgTransparent;
714}
715
717{
718 return m_style;
719}
720
722{
723 return m_style;
724}
725
727{
729 while (pChild)
730 {
731 if (pChild->GetID() == id)
732 return pChild;
733 pChild = (SWindow *)pChild->GetWindow(GSW_NEXTSIBLING);
734 }
735
736 if (nDeep > 0)
737 nDeep--;
738 if (nDeep == 0)
739 return NULL;
740
741 pChild = (SWindow *)GetWindow(GSW_FIRSTCHILD);
742 while (pChild)
743 {
744 SWindow *pChildFind = pChild->_FindChildByID(id, nDeep);
745 if (pChildFind)
746 return pChildFind;
747 pChild = (SWindow *)pChild->GetWindow(GSW_NEXTSIBLING);
748 }
749
750 return NULL;
751}
752
753SWindow *SWindow::_FindChildByName(const SStringW &strName, int nDeep)
754{
756 while (pChild)
757 {
758 if (pChild->m_strName == strName)
759 return pChild;
760 pChild = (SWindow *)pChild->GetWindow(GSW_NEXTSIBLING);
761 }
762
763 if (nDeep > 0)
764 nDeep--;
765 if (nDeep == 0)
766 return NULL;
767
768 pChild = (SWindow *)GetWindow(GSW_FIRSTCHILD);
769 while (pChild)
770 {
771 SWindow *pChildFind = pChild->_FindChildByName(strName, nDeep);
772 if (pChildFind)
773 return pChildFind;
774 pChild = (SWindow *)pChild->GetWindow(GSW_NEXTSIBLING);
775 }
776
777 return NULL;
778}
779
780//改用广度优先算法搜索控件,便于逐级查找 2014年12月8日
781SWindow *SWindow::FindChildByID(int id, int nDeep /* =-1*/)
782{
783 if (id == SWindowMgr::SWND_INVALID || nDeep == 0)
784 return NULL;
785 SWindow *pRet = SWindowFinder::getSingletonPtr()->FindChildByID(this, id, nDeep);
786 if (pRet)
787 return pRet;
788
789 pRet = _FindChildByID(id, nDeep);
790 if (pRet)
791 SWindowFinder::getSingletonPtr()->CacheResultForID(this, id, nDeep, pRet);
792 return pRet;
793}
794
795SWindow *SWindow::FindChildByName(LPCWSTR pszName, int nDeep)
796{
797 if (pszName == NULL || nDeep == 0)
798 return NULL;
799 SStringW strName(pszName);
800 if (strName.IsEmpty())
801 return NULL;
802
803 SWindow *pRet = SWindowFinder::getSingletonPtr()->FindChildByName(this, strName, nDeep);
804 if (pRet)
805 return pRet;
806
807 pRet = _FindChildByName(strName, nDeep);
808 if (pRet)
809 SWindowFinder::getSingletonPtr()->CacheResultForName(this, strName, nDeep, pRet);
810 return pRet;
811}
812
813SWindow *SWindow::FindChildByName(LPCSTR strName, int nDeep /*= -1*/)
814{
815 return FindChildByName(S_CA2W(strName, CP_UTF8), nDeep);
816}
817
818const static wchar_t KLabelInclude[] = L"include"; //文件包含的标签
819const static wchar_t KTempNamespace[] = L"t:"; //模板识别NS
820const static wchar_t KTempData[] = L"data"; //模板参数
821const static wchar_t KTempParamFmt[] = L"{{%s}}"; //模板数据替换格式
822
824{
825 ASSERT_UI_THREAD();
826 SAutoEnableHostPrivUiDef enableUiDef(this);
827 for (SXmlNode xmlChild = xmlNode.first_child(); xmlChild; xmlChild = xmlChild.next_sibling())
828 {
829 if (xmlChild.type() != node_element)
830 continue;
831
832 if (_wcsicmp(xmlChild.name(), KLabelInclude) == 0)
833 { //在窗口布局中支持include标签
834 SStringT strSrc = S_CW2T(xmlChild.attribute(L"src").value());
835 SXmlDoc xmlDoc;
836 if (LOADXML(xmlDoc, strSrc))
837 {
838 SXmlNode xmlInclude = xmlDoc.root().first_child();
839 if (_wcsicmp(xmlInclude.name(), KLabelInclude) == 0)
840 { // compatible with 2.9.0.1
841 CreateChildren(xmlInclude);
842 }
843 else
844 {
845 // merger include attribute to xml node.
846 for (SXmlAttr attr = xmlChild.first_attribute(); attr; attr = attr.next_attribute())
847 {
848 if (_wcsicmp(attr.name(), L"src") == 0)
849 continue;
850 if (xmlInclude.attribute(attr.name()))
851 {
852 xmlInclude.attribute(attr.name()).set_value(attr.value());
853 }
854 else
855 {
856 xmlInclude.append_attribute(attr.name()).set_value(attr.value());
857 }
858 }
859 CreateChild(xmlInclude);
860 }
861 }
862 else
863 {
864 SASSERT(FALSE);
865 }
866 }
867 else if (!xmlChild.get_userdata()) //通过userdata来标记一个节点是否可以忽略
868 {
869 SStringW strName = xmlChild.name();
870 if (strName.StartsWith(KTempNamespace))
871 {
872 strName = strName.Right(strName.GetLength() - 2);
873 SStringW strXmlTemp = GETUIDEF->GetTemplateString(strName);
874 SASSERT(!strXmlTemp.IsEmpty());
875 if (!strXmlTemp.IsEmpty())
876 { // create children by template.
877 SXmlNode xmlData = xmlChild.child(KTempData);
878 while (xmlData)
879 {
880 SStringW strXml = strXmlTemp;
881 for (SXmlAttr param = xmlData.first_attribute(); param; param = param.next_attribute())
882 {
883 SStringW strParam = SStringW().Format(KTempParamFmt, param.name());
884 SStringW strValue = param.value();
885 strValue.Replace(L"\"", L"&#34;"); //防止数据中包含“双引号”,导致破坏XML结构
886 strXml.Replace(strParam, strValue); // replace params to value.
887 }
888 SXmlDoc xmlDoc;
889 if (xmlDoc.load_buffer_inplace(strXml.GetBuffer(strXml.GetLength()), strXml.GetLength() * sizeof(WCHAR), 116, sizeof(wchar_t) == 2 ? enc_utf16 : enc_utf32))
890 {
891 CreateChilds(xmlDoc.root());
892 }
893 strXml.ReleaseBuffer();
894 xmlData = xmlData.next_sibling(KTempData);
895 }
896 }
897 }
898 else
899 {
900 CreateChild(xmlChild);
901 }
902 }
903 }
904 if (!m_isLoading)
905 {
906 //动态创建子窗口,同步窗口的的属性
907 if (GetScale() != 100)
908 SDispatchMessage(UM_SETSCALE, GetScale(), 0);
909 if (m_crColorize != 0)
910 SDispatchMessage(UM_SETCOLORIZE, GetColorizeColor());
911 }
912 return TRUE;
913}
914
916{
917 SWindow *pChild = CreateChildByName(xmlChild.name());
918 if (!pChild)
919 {
920 return FALSE;
921 }
922 InsertChild(pChild);
923 pChild->InitFromXml(&xmlChild);
924 return TRUE;
925}
926
928{
929 for (SXmlNode xmlChild = xmlNode.first_child(); xmlChild; xmlChild = xmlChild.next_sibling())
930 {
931 CreateChild(xmlChild);
932 }
933}
934
936{
938}
939
940SStringW SWindow::tr(const SStringW &strSrc) const
941{
942 return TR(strSrc, GetTrCtx());
943}
944
945// Create SWindow from xml element
947{
948 ASSERT_UI_THREAD();
949 SXmlNode xmlNode(pNode);
950 SASSERT(m_pContainer);
951 m_isLoading = true;
952 if (xmlNode)
953 {
954 if (m_pLayoutParam)
955 m_pLayoutParam->Clear();
956
957 //优先处理"layout"属性
958 SXmlAttr attrLayout = xmlNode.attribute(L"layout");
959 if (attrLayout)
960 {
961 MarkAttributeHandled(attrLayout, true);
962 SetAttribute(attrLayout.name(), attrLayout.value(), TRUE);
963 }
964
965 //优先处理"class"属性
966 SXmlAttr attrClass = xmlNode.attribute(L"class");
967 if (attrClass)
968 {
969 MarkAttributeHandled(attrClass, true);
970 SetAttribute(attrClass.name(), attrClass.value(), TRUE);
971 }
972
973 __baseCls::InitFromXml(pNode);
974
975 MarkAttributeHandled(attrClass, false);
976 MarkAttributeHandled(attrLayout, false);
977
978 if (m_strText.GetText(TRUE).IsEmpty())
979 {
980 SStringW strText = GetXmlText(xmlNode);
981 if (!strText.IsEmpty())
982 {
983 OnAttrText(strText, TRUE);
984 }
985 }
986 }
987
988 //发送WM_CREATE消息
989 if (0 != SSendMessage(WM_CREATE))
990 {
991 if (m_pParent)
992 m_pParent->DestroyChild(this);
993 return FALSE;
994 }
995
996 //给this发一个WM_SHOWWINDOW消息,一些控件需要在WM_SHOWWINDOW中处理状态
997 //初始化的WM_SHOWWINDOW只影响this,子窗口的SHOW由子窗口发出。
998 //不改变窗口的m_bVisible状态,需要使用ParentShow标志
999 if (m_pParent)
1000 { //从父窗口更新状态
1001 if (!m_pParent->IsVisible(TRUE))
1003 if (m_pParent->IsDisabled(TRUE))
1005 }
1006 SSendMessage(WM_SHOWWINDOW, IsVisible(TRUE), ParentShow);
1007
1008 //创建子窗口
1009 if (!CreateChildren(xmlNode))
1010 {
1011 if (m_pParent)
1012 m_pParent->DestroyChild(this);
1013 return FALSE;
1014 }
1015 //请求根窗口重新布局。由于布局涉及到父子窗口同步进行,同步执行布局操作可能导致布局过程重复执行。
1017
1018 EventSwndInitFinish evt(this);
1019 FireEvent(&evt);
1020 m_isLoading = false;
1021 return TRUE;
1022}
1023
1025{
1026 SXmlDoc xmlDoc;
1027 if (!xmlDoc.load_buffer(pszXml, wcslen(pszXml) * sizeof(wchar_t), xml_parse_default, sizeof(wchar_t) == 2 ? enc_utf16 : enc_utf32))
1028 return FALSE;
1029 return CreateChildren(xmlDoc.root());
1030}
1031
1033{
1034 SXmlDoc xmlDoc;
1035 if (!LOADXML(xmlDoc, pszResId))
1036 return FALSE;
1037 return CreateChildren(xmlDoc.root());
1038}
1039
1040SWND SWindow::SwndFromPoint(POINT *pt, BOOL bIncludeMsgTransparent) const
1041{
1042 if (!pt)
1043 return 0;
1044 CPoint pt2(*pt);
1045 SWND ret = SwndFromPoint(pt2, bIncludeMsgTransparent);
1046 *pt = pt2;
1047 return ret;
1048}
1049
1050// Hittest children
1051SWND SWindow::SwndFromPoint(CPoint &pt, BOOL bIncludeMsgTransparent) const
1052{
1053 CPoint pt2(pt);
1054 TransformPoint(pt2);
1055
1056 if (!IsContainPoint(pt2, FALSE))
1057 return 0;
1058
1059 if (!IsContainPoint(pt2, TRUE))
1060 {
1061 pt = pt2; // update pt;
1062 return m_swnd; //只在鼠标位于客户区时,才继续搜索子窗口
1063 }
1064 SWND swndChild = 0;
1065
1066 SWindow *pChild = GetWindow(GSW_LASTCHILD);
1067 while (pChild)
1068 {
1069 if (pChild->IsVisible(TRUE) && (bIncludeMsgTransparent || !pChild->IsMsgTransparent()))
1070 {
1071 swndChild = pChild->SwndFromPoint(pt2, bIncludeMsgTransparent);
1072
1073 if (swndChild)
1074 {
1075 pt = pt2;
1076 return swndChild;
1077 }
1078 }
1079
1080 pChild = pChild->GetWindow(GSW_PREVSIBLING);
1081 }
1082 pt = pt2; // update pt;
1083 return m_swnd;
1084}
1085
1087{
1088 if (m_pBgSkin && m_pBgSkin->GetStates() > 1)
1089 {
1090 return TRUE;
1091 }
1092 return GetStyle().GetStates() > 1;
1093}
1094
1095//如果当前窗口有绘制缓存,它可能是由cache属性定义的,也可能是由于定义了alpha
1097{
1098 if (m_pGetRTData)
1099 {
1100 CRect &rcRT = m_pGetRTData->rcRT;
1101 pRT->AlphaBlend(rcRT, m_pGetRTData->rt, rcRT, 255);
1102 }
1103 else if (IsDrawToCache())
1104 {
1105 IRenderTarget *pRTCache = m_cachedRT;
1106 if (pRTCache)
1107 { //在窗口正在创建的时候进来pRTCache可能为NULL
1108 CRect rcWnd = GetWindowRect();
1109 pRTCache->SetViewportOrg(-rcWnd.TopLeft());
1110 if (IsCacheDirty())
1111 {
1112 pRTCache->BeginDraw();
1113 pRTCache->ClearRect(&rcWnd, 0);
1114
1115 SAutoRefPtr<IFontS> oldFont;
1116 COLORREF crOld = pRT->GetTextColor();
1117 pRTCache->SelectObject(pRT->GetCurrentObject(OT_FONT), (IRenderObj **)&oldFont);
1118 pRTCache->SetTextColor(crOld);
1119
1120 SSendMessage(WM_ERASEBKGND, (WPARAM)pRTCache);
1121 SSendMessage(WM_PAINT, (WPARAM)pRTCache);
1122
1123 pRTCache->SelectObject(oldFont, NULL);
1124 pRTCache->SetTextColor(crOld);
1125
1126 MarkCacheDirty(false);
1127 pRTCache->EndDraw();
1128 }
1129 pRT->AlphaBlend(rcWnd, pRTCache, rcWnd, 255);
1130 }
1131 }
1132 else
1133 {
1134 SSendMessage(WM_ERASEBKGND, (WPARAM)pRT);
1135 SSendMessage(WM_PAINT, (WPARAM)pRT);
1136 }
1137}
1138
1140{
1141 CRect rcWnd = GetWindowRect();
1142 CRect rcClient = GetClientRect();
1143 if (rcWnd == rcClient)
1144 return;
1145
1146 if (m_pGetRTData)
1147 {
1148 CRect &rcRT = m_pGetRTData->rcRT;
1149 pRT->AlphaBlend(rcRT, m_pGetRTData->rt, rcRT, 255);
1150 }
1151 else if (IsDrawToCache())
1152 {
1153 IRenderTarget *pRTCache = m_cachedRT;
1154 if (pRTCache)
1155 {
1156 SSendMessage(WM_NCPAINT, (WPARAM)pRTCache);
1157 pRT->PushClipRect(&rcClient, RGN_DIFF);
1158 pRT->AlphaBlend(rcWnd, pRTCache, rcWnd, 255);
1159 pRT->PopClip();
1160 }
1161 }
1162 else
1163 {
1164 SSendMessage(WM_NCPAINT, (WPARAM)pRT);
1165 }
1166}
1167
1169{
1170 CRect rcWnd = GetWindowRect();
1171 CRect rcClient = SWindow::GetClientRect();
1172 if (rcWnd == rcClient)
1173 return;
1174 Update();
1175 InvalidateRect(rcWnd, TRUE, FALSE); // invalid window rect
1176 InvalidateRect(rcClient, TRUE, TRUE); // but clip client rect
1177 Update();
1178}
1179
1180static SAutoRefPtr<IRegionS> ConvertRect2RenderRegion(const CRect &rc, const SMatrix &mtx)
1181{
1183 GETRENDERFACTORY->CreateRegion(&pRet);
1184 if (!mtx.isIdentity())
1185 {
1186 SRect sRc = SRect::IMake(rc);
1187 if (mtx.rectStaysRect())
1188 {
1189 mtx.mapRect(&sRc);
1190 CRect rc2 = sRc.toRect();
1191 pRet->CombineRect(&rc2, RGN_COPY);
1192 }
1193 else
1194 {
1195 SPoint quad[4];
1196 mtx.mapRectToQuad(quad, sRc);
1197 POINT pts[4];
1198 for (int i = 0; i < 4; i++)
1199 {
1200 pts[i] = quad[i].toPoint();
1201 }
1202 pRet->CombinePolygon(pts, 4, WINDING, RGN_COPY);
1203 }
1204 }
1205 else
1206 {
1207 pRet->CombineRect(&rc, RGN_COPY);
1208 }
1209 return pRet;
1210}
1211
1212static bool RgnInRgn(const IRegionS *r1, IRegionS *r2)
1213{
1215 GETRENDERFACTORY->CreateRegion(&pRet);
1216 pRet->CombineRgn(r1, RGN_COPY);
1217 pRet->CombineRgn(r2, RGN_AND);
1218 return !pRet->IsEmpty();
1219}
1220
1221bool SWindow::_WndRectInRgn(const CRect &rc, const IRegionS *rgn) const
1222{
1223 CRect rc2;
1224 rgn->GetRgnBox(&rc2);
1225
1226 SMatrix mtx = _GetMatrixEx();
1227 if (mtx.isIdentity() && !rc2.IntersectRect(rc2, rc))
1228 return false;
1229 SAutoRefPtr<IRegionS> rgn2 = ConvertRect2RenderRegion(rc, mtx);
1230 return RgnInRgn(rgn, rgn2);
1231}
1232
1233void SWindow::_PaintChildren(IRenderTarget *pRT, IRegionS *pRgn, UINT iBeginZorder, UINT iEndZorder)
1234{
1235 SWindow *pChild = GetWindow(GSW_FIRSTCHILD);
1236 while (pChild)
1237 {
1238 if (pChild->m_uZorder >= iEndZorder)
1239 break;
1240 if (pChild->m_uZorder < iBeginZorder)
1241 { //看整个分枝的zorder是不是在绘制范围内
1242 SWindow *pNextChild = pChild->GetWindow(GSW_NEXTSIBLING);
1243 if (pNextChild)
1244 {
1245 if (pNextChild->m_uZorder <= iBeginZorder)
1246 {
1247 pChild = pNextChild;
1248 continue;
1249 }
1250 }
1251 else
1252 { //最后一个节点时查看最后子窗口的zorder
1253 SWindow *pLastChild = pChild;
1254 while (pLastChild->GetChildrenCount())
1255 {
1256 pLastChild = pLastChild->GetWindow(GSW_LASTCHILD);
1257 }
1258 if (pLastChild->m_uZorder < iBeginZorder)
1259 {
1260 break;
1261 }
1262 }
1263 }
1264
1265 pChild->DispatchPaint(pRT, pRgn, iBeginZorder, iEndZorder);
1266 pChild = pChild->GetWindow(GSW_NEXTSIBLING);
1267 }
1268}
1269
1270// paint zorder in [iZorderBegin,iZorderEnd) widnows
1271void SWindow::DispatchPaint(IRenderTarget *pRT, IRegionS *pRgn, UINT iZorderBegin, UINT iZorderEnd)
1272{
1273 if (!IsVisible(FALSE) || !GetContainer())
1274 return;
1275
1276 SMatrix oriMtx;
1277 bool bMtx = _ApplyMatrix(pRT, oriMtx);
1278
1279 CRect rcWnd = GetWindowRect();
1280 CRect rcClient = GetClientRect();
1281 float fMat[9];
1282 pRT->GetTransform(fMat);
1283 SMatrix curMtx(fMat);
1284 BOOL bRgnInClient = FALSE;
1285 if (curMtx.isIdentity())
1286 { // detect client area only if matrix is identity.
1287 CRect rcRgn = rcWnd;
1288 if (pRgn && !pRgn->IsEmpty())
1289 {
1290 pRgn->GetRgnBox(&rcRgn);
1291 }
1292 CRect rcRgnUnionClient;
1293 rcRgnUnionClient.UnionRect(rcClient, rcRgn);
1294 bRgnInClient = rcRgnUnionClient == rcClient;
1295 }
1296
1297 IRenderTarget *pRTBackup = NULL; // backup current RT
1298
1299 if (IsLayeredWindow())
1300 { //获得当前LayeredWindow RT来绘制内容
1301 pRTBackup = pRT;
1302 pRT = NULL;
1303 GETRENDERFACTORY->CreateRenderTarget(&pRT, rcWnd.Width(), rcWnd.Height());
1304 pRT->BeginDraw();
1305 pRT->OffsetViewportOrg(-rcWnd.left, -rcWnd.top, NULL);
1306 //绘制到窗口的缓存上,需要继承原RT的绘图属性
1307 pRT->SelectObject(pRTBackup->GetCurrentObject(OT_FONT), NULL);
1308 pRT->SelectObject(pRTBackup->GetCurrentObject(OT_PEN), NULL);
1309 pRT->SelectObject(pRTBackup->GetCurrentObject(OT_BRUSH), NULL);
1310 pRT->SetTextColor(pRTBackup->GetTextColor());
1311 pRT->ClearRect(&rcWnd, 0);
1312 }
1313 // save clip state
1314 int nSave1 = -1;
1315 pRT->SaveClip(&nSave1);
1316 if (m_clipRgn)
1317 {
1318 m_clipRgn->Offset(rcWnd.TopLeft());
1319 pRT->PushClipRegion(m_clipRgn, RGN_AND);
1320 m_clipRgn->Offset(-rcWnd.TopLeft());
1321 }
1322 if (m_clipPath)
1323 {
1324 m_clipPath->offset((float)rcWnd.left, (float)rcWnd.top);
1325 pRT->PushClipPath(m_clipPath, RGN_AND, true);
1326 m_clipPath->offset(-(float)rcWnd.left, -(float)rcWnd.top);
1327 }
1328 int nSave2 = -1;
1329 pRT->SaveClip(&nSave2);
1330
1331 if (IsClipClient())
1332 {
1333 pRT->PushClipRect(rcClient, RGN_AND);
1334 }
1335 if (m_uZorder >= iZorderBegin && m_uZorder < iZorderEnd && (!pRgn || pRgn->IsEmpty() || _WndRectInRgn(rcClient, pRgn)))
1336 { // paint client
1337 _PaintClient(pRT);
1338 if (IsFocused() && m_caret)
1339 { // draw caret
1340 m_caret->Draw(pRT);
1341 }
1342 }
1343
1344 SPainter painter;
1345 BeforePaint(pRT, painter);
1346
1347 CRect rcText;
1348 GetTextRect(rcText);
1349 if (rcText != rcClient && IsClipClient())
1350 {
1351 pRT->PushClipRect(rcText, RGN_AND);
1352 }
1353
1354 _PaintChildren(pRT, pRgn, iZorderBegin, iZorderEnd);
1355 AfterPaint(pRT, painter);
1356 pRT->RestoreClip(nSave2);
1357
1358 if (m_uZorder >= iZorderBegin && m_uZorder < iZorderEnd && !bRgnInClient && (!pRgn || pRgn->IsEmpty() || _WndRectInRgn(rcWnd, pRgn)))
1359 { // paint nonclient
1360 _PaintNonClient(pRT);
1361 }
1362 // restore clip state.
1363 pRT->RestoreClip(nSave1);
1364
1365 if (IsLayeredWindow())
1366 { //将绘制到窗口的缓存上的图像返回到上一级RT
1367 SASSERT(pRTBackup);
1368 pRT->EndDraw();
1369 OnCommitSurface(pRTBackup, &rcWnd, pRT, &rcWnd, GetAlpha());
1370 pRT->Release();
1371 pRT = pRTBackup;
1372 }
1373 if (bMtx)
1374 pRT->SetTransform(oriMtx.fMat, NULL);
1375}
1376
1377void SWindow::TransformPoint(CPoint &pt) const
1378{
1380 if (xform.hasMatrix() && !xform.getMatrix().isIdentity())
1381 {
1382 CRect rc = GetWindowRect();
1383 SMatrix mtx = xform.getMatrix();
1384 mtx.preTranslate((int)-rc.left, (int)-rc.top);
1385 mtx.postTranslate((int)rc.left, (int)rc.top);
1386 if (mtx.invert(&mtx))
1387 {
1388 SPoint spt = SPoint::IMake(pt);
1389 mtx.mapPoints(&spt, 1);
1390 pt = spt.toPoint();
1391 }
1392 }
1393}
1394
1395void SWindow::TransformPointEx(CPoint &pt) const
1396{
1397 SList<const SWindow *> lstParent;
1398 const SWindow *pParent = this;
1399 while (pParent)
1400 {
1401 lstParent.AddHead(pParent);
1402 pParent = pParent->GetParent();
1403 }
1404 SPOSITION pos = lstParent.GetHeadPosition();
1405 while (pos)
1406 {
1407 pParent = lstParent.GetNext(pos);
1408 pParent->TransformPoint(pt);
1409 }
1410}
1411
1412//当前函数中的参数包含zorder,为了保证传递进来的zorder是正确的,必须在外面调用zorder重建.
1413void SWindow::_PaintRegion(IRenderTarget *pRT, IRegionS *pRgn, UINT iZorderBegin, UINT iZorderEnd)
1414{
1415 ASSERT_UI_THREAD();
1416 if (!IsVisible(TRUE))
1417 return;
1418 BeforePaintEx(pRT);
1419 DispatchPaint(pRT, pRgn, iZorderBegin, iZorderEnd);
1420}
1421
1423{
1424 ASSERT_UI_THREAD();
1425 if (!IsVisible(TRUE))
1426 return;
1427 DispatchPaint(pRT, pRgn, (UINT)ZORDER_MIN, (UINT)ZORDER_MAX);
1428}
1429
1430void SWindow::Update(BOOL bForce)
1431{
1432 if (!GetContainer())
1433 return;
1434 GetContainer()->UpdateWindow(bForce);
1435}
1436
1438{
1439 CRect rcClient;
1440 GetClientRect(&rcClient);
1441 InvalidateRect(rcClient);
1442}
1443
1444void SWindow::InvalidateRect(LPCRECT lprect)
1445{
1446 if (lprect)
1447 {
1448 CRect rect = *lprect;
1449 InvalidateRect(rect);
1450 }
1451 else
1452 {
1454 }
1455}
1456
1457void SWindow::InvalidateRect(const CRect &rect, BOOL bFromThis /*=TRUE*/, BOOL bClip /*=FALSE*/)
1458{
1459 ASSERT_UI_THREAD();
1460 if (!IsVisible(TRUE) || IsUpdateLocked() || !GetContainer())
1461 return;
1462
1463 //只能更新窗口有效区域
1464 CRect rcWnd = GetWindowRect();
1465
1466 CRect rcIntersect = rect & rcWnd;
1467 if (rcIntersect.IsRectEmpty())
1468 return;
1469 if (!bClip)
1470 MarkCacheDirty(true);
1471
1473 if (xForm.hasMatrix() && !xForm.getMatrix().isIdentity())
1474 {
1475 SMatrix mtx = xForm.getMatrix();
1476 mtx.preTranslate((int)-rcWnd.left, (int)-rcWnd.top);
1477 mtx.postTranslate((int)rcWnd.left, (int)rcWnd.top);
1478 SRect fRc = SRect::IMake(rcIntersect);
1479 mtx.mapRect(&fRc);
1480 rcIntersect = fRc.toRect();
1481 }
1482 if (GetParent())
1483 {
1484 GetParent()->InvalidateRect(rcIntersect, FALSE, bClip);
1485 }
1486 else
1487 {
1488 GetContainer()->OnRedraw(rcIntersect, bClip);
1489 }
1490}
1491
1493{
1495}
1496
1498{
1500 SASSERT(m_nUpdateLockCnt >= 0);
1501}
1502
1503BOOL SWindow::IsUpdateLocked(BOOL bCheckParent) const
1504{
1505 BOOL bLocked = m_nUpdateLockCnt > 0;
1506 if (bLocked)
1507 return TRUE;
1508 if (!bCheckParent || !GetParent())
1509 return bLocked;
1510 return GetParent()->IsUpdateLocked(TRUE);
1511}
1512
1514{
1515 AdjustZOrder(ICWND_LAST);
1516}
1517
1519{
1520 ASSERT_UI_THREAD();
1521 SWindow *pParent = GetParent();
1522 if (!pParent)
1523 return TRUE;
1524 if (m_isDestroying)
1525 return TRUE;
1526 if (pInsertAfter != ICWND_FIRST && pInsertAfter != ICWND_LAST && pInsertAfter->GetParent() != pParent)
1527 {
1528 return FALSE;
1529 }
1530 if (pInsertAfter == this)
1531 {
1532 return FALSE;
1533 }
1534 pParent->RemoveChild(this);
1535 pParent->InsertChild(this, pInsertAfter);
1536 pParent->Invalidate();
1537 return TRUE;
1538}
1539
1540BOOL SWindow::FireEvent(IEvtArgs *evt)
1541{
1542 ASSERT_UI_THREAD();
1543 if (m_evtSet.isMuted() || !GetContainer())
1544 return FALSE;
1545
1546 AddRef();
1547 BOOL bRet = FALSE;
1548 do
1549 {
1550 //调用事件订阅的处理方法
1551 m_evtSet.FireEvent(evt);
1552 if (!evt->IsBubbleUp())
1553 {
1554 bRet = evt->HandleCount() > 0;
1555 break;
1556 }
1557
1558 //调用脚本事件处理方法
1559 if (GetScriptModule())
1560 {
1561 SStringW strEvtName = evt->GetName();
1562 if (!strEvtName.IsEmpty())
1563 {
1564 SStringA strScriptHandler = m_evtSet.getEventScriptHandler(strEvtName);
1565 if (!strScriptHandler.IsEmpty())
1566 {
1567 GetScriptModule()->executeScriptedEventHandler(strScriptHandler, evt);
1568 if (!evt->IsBubbleUp())
1569 {
1570 bRet = evt->HandleCount() > 0;
1571 break;
1572 }
1573 }
1574 }
1575 }
1576 if (GetOwner())
1577 {
1578 bRet = GetOwner()->FireEvent(evt);
1579 break;
1580 }
1581 bRet = GetContainer()->OnFireEvent(evt);
1582 } while (false);
1583 Release();
1584 return bRet;
1585}
1586
1587BOOL SWindow::OnRelayout(const CRect &rcWnd)
1588{
1589 if (m_rcWindow.EqualRect(&rcWnd) && m_layoutDirty == dirty_clean)
1590 return FALSE;
1591 CRect rcLayout;
1592 GetChildrenLayoutRect(&rcLayout);
1593 CPoint ptDiff = (rcWnd.left - m_rcWindow.left, rcWnd.top - m_rcWindow.top);
1594 if (!m_rcWindow.EqualRect(&rcWnd))
1595 {
1596 InvalidateRect(m_rcWindow);
1597 m_rcWindow = rcWnd;
1598
1599 m_layoutDirty = dirty_self;
1600
1601 if (m_rcWindow.left > m_rcWindow.right)
1602 m_rcWindow.right = m_rcWindow.left;
1603 if (m_rcWindow.top > m_rcWindow.bottom)
1604 m_rcWindow.bottom = m_rcWindow.top;
1605
1606 InvalidateRect(m_rcWindow);
1607
1608 SSendMessage(WM_NCCALCSIZE); //计算非客户区大小
1609 }
1610 // keep relative position of float children
1611 if (ptDiff.x != 0 || ptDiff.y != 0)
1612 {
1613 CRect rcLayout2;
1614 GetChildrenLayoutRect(&rcLayout2);
1615
1616 SWindow *pChild = GetWindow(GSW_FIRSTCHILD);
1617 while (pChild)
1618 {
1619 if (pChild->IsFloat())
1620 {
1621 CRect rcChild = pChild->GetWindowRect();
1622 CPoint ptRelative(rcChild.left - rcLayout.left, rcChild.top - rcLayout.top); // relative pos
1623 rcChild.MoveToXY(rcLayout2.left + ptRelative.x, rcLayout2.top + ptRelative.y);
1624 pChild->Move(rcChild);
1625 }
1626 pChild = pChild->GetWindow(GSW_NEXTSIBLING);
1627 }
1628 }
1629 // only if window is visible now, we do relayout.
1630 if (IsVisible(FALSE))
1631 {
1632 // don't call UpdateLayout, otherwise will result in dead cycle.
1633 if (m_layoutDirty != dirty_clean && GetChildrenCount())
1634 {
1635 UpdateChildrenPosition(); //更新子窗口位置
1636 }
1637 m_layoutDirty = dirty_clean;
1638 }
1639 else
1640 { // mark layout to self dirty.
1641 m_layoutDirty = dirty_self;
1642 }
1643
1644 EventSwndPos evt(this);
1645 evt.rcWnd = m_rcWindow;
1646 FireEvent(evt);
1647
1648 CRect rcClient;
1649 GetClientRect(&rcClient);
1650 SSendMessage(WM_SIZE, 0, MAKELPARAM(rcClient.Width(), rcClient.Height()));
1651 return TRUE;
1652}
1653
1655{
1656 SASSERT(GetContainer());
1657 if (GetStyle().m_bTrackMouseEvent)
1659 if (GetStyle().m_bVideoCanvas)
1661
1663
1664 EventSwndCreate evt(this);
1665 FireEvent(evt);
1666 accNotifyEvent(EVENT_OBJECT_CREATE);
1667 return 0;
1668}
1669
1670IWindow *SWindow::FindIChildByID(THIS_ int nId)
1671{
1672 return FindChildByID(nId, -1);
1673}
1674
1675IWindow *SWindow::FindIChildByName(THIS_ LPCWSTR pszName)
1676{
1677 return FindChildByName(pszName, -1);
1678}
1679
1680IWindow *SWindow::FindIChildByNameA(THIS_ LPCSTR pszName)
1681{
1682 return FindChildByName(pszName, -1);
1683}
1684
1686{
1687 // destroy children windows
1688 SWindow *pChild = m_pFirstChild;
1689 while (pChild)
1690 {
1691 SWindow *pNextChild = pChild->m_pNextSibling;
1692 pChild->SSendMessage(WM_DESTROY);
1693 pChild->Release();
1694
1695 pChild = pNextChild;
1696 }
1697 m_pFirstChild = m_pLastChild = NULL;
1698 m_nChildrenCount = 0;
1699}
1700
1702{
1703 if (m_isDestroying)
1704 return;
1705
1706 m_isDestroying = true;
1707 EventSwndDestroy evt(this);
1708 FireEvent(evt);
1709 accNotifyEvent(EVENT_OBJECT_DESTROY);
1710
1711#ifdef SOUI_ENABLE_ACC
1712 if (m_pAcc)
1713 {
1714 SComPtr<IAccHelper> accHelper;
1715 if (m_pAcc->QueryInterface(__uuidof(IAccHelper), (void **)&accHelper) == S_OK)
1716 {
1717 accHelper->SetOwner(NULL);
1718 }
1719 }
1720#endif
1721 if (GetStyle().m_bTrackMouseEvent)
1723 if (GetStyle().m_bVideoCanvas)
1725
1728 m_style = SwndStyle();
1729 m_isDestroying = false;
1730}
1731
1732// Draw background default
1734{
1735 CRect rcClient = GetClientRect();
1736 if (!m_pBgSkin)
1737 {
1738 COLORREF crBg = GetBkgndColor();
1739
1740 if (CR_INVALID != crBg)
1741 {
1742 pRT->FillSolidRect(&rcClient, crBg);
1743 }
1744 }
1745 else
1746 {
1747 int idx = SState2Index::GetDefIndex(GetState(), true);
1748 if (idx >= m_pBgSkin->GetStates())
1749 idx = 0;
1750 m_pBgSkin->DrawByIndex(pRT, rcClient, idx);
1751 }
1752 return TRUE;
1753}
1754
1756{
1757 int iState = SState2Index::GetDefIndex(GetState(), true);
1758 IFontPtr pFont = GetStyle().GetTextFont(iState);
1759 if (pFont)
1760 pRT->SelectObject(pFont, (IRenderObj **)&painter.oldFont);
1761
1762 COLORREF crTxt = GetStyle().GetTextColor(iState);
1763 if (crTxt != CR_INVALID)
1764 painter.oldTextColor = pRT->SetTextColor(crTxt);
1765}
1766
1768{
1769 SWindow *pParent = GetParent();
1770 if (pParent)
1771 pParent->BeforePaintEx(pRT);
1772 SPainter painter;
1773 BeforePaint(pRT, painter);
1774}
1775
1777{
1778 if (painter.oldFont)
1779 pRT->SelectObject(painter.oldFont, NULL);
1780 if (painter.oldTextColor != CR_INVALID)
1781 pRT->SetTextColor(painter.oldTextColor);
1782}
1783
1784// Draw inner text default and focus rect
1786{
1787 SPainter painter;
1788
1789 BeforePaint(pRT, painter);
1790
1791 CRect rcText;
1792 GetTextRect(rcText);
1793 SStringT strText = GetWindowText(FALSE);
1794 DrawText(pRT, strText, strText.GetLength(), rcText, GetTextAlign());
1795
1796 // draw focus rect
1797 if (IsFocused())
1798 {
1799 DrawFocus(pRT);
1800 }
1801
1802 AfterPaint(pRT, painter);
1803}
1804
1806{
1807 if (!IsVisible(TRUE))
1808 return;
1809 if (!GetStyle().GetMargin().IsRectNull())
1810 {
1811 SASSERT(pRT);
1812 CRect rcClient = SWindow::GetClientRect();
1813 CRect rcWnd = GetWindowRect();
1814
1815 pRT->PushClipRect(&rcClient, RGN_DIFF);
1816
1817 int nState = 0;
1819 nState = 1;
1820 if (m_pNcSkin)
1821 {
1822 if (nState >= m_pNcSkin->GetStates())
1823 nState = 0;
1824 m_pNcSkin->DrawByIndex(pRT, &rcWnd, nState);
1825 }
1826 else
1827 {
1828 COLORREF crBg = GetStyle().m_crBorder;
1829 if (CR_INVALID != crBg)
1830 {
1831 pRT->FillSolidRect(&rcWnd, crBg);
1832 }
1833 }
1834 pRT->PopClip();
1835 }
1836}
1837
1838static const int KWnd_MaxSize = 10000;
1839void SWindow::GetDesiredSize(SIZE *psz, int nParentWid, int nParentHei)
1840{
1841 if (m_funSwndProc)
1842 {
1843 //使用回调函数计算窗口Size
1844 BOOL bRet = m_funSwndProc(this, UM_GETDESIREDSIZE, nParentHei, nParentHei, (LRESULT *)psz);
1845 if (bRet)
1846 {
1847 return;
1848 }
1849 }
1850 //检查当前窗口的MatchParent属性及容器窗口的WrapContent属性。
1851 ILayoutParam *pLayoutParam = GetLayoutParam();
1852 bool bSaveHorz = nParentWid == SIZE_WRAP_CONTENT && pLayoutParam->IsMatchParent(Horz);
1853 bool bSaveVert = nParentHei == SIZE_WRAP_CONTENT && pLayoutParam->IsMatchParent(Vert);
1854 if (bSaveHorz)
1855 pLayoutParam->SetWrapContent(Horz);
1856 if (bSaveVert)
1857 pLayoutParam->SetWrapContent(Vert);
1858
1859 CSize szRet(KWnd_MaxSize, KWnd_MaxSize);
1860 if (pLayoutParam->IsSpecifiedSize(Horz))
1861 { //检查设置大小
1862 szRet.cx = pLayoutParam->GetSpecifiedSize(Horz).toPixelSize(GetScale());
1863 }
1864 else if (pLayoutParam->IsMatchParent(Horz) && nParentWid >= 0)
1865 {
1866 szRet.cx = nParentWid;
1867 }
1868
1869 if (pLayoutParam->IsSpecifiedSize(Vert))
1870 { //检查设置大小
1871 szRet.cy = pLayoutParam->GetSpecifiedSize(Vert).toPixelSize(GetScale());
1872 }
1873 else if (pLayoutParam->IsMatchParent(Vert) && nParentHei >= 0)
1874 {
1875 szRet.cy = nParentHei;
1876 }
1877
1878 if (szRet.cx == KWnd_MaxSize || szRet.cy == KWnd_MaxSize)
1879 {
1880 int nTestDrawMode = GetTextAlign() & ~(DT_CENTER | DT_RIGHT | DT_VCENTER | DT_BOTTOM);
1881
1882 CRect rcPadding = GetStyle().GetPadding();
1883 CRect rcMargin = GetStyle().GetMargin();
1884
1885 CSize szContent = MeasureContent(szRet.cx, szRet.cy);
1886 CSize szChilds;
1887 if (GetChildrenCount() > 0)
1888 {
1889 //计算子窗口大小
1890 CSize szParent(nParentWid, nParentHei);
1891 if (nParentWid > 0)
1892 {
1893 szParent.cx -= rcMargin.left + rcPadding.left + rcMargin.right + rcPadding.right;
1894 if (szParent.cx < 0)
1895 szParent.cx = 0;
1896 }
1897 if (nParentHei > 0)
1898 {
1899 szParent.cy -= rcMargin.top + rcPadding.top + rcMargin.bottom + rcPadding.bottom;
1900 if (szParent.cy < 0)
1901 szParent.cy = 0;
1902 }
1903 szChilds = MeasureChildren(szParent.cx, szParent.cy);
1904 }
1905
1906 CRect rcTest(0, 0, smax(szChilds.cx, szContent.cx), smax(szChilds.cy, szContent.cy));
1907
1908 rcTest.InflateRect(rcMargin);
1909 rcTest.InflateRect(rcPadding);
1910
1911 if (pLayoutParam->IsWrapContent(Horz) || (pLayoutParam->IsMatchParent(Horz) && nParentWid < SIZE_WRAP_CONTENT))
1912 szRet.cx = rcTest.Width();
1913 if (pLayoutParam->IsWrapContent(Vert) || (pLayoutParam->IsMatchParent(Vert) && nParentHei < SIZE_WRAP_CONTENT))
1914 szRet.cy = rcTest.Height();
1915 }
1916
1917 if (bSaveHorz)
1918 pLayoutParam->SetMatchParent(Horz);
1919 if (bSaveVert)
1920 pLayoutParam->SetMatchParent(Vert);
1921
1922 *psz = szRet;
1923}
1924
1925SIZE SWindow::MeasureContent(int nParentWid, int nParentHei)
1926{
1927 ILayoutParam *pLayoutParam = GetLayoutParam();
1928 CRect rcPadding = GetStyle().GetPadding();
1929
1930 //计算文本大小
1931 SStringT strText = GetWindowText(FALSE);
1932 CRect rcTest4Text;
1933 if (!strText.IsEmpty())
1934 {
1935 int nTestDrawMode = GetTextAlign() & ~(DT_CENTER | DT_RIGHT | DT_VCENTER | DT_BOTTOM);
1936 rcTest4Text = CRect(0, 0, nParentWid, nParentHei);
1937 int nMaxWid = pLayoutParam->IsWrapContent(Horz) ? m_nMaxWidth.toPixelSize(GetScale()) : nParentWid;
1938 if (nMaxWid == SIZE_WRAP_CONTENT)
1939 {
1940 nMaxWid = KWnd_MaxSize;
1941 }
1942 else // if(nMaxWid >= SIZE_SPEC)
1943 {
1944 nMaxWid -= rcPadding.left + rcPadding.right;
1945 nTestDrawMode |= DT_WORDBREAK;
1946 }
1947 rcTest4Text.right = smax(nMaxWid, 10);
1949 GETRENDERFACTORY->CreateRenderTarget(&pRT, 0, 0);
1950 BeforePaintEx(pRT);
1951 DrawText(pRT, strText, strText.GetLength(), rcTest4Text, nTestDrawMode | DT_CALCRECT);
1952 }
1953 return rcTest4Text.Size();
1954}
1955
1956SIZE SWindow::MeasureChildren(int nParentWid, int nParentHei)
1957{
1958 return GetLayout()->MeasureChildren(this, nParentWid, nParentHei);
1959}
1960
1961void SWindow::GetTextRect(LPRECT pRect)
1962{
1963 CRect rcClient = GetClientRect();
1964 rcClient.DeflateRect(GetStyle().GetPadding());
1965 *pRect = rcClient;
1966}
1967
1968void SWindow::DrawText(IRenderTarget *pRT, LPCTSTR pszBuf, int cchText, LPRECT pRect, UINT uFormat)
1969{
1970 pRT->DrawText(pszBuf, cchText, pRect, uFormat);
1971}
1972
1974{
1975 CRect rcFocus;
1976 GetTextRect(&rcFocus);
1978 DrawDefFocusRect(pRT, rcFocus);
1979}
1980
1982{
1983 rcFocus.DeflateRect(2, 2);
1984 SAutoRefPtr<IPenS> pPen, oldPen;
1985 pRT->CreatePen(PS_DOT, RGBA(88, 88, 88, 0xFF), 1, &pPen);
1986 pRT->SelectObject(pPen, (IRenderObj **)&oldPen);
1987 pRT->DrawRectangle(&rcFocus);
1988 pRT->SelectObject(oldPen, NULL);
1989}
1990
1992{
1993 return 0;
1994}
1995
1997{
1998 return m_bFocusable;
1999}
2000
2001void SWindow::OnShowWindow(BOOL bShow, UINT nStatus)
2002{
2003 if (nStatus == ParentShow)
2004 {
2005 if (bShow && !IsVisible(FALSE))
2006 bShow = FALSE;
2007 }
2008 else
2009 {
2010 m_bVisible = bShow;
2011 }
2012 if (bShow && m_pParent)
2013 {
2014 bShow = m_pParent->IsVisible(TRUE);
2015 }
2016 if (bShow)
2017 { // delay refresh layout of children.
2018 UpdateLayout();
2019 }
2020 if (bShow)
2021 {
2023 accNotifyEvent(EVENT_OBJECT_SHOW);
2024 }
2025 else
2026 {
2028 accNotifyEvent(EVENT_OBJECT_HIDE);
2029 }
2030
2031 SWindow *pChild = m_pFirstChild;
2032 while (pChild)
2033 {
2034 pChild->AddRef();
2035 pChild->SSendMessage(WM_SHOWWINDOW, bShow, ParentShow);
2036 SWindow *pNextChild = pChild->GetWindow(GSW_NEXTSIBLING);
2037 ;
2038 pChild->Release();
2039 pChild = pNextChild;
2040 }
2041 if (!IsVisible(TRUE))
2042 {
2043 if (IsFocused() && GetContainer())
2044 GetContainer()->OnSetSwndFocus(0); //窗口隐藏时自动失去焦点
2045 if (GetCapture() == m_swnd)
2046 ReleaseCapture(); //窗口隐藏时自动失去Capture
2047 }
2048
2049 if (!m_bDisplay)
2050 {
2052 }
2053
2054 EventSwndVisibleChanged evtShow(this);
2055 evtShow.bVisible = bShow;
2056 FireEvent(evtShow);
2057}
2058
2059void SWindow::OnEnable(BOOL bEnable, UINT nStatus)
2060{
2061 if (nStatus == ParentEnable)
2062 {
2063 if (bEnable && IsDisabled(FALSE))
2064 bEnable = FALSE;
2065 }
2066 else
2067 {
2068 m_bDisable = !bEnable;
2069 }
2070 if (bEnable && m_pParent)
2071 {
2072 bEnable = !m_pParent->IsDisabled(TRUE);
2073 }
2074
2075 if (bEnable)
2077 else
2079
2080 SWindow *pChild = m_pFirstChild;
2081 while (pChild)
2082 {
2083 pChild->SSendMessage(WM_ENABLE, bEnable, ParentEnable);
2084 pChild = pChild->GetWindow(GSW_NEXTSIBLING);
2085 }
2086 if (IsDisabled(TRUE) && IsFocused() && GetContainer())
2087 {
2089 }
2090}
2091
2092void SWindow::OnLButtonDown(UINT nFlags, CPoint pt)
2093{
2094 if (m_bFocusable)
2095 SetFocus();
2096 SetCapture();
2098}
2099
2100void SWindow::OnLButtonDbClick(UINT nFlags, CPoint point)
2101{
2102 OnLButtonDown(nFlags, point);
2103}
2104
2105void SWindow::OnLButtonUp(UINT nFlags, CPoint pt)
2106{
2108
2109 if (!(GetState() & WndState_PushDown))
2110 return;
2111
2113 if (!GetWindowRect().PtInRect(pt))
2114 return;
2115
2116 if (GetID() || GetName())
2117 {
2118 FireCommand();
2119 }
2120}
2121
2122void SWindow::OnRButtonDown(UINT nFlags, CPoint point)
2123{
2124}
2125
2126void SWindow::OnRButtonUp(UINT nFlags, CPoint point)
2127{
2128 FireCtxMenu(point);
2129}
2130
2131void SWindow::OnMouseMove(UINT nFlags, CPoint pt)
2132{
2133}
2134
2135void SWindow::OnMouseHover(UINT nFlags, CPoint ptPos)
2136{
2137 if (!m_bHoverAware)
2138 return;
2139 if (GetCapture() == m_swnd)
2140 ModifyState(WndState_PushDown, 0, FALSE);
2141 ModifyState(WndState_Hover, 0, TRUE);
2143 EventSwndMouseHover evtHover(this);
2144 FireEvent(evtHover);
2145}
2146
2148{
2149 if (!m_bHoverAware)
2150 return;
2151 if (GetCapture() == m_swnd)
2152 ModifyState(0, WndState_PushDown, FALSE);
2153 ModifyState(0, WndState_Hover, TRUE);
2155 EventSwndMouseLeave evtLeave(this);
2156 FireEvent(evtLeave);
2157}
2158
2159BOOL SWindow::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
2160{
2161 BOOL bRet = FALSE;
2162 if (m_pParent)
2163 bRet = (BOOL)m_pParent->SSendMessage(WM_MOUSEWHEEL, MAKEWPARAM(nFlags, zDelta), MAKELPARAM(pt.x, pt.y));
2164 return bRet;
2165}
2166
2167LRESULT SWindow::OnMouseClick(UINT uMsg, WPARAM wParam, LPARAM lParam)
2168{
2169 SetMsgHandled(FALSE);
2170
2171 EventMouseClick evt(this);
2172 evt.clickId = MouseClickId(uMsg - WM_LBUTTONDOWN);
2173 evt.uFlags = (UINT)wParam;
2174 evt.pt.x = GET_X_LPARAM(lParam);
2175 evt.pt.y = GET_Y_LPARAM(lParam);
2176 evt.bHover = GetClientRect().PtInRect(evt.pt);
2177 FireEvent(&evt);
2178 return 0;
2179}
2180
2182{
2183 CRect rcRet;
2184 GetClientRect(rcRet);
2185 rcRet.DeflateRect(GetStyle().GetPadding());
2186 *prc = rcRet;
2187}
2188
2190{
2191 if (m_layoutDirty == dirty_self)
2192 { //当前窗口所有子窗口全部重新布局
2193 GetLayout()->LayoutChildren(this);
2194
2195 SWindow *pChild = GetWindow(GSW_FIRSTCHILD);
2196 while (pChild)
2197 {
2198 if (pChild->m_bFloat)
2199 {
2200 RECT rcChild;
2201 GetChildrenLayoutRect(&rcChild);
2202 pChild->OnUpdateFloatPosition(rcChild);
2203 if (pChild->m_layoutDirty != dirty_clean)
2204 {
2205 pChild->UpdateChildrenPosition();
2206 }
2207 }
2208 pChild = pChild->GetWindow(GSW_NEXTSIBLING);
2209 }
2210 }
2211 else if (m_layoutDirty == dirty_child)
2212 { //只有个别子窗口需要重新布局
2213 SWindow *pChild = GetNextLayoutChild(NULL);
2214 while (pChild)
2215 {
2216 if (pChild->IsLayoutDirty())
2217 {
2218 pChild->UpdateChildrenPosition();
2219 }
2220 pChild = GetNextLayoutChild(pChild);
2221 }
2222 }
2223}
2224
2226{
2227 RequestRelayout(m_swnd, TRUE); //此处bSourceResizable可以为任意值
2228}
2229
2230void SWindow::RequestRelayout(SWND hSource, BOOL bSourceResizable)
2231{
2232 SASSERT(SWindowMgr::IsWindow(hSource));
2233
2234 if (bSourceResizable)
2235 { //源窗口大小发生变化,当前窗口的所有子窗口全部重新布局
2236 m_layoutDirty = dirty_self;
2237 }
2238
2239 if (m_layoutDirty != dirty_self)
2240 { //需要检测当前窗口是不是内容自适应
2241 m_layoutDirty = (hSource == m_swnd || GetLayoutParam()->IsWrapContent(Any)) ? dirty_self : dirty_child;
2242 }
2243
2244 SWindow *pParent = GetParent();
2245 if (pParent && pParent->IsVisible())
2246 {
2247 pParent->RequestRelayout(hSource, GetLayoutParam()->IsWrapContent(Any) || !IsDisplay());
2248 }
2249}
2250
2252{
2253 if (m_layoutDirty == dirty_clean)
2254 return;
2255 if (GetChildrenCount())
2257 m_layoutDirty = dirty_clean;
2258}
2259
2260IWindow *SWindow::GetNextLayoutIChild(THIS_ const IWindow *pCurChild) const
2261{
2262 return GetNextLayoutChild((const SWindow *)pCurChild);
2263}
2264
2265void SWindow::OnSetFocus(SWND wndOld)
2266{
2268 accNotifyEvent(EVENT_OBJECT_FOCUS);
2269 EventSetFocus evt(this);
2270 evt.wndOld = wndOld;
2271 FireEvent(evt);
2272}
2273
2274void SWindow::OnKillFocus(SWND wndFocus)
2275{
2277 EventKillFocus evt(this);
2278 evt.wndFocus = wndFocus;
2279 FireEvent(evt);
2280}
2281
2282LRESULT SWindow::OnSetScale(UINT uMsg, WPARAM wParam, LPARAM lParam)
2283{
2284 int nScale = (int)wParam;
2285 OnScaleChanged(nScale);
2286 return 0;
2287}
2288
2289LRESULT SWindow::OnSetLanguage(UINT uMsg, WPARAM wParam, LPARAM lParam)
2290{
2291 HRESULT hr = OnLanguageChanged();
2292 if (hr == S_FALSE)
2293 Invalidate();
2294 else if (hr == S_OK)
2295 RequestRelayout(m_swnd, TRUE);
2296 return 0;
2297}
2298
2300{
2301 return m_bLayeredWindow || GetAlpha() != 0xFF;
2302}
2303
2304//查询当前窗口内容将被渲染到哪一个渲染层上,没有渲染层时返回NULL
2306{
2307 SWindow *pWnd = this;
2308 while (pWnd)
2309 {
2310 if (pWnd->IsLayeredWindow())
2311 {
2312 break;
2313 }
2314 pWnd = pWnd->GetParent();
2315 }
2316
2317 return pWnd;
2318}
2319
2320IRenderTarget *SWindow::GetRenderTarget(LPCRECT pRc, GrtFlag gdcFlags /*=GRT_NODRAW*/, BOOL bClientRT /*=TRUE*/)
2321{
2322 CRect rcRT;
2323 if (bClientRT)
2324 {
2325 GetClientRect(&rcRT);
2326 }
2327 else
2328 {
2329 GetWindowRect(&rcRT);
2330 }
2331 if (pRc)
2332 rcRT.IntersectRect(pRc, &rcRT);
2333
2335 GETRENDERFACTORY->CreateRegion(&rgn);
2336 rgn->CombineRect(rcRT, RGN_COPY);
2337
2338 return GetRenderTarget(gdcFlags, rgn);
2339}
2340
2342{
2343 SASSERT(!m_pGetRTData);
2344
2345 BOOL bRenderValid = GetContainer() && IsVisible(TRUE) && !IsUpdateLocked(TRUE);
2346 if (!bRenderValid)
2347 { // return a empty render target
2348 IRenderTarget *pRT = NULL;
2349 GETRENDERFACTORY->CreateRenderTarget(&pRT, 0, 0);
2350 return pRT;
2351 }
2352
2354
2355 CRect rcRT;
2356 pRgn->GetRgnBox(&rcRT);
2357 IRenderTarget *pRT = NULL;
2358 m_pGetRTData = new GETRTDATA;
2359 GETRENDERFACTORY->CreateRenderTarget(&pRT, rcRT.Width(), rcRT.Height());
2360 pRT->BeginDraw();
2361 pRT->OffsetViewportOrg(-rcRT.left, -rcRT.top, NULL);
2362 BeforePaintEx(pRT);
2363 pRT->PushClipRegion(pRgn, RGN_COPY);
2364 pRT->ClearRect(&rcRT, 0);
2365 m_pGetRTData->gdcFlags = gdcFlags;
2366 m_pGetRTData->rcRT = rcRT;
2367 m_pGetRTData->rgn = pRgn;
2368 m_pGetRTData->rt = pRT;
2369 return pRT;
2370}
2371
2373{
2374 pRT->Release();
2375 if (!m_pGetRTData)
2376 return;
2377 if (m_pGetRTData->gdcFlags != GRT_NODRAW)
2378 {
2379 m_pGetRTData->rt->EndDraw();
2380 SMatrix mtx;
2381 SWindow *p = this;
2382 while (p)
2383 {
2385 if (xform.hasMatrix() && !xform.getMatrix().isIdentity())
2386 {
2387 SMatrix mtx2 = xform.getMatrix();
2388 CRect rc = p->GetWindowRect();
2389 mtx2.preTranslate((int)-rc.left, (int)-rc.top);
2390 mtx2.postTranslate((int)rc.left, (int)rc.top);
2391 mtx.preConcat(mtx2);
2392 }
2393 p = p->GetParent();
2394 }
2395
2396 CRect rcRT = m_pGetRTData->rcRT;
2397 if (!mtx.isIdentity())
2398 {
2399 SRect sRcRT = SRect::IMake(rcRT);
2400 mtx.mapRect(&sRcRT);
2401 rcRT = sRcRT.toRect();
2402 }
2403
2404 SASSERT(GetContainer());
2405 SWindow *pRoot = GetRoot();
2407 GETRENDERFACTORY->CreateRegion(&rgn);
2408 if (!mtx.isIdentity())
2409 {
2410 SRect sRcRT = SRect::IMake(m_pGetRTData->rcRT);
2411 SPoint quad[4];
2412 mtx.mapRectToQuad(quad, sRcRT);
2413 POINT pts[4];
2414 for (int i = 0; i < 4; i++)
2415 {
2416 pts[i] = quad[i].toPoint();
2417 }
2418 rgn->CombinePolygon(pts, 4, WINDING, RGN_COPY);
2419 }
2420 else
2421 {
2422 rgn->CombineRect(rcRT, RGN_COPY);
2423 }
2424 if (mtx.isIdentity())
2425 { // todo: if matrix transform existed, combine getrt.rgn to the root rgn will not work.
2426 rgn->CombineRgn(m_pGetRTData->rgn, RGN_AND);
2427 }
2428 if (!rgn->IsEmpty())
2429 GetContainer()->UpdateRegion(rgn);
2430 }
2431 delete m_pGetRTData;
2432 m_pGetRTData = NULL;
2433}
2434
2436{
2438 if (!xform.hasMatrix() || xform.getMatrix().isIdentity())
2439 return false;
2440 pRT->GetTransform(oriMtx.fMat);
2441 CRect rcWnd = GetWindowRect();
2442 SMatrix mtx = xform.getMatrix();
2443 mtx.preTranslate((int)-rcWnd.left, (int)-rcWnd.top);
2444 mtx.postTranslate((int)rcWnd.left, (int)rcWnd.top);
2445 mtx.preConcat(oriMtx);
2446 pRT->SetTransform(mtx.fMat, NULL);
2447 return true;
2448}
2449
2451{
2452 SMatrix mtx;
2453 const SWindow *p = this;
2454 while (p)
2455 {
2457 if (xform.hasMatrix() && !xform.getMatrix().isIdentity())
2458 {
2459 SMatrix &mtx2 = xform.getMatrix();
2460 CRect rcWnd = p->GetWindowRect();
2461 mtx2.preTranslate((int)-rcWnd.left, (int)-rcWnd.top);
2462 mtx2.postTranslate((int)rcWnd.left, (int)rcWnd.top);
2463 mtx.preConcat(mtx2);
2464 }
2465 p = p->GetParent();
2466 }
2467 return mtx;
2468}
2469
2471{
2472 if (!GetContainer())
2473 return 0;
2474 return GetContainer()->OnGetSwndCapture();
2475}
2476
2477void SWindow::OnCaptureChanged(BOOL bCaptured)
2478{
2479 EventSwndCaptureChanged evt(this);
2480 evt.bCaptured = bCaptured;
2481 FireEvent(&evt);
2482}
2483
2485{
2486 if (!GetContainer())
2487 return 0;
2489}
2490
2492{
2493 if (!GetContainer())
2494 return FALSE;
2496}
2497
2498/**
2499 * Sets the next animation to play for this view.
2500 * If you want the animation to play immediately, use
2501 * {@link #startAnimation(android.view.animation.Animation)} instead.
2502 * This method provides allows fine-grained
2503 * control over the start time and invalidation, but you
2504 * must make sure that 1) the animation has a start time set, and
2505 * 2) the view's parent (which controls animations on its children)
2506 * will be invalidated when the animation is supposed to
2507 * start.
2508 *
2509 * @param animation The next animation, or null.
2510 */
2511
2512void SWindow::SetAnimation(IAnimation *animation)
2513{
2514 if (m_isAnimating)
2515 {
2517 }
2518 m_animation = animation;
2519 if (m_animation)
2520 {
2521 m_animation->setAnimationListener(this);
2522 if (m_animation->getStartTime() == START_ON_FIRST_FRAME)
2523 {
2524 m_animation->startNow();
2525 }
2526 if (GetContainer())
2528 }
2529}
2530
2531/**
2532 * Get the animation currently associated with this view.
2533 *
2534 * @return The animation that is currently playing or
2535 * scheduled to play for this view.
2536 */
2537
2538IAnimation *SWindow::GetAnimation() const
2539{
2540 return m_animation;
2541}
2542
2543/**
2544 * Start the specified animation now.
2545 *
2546 * @param animation the animation to start now
2547 */
2548
2549void SWindow::StartAnimation(IAnimation *animation)
2550{
2551 SASSERT(animation);
2552 animation->setStartTime(START_ON_FIRST_FRAME);
2553 SetAnimation(animation);
2554}
2555
2556/**
2557 * Cancels any animations for this view.
2558 */
2560{
2561 if (m_animation)
2562 {
2563 if (m_isAnimating)
2564 {
2565 m_animation->cancel();
2567 }
2568 else if (GetContainer())
2569 {
2571 }
2572 m_animation->setAnimationListener(NULL);
2573 m_animation = NULL;
2574 }
2575}
2576
2578{
2579 if (!m_isAnimating && !m_animationHandler.getFillAfter())
2580 return m_transform;
2581 else
2582 {
2584 ret.postCompose(m_animationHandler.GetTransformation());
2585 return ret;
2586 }
2587}
2588
2590{
2591 InvalidateRect(NULL);
2592 m_transform.setMatrix(mtx);
2593 InvalidateRect(NULL);
2594}
2595
2596void SWindow::SetAlpha(BYTE byAlpha)
2597{
2598 m_transform.SetAlpha(byAlpha);
2599 InvalidateRect(NULL);
2600}
2601
2603{
2604 return (BYTE)((int)m_transform.GetAlpha() * m_animationHandler.GetTransformation().GetAlpha() / 255);
2605}
2606
2607void SWindow::SetMatrix(const IMatrix *mtx)
2608{
2609 SMatrix smtx(mtx->Data()->fMat);
2610 SetMatrix(&smtx);
2611}
2612
2613void SWindow::GetMatrix(IMatrix *mtx) SCONST
2614{
2615 SMatrix smtx = m_transform.getMatrix();
2616 smtx.postConcat(m_animationHandler.GetTransformation().getMatrix());
2617 memcpy(mtx->Data()->fMat, smtx.fMat, sizeof(smtx.fMat));
2618}
2619
2621{
2622 if (!IsVisible(TRUE) || IsDisabled(TRUE) || !IsFocusable())
2623 return;
2624 if (!GetContainer())
2625 return;
2627}
2628
2630{
2631 if (IsFocused())
2632 {
2633 if (!GetContainer())
2634 return;
2636 }
2637}
2638
2640{
2641 if (!GetContainer())
2642 return FALSE;
2643
2644 return GetContainer()->GetFocus() == m_swnd;
2645}
2646
2648{
2649 CRect rcClient = GetClientRect();
2650 return !rcClient.PtInRect(pt);
2651}
2652
2653IWindow *SWindow::GetIWindow(int uCode) const
2654{
2655 return GetWindow(uCode);
2656}
2657
2658IWindow *SWindow::GetIChild(int iChild) const
2659{
2660 if (iChild == CHILDID_SELF)
2661 return (IWindow *)this;
2662 IWindow *pChild = GetIWindow(GSW_FIRSTCHILD);
2663 for (int i = 0; i < iChild - 1 && pChild; i++)
2664 {
2665 pChild = pChild->GetIWindow(GSW_NEXTSIBLING);
2666 if (!pChild)
2667 return NULL;
2668 }
2669
2670 return pChild;
2671}
2672
2674{
2675 CRect rcDraw = GetWindowRect();
2676 if (pRc)
2677 rcDraw.IntersectRect(rcDraw, pRc);
2678 pRT->PushClipRect(&rcDraw, RGN_AND);
2679
2680 SWindow *pTopWnd = GetRoot();
2682 GETRENDERFACTORY->CreateRegion(&pRgn);
2683 pRgn->CombineRect(&rcDraw, RGN_COPY);
2684
2685 pRT->ClearRect(&rcDraw, 0); //清除残留的alpha值
2686
2687 SASSERT(GetContainer());
2689 pTopWnd->_PaintRegion(pRT, pRgn, ZORDER_MIN, m_uZorder);
2690
2691 pRT->PopClip();
2692}
2693
2694void SWindow::PaintForeground(IRenderTarget *pRT, LPRECT pRc, SWindow *pStartFrom /*=NULL*/)
2695{
2696 CRect rcDraw = GetWindowRect();
2697 if (pRc)
2698 rcDraw.IntersectRect(rcDraw, pRc);
2700 GETRENDERFACTORY->CreateRegion(&pRgn);
2701 pRgn->CombineRect(&rcDraw, RGN_COPY);
2702 pRT->PushClipRect(&rcDraw, RGN_AND);
2703
2704 SASSERT(GetContainer());
2706 if (!pStartFrom)
2707 pStartFrom = GetRoot();
2708 pStartFrom->_PaintRegion(pRT, pRgn, (UINT)m_uZorder + 1, (UINT)ZORDER_MAX);
2709
2710 pRT->PopClip();
2711}
2712
2714{
2715 EventCmd evt(this);
2716 return FireEvent(evt);
2717}
2718
2720{
2721 EventCtxMenu evt(this);
2722 evt.bCancel = FALSE;
2723 evt.pt = pt;
2724 FireEvent(evt);
2725 return evt.bCancel;
2726}
2727
2729{
2730 return m_bCacheDirty && IsDrawToCache();
2731}
2732
2734{
2735 m_bCacheDirty = bDirty;
2736}
2737//////////////////////////////////////////////////////////////////////////
2738
2739HRESULT SWindow::OnAttrVisible(const SStringW &strValue, BOOL bLoading)
2740{
2741 BOOL bVisible = STRINGASBOOL(strValue);
2742 if (!bLoading)
2743 SetVisible(bVisible, TRUE);
2744 else
2745 m_bVisible = bVisible;
2746 return S_FALSE;
2747}
2748
2749HRESULT SWindow::OnAttrEnable(const SStringW &strValue, BOOL bLoading)
2750{
2751 BOOL bEnable = STRINGASBOOL(strValue);
2752 if (bLoading)
2753 {
2754 if (bEnable)
2756 else
2758 }
2759 else
2760 {
2761 EnableWindow(bEnable, TRUE);
2762 }
2763 return S_FALSE;
2764}
2765
2766HRESULT SWindow::OnAttrDisplay(const SStringW &strValue, BOOL bLoading)
2767{
2768 m_bDisplay = STRINGASBOOL(strValue);
2769 if (bLoading)
2770 return S_FALSE;
2771
2773 return S_OK;
2774}
2775
2776HRESULT SWindow::OnAttrSkin(const SStringW &strValue, BOOL bLoading)
2777{
2778 m_pBgSkin = GETSKIN(strValue, GetScale());
2779 if (bLoading)
2780 return S_FALSE;
2781
2782 if ((GetLayoutParam()->IsWrapContent(Vert) || GetLayoutParam()->IsWrapContent(Horz)))
2783 {
2785 }
2786 return S_OK;
2787}
2788
2789HRESULT SWindow::OnAttrClass(const SStringW &strValue, BOOL bLoading)
2790{
2791 SXmlNode xmlStyle = GETSTYLE(strValue);
2792 if (xmlStyle)
2793 {
2794 //优先处理layout属性
2795 SXmlAttr attrLayout = xmlStyle.attribute(L"layout");
2796 if (attrLayout)
2797 {
2798 SetAttribute(attrLayout.name(), attrLayout.value(), bLoading);
2799 MarkAttributeHandled(attrLayout, true);
2800 }
2801 for (SXmlAttr attr = xmlStyle.first_attribute(); attr; attr = attr.next_attribute())
2802 { //解析style中的属性
2803 if (_wcsicmp(attr.name(), L"class") == 0 || IsAttributeHandled(attr))
2804 continue; //防止class中包含有其它class属性,避免发生死循环
2805 SetAttribute(attr.name(), attr.value(), bLoading);
2806 }
2807 MarkAttributeHandled(attrLayout, false);
2808 }
2809 return S_FALSE;
2810}
2811
2812HRESULT SWindow::OnAttrTrackMouseEvent(const SStringW &strValue, BOOL bLoading)
2813{
2814 GetStyle().m_bTrackMouseEvent = STRINGASBOOL(strValue);
2815 if (!bLoading)
2816 {
2817 if (GetContainer())
2818 {
2819 if (GetStyle().m_bTrackMouseEvent)
2821 else
2823 }
2824 }
2825 return S_FALSE;
2826}
2827
2828HRESULT SWindow::OnAttrVideoCanvas(const SStringW &strValue, BOOL bLoading)
2829{
2830 GetStyle().m_bVideoCanvas = STRINGASBOOL(strValue);
2831 if (!bLoading)
2832 {
2833 if (GetContainer())
2834 {
2835 if (GetStyle().m_bVideoCanvas)
2837 else
2839 }
2840 }
2841 return S_FALSE;
2842}
2843
2844void SWindow::OnSize(UINT nType, CSize size)
2845{
2846 if (IsDrawToCache())
2847 {
2848 if (!m_cachedRT)
2849 {
2850 GETRENDERFACTORY->CreateRenderTarget(&m_cachedRT, GetWindowRect().Width(), GetWindowRect().Height());
2851 }
2852 else
2853 {
2854 m_cachedRT->Resize(GetWindowRect().Size());
2855 }
2856 m_cachedRT->SetViewportOrg(-GetWindowRect().TopLeft());
2857
2858 MarkCacheDirty(true);
2859 }
2860
2861 EventSwndSize evt(this);
2862 evt.szWnd = size;
2863 FireEvent(evt);
2864}
2865
2867{
2868 if (IsDrawToCache() && !m_cachedRT)
2869 {
2870 GETRENDERFACTORY->CreateRenderTarget(&m_cachedRT, GetWindowRect().Width(), GetWindowRect().Height());
2871 MarkCacheDirty(true);
2872 }
2873 if (!IsDrawToCache() && m_cachedRT)
2874 {
2875 m_cachedRT = NULL;
2876 }
2877}
2878
2879HRESULT SWindow::OnAttrCache(const SStringW &strValue, BOOL bLoading)
2880{
2881 m_bCacheDraw = STRINGASBOOL(strValue);
2882
2883 if (!bLoading)
2884 {
2886 InvalidateRect(NULL);
2887 }
2888 return S_FALSE;
2889}
2890
2891HRESULT SWindow::OnAttrAlpha(const SStringW &strValue, BOOL bLoading)
2892{
2893 BYTE byAlpha = _wtoi(strValue);
2894 SetAlpha(byAlpha);
2895 return bLoading ? S_FALSE : S_OK;
2896}
2897
2898HRESULT SWindow::OnAttrID(const SStringW &strValue, BOOL bLoading)
2899{
2900 static struct SystemID
2901 {
2902 int id;
2903 LPCWSTR pszName;
2904 } systemID[] = { IDOK, L"IDOK", IDCANCEL, L"IDCANCEL", IDCLOSE, L"IDCLOSE", IDHELP, L"IDHELP", IDABORT, L"IDABORT", IDYES, L"IDYES", IDNO, L"IDNO", IDRETRY, L"IDRETRY", IDIGNORE, L"IDIGNORE" };
2905 if (!strValue.IsEmpty())
2906 {
2907 if (strValue.Left(2).CompareNoCase(L"ID") == 0)
2908 {
2909 for (int i = 0; i < ARRAYSIZE(systemID); i++)
2910 {
2911 if (strValue.CompareNoCase(systemID[i].pszName) == 0)
2912 {
2913 m_nID = systemID[i].id;
2914 break;
2915 }
2916 }
2917 }
2918 else
2919 {
2920 m_nID = SNcPainter::toNcBuiltinID(strValue);
2921 if (m_nID == 0)
2922 m_nID = _wtoi(strValue);
2923 }
2924 }
2925 IAttrStorageFactory *pAttrFac = SApplication::getSingleton().GetAttrStorageFactory();
2926 if (pAttrFac && !m_attrStorage)
2927 {
2928 pAttrFac->CreateAttrStorage(this, &m_attrStorage);
2929 }
2930
2931 return S_FALSE;
2932}
2933
2934HRESULT SWindow::OnAttrName(const SStringW &strValue, BOOL bLoading)
2935{
2936 m_strName = strValue;
2937 if (m_nID == 0)
2938 {
2939 m_nID = STR2ID(strValue);
2940 }
2941 IAttrStorageFactory *pAttrFac = SApplication::getSingleton().GetAttrStorageFactory();
2942 if (pAttrFac && !m_attrStorage)
2943 {
2944 pAttrFac->CreateAttrStorage(this, &m_attrStorage);
2945 }
2946 return S_FALSE;
2947}
2948
2949HRESULT SWindow::OnAttrTip(const SStringW &strValue, BOOL bLoading)
2950{
2951 SetToolTipText(S_CW2T(GETSTRING(strValue)));
2952 return S_FALSE;
2953}
2954
2956{
2957 SStringW strText = xmlNode.Text();
2958 strText.TrimBlank();
2959 if (strText.IsEmpty())
2960 {
2961 strText = xmlNode.child_value();
2962 strText.TrimBlank();
2963 }
2964 return strText;
2965}
2966
2967HRESULT SWindow::OnAttrText(const SStringW &strValue, BOOL bLoading)
2968{
2969 SStringW strText = GETSTRING(strValue);
2970 SStringT strCvt2 = S_CW2T(strText);
2971 if (bLoading)
2972 m_strText.SetText(strCvt2);
2973 else
2974 SetWindowText(strCvt2);
2975 return S_OK;
2976}
2977
2979{
2980 SWindow *pChild = GetWindow(GSW_FIRSTCHILD);
2981 while (pChild)
2982 {
2983 if (pChild->IsSiblingsAutoGroupped())
2984 break;
2985 pChild = pChild->GetWindow(GSW_NEXTSIBLING);
2986 }
2987 if (!pChild)
2988 return NULL;
2989 return pChild->GetSelectedSiblingInGroup();
2990}
2991
2993{
2994 return m_bCacheDraw || m_isAnimating;
2995}
2996
2997void SWindow::OnStateChanging(DWORD dwOldState, DWORD dwNewState)
2998{
2999}
3000
3001void SWindow::OnStateChanged(DWORD dwOldState, DWORD dwNewState)
3002{
3003 EventSwndStateChanged evt(this);
3004 evt.dwOldState = dwOldState;
3005 evt.dwNewState = dwNewState;
3006 FireEvent(evt);
3007 accNotifyEvent(EVENT_OBJECT_STATECHANGE);
3008}
3009
3011{
3012 if (!GetContainer())
3013 return NULL;
3014 return GetContainer()->GetScriptModule();
3015}
3016
3017HRESULT SWindow::DefAttributeProc(const SStringW &strAttribName, const SStringW &strValue, BOOL bLoading)
3018{
3019 HRESULT hr = E_FAIL;
3020 if (GetScriptModule())
3021 {
3022 if (m_evtSet.setEventScriptHandler(strAttribName, S_CW2A(strValue, CP_UTF8)))
3023 {
3024 hr = S_FALSE;
3025 }
3026 }
3027 if (m_attrStorage)
3028 {
3029 m_attrStorage->OnSetAttribute(&strAttribName, &strValue, false);
3030 }
3031
3032 return hr;
3033}
3034
3035//////////////////////////////////////////////////////////////////////////
3036// caret functions
3037
3038BOOL SWindow::CreateCaret(HBITMAP pBmp, int nWid, int nHeight)
3039{
3040 if (!GetContainer())
3041 return FALSE;
3042 if (!m_caret)
3043 {
3044 m_caret.Attach(new SCaret(GetContainer()));
3045 SStringW strCaret;
3046 EventGetCaret evt(this);
3047 evt.strCaret = &strCaret;
3048 FireEvent(&evt);
3049 SXmlNode xmlCaret;
3050 SXmlDoc xmlDoc;
3051 if (!strCaret.IsEmpty())
3052 {
3053 if (xmlDoc.load_buffer_inplace(strCaret.GetBuffer(), strCaret.GetLength() * sizeof(wchar_t), xml_parse_default, sizeof(wchar_t) == 2 ? enc_utf16 : enc_utf32))
3054 xmlCaret = xmlDoc.root().child(L"caret");
3055 strCaret.ReleaseBuffer();
3056 }
3057 if (!xmlCaret)
3058 {
3059 xmlCaret = GETUIDEF->GetUiDef()->GetCaretInfo();
3060 }
3061 m_caret->InitFromXml(&xmlCaret);
3062 }
3063 return m_caret->Init(pBmp, nWid, nHeight);
3064}
3065
3066void SWindow::ShowCaret(BOOL bShow)
3067{
3068 if (!m_caret)
3069 return;
3070 if (m_caret->SetVisible(bShow, m_swnd))
3071 {
3072 CRect rcCaret = m_caret->GetRect();
3073 InvalidateRect(rcCaret);
3074 }
3075}
3076
3077void SWindow::SetCaretPos(int x, int y)
3078{
3079 if (!m_caret)
3080 return;
3081
3082 if (m_caret->IsVisible())
3083 {
3084 {
3085 CRect rcCaret = m_caret->GetRect();
3086 InvalidateRect(rcCaret);
3087 }
3088 m_caret->SetPosition(x, y);
3089 {
3090 CRect rcCaret = m_caret->GetRect();
3091 InvalidateRect(rcCaret);
3092 }
3093 }
3094 else
3095 {
3096 m_caret->SetPosition(x, y);
3097 }
3098}
3099
3100BOOL SWindow::IsContainPoint(POINT pt, BOOL bClientOnly) const
3101{
3102 BOOL bRet = FALSE;
3103 CRect rc = bClientOnly ? GetClientRect() : GetWindowRect();
3104 bRet = rc.PtInRect(pt);
3105 if (m_clipRgn)
3106 {
3107 CPoint ptTmp = pt;
3108 ptTmp -= GetWindowRect().TopLeft();
3109 bRet = m_clipRgn->PtInRegion(ptTmp);
3110 }
3111 return bRet;
3112}
3113
3114void SWindow::SetWindowRgn(IRegionS *pRgn, BOOL bRedraw /*=TRUE*/)
3115{
3116 m_clipRgn = NULL;
3117 if (pRgn)
3118 {
3119 GETRENDERFACTORY->CreateRegion(&m_clipRgn);
3120 m_clipRgn->CombineRgn(pRgn, RGN_COPY);
3121 }
3122 if (bRedraw)
3123 InvalidateRect(NULL);
3124}
3125
3127{
3128 return m_clipRgn;
3129}
3130
3131void SWindow::SetWindowPath(IPathS *pPath, BOOL bRedraw /*=TRUE*/)
3132{
3133 m_clipPath = pPath;
3134 if (bRedraw)
3135 InvalidateRect(NULL);
3136}
3137
3139{
3140 return m_clipPath;
3141}
3142
3143void SWindow::DoColorize(COLORREF cr)
3144{
3145 SDispatchMessage(UM_SETCOLORIZE, cr, 0);
3146}
3147
3148LRESULT SWindow::OnSetColorize(UINT uMsg, WPARAM wParam, LPARAM lParam)
3149{
3150 OnColorize((COLORREF)wParam);
3151 return 0;
3152}
3153
3154void SWindow::OnColorize(COLORREF cr)
3155{
3156 if (m_crColorize == cr)
3157 return;
3158 m_crColorize = cr;
3159 if (m_pNcSkin)
3160 m_pNcSkin->OnColorize(cr);
3161 if (m_pBgSkin)
3162 m_pBgSkin->OnColorize(cr);
3163 InvalidateRect(NULL);
3164}
3165
3167{
3168 return m_crColorize;
3169}
3170
3171LRESULT SWindow::OnUpdateFont(UINT uMsg, WPARAM wParam, LPARAM lParam)
3172{
3173 OnRebuildFont();
3174 return 0;
3175}
3176
3177HRESULT SWindow::OnAttrLayout(const SStringW &strValue, BOOL bLoading)
3178{
3179 ILayout *pLayout = (ILayout *)SApplication::getSingleton().CreateObject(strValue, Layout);
3180 if (pLayout == NULL)
3181 return E_INVALIDARG;
3182
3183 m_pLayout = pLayout;
3184 pLayout->Release();
3185 return S_OK;
3186}
3187
3188HRESULT SWindow::AfterAttribute(const SStringW &strAttribName, const SStringW &strValue, BOOL bLoading, HRESULT hr)
3189{
3190 if (m_attrStorage)
3191 {
3192 m_attrStorage->OnSetAttribute(&strAttribName, &strValue, true);
3193 }
3194 if ((hr & 0x0000ffff) == S_OK && !bLoading)
3195 {
3196 HRESULT hFlag = hr & 0xFFFF0000;
3197 if ((hFlag & HRET_FLAG_LAYOUT_PARAM) || (hFlag & HRET_FLAG_LAYOUT))
3198 { //修改了窗口的布局属性,请求父窗口重新布局
3199 if (GetParent())
3200 {
3202 }
3203 else
3204 {
3205 InvalidateRect(NULL);
3206 }
3207 }
3208 else if ((hr & 0x0000ffff) == S_OK)
3209 {
3210 InvalidateRect(NULL);
3211 }
3212 }
3213 return hr;
3214}
3215
3216BOOL SWindow::GetAttribute(LPCWSTR pszAttr, IStringW *strValue) const
3217{
3218 if (m_attrStorage)
3219 {
3220 SStringW strAttr(pszAttr);
3221 return m_attrStorage->OnGetAttribute(&strAttr, strValue);
3222 }
3223 else
3224 {
3225 return __baseCls::GetAttribute(pszAttr, strValue);
3226 }
3227}
3228
3230{
3231 m_strText.TranslateText();
3232 m_strToolTipText.TranslateText();
3233 return GetLayoutParam()->IsWrapContent(Any) ? S_OK : S_FALSE;
3234}
3235
3237{
3238 return m_strToolTipText.GetText(FALSE);
3239}
3240
3241void SWindow::SetToolTipText(LPCTSTR pszText)
3242{
3243 m_strToolTipText.SetText(pszText, false);
3244 if (!GetContainer())
3245 return;
3246 if (GetContainer()->GetHover() == m_swnd)
3247 { //请求更新显示的tip
3249 }
3250}
3251
3252void SWindow::SetToolTipTextU8(LPCSTR pszText)
3253{
3254 SStringT str = S_CA2T(pszText, CP_UTF8);
3255 return SetToolTipText(str);
3256}
3257
3258LPCWSTR SWindow::GetTrCtx() const
3259{
3260 if (GetContainer() && m_strTrCtx.IsEmpty())
3262 else
3263 return m_strTrCtx;
3264}
3265
3267{
3268 return GetStyle().GetScale();
3269}
3270
3272{
3273 GetStyle().SetScale(scale);
3274 GetScaleSkin(m_pNcSkin, scale);
3275 GetScaleSkin(m_pBgSkin, scale);
3276
3277 //标记布局脏
3278 m_layoutDirty = dirty_self;
3279
3280 if (m_animation && m_animation->hasEnded())
3281 {
3282 //动画结束状态下,重新刷新动画结束位置
3283 long tmDuration = m_animation->getDuration();
3284 long tmOffset = m_animation->getStartOffset();
3285 m_animation->setStartTime(STime::GetCurrentTimeMs() - tmDuration - tmOffset);
3286 m_animationHandler.OnNextFrame();
3287 }
3288}
3289
3291{
3292 if (!pSkin)
3293 return;
3294 SStringW strName = pSkin->GetName();
3295 if (!strName.IsEmpty())
3296 {
3297 ISkinObj *pNewSkin = GETSKIN(strName, nScale);
3298 if (pNewSkin)
3299 pSkin = pNewSkin;
3300 }
3301}
3302
3304{
3305 m_style.UpdateFont();
3306}
3307
3308#ifdef _WIN32
3309IAccessible *SWindow::GetAccessible()
3310{
3311#ifdef SOUI_ENABLE_ACC
3312 if (!m_pAcc)
3313 m_pAcc.Attach(SApplication::getSingleton().CreateAccessible(this));
3314 return m_pAcc;
3315#else
3316 return NULL;
3317#endif
3318}
3319#endif
3320
3322{
3323#ifdef SOUI_ENABLE_ACC
3324 if (!m_pAccProxy)
3325 {
3326 m_pAccProxy.Attach(SApplication::getSingleton().CreateAccProxy(this));
3327 }
3328 return m_pAccProxy;
3329#else
3330 return NULL;
3331#endif
3332}
3333
3335{
3336#ifdef SOUI_ENABLE_ACC
3337 if (GetContainer())
3338 NotifyWinEvent(dwEvt, GetContainer()->GetHostHwnd(), GetSwnd(), CHILDID_SELF);
3339#endif
3340}
3341
3342BOOL SWindow::SetLayoutParam(ILayoutParam *pLayoutParam)
3343{
3344 SWindow *pParent = GetParent();
3345 if (!pParent->GetLayout()->IsParamAcceptable(pLayoutParam))
3346 return FALSE;
3347 m_pLayoutParam = pLayoutParam;
3348 return TRUE;
3349}
3350
3351void SWindow::OnAnimationStart(THIS_ IAnimation *pAni)
3352{
3353 EventSwndAnimationStart evt(this);
3354 evt.pAni = pAni;
3355 FireEvent(&evt);
3356
3357 m_isAnimating = true;
3358 m_animationHandler.OnAnimationStart();
3360}
3361
3362void SWindow::OnAnimationStop(THIS_ IAnimation *pAni)
3363{
3364 if (GetContainer())
3366 m_animationHandler.OnAnimationStop();
3367 m_isAnimating = false;
3369 EventSwndAnimationStop evt(this);
3370 evt.pAni = pAni;
3371 FireEvent(&evt);
3372}
3373
3374void SWindow::OnAnimationRepeat(THIS_ IAnimation *pAni)
3375{
3376 EventSwndAnimationRepeat evt(this);
3377 evt.pAni = pAni;
3378 FireEvent(&evt);
3379}
3380
3381void SWindow::OnAnimationInvalidate(IAnimation *pAni, bool bErase)
3382{
3383 InvalidateRect(NULL);
3384}
3385
3387{
3388 return GetStyle().m_crBg;
3389}
3390
3392{
3393}
3394
3396{
3397}
3398
3400{
3401}
3402
3404{
3405}
3406
3408{
3409 if (pOldContainer)
3410 {
3411 if (IsFocused())
3412 pOldContainer->OnSetSwndFocus(0);
3413 if (GetStyle().m_bTrackMouseEvent)
3414 pOldContainer->UnregisterTrackMouseEvent(m_swnd);
3415 if (GetCapture() == m_swnd)
3418 if (GetStyle().m_bVideoCanvas)
3419 pOldContainer->UnregisterVideoCanvas(m_swnd);
3420 }
3421 m_pContainer = pNewContainer;
3422 if (pNewContainer)
3423 {
3424 if (GetStyle().m_bTrackMouseEvent)
3425 pNewContainer->RegisterTrackMouseEvent(m_swnd);
3426 if (GetStyle().m_bVideoCanvas)
3427 pNewContainer->RegisterVideoCanvas(m_swnd);
3428 }
3429}
3430
3432{
3433 return m_bFloat;
3434}
3435
3437{
3438 return m_bDisplay;
3439}
3440
3442{
3443 return FALSE;
3444}
3445
3447{
3448 return m_bClipClient;
3449}
3450
3452{
3453 return m_layoutDirty != dirty_clean;
3454}
3455
3457{
3458 SWindow *pRet = NULL;
3459 switch (uCode)
3460 {
3461 case GSW_FIRSTCHILD:
3462 pRet = m_pFirstChild;
3463 break;
3464 case GSW_LASTCHILD:
3465 pRet = m_pLastChild;
3466 break;
3467 case GSW_PREVSIBLING:
3468 pRet = m_pPrevSibling;
3469 break;
3470 case GSW_NEXTSIBLING:
3471 pRet = m_pNextSibling;
3472 break;
3473 case GSW_OWNER:
3474 pRet = m_pOwner;
3475 break;
3476 case GSW_PARENT:
3477 pRet = m_pParent;
3478 break;
3479 }
3480 return pRet;
3481}
3482
3483SWindow *SWindow::GetChild(int iChild) const
3484{
3485 return (SWindow *)GetIChild(iChild);
3486}
3487
3489{
3490 return m_pParent;
3491}
3492
3494{
3495 SWindow *pParent = (SWindow *)this;
3496 while (pParent->GetParent())
3497 pParent = pParent->GetParent();
3498 return pParent;
3499}
3500
3502{
3503 SWindow *pRet = NULL;
3504 if (pCurChild == NULL)
3505 {
3506 pRet = GetWindow(GSW_FIRSTCHILD);
3507 }
3508 else
3509 {
3510 pRet = pCurChild->GetWindow(GSW_NEXTSIBLING);
3511 }
3512
3513 if (pRet && (pRet->IsFloat() || (!pRet->IsDisplay() && !pRet->IsVisible(FALSE))))
3514 return GetNextLayoutChild(pRet);
3515 return pRet;
3516}
3517
3518BOOL SWindow::IsDescendant(THIS_ const IWindow *pWnd) const
3519{
3520 if (!pWnd)
3521 return FALSE;
3522 const IWindow *pParent = GetIParent();
3523 while (pParent)
3524 {
3525 if (pParent == pWnd)
3526 return TRUE;
3527 pParent = pParent->GetIParent();
3528 }
3529 return FALSE;
3530}
3531
3532BOOL SWindow::AdjustIZOrder(THIS_ IWindow *pInsertAfter)
3533{
3534 return AdjustZOrder((SWindow *)pInsertAfter);
3535}
3536
3537void SWindow::InsertIChild(THIS_ IWindow *pNewChild, IWindow *pInsertAfter /*=ICWND_LAST*/)
3538{
3539 return InsertChild((SWindow *)pNewChild, (SWindow *)pInsertAfter);
3540}
3541
3542BOOL SWindow::RemoveIChild(THIS_ IWindow *pChild)
3543{
3544 return RemoveChild((SWindow *)pChild);
3545}
3546
3547BOOL SWindow::DestroyIChild(THIS_ IWindow *pChild)
3548{
3549 return DestroyChild((SWindow *)pChild);
3550}
3551
3552void SWindow::SetIOwner(THIS_ IWindow *pOwner)
3553{
3554 SetOwner((SWindow *)pOwner);
3555}
3556
3557IWindow *SWindow::GetIOwner(THIS) const
3558{
3559 return GetOwner();
3560}
3561
3562BOOL SWindow::SubscribeEvent(THIS_ DWORD evtId, const IEvtSlot *pSlot)
3563{
3564 return GetEventSet()->subscribeEvent(evtId, pSlot);
3565}
3566
3567BOOL SWindow::UnsubscribeEvent(THIS_ DWORD evtId, const IEvtSlot *pSlot)
3568{
3569 return GetEventSet()->unsubscribeEvent(evtId, pSlot);
3570}
3571
3572HRESULT SWindow::QueryInterface(THIS_ REFGUID id, IObjRef **ppRet)
3573{
3574 return E_NOINTERFACE;
3575}
3576
3577void SWindow::OnCommitSurface(IRenderTarget *pRtDest, LPCRECT pRcDest, IRenderTarget *pRtSrc, LPCRECT pRcSrc, BYTE alpha)
3578{
3579 pRtDest->AlphaBlend(pRcDest, pRtSrc, pRcSrc, alpha);
3580}
3581
3583{
3585}
3586
3588{
3589 return GetSelectedChildInGroup();
3590}
3591
3592BOOL SWindow::SwndProc(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
3593{
3594 SASSERT(lResult);
3595 BOOL bOldMsgHandle = IsMsgHandled(); //备分上一个消息的处理状态
3596 BOOL bRet = FALSE;
3597 if (m_funSwndProc)
3598 {
3599 bRet = m_funSwndProc(this, uMsg, wParam, lParam, lResult);
3600 }
3601 if (!bRet)
3602 {
3603 SetMsgHandled(FALSE);
3604 bRet = ProcessSwndMessage(uMsg, wParam, lParam, *lResult);
3605 }
3606 SetMsgHandled(bOldMsgHandle); //恢复上一个消息的处理状态
3607
3608 return bRet;
3609}
3610
3611void SWindow::SetSwndProc(FunSwndProc swndProc)
3612{
3613 m_funSwndProc = swndProc;
3614}
3615
3617{
3618 return GetContainer()->GetHostHwnd();
3619}
3620
3621ITimelineHandlersMgr *SWindow::GetTimelineHandlersMgr(THIS)
3622{
3623 return GetContainer();
3624}
3625
3626BOOL SWindow::AddEvent(THIS_ DWORD dwEventID, LPCWSTR pszEventHandlerName)
3627{
3628 return m_evtSet.addEvent(dwEventID, pszEventHandlerName);
3629}
3630
3631BOOL SWindow::RemoveEvent(THIS_ DWORD dwEventID)
3632{
3633 return m_evtSet.removeEvent(dwEventID);
3634}
3635
3636void SWindow::GetVisibleRect(LPRECT prc) const
3637{
3638 SASSERT(prc);
3639 CRect rcWnd;
3640 *prc = rcWnd;
3641 if (!IsVisible(TRUE))
3642 return;
3643 rcWnd = GetWindowRect();
3644 SWindow *pParent = GetParent();
3645 while (pParent)
3646 {
3647 CRect rcParent = pParent->GetClientRect();
3648 rcWnd = rcWnd & rcParent;
3649 if (rcWnd.IsRectEmpty())
3650 break;
3651 pParent = pParent->GetParent();
3652 }
3653 *prc = rcWnd;
3654}
3655
3656BOOL SWindow::IsVideoCanvas(CTHIS) const
3657{
3658 return GetStyle().m_bVideoCanvas;
3659}
3660
3661BOOL SWindow::RegisterDragDrop(THIS_ IDropTarget *pDragTarget)
3662{
3663 return GetContainer()->RegisterDragDrop(m_swnd, pDragTarget);
3664}
3665
3670
3671void SWindow::OnAnimationPauseChange(THIS_ IAnimation *animation, BOOL bPaused)
3672{
3673 if (bPaused)
3675 else
3677}
3678
3679//////////////////////////////////////////////////////////////////////////
3680static SWindow *ICWND_NONE = (SWindow *)-2;
3681SWindow::SAnimationHandler::SAnimationHandler(SWindow *pOwner)
3682 : m_pOwner(pOwner)
3683 , m_bFillAfter(false)
3684 , m_pPrevSiblingBackup(ICWND_NONE)
3685{
3686}
3687
3688void SWindow::SAnimationHandler::OnAnimationStart()
3689{
3690 IAnimation *pAni = m_pOwner->GetAnimation();
3691 SASSERT(pAni);
3692 if (pAni->getZAdjustment() != ZORDER_NORMAL)
3693 {
3694 m_pPrevSiblingBackup = m_pOwner->GetWindow(GSW_PREVSIBLING);
3695 if (m_pPrevSiblingBackup == NULL)
3696 m_pPrevSiblingBackup = ICWND_FIRST;
3697
3698 if (pAni->getZAdjustment() == ZORDER_TOP)
3699 m_pOwner->AdjustZOrder(ICWND_LAST);
3700 else
3701 m_pOwner->AdjustZOrder(ICWND_FIRST);
3702 }
3703 else
3704 {
3705 m_pPrevSiblingBackup = ICWND_NONE;
3706 }
3707 m_pOwner->GetEventSet()->subscribeEvent(EventSwndSize::EventID, Subscriber(&SWindow::SAnimationHandler::OnOwnerResize, this));
3708 if (m_pOwner->GetParent())
3709 {
3710 m_pOwner->GetParent()->GetEventSet()->subscribeEvent(EventSwndSize::EventID, Subscriber(&SWindow::SAnimationHandler::OnOwnerResize, this));
3711 }
3712 OnOwnerResize(NULL);
3713}
3714
3715void SWindow::SAnimationHandler::OnAnimationStop()
3716{
3717 m_pOwner->GetEventSet()->unsubscribeEvent(EventSwndSize::EventID, Subscriber(&SWindow::SAnimationHandler::OnOwnerResize, this));
3718 if (m_pOwner->GetParent())
3719 {
3720 m_pOwner->GetParent()->GetEventSet()->unsubscribeEvent(EventSwndSize::EventID, Subscriber(&SWindow::SAnimationHandler::OnOwnerResize, this));
3721 }
3722 if (m_pPrevSiblingBackup != ICWND_NONE)
3723 {
3724 m_pOwner->AdjustZOrder(m_pPrevSiblingBackup);
3725 m_pPrevSiblingBackup = ICWND_NONE;
3726 }
3727}
3728
3729const STransformation &SWindow::SAnimationHandler::GetTransformation() const
3730{
3731 return m_transform;
3732}
3733
3734void SWindow::SAnimationHandler::OnNextFrame()
3735{
3736 IAnimation *pAni = m_pOwner->GetAnimation();
3737 SASSERT(pAni);
3738 pAni->AddRef();
3739 m_pOwner->AddRef();
3740 uint64_t tm = pAni->getStartTime();
3741 if (tm > 0)
3742 {
3743 m_pOwner->OnAnimationInvalidate(pAni, true);
3744 BOOL bMore = pAni->getTransformation(STime::GetCurrentTimeMs(), &m_transform);
3745 m_pOwner->OnAnimationInvalidate(pAni, false);
3746 if (!bMore)
3747 { // animation stopped.
3748 if (pAni->isFillEnabled() && pAni->getFillAfter())
3749 {
3750 m_bFillAfter = true;
3751 }
3752 else
3753 {
3754 m_bFillAfter = false;
3755 }
3756 }
3757 }
3758 m_pOwner->Release();
3759 pAni->Release();
3760}
3761
3762BOOL SWindow::SAnimationHandler::OnOwnerResize(IEvtArgs *e)
3763{
3764 CSize szOwner = m_pOwner->GetWindowRect().Size();
3765 CSize szParent = szOwner;
3766 SWindow *p = m_pOwner->GetParent();
3767 if (p)
3768 {
3769 szParent = p->GetWindowRect().Size();
3770 }
3771 m_pOwner->GetAnimation()->initialize(szOwner.cx, szOwner.cy, szParent.cx, szParent.cy, m_pOwner->GetScale());
3772 return true;
3773}
3774
3775bool SWindow::SAnimationHandler::getFillAfter() const
3776{
3777 return m_bFillAfter;
3778}
3779
3780SNSEND
SOUI基础DUI窗口模块
@ ParentShow
Definition SWnd.h:57
@ GSW_FIRSTCHILD
Definition SWnd.h:195
@ GSW_LASTCHILD
Definition SWnd.h:196
@ GSW_PREVSIBLING
Definition SWnd.h:197
@ GSW_NEXTSIBLING
Definition SWnd.h:198
@ GSW_PARENT
Definition SWnd.h:199
@ GSW_OWNER
Definition SWnd.h:200
@ ParentEnable
Definition SWnd.h:66
@ HRET_FLAG_LAYOUT
Definition SWnd.h:222
@ HRET_FLAG_LAYOUT_PARAM
Definition SWnd.h:223
@ WndState_Hover
Definition SWnd.h:76
@ WndState_Check
Definition SWnd.h:78
@ WndState_Disable
Definition SWnd.h:80
@ WndState_Invisible
Definition SWnd.h:79
@ WndState_Normal
Definition SWnd.h:75
@ WndState_PushDown
Definition SWnd.h:77
GrtFlag
@ GRT_NODRAW
@ ZORDER_MIN
@ ZORDER_MAX
IAttrStorageFactory * GetAttrStorageFactory() OVERRIDE
Get the attribute storage factory.
Definition SApp.cpp:684
virtual IWindow * CreateWindowByName(LPCWSTR pszWndClass) const
Create a window by name.
Definition SApp.cpp:630
A helper class to enable or disable private UI definitions for the host container.
Definition SWnd.h:2663
Smart pointer class for managing COM-style reference-counted objects.
Caret management class.
Definition SCaret.h:20
BOOL subscribeEvent(DWORD dwEventID, const IEvtSlot &subscriber)
订阅事件
Definition SEventSet.h:151
BOOL unsubscribeEvent(DWORD dwEventID, const IEvtSlot *subscriber)
取消订阅事件
void setMutedState(BOOL setting)
设置事件集的静音状态
int toPixelSize(int scale) const
将大小转换为像素值
The SMatrix class holds a 3x3 matrix for transforming coordinates. SMatrix does not have a constructo...
Definition SMatrix.h:22
bool invert(SMatrix *inverse) const
If this matrix can be inverted, return true and if inverse is not null, set inverse to be the inverse...
Definition SMatrix.h:600
void postTranslate(float dx, float dy)
Post-concats the matrix with the specified translation.
Definition SMatrix.cpp:300
void mapRectToQuad(SPoint dst[4], const SRect &rect) const
Apply this matrix to the src rectangle, and write the four transformed points into dst....
Definition SMatrix.h:762
void mapPoints(SPoint dst[], const SPoint src[], int count) const
Apply this matrix to the array of points specified by src, and write the transformed points into the ...
Definition SMatrix.cpp:1135
void preTranslate(float dx, float dy)
Pre-concats the matrix with the specified translation.
Definition SMatrix.cpp:274
IxForm * Data() SCONST OVERRIDE
Returns a pointer to the matrix data.
Definition SMatrix.cpp:1772
void preConcat(const SMatrix &other)
Pre-concats the matrix with the specified matrix.
Definition SMatrix.cpp:783
bool mapRect(SRect *dst, const SRect &src) const
Apply this matrix to the src rectangle, and write the transformed rectangle into dst....
Definition SMatrix.cpp:1216
bool rectStaysRect() const
Returns true if the matrix will map a rectangle to another rectangle. This can be true if the matrix ...
Definition SMatrix.h:249
BOOL isIdentity() SCONST OVERRIDE
Checks if the matrix is the identity matrix.
Definition SMatrix.cpp:1777
void postConcat(const SMatrix &other)
Post-concats the matrix with the specified matrix.
Definition SMatrix.cpp:793
static int toNcBuiltinID(const SStringW &str)
Converts a string to a built-in non-client ID.
static void MarkAttributeHandled(SXmlAttr xmlAttr, bool bHandled)
Definition Sobject.hpp:59
int GetID() SCONST OVERRIDE
Retrieves the object's ID.
Definition Sobject.hpp:134
LPCWSTR GetName() SCONST OVERRIDE
Definition Sobject.hpp:108
static bool IsAttributeHandled(SXmlAttr xmlAttr)
Definition Sobject.hpp:68
SStringW m_strName
Definition Sobject.hpp:293
Helper class for painting.
Definition SWnd.h:178
SAutoRefPtr< IFontS > oldFont
Definition SWnd.h:185
COLORREF oldTextColor
Definition SWnd.h:186
static SWindowFinder * getSingletonPtr(void)
Definition SSingleton2.h:70
static SApplication & getSingleton(void)
Definition SSingleton.h:63
static int GetDefIndex(DWORD dwState, bool checkAsPushdown=false)
Gets the default index for a given state.
A class representing an ASCII string.
Definition sstringa.h:96
BOOL IsEmpty() SCONST
Checks if the string is empty.
A class representing an ASCII string.
Definition sstringw.h:96
int CompareNoCase(const wchar_t *psz) SCONST
Compares the string with another string, ignoring case.
Definition sstringw.cpp:929
void ReleaseBuffer(int nNewLength=-1)
Releases the buffer and sets the new length of the string.
Definition sstringw.cpp:426
void TrimBlank()
Trims leading and trailing whitespace characters from the string.
Definition sstringw.cpp:762
int Replace(const wchar_t *pszOld, const wchar_t *pszNew)
Replaces all occurrences of a substring with another substring.
Definition sstringw.cpp:575
BOOL IsEmpty() SCONST
Checks if the string is empty.
SStringW Mid(int nFirst) const
Extracts a substring from the string.
Definition sstringw.cpp:924
BOOL __cdecl Format(HINSTANCE hInst, UINT nFormatID,...)
Formats a string using a format string and variable arguments.
Definition sstringw.cpp:490
SStringW Right(int nCount) const
Extracts the rightmost part of the string.
Definition sstringw.cpp:892
wchar_t * GetBuffer(int nMinBufLength=-1)
Retrieves a modifiable buffer for the string.
Definition sstringw.cpp:439
int GetLength() SCONST
Retrieves the length of the string.
SStringW Left(int nCount) const
Extracts the leftmost part of the string.
Definition sstringw.cpp:879
bool StartsWith(const SStringW &prefix, bool IgnoreCase=false) const
Checks if the string starts with a specified prefix.
Definition sstringw.cpp:749
static uint64_t GetCurrentTimeMs()
获取当前时间的毫秒数
Definition stime.cpp:189
Structure representing a timer ID.
Definition SWnd.h:136
bool bAutoEscape
Definition SWnd.h:273
SStringT strRaw
Definition SWnd.h:272
void SetOwner(SWindow *pOwner)
Sets the owner window.
Definition Swnd.cpp:25
SWindow * pOwner
Definition SWnd.h:271
void TranslateText()
Translates the text.
Definition Swnd.cpp:42
void SetText(const SStringT &strText, bool bAutoEscape=true)
Sets the text.
Definition Swnd.cpp:35
SStringT GetText(BOOL bRawText=FALSE) const
Gets the text.
Definition Swnd.cpp:30
static SStringW EscapeString(const SStringW &str)
Escapes a string.
Definition Swnd.cpp:52
STrText(SWindow *pOwner=NULL)
Constructor.
Definition Swnd.cpp:19
SStringT strTr
Definition SWnd.h:274
Defines the transformation to be applied at one point in time of an Animation.
bool hasMatrix() const
Checks if the transformation affects the matrix property.
void postCompose(STransformation t)
Composes this transformation with another transformation using postConcat.
const SMatrix & getMatrix() const
Gets the 3x3 matrix representing the transformation.
void CacheResultForID(SWindow *pParent, int nID, int nDeep, SWindow *pResult)
缓存通过ID查找的结果
SWindow * FindChildByName(SWindow *pParent, const SStringW &strName, int nDeep)
通过名称查找子窗口
SWindow * FindChildByID(SWindow *pParent, int nID, int nDeep)
通过ID查找子窗口
void CacheResultForName(SWindow *pParent, const SStringW &strName, int nDeep, SWindow *pResult)
缓存通过名称查找的结果
Base class for SOUI DUI windows.
Definition SWnd.h:286
IWindow * GetISelectedSiblingInGroup() OVERRIDE
Retrieves the selected sibling window in a group.
Definition Swnd.cpp:3582
virtual SIZE MeasureChildren(int nParentWid, int nParentHei)
Measures the size of all child windows.
Definition Swnd.cpp:1956
virtual LPCWSTR GetTrCtx() const
Get translation context.
Definition Swnd.cpp:3258
void StartAnimation(IAnimation *animation) OVERRIDE
Starts an animation for the window.
Definition Swnd.cpp:2549
virtual void OnAnimationInvalidate(IAnimation *pAni, bool bErase)
Called when an animation requires a redraw.
Definition Swnd.cpp:3381
virtual void OnCommitSurface(IRenderTarget *pRtDest, LPCRECT pRcDest, IRenderTarget *pRtSrc, LPCRECT pRcSrc, BYTE alpha)
Commits surface changes.
Definition Swnd.cpp:3577
BOOL CreateChild(SXmlNode xmlChild)
Creates a child window from an XML node.
Definition Swnd.cpp:915
BOOL IsClipClient() SCONST OVERRIDE
Checks if client area clipping is enabled.
Definition Swnd.cpp:3446
SWNDMSG * m_pCurMsg
Definition SWnd.h:2594
BOOL m_bLayeredWindow
Definition SWnd.h:2613
HRESULT OnAttrTip(const SStringW &strValue, BOOL bLoading)
Handles the 'tip' attribute.
Definition Swnd.cpp:2949
BOOL SetTimer(char id, UINT uElapse) OVERRIDE
Sets a timer for the window.
Definition Swnd.cpp:477
UINT OnGetDlgCode() SCONST OVERRIDE
Retrieves the dialog code for the window.
Definition Swnd.cpp:1991
void UpdateCacheMode()
Updates the cache mode for the window.
Definition Swnd.cpp:2866
IScriptModule * GetScriptModule()
Retrieves the script module interface.
Definition Swnd.cpp:3010
BOOL FireEvent(IEvtArgs *evt) OVERRIDE
Fires an event.
Definition Swnd.cpp:1540
SAutoRefPtr< ISkinObj > m_pNcSkin
Definition SWnd.h:2623
BOOL DestroyChild(SWindow *pChild)
Destroys a child window.
Definition Swnd.cpp:519
void SetMatrix(const IMatrix *mtx) OVERRIDE
Sets the transformation matrix for the window.
Definition Swnd.cpp:2607
void GetDesiredSize(SIZE *psz, int nParentWid, int nParentHei) OVERRIDE
Retrieves the desired size of the window.
Definition Swnd.cpp:1839
int m_nUpdateLockCnt
Definition SWnd.h:2601
SWND GetSwnd() SCONST OVERRIDE
Retrieves the window handle.
Definition Swnd.cpp:489
void accNotifyEvent(DWORD dwEvt)
Notifies an accessibility event.
Definition Swnd.cpp:3334
virtual BOOL UpdateToolTip(CPoint pt, SwndToolTipInfo &tipInfo)
Handle tooltip updates.
Definition Swnd.cpp:277
PGETRTDATA m_pGetRTData
Definition SWnd.h:2644
HRESULT OnAttrName(const SStringW &strValue, BOOL bLoading)
Handles the 'name' attribute.
Definition Swnd.cpp:2934
BOOL IsDisplay() SCONST OVERRIDE
Checks if the window is displayed.
Definition Swnd.cpp:3436
virtual void OnContainerChanged(ISwndContainer *pOldContainer, ISwndContainer *pNewContainer)
Called when the container of the window changes.
Definition Swnd.cpp:3407
void OnMouseMove(UINT nFlags, CPoint pt)
Handles the mouse move event.
Definition Swnd.cpp:2131
SWindow * GetParent() const
Retrieves the parent window.
Definition Swnd.cpp:3488
void OnMouseHover(UINT nFlags, CPoint ptPos)
Handles the mouse hover event.
Definition Swnd.cpp:2135
HRESULT QueryInterface(REFGUID id, IObjRef **ppRet) OVERRIDE
Queries an interface.
Definition Swnd.cpp:3572
IWindow * GetIOwner() SCONST OVERRIDE
Retrieves the owner window.
Definition Swnd.cpp:3557
SWindow * m_pLastChild
Definition SWnd.h:2589
BOOL m_bDisplay
Definition SWnd.h:2606
void SetVisible(BOOL bVisible, BOOL bUpdate=FALSE) OVERRIDE
Sets the visibility of the window.
Definition Swnd.cpp:655
IWindow * GetIParent() SCONST OVERRIDE
Retrieves the parent window.
Definition Swnd.cpp:494
BOOL SubscribeEvent(DWORD evtId, const IEvtSlot *pSlot) OVERRIDE
Subscribes to an event.
Definition Swnd.cpp:3562
void InsertIChild(IWindow *pNewChild, IWindow *pInsertAfter=NULL) OVERRIDE
Inserts a child window into the window tree.
Definition Swnd.cpp:3537
HRESULT OnAttrID(const SStringW &strValue, BOOL bLoading)
Handles the 'id' attribute.
Definition Swnd.cpp:2898
LRESULT OnSetLanguage(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles setting the language of the window.
Definition Swnd.cpp:2289
void Move2(int x, int y, int cx=-1, int cy=-1) OVERRIDE
Moves the window to a new position and optionally resizes it.
Definition Swnd.cpp:417
void OnDestroy()
Handles the destruction of the window.
Definition Swnd.cpp:1701
void CreateChilds(SXmlNode xmlNode)
Creates multiple child windows from XML nodes.
Definition Swnd.cpp:927
BOOL m_isLoading
Definition SWnd.h:2614
BOOL m_bDisable
Definition SWnd.h:2605
BOOL UnregisterDragDrop() OVERRIDE
Unregisters a drop target for the window.
Definition Swnd.cpp:3666
LRESULT OnMouseClick(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles general mouse click events.
Definition Swnd.cpp:2167
IWindow * GetIRoot() SCONST OVERRIDE
Retrieves the root window in the hierarchy.
Definition Swnd.cpp:499
void UnlockUpdate() OVERRIDE
Unlocks updates to the window.
Definition Swnd.cpp:1497
SWindow * GetOwner() const
Retrieves the current owner of the window.
Definition Swnd.cpp:706
BOOL Destroy() OVERRIDE
Destroys the window.
Definition Swnd.cpp:504
SWindow * m_pPrevSibling
Definition SWnd.h:2591
DWORD GetState() SCONST OVERRIDE
Retrieves the current state of the window.
Definition Swnd.cpp:437
SWindow * _GetCurrentLayeredWindow()
Retrieves the host window for the current render layer.
Definition Swnd.cpp:2305
BOOL AdjustIZOrder(IWindow *pInsertAfter) OVERRIDE
Adjusts the Z-order of the window.
Definition Swnd.cpp:3532
HRESULT OnAttrAlpha(const SStringW &strValue, BOOL bLoading)
Handles the 'alpha' attribute.
Definition Swnd.cpp:2891
ULONG_PTR GetUserData() SCONST OVERRIDE
Retrieves the user data associated with the window.
Definition Swnd.cpp:465
BOOL m_bCacheDirty
Definition SWnd.h:2612
SwndStyle m_style
Definition SWnd.h:2596
void OnAnimationStop(IAnimation *animation)
Called when an animation stops.
Definition Swnd.cpp:3362
void SetCaretPos(int x, int y) OVERRIDE
Sets the caret position.
Definition Swnd.cpp:3077
SWindow * GetChild(int iChild) const
Retrieves a child window by index.
Definition Swnd.cpp:3483
SAutoRefPtr< IRegionS > m_clipRgn
Definition SWnd.h:2620
void SetWindowTextU8(LPCSTR lpszText) OVERRIDE
Sets the window text using a UTF-8 string.
Definition Swnd.cpp:318
HRESULT OnAttrVideoCanvas(const SStringW &strValue, BOOL bLoading)
Handles the 'videoCanvas' attribute.
Definition Swnd.cpp:2828
void EnableWindow(BOOL bEnable, BOOL bUpdate=FALSE) OVERRIDE
Enables or disables the window.
Definition Swnd.cpp:664
SWND SwndFromPoint(POINT *pt, BOOL bIncludeMsgTransparent=FALSE) SCONST OVERRIDE
Retrieves the window handle at a specified point.
HRESULT OnAttrClass(const SStringW &strValue, BOOL bLoading)
Handles the 'class' attribute.
Definition Swnd.cpp:2789
BOOL GetAttribute(LPCWSTR pszName, IStringW *strValue) SCONST OVERRIDE
Retrieves an attribute value from the window.
Definition Swnd.cpp:3216
void GetClientRect(LPRECT prect) SCONST OVERRIDE
Retrieves the client rectangle of the window.
void OnNcPaint(IRenderTarget *pRT)
Handles the painting of the non-client area.
Definition Swnd.cpp:1805
HRESULT OnAttrText(const SStringW &strValue, BOOL bLoading)
Handles the 'text' attribute.
Definition Swnd.cpp:2967
void ReleaseRenderTarget(IRenderTarget *pRT)
Releases the RenderTarget obtained via GetRenderTarget.
Definition Swnd.cpp:2372
BOOL IsSiblingsAutoGroupped() SCONST OVERRIDE
Checks if siblings are auto-grouped.
Definition Swnd.cpp:3441
BOOL m_bFloat
Definition SWnd.h:2578
IAccProxy * GetAccProxy()
Retrieves the accessibility proxy for the window.
Definition Swnd.cpp:3321
int GetWindowTextU8(IStringA *pStr, BOOL bRawText) OVERRIDE
Retrieves the window text as a UTF-8 string.
Definition Swnd.cpp:255
int GetWindowText(TCHAR *pBuf, int nBufLen, BOOL bRawText) OVERRIDE
Retrieves the window text.
Definition Swnd.cpp:263
IWindow * GetNextLayoutIChild(const IWindow *pCurChild) SCONST OVERRIDE
Retrieves the next layout child window.
Definition Swnd.cpp:2260
void SetToolTipText(LPCTSTR pszText) OVERRIDE
Sets the tooltip text for the window.
Definition Swnd.cpp:3241
BOOL IsLayoutDirty() SCONST OVERRIDE
Checks if the layout is dirty.
Definition Swnd.cpp:3451
virtual SWindow * _FindChildByName(const SStringW &strName, int nDeep)
Finds a child window by name.
Definition Swnd.cpp:753
void SetAnimation(IAnimation *animation) OVERRIDE
Sets an animation for the window.
Definition Swnd.cpp:2512
UINT GetTextAlign() const
Retrieves the text alignment of the window.
Definition Swnd.cpp:218
HRESULT OnAttrCache(const SStringW &strValue, BOOL bLoading)
Handles the 'cache' attribute.
Definition Swnd.cpp:2879
void OnAnimationStart(IAnimation *animation)
Called when an animation starts.
Definition Swnd.cpp:3351
UINT GetChildrenCount() SCONST OVERRIDE
Retrieves the number of child windows.
Definition Swnd.cpp:533
SAutoRefPtr< ILayoutParam > m_pLayoutParam
Definition SWnd.h:2584
SAutoRefPtr< IPathS > m_clipPath
Definition SWnd.h:2621
BOOL RemoveChild(SWindow *pChild)
Removes a child window from the window tree.
Definition Swnd.cpp:602
BOOL SwndProc(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult) OVERRIDE
Processes a window message.
Definition Swnd.cpp:3592
void OnKillFocus(SWND wndFocus)
Handles losing focus.
Definition Swnd.cpp:2274
void SDispatchMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0) OVERRIDE
Dispatches a message to the window.
Definition Swnd.cpp:388
void BringWindowToTop() OVERRIDE
Brings the window to the top of the Z-order.
Definition Swnd.cpp:1513
void OnPaint(IRenderTarget *pRT)
Handles the painting of the window.
Definition Swnd.cpp:1785
int GetScale() SCONST OVERRIDE
Retrieves the scale factor of the window.
Definition Swnd.cpp:3266
void GetMatrix(IMatrix *mtx) SCONST OVERRIDE
Retrieves the transformation matrix of the window.
Definition Swnd.cpp:2613
BOOL IsMsgHandled() const
Checks if the message is handled.
Definition Swnd.cpp:207
void GetVisibleRect(LPRECT prect) SCONST OVERRIDE
Retrieves the visible rectangle of the window.
Definition Swnd.cpp:3636
COLORREF GetColorizeColor() SCONST OVERRIDE
Retrieves the colorization color of the window.
Definition Swnd.cpp:3166
BOOL IsVideoCanvas() SCONST OVERRIDE
Checks if the window is a video canvas.
Definition Swnd.cpp:3656
UINT m_uZorder
Definition SWnd.h:2600
BOOL DestroyIChild(IWindow *pChild) OVERRIDE
Destroys a child window.
Definition Swnd.cpp:3547
void SetWindowPath(IPathS *pPath, BOOL bRedraw=TRUE) OVERRIDE
Sets the window path.
Definition Swnd.cpp:3131
CRect GetWindowRect() const
Retrieves the bounding rectangle of the window.
Definition Swnd.cpp:230
virtual void OnCaptureChanged(BOOL bCaptured)
Called when the capture state of the window changes.
Definition Swnd.cpp:2477
BOOL IsVisible(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if the window is visible.
Definition Swnd.cpp:646
LRESULT OnSetScale(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles setting the scale of the window.
Definition Swnd.cpp:2282
STransformation m_transform
Definition SWnd.h:2632
void PaintForeground(IRenderTarget *pRT, LPRECT pRc, SWindow *pStartFrom=NULL)
Draws the foreground content of the window.
Definition Swnd.cpp:2694
virtual void DispatchPaint(IRenderTarget *pRT, IRegionS *pRgn, UINT iZorderBegin, UINT iZorderEnd)
Handles paint dispatching for the window.
Definition Swnd.cpp:1271
void _RedrawNonClient()
Redraws the non-client area of the window.
Definition Swnd.cpp:1168
virtual SWindow * GetSelectedChildInGroup()
Get selected child in group.
Definition Swnd.cpp:2978
virtual SIZE MeasureContent(int nParentWid, int nParentHei)
Measures the size of the content within the window.
Definition Swnd.cpp:1925
virtual void OnScaleChanged(int scale)
Called when the scale of the window changes.
Definition Swnd.cpp:3271
virtual void OnContentChanged()
Called when the content of the window changes.
Definition Swnd.cpp:329
BOOL UnsubscribeEvent(DWORD evtId, const IEvtSlot *pSlot) OVERRIDE
Unsubscribes from an event.
Definition Swnd.cpp:3567
ISwndContainer * GetContainer() OVERRIDE
Retrieves the container associated with this window.
Definition Swnd.cpp:679
void _PaintChildren(IRenderTarget *pRT, IRegionS *pRgn, UINT iBeginZorder, UINT iEndZorder)
Renders child windows within a specific Z-order range.
Definition Swnd.cpp:1233
void SetEventMute(BOOL bMute) OVERRIDE
Sets the event mute state.
Definition Swnd.cpp:324
COLORREF m_crColorize
Definition SWnd.h:2628
void OnLButtonDbClick(UINT nFlags, CPoint point)
Handles the left mouse button double-click event.
Definition Swnd.cpp:2100
BOOL m_bMsgTransparent
Definition SWnd.h:2608
BOOL IsFloat() SCONST OVERRIDE
Checks if the window is floating.
Definition Swnd.cpp:3431
BOOL IsFocused() SCONST OVERRIDE
Checks if the window has focus.
Definition Swnd.cpp:2639
void DoColorize(COLORREF cr) OVERRIDE
Applies colorization to the window.
Definition Swnd.cpp:3143
BYTE GetAlpha() SCONST OVERRIDE
Retrieves the alpha value of the window.
Definition Swnd.cpp:2602
STransformation GetTransformation() const
Retrieves the current transformation matrix of the window.
Definition Swnd.cpp:2577
void OnMouseLeave()
Handles the mouse leave event.
Definition Swnd.cpp:2147
void SetAlpha(BYTE byAlpha) OVERRIDE
Sets the alpha value for the window.
Definition Swnd.cpp:2596
void SetSwndProc(FunSwndProc swndProc) OVERRIDE
Sets the window procedure.
Definition Swnd.cpp:3611
void _PaintRegion(IRenderTarget *pRT, IRegionS *pRgn, UINT iZorderBegin, UINT iZorderEnd)
Renders a specific region of the window onto the RenderTarget.
Definition Swnd.cpp:1413
int OnCreate(LPVOID)
Handles the creation of the window.
Definition Swnd.cpp:1654
FunSwndProc m_funSwndProc
Definition SWnd.h:2649
SWindow * GetNextLayoutChild(const SWindow *pCurChild) const
Retrieves the next layout child after a specified child.
Definition Swnd.cpp:3501
void TransformPointEx(CPoint &pt) const
Extends the transformation of a point.
Definition Swnd.cpp:1395
void SetOwner(SWindow *pOwner)
Sets the owner of the window.
Definition Swnd.cpp:701
HRESULT OnAttrLayout(const SStringW &strValue, BOOL bLoading)
Handles the 'layout' attribute.
Definition Swnd.cpp:3177
virtual HRESULT OnLanguageChanged()
Called when the language of the window changes.
Definition Swnd.cpp:3229
void PaintBackground(IRenderTarget *pRT, LPRECT pRc)
Draws the background content of the window.
Definition Swnd.cpp:2673
void GetChildrenLayoutRect(RECT *prc) SCONST OVERRIDE
Retrieves the layout rectangle of the children.
Definition Swnd.cpp:2181
virtual BOOL NeedRedrawWhenStateChange()
Determine if redraw is needed on state change.
Definition Swnd.cpp:1086
void TestMainThread()
Tests if the current thread is the main UI thread.
Definition Swnd.cpp:345
HRESULT OnAttrDisplay(const SStringW &strValue, BOOL bLoading)
Handles the 'display' attribute.
Definition Swnd.cpp:2766
BOOL m_bDrawFocusRect
Definition SWnd.h:2610
void OnSize(UINT nType, CSize size)
Handles the resizing of the window.
Definition Swnd.cpp:2844
SWindow * FindChildByName(LPCWSTR strName, int nDeep=-1)
Finds a child window by its name.
Definition Swnd.cpp:795
IAnimation * GetAnimation() SCONST OVERRIDE
Retrieves the animation object associated with the window.
Definition Swnd.cpp:2538
BOOL m_dwState
Definition SWnd.h:2603
void OnFinalRelease()
Called when the last reference to the object is released.
Definition Swnd.cpp:198
void OnRButtonUp(UINT nFlags, CPoint point)
Handles the right mouse button up event.
Definition Swnd.cpp:2126
virtual ~SWindow()
Destructor.
Definition Swnd.cpp:183
virtual BOOL IsLayeredWindow() const
Determines if the window requires a render layer.
Definition Swnd.cpp:2299
virtual CRect GetClientRect() const
Retrieves the client rectangle of the window.
Definition Swnd.cpp:243
void InsertChild(SWindow *pNewChild, SWindow *pInsertAfter=NULL)
Inserts a child window into the window tree.
Definition Swnd.cpp:538
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
Handles the mouse wheel event.
Definition Swnd.cpp:2159
void OnLButtonUp(UINT nFlags, CPoint pt)
Handles the left mouse button up event.
Definition Swnd.cpp:2105
SWindow * GetRoot() const
Retrieves the root window in the hierarchy.
Definition Swnd.cpp:3493
LRESULT SSendMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0, BOOL *pbMsgHandled=NULL) OVERRIDE
Sends a message to the window.
Definition Swnd.cpp:364
void SetCheck(BOOL bCheck) OVERRIDE
Sets the check state of the window.
Definition Swnd.cpp:671
IWindow * GetIWindow(int uCode) SCONST OVERRIDE
Retrieves a window based on a given code.
Definition Swnd.cpp:2653
IWindow * GetISelectedChildInGroup() OVERRIDE
Retrieves the selected child window in a group.
Definition Swnd.cpp:3587
void MarkCacheDirty(bool bDirty)
Marks the cache as dirty.
Definition Swnd.cpp:2733
SWindow * m_pFirstChild
Definition SWnd.h:2588
IWindow * FindIChildByNameA(LPCSTR pszName) OVERRIDE
Finds a child window by its name (ANSI version).
Definition Swnd.cpp:1680
HRESULT OnAttrVisible(const SStringW &strValue, BOOL bLoading)
Handles the 'visible' attribute.
Definition Swnd.cpp:2739
BOOL CreateChildrenFromXml(LPCWSTR pszXml) OVERRIDE
Creates child windows from XML.
Definition Swnd.cpp:1024
HRESULT OnAttrEnable(const SStringW &strValue, BOOL bLoading)
Handles the 'enable' attribute.
Definition Swnd.cpp:2749
virtual void BeforePaint(IRenderTarget *pRT, SPainter &painter)
Prepare rendering environment.
Definition Swnd.cpp:1755
void SetToolTipTextU8(LPCSTR pszText) OVERRIDE
Sets the tooltip text using a UTF-8 string.
Definition Swnd.cpp:3252
static SStringW GetXmlText(const SXmlNode &xmlNode)
Gets the XML text from a node.
Definition Swnd.cpp:2955
void InvalidateRect(LPCRECT lprect) OVERRIDE
Invalidates a specific rectangle area of the window.
Definition Swnd.cpp:1444
virtual void OnAfterRemoveChild(SWindow *pChild)
Called after a child window has been removed from this window.
Definition Swnd.cpp:3403
void UpdateLayout() OVERRIDE
Updates the layout of the window.
Definition Swnd.cpp:2251
BOOL OnEraseBkgnd(IRenderTarget *pRT)
Handles the erasing of the background.
Definition Swnd.cpp:1733
void _PaintClient(IRenderTarget *pRT)
Renders the client area of the window onto the RenderTarget.
Definition Swnd.cpp:1096
virtual SStringW tr(const SStringW &strSrc) const
Translation function.
Definition Swnd.cpp:940
virtual SWindow * _FindChildByID(int nID, int nDeep)
Finds a child window by ID.
Definition Swnd.cpp:726
SMatrix _GetMatrixEx() const
Retrieves the extended transformation matrix for the window.
Definition Swnd.cpp:2450
BOOL IsMsgTransparent() SCONST OVERRIDE
Checks if the window is message transparent.
Definition Swnd.cpp:711
BOOL m_bHoverAware
Definition SWnd.h:2615
void UpdateChildrenPosition() OVERRIDE
Updates the position of child windows.
Definition Swnd.cpp:2189
bool m_isAnimating
Definition SWnd.h:2633
BOOL IsChecked() SCONST OVERRIDE
Checks if the window is checked.
Definition Swnd.cpp:633
STrText m_strToolTipText
Definition SWnd.h:2598
BOOL m_bFocusable
Definition SWnd.h:2609
virtual SWindow * CreateChildByName(LPCWSTR pszName)
Create child window by name.
Definition Swnd.cpp:935
LayoutDirtyType m_layoutDirty
Definition SWnd.h:2618
SAutoRefPtr< IRenderTarget > m_cachedRT
Definition SWnd.h:2619
SWindow()
Constructor.
Definition Swnd.cpp:104
IRegionS * GetWindowRgn() SCONST OVERRIDE
Retrieves the window region.
Definition Swnd.cpp:3126
virtual void DrawFocus(IRenderTarget *pRT)
Draw focus state.
Definition Swnd.cpp:1973
LRESULT OnSetColorize(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles setting the colorization of the window.
Definition Swnd.cpp:3148
virtual HRESULT AfterAttribute(const SStringW &strAttribName, const SStringW &strValue, BOOL bLoading, HRESULT hr)
Called after an attribute is processed.
Definition Swnd.cpp:3188
bool _ApplyMatrix(IRenderTarget *pRT, SMatrix &oriMtx)
Applies a transformation matrix to the RenderTarget.
Definition Swnd.cpp:2435
void OnLButtonDown(UINT nFlags, CPoint pt)
Handles the left mouse button down event.
Definition Swnd.cpp:2092
virtual void OnUpdateFloatPosition(const CRect &rcParent)
Update floating window position.
Definition SWnd.h:1660
BOOL RemoveIChild(IWindow *pChild) OVERRIDE
Removes a child window from the window tree.
Definition Swnd.cpp:3542
void SetContainer(ISwndContainer *pContainer) OVERRIDE
Sets the container for the window.
Definition Swnd.cpp:689
BOOL IsContainPoint(POINT pt, BOOL bClientOnly) SCONST OVERRIDE
Checks if the window contains a specified point.
Definition Swnd.cpp:3100
virtual BOOL OnRelayout(const CRect &rcWnd)
Handles window position changes during layout updates.
Definition Swnd.cpp:1587
SWND SetCapture() OVERRIDE
Sets the window to capture the mouse.
Definition Swnd.cpp:2484
void OnAnimationRepeat(IAnimation *animation)
Called when an animation repeats.
Definition Swnd.cpp:3374
SWindow * m_pOwner
Definition SWnd.h:2586
SAutoRefPtr< ICaret > m_caret
Definition SWnd.h:2647
void ClearAnimation() OVERRIDE
Clears the animation for the window.
Definition Swnd.cpp:2559
void SetFocus() OVERRIDE
Sets the focus to the window.
Definition Swnd.cpp:2620
virtual void OnBeforeRemoveChild(SWindow *pChild)
Called before a child window is removed from this window.
Definition Swnd.cpp:3391
HRESULT DefAttributeProc(const SStringW &strAttribName, const SStringW &strValue, BOOL bLoading)
Default attribute processing function.
Definition Swnd.cpp:3017
virtual void OnRebuildFont()
Called when the font of the window needs to be rebuilt.
Definition Swnd.cpp:3303
void OnAnimationPauseChange(IAnimation *animation, BOOL bPaused)
Called when the pause state of an animation changes.
Definition Swnd.cpp:3671
BOOL m_bCacheDraw
Definition SWnd.h:2611
virtual void OnAfterInsertChild(SWindow *pChild)
Called after a child window has been inserted into this window.
Definition Swnd.cpp:3395
BOOL AdjustZOrder(SWindow *pInsertAfter)
Adjusts the Z-order of the window.
Definition Swnd.cpp:1518
SStringW m_strTrCtx
Definition SWnd.h:2599
virtual void OnBeforeInsertChild(SWindow *pChild)
Called before a child window is inserted into this window.
Definition Swnd.cpp:3399
SWND GetCapture() SCONST OVERRIDE
Retrieves the window that has captured the mouse.
Definition Swnd.cpp:2470
virtual void GetTextRect(LPRECT pRect)
Calculate text display rectangle.
Definition Swnd.cpp:1961
void SetIOwner(IWindow *pOwner) OVERRIDE
Sets the owner window.
Definition Swnd.cpp:3552
BOOL IsUpdateLocked(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if updates to the window are locked.
Definition Swnd.cpp:1503
void SetWindowRgn(IRegionS *pRgn, BOOL bRedraw=TRUE) OVERRIDE
Sets the window region.
Definition Swnd.cpp:3114
virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter)
Restore rendering environment.
Definition Swnd.cpp:1776
ILayoutParam * GetLayoutParam() SCONST OVERRIDE
Retrieves the layout parameter object associated with the window.
Definition SWnd.h:405
SWindow * GetWindow(int uCode) const
Retrieves a window based on a given code.
Definition Swnd.cpp:3456
void ShowCaret(BOOL bShow) OVERRIDE
Shows or hides the caret.
Definition Swnd.cpp:3066
void TransformPoint(CPoint &pt) const
Transforms a point based on the current window's transformation matrix.
Definition Swnd.cpp:1377
BOOL IsDisabled(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if the window is disabled.
Definition Swnd.cpp:638
virtual void DrawText(IRenderTarget *pRT, LPCTSTR pszBuf, int cchText, LPRECT pRect, UINT uFormat)
Draw text content.
Definition Swnd.cpp:1968
SLayoutSize m_nMaxWidth
Definition SWnd.h:2626
void DrawDefFocusRect(IRenderTarget *pRT, CRect rc)
Draws the default focus rectangle.
Definition Swnd.cpp:1981
void KillFocus() OVERRIDE
Kills the focus from the window.
Definition Swnd.cpp:2629
IWindow * FindIChildByName(LPCWSTR pszName) OVERRIDE
Finds a child window by its name.
Definition Swnd.cpp:1675
void DestroyAllChildren() OVERRIDE
Destroys all child windows.
Definition Swnd.cpp:1685
SWindow * m_pNextSibling
Definition SWnd.h:2590
SEventSet * GetEventSet()
Retrieves the event set associated with the window.
Definition SWnd.h:1290
BOOL KillTimer(char id) OVERRIDE
Kills a timer for the window.
Definition Swnd.cpp:483
BOOL IsFocusable() SCONST OVERRIDE
Checks if the window is focusable.
Definition Swnd.cpp:1996
SWindow * m_pParent
Definition SWnd.h:2587
SAutoRefPtr< ISkinObj > m_pBgSkin
Definition SWnd.h:2622
bool _WndRectInRgn(const CRect &rc, const IRegionS *rgn) const
Checks if the window rectangle lies within a specified region.
Definition Swnd.cpp:1221
void RedrawRegion(IRenderTarget *pRT, IRegionS *pRgn)
Renders the content of the window and its child windows onto the RenderTarget.
Definition Swnd.cpp:1422
void OnShowWindow(BOOL bShow, UINT nStatus)
Handles showing or hiding the window.
Definition Swnd.cpp:2001
virtual void OnColorize(COLORREF cr)
Adjusts the color tone of the window.
Definition Swnd.cpp:3154
virtual BOOL OnSetCursor(const CPoint &pt)
Sets the cursor when the mouse hovers over the window.
Definition Swnd.cpp:429
BOOL FireCtxMenu(POINT pt) OVERRIDE
Fires a context menu event.
Definition Swnd.cpp:2719
void Invalidate() OVERRIDE
Invalidates the entire window.
Definition Swnd.cpp:1437
bool IsCacheDirty() const
Checks if the cache is marked as dirty.
Definition Swnd.cpp:2728
IPathS * GetWindowPath() SCONST OVERRIDE
Retrieves the window path.
Definition Swnd.cpp:3138
BOOL CreateCaret(HBITMAP pBmp, int nWid, int nHeight) OVERRIDE
Creates a caret.
Definition Swnd.cpp:3038
void SetWindowText(LPCTSTR lpszText) OVERRIDE
Sets the window text.
Definition Swnd.cpp:311
BOOL IsDescendant(const IWindow *pWnd) SCONST OVERRIDE
Checks if a window is a descendant of this window.
Definition Swnd.cpp:3518
BOOL m_bMsgHandled
Definition SWnd.h:2616
STrText m_strText
Definition SWnd.h:2597
virtual SWindow * GetSelectedSiblingInGroup()
Get selected sibling in group.
Definition SWnd.h:1598
virtual bool IsDrawToCache() const
Checks if the window content is being drawn to the cache.
Definition Swnd.cpp:2992
void RequestRelayout() OVERRIDE
Requests a relayout of the window.
Definition Swnd.cpp:2225
BOOL AddEvent(DWORD dwEventID, LPCWSTR pszEventHandlerName) OVERRIDE
Adds an event handler.
Definition Swnd.cpp:3626
void GetWindowRect(LPRECT prect) SCONST OVERRIDE
Retrieves the bounding rectangle of the window.
COLORREF GetBkgndColor() SCONST OVERRIDE
Retrieves the background color of the window.
Definition Swnd.cpp:3386
virtual void OnStateChanging(DWORD dwOldState, DWORD dwNewState)
Called before the state of the window changes.
Definition Swnd.cpp:2997
virtual BOOL CreateChildren(SXmlNode xmlNode)
Create child windows from XML node.
Definition Swnd.cpp:823
ILayout * GetLayout() OVERRIDE
Retrieves the layout object associated with the window.
Definition SWnd.h:396
void SetMsgHandled(BOOL bHandled)
Sets the message handled flag.
Definition Swnd.cpp:212
void OnRButtonDown(UINT nFlags, CPoint point)
Handles the right mouse button down event.
Definition Swnd.cpp:2122
SEventSet m_evtSet
Definition SWnd.h:2581
HRESULT OnAttrTrackMouseEvent(const SStringW &strValue, BOOL bLoading)
Handles the 'trackMouseEvent' attribute.
Definition Swnd.cpp:2812
virtual SStringT GetToolTipText()
Retrieves the tooltip text of the window.
Definition Swnd.cpp:3236
bool m_isDestroying
Definition SWnd.h:2634
ULONG_PTR SetUserData(ULONG_PTR uData) OVERRIDE
Sets the user data for the window.
Definition Swnd.cpp:470
BOOL RegisterDragDrop(IDropTarget *pDragTarget) OVERRIDE
Registers a drop target for the window.
Definition Swnd.cpp:3661
void GetScaleSkin(SAutoRefPtr< ISkinObj > &pSkin, int nScale)
Retrieves a scaled skin object based on the current scale factor.
Definition Swnd.cpp:3290
BOOL InitFromXml(IXmlNode *pNode) OVERRIDE
Initializes the window from an XML node.
Definition Swnd.cpp:946
IWindow * GetIChild(int iChild) SCONST OVERRIDE
Retrieves a child window by index.
Definition Swnd.cpp:2658
BOOL FireCommand() OVERRIDE
Fires a command event.
Definition Swnd.cpp:2713
void OnEnable(BOOL bEnable, UINT nStatus)
Handles enabling or disabling the window.
Definition Swnd.cpp:2059
void _PaintNonClient(IRenderTarget *pRT)
Renders the non-client area of the window onto the RenderTarget.
Definition Swnd.cpp:1139
void Update(BOOL bForce=FALSE) OVERRIDE
Updates the window.
Definition Swnd.cpp:1430
void OnSetFocus(SWND wndOld)
Handles gaining focus.
Definition Swnd.cpp:2265
BOOL m_bVisible
Definition SWnd.h:2604
SAnimationHandler m_animationHandler
Definition SWnd.h:2631
DWORD ModifyState(DWORD dwStateAdd, DWORD dwStateRemove, BOOL bUpdate=FALSE) OVERRIDE
Modifies the state of the window.
Definition Swnd.cpp:443
SAutoRefPtr< IAttrStorage > m_attrStorage
Definition SWnd.h:2646
const SwndStyle & GetStyle() const
Retrieves the style of the window.
Definition Swnd.cpp:716
void LockUpdate() OVERRIDE
Locks updates to the window.
Definition Swnd.cpp:1492
virtual void OnStateChanged(DWORD dwOldState, DWORD dwNewState)
Called after the state of the window changes.
Definition Swnd.cpp:3001
HWND GetHostHwnd() OVERRIDE
Retrieves the host window handle.
Definition Swnd.cpp:3616
IWindow * FindIChildByID(int nId) OVERRIDE
Finds a child window by its ID.
Definition Swnd.cpp:1670
SWND m_swnd
Member variables representing various properties of the window.
Definition SWnd.h:2577
SWindow * FindChildByID(int nID, int nDeep=-1)
Finds a child window by its ID.
Definition Swnd.cpp:781
void BeforePaintEx(IRenderTarget *pRT)
Prepares the drawing environment for the current window's RenderTarget, starting from the top-level w...
Definition Swnd.cpp:1767
void Move(LPCRECT prect) OVERRIDE
Moves the window to a new position and size.
Definition Swnd.cpp:399
BOOL m_bClipClient
Definition SWnd.h:2607
ISwndContainer * m_pContainer
Definition SWnd.h:2580
HRESULT OnAttrSkin(const SStringW &strValue, BOOL bLoading)
Handles the 'skin' attribute.
Definition Swnd.cpp:2776
ITimelineHandlersMgr * GetTimelineHandlersMgr() OVERRIDE
Retrieves the timeline handlers manager.
Definition Swnd.cpp:3621
SAutoRefPtr< ILayout > m_pLayout
Definition SWnd.h:2583
virtual BOOL OnNcHitTest(CPoint pt)
Non-client area hit test.
Definition Swnd.cpp:2647
BOOL RemoveEvent(DWORD dwEventID) OVERRIDE
Removes an event handler.
Definition Swnd.cpp:3631
BOOL CreateChildrenFromResId(LPCTSTR pszResId) OVERRIDE
Creates child windows from a resource ID.
Definition Swnd.cpp:1032
ULONG_PTR m_uData
Definition SWnd.h:2624
SAutoRefPtr< IAnimation > m_animation
Definition SWnd.h:2630
LRESULT OnUpdateFont(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles updating the font of the window.
Definition Swnd.cpp:3171
UINT m_nChildrenCount
Definition SWnd.h:2592
BOOL ReleaseCapture() OVERRIDE
Releases the mouse capture from the window.
Definition Swnd.cpp:2491
BOOL SetLayoutParam(ILayoutParam *pLayoutParam) OVERRIDE
Sets the layout parameter object for the window.
Definition Swnd.cpp:3342
IRenderTarget * GetRenderTarget(LPCRECT pRc=NULL, GrtFlag gdcFlags=GRT_NODRAW, BOOL bClientRT=TRUE)
Retrieves a memory DC compatible with the SWND window.
Definition Swnd.cpp:2320
Manages DUI windows in the SOUI system.
Definition SWindowMgr.h:33
static bool IsWindow(SWND swnd)
Checks if a given handle is a valid window handle.
static BOOL DestroyWindow(SWND swnd)
Destroys a window with the specified handle.
Class representing an XML attribute.
Definition SXml.h:20
SXmlAttr next_attribute() const
Gets the next attribute in the attribute list of the parent node.
Definition SXml.cpp:180
bool set_value(const wchar_t *rhs)
Sets the attribute value.
Definition SXml.cpp:130
const wchar_t * name() const
Gets the attribute name.
Definition SXml.cpp:85
const wchar_t * value() const
Gets the attribute value.
Definition SXml.cpp:90
Implementation of IXmlDoc.
Definition SXml.h:912
bool load_buffer_inplace(void *contents, size_t size, unsigned int options=xml_parse_default, XmlEncoding encoding=enc_auto)
Loads the document from a buffer using in-place parsing.
Definition SXml.cpp:732
SXmlNode root() const
Retrieves the root node of the document.
Definition SXml.cpp:754
bool load_buffer(const void *contents, size_t size, unsigned int options=xml_parse_default, XmlEncoding encoding=enc_auto)
Loads the document from a buffer.
Definition SXml.cpp:726
Class representing an XML node.
Definition SXml.h:352
SXmlNode next_sibling() const
Gets the next sibling node in the children list of the parent node.
Definition SXml.cpp:393
SXmlAttr first_attribute() const
Gets the first attribute of the node.
Definition SXml.cpp:373
SXmlNode first_child() const
Gets the first child node of the node.
Definition SXml.cpp:383
const wchar_t * name() const
Gets the name of the node.
Definition SXml.cpp:363
const wchar_t * child_value() const
Gets the child value of the current node.
Definition SXml.cpp:438
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
Definition SXml.cpp:428
SXmlAttr append_attribute(const wchar_t *name)
Adds an attribute with the specified name.
Definition SXml.cpp:458
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
Definition SXml.cpp:423
const wchar_t * Text() SCONST OVERRIDE
Gets the node text.
Definition SXml.cpp:265
Soui布局参数类
Definition SouiLayout.h:16
Manages the style attributes of SOUI windows.
Definition SWndStyle.h:28
UINT GetTextAlign() const
Retrieves the text alignment.
Definition SwndStyle.cpp:36
IFontPtr GetTextFont(int iState)
Retrieves the text font for a specific state.
Definition SwndStyle.cpp:87
int GetScale() const
Retrieves the scale factor.
void SetScale(int nScale)
Sets the scale factor.
COLORREF m_crBorder
Definition SWndStyle.h:59
DWORD m_bTrackMouseEvent
Definition SWndStyle.h:64
int GetStates()
Retrieves the number of states.
Definition SwndStyle.cpp:66
COLORREF m_crBg
Definition SWndStyle.h:58
COLORREF GetTextColor(int iState)
Retrieves the text color for a specific state.
Definition SwndStyle.cpp:79
DWORD m_bVideoCanvas
Definition SWndStyle.h:65
CRect GetMargin() const
Retrieves the margin rectangle.
CRect GetPadding() const
Retrieves the padding rectangle.
long AddRef() override
Increments the reference count.
float fMat[kMCount]
Array of floats representing the matrix elements.
Definition SRender-i.h:975
Interface for reference counting.
Definition obj-ref-i.h:19
Region object interface.
Definition SRender-i.h:792
BOOL IsEmpty() SCONST PURE
Checks if the region is empty.
void GetRgnBox(LPRECT lprect) SCONST PURE
Retrieves the bounding rectangle of the region.
Base class for all renderable objects.
Definition SRender-i.h:145
Interface for rendering target objects.
Definition SRender-i.h:1440
HRESULT DrawRectangle(LPCRECT pRect) PURE
Draw a rectangle outline.
HRESULT DrawText(LPCTSTR pszText, int cchLen, LPRECT pRc, UINT uFormat) PURE
Draw text within a rectangle.
HRESULT SetViewportOrg(POINT pt) PURE
Set the viewport origin.
HRESULT AlphaBlend(LPCRECT pRcDest, IRenderTarget *pRTSrc, LPCRECT pRcSrc, BYTE byAlpha) PURE
Performs an alpha-blended transfer from one render target to another.
long Release() PURE
Decrement the reference count and destroy the object if the count reaches zero.
HRESULT GetTransform(float matrix[9]) SCONST PURE
Retrieves the current coordinate transformation matrix.
IRenderObj * GetCurrentObject(OBJTYPE uType) PURE
Retrieves the current rendering object of the specified type.
HRESULT SelectObject(IRenderObj *pObj, IRenderObj **pOldObj=NULL) PURE
Selects a new rendering object and optionally retrieves the previous one.
HRESULT SetTransform(const float matrix[9], float oldMatrix[9]=NULL) PURE
Sets the coordinate transformation matrix.
void EndDraw() PURE
End a drawing operation.
HRESULT PushClipRect(LPCRECT pRect, UINT mode=RGN_AND) PURE
Push a rectangular clip region.
HRESULT CreatePen(int iStyle, COLORREF cr, int cWidth, IPenS **ppPen) PURE
Create a pen object.
HRESULT RestoreClip(int nState=-1) PURE
Restore a previously saved clip state.
HRESULT PopClip() PURE
Pop the last clip region from the stack.
HRESULT FillSolidRect(LPCRECT pRect, COLORREF cr) PURE
Fill a rectangle with a solid color.
void BeginDraw() PURE
Start a drawing operation.
HRESULT PushClipPath(const IPathS *path, UINT mode, BOOL doAntiAlias=FALSE) PURE
Modifies the current clipping region using a path.
HRESULT SaveClip(int *pnState) PURE
Save the current clip state.
HRESULT OffsetViewportOrg(int xOff, int yOff, LPPOINT lpPoint=NULL) PURE
Offset the viewport origin.
COLORREF GetTextColor() PURE
Retrieves the current text color.
HRESULT ClearRect(LPCRECT pRect, COLORREF cr) PURE
Clear a rectangle with a solid color.
COLORREF SetTextColor(COLORREF color) PURE
Sets the current text color.
HRESULT PushClipRegion(IRegionS *pRegion, UINT mode=RGN_AND) PURE
Push a region-based clip.
Interface for Skin Objects.
Definition SSkinobj-i.h:29
SOUI Window Container Interface.
void OnSetSwndFocus(SWND swnd) PURE
Sets the focus to the specified Swnd object.
BOOL RegisterDragDrop(SWND swnd, IDropTarget *pDropTarget) PURE
Registers an IDropTarget with a Swnd.
BOOL RegisterVideoCanvas(SWND swnd) PURE
Registers a VideoCanvas window.
HWND GetHostHwnd() PURE
Retrieves the handle to the host window.
IScriptModule * GetScriptModule() PURE
Retrieves the script module.
void BuildWndTreeZorder() PURE
Rebuilds the window tree's z-order.
BOOL RegisterTimelineHandler(ITimelineHandler *pHandler) PURE
Registers an animation frame handler.
SWND GetFocus() SCONST PURE
Retrieves the Swnd object that has focus.
BOOL OnReleaseSwndCapture() PURE
Releases the mouse capture from the Swnd object.
void MarkWndTreeZorderDirty() PURE
Marks the window tree's z-order as dirty.
BOOL UnregisterTrackMouseEvent(SWND swnd) PURE
Unregisters a Swnd as a TrackMouseEvent window.
void UpdateTooltip() PURE
Requests an update of the tooltip.
LPCWSTR GetTranslatorContext() SCONST PURE
Retrieves the translation context.
SWND OnGetSwndCapture() SCONST PURE
Retrieves the Swnd object that has captured the mouse.
BOOL OnFireEvent(IEvtArgs *evt) PURE
Fires an event.
BOOL UnregisterTimelineHandler(ITimelineHandler *pHandler) PURE
Unregisters an animation frame handler.
void OnRedraw(LPCRECT rc, BOOL bClip) PURE
Requests a redraw of the specified area.
void UpdateRegion(IRegionS *rgn) PURE
Updates the specified region of the memory bitmap.
BOOL UnregisterDragDrop(SWND swnd) PURE
Unregisters an IDropTarget from a Swnd.
BOOL UpdateWindow(BOOL bForce=TRUE) PURE
Requests an immediate update of the window.
BOOL UnregisterVideoCanvas(SWND swnd) PURE
Unregisters a VideoCanvas window.
BOOL RegisterTrackMouseEvent(SWND swnd) PURE
Registers a Swnd as a TrackMouseEvent window.
SWND OnSetSwndCapture(SWND swnd) PURE
Sets the Swnd object to capture the mouse.
Interface for XML nodes.
Definition sxml-i.h:128
Structure representing a window message.
Definition SWnd.h:88
Information for window tooltips.
Definition SWnd.h:208
CRect rcTarget
Definition SWnd.h:211
DWORD dwCookie
Definition SWnd.h:210
SStringT strTip
Definition SWnd.h:212
Bitfield structure for font style attributes.