diff --git a/Demos/bdwallpaper/BDWallPaper.cpp b/Demos/bdwallpaper/BDWallPaper.cpp
index c057c225..0cf422cd 100644
--- a/Demos/bdwallpaper/BDWallPaper.cpp
+++ b/Demos/bdwallpaper/BDWallPaper.cpp
@@ -15,7 +15,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*l
CMainWnd* pFrame = new CMainWnd();
if( pFrame == NULL ) return 0;
- pFrame->Create(NULL, _T("迅雷游戏盒子"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 884, 652);
+ pFrame->Create(NULL, _T("百度壁纸"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 884, 652);
pFrame->CenterWindow();
CPaintManagerUI::MessageLoop();
diff --git a/Demos/bdwallpaper/MainWnd.cpp b/Demos/bdwallpaper/MainWnd.cpp
index 3cc48717..ac162c6b 100644
--- a/Demos/bdwallpaper/MainWnd.cpp
+++ b/Demos/bdwallpaper/MainWnd.cpp
@@ -61,7 +61,7 @@ DuiLib::CDuiString CMainWnd::GetSkinFolder()
#ifdef _DEBUG
return _T("skin\\BDWallPaper\\");
#else
- return _T("skin\\");
+ return _T("skin\\BDWallPaper\\");
#endif
}
@@ -143,6 +143,8 @@ void CMainWnd::InitWindow()
pOption->SetFixedWidth(65);
pOption->SetHotImage(_T("file='main/224.bmp' corner='4,4,4,4'"));
pOption->SetSelectedImage(_T("file='main/224.bmp' corner='4,4,4,4'"));
+ pOption->OnNotify += MakeDelegate(this, &CMainWnd::OnNotify1);
+ pOption->OnNotify += MakeDelegate(this, &CMainWnd::OnNotify2);
pTabBar->Add(pOption);
if(pFirst == NULL) pFirst = pOption;
}
diff --git a/Demos/bdwallpaper/MainWnd.h b/Demos/bdwallpaper/MainWnd.h
index cfe2a5fe..e14d16fd 100644
--- a/Demos/bdwallpaper/MainWnd.h
+++ b/Demos/bdwallpaper/MainWnd.h
@@ -152,6 +152,16 @@ class CMainWnd : public WindowImplBase
return 0;
}
+
+ bool OnNotify1(void* param)
+ {
+ return true;
+ }
+
+ bool OnNotify2(void* param)
+ {
+ return true;
+ }
public:
virtual void Notify( TNotifyUI &msg );
DUI_DECLARE_MESSAGE_MAP()
diff --git a/Demos/bdwallpaper/controlex/UIWPPanel.h b/Demos/bdwallpaper/controlex/UIWPPanel.h
index db948e5b..d3b70b41 100644
--- a/Demos/bdwallpaper/controlex/UIWPPanel.h
+++ b/Demos/bdwallpaper/controlex/UIWPPanel.h
@@ -24,9 +24,9 @@ namespace DuiLib
}
public:
- void SetPos(RECT rc)
+ void SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
RECT rcItem = m_rcItem;
rcItem.left += m_rcInset.left;
diff --git a/Demos/duidemo/duidemo.vcxproj b/Demos/duidemo/duidemo.vcxproj
index 3213b3b2..c5564286 100644
--- a/Demos/duidemo/duidemo.vcxproj
+++ b/Demos/duidemo/duidemo.vcxproj
@@ -307,6 +307,11 @@
+
+
+ {e106acd7-4e53-4aee-942b-d0dd426db34e}
+
+
diff --git a/DuiLib/Control/UIActiveX.cpp b/DuiLib/Control/UIActiveX.cpp
index 7c1bdfc1..bc9bc9ad 100644
--- a/DuiLib/Control/UIActiveX.cpp
+++ b/DuiLib/Control/UIActiveX.cpp
@@ -913,9 +913,9 @@ void CActiveXUI::SetInternVisible(bool bVisible)
::ShowWindow(m_hwndHost, IsVisible() ? SW_SHOW : SW_HIDE);
}
-void CActiveXUI::SetPos(RECT rc)
+void CActiveXUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
if( !m_bCreated ) DoCreateControl();
diff --git a/DuiLib/Control/UIActiveX.h b/DuiLib/Control/UIActiveX.h
index 17e15bba..40e88767 100644
--- a/DuiLib/Control/UIActiveX.h
+++ b/DuiLib/Control/UIActiveX.h
@@ -49,7 +49,7 @@ namespace DuiLib {
void SetVisible(bool bVisible = true);
void SetInternVisible(bool bVisible = true);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void DoPaint(HDC hDC, const RECT& rcPaint);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
diff --git a/DuiLib/Control/UICombo.cpp b/DuiLib/Control/UICombo.cpp
index 486aed9d..82741fb9 100644
--- a/DuiLib/Control/UICombo.cpp
+++ b/DuiLib/Control/UICombo.cpp
@@ -781,13 +781,13 @@ void CComboUI::SetItemShowHtml(bool bShowHtml)
Invalidate();
}
-void CComboUI::SetPos(RECT rc)
+void CComboUI::SetPos(RECT rc, bool bNeedInvalidate)
{
// Put all elements out of sight
RECT rcNull = { 0 };
for( int i = 0; i < m_items.GetSize(); i++ ) static_cast(m_items[i])->SetPos(rcNull);
// Position this control
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
}
void CComboUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
diff --git a/DuiLib/Control/UICombo.h b/DuiLib/Control/UICombo.h
index 78b7f6cb..1c4ce7ad 100644
--- a/DuiLib/Control/UICombo.h
+++ b/DuiLib/Control/UICombo.h
@@ -91,7 +91,7 @@ class UILIB_API CComboUI : public CContainerUI, public IListOwnerUI
void SetItemShowHtml(bool bShowHtml = true);
SIZE EstimateSize(SIZE szAvailable);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void DoEvent(TEventUI& event);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
diff --git a/DuiLib/Control/UIEdit.cpp b/DuiLib/Control/UIEdit.cpp
index 400e45ed..1040aca9 100644
--- a/DuiLib/Control/UIEdit.cpp
+++ b/DuiLib/Control/UIEdit.cpp
@@ -506,9 +506,9 @@ namespace DuiLib
return m_dwTipValueColor;
}
- void CEditUI::SetPos(RECT rc)
+ void CEditUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
if( m_pWindow != NULL ) {
RECT rcPos = m_pWindow->CalPos();
::SetWindowPos(m_pWindow->GetHWND(), NULL, rcPos.left, rcPos.top, rcPos.right - rcPos.left,
diff --git a/DuiLib/Control/UIEdit.h b/DuiLib/Control/UIEdit.h
index 03478892..f2680a29 100644
--- a/DuiLib/Control/UIEdit.h
+++ b/DuiLib/Control/UIEdit.h
@@ -53,7 +53,7 @@ namespace DuiLib
void SetTipValueColor(LPCTSTR pStrColor);
DWORD GetTipValueColor();
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void SetVisible(bool bVisible = true);
void SetInternVisible(bool bVisible = true);
SIZE EstimateSize(SIZE szAvailable);
diff --git a/DuiLib/Control/UIList.cpp b/DuiLib/Control/UIList.cpp
index a851ea3e..ba400f8d 100644
--- a/DuiLib/Control/UIList.cpp
+++ b/DuiLib/Control/UIList.cpp
@@ -218,9 +218,9 @@ void CListUI::RemoveAll()
m_pList->RemoveAll();
}
-void CListUI::SetPos(RECT rc)
+void CListUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CVerticalLayoutUI::SetPos(rc);
+ CVerticalLayoutUI::SetPos(rc, bNeedInvalidate);
if( m_pHeader == NULL ) return;
// Determine general list information and the size of header columns
@@ -1000,9 +1000,9 @@ void CListBodyUI::SetScrollPos(SIZE szPos)
}
-void CListBodyUI::SetPos(RECT rc)
+void CListBodyUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
rc = m_rcItem;
// Adjust for inset
@@ -1189,9 +1189,9 @@ SIZE CListHeaderUI::EstimateSize(SIZE szAvailable)
return cXY;
}
-void CListHeaderUI::SetPos(RECT rc)
+void CListHeaderUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
rc = m_rcItem;
// Adjust for inset
@@ -2557,9 +2557,9 @@ void CListContainerElementUI::DrawItemBk(HDC hDC, const RECT& rcItem)
}
}
-void CListContainerElementUI::SetPos(RECT rc)
+void CListContainerElementUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CHorizontalLayoutUI::SetPos(rc);
+ CHorizontalLayoutUI::SetPos(rc, bNeedInvalidate);
if( m_pOwner == NULL ) return;
CListUI* pList = static_cast(m_pOwner);
diff --git a/DuiLib/Control/UIList.h b/DuiLib/Control/UIList.h
index ab7ca85a..517dd4b4 100644
--- a/DuiLib/Control/UIList.h
+++ b/DuiLib/Control/UIList.h
@@ -168,7 +168,7 @@ class UILIB_API CListUI : public CVerticalLayoutUI, public IListUI
int GetExpandedItem() const;
bool ExpandItem(int iIndex, bool bExpand = true);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void DoEvent(TEventUI& event);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
@@ -216,7 +216,7 @@ class UILIB_API CListBodyUI : public CVerticalLayoutUI
CListBodyUI(CListUI* pOwner);
void SetScrollPos(SIZE szPos);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void DoEvent(TEventUI& event);
BOOL SortItems(PULVCompareFunc pfnCompare, UINT_PTR dwData);
protected:
@@ -240,7 +240,7 @@ class UILIB_API CListHeaderUI : public CHorizontalLayoutUI
LPVOID GetInterface(LPCTSTR pstrName);
SIZE EstimateSize(SIZE szAvailable);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
void SetScaleHeader(bool bIsScale);
@@ -449,7 +449,7 @@ class UILIB_API CListContainerElementUI : public CHorizontalLayoutUI, public ILi
virtual void DrawItemText(HDC hDC, const RECT& rcItem);
virtual void DrawItemBk(HDC hDC, const RECT& rcItem);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
protected:
int m_iIndex;
diff --git a/DuiLib/Control/UIRichEdit.cpp b/DuiLib/Control/UIRichEdit.cpp
index d1bd7865..7a4c3c9a 100644
--- a/DuiLib/Control/UIRichEdit.cpp
+++ b/DuiLib/Control/UIRichEdit.cpp
@@ -1794,7 +1794,7 @@ void CRichEditUI::OnTxNotify(DWORD iNotify, void *pv)
// 多行非rich格式的richedit有一个滚动条bug,在最后一行是空行时,LineDown和SetScrollPos无法滚动到最后
// 引入iPos就是为了修正这个bug
-void CRichEditUI::SetScrollPos(SIZE szPos)
+void CRichEditUI::SetScrollPos(SIZE szPos, bool bMsg)
{
int cx = 0;
int cy = 0;
@@ -2093,13 +2093,12 @@ void CRichEditUI::PaintStatusImage(HDC hDC)
SIZE CRichEditUI::EstimateSize(SIZE szAvailable)
{
- //return CDuiSize(m_rcItem); // 这种方式在第一次设置大小之后就大小不变了
return CContainerUI::EstimateSize(szAvailable);
}
-void CRichEditUI::SetPos(RECT rc)
+void CRichEditUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
rc = m_rcItem;
rc.left += m_rcInset.left;
@@ -2223,13 +2222,12 @@ void CRichEditUI::SetPos(RECT rc)
if( sz.cy > pControl->GetMaxHeight() ) sz.cy = pControl->GetMaxHeight();
RECT rcCtrl = { iPosX + rcPadding.left, rc.top + rcPadding.top, iPosX + sz.cx + rcPadding.left , rc.top + rcPadding.top + sz.cy};
- pControl->SetPos(rcCtrl);
+ pControl->SetPos(rcCtrl, true);
iPosX += sz.cx + m_iChildPadding + rcPadding.left + rcPadding.right;
cxNeeded += sz.cx + rcPadding.left + rcPadding.right;
szRemaining.cx -= sz.cx + m_iChildPadding + rcPadding.right;
}
cxNeeded += (nEstimateNum - 1) * m_iChildPadding;
- //reddrain
if( m_pHorizontalScrollBar != NULL ) {
if( cxNeeded > rc.right - rc.left ) {
if( m_pHorizontalScrollBar->IsVisible() ) {
@@ -2242,14 +2240,6 @@ void CRichEditUI::SetPos(RECT rc)
rc.bottom -= m_pHorizontalScrollBar->GetFixedHeight();
}
}
- else {
- if( m_pHorizontalScrollBar->IsVisible() ) {
- m_pHorizontalScrollBar->SetVisible(false);
- m_pHorizontalScrollBar->SetScrollRange(0);
- m_pHorizontalScrollBar->SetScrollPos(0);
- rc.bottom += m_pHorizontalScrollBar->GetFixedHeight();
- }
- }
}
}
diff --git a/DuiLib/Control/UIRichEdit.h b/DuiLib/Control/UIRichEdit.h
index 5ac653bf..762e53f6 100644
--- a/DuiLib/Control/UIRichEdit.h
+++ b/DuiLib/Control/UIRichEdit.h
@@ -106,7 +106,7 @@ class UILIB_API CRichEditUI : public CContainerUI, public IMessageFilterUI
virtual bool OnTxViewChanged();
virtual void OnTxNotify(DWORD iNotify, void *pv);
- void SetScrollPos(SIZE szPos);
+ void SetScrollPos(SIZE szPos, bool bMsg = true);
void LineUp();
void LineDown();
void PageUp();
@@ -121,7 +121,7 @@ class UILIB_API CRichEditUI : public CContainerUI, public IMessageFilterUI
void EndRight();
SIZE EstimateSize(SIZE szAvailable);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void DoEvent(TEventUI& event);
void DoPaint(HDC hDC, const RECT& rcPaint);
diff --git a/DuiLib/Control/UIScrollBar.cpp b/DuiLib/Control/UIScrollBar.cpp
index 912e36c2..11d28d19 100644
--- a/DuiLib/Control/UIScrollBar.cpp
+++ b/DuiLib/Control/UIScrollBar.cpp
@@ -369,9 +369,9 @@ namespace DuiLib
Invalidate();
}
- void CScrollBarUI::SetPos(RECT rc)
+ void CScrollBarUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
rc = m_rcItem;
if( m_bHorizontal ) {
diff --git a/DuiLib/Control/UIScrollBar.h b/DuiLib/Control/UIScrollBar.h
index 8d8ae500..e4959525 100644
--- a/DuiLib/Control/UIScrollBar.h
+++ b/DuiLib/Control/UIScrollBar.h
@@ -78,7 +78,7 @@ namespace DuiLib
LPCTSTR GetBkDisabledImage();
void SetBkDisabledImage(LPCTSTR pStrImage);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void DoEvent(TEventUI& event);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
diff --git a/DuiLib/Control/UITreeView.cpp b/DuiLib/Control/UITreeView.cpp
index 63f3b019..771da2b4 100644
--- a/DuiLib/Control/UITreeView.cpp
+++ b/DuiLib/Control/UITreeView.cpp
@@ -633,6 +633,7 @@ namespace DuiLib
pControl->OnNotify += MakeDelegate(this,&CTreeViewUI::OnDBClickItem);
pControl->GetFolderButton()->OnNotify += MakeDelegate(this,&CTreeViewUI::OnFolderChanged);
pControl->GetCheckBox()->OnNotify += MakeDelegate(this,&CTreeViewUI::OnCheckBoxChanged);
+ pControl->GetCheckBox()->OnNotify += MakeDelegate(this,&CTreeViewUI::OnCheckBoxChanged);
pControl->SetVisibleCheckBtn(m_bVisibleCheckBtn);
pControl->SetVisibleFolderBtn(false);
diff --git a/DuiLib/Core/UIContainer.cpp b/DuiLib/Core/UIContainer.cpp
index 5761a62b..24a95789 100644
--- a/DuiLib/Core/UIContainer.cpp
+++ b/DuiLib/Core/UIContainer.cpp
@@ -249,35 +249,35 @@ namespace DuiLib
if( event.Type == UIEVENT_KEYDOWN )
{
switch( event.chKey ) {
- case VK_DOWN:
- LineDown();
- return;
- case VK_UP:
- LineUp();
- return;
- case VK_NEXT:
- PageDown();
- return;
- case VK_PRIOR:
- PageUp();
- return;
- case VK_HOME:
- HomeUp();
- return;
- case VK_END:
- EndDown();
- return;
+ case VK_DOWN:
+ LineDown();
+ return;
+ case VK_UP:
+ LineUp();
+ return;
+ case VK_NEXT:
+ PageDown();
+ return;
+ case VK_PRIOR:
+ PageUp();
+ return;
+ case VK_HOME:
+ HomeUp();
+ return;
+ case VK_END:
+ EndDown();
+ return;
}
}
else if( event.Type == UIEVENT_SCROLLWHEEL )
{
switch( LOWORD(event.wParam) ) {
- case SB_LINEUP:
- LineUp();
- return;
- case SB_LINEDOWN:
- LineDown();
- return;
+ case SB_LINEUP:
+ LineUp();
+ return;
+ case SB_LINEDOWN:
+ LineDown();
+ return;
}
}
}
@@ -285,35 +285,35 @@ namespace DuiLib
if( event.Type == UIEVENT_KEYDOWN )
{
switch( event.chKey ) {
- case VK_DOWN:
- LineRight();
- return;
- case VK_UP:
- LineLeft();
- return;
- case VK_NEXT:
- PageRight();
- return;
- case VK_PRIOR:
- PageLeft();
- return;
- case VK_HOME:
- HomeLeft();
- return;
- case VK_END:
- EndRight();
- return;
+ case VK_DOWN:
+ LineRight();
+ return;
+ case VK_UP:
+ LineLeft();
+ return;
+ case VK_NEXT:
+ PageRight();
+ return;
+ case VK_PRIOR:
+ PageLeft();
+ return;
+ case VK_HOME:
+ HomeLeft();
+ return;
+ case VK_END:
+ EndRight();
+ return;
}
}
else if( event.Type == UIEVENT_SCROLLWHEEL )
{
switch( LOWORD(event.wParam) ) {
- case SB_LINEUP:
- LineLeft();
- return;
- case SB_LINEDOWN:
- LineRight();
- return;
+ case SB_LINEUP:
+ LineLeft();
+ return;
+ case SB_LINEDOWN:
+ LineRight();
+ return;
}
}
}
@@ -370,10 +370,13 @@ namespace DuiLib
Invalidate();
- // 发送滚动消息
- if( m_pManager != NULL && bMsg ) {
- int nPage = (m_pVerticalScrollBar->GetScrollPos() + m_pVerticalScrollBar->GetLineSize()) / m_pVerticalScrollBar->GetLineSize();
- m_pManager->SendNotify(this, DUI_MSGTYPE_SCROLL, (WPARAM)nPage);
+ if(m_pVerticalScrollBar)
+ {
+ // 发送滚动消息
+ if( m_pManager != NULL && bMsg ) {
+ int nPage = (m_pVerticalScrollBar->GetScrollPos() + m_pVerticalScrollBar->GetLineSize()) / m_pVerticalScrollBar->GetLineSize();
+ m_pManager->SendNotify(this, DUI_MSGTYPE_SCROLL, (WPARAM)nPage);
+ }
}
}
@@ -396,7 +399,7 @@ namespace DuiLib
cyLine = 8;
if( m_pManager ) cyLine = m_pManager->GetDefaultFontInfo()->tm.tmHeight + 8;
}
-
+
SIZE sz = GetScrollPos();
sz.cy -= cyLine;
SetScrollPos(sz);
@@ -571,9 +574,9 @@ namespace DuiLib
}
}
- void CContainerUI::SetPos(RECT rc)
+ void CContainerUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
if( m_items.IsEmpty() ) return;
rc.left += m_rcInset.left;
rc.top += m_rcInset.top;
@@ -768,39 +771,15 @@ namespace DuiLib
SIZE szXY = pControl->GetFixedXY();
SIZE sz = {pControl->GetFixedWidth(), pControl->GetFixedHeight()};
+ TPercentInfo rcPercent = pControl->GetFloatPercent();
+ LONG width = m_rcItem.right - m_rcItem.left;
+ LONG height = m_rcItem.bottom - m_rcItem.top;
RECT rcCtrl = { 0 };
- if( szXY.cx >= 0 ) {
- rcCtrl.left = m_rcItem.left + szXY.cx;
- rcCtrl.right = m_rcItem.left + szXY.cx + sz.cx;
- }
- else {
- rcCtrl.left = m_rcItem.right + szXY.cx - sz.cx;
- rcCtrl.right = m_rcItem.right + szXY.cx;
- }
- if( szXY.cy >= 0 ) {
- rcCtrl.top = m_rcItem.top + szXY.cy;
- rcCtrl.bottom = m_rcItem.top + szXY.cy + sz.cy;
- }
- else {
- rcCtrl.top = m_rcItem.bottom + szXY.cy - sz.cy;
- rcCtrl.bottom = m_rcItem.bottom + szXY.cy;
- }
- if( pControl->IsRelativePos() )
- {
- TRelativePosUI tRelativePos = pControl->GetRelativePos();
- SIZE szParent = {m_rcItem.right-m_rcItem.left,m_rcItem.bottom-m_rcItem.top};
- if(tRelativePos.szParent.cx != 0)
- {
- int nIncrementX = szParent.cx-tRelativePos.szParent.cx;
- int nIncrementY = szParent.cy-tRelativePos.szParent.cy;
- rcCtrl.left += (nIncrementX*tRelativePos.nMoveXPercent/100);
- rcCtrl.top += (nIncrementY*tRelativePos.nMoveYPercent/100);
- rcCtrl.right = rcCtrl.left+sz.cx+(nIncrementX*tRelativePos.nZoomXPercent/100);
- rcCtrl.bottom = rcCtrl.top+sz.cy+(nIncrementY*tRelativePos.nZoomYPercent/100);
- }
- pControl->SetRelativeParentSize(szParent);
- }
- pControl->SetPos(rcCtrl);
+ rcCtrl.left = (LONG)(width*rcPercent.left) + szXY.cx;
+ rcCtrl.top = (LONG)(height*rcPercent.top) + szXY.cy;
+ rcCtrl.right = (LONG)(width*rcPercent.right) + szXY.cx + sz.cx;
+ rcCtrl.bottom = (LONG)(height*rcPercent.bottom) + szXY.cy + sz.cy;
+ pControl->SetPos(rcCtrl, false);
}
void CContainerUI::ProcessScrollBar(RECT rc, int cxRequired, int cyRequired)
@@ -814,7 +793,7 @@ namespace DuiLib
if( cyRequired > rc.bottom - rc.top && !m_pVerticalScrollBar->IsVisible() ) {
m_pVerticalScrollBar->SetVisible(true);
- m_pVerticalScrollBar->SetScrollRange(cyRequired - (rc.bottom - rc.top));
+ m_pVerticalScrollBar->SetScrollRange(cyRequired - (rc.bottom - rc.top));
m_pVerticalScrollBar->SetScrollPos(0);
m_bScrollProcess = true;
SetPos(m_rcItem);
diff --git a/DuiLib/Core/UIContainer.h b/DuiLib/Core/UIContainer.h
index 211b800d..454198c0 100644
--- a/DuiLib/Core/UIContainer.h
+++ b/DuiLib/Core/UIContainer.h
@@ -65,7 +65,7 @@ class UILIB_API CContainerUI : public CControlUI, public IContainerUI
virtual int FindSelectable(int iIndex, bool bForward = true) const;
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void DoPaint(HDC hDC, const RECT& rcPaint);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
diff --git a/DuiLib/Core/UIControl.cpp b/DuiLib/Core/UIControl.cpp
index 81b9abd2..ca8ab8a8 100644
--- a/DuiLib/Core/UIControl.cpp
+++ b/DuiLib/Core/UIControl.cpp
@@ -37,7 +37,8 @@ m_nTooltipWidth(300)
::ZeroMemory(&m_rcItem, sizeof(RECT));
::ZeroMemory(&m_rcPaint, sizeof(RECT));
::ZeroMemory(&m_rcBorderSize,sizeof(RECT));
- ::ZeroMemory(&m_tRelativePos, sizeof(TRelativePosUI));
+ m_piFloatPercent.left = m_piFloatPercent.top = m_piFloatPercent.right = m_piFloatPercent.bottom = 0.0f;
+
}
CControlUI::~CControlUI()
@@ -240,7 +241,7 @@ const RECT& CControlUI::GetPos() const
return m_rcItem;
}
-void CControlUI::SetPos(RECT rc)
+void CControlUI::SetPos(RECT rc, bool bNeedInvalidate)
{
if( rc.right < rc.left ) rc.right = rc.left;
if( rc.bottom < rc.top ) rc.bottom = rc.top;
@@ -248,7 +249,27 @@ void CControlUI::SetPos(RECT rc)
CDuiRect invalidateRc = m_rcItem;
if( ::IsRectEmpty(&invalidateRc) ) invalidateRc = rc;
- m_rcItem = rc;
+ if( m_bFloat ) {
+ CControlUI* pParent = GetParent();
+ if( pParent != NULL ) {
+ RECT rcParentPos = pParent->GetPos();
+ RECT rcCtrl = {rcParentPos.left + rc.left, rcParentPos.top + rc.top,
+ rcParentPos.left + rc.right, rcParentPos.top + rc.bottom};
+ m_rcItem = rcCtrl;
+
+ LONG width = rcParentPos.right - rcParentPos.left;
+ LONG height = rcParentPos.bottom - rcParentPos.top;
+ RECT rcPercent = {(LONG)(width*m_piFloatPercent.left), (LONG)(height*m_piFloatPercent.top),
+ (LONG)(width*m_piFloatPercent.right), (LONG)(height*m_piFloatPercent.bottom)};
+ m_cXY.cx = rc.left - rcPercent.left;
+ m_cXY.cy = rc.top - rcPercent.top;
+ m_cxyFixed.cx = rc.right - rcPercent.right - m_cXY.cx;
+ m_cxyFixed.cy = rc.bottom - rcPercent.bottom - m_cXY.cy;
+ }
+ }
+ else {
+ m_rcItem = rc;
+ }
if( m_pManager == NULL ) return;
if( !m_bSetPos ) {
@@ -257,35 +278,21 @@ void CControlUI::SetPos(RECT rc)
m_bSetPos = false;
}
- if( m_bFloat ) {
- CControlUI* pParent = GetParent();
- if( pParent != NULL ) {
- RECT rcParentPos = pParent->GetPos();
- if( m_cXY.cx >= 0 ) m_cXY.cx = m_rcItem.left - rcParentPos.left;
- else m_cXY.cx = m_rcItem.right - rcParentPos.right;
- if( m_cXY.cy >= 0 ) m_cXY.cy = m_rcItem.top - rcParentPos.top;
- else m_cXY.cy = m_rcItem.bottom - rcParentPos.bottom;
- m_cxyFixed.cx = m_rcItem.right - m_rcItem.left;
- m_cxyFixed.cy = m_rcItem.bottom - m_rcItem.top;
- }
- }
-
m_bUpdateNeeded = false;
- invalidateRc.Join(m_rcItem);
- CControlUI* pParent = this;
- RECT rcTemp;
- RECT rcParent;
- while( pParent = pParent->GetParent() )
- {
- rcTemp = invalidateRc;
- rcParent = pParent->GetPos();
- if( !::IntersectRect(&invalidateRc, &rcTemp, &rcParent) )
- {
- return;
- }
- }
- m_pManager->Invalidate(invalidateRc);
+ if( bNeedInvalidate && IsVisible() ) {
+ invalidateRc.Join(m_rcItem);
+ CControlUI* pParent = this;
+ RECT rcTemp;
+ RECT rcParent;
+ while( pParent = pParent->GetParent() ) {
+ if( !pParent->IsVisible() ) return;
+ rcTemp = invalidateRc;
+ rcParent = pParent->GetPos();
+ if( !::IntersectRect(&invalidateRc, &rcTemp, &rcParent) ) return;
+ }
+ m_pManager->Invalidate(invalidateRc);
+ }
}
int CControlUI::GetWidth() const
@@ -418,29 +425,17 @@ void CControlUI::SetMaxHeight(int cy)
else NeedUpdate();
}
-void CControlUI::SetRelativePos(SIZE szMove,SIZE szZoom)
+TPercentInfo CControlUI::GetFloatPercent() const
{
- m_tRelativePos.bRelative = TRUE;
- m_tRelativePos.nMoveXPercent = szMove.cx;
- m_tRelativePos.nMoveYPercent = szMove.cy;
- m_tRelativePos.nZoomXPercent = szZoom.cx;
- m_tRelativePos.nZoomYPercent = szZoom.cy;
+ return m_piFloatPercent;
}
-void CControlUI::SetRelativeParentSize(SIZE sz)
+void CControlUI::SetFloatPercent(TPercentInfo piFloatPercent)
{
- m_tRelativePos.szParent = sz;
+ m_piFloatPercent = piFloatPercent;
+ NeedParentUpdate();
}
-TRelativePosUI CControlUI::GetRelativePos() const
-{
- return m_tRelativePos;
-}
-
-bool CControlUI::IsRelativePos() const
-{
- return m_tRelativePos.bRelative;
-}
CDuiString CControlUI::GetToolTip() const
{
@@ -743,15 +738,22 @@ void CControlUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
SetFixedWidth(rcPos.right - rcPos.left);
SetFixedHeight(rcPos.bottom - rcPos.top);
}
- else if( _tcscmp(pstrName, _T("relativepos")) == 0 ) {
- SIZE szMove,szZoom;
- LPTSTR pstr = NULL;
- szMove.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr);
- szMove.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);
- szZoom.cx = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);
- szZoom.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr);
- SetRelativePos(szMove,szZoom);
- }
+ else if( _tcscmp(pstrName, _T("float")) == 0 ) {
+ CDuiString nValue = pstrValue;
+ if(nValue.Find(',') < 0) {
+ SetFloat(_tcscmp(pstrValue, _T("true")) == 0);
+ }
+ else {
+ TPercentInfo piFloatPercent = { 0 };
+ LPTSTR pstr = NULL;
+ piFloatPercent.left = _tcstod(pstrValue, &pstr); ASSERT(pstr);
+ piFloatPercent.top = _tcstod(pstr + 1, &pstr); ASSERT(pstr);
+ piFloatPercent.right = _tcstod(pstr + 1, &pstr); ASSERT(pstr);
+ piFloatPercent.bottom = _tcstod(pstr + 1, &pstr); ASSERT(pstr);
+ SetFloatPercent(piFloatPercent);
+ SetFloat(true);
+ }
+ }
else if( _tcscmp(pstrName, _T("padding")) == 0 ) {
RECT rcPadding = { 0 };
LPTSTR pstr = NULL;
diff --git a/DuiLib/Core/UIControl.h b/DuiLib/Core/UIControl.h
index a3fe6b71..80e47856 100644
--- a/DuiLib/Core/UIControl.h
+++ b/DuiLib/Core/UIControl.h
@@ -69,7 +69,7 @@ class UILIB_API CControlUI
// 位置相关
virtual const RECT& GetPos() const;
- virtual void SetPos(RECT rc);
+ virtual void SetPos(RECT rc, bool bNeedInvalidate = true);
virtual int GetWidth() const;
virtual int GetHeight() const;
virtual int GetX() const;
@@ -90,10 +90,8 @@ class UILIB_API CControlUI
virtual void SetMinHeight(int cy);
virtual int GetMaxHeight() const;
virtual void SetMaxHeight(int cy);
- virtual void SetRelativePos(SIZE szMove,SIZE szZoom);
- virtual void SetRelativeParentSize(SIZE sz);
- virtual TRelativePosUI GetRelativePos() const;
- virtual bool IsRelativePos() const;
+ virtual TPercentInfo GetFloatPercent() const;
+ virtual void SetFloatPercent(TPercentInfo piFloatPercent);
// 鼠标提示
virtual CDuiString GetToolTip() const;
@@ -189,8 +187,8 @@ class UILIB_API CControlUI
bool m_bKeyboardEnabled ;
bool m_bFocused;
bool m_bFloat;
+ TPercentInfo m_piFloatPercent;
bool m_bSetPos; // 防止SetPos循环调用
- TRelativePosUI m_tRelativePos;
CDuiString m_sText;
CDuiString m_sToolTip;
diff --git a/DuiLib/Core/UIManager.h b/DuiLib/Core/UIManager.h
index 965ae490..42bc3bd0 100644
--- a/DuiLib/Core/UIManager.h
+++ b/DuiLib/Core/UIManager.h
@@ -82,7 +82,7 @@ typedef enum EVENTTYPE_UI
/////////////////////////////////////////////////////////////////////////////////////
//
-typedef struct tagTFontInfo
+typedef struct UILIB_API tagTFontInfo
{
HFONT hFont;
CDuiString sFontName;
@@ -93,19 +93,62 @@ typedef struct tagTFontInfo
TEXTMETRIC tm;
} TFontInfo;
-typedef struct tagTImageInfo
+typedef struct UILIB_API tagTImageInfo
{
HBITMAP hBitmap;
+ LPBYTE pBits;
+ LPBYTE pSrcBits;
int nX;
int nY;
bool alphaChannel;
+ bool bUseHSL;
CDuiString sResType;
DWORD dwMask;
} TImageInfo;
+typedef struct UILIB_API tagTDrawInfo
+{
+ tagTDrawInfo();
+ tagTDrawInfo(LPCTSTR lpsz);
+ void Clear();
+ CDuiString sDrawString;
+ bool bLoaded;
+ CDuiString sImageName;
+ const TImageInfo* pImageInfo;
+ RECT rcDestOffset;
+ RECT rcBmpPart;
+ RECT rcCorner;
+ BYTE uFade;
+ bool bHole;
+ bool bTiledX;
+ bool bTiledY;
+} TDrawInfo;
+
+typedef struct UILIB_API tagTPercentInfo
+{
+ double left;
+ double top;
+ double right;
+ double bottom;
+} TPercentInfo;
+
+typedef struct UILIB_API tagTResInfo
+{
+ DWORD m_dwDefaultDisabledColor;
+ DWORD m_dwDefaultFontColor;
+ DWORD m_dwDefaultLinkFontColor;
+ DWORD m_dwDefaultLinkHoverFontColor;
+ DWORD m_dwDefaultSelectedBkColor;
+ TFontInfo m_DefaultFontInfo;
+ CStdStringPtrMap m_CustomFonts;
+ CStdStringPtrMap m_ImageHash;
+ CStdStringPtrMap m_AttrHash;
+ CStdStringPtrMap m_MultiLanguageHash;
+} TResInfo;
+
// Structure for notifications from the system
// to the control implementation.
-typedef struct tagTEventUI
+typedef struct UILIB_API tagTEventUI
{
int Type;
CControlUI* pSender;
@@ -117,16 +160,6 @@ typedef struct tagTEventUI
LPARAM lParam;
} TEventUI;
-// Structure for relative position to the parent
-typedef struct tagTRelativePosUI
-{
- bool bRelative;
- SIZE szParent;
- int nMoveXPercent;
- int nMoveYPercent;
- int nZoomXPercent;
- int nZoomYPercent;
-}TRelativePosUI;
// Listener interface
class INotifyUI
diff --git a/DuiLib/Layout/UIHorizontalLayout.cpp b/DuiLib/Layout/UIHorizontalLayout.cpp
index 619f2f70..0a2ca548 100644
--- a/DuiLib/Layout/UIHorizontalLayout.cpp
+++ b/DuiLib/Layout/UIHorizontalLayout.cpp
@@ -26,9 +26,9 @@ namespace DuiLib
else return 0;
}
- void CHorizontalLayoutUI::SetPos(RECT rc)
+ void CHorizontalLayoutUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
rc = m_rcItem;
// Adjust for inset
diff --git a/DuiLib/Layout/UIHorizontalLayout.h b/DuiLib/Layout/UIHorizontalLayout.h
index 067d3f90..d8243474 100644
--- a/DuiLib/Layout/UIHorizontalLayout.h
+++ b/DuiLib/Layout/UIHorizontalLayout.h
@@ -21,7 +21,7 @@ namespace DuiLib
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
void DoEvent(TEventUI& event);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void DoPostPaint(HDC hDC, const RECT& rcPaint);
RECT GetThumbRect(bool bUseNew = false) const;
diff --git a/DuiLib/Layout/UITabLayout.cpp b/DuiLib/Layout/UITabLayout.cpp
index 9df66265..931e811f 100644
--- a/DuiLib/Layout/UITabLayout.cpp
+++ b/DuiLib/Layout/UITabLayout.cpp
@@ -135,9 +135,9 @@ namespace DuiLib
return CContainerUI::SetAttribute(pstrName, pstrValue);
}
- void CTabLayoutUI::SetPos(RECT rc)
+ void CTabLayoutUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
rc = m_rcItem;
// Adjust for inset
diff --git a/DuiLib/Layout/UITabLayout.h b/DuiLib/Layout/UITabLayout.h
index 964006cd..7ed56fee 100644
--- a/DuiLib/Layout/UITabLayout.h
+++ b/DuiLib/Layout/UITabLayout.h
@@ -21,7 +21,7 @@ namespace DuiLib
virtual bool SelectItem(int iIndex);
virtual bool SelectItem(CControlUI* pControl);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
diff --git a/DuiLib/Layout/UITileLayout.cpp b/DuiLib/Layout/UITileLayout.cpp
index ed514695..a16cbef8 100644
--- a/DuiLib/Layout/UITileLayout.cpp
+++ b/DuiLib/Layout/UITileLayout.cpp
@@ -57,9 +57,9 @@ namespace DuiLib
else CContainerUI::SetAttribute(pstrName, pstrValue);
}
- void CTileLayoutUI::SetPos(RECT rc)
+ void CTileLayoutUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
rc = m_rcItem;
// Adjust for inset
diff --git a/DuiLib/Layout/UITileLayout.h b/DuiLib/Layout/UITileLayout.h
index 96c82286..a726971d 100644
--- a/DuiLib/Layout/UITileLayout.h
+++ b/DuiLib/Layout/UITileLayout.h
@@ -13,7 +13,7 @@ namespace DuiLib
LPCTSTR GetClass() const;
LPVOID GetInterface(LPCTSTR pstrName);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
SIZE GetItemSize() const;
void SetItemSize(SIZE szItem);
diff --git a/DuiLib/Layout/UIVerticalLayout.cpp b/DuiLib/Layout/UIVerticalLayout.cpp
index af52d261..3463af31 100644
--- a/DuiLib/Layout/UIVerticalLayout.cpp
+++ b/DuiLib/Layout/UIVerticalLayout.cpp
@@ -26,9 +26,9 @@ namespace DuiLib
else return 0;
}
- void CVerticalLayoutUI::SetPos(RECT rc)
+ void CVerticalLayoutUI::SetPos(RECT rc, bool bNeedInvalidate)
{
- CControlUI::SetPos(rc);
+ CControlUI::SetPos(rc, bNeedInvalidate);
rc = m_rcItem;
// Adjust for inset
diff --git a/DuiLib/Layout/UIVerticalLayout.h b/DuiLib/Layout/UIVerticalLayout.h
index d29b26ab..729cd228 100644
--- a/DuiLib/Layout/UIVerticalLayout.h
+++ b/DuiLib/Layout/UIVerticalLayout.h
@@ -21,7 +21,7 @@ namespace DuiLib
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
void DoEvent(TEventUI& event);
- void SetPos(RECT rc);
+ void SetPos(RECT rc, bool bNeedInvalidate = true);
void DoPostPaint(HDC hDC, const RECT& rcPaint);
RECT GetThumbRect(bool bUseNew = false) const;
diff --git a/bin/skin/bdwallpaper/main.xml b/bin/skin/bdwallpaper/main.xml
index f41e3ded..9fe4aa6d 100644
--- a/bin/skin/bdwallpaper/main.xml
+++ b/bin/skin/bdwallpaper/main.xml
@@ -20,7 +20,7 @@
-
+
diff --git a/bin/skin/duidemo/main.xml b/bin/skin/duidemo/main.xml
index e27ab09b..6400687e 100644
--- a/bin/skin/duidemo/main.xml
+++ b/bin/skin/duidemo/main.xml
@@ -125,7 +125,7 @@
-
+