Skip to content

Commit

Permalink
调整SetPos函数
Browse files Browse the repository at this point in the history
  • Loading branch information
Troy committed Jun 17, 2015
1 parent 04fdeb9 commit 2d5a713
Show file tree
Hide file tree
Showing 33 changed files with 242 additions and 222 deletions.
2 changes: 1 addition & 1 deletion Demos/bdwallpaper/BDWallPaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion Demos/bdwallpaper/MainWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ DuiLib::CDuiString CMainWnd::GetSkinFolder()
#ifdef _DEBUG
return _T("skin\\BDWallPaper\\");
#else
return _T("skin\\");
return _T("skin\\BDWallPaper\\");
#endif
}

Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions Demos/bdwallpaper/MainWnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions Demos/bdwallpaper/controlex/UIWPPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions Demos/duidemo/duidemo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@
<ItemGroup>
<ResourceCompile Include="duidemo.rc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DuiLib\DuiLib.vcxproj">
<Project>{e106acd7-4e53-4aee-942b-d0dd426db34e}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
4 changes: 2 additions & 2 deletions DuiLib/Control/UIActiveX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Control/UIActiveX.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions DuiLib/Control/UICombo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CControlUI*>(m_items[i])->SetPos(rcNull);
// Position this control
CControlUI::SetPos(rc);
CControlUI::SetPos(rc, bNeedInvalidate);
}

void CComboUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Control/UICombo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions DuiLib/Control/UIEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Control/UIEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions DuiLib/Control/UIList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<CListUI*>(m_pOwner);
Expand Down
8 changes: 4 additions & 4 deletions DuiLib/Control/UIList.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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:
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 4 additions & 14 deletions DuiLib/Control/UIRichEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() ) {
Expand All @@ -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();
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions DuiLib/Control/UIRichEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions DuiLib/Control/UIScrollBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Control/UIScrollBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions DuiLib/Control/UITreeView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 2d5a713

Please sign in to comment.