Skip to content

Commit

Permalink
修正edit透明背景的重复绘制bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wangchyz committed Feb 17, 2016
1 parent bc00467 commit 10962b0
Show file tree
Hide file tree
Showing 21 changed files with 83 additions and 61 deletions.
4 changes: 1 addition & 3 deletions DuiLib/Control/UIActiveX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,8 @@ void CActiveXUI::Move(SIZE szOffset, bool bNeedInvalidate)
}
}

void CActiveXUI::DoPaint(HDC hDC, const RECT& rcPaint)
void CActiveXUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return;

if( m_pControl != NULL && m_pControl->m_bWindowless && m_pControl->m_pViewObject != NULL )
{
m_pControl->m_pViewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL, hDC, (RECTL*) &m_rcItem, (RECTL*) &m_rcItem, NULL, NULL);
Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Control/UIActiveX.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class UILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI
void SetInternVisible(bool bVisible = true);
void SetPos(RECT rc, bool bNeedInvalidate = true);
void Move(SIZE szOffset, bool bNeedInvalidate = true);
void DoPaint(HDC hDC, const RECT& rcPaint);
void DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);

void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);

Expand Down
6 changes: 3 additions & 3 deletions DuiLib/Control/UICombo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,9 +958,9 @@ void CComboUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
else CContainerUI::SetAttribute(pstrName, pstrValue);
}

void CComboUI::DoPaint(HDC hDC, const RECT& rcPaint)
void CComboUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
CControlUI::DoPaint(hDC, rcPaint);
CControlUI::DoPaint(hDC, rcPaint, pStopControl);
}

void CComboUI::PaintStatusImage(HDC hDC)
Expand Down Expand Up @@ -1005,7 +1005,7 @@ void CComboUI::PaintText(HDC hDC)
else {
RECT rcOldPos = pControl->GetPos();
pControl->SetPos(rcText, false);
pControl->Paint(hDC, rcText);
pControl->Paint(hDC, rcText, NULL);
pControl->SetPos(rcOldPos, false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Control/UICombo.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class UILIB_API CComboUI : public CContainerUI, public IListOwnerUI
void DoEvent(TEventUI& event);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);

void DoPaint(HDC hDC, const RECT& rcPaint);
void DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
void PaintText(HDC hDC);
void PaintStatusImage(HDC hDC);

Expand Down
3 changes: 2 additions & 1 deletion DuiLib/Control/UIEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace DuiLib
if (clrColor < 0xFF000000) {
if (m_hBkBrush != NULL) ::DeleteObject(m_hBkBrush);
RECT rcWnd = m_pOwner->GetManager()->GetNativeWindowRect(m_hWnd);
HBITMAP hBmpEditBk = CRenderEngine::GenerateBitmap(m_pOwner->GetManager(), rcWnd, clrColor);
HBITMAP hBmpEditBk = CRenderEngine::GenerateBitmap(m_pOwner->GetManager(), rcWnd, m_pOwner, clrColor);
m_hBkBrush = ::CreatePatternBrush(hBmpEditBk);
::DeleteObject(hBmpEditBk);
}
Expand Down Expand Up @@ -320,6 +320,7 @@ namespace DuiLib
POINT pt = event.ptMouse;
pt.x -= m_rcItem.left + m_rcTextPadding.left;
pt.y -= m_rcItem.top + m_rcTextPadding.top;
Edit_SetSel(*m_pWindow, 0, 0);
::SendMessage(*m_pWindow, WM_LBUTTONDOWN, event.wParam, MAKELPARAM(pt.x, pt.y));
}
}
Expand Down
3 changes: 1 addition & 2 deletions DuiLib/Control/UIGifAnim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ namespace DuiLib
InitGifImage();
}

void CGifAnimUI::DoPaint( HDC hDC, const RECT& rcPaint )
void CGifAnimUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
if( !::IntersectRect( &m_rcPaint, &rcPaint, &m_rcItem ) ) return;
if ( NULL == m_pGifImage )
{
InitGifImage();
Expand Down
8 changes: 4 additions & 4 deletions DuiLib/Control/UIGifAnim.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace DuiLib
LPCTSTR GetClass() const;
LPVOID GetInterface(LPCTSTR pstrName);
void DoInit() override;
void DoPaint(HDC hDC, const RECT& rcPaint) override;
void DoEvent(TEventUI& event) override;
void SetVisible(bool bVisible = true ) override;
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) override;
void DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
void DoEvent(TEventUI& event);
void SetVisible(bool bVisible = true );
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
void SetBkImage(LPCTSTR pStrImage);
LPCTSTR GetBkImage();

Expand Down
8 changes: 3 additions & 5 deletions DuiLib/Control/UIList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1895,9 +1895,8 @@ SIZE CListLabelElementUI::EstimateSize(SIZE szAvailable)
return cXY;
}

void CListLabelElementUI::DoPaint(HDC hDC, const RECT& rcPaint)
void CListLabelElementUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return;
DrawItemBk(hDC, m_rcItem);
DrawItemText(hDC, m_rcItem);
}
Expand Down Expand Up @@ -2333,11 +2332,10 @@ void CListContainerElementUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
else CContainerUI::SetAttribute(pstrName, pstrValue);
}

void CListContainerElementUI::DoPaint(HDC hDC, const RECT& rcPaint)
void CListContainerElementUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return;
DrawItemBk(hDC, m_rcItem);
CContainerUI::DoPaint(hDC, rcPaint);
CContainerUI::DoPaint(hDC, rcPaint, pStopControl);
}

void CListContainerElementUI::DrawItemText(HDC hDC, const RECT& rcItem)
Expand Down
4 changes: 2 additions & 2 deletions DuiLib/Control/UIList.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class UILIB_API CListLabelElementUI : public CListElementUI

void DoEvent(TEventUI& event);
SIZE EstimateSize(SIZE szAvailable);
void DoPaint(HDC hDC, const RECT& rcPaint);
void DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);

void DrawItemText(HDC hDC, const RECT& rcItem);
};
Expand Down Expand Up @@ -427,7 +427,7 @@ class UILIB_API CListContainerElementUI : public CContainerUI, public IListItemU

void DoEvent(TEventUI& event);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
void DoPaint(HDC hDC, const RECT& rcPaint);
void DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);

void DrawItemText(HDC hDC, const RECT& rcItem);
void DrawItemBk(HDC hDC, const RECT& rcItem);
Expand Down
20 changes: 11 additions & 9 deletions DuiLib/Control/UIRichEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2088,14 +2088,14 @@ void CRichEditUI::Move(SIZE szOffset, bool bNeedInvalidate)
}
}

void CRichEditUI::DoPaint(HDC hDC, const RECT& rcPaint)
void CRichEditUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
RECT rcTemp = { 0 };
if( !::IntersectRect(&rcTemp, &rcPaint, &m_rcItem) ) return;

CRenderClip clip;
CRenderClip::GenerateClip(hDC, rcTemp, clip);
CControlUI::DoPaint(hDC, rcPaint);
CControlUI::DoPaint(hDC, rcPaint, pStopControl);

if( m_pTwh ) {
RECT rc;
Expand Down Expand Up @@ -2146,11 +2146,12 @@ void CRichEditUI::DoPaint(HDC hDC, const RECT& rcPaint)
if( !::IntersectRect(&rcTemp, &rcPaint, &rc) ) {
for( int it = 0; it < m_items.GetSize(); it++ ) {
CControlUI* pControl = static_cast<CControlUI*>(m_items[it]);
if( pControl == pStopControl ) break;
if( !pControl->IsVisible() ) continue;
if( !::IntersectRect(&rcTemp, &rcPaint, &pControl->GetPos()) ) continue;
if( pControl ->IsFloat() ) {
if( pControl->IsFloat() ) {
if( !::IntersectRect(&rcTemp, &m_rcItem, &pControl->GetPos()) ) continue;
pControl->Paint(hDC, rcPaint);
pControl->Paint(hDC, rcPaint, pStopControl);
}
}
}
Expand All @@ -2159,17 +2160,18 @@ void CRichEditUI::DoPaint(HDC hDC, const RECT& rcPaint)
CRenderClip::GenerateClip(hDC, rcTemp, childClip);
for( int it = 0; it < m_items.GetSize(); it++ ) {
CControlUI* pControl = static_cast<CControlUI*>(m_items[it]);
if( pControl == pStopControl ) break;
if( !pControl->IsVisible() ) continue;
if( !::IntersectRect(&rcTemp, &rcPaint, &pControl->GetPos()) ) continue;
if( pControl ->IsFloat() ) {
if( pControl->IsFloat() ) {
if( !::IntersectRect(&rcTemp, &m_rcItem, &pControl->GetPos()) ) continue;
CRenderClip::UseOldClipBegin(hDC, childClip);
pControl->Paint(hDC, rcPaint);
pControl->Paint(hDC, rcPaint, pStopControl);
CRenderClip::UseOldClipEnd(hDC, childClip);
}
else {
if( !::IntersectRect(&rcTemp, &rc, &pControl->GetPos()) ) continue;
pControl->Paint(hDC, rcPaint);
pControl->Paint(hDC, rcPaint, pStopControl);
}
}
}
Expand All @@ -2186,13 +2188,13 @@ void CRichEditUI::DoPaint(HDC hDC, const RECT& rcPaint)

if( m_pVerticalScrollBar != NULL && m_pVerticalScrollBar->IsVisible() ) {
if( ::IntersectRect(&rcTemp, &rcPaint, &m_pVerticalScrollBar->GetPos()) ) {
m_pVerticalScrollBar->Paint(hDC, rcPaint);
m_pVerticalScrollBar->Paint(hDC, rcPaint, pStopControl);
}
}

if( m_pHorizontalScrollBar != NULL && m_pHorizontalScrollBar->IsVisible() ) {
if( ::IntersectRect(&rcTemp, &rcPaint, &m_pHorizontalScrollBar->GetPos()) ) {
m_pHorizontalScrollBar->Paint(hDC, rcPaint);
m_pHorizontalScrollBar->Paint(hDC, rcPaint, pStopControl);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Control/UIRichEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class UILIB_API CRichEditUI : public CContainerUI, public IMessageFilterUI
void SetPos(RECT rc, bool bNeedInvalidate = true);
void Move(SIZE szOffset, bool bNeedInvalidate = true);
void DoEvent(TEventUI& event);
void DoPaint(HDC hDC, const RECT& rcPaint);
void DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);

void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);

Expand Down
3 changes: 1 addition & 2 deletions DuiLib/Control/UIScrollBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -892,9 +892,8 @@ void CScrollBarUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue)
else CControlUI::SetAttribute(pstrName, pstrValue);
}

void CScrollBarUI::DoPaint(HDC hDC, const RECT& rcPaint)
void CScrollBarUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return;
PaintBkColor(hDC);
PaintBkImage(hDC);
PaintBk(hDC);
Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Control/UIScrollBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace DuiLib
void DoEvent(TEventUI& event);
void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);

void DoPaint(HDC hDC, const RECT& rcPaint);
void DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);

void PaintBk(HDC hDC);
void PaintButton1(HDC hDC);
Expand Down
20 changes: 11 additions & 9 deletions DuiLib/Core/UIContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,14 +749,14 @@ namespace DuiLib
return pResult;
}

void CContainerUI::DoPaint(HDC hDC, const RECT& rcPaint)
void CContainerUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
RECT rcTemp = { 0 };
if( !::IntersectRect(&rcTemp, &rcPaint, &m_rcItem) ) return;

CRenderClip clip;
CRenderClip::GenerateClip(hDC, rcTemp, clip);
CControlUI::DoPaint(hDC, rcPaint);
CControlUI::DoPaint(hDC, rcPaint, pStopControl);

if( m_items.GetSize() > 0 ) {
RECT rc = m_rcItem;
Expand All @@ -770,11 +770,12 @@ namespace DuiLib
if( !::IntersectRect(&rcTemp, &rcPaint, &rc) ) {
for( int it = 0; it < m_items.GetSize(); it++ ) {
CControlUI* pControl = static_cast<CControlUI*>(m_items[it]);
if( pControl == pStopControl ) break;
if( !pControl->IsVisible() ) continue;
if( !::IntersectRect(&rcTemp, &rcPaint, &pControl->GetPos()) ) continue;
if( pControl ->IsFloat() ) {
if( pControl->IsFloat() ) {
if( !::IntersectRect(&rcTemp, &m_rcItem, &pControl->GetPos()) ) continue;
pControl->Paint(hDC, rcPaint);
pControl->Paint(hDC, rcPaint, pStopControl);
}
}
}
Expand All @@ -783,31 +784,32 @@ namespace DuiLib
CRenderClip::GenerateClip(hDC, rcTemp, childClip);
for( int it = 0; it < m_items.GetSize(); it++ ) {
CControlUI* pControl = static_cast<CControlUI*>(m_items[it]);
if( pControl == pStopControl ) break;
if( !pControl->IsVisible() ) continue;
if( !::IntersectRect(&rcTemp, &rcPaint, &pControl->GetPos()) ) continue;
if( pControl ->IsFloat() ) {
if( pControl->IsFloat() ) {
if( !::IntersectRect(&rcTemp, &m_rcItem, &pControl->GetPos()) ) continue;
CRenderClip::UseOldClipBegin(hDC, childClip);
pControl->Paint(hDC, rcPaint);
pControl->Paint(hDC, rcPaint, pStopControl);
CRenderClip::UseOldClipEnd(hDC, childClip);
}
else {
if( !::IntersectRect(&rcTemp, &rc, &pControl->GetPos()) ) continue;
pControl->Paint(hDC, rcPaint);
pControl->Paint(hDC, rcPaint, pStopControl);
}
}
}
}

if( m_pVerticalScrollBar != NULL && m_pVerticalScrollBar->IsVisible() ) {
if( ::IntersectRect(&rcTemp, &rcPaint, &m_pVerticalScrollBar->GetPos()) ) {
m_pVerticalScrollBar->Paint(hDC, rcPaint);
m_pVerticalScrollBar->Paint(hDC, rcPaint, pStopControl);
}
}

if( m_pHorizontalScrollBar != NULL && m_pHorizontalScrollBar->IsVisible() ) {
if( ::IntersectRect(&rcTemp, &rcPaint, &m_pHorizontalScrollBar->GetPos()) ) {
m_pHorizontalScrollBar->Paint(hDC, rcPaint);
m_pHorizontalScrollBar->Paint(hDC, rcPaint, pStopControl);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion DuiLib/Core/UIContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class UILIB_API CContainerUI : public CControlUI, public IContainerUI
RECT GetClientPos() const;
void SetPos(RECT rc, bool bNeedInvalidate = true);
void Move(SIZE szOffset, bool bNeedInvalidate = true);
void DoPaint(HDC hDC, const RECT& rcPaint);
void DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);

void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);

Expand Down
20 changes: 14 additions & 6 deletions DuiLib/Core/UIControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ m_pManager(NULL),
m_pParent(NULL),
m_bUpdateNeeded(true),
m_bMenuUsed(false),
m_bAsyncNotify(false),
m_bVisible(true),
m_bInternVisible(true),
m_bFocused(false),
Expand Down Expand Up @@ -53,7 +54,10 @@ CDuiString CControlUI::GetName() const

void CControlUI::SetName(LPCTSTR pstrName)
{
m_sName = pstrName;
if (m_sName != pstrName) {
m_sName = pstrName;
if (m_pManager != NULL) m_pManager->RenameControl(this, pstrName);
}
}

LPVOID CControlUI::GetInterface(LPCTSTR pstrName)
Expand Down Expand Up @@ -963,24 +967,28 @@ CControlUI* CControlUI::ApplyAttributeList(LPCTSTR pstrList)
return this;
}

CDuiString CControlUI::GetAttributeList()
{
return "";
}

SIZE CControlUI::EstimateSize(SIZE szAvailable)
{
return m_cxyFixed;
}

void CControlUI::Paint(HDC hDC, const RECT& rcPaint)
void CControlUI::Paint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
if (pStopControl == this) return;
if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return;
if( OnPaint ) {
if( !OnPaint(this) ) return;
}
DoPaint(hDC, rcPaint);
DoPaint(hDC, rcPaint, pStopControl);
}

void CControlUI::DoPaint(HDC hDC, const RECT& rcPaint)
void CControlUI::DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl)
{
if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return;

// 绘制循序:背景颜色->背景图->状态图->文本->边框
if( m_cxyBorderRound.cx > 0 || m_cxyBorderRound.cy > 0 ) {
CRenderClip roundClip;
Expand Down
6 changes: 4 additions & 2 deletions DuiLib/Core/UIControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@ class UILIB_API CControlUI

virtual void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
CControlUI* ApplyAttributeList(LPCTSTR pstrList);
CDuiString GetAttributeList();

virtual SIZE EstimateSize(SIZE szAvailable);

virtual void Paint(HDC hDC, const RECT& rcPaint);
virtual void DoPaint(HDC hDC, const RECT& rcPaint);
virtual void Paint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl=NULL);
virtual void DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
virtual void PaintBkColor(HDC hDC);
virtual void PaintBkImage(HDC hDC);
virtual void PaintStatusImage(HDC hDC);
Expand Down Expand Up @@ -179,6 +180,7 @@ class UILIB_API CControlUI
CDuiString m_sName;
bool m_bUpdateNeeded;
bool m_bMenuUsed;
bool m_bAsyncNotify;
RECT m_rcItem;
RECT m_rcPadding;
SIZE m_cXY;
Expand Down
Loading

0 comments on commit 10962b0

Please sign in to comment.