From 2f45267a4d44332057016ed44c9055211638d59c Mon Sep 17 00:00:00 2001 From: duisharp Date: Wed, 17 Jun 2015 00:13:55 +0800 Subject: [PATCH] =?UTF-8?q?Button=E6=8E=A7=E4=BB=B6=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Button控件支持颜色(bkcolor-hotbkcolor-pushedbkcolor) --- DuiLib/Control/UIButton.cpp | 26 ++++++++++++++++++++++++-- DuiLib/Control/UIButton.h | 3 +++ bin/skin/duidemo/main.xml | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/DuiLib/Control/UIButton.cpp b/DuiLib/Control/UIButton.cpp index 81772816..f34b77d7 100644 --- a/DuiLib/Control/UIButton.cpp +++ b/DuiLib/Control/UIButton.cpp @@ -8,8 +8,9 @@ namespace DuiLib , m_dwHotTextColor(0) , m_dwPushedTextColor(0) , m_dwFocusedTextColor(0) - ,m_dwHotBkColor(0) - ,m_iBindTabIndex(-1) + , m_dwHotBkColor(0) + , m_dwPushedBkColor(0) + , m_iBindTabIndex(-1) { m_uTextStyle = DT_SINGLELINE | DT_VCENTER | DT_CENTER; } @@ -139,6 +140,16 @@ namespace DuiLib { return m_dwHotBkColor; } + + void CButtonUI::SetPushedBkColor( DWORD dwColor ) + { + m_dwPushedBkColor = dwColor; + } + + DWORD CButtonUI::GetPushedBkColor() const + { + return m_dwPushedBkColor; + } void CButtonUI::SetHotTextColor(DWORD dwColor) { @@ -311,6 +322,13 @@ namespace DuiLib DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetHotBkColor(clrColor); } + else if( _tcscmp(pstrName, _T("pushedbkcolor")) == 0 ) + { + if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); + LPTSTR pstr = NULL; + DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); + SetPushedBkColor(clrColor); + } else if( _tcscmp(pstrName, _T("hottextcolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); @@ -410,6 +428,10 @@ namespace DuiLib } else goto Label_ForeImage; } + else if(m_dwPushedBkColor != 0) { + CRenderEngine::DrawColor(hDC, m_rcPaint, GetAdjustColor(m_dwPushedBkColor)); + return; + } } else if( (m_uButtonState & UISTATE_HOT) != 0 ) { if( !m_sHotImage.IsEmpty() ) { diff --git a/DuiLib/Control/UIButton.h b/DuiLib/Control/UIButton.h index 42392159..00654d02 100644 --- a/DuiLib/Control/UIButton.h +++ b/DuiLib/Control/UIButton.h @@ -42,6 +42,8 @@ namespace DuiLib void SetHotBkColor(DWORD dwColor); DWORD GetHotBkColor() const; + void SetPushedBkColor(DWORD dwColor); + DWORD GetPushedBkColor() const; void SetHotTextColor(DWORD dwColor); DWORD GetHotTextColor() const; void SetPushedTextColor(DWORD dwColor); @@ -58,6 +60,7 @@ namespace DuiLib UINT m_uButtonState; DWORD m_dwHotBkColor; + DWORD m_dwPushedBkColor; DWORD m_dwHotTextColor; DWORD m_dwPushedTextColor; DWORD m_dwFocusedTextColor; diff --git a/bin/skin/duidemo/main.xml b/bin/skin/duidemo/main.xml index e27ab09b..533f16f3 100644 --- a/bin/skin/duidemo/main.xml +++ b/bin/skin/duidemo/main.xml @@ -45,6 +45,7 @@