From e8d14c5367985747481084ad15035a617b2cf4d0 Mon Sep 17 00:00:00 2001 From: Troy <656067418@qq.com> Date: Fri, 21 Aug 2015 18:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=B8=B8=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1、修正Slider右键Bug 2、Control增加SetTimer接口 --- DuiLib/Control/UIOption.cpp | 2 +- DuiLib/Control/UIRichEdit.cpp | 11 +++++++++++ DuiLib/Control/UIRichEdit.h | 2 ++ DuiLib/Control/UISlider.cpp | 19 ++++++++----------- DuiLib/Core/UIControl.cpp | 14 ++++++++++++++ DuiLib/Core/UIControl.h | 4 ++++ DuiLib/Core/UIManager.cpp | 20 ++++++++++++++++++++ DuiLib/Core/UIManager.h | 1 + 8 files changed, 61 insertions(+), 12 deletions(-) diff --git a/DuiLib/Control/UIOption.cpp b/DuiLib/Control/UIOption.cpp index cfd6b637..d39cf50b 100644 --- a/DuiLib/Control/UIOption.cpp +++ b/DuiLib/Control/UIOption.cpp @@ -3,7 +3,7 @@ namespace DuiLib { - COptionUI::COptionUI() : m_bSelected(false), m_dwSelectedTextColor(0) + COptionUI::COptionUI() : m_bSelected(false), m_dwSelectedTextColor(0), m_dwSelectedBkColor(0) { } diff --git a/DuiLib/Control/UIRichEdit.cpp b/DuiLib/Control/UIRichEdit.cpp index d1f186a7..5a1b8f79 100644 --- a/DuiLib/Control/UIRichEdit.cpp +++ b/DuiLib/Control/UIRichEdit.cpp @@ -1098,6 +1098,17 @@ UINT CRichEditUI::GetControlFlags() const return UIFLAG_SETCURSOR | UIFLAG_TABSTOP; } +bool CRichEditUI::IsMultiLine() +{ + return (m_lTwhStyle & ES_MULTILINE) == ES_MULTILINE; +} + +void CRichEditUI::SetMultiLine(bool bMultiLine) +{ + if(!bMultiLine) m_lTwhStyle &= ~ES_MULTILINE; + else m_lTwhStyle |= ES_MULTILINE; +} + bool CRichEditUI::IsWantTab() { return m_bWantTab; diff --git a/DuiLib/Control/UIRichEdit.h b/DuiLib/Control/UIRichEdit.h index 762e53f6..c73ae512 100644 --- a/DuiLib/Control/UIRichEdit.h +++ b/DuiLib/Control/UIRichEdit.h @@ -19,6 +19,8 @@ class UILIB_API CRichEditUI : public CContainerUI, public IMessageFilterUI LPVOID GetInterface(LPCTSTR pstrName); UINT GetControlFlags() const; + bool IsMultiLine(); + void SetMultiLine(bool bMultiLine); bool IsWantTab(); void SetWantTab(bool bWantTab = true); bool IsWantReturn(); diff --git a/DuiLib/Control/UISlider.cpp b/DuiLib/Control/UISlider.cpp index 38f7fdea..b7d4dd26 100644 --- a/DuiLib/Control/UISlider.cpp +++ b/DuiLib/Control/UISlider.cpp @@ -116,7 +116,6 @@ namespace DuiLib m_uButtonState |= UISTATE_CAPTURED; int nValue; - if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) nValue = m_nMin; @@ -127,16 +126,16 @@ namespace DuiLib else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) nValue = m_nMax; else nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } - if(m_nValue !=nValue && nValue>=m_nMin && nValue<=m_nMax) + if(m_nValue != nValue && nValue >= m_nMin && nValue <= m_nMax) { - m_nValue =nValue; + m_nValue = nValue; Invalidate(); } } return; } - if( event.Type == UIEVENT_BUTTONUP ) + if( event.Type == UIEVENT_BUTTONUP || event.Type == UIEVENT_RBUTTONUP) { int nValue; if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { @@ -152,7 +151,7 @@ namespace DuiLib else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) nValue = m_nMax; else nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } - if(nValue>=m_nMin && nValue<=m_nMax) + if(nValue >= m_nMin && nValue <= m_nMax) { m_nValue =nValue; m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); @@ -190,20 +189,19 @@ namespace DuiLib else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } - if (m_bSendMove) + if (m_bSendMove) { m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED_MOVE); + } Invalidate(); } - // Generate the appropriate mouse messages POINT pt = event.ptMouse; RECT rcThumb = GetThumbRect(); if( IsEnabled() && ::PtInRect(&rcThumb, event.ptMouse) ) { - m_uButtonState |= UISTATE_HOT; Invalidate(); - }else - { + } + else { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } @@ -217,7 +215,6 @@ namespace DuiLib return; } } - if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled() ) { diff --git a/DuiLib/Core/UIControl.cpp b/DuiLib/Core/UIControl.cpp index ae4581c1..034da491 100644 --- a/DuiLib/Core/UIControl.cpp +++ b/DuiLib/Core/UIControl.cpp @@ -97,6 +97,20 @@ CControlUI* CControlUI::GetParent() const return m_pParent; } +bool CControlUI::SetTimer(UINT nTimerID, UINT nElapse) +{ + if(m_pManager == NULL) return false; + + return m_pManager->SetTimer(this, nTimerID, nElapse); +} + +void CControlUI::KillTimer(UINT nTimerID) +{ + if(m_pManager == NULL) return; + + m_pManager->KillTimer(this, nTimerID); +} + CDuiString CControlUI::GetText() const { return m_sText; diff --git a/DuiLib/Core/UIControl.h b/DuiLib/Core/UIControl.h index 80e47856..b6011456 100644 --- a/DuiLib/Core/UIControl.h +++ b/DuiLib/Core/UIControl.h @@ -28,6 +28,10 @@ class UILIB_API CControlUI virtual void SetManager(CPaintManagerUI* pManager, CControlUI* pParent, bool bInit = true); virtual CControlUI* GetParent() const; + // ʱ + bool SetTimer(UINT nTimerID, UINT nElapse); + void KillTimer(UINT nTimerID); + // ı virtual CDuiString GetText() const; virtual void SetText(LPCTSTR pstrText); diff --git a/DuiLib/Core/UIManager.cpp b/DuiLib/Core/UIManager.cpp index c5d2f380..485c157d 100644 --- a/DuiLib/Core/UIManager.cpp +++ b/DuiLib/Core/UIManager.cpp @@ -1125,6 +1125,26 @@ namespace DuiLib { m_pEventClick = pControl; } break; + case WM_RBUTTONUP: + { + ReleaseCapture(); + + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + m_ptLastMousePos = pt; + m_pEventClick = FindControl(pt); + if(m_pEventClick == NULL) break; + TEventUI event = { 0 }; + event.Type = UIEVENT_RBUTTONUP; + event.pSender = m_pEventClick; + event.wParam = wParam; + event.lParam = lParam; + event.ptMouse = pt; + event.wKeyState = (WORD)wParam; + event.dwTimestamp = ::GetTickCount(); + m_pEventClick->Event(event); + m_pEventClick = NULL; + } + break; case WM_CONTEXTMENU: { POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; diff --git a/DuiLib/Core/UIManager.h b/DuiLib/Core/UIManager.h index 42bc3bd0..6b9d63a2 100644 --- a/DuiLib/Core/UIManager.h +++ b/DuiLib/Core/UIManager.h @@ -30,6 +30,7 @@ typedef enum EVENTTYPE_UI UIEVENT_BUTTONDOWN, UIEVENT_BUTTONUP, UIEVENT_RBUTTONDOWN, + UIEVENT_RBUTTONUP, UIEVENT_DBLCLICK, UIEVENT_CONTEXTMENU, UIEVENT_SCROLLWHEEL,