Skip to content

Commit

Permalink
日常维护
Browse files Browse the repository at this point in the history
1、修正Slider右键Bug
2、Control增加SetTimer接口
  • Loading branch information
Troy committed Aug 21, 2015
1 parent c275b61 commit e8d14c5
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 12 deletions.
2 changes: 1 addition & 1 deletion DuiLib/Control/UIOption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
11 changes: 11 additions & 0 deletions DuiLib/Control/UIRichEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions DuiLib/Control/UIRichEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
19 changes: 8 additions & 11 deletions DuiLib/Control/UISlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 ) {
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
Expand All @@ -217,7 +215,6 @@ namespace DuiLib
return;
}
}

if( event.Type == UIEVENT_MOUSELEAVE )
{
if( IsEnabled() ) {
Expand Down
14 changes: 14 additions & 0 deletions DuiLib/Core/UIControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions DuiLib/Core/UIControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions DuiLib/Core/UIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) };
Expand Down
1 change: 1 addition & 0 deletions DuiLib/Core/UIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef enum EVENTTYPE_UI
UIEVENT_BUTTONDOWN,
UIEVENT_BUTTONUP,
UIEVENT_RBUTTONDOWN,
UIEVENT_RBUTTONUP,
UIEVENT_DBLCLICK,
UIEVENT_CONTEXTMENU,
UIEVENT_SCROLLWHEEL,
Expand Down

0 comments on commit e8d14c5

Please sign in to comment.