Simplify changing window styles in wxMSW code
Add wxMSWWinStyleUpdater and wxMSWWinExStyleUpdater helper classes which allow writing code changing GWL_STYLE and GWL_EXSTYLE bits, respectively, in a shorter and more clear way. There should be no real changes in behaviour.
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
#include "wx/msw/uxtheme.h"
|
||||
#include "wx/msw/dc.h" // for wxDCTemp
|
||||
#include "wx/msw/ownerdrawnbutton.h"
|
||||
#include "wx/msw/private/winstyle.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxWin macros
|
||||
@@ -421,14 +422,13 @@ bool wxMSWOwnerDrawnButtonBase::MSWIsOwnerDrawn() const
|
||||
|
||||
void wxMSWOwnerDrawnButtonBase::MSWMakeOwnerDrawn(bool ownerDrawn)
|
||||
{
|
||||
long style = ::GetWindowLong(GetHwndOf(m_win), GWL_STYLE);
|
||||
wxMSWWinStyleUpdater updateStyle(GetHwndOf(m_win));
|
||||
|
||||
// note that BS_CHECKBOX & BS_OWNERDRAW != 0 so we can't operate on
|
||||
// them as on independent style bits
|
||||
if ( ownerDrawn )
|
||||
{
|
||||
style &= ~BS_TYPEMASK;
|
||||
style |= BS_OWNERDRAW;
|
||||
updateStyle.TurnOff(BS_TYPEMASK).TurnOn(BS_OWNERDRAW);
|
||||
|
||||
m_win->Bind(wxEVT_ENTER_WINDOW,
|
||||
&wxMSWOwnerDrawnButtonBase::OnMouseEnterOrLeave, this);
|
||||
@@ -448,8 +448,7 @@ void wxMSWOwnerDrawnButtonBase::MSWMakeOwnerDrawn(bool ownerDrawn)
|
||||
}
|
||||
else // reset to default colour
|
||||
{
|
||||
style &= ~BS_OWNERDRAW;
|
||||
style |= MSWGetButtonStyle();
|
||||
updateStyle.TurnOff(BS_OWNERDRAW).TurnOn(MSWGetButtonStyle());
|
||||
|
||||
m_win->Unbind(wxEVT_ENTER_WINDOW,
|
||||
&wxMSWOwnerDrawnButtonBase::OnMouseEnterOrLeave, this);
|
||||
@@ -467,7 +466,7 @@ void wxMSWOwnerDrawnButtonBase::MSWMakeOwnerDrawn(bool ownerDrawn)
|
||||
&wxMSWOwnerDrawnButtonBase::OnFocus, this);
|
||||
}
|
||||
|
||||
::SetWindowLong(GetHwndOf(m_win), GWL_STYLE, style);
|
||||
updateStyle.Apply();
|
||||
|
||||
if ( !ownerDrawn )
|
||||
MSWOnButtonResetOwnerDrawn();
|
||||
|
Reference in New Issue
Block a user