Fix setting "pressed" bitmap for wxToggleButton.
Move wxAnyButton::GetNormalState(), which allows wxToggleButton to override what "normal" means for it, down to the platform-independent wxAnyButtonBase class and use it now in wxGTK as well to correctly choose the pressed bitmap for a toggle button in this state. Closes #16771.
This commit is contained in:
committed by
Vadim Zeitlin
parent
c0ae81ced7
commit
1ad4596e8c
@@ -121,6 +121,7 @@ wxGTK:
|
|||||||
- Support building wxGTK3 under Windows (Kolya Kosenko).
|
- Support building wxGTK3 under Windows (Kolya Kosenko).
|
||||||
- Fix vertical cell alignment in wxDataViewCtrl.
|
- Fix vertical cell alignment in wxDataViewCtrl.
|
||||||
- Fix clearing of wxComboBox with wxCB_READONLY (Chuddah).
|
- Fix clearing of wxComboBox with wxCB_READONLY (Chuddah).
|
||||||
|
- Fix setting "pressed" bitmap for wxToggleButton (Kevin B. McCarty).
|
||||||
- Fix GTK+ warnings for wxFileDialog with wxFD_MULTIPLE style.
|
- Fix GTK+ warnings for wxFileDialog with wxFD_MULTIPLE style.
|
||||||
|
|
||||||
wxMSW:
|
wxMSW:
|
||||||
|
@@ -135,6 +135,13 @@ public:
|
|||||||
State_Max
|
State_Max
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// return the current setting for the "normal" state of the button, it can
|
||||||
|
// be different from State_Normal for a wxToggleButton
|
||||||
|
virtual State GetNormalState() const
|
||||||
|
{
|
||||||
|
return State_Normal;
|
||||||
|
}
|
||||||
|
|
||||||
// return true if this button shouldn't show the text label, either because
|
// return true if this button shouldn't show the text label, either because
|
||||||
// it doesn't have it or because it was explicitly disabled with wxBU_NOTEXT
|
// it doesn't have it or because it was explicitly disabled with wxBU_NOTEXT
|
||||||
bool DontShowLabel() const
|
bool DontShowLabel() const
|
||||||
|
@@ -36,7 +36,6 @@ public:
|
|||||||
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||||
|
|
||||||
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
|
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
|
||||||
virtual State GetNormalState() const { return State_Normal; }
|
|
||||||
|
|
||||||
// returns true if the platform should explicitly apply a theme border
|
// returns true if the platform should explicitly apply a theme border
|
||||||
virtual bool CanApplyThemeBorder() const { return false; }
|
virtual bool CanApplyThemeBorder() const { return false; }
|
||||||
|
@@ -46,8 +46,6 @@ public:
|
|||||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||||
virtual void Command(wxCommandEvent& event);
|
virtual void Command(wxCommandEvent& event);
|
||||||
|
|
||||||
virtual State GetNormalState() const;
|
|
||||||
|
|
||||||
// returns true if the platform should explicitly apply a theme border
|
// returns true if the platform should explicitly apply a theme border
|
||||||
virtual bool CanApplyThemeBorder() const { return false; }
|
virtual bool CanApplyThemeBorder() const { return false; }
|
||||||
|
|
||||||
|
@@ -36,6 +36,12 @@ public:
|
|||||||
virtual void SetValue(bool state) = 0;
|
virtual void SetValue(bool state) = 0;
|
||||||
virtual bool GetValue() const = 0;
|
virtual bool GetValue() const = 0;
|
||||||
|
|
||||||
|
// The current "normal" state for the toggle button depends upon its value.
|
||||||
|
virtual State GetNormalState() const wxOVERRIDE
|
||||||
|
{
|
||||||
|
return GetValue() ? State_Pressed : State_Normal;
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateWindowUI(long flags) wxOVERRIDE
|
void UpdateWindowUI(long flags) wxOVERRIDE
|
||||||
{
|
{
|
||||||
wxControl::UpdateWindowUI(flags);
|
wxControl::UpdateWindowUI(flags);
|
||||||
|
@@ -139,17 +139,32 @@ void wxAnyButton::GTKOnFocus(wxFocusEvent& event)
|
|||||||
wxAnyButton::State wxAnyButton::GTKGetCurrentBitmapState() const
|
wxAnyButton::State wxAnyButton::GTKGetCurrentBitmapState() const
|
||||||
{
|
{
|
||||||
if ( !IsThisEnabled() )
|
if ( !IsThisEnabled() )
|
||||||
return m_bitmaps[State_Disabled].IsOk() ? State_Disabled : State_Normal;
|
{
|
||||||
|
if ( m_bitmaps[State_Disabled].IsOk() )
|
||||||
|
return State_Disabled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( m_isPressed && m_bitmaps[State_Pressed].IsOk() )
|
||||||
|
return State_Pressed;
|
||||||
|
|
||||||
if ( m_isPressed && m_bitmaps[State_Pressed].IsOk() )
|
if ( m_isCurrent && m_bitmaps[State_Current].IsOk() )
|
||||||
return State_Pressed;
|
return State_Current;
|
||||||
|
|
||||||
if ( m_isCurrent && m_bitmaps[State_Current].IsOk() )
|
if ( HasFocus() && m_bitmaps[State_Focused].IsOk() )
|
||||||
return State_Current;
|
return State_Focused;
|
||||||
|
}
|
||||||
|
|
||||||
if ( HasFocus() && m_bitmaps[State_Focused].IsOk() )
|
// Fall back on the normal state: which still might be different from
|
||||||
return State_Focused;
|
// State_Normal for the toggle buttons, so the check for bitmap validity is
|
||||||
|
// still needed.
|
||||||
|
const State normalState = GetNormalState();
|
||||||
|
if ( m_bitmaps[normalState].IsOk() )
|
||||||
|
return normalState;
|
||||||
|
|
||||||
|
// And if nothing else can (or should) be used, finally fall back to the
|
||||||
|
// normal state which is the only one guaranteed to have a bitmap (if we're
|
||||||
|
// using bitmaps at all and we're only called in this case).
|
||||||
return State_Normal;
|
return State_Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -190,12 +190,4 @@ bool wxToggleButton::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxAnyButton::State wxToggleButton::GetNormalState() const
|
|
||||||
{
|
|
||||||
if ( GetValue() )
|
|
||||||
return State_Pressed;
|
|
||||||
else
|
|
||||||
return State_Normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // wxUSE_TOGGLEBTN
|
#endif // wxUSE_TOGGLEBTN
|
||||||
|
Reference in New Issue
Block a user