simplify Enable()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62785 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2009-12-05 19:25:04 +00:00
parent 61aba4609a
commit b545684e13
11 changed files with 28 additions and 40 deletions

View File

@@ -68,6 +68,8 @@ protected:
virtual void DoSetBitmapPosition(wxDirection dir); virtual void DoSetBitmapPosition(wxDirection dir);
private: private:
typedef wxButtonBase base_type;
// common part of all ctors // common part of all ctors
void Init() void Init()
{ {
@@ -89,7 +91,6 @@ private:
// show the given bitmap (must be valid) // show the given bitmap (must be valid)
void GTKDoShowBitmap(const wxBitmap& bitmap); void GTKDoShowBitmap(const wxBitmap& bitmap);
// the bitmaps for the different state of the buttons, all of them may be // the bitmaps for the different state of the buttons, all of them may be
// invalid and the button only shows a bitmap at all if State_Normal bitmap // invalid and the button only shows a bitmap at all if State_Normal bitmap
// is valid // is valid
@@ -101,7 +102,6 @@ private:
// true iff the button is in pressed state // true iff the button is in pressed state
bool m_isPressed; bool m_isPressed;
DECLARE_DYNAMIC_CLASS(wxButton) DECLARE_DYNAMIC_CLASS(wxButton)
}; };

View File

@@ -44,6 +44,10 @@ public:
static wxVisualAttributes static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
// implementation
void GTKDisableEvents();
void GTKEnableEvents();
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
virtual void DoApplyWidgetStyle(GtkRcStyle *style); virtual void DoApplyWidgetStyle(GtkRcStyle *style);
@@ -52,15 +56,12 @@ protected:
void DoSet3StateValue(wxCheckBoxState state); void DoSet3StateValue(wxCheckBoxState state);
wxCheckBoxState DoGet3StateValue() const; wxCheckBoxState DoGet3StateValue() const;
public: private:
// implementation typedef wxCheckBoxBase base_type;
void GTKDisableEvents();
void GTKEnableEvents();
GtkWidget *m_widgetCheckbox; GtkWidget *m_widgetCheckbox;
GtkWidget *m_widgetLabel; GtkWidget *m_widgetLabel;
private:
DECLARE_DYNAMIC_CLASS(wxCheckBox) DECLARE_DYNAMIC_CLASS(wxCheckBox)
}; };

View File

@@ -53,6 +53,9 @@ protected:
virtual void DoApplyWidgetStyle(GtkRcStyle *style); virtual void DoApplyWidgetStyle(GtkRcStyle *style);
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private:
typedef wxControl base_type;
DECLARE_DYNAMIC_CLASS(wxRadioButton) DECLARE_DYNAMIC_CLASS(wxRadioButton)
}; };

View File

@@ -60,6 +60,8 @@ protected:
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private: private:
typedef wxSpinButtonBase base_type;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxSpinButton) DECLARE_DYNAMIC_CLASS(wxSpinButton)
}; };

View File

@@ -84,6 +84,8 @@ protected:
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private: private:
typedef wxToggleButtonBase base_type;
DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton) DECLARE_DYNAMIC_CLASS(wxBitmapToggleButton)
}; };
@@ -137,6 +139,8 @@ protected:
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
private: private:
typedef wxToggleButtonBase base_type;
DECLARE_DYNAMIC_CLASS(wxToggleButton) DECLARE_DYNAMIC_CLASS(wxToggleButton)
}; };

View File

@@ -266,17 +266,13 @@ void wxButton::SetLabel( const wxString &lbl )
bool wxButton::Enable( bool enable ) bool wxButton::Enable( bool enable )
{ {
bool isEnabled = IsEnabled(); if (!base_type::Enable(enable))
if ( !wxControl::Enable( enable ) )
return false; return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable); gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
if (!isEnabled && enable) if (enable)
{
GTKFixSensitivity(); GTKFixSensitivity();
}
GTKUpdateBitmap(); GTKUpdateBitmap();

View File

@@ -217,17 +217,13 @@ void wxCheckBox::SetLabel( const wxString& label )
bool wxCheckBox::Enable( bool enable ) bool wxCheckBox::Enable( bool enable )
{ {
bool isEnabled = IsEnabled(); if (!base_type::Enable(enable))
if ( !wxControl::Enable( enable ) )
return false; return false;
gtk_widget_set_sensitive( m_widgetLabel, enable ); gtk_widget_set_sensitive( m_widgetLabel, enable );
if (!isEnabled && enable) if (enable)
{
GTKFixSensitivity(); GTKFixSensitivity();
}
return true; return true;
} }

View File

@@ -428,8 +428,6 @@ void wxRadioBox::SetString(unsigned int item, const wxString& label)
bool wxRadioBox::Enable( bool enable ) bool wxRadioBox::Enable( bool enable )
{ {
bool isEnabled = IsEnabled();
if ( !wxControl::Enable( enable ) ) if ( !wxControl::Enable( enable ) )
return false; return false;
@@ -444,10 +442,8 @@ bool wxRadioBox::Enable( bool enable )
node = node->GetNext(); node = node->GetNext();
} }
if (!isEnabled && enable) if (enable)
{
GTKFixSensitivity(); GTKFixSensitivity();
}
return true; return true;
} }

View File

@@ -138,17 +138,13 @@ bool wxRadioButton::GetValue() const
bool wxRadioButton::Enable( bool enable ) bool wxRadioButton::Enable( bool enable )
{ {
bool isEnabled = IsEnabled(); if (!base_type::Enable(enable))
if ( !wxControl::Enable( enable ) )
return false; return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable); gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
if (!isEnabled && enable) if (enable)
{
GTKFixSensitivity(); GTKFixSensitivity();
}
return true; return true;
} }

View File

@@ -177,13 +177,11 @@ void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) )
bool wxSpinButton::Enable( bool enable ) bool wxSpinButton::Enable( bool enable )
{ {
bool isEnabled = IsEnabled(); if (!base_type::Enable(enable))
if ( !wxControl::Enable( enable ) )
return false; return false;
// Work around lack of visual update when enabling // Work around lack of visual update when enabling
if (!isEnabled && enable) if (enable)
GTKFixSensitivity(false /* fix even if not under mouse */); GTKFixSensitivity(false /* fix even if not under mouse */);
return true; return true;

View File

@@ -285,17 +285,13 @@ void wxToggleButton::SetLabel(const wxString& label)
bool wxToggleButton::Enable(bool enable /*=true*/) bool wxToggleButton::Enable(bool enable /*=true*/)
{ {
bool isEnabled = IsEnabled(); if (!base_type::Enable(enable))
if (!wxControl::Enable(enable))
return false; return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable); gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
if (!isEnabled && enable) if (enable)
{
GTKFixSensitivity(); GTKFixSensitivity();
}
return true; return true;
} }