// override this and return true.
virtual bool UseGTKStyleBase() const { return false; }
+ // Fix sensitivity due to bug in GTK+ < 2.14
+ void GTKFixSensitivity(bool onlyIfUnderMouse = true);
+
private:
DECLARE_DYNAMIC_CLASS(wxControl)
};
static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+ virtual bool Enable( bool enable = true );
+
// implementation
void OnSize( wxSizeEvent &event );
void WidgetsFrame::OnEnable(wxCommandEvent& event)
{
CurrentPage()->GetWidget()->Enable(event.IsChecked());
+ if (CurrentPage()->GetWidget2())
+ CurrentPage()->GetWidget2()->Enable(event.IsChecked());
}
void WidgetsFrame::OnSetBorder(wxCommandEvent& event)
bool wxButton::Enable( bool enable )
{
+ bool isEnabled = IsEnabled();
+
if ( !wxControl::Enable( enable ) )
return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ if (!isEnabled && enable)
+ {
+ GTKFixSensitivity();
+ }
+
return true;
}
bool wxCheckBox::Enable( bool enable )
{
+ bool isEnabled = IsEnabled();
+
if ( !wxControl::Enable( enable ) )
return false;
gtk_widget_set_sensitive( m_widgetLabel, enable );
+ if (!isEnabled && enable)
+ {
+ GTKFixSensitivity();
+ }
+
return true;
}
#include "wx/fontutil.h"
#include "wx/gtk/private.h"
+#include "wx/utils.h"
+#include "wx/sysopt.h"
#include "wx/gtk/private/mnemonics.h"
SetInitialSize(size);
}
+// ----------------------------------------------------------------------------
+// Work around a GTK+ bug whereby button is insensitive after being
+// enabled
+// ----------------------------------------------------------------------------
+
+// Fix sensitivity due to bug in GTK+ < 2.14
+void wxControl::GTKFixSensitivity(bool onlyIfUnderMouse)
+{
+ if (gtk_check_version(2,14,0)
+#if wxUSE_SYSTEM_OPTIONS
+ && (wxSystemOptions::GetOptionInt(wxT("gtk.control.disable-sensitivity-fix")) != 1)
+#endif
+ )
+ {
+ wxPoint pt = wxGetMousePosition();
+ wxRect rect(ClientToScreen(wxPoint(0, 0)), GetSize());
+ if (!onlyIfUnderMouse || rect.Contains(pt))
+ {
+ Hide();
+ Show();
+ }
+ }
+}
+
// ----------------------------------------------------------------------------
// wxControl dealing with labels
// ----------------------------------------------------------------------------
bool wxRadioBox::Enable( bool enable )
{
+ bool isEnabled = IsEnabled();
+
if ( !wxControl::Enable( enable ) )
return false;
node = node->GetNext();
}
+ if (!isEnabled && enable)
+ {
+ GTKFixSensitivity();
+ }
+
return true;
}
bool wxRadioButton::Enable( bool enable )
{
+ bool isEnabled = IsEnabled();
+
if ( !wxControl::Enable( enable ) )
return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ if (!isEnabled && enable)
+ {
+ GTKFixSensitivity();
+ }
+
return true;
}
gtk_widget_set_size_request( m_widget, m_width, m_height );
}
+bool wxSpinButton::Enable( bool enable )
+{
+ bool isEnabled = IsEnabled();
+
+ if ( !wxControl::Enable( enable ) )
+ return false;
+
+ // Work around lack of visual update when enabling
+ if (!isEnabled && enable)
+ GTKFixSensitivity(false /* fix even if not under mouse */);
+
+ return true;
+}
+
void wxSpinButton::GtkDisableEvents() const
{
g_signal_handlers_block_by_func(m_widget,
bool wxBitmapToggleButton::Enable(bool enable /*=true*/)
{
+ bool isEnabled = IsEnabled();
+
if (!wxControl::Enable(enable))
return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ if (!isEnabled && enable)
+ {
+ GTKFixSensitivity();
+ }
+
return true;
}
bool wxToggleButton::Enable(bool enable /*=true*/)
{
+ bool isEnabled = IsEnabled();
+
if (!wxControl::Enable(enable))
return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ if (!isEnabled && enable)
+ {
+ GTKFixSensitivity();
+ }
+
return true;
}