Remove unnecessary IsRadioButton().
Replace m_blockEvent with g_signal_handlers_block(). Remove wxRadioButton::DoGetBestSize(), it just calls the base. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -42,25 +42,17 @@ public:
|
|||||||
virtual void SetLabel(const wxString& label);
|
virtual void SetLabel(const wxString& label);
|
||||||
virtual void SetValue(bool val);
|
virtual void SetValue(bool val);
|
||||||
virtual bool GetValue() const;
|
virtual bool GetValue() const;
|
||||||
virtual bool Enable( bool enable = TRUE );
|
virtual bool Enable( bool enable = true );
|
||||||
|
|
||||||
static wxVisualAttributes
|
static wxVisualAttributes
|
||||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||||
|
|
||||||
// implementation
|
|
||||||
|
|
||||||
virtual bool IsRadioButton() const { return TRUE; }
|
|
||||||
|
|
||||||
bool m_blockEvent;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
|
virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
|
||||||
|
|
||||||
virtual wxSize DoGetBestSize() const;
|
|
||||||
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
|
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
|
||||||
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
|
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
|
||||||
|
|
||||||
private:
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxRadioButton)
|
DECLARE_DYNAMIC_CLASS(wxRadioButton)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -237,9 +237,6 @@ public:
|
|||||||
// is this window transparent for the mouse events (as wxStaticBox is)?
|
// is this window transparent for the mouse events (as wxStaticBox is)?
|
||||||
virtual bool IsTransparentForMouse() const { return false; }
|
virtual bool IsTransparentForMouse() const { return false; }
|
||||||
|
|
||||||
// is this a radiobutton (used by radiobutton code itself only)?
|
|
||||||
virtual bool IsRadioButton() const { return false; }
|
|
||||||
|
|
||||||
// Common scroll event handling code for wxWindow and wxScrollBar
|
// Common scroll event handling code for wxWindow and wxScrollBar
|
||||||
wxEventType GetScrollEventType(GtkRange* range);
|
wxEventType GetScrollEventType(GtkRange* range);
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
// For compilers that support precompilation, includes "wx.h".
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#if wxUSE_RADIOBOX
|
#if wxUSE_RADIOBTN
|
||||||
|
|
||||||
#include "wx/radiobut.h"
|
#include "wx/radiobut.h"
|
||||||
|
|
||||||
@@ -36,8 +36,6 @@ void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioButton *r
|
|||||||
|
|
||||||
if (!button->active) return;
|
if (!button->active) return;
|
||||||
|
|
||||||
if (rb->m_blockEvent) return;
|
|
||||||
|
|
||||||
wxCommandEvent event( wxEVT_COMMAND_RADIOBUTTON_SELECTED, rb->GetId());
|
wxCommandEvent event( wxEVT_COMMAND_RADIOBUTTON_SELECTED, rb->GetId());
|
||||||
event.SetInt( rb->GetValue() );
|
event.SetInt( rb->GetValue() );
|
||||||
event.SetEventObject( rb );
|
event.SetEventObject( rb );
|
||||||
@@ -60,8 +58,6 @@ bool wxRadioButton::Create( wxWindow *parent,
|
|||||||
const wxValidator& validator,
|
const wxValidator& validator,
|
||||||
const wxString& name )
|
const wxString& name )
|
||||||
{
|
{
|
||||||
m_blockEvent = false;
|
|
||||||
|
|
||||||
if (!PreCreation( parent, pos, size ) ||
|
if (!PreCreation( parent, pos, size ) ||
|
||||||
!CreateBase( parent, id, pos, size, style, validator, name ))
|
!CreateBase( parent, id, pos, size, style, validator, name ))
|
||||||
{
|
{
|
||||||
@@ -73,23 +69,16 @@ bool wxRadioButton::Create( wxWindow *parent,
|
|||||||
if (!HasFlag(wxRB_GROUP))
|
if (!HasFlag(wxRB_GROUP))
|
||||||
{
|
{
|
||||||
// search backward for last group start
|
// search backward for last group start
|
||||||
wxRadioButton *chief = (wxRadioButton*) NULL;
|
|
||||||
wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast();
|
wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast();
|
||||||
while (node)
|
for (; node; node = node->GetPrevious())
|
||||||
{
|
{
|
||||||
wxWindow *child = node->GetData();
|
wxWindow *child = node->GetData();
|
||||||
if (child->IsRadioButton())
|
if (child->HasFlag(wxRB_GROUP) && wxIsKindOf(child, wxRadioButton))
|
||||||
{
|
{
|
||||||
chief = (wxRadioButton*) child;
|
radioButtonGroup = gtk_radio_button_get_group(
|
||||||
if (child->HasFlag(wxRB_GROUP))
|
GTK_RADIO_BUTTON(child->m_widget));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
node = node->GetPrevious();
|
|
||||||
}
|
|
||||||
if (chief)
|
|
||||||
{
|
|
||||||
// we are part of the group started by chief
|
|
||||||
radioButtonGroup = gtk_radio_button_get_group( GTK_RADIO_BUTTON(chief->m_widget) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +93,7 @@ bool wxRadioButton::Create( wxWindow *parent,
|
|||||||
|
|
||||||
PostCreation(size);
|
PostCreation(size);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioButton::SetLabel( const wxString& label )
|
void wxRadioButton::SetLabel( const wxString& label )
|
||||||
@@ -121,7 +110,8 @@ void wxRadioButton::SetValue( bool val )
|
|||||||
if (val == GetValue())
|
if (val == GetValue())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_blockEvent = TRUE;
|
g_signal_handlers_block_by_func(
|
||||||
|
m_widget, (void*)gtk_radiobutton_clicked_callback, this);
|
||||||
|
|
||||||
if (val)
|
if (val)
|
||||||
{
|
{
|
||||||
@@ -134,12 +124,13 @@ void wxRadioButton::SetValue( bool val )
|
|||||||
// as FALSE. Failing silently is probably TRTTD here.
|
// as FALSE. Failing silently is probably TRTTD here.
|
||||||
}
|
}
|
||||||
|
|
||||||
m_blockEvent = FALSE;
|
g_signal_handlers_unblock_by_func(
|
||||||
|
m_widget, (void*)gtk_radiobutton_clicked_callback, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxRadioButton::GetValue() const
|
bool wxRadioButton::GetValue() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid radiobutton") );
|
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobutton") );
|
||||||
|
|
||||||
return GTK_TOGGLE_BUTTON(m_widget)->active;
|
return GTK_TOGGLE_BUTTON(m_widget)->active;
|
||||||
}
|
}
|
||||||
@@ -147,11 +138,11 @@ bool wxRadioButton::GetValue() const
|
|||||||
bool wxRadioButton::Enable( bool enable )
|
bool wxRadioButton::Enable( bool enable )
|
||||||
{
|
{
|
||||||
if ( !wxControl::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);
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioButton::DoApplyWidgetStyle(GtkRcStyle *style)
|
void wxRadioButton::DoApplyWidgetStyle(GtkRcStyle *style)
|
||||||
@@ -166,11 +157,6 @@ wxRadioButton::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
|
|||||||
return GTK_BUTTON(m_widget)->event_window;
|
return GTK_BUTTON(m_widget)->event_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxRadioButton::DoGetBestSize() const
|
|
||||||
{
|
|
||||||
return wxControl::DoGetBestSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
wxVisualAttributes
|
wxVisualAttributes
|
||||||
wxRadioButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
wxRadioButton::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
|
||||||
|
Reference in New Issue
Block a user