Corrected wxlistBox, wxRadioBox, wxComboBox and
wxChoice in that they do no longer send events after programmatic calls Corrected wxStaticBitmap Reimplemented wxRadioButton as per wxMSW Updated docs for the above Update testconf for socket changes Other minor fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3087 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -42,12 +42,6 @@ static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckB
|
||||
|
||||
if (!cb->m_hasVMT) return;
|
||||
|
||||
if (cb->m_blockFirstEvent)
|
||||
{
|
||||
cb->m_blockFirstEvent = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_blockEventsOnDrag) return;
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId());
|
||||
@@ -80,8 +74,6 @@ bool wxCheckBox::Create(wxWindow *parent,
|
||||
|
||||
PreCreation( parent, id, pos, size, style, name );
|
||||
|
||||
m_blockFirstEvent = FALSE;
|
||||
|
||||
#if wxUSE_VALIDATORS
|
||||
SetValidator( validator );
|
||||
#endif
|
||||
@@ -102,7 +94,6 @@ bool wxCheckBox::Create(wxWindow *parent,
|
||||
gtk_box_pack_start(GTK_BOX(m_widget), m_widgetLabel, FALSE, FALSE, 3);
|
||||
gtk_box_pack_start(GTK_BOX(m_widget), m_widgetCheckbox, FALSE, FALSE, 3);
|
||||
|
||||
// VZ: why do I have to do this to make them appear?
|
||||
gtk_widget_show( m_widgetLabel );
|
||||
gtk_widget_show( m_widgetCheckbox );
|
||||
}
|
||||
@@ -146,14 +137,19 @@ void wxCheckBox::SetValue( bool state )
|
||||
{
|
||||
wxCHECK_RET( m_widgetCheckbox != NULL, _T("invalid checkbox") );
|
||||
|
||||
if ( state == GetValue() )
|
||||
if (state == GetValue())
|
||||
return;
|
||||
|
||||
// for compatibility with wxMSW don't send notification when the check box
|
||||
// state is changed programmatically
|
||||
m_blockFirstEvent = TRUE;
|
||||
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widgetCheckbox),
|
||||
GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback),
|
||||
(gpointer *)this );
|
||||
|
||||
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widgetCheckbox), state );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox),
|
||||
"clicked",
|
||||
GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback),
|
||||
(gpointer *)this );
|
||||
}
|
||||
|
||||
bool wxCheckBox::GetValue() const
|
||||
|
@@ -355,8 +355,6 @@ void wxChoice::SetSelection( int n )
|
||||
|
||||
int tmp = n;
|
||||
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
|
||||
|
||||
gtk_choice_clicked_callback( (GtkWidget *) NULL, this );
|
||||
}
|
||||
|
||||
void wxChoice::SetStringSelection( const wxString &string )
|
||||
@@ -367,6 +365,36 @@ void wxChoice::SetStringSelection( const wxString &string )
|
||||
if (n != -1) SetSelection( n );
|
||||
}
|
||||
|
||||
void wxChoice::DisableEvents()
|
||||
{
|
||||
/*
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_signal_disconnect_by_func( GTK_OBJECT( child->data ),
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void wxChoice::EnableEvents()
|
||||
{
|
||||
/*
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_signal_connect( GTK_OBJECT( child->data ), "activate",
|
||||
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void wxChoice::ApplyWidgetStyle()
|
||||
{
|
||||
SetWidgetStyle();
|
||||
|
@@ -422,8 +422,12 @@ void wxComboBox::SetSelection( int n )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
|
||||
|
||||
DisableEvents();
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
gtk_list_select_item( GTK_LIST(list), n );
|
||||
|
||||
EnableEvents();
|
||||
}
|
||||
|
||||
void wxComboBox::SetStringSelection( const wxString &string )
|
||||
@@ -586,6 +590,32 @@ void wxComboBox::OnChar( wxKeyEvent &event )
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxComboBox::DisableEvents()
|
||||
{
|
||||
GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
GList *child = list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
void wxComboBox::EnableEvents()
|
||||
{
|
||||
GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||
GList *child = list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_signal_connect( GTK_OBJECT(child->data), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
void wxComboBox::OnSize( wxSizeEvent &event )
|
||||
{
|
||||
event.Skip();
|
||||
|
@@ -939,6 +939,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
||||
}
|
||||
}
|
||||
|
||||
#if (GTK_MINOR_VERSION > 0)
|
||||
if (req_dash && req_nb_dash)
|
||||
{
|
||||
char *real_req_dash = new char[req_nb_dash];
|
||||
@@ -955,6 +956,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
||||
gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GdkCapStyle capStyle = GDK_CAP_ROUND;
|
||||
switch (m_pen.GetCap())
|
||||
|
@@ -640,7 +640,11 @@ void wxListBox::Deselect( int n )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
|
||||
|
||||
DisableEvents();
|
||||
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
|
||||
EnableEvents();
|
||||
}
|
||||
|
||||
int wxListBox::FindString( const wxString &item ) const
|
||||
@@ -799,10 +803,14 @@ void wxListBox::SetSelection( int n, bool select )
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
|
||||
|
||||
DisableEvents();
|
||||
|
||||
if (select)
|
||||
gtk_list_select_item( m_list, n );
|
||||
else
|
||||
gtk_list_unselect_item( m_list, n );
|
||||
|
||||
EnableEvents();
|
||||
}
|
||||
|
||||
void wxListBox::SetString( int n, const wxString &string )
|
||||
@@ -859,7 +867,7 @@ void wxListBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip )
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_tooltips_set_tip( tips, GTK_WIDGET( child->data ), wxConvLocal.cWX2MB(tip), (gchar*) NULL );
|
||||
gtk_tooltips_set_tip( tips, GTK_WIDGET( child->data ), wxConvCurrent->cWX2MB(tip), (gchar*) NULL );
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
@@ -898,6 +906,38 @@ void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
|
||||
}
|
||||
#endif
|
||||
|
||||
void wxListBox::DisableEvents()
|
||||
{
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
if (HasFlag(wxLB_MULTIPLE))
|
||||
gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
void wxListBox::EnableEvents()
|
||||
{
|
||||
GList *child = m_list->children;
|
||||
while (child)
|
||||
{
|
||||
gtk_signal_connect( GTK_OBJECT(child->data), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
if (HasFlag(wxLB_MULTIPLE))
|
||||
gtk_signal_connect( GTK_OBJECT(child->data), "deselect",
|
||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *wxListBox::GetConnectWidget()
|
||||
{
|
||||
return GTK_WIDGET(m_list);
|
||||
|
@@ -328,7 +328,11 @@ void wxRadioBox::SetSelection( int n )
|
||||
|
||||
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
|
||||
|
||||
DisableEvents();
|
||||
|
||||
gtk_toggle_button_set_state( button, 1 );
|
||||
|
||||
EnableEvents();
|
||||
}
|
||||
|
||||
int wxRadioBox::GetSelection(void) const
|
||||
@@ -494,6 +498,30 @@ void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) )
|
||||
wxFAIL_MSG(_T("wxRadioBox::SetNumberOfRowsOrCols not implemented."));
|
||||
}
|
||||
|
||||
void wxRadioBox::DisableEvents()
|
||||
{
|
||||
wxNode *node = m_boxes.First();
|
||||
while (node)
|
||||
{
|
||||
gtk_signal_disconnect_by_func( GTK_OBJECT(node->Data()),
|
||||
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
void wxRadioBox::EnableEvents()
|
||||
{
|
||||
wxNode *node = m_boxes.First();
|
||||
while (node)
|
||||
{
|
||||
gtk_signal_connect( GTK_OBJECT(node->Data()), "clicked",
|
||||
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
void wxRadioBox::ApplyWidgetStyle()
|
||||
{
|
||||
SetWidgetStyle();
|
||||
|
@@ -43,12 +43,6 @@ void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioButto
|
||||
|
||||
if (!rb->m_hasVMT) return;
|
||||
|
||||
if (rb->m_blockFirstEvent)
|
||||
{
|
||||
rb->m_blockFirstEvent = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_blockEventsOnDrag) return;
|
||||
|
||||
wxCommandEvent event( wxEVT_COMMAND_RADIOBUTTON_SELECTED, rb->GetId());
|
||||
@@ -73,22 +67,50 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab
|
||||
wxSize newSize = size;
|
||||
|
||||
PreCreation( parent, id, pos, newSize, style, name );
|
||||
|
||||
m_isRadioButton = TRUE;
|
||||
|
||||
#if wxUSE_VALIDATORS
|
||||
SetValidator( validator );
|
||||
#endif
|
||||
|
||||
m_widget = gtk_radio_button_new_with_label( (GSList *) NULL, label.mbc_str() );
|
||||
|
||||
if (HasFlag(wxRB_GROUP))
|
||||
{
|
||||
/* start a new group */
|
||||
m_radioButtonGroup = (GSList*) NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* search backward for last group start */
|
||||
wxRadioButton *chief = (wxRadioButton*) NULL;
|
||||
wxWindowList::Node *node = parent->GetChildren().GetLast();
|
||||
while (node)
|
||||
{
|
||||
wxWindow *child = node->GetData();
|
||||
if (child->m_isRadioButton)
|
||||
{
|
||||
chief = (wxRadioButton*) child;
|
||||
if (child->HasFlag(wxRB_GROUP)) break;
|
||||
}
|
||||
if (chief)
|
||||
{
|
||||
/* we are part of the group started by chief */
|
||||
m_radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* start a new group */
|
||||
m_radioButtonGroup = (GSList*) NULL;
|
||||
}
|
||||
node = node->GetPrevious();
|
||||
}
|
||||
}
|
||||
|
||||
m_widget = gtk_radio_button_new_with_label( m_radioButtonGroup, label.mbc_str() );
|
||||
|
||||
m_theOtherRadioButtton =
|
||||
gtk_radio_button_new_with_label(
|
||||
gtk_radio_button_group( GTK_RADIO_BUTTON(m_widget) ),
|
||||
"button2" );
|
||||
|
||||
SetLabel(label);
|
||||
|
||||
m_blockFirstEvent = FALSE;
|
||||
|
||||
if (newSize.x == -1) newSize.x = 22+gdk_string_measure( m_widget->style->font, label.mbc_str() );
|
||||
if (newSize.y == -1) newSize.y = 26;
|
||||
SetSize( newSize.x, newSize.y );
|
||||
@@ -123,15 +145,23 @@ void wxRadioButton::SetValue( bool val )
|
||||
{
|
||||
wxCHECK_RET( m_widget != NULL, _T("invalid radiobutton") );
|
||||
|
||||
if ( val == GetValue() )
|
||||
if (val == GetValue())
|
||||
return;
|
||||
|
||||
m_blockFirstEvent = TRUE;
|
||||
|
||||
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
|
||||
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
|
||||
|
||||
if (val)
|
||||
{
|
||||
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), TRUE );
|
||||
}
|
||||
else
|
||||
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_theOtherRadioButtton), TRUE );
|
||||
{
|
||||
// should give an assert
|
||||
}
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
|
||||
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
|
||||
}
|
||||
|
||||
bool wxRadioButton::GetValue() const
|
||||
|
@@ -44,6 +44,11 @@ void wxStaticBitmap::CreatePixmapWidget()
|
||||
mask = m_bitmap.GetMask()->GetBitmap();
|
||||
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
|
||||
|
||||
/* insert GTK representation */
|
||||
(*m_parent->m_insertCallback)(m_parent, this);
|
||||
|
||||
gtk_widget_show( m_widget );
|
||||
|
||||
PostCreation();
|
||||
}
|
||||
|
||||
@@ -61,7 +66,10 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
|
||||
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
CreatePixmapWidget();
|
||||
GdkBitmap *mask = (GdkBitmap *) NULL;
|
||||
if ( m_bitmap.GetMask() )
|
||||
mask = m_bitmap.GetMask()->GetBitmap();
|
||||
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
|
||||
|
||||
if (newSize.x == -1) newSize.x = m_bitmap.GetWidth();
|
||||
if (newSize.y == -1) newSize.y = m_bitmap.GetHeight();
|
||||
@@ -70,9 +78,9 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
|
||||
else
|
||||
{
|
||||
m_widget = gtk_label_new( "Bitmap" );
|
||||
}
|
||||
|
||||
PostCreation();
|
||||
PostCreation();
|
||||
}
|
||||
|
||||
m_parent->DoAddChild( this );
|
||||
|
||||
@@ -88,18 +96,22 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
|
||||
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
if ( !hasWidget )
|
||||
if (!hasWidget)
|
||||
{
|
||||
gtk_widget_destroy( m_widget );
|
||||
|
||||
// recreate m_widget because we'd created a label and not a bitmap
|
||||
// above
|
||||
/* recreate m_widget because we've created a label
|
||||
and not a bitmap above */
|
||||
CreatePixmapWidget();
|
||||
}
|
||||
|
||||
GdkBitmap *mask = (GdkBitmap *) NULL;
|
||||
if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
|
||||
gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
|
||||
else
|
||||
{
|
||||
GdkBitmap *mask = (GdkBitmap *) NULL;
|
||||
if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
|
||||
gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
|
||||
}
|
||||
|
||||
SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1799,6 +1799,7 @@ void wxWindow::Init()
|
||||
m_insertCallback = (wxInsertChildFunction) NULL;
|
||||
|
||||
m_isStaticBox = FALSE;
|
||||
m_isRadioButton = FALSE;
|
||||
m_acceptsFocus = FALSE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user