\func{void}{SetValue}{\param{const bool}{ state}}
-Sets the checkbox to the given state.
+Sets the checkbox to the given state. This does not cause a
+wxEVT\_COMMAND\_CHECKBOX\_CLICKED event to get emitted.
\wxheading{Parameters}
\func{void}{SetSelection}{\param{int}{ n}}
-Sets the choice by passing the desired string position.
+Sets the choice by passing the desired string position. This does not cause
+a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted.
\wxheading{Parameters}
\func{void}{SetStringSelection}{\param{const wxString\& }{ string}}
-Sets the choice by passing the desired string.
+Sets the choice by passing the desired string. This does not cause
+a wxEVT\_COMMAND\_CHOICE\_SELECTED event to get emitted.
\wxheading{Parameters}
\func{void}{SetSelection}{\param{int}{ n}}
-Selects the given item in the combobox list.
+Selects the given item in the combobox list. This does not cause a
+wxEVT\_COMMAND\_COMBOBOX\_SELECTED event to get emitted.
\func{void}{SetSelection}{\param{long}{ from}, \param{long}{ to}}
\func{void}{SetFirstItem}{\param{const wxString\& }{string}}
-Set the specified item to be the first visible item.
+Set the specified item to be the first visible item. Windows only.
\wxheading{Parameters}
\func{void}{SetSelection}{\param{int}{ n}, \param{const bool }{select = TRUE}}
-Selects or deselects the given item.
+Selects or deselects the given item. This does not cause a
+wxEVT\_COMMAND\_LISTBOX\_SELECT event to get emitted.
\wxheading{Parameters}
\func{void}{SetStringSelection}{\param{const wxString\& }{ string}, \param{const bool}{ select = TRUE}}
-Sets the current selection.
+Sets the current selection. This does not cause a
+wxEVT\_COMMAND\_LISTBOX\_SELECT event to get emitted.
\wxheading{Parameters}
Retrieves the next node (NULL if at end of list).
-\membersection{wxNodeBase::Previous}
+\membersection{wxNodeBase::GetPrevious}
\func{wxNodeBase *}{GetPrevious}{\void}
\func{void}{SetSelection}{\param{int}{ n}}
-Sets a button by passing the desired string position.
+Sets a button by passing the desired string position. This does not cause
+a wxEVT\_COMMAND\_RADIOBOX\_SELECTED event to get emitted.
\wxheading{Parameters}
\func{void}{SetStringSelection}{\param{const wxString\& }{string}}
-Sets a button by passing the desired string.
+Sets the selection to a button by passing the desired string. This does not cause
+a wxEVT\_COMMAND\_RADIOBOX\_SELECTED event to get emitted.
\wxheading{Parameters}
\wxheading{Window styles}
-There are no specific styles for this class.
+\twocolwidtha{5cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{\windowstyle{wxRB\_GROUP}}{Marks the beginning of a new group of radio buttons.}
+\end{twocollist}
See also \helpref{window styles overview}{windowstyles}.
\func{void}{SetValue}{\param{const bool}{ value}}
-Sets the radio button to selected or deselected status.
+Sets the radio button to selected or deselected status. This does not cause a
+wxEVT\_COMMAND\_RADIOBUTTON\_SELECTED event to get emitted.
\wxheading{Parameters}
resource.h \
sashwin.h \
sckaddr.h \
- sckint.h \
sckipc.h \
sckstrm.h \
scrolbar.h \
typedef unsigned guint;
typedef unsigned long gulong;
typedef void* gpointer;
+typedef struct _GSList GSList;
/* Stand-ins for GDK types */
typedef gulong GdkAtom;
// implementation
void ApplyWidgetStyle();
- bool m_blockFirstEvent;
GtkWidget *m_widgetCheckbox;
GtkWidget *m_widgetLabel;
};
wxList m_clientDataList;
wxList m_clientObjectList;
+ void DisableEvents();
+ void EnableEvents();
void AppendCommon( const wxString &item );
void ApplyWidgetStyle();
};
wxList m_clientDataList;
wxList m_clientObjectList;
+ void DisableEvents();
+ void EnableEvents();
void AppendCommon( const wxString &item );
GtkWidget* GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window );
// implementation
+ void DisableEvents();
+ void EnableEvents();
void AppendCommon( const wxString &item );
int GetIndex( GtkWidget *item ) const;
GtkWidget *GetConnectWidget();
// implementation
+ void DisableEvents();
+ void EnableEvents();
bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle();
wxSize LayoutItems();
class wxRadioButton: public wxControl
{
- DECLARE_DYNAMIC_CLASS(wxRadioButton)
+DECLARE_DYNAMIC_CLASS(wxRadioButton)
- public:
- inline wxRadioButton() {}
- inline wxRadioButton( wxWindow *parent, wxWindowID id,
+public:
+ inline wxRadioButton() {}
+ inline wxRadioButton( wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr )
- {
+ {
Create( parent, id, label, pos, size, style, validator, name );
- }
- bool Create(wxWindow *parent, wxWindowID id,
+ }
+ bool Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr );
- virtual void SetLabel(const wxString& label);
- virtual void SetValue(bool val);
- virtual bool GetValue() const;
- bool Enable( bool enable );
+ virtual void SetLabel(const wxString& label);
+ virtual void SetValue(bool val);
+ virtual bool GetValue() const;
+ bool Enable( bool enable );
// implementation
- void ApplyWidgetStyle();
-
- bool m_blockFirstEvent;
- GtkWidget* m_theOtherRadioButtton;
+ GSList *m_radioButtonGroup;
+ void ApplyWidgetStyle();
};
#endif
bool m_sizeSet:1;
bool m_resizing:1;
bool m_isStaticBox:1; /* faster than IS_KIND_OF */
+ bool m_isRadioButton:1; /* faster than IS_KIND_OF */
bool m_isFrame:1; /* faster than IS_KIND_OF */
bool m_acceptsFocus:1; /* ! wxStaticBox etc. */
// implementation
void ApplyWidgetStyle();
- bool m_blockFirstEvent;
GtkWidget *m_widgetCheckbox;
GtkWidget *m_widgetLabel;
};
wxList m_clientDataList;
wxList m_clientObjectList;
+ void DisableEvents();
+ void EnableEvents();
void AppendCommon( const wxString &item );
void ApplyWidgetStyle();
};
wxList m_clientDataList;
wxList m_clientObjectList;
+ void DisableEvents();
+ void EnableEvents();
void AppendCommon( const wxString &item );
GtkWidget* GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window );
// implementation
+ void DisableEvents();
+ void EnableEvents();
void AppendCommon( const wxString &item );
int GetIndex( GtkWidget *item ) const;
GtkWidget *GetConnectWidget();
// implementation
+ void DisableEvents();
+ void EnableEvents();
bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle();
wxSize LayoutItems();
class wxRadioButton: public wxControl
{
- DECLARE_DYNAMIC_CLASS(wxRadioButton)
+DECLARE_DYNAMIC_CLASS(wxRadioButton)
- public:
- inline wxRadioButton() {}
- inline wxRadioButton( wxWindow *parent, wxWindowID id,
+public:
+ inline wxRadioButton() {}
+ inline wxRadioButton( wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr )
- {
+ {
Create( parent, id, label, pos, size, style, validator, name );
- }
- bool Create(wxWindow *parent, wxWindowID id,
+ }
+ bool Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr );
- virtual void SetLabel(const wxString& label);
- virtual void SetValue(bool val);
- virtual bool GetValue() const;
- bool Enable( bool enable );
+ virtual void SetLabel(const wxString& label);
+ virtual void SetValue(bool val);
+ virtual bool GetValue() const;
+ bool Enable( bool enable );
// implementation
- void ApplyWidgetStyle();
-
- bool m_blockFirstEvent;
- GtkWidget* m_theOtherRadioButtton;
+ GSList *m_radioButtonGroup;
+ void ApplyWidgetStyle();
};
#endif
bool m_sizeSet:1;
bool m_resizing:1;
bool m_isStaticBox:1; /* faster than IS_KIND_OF */
+ bool m_isRadioButton:1; /* faster than IS_KIND_OF */
bool m_isFrame:1; /* faster than IS_KIND_OF */
bool m_acceptsFocus:1; /* ! wxStaticBox etc. */
(void)new wxButton( panel, ID_CHOICE_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) );
(void)new wxCheckBox( panel, ID_CHOICE_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
+/*
wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
wxSize sizeIcon = wxSize(icon.GetWidth(), icon.GetHeight());
-
- wxStaticBitmap *bitmap = new wxStaticBitmap( panel, -1, icon, wxPoint(50, 60), sizeIcon);
-
- // this doesn't work under wxGTK
- bitmap = new wxStaticBitmap( panel, -1, wxNullBitmap, wxPoint(10, 60), sizeIcon);
+ (void)new wxStaticBitmap( panel, -1, icon, wxPoint(50, 60), sizeIcon);
+ wxStaticBitmap *bitmap = new wxStaticBitmap( panel, -1, wxNullBitmap, wxPoint(10, 60), sizeIcon);
+ bitmap->SetBitmap(icon);
+*/
+ wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
+ (void)new wxStaticBitmap( panel, -1, icon, wxPoint(50, 60) );
+ wxStaticBitmap *bitmap = new wxStaticBitmap( panel, -1, wxNullBitmap, wxPoint(10, 60) );
bitmap->SetBitmap(icon);
m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
if ( selOld == 2 && selNew == 4 )
{
wxMessageBox("This demonstrates how a program may prevent the "
- "page change from taking place - the current page will "
- "stay the third one", "Conntrol sample",
+ "page change from taking place - \n the current page will "
+ "stay the third one", "Control sample",
wxICON_INFORMATION | wxOK);
event.Veto();
ptr[poffset + 1] = cmap[aByte].g;
ptr[poffset + 2] = cmap[aByte].b;
column++;
- linepos += size;
+ // linepos += size; seems to be wrong, RR
}
}
}
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());
PreCreation( parent, id, pos, size, style, name );
- m_blockFirstEvent = FALSE;
-
#if wxUSE_VALIDATORS
SetValidator( validator );
#endif
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 );
}
{
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
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 )
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();
{
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 )
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();
}
}
+#if (GTK_MINOR_VERSION > 0)
if (req_dash && req_nb_dash)
{
char *real_req_dash = new char[req_nb_dash];
gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
}
}
+#endif
GdkCapStyle capStyle = GDK_CAP_ROUND;
switch (m_pen.GetCap())
{
wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
+ DisableEvents();
+
gtk_list_unselect_item( m_list, n );
+
+ EnableEvents();
}
int wxListBox::FindString( const wxString &item ) const
{
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 )
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;
}
}
}
#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);
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
+ DisableEvents();
+
gtk_toggle_button_set_state( button, 1 );
+
+ EnableEvents();
}
int wxRadioBox::GetSelection(void) const
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();
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());
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 );
{
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
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();
}
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();
else
{
m_widget = gtk_label_new( "Bitmap" );
- }
- PostCreation();
+ PostCreation();
+ }
m_parent->DoAddChild( this );
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() );
}
}
m_insertCallback = (wxInsertChildFunction) NULL;
m_isStaticBox = FALSE;
+ m_isRadioButton = FALSE;
m_acceptsFocus = FALSE;
}
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());
PreCreation( parent, id, pos, size, style, name );
- m_blockFirstEvent = FALSE;
-
#if wxUSE_VALIDATORS
SetValidator( validator );
#endif
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 );
}
{
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
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 )
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();
{
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 )
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();
}
}
+#if (GTK_MINOR_VERSION > 0)
if (req_dash && req_nb_dash)
{
char *real_req_dash = new char[req_nb_dash];
gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
}
}
+#endif
GdkCapStyle capStyle = GDK_CAP_ROUND;
switch (m_pen.GetCap())
{
wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
+ DisableEvents();
+
gtk_list_unselect_item( m_list, n );
+
+ EnableEvents();
}
int wxListBox::FindString( const wxString &item ) const
{
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 )
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;
}
}
}
#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);
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
+ DisableEvents();
+
gtk_toggle_button_set_state( button, 1 );
+
+ EnableEvents();
}
int wxRadioBox::GetSelection(void) const
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();
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());
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 );
{
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
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();
}
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();
else
{
m_widget = gtk_label_new( "Bitmap" );
- }
- PostCreation();
+ PostCreation();
+ }
m_parent->DoAddChild( this );
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() );
}
}
m_insertCallback = (wxInsertChildFunction) NULL;
m_isStaticBox = FALSE;
+ m_isRadioButton = FALSE;
m_acceptsFocus = FALSE;
}