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:
Robert Roebling
1999-07-22 23:28:55 +00:00
parent 1e7fd31108
commit 953704c1c7
43 changed files with 502 additions and 141 deletions

View File

@@ -99,7 +99,8 @@ Returns TRUE if it is checked, FALSE otherwise.
\func{void}{SetValue}{\param{const bool}{ state}} \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} \wxheading{Parameters}

View File

@@ -183,7 +183,8 @@ This is implemented for Motif only.
\func{void}{SetSelection}{\param{int}{ n}} \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} \wxheading{Parameters}
@@ -197,7 +198,8 @@ Sets the choice by passing the desired string position.
\func{void}{SetStringSelection}{\param{const wxString\& }{ string}} \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} \wxheading{Parameters}

View File

@@ -295,7 +295,8 @@ Sets the insertion point at the end of the combobox text field.
\func{void}{SetSelection}{\param{int}{ n}} \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}{SetSelection}{\param{long}{ from}, \param{long}{ to}}

View File

@@ -338,7 +338,7 @@ Associates the given client data pointer with the given item.
\func{void}{SetFirstItem}{\param{const wxString\& }{string}} \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} \wxheading{Parameters}
@@ -350,7 +350,8 @@ Set the specified item to be the first visible item.
\func{void}{SetSelection}{\param{int}{ n}, \param{const bool }{select = TRUE}} \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} \wxheading{Parameters}
@@ -374,7 +375,8 @@ Sets the string value of an item.
\func{void}{SetStringSelection}{\param{const wxString\& }{ string}, \param{const bool}{ select = TRUE}} \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} \wxheading{Parameters}

View File

@@ -34,7 +34,7 @@ Retrieves the client data pointer associated with the node.
Retrieves the next node (NULL if at end of list). Retrieves the next node (NULL if at end of list).
\membersection{wxNodeBase::Previous} \membersection{wxNodeBase::GetPrevious}
\func{wxNodeBase *}{GetPrevious}{\void} \func{wxNodeBase *}{GetPrevious}{\void}

View File

@@ -219,7 +219,8 @@ implements the following methods:\par
\func{void}{SetSelection}{\param{int}{ n}} \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} \wxheading{Parameters}
@@ -229,7 +230,8 @@ Sets a button by passing the desired string position.
\func{void}{SetStringSelection}{\param{const wxString\& }{string}} \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{Parameters}

View File

@@ -16,7 +16,10 @@ exclusive options. It has a text label next to a (usually) round button.
\wxheading{Window styles} \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}. See also \helpref{window styles overview}{windowstyles}.
@@ -98,7 +101,8 @@ Returns TRUE if the radio button is depressed, FALSE otherwise.
\func{void}{SetValue}{\param{const bool}{ value}} \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} \wxheading{Parameters}

View File

@@ -128,7 +128,6 @@ wx_include_HEADERS = \
resource.h \ resource.h \
sashwin.h \ sashwin.h \
sckaddr.h \ sckaddr.h \
sckint.h \
sckipc.h \ sckipc.h \
sckstrm.h \ sckstrm.h \
scrolbar.h \ scrolbar.h \

View File

@@ -1421,6 +1421,7 @@ typedef int gint;
typedef unsigned guint; typedef unsigned guint;
typedef unsigned long gulong; typedef unsigned long gulong;
typedef void* gpointer; typedef void* gpointer;
typedef struct _GSList GSList;
/* Stand-ins for GDK types */ /* Stand-ins for GDK types */
typedef gulong GdkAtom; typedef gulong GdkAtom;

View File

@@ -71,7 +71,6 @@ public:
// implementation // implementation
void ApplyWidgetStyle(); void ApplyWidgetStyle();
bool m_blockFirstEvent;
GtkWidget *m_widgetCheckbox; GtkWidget *m_widgetCheckbox;
GtkWidget *m_widgetLabel; GtkWidget *m_widgetLabel;
}; };

View File

@@ -93,6 +93,8 @@ public:
wxList m_clientDataList; wxList m_clientDataList;
wxList m_clientObjectList; wxList m_clientObjectList;
void DisableEvents();
void EnableEvents();
void AppendCommon( const wxString &item ); void AppendCommon( const wxString &item );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
}; };

View File

@@ -117,6 +117,8 @@ public:
wxList m_clientDataList; wxList m_clientDataList;
wxList m_clientObjectList; wxList m_clientObjectList;
void DisableEvents();
void EnableEvents();
void AppendCommon( const wxString &item ); void AppendCommon( const wxString &item );
GtkWidget* GetConnectWidget(); GtkWidget* GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );

View File

@@ -109,6 +109,8 @@ public:
// implementation // implementation
void DisableEvents();
void EnableEvents();
void AppendCommon( const wxString &item ); void AppendCommon( const wxString &item );
int GetIndex( GtkWidget *item ) const; int GetIndex( GtkWidget *item ) const;
GtkWidget *GetConnectWidget(); GtkWidget *GetConnectWidget();

View File

@@ -96,6 +96,8 @@ public:
// implementation // implementation
void DisableEvents();
void EnableEvents();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
wxSize LayoutItems(); wxSize LayoutItems();

View File

@@ -41,36 +41,34 @@ extern const char* wxRadioButtonNameStr;
class wxRadioButton: public wxControl class wxRadioButton: public wxControl
{ {
DECLARE_DYNAMIC_CLASS(wxRadioButton) DECLARE_DYNAMIC_CLASS(wxRadioButton)
public: public:
inline wxRadioButton() {} inline wxRadioButton() {}
inline wxRadioButton( wxWindow *parent, wxWindowID id, inline wxRadioButton( wxWindow *parent, wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr ) const wxString& name = wxRadioButtonNameStr )
{ {
Create( parent, id, label, pos, size, style, validator, name ); 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 wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr ); const wxString& name = wxRadioButtonNameStr );
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;
bool Enable( bool enable ); bool Enable( bool enable );
// implementation // implementation
void ApplyWidgetStyle(); GSList *m_radioButtonGroup;
void ApplyWidgetStyle();
bool m_blockFirstEvent;
GtkWidget* m_theOtherRadioButtton;
}; };
#endif #endif

View File

@@ -187,6 +187,7 @@ public:
bool m_sizeSet:1; bool m_sizeSet:1;
bool m_resizing:1; bool m_resizing:1;
bool m_isStaticBox:1; /* faster than IS_KIND_OF */ 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_isFrame:1; /* faster than IS_KIND_OF */
bool m_acceptsFocus:1; /* ! wxStaticBox etc. */ bool m_acceptsFocus:1; /* ! wxStaticBox etc. */

View File

@@ -71,7 +71,6 @@ public:
// implementation // implementation
void ApplyWidgetStyle(); void ApplyWidgetStyle();
bool m_blockFirstEvent;
GtkWidget *m_widgetCheckbox; GtkWidget *m_widgetCheckbox;
GtkWidget *m_widgetLabel; GtkWidget *m_widgetLabel;
}; };

View File

@@ -93,6 +93,8 @@ public:
wxList m_clientDataList; wxList m_clientDataList;
wxList m_clientObjectList; wxList m_clientObjectList;
void DisableEvents();
void EnableEvents();
void AppendCommon( const wxString &item ); void AppendCommon( const wxString &item );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
}; };

View File

@@ -117,6 +117,8 @@ public:
wxList m_clientDataList; wxList m_clientDataList;
wxList m_clientObjectList; wxList m_clientObjectList;
void DisableEvents();
void EnableEvents();
void AppendCommon( const wxString &item ); void AppendCommon( const wxString &item );
GtkWidget* GetConnectWidget(); GtkWidget* GetConnectWidget();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );

View File

@@ -109,6 +109,8 @@ public:
// implementation // implementation
void DisableEvents();
void EnableEvents();
void AppendCommon( const wxString &item ); void AppendCommon( const wxString &item );
int GetIndex( GtkWidget *item ) const; int GetIndex( GtkWidget *item ) const;
GtkWidget *GetConnectWidget(); GtkWidget *GetConnectWidget();

View File

@@ -96,6 +96,8 @@ public:
// implementation // implementation
void DisableEvents();
void EnableEvents();
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle(); void ApplyWidgetStyle();
wxSize LayoutItems(); wxSize LayoutItems();

View File

@@ -41,36 +41,34 @@ extern const char* wxRadioButtonNameStr;
class wxRadioButton: public wxControl class wxRadioButton: public wxControl
{ {
DECLARE_DYNAMIC_CLASS(wxRadioButton) DECLARE_DYNAMIC_CLASS(wxRadioButton)
public: public:
inline wxRadioButton() {} inline wxRadioButton() {}
inline wxRadioButton( wxWindow *parent, wxWindowID id, inline wxRadioButton( wxWindow *parent, wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr ) const wxString& name = wxRadioButtonNameStr )
{ {
Create( parent, id, label, pos, size, style, validator, name ); 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 wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr ); const wxString& name = wxRadioButtonNameStr );
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;
bool Enable( bool enable ); bool Enable( bool enable );
// implementation // implementation
void ApplyWidgetStyle(); GSList *m_radioButtonGroup;
void ApplyWidgetStyle();
bool m_blockFirstEvent;
GtkWidget* m_theOtherRadioButtton;
}; };
#endif #endif

View File

@@ -187,6 +187,7 @@ public:
bool m_sizeSet:1; bool m_sizeSet:1;
bool m_resizing:1; bool m_resizing:1;
bool m_isStaticBox:1; /* faster than IS_KIND_OF */ 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_isFrame:1; /* faster than IS_KIND_OF */
bool m_acceptsFocus:1; /* ! wxStaticBox etc. */ bool m_acceptsFocus:1; /* ! wxStaticBox etc. */

View File

@@ -398,13 +398,16 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
(void)new wxButton( panel, ID_CHOICE_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); (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) ); (void)new wxCheckBox( panel, ID_CHOICE_ENABLE, "Disable", wxPoint(20,130), wxSize(140,30) );
/*
wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION); wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
wxSize sizeIcon = wxSize(icon.GetWidth(), icon.GetHeight()); wxSize sizeIcon = wxSize(icon.GetWidth(), icon.GetHeight());
(void)new wxStaticBitmap( panel, -1, icon, wxPoint(50, 60), sizeIcon);
wxStaticBitmap *bitmap = new wxStaticBitmap( panel, -1, icon, wxPoint(50, 60), sizeIcon); wxStaticBitmap *bitmap = new wxStaticBitmap( panel, -1, wxNullBitmap, wxPoint(10, 60), sizeIcon);
bitmap->SetBitmap(icon);
// this doesn't work under wxGTK */
bitmap = new wxStaticBitmap( panel, -1, wxNullBitmap, wxPoint(10, 60), sizeIcon); 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); bitmap->SetBitmap(icon);
m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice); m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
@@ -494,8 +497,8 @@ void MyPanel::OnPageChanging( wxNotebookEvent &event )
if ( selOld == 2 && selNew == 4 ) if ( selOld == 2 && selNew == 4 )
{ {
wxMessageBox("This demonstrates how a program may prevent the " wxMessageBox("This demonstrates how a program may prevent the "
"page change from taking place - the current page will " "page change from taking place - \n the current page will "
"stay the third one", "Conntrol sample", "stay the third one", "Control sample",
wxICON_INFORMATION | wxOK); wxICON_INFORMATION | wxOK);
event.Veto(); event.Veto();

View File

@@ -341,7 +341,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
ptr[poffset + 1] = cmap[aByte].g; ptr[poffset + 1] = cmap[aByte].g;
ptr[poffset + 2] = cmap[aByte].b; ptr[poffset + 2] = cmap[aByte].b;
column++; column++;
linepos += size; // linepos += size; seems to be wrong, RR
} }
} }
} }

View File

@@ -42,12 +42,6 @@ static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckB
if (!cb->m_hasVMT) return; if (!cb->m_hasVMT) return;
if (cb->m_blockFirstEvent)
{
cb->m_blockFirstEvent = FALSE;
return;
}
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId()); wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId());
@@ -80,8 +74,6 @@ bool wxCheckBox::Create(wxWindow *parent,
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_blockFirstEvent = FALSE;
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
SetValidator( validator ); SetValidator( validator );
#endif #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_widgetLabel, FALSE, FALSE, 3);
gtk_box_pack_start(GTK_BOX(m_widget), m_widgetCheckbox, 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_widgetLabel );
gtk_widget_show( m_widgetCheckbox ); gtk_widget_show( m_widgetCheckbox );
} }
@@ -146,14 +137,19 @@ void wxCheckBox::SetValue( bool state )
{ {
wxCHECK_RET( m_widgetCheckbox != NULL, _T("invalid checkbox") ); wxCHECK_RET( m_widgetCheckbox != NULL, _T("invalid checkbox") );
if ( state == GetValue() ) if (state == GetValue())
return; return;
// for compatibility with wxMSW don't send notification when the check box gtk_signal_disconnect_by_func( GTK_OBJECT(m_widgetCheckbox),
// state is changed programmatically GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback),
m_blockFirstEvent = TRUE; (gpointer *)this );
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widgetCheckbox), state ); 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 bool wxCheckBox::GetValue() const

View File

@@ -355,8 +355,6 @@ void wxChoice::SetSelection( int n )
int tmp = n; int tmp = n;
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); 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 ) void wxChoice::SetStringSelection( const wxString &string )
@@ -367,6 +365,36 @@ void wxChoice::SetStringSelection( const wxString &string )
if (n != -1) SetSelection( n ); 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() void wxChoice::ApplyWidgetStyle()
{ {
SetWidgetStyle(); SetWidgetStyle();

View File

@@ -422,8 +422,12 @@ void wxComboBox::SetSelection( int n )
{ {
wxCHECK_RET( m_widget != NULL, _T("invalid combobox") ); wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
DisableEvents();
GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_select_item( GTK_LIST(list), n ); gtk_list_select_item( GTK_LIST(list), n );
EnableEvents();
} }
void wxComboBox::SetStringSelection( const wxString &string ) void wxComboBox::SetStringSelection( const wxString &string )
@@ -586,6 +590,32 @@ void wxComboBox::OnChar( wxKeyEvent &event )
event.Skip(); 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 ) void wxComboBox::OnSize( wxSizeEvent &event )
{ {
event.Skip(); event.Skip();

View File

@@ -939,6 +939,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
} }
} }
#if (GTK_MINOR_VERSION > 0)
if (req_dash && req_nb_dash) if (req_dash && req_nb_dash)
{ {
char *real_req_dash = new char[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 ); gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
} }
} }
#endif
GdkCapStyle capStyle = GDK_CAP_ROUND; GdkCapStyle capStyle = GDK_CAP_ROUND;
switch (m_pen.GetCap()) switch (m_pen.GetCap())

View File

@@ -640,7 +640,11 @@ void wxListBox::Deselect( int n )
{ {
wxCHECK_RET( m_list != NULL, _T("invalid listbox") ); wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
DisableEvents();
gtk_list_unselect_item( m_list, n ); gtk_list_unselect_item( m_list, n );
EnableEvents();
} }
int wxListBox::FindString( const wxString &item ) const 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") ); wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
DisableEvents();
if (select) if (select)
gtk_list_select_item( m_list, n ); gtk_list_select_item( m_list, n );
else else
gtk_list_unselect_item( m_list, n ); gtk_list_unselect_item( m_list, n );
EnableEvents();
} }
void wxListBox::SetString( int n, const wxString &string ) 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; GList *child = m_list->children;
while (child) 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; child = child->next;
} }
} }
@@ -898,6 +906,38 @@ void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
} }
#endif #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() GtkWidget *wxListBox::GetConnectWidget()
{ {
return GTK_WIDGET(m_list); return GTK_WIDGET(m_list);

View File

@@ -328,7 +328,11 @@ void wxRadioBox::SetSelection( int n )
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
DisableEvents();
gtk_toggle_button_set_state( button, 1 ); gtk_toggle_button_set_state( button, 1 );
EnableEvents();
} }
int wxRadioBox::GetSelection(void) const int wxRadioBox::GetSelection(void) const
@@ -494,6 +498,30 @@ void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) )
wxFAIL_MSG(_T("wxRadioBox::SetNumberOfRowsOrCols not implemented.")); 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() void wxRadioBox::ApplyWidgetStyle()
{ {
SetWidgetStyle(); SetWidgetStyle();

View File

@@ -43,12 +43,6 @@ void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioButto
if (!rb->m_hasVMT) return; if (!rb->m_hasVMT) return;
if (rb->m_blockFirstEvent)
{
rb->m_blockFirstEvent = FALSE;
return;
}
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
wxCommandEvent event( wxEVT_COMMAND_RADIOBUTTON_SELECTED, rb->GetId()); wxCommandEvent event( wxEVT_COMMAND_RADIOBUTTON_SELECTED, rb->GetId());
@@ -74,21 +68,49 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab
PreCreation( parent, id, pos, newSize, style, name ); PreCreation( parent, id, pos, newSize, style, name );
m_isRadioButton = TRUE;
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
SetValidator( validator ); SetValidator( validator );
#endif #endif
m_widget = gtk_radio_button_new_with_label( (GSList *) NULL, label.mbc_str() );
m_theOtherRadioButtton = if (HasFlag(wxRB_GROUP))
gtk_radio_button_new_with_label( {
gtk_radio_button_group( GTK_RADIO_BUTTON(m_widget) ), /* start a new group */
"button2" ); 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() );
SetLabel(label); SetLabel(label);
m_blockFirstEvent = FALSE;
if (newSize.x == -1) newSize.x = 22+gdk_string_measure( m_widget->style->font, label.mbc_str() ); if (newSize.x == -1) newSize.x = 22+gdk_string_measure( m_widget->style->font, label.mbc_str() );
if (newSize.y == -1) newSize.y = 26; if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
@@ -123,15 +145,23 @@ void wxRadioButton::SetValue( bool val )
{ {
wxCHECK_RET( m_widget != NULL, _T("invalid radiobutton") ); wxCHECK_RET( m_widget != NULL, _T("invalid radiobutton") );
if ( val == GetValue() ) if (val == GetValue())
return; return;
m_blockFirstEvent = TRUE; gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
if (val) if (val)
{
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), TRUE ); gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), TRUE );
}
else 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 bool wxRadioButton::GetValue() const

View File

@@ -44,6 +44,11 @@ void wxStaticBitmap::CreatePixmapWidget()
mask = m_bitmap.GetMask()->GetBitmap(); mask = m_bitmap.GetMask()->GetBitmap();
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); 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(); PostCreation();
} }
@@ -61,7 +66,10 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
if (m_bitmap.Ok()) 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.x == -1) newSize.x = m_bitmap.GetWidth();
if (newSize.y == -1) newSize.y = m_bitmap.GetHeight(); if (newSize.y == -1) newSize.y = m_bitmap.GetHeight();
@@ -70,9 +78,9 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
else else
{ {
m_widget = gtk_label_new( "Bitmap" ); m_widget = gtk_label_new( "Bitmap" );
}
PostCreation(); PostCreation();
}
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
@@ -88,18 +96,22 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
if (m_bitmap.Ok()) if (m_bitmap.Ok())
{ {
if ( !hasWidget ) if (!hasWidget)
{ {
gtk_widget_destroy( m_widget ); gtk_widget_destroy( m_widget );
// recreate m_widget because we'd created a label and not a bitmap /* recreate m_widget because we've created a label
// above and not a bitmap above */
CreatePixmapWidget(); CreatePixmapWidget();
} }
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 );
}
GdkBitmap *mask = (GdkBitmap *) NULL; SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
} }
} }

View File

@@ -1799,6 +1799,7 @@ void wxWindow::Init()
m_insertCallback = (wxInsertChildFunction) NULL; m_insertCallback = (wxInsertChildFunction) NULL;
m_isStaticBox = FALSE; m_isStaticBox = FALSE;
m_isRadioButton = FALSE;
m_acceptsFocus = FALSE; m_acceptsFocus = FALSE;
} }

View File

@@ -42,12 +42,6 @@ static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckB
if (!cb->m_hasVMT) return; if (!cb->m_hasVMT) return;
if (cb->m_blockFirstEvent)
{
cb->m_blockFirstEvent = FALSE;
return;
}
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId()); wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId());
@@ -80,8 +74,6 @@ bool wxCheckBox::Create(wxWindow *parent,
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_blockFirstEvent = FALSE;
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
SetValidator( validator ); SetValidator( validator );
#endif #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_widgetLabel, FALSE, FALSE, 3);
gtk_box_pack_start(GTK_BOX(m_widget), m_widgetCheckbox, 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_widgetLabel );
gtk_widget_show( m_widgetCheckbox ); gtk_widget_show( m_widgetCheckbox );
} }
@@ -146,14 +137,19 @@ void wxCheckBox::SetValue( bool state )
{ {
wxCHECK_RET( m_widgetCheckbox != NULL, _T("invalid checkbox") ); wxCHECK_RET( m_widgetCheckbox != NULL, _T("invalid checkbox") );
if ( state == GetValue() ) if (state == GetValue())
return; return;
// for compatibility with wxMSW don't send notification when the check box gtk_signal_disconnect_by_func( GTK_OBJECT(m_widgetCheckbox),
// state is changed programmatically GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback),
m_blockFirstEvent = TRUE; (gpointer *)this );
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widgetCheckbox), state ); 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 bool wxCheckBox::GetValue() const

View File

@@ -355,8 +355,6 @@ void wxChoice::SetSelection( int n )
int tmp = n; int tmp = n;
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); 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 ) void wxChoice::SetStringSelection( const wxString &string )
@@ -367,6 +365,36 @@ void wxChoice::SetStringSelection( const wxString &string )
if (n != -1) SetSelection( n ); 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() void wxChoice::ApplyWidgetStyle()
{ {
SetWidgetStyle(); SetWidgetStyle();

View File

@@ -422,8 +422,12 @@ void wxComboBox::SetSelection( int n )
{ {
wxCHECK_RET( m_widget != NULL, _T("invalid combobox") ); wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
DisableEvents();
GtkWidget *list = GTK_COMBO(m_widget)->list; GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_select_item( GTK_LIST(list), n ); gtk_list_select_item( GTK_LIST(list), n );
EnableEvents();
} }
void wxComboBox::SetStringSelection( const wxString &string ) void wxComboBox::SetStringSelection( const wxString &string )
@@ -586,6 +590,32 @@ void wxComboBox::OnChar( wxKeyEvent &event )
event.Skip(); 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 ) void wxComboBox::OnSize( wxSizeEvent &event )
{ {
event.Skip(); event.Skip();

View File

@@ -939,6 +939,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
} }
} }
#if (GTK_MINOR_VERSION > 0)
if (req_dash && req_nb_dash) if (req_dash && req_nb_dash)
{ {
char *real_req_dash = new char[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 ); gdk_gc_set_dashes( m_penGC, 0, (char*)req_dash, req_nb_dash );
} }
} }
#endif
GdkCapStyle capStyle = GDK_CAP_ROUND; GdkCapStyle capStyle = GDK_CAP_ROUND;
switch (m_pen.GetCap()) switch (m_pen.GetCap())

View File

@@ -640,7 +640,11 @@ void wxListBox::Deselect( int n )
{ {
wxCHECK_RET( m_list != NULL, _T("invalid listbox") ); wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
DisableEvents();
gtk_list_unselect_item( m_list, n ); gtk_list_unselect_item( m_list, n );
EnableEvents();
} }
int wxListBox::FindString( const wxString &item ) const 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") ); wxCHECK_RET( m_list != NULL, _T("invalid listbox") );
DisableEvents();
if (select) if (select)
gtk_list_select_item( m_list, n ); gtk_list_select_item( m_list, n );
else else
gtk_list_unselect_item( m_list, n ); gtk_list_unselect_item( m_list, n );
EnableEvents();
} }
void wxListBox::SetString( int n, const wxString &string ) 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; GList *child = m_list->children;
while (child) 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; child = child->next;
} }
} }
@@ -898,6 +906,38 @@ void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
} }
#endif #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() GtkWidget *wxListBox::GetConnectWidget()
{ {
return GTK_WIDGET(m_list); return GTK_WIDGET(m_list);

View File

@@ -328,7 +328,11 @@ void wxRadioBox::SetSelection( int n )
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
DisableEvents();
gtk_toggle_button_set_state( button, 1 ); gtk_toggle_button_set_state( button, 1 );
EnableEvents();
} }
int wxRadioBox::GetSelection(void) const int wxRadioBox::GetSelection(void) const
@@ -494,6 +498,30 @@ void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) )
wxFAIL_MSG(_T("wxRadioBox::SetNumberOfRowsOrCols not implemented.")); 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() void wxRadioBox::ApplyWidgetStyle()
{ {
SetWidgetStyle(); SetWidgetStyle();

View File

@@ -43,12 +43,6 @@ void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioButto
if (!rb->m_hasVMT) return; if (!rb->m_hasVMT) return;
if (rb->m_blockFirstEvent)
{
rb->m_blockFirstEvent = FALSE;
return;
}
if (g_blockEventsOnDrag) return; if (g_blockEventsOnDrag) return;
wxCommandEvent event( wxEVT_COMMAND_RADIOBUTTON_SELECTED, rb->GetId()); wxCommandEvent event( wxEVT_COMMAND_RADIOBUTTON_SELECTED, rb->GetId());
@@ -74,21 +68,49 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab
PreCreation( parent, id, pos, newSize, style, name ); PreCreation( parent, id, pos, newSize, style, name );
m_isRadioButton = TRUE;
#if wxUSE_VALIDATORS #if wxUSE_VALIDATORS
SetValidator( validator ); SetValidator( validator );
#endif #endif
m_widget = gtk_radio_button_new_with_label( (GSList *) NULL, label.mbc_str() );
m_theOtherRadioButtton = if (HasFlag(wxRB_GROUP))
gtk_radio_button_new_with_label( {
gtk_radio_button_group( GTK_RADIO_BUTTON(m_widget) ), /* start a new group */
"button2" ); 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() );
SetLabel(label); SetLabel(label);
m_blockFirstEvent = FALSE;
if (newSize.x == -1) newSize.x = 22+gdk_string_measure( m_widget->style->font, label.mbc_str() ); if (newSize.x == -1) newSize.x = 22+gdk_string_measure( m_widget->style->font, label.mbc_str() );
if (newSize.y == -1) newSize.y = 26; if (newSize.y == -1) newSize.y = 26;
SetSize( newSize.x, newSize.y ); SetSize( newSize.x, newSize.y );
@@ -123,15 +145,23 @@ void wxRadioButton::SetValue( bool val )
{ {
wxCHECK_RET( m_widget != NULL, _T("invalid radiobutton") ); wxCHECK_RET( m_widget != NULL, _T("invalid radiobutton") );
if ( val == GetValue() ) if (val == GetValue())
return; return;
m_blockFirstEvent = TRUE; gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
if (val) if (val)
{
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), TRUE ); gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget), TRUE );
}
else 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 bool wxRadioButton::GetValue() const

View File

@@ -44,6 +44,11 @@ void wxStaticBitmap::CreatePixmapWidget()
mask = m_bitmap.GetMask()->GetBitmap(); mask = m_bitmap.GetMask()->GetBitmap();
m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); 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(); PostCreation();
} }
@@ -61,7 +66,10 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
if (m_bitmap.Ok()) 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.x == -1) newSize.x = m_bitmap.GetWidth();
if (newSize.y == -1) newSize.y = m_bitmap.GetHeight(); if (newSize.y == -1) newSize.y = m_bitmap.GetHeight();
@@ -70,9 +78,9 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
else else
{ {
m_widget = gtk_label_new( "Bitmap" ); m_widget = gtk_label_new( "Bitmap" );
}
PostCreation(); PostCreation();
}
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );
@@ -88,18 +96,22 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
if (m_bitmap.Ok()) if (m_bitmap.Ok())
{ {
if ( !hasWidget ) if (!hasWidget)
{ {
gtk_widget_destroy( m_widget ); gtk_widget_destroy( m_widget );
// recreate m_widget because we'd created a label and not a bitmap /* recreate m_widget because we've created a label
// above and not a bitmap above */
CreatePixmapWidget(); CreatePixmapWidget();
} }
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 );
}
GdkBitmap *mask = (GdkBitmap *) NULL; SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
} }
} }

View File

@@ -1799,6 +1799,7 @@ void wxWindow::Init()
m_insertCallback = (wxInsertChildFunction) NULL; m_insertCallback = (wxInsertChildFunction) NULL;
m_isStaticBox = FALSE; m_isStaticBox = FALSE;
m_isRadioButton = FALSE;
m_acceptsFocus = FALSE; m_acceptsFocus = FALSE;
} }