1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "button.h"
15 #include "wx/button.h"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 IMPLEMENT_DYNAMIC_CLASS(wxButton
,wxControl
)
29 void gtk_button_clicked_callback( GtkWidget
*WXUNUSED(widget
), wxButton
*button
)
31 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, button
->GetId());
32 event
.SetEventObject(button
);
33 button
->GetEventHandler()->ProcessEvent(event
);
36 //-----------------------------------------------------------------------------
38 wxButton::wxButton(void)
42 wxButton::wxButton( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
43 const wxPoint
&pos
, const wxSize
&size
,
44 long style
, const wxString
&name
)
46 Create( parent
, id
, label
, pos
, size
, style
, name
);
49 bool wxButton::Create( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
50 const wxPoint
&pos
, const wxSize
&size
,
51 long style
, const wxString
&name
)
55 wxSize newSize
= size
;
57 PreCreation( parent
, id
, pos
, newSize
, style
, name
);
60 m_widget
= gtk_button_new_with_label( m_label
);
62 if (newSize
.x
== -1) newSize
.x
= 15+gdk_string_measure( m_widget
->style
->font
, label
);
63 if (newSize
.y
== -1) newSize
.y
= 26;
64 SetSize( newSize
.x
, newSize
.y
);
66 gtk_signal_connect( GTK_OBJECT(m_widget
), "clicked",
67 GTK_SIGNAL_FUNC(gtk_button_clicked_callback
), (gpointer
*)this );
76 void wxButton::SetDefault(void)
80 void wxButton::SetLabel( const wxString
&label
)
82 wxControl::SetLabel( label
);
85 wxString
wxButton::GetLabel(void) const
87 return wxControl::GetLabel();