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
), gpointer data
)
31 wxButton
*button
= (wxButton
*)data
;
32 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, button
->GetId());
33 event
.SetEventObject(button
);
34 button
->ProcessEvent(event
);
37 //-----------------------------------------------------------------------------
39 wxButton::wxButton(void)
43 wxButton::wxButton( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
44 const wxPoint
&pos
, const wxSize
&size
,
45 long style
, const wxString
&name
)
47 Create( parent
, id
, label
, pos
, size
, style
, name
);
50 bool wxButton::Create( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
51 const wxPoint
&pos
, const wxSize
&size
,
52 long style
, const wxString
&name
)
56 wxSize newSize
= size
;
58 PreCreation( parent
, id
, pos
, newSize
, style
, name
);
61 m_widget
= gtk_button_new_with_label( label
);
63 if (newSize
.x
== -1) newSize
.x
= 15+gdk_string_measure( m_widget
->style
->font
, label
);
64 if (newSize
.y
== -1) newSize
.y
= 26;
65 SetSize( newSize
.x
, newSize
.y
);
67 gtk_signal_connect( GTK_OBJECT(m_widget
), "clicked",
68 GTK_SIGNAL_FUNC(gtk_button_clicked_callback
), (gpointer
*)this );
77 void wxButton::SetDefault(void)
81 void wxButton::SetLabel( const wxString
&label
)
83 wxControl::SetLabel( label
);
86 wxString
wxButton::GetLabel(void) const
88 return wxControl::GetLabel();