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 extern bool g_blockEventsOnDrag
;
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 IMPLEMENT_DYNAMIC_CLASS(wxButton
,wxControl
)
35 static void gtk_button_clicked_callback( GtkWidget
*WXUNUSED(widget
), wxButton
*button
)
37 if (!button
->HasVMT()) return;
38 if (g_blockEventsOnDrag
) return;
40 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, button
->GetId());
41 event
.SetEventObject(button
);
42 button
->GetEventHandler()->ProcessEvent(event
);
45 //-----------------------------------------------------------------------------
47 wxButton::wxButton(void)
51 wxButton::wxButton( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
52 const wxPoint
&pos
, const wxSize
&size
,
53 long style
, const wxString
&name
)
55 Create( parent
, id
, label
, pos
, size
, style
, name
);
58 bool wxButton::Create( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
59 const wxPoint
&pos
, const wxSize
&size
,
60 long style
, const wxString
&name
)
64 wxSize newSize
= size
;
66 PreCreation( parent
, id
, pos
, newSize
, style
, name
);
69 m_widget
= gtk_button_new_with_label( m_label
);
71 if (newSize
.x
== -1) newSize
.x
= 15+gdk_string_measure( m_widget
->style
->font
, label
);
72 if (newSize
.y
== -1) newSize
.y
= 26;
73 SetSize( newSize
.x
, newSize
.y
);
75 gtk_signal_connect( GTK_OBJECT(m_widget
), "clicked",
76 GTK_SIGNAL_FUNC(gtk_button_clicked_callback
), (gpointer
*)this );
85 void wxButton::SetDefault(void)
89 void wxButton::SetLabel( const wxString
&label
)
91 wxControl::SetLabel( label
);
94 wxString
wxButton::GetLabel(void) const
96 return wxControl::GetLabel();