]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: button.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
6 | // Id: | |
7 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifdef __GNUG__ | |
12 | #pragma implementation "button.h" | |
13 | #endif | |
14 | ||
15 | #include "wx/button.h" | |
16 | ||
17 | //----------------------------------------------------------------------------- | |
18 | // classes | |
19 | //----------------------------------------------------------------------------- | |
20 | ||
21 | class wxButton; | |
22 | ||
23 | //----------------------------------------------------------------------------- | |
24 | // wxButton | |
25 | //----------------------------------------------------------------------------- | |
26 | ||
27 | IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) | |
28 | ||
29 | void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) | |
30 | { | |
31 | wxButton *button = (wxButton*)data; | |
32 | wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); | |
33 | event.SetEventObject(button); | |
34 | button->ProcessEvent(event); | |
35 | }; | |
36 | ||
37 | //----------------------------------------------------------------------------- | |
38 | ||
39 | wxButton::wxButton(void) | |
40 | { | |
41 | }; | |
42 | ||
43 | wxButton::wxButton( wxWindow *parent, wxWindowID id, const wxString &label, | |
44 | const wxPoint &pos, const wxSize &size, | |
debe6624 | 45 | long style, const wxString &name ) |
c801d85f KB |
46 | { |
47 | Create( parent, id, label, pos, size, style, name ); | |
48 | }; | |
49 | ||
50 | bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, | |
51 | const wxPoint &pos, const wxSize &size, | |
debe6624 | 52 | long style, const wxString &name ) |
c801d85f KB |
53 | { |
54 | m_needParent = TRUE; | |
55 | ||
56 | wxSize newSize = size; | |
57 | ||
58 | PreCreation( parent, id, pos, newSize, style, name ); | |
59 | ||
60 | m_label = label; | |
61 | m_widget = gtk_button_new_with_label( label ); | |
62 | ||
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 ); | |
66 | ||
67 | gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", | |
68 | GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); | |
69 | ||
70 | PostCreation(); | |
71 | ||
72 | Show( TRUE ); | |
73 | ||
74 | return TRUE; | |
75 | }; | |
76 | ||
77 | void wxButton::SetDefault(void) | |
78 | { | |
79 | }; | |
80 | ||
81 | void wxButton::SetLabel( const wxString &label ) | |
82 | { | |
83 | wxControl::SetLabel( label ); | |
84 | }; | |
85 | ||
86 | wxString wxButton::GetLabel(void) const | |
87 | { | |
88 | return wxControl::GetLabel(); | |
89 | }; |