]>
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 | ||
47908e25 | 29 | void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) |
c801d85f | 30 | { |
c801d85f KB |
31 | wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); |
32 | event.SetEventObject(button); | |
47908e25 | 33 | button->GetEventHandler()->ProcessEvent(event); |
c801d85f KB |
34 | }; |
35 | ||
36 | //----------------------------------------------------------------------------- | |
37 | ||
38 | wxButton::wxButton(void) | |
39 | { | |
40 | }; | |
41 | ||
42 | wxButton::wxButton( wxWindow *parent, wxWindowID id, const wxString &label, | |
32c77a71 | 43 | const wxPoint &pos, const wxSize &size, |
debe6624 | 44 | long style, const wxString &name ) |
c801d85f KB |
45 | { |
46 | Create( parent, id, label, pos, size, style, name ); | |
47 | }; | |
48 | ||
49 | bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, | |
32c77a71 | 50 | const wxPoint &pos, const wxSize &size, |
debe6624 | 51 | long style, const wxString &name ) |
c801d85f KB |
52 | { |
53 | m_needParent = TRUE; | |
32c77a71 | 54 | |
c801d85f KB |
55 | wxSize newSize = size; |
56 | ||
57 | PreCreation( parent, id, pos, newSize, style, name ); | |
32c77a71 VZ |
58 | |
59 | SetLabel(label); | |
60 | m_widget = gtk_button_new_with_label( m_label ); | |
61 | ||
c801d85f KB |
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 ); | |
32c77a71 VZ |
65 | |
66 | gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", | |
c801d85f KB |
67 | GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); |
68 | ||
69 | PostCreation(); | |
32c77a71 | 70 | |
c801d85f | 71 | Show( TRUE ); |
32c77a71 | 72 | |
c801d85f KB |
73 | return TRUE; |
74 | }; | |
32c77a71 | 75 | |
c801d85f KB |
76 | void wxButton::SetDefault(void) |
77 | { | |
78 | }; | |
79 | ||
80 | void wxButton::SetLabel( const wxString &label ) | |
81 | { | |
82 | wxControl::SetLabel( label ); | |
83 | }; | |
84 | ||
85 | wxString wxButton::GetLabel(void) const | |
86 | { | |
87 | return wxControl::GetLabel(); | |
88 | }; |