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