]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/bmpbuttn.cpp
wxConfig -> wxConfigBase renaming plus some minor changes
[wxWidgets.git] / src / gtk / bmpbuttn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: bmpbuttn.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 "bmpbuttn.h"
13 #endif
14
15 #include "wx/bmpbuttn.h"
16
17 //-----------------------------------------------------------------------------
18 // classes
19 //-----------------------------------------------------------------------------
20
21 class wxBitmapButton;
22
23 //-----------------------------------------------------------------------------
24 // data
25 //-----------------------------------------------------------------------------
26
27 extern bool g_blockEventsOnDrag;
28
29 //-----------------------------------------------------------------------------
30 // wxBitmapButton
31 //-----------------------------------------------------------------------------
32
33 IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl)
34
35 static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button )
36 {
37 if (!button->HasVMT()) return;
38 if (g_blockEventsOnDrag) return;
39
40 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
41 event.SetEventObject(button);
42 button->GetEventHandler()->ProcessEvent(event);
43 };
44
45 //-----------------------------------------------------------------------------
46
47 wxBitmapButton::wxBitmapButton(void)
48 {
49 };
50
51 wxBitmapButton::wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
52 const wxPoint &pos, const wxSize &size,
53 long style, const wxString &name )
54 {
55 Create( parent, id, bitmap, pos, size, style, name );
56 };
57
58 bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
59 const wxPoint &pos, const wxSize &size,
60 long style, const wxString &name )
61 {
62 m_needParent = TRUE;
63
64 wxSize newSize = size;
65
66 PreCreation( parent, id, pos, newSize, style, name );
67
68 m_bitmap = bitmap;
69 m_label = "";
70
71 m_widget = gtk_button_new();
72
73 if (m_bitmap.Ok())
74 {
75 GdkBitmap *mask = NULL;
76 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
77 GtkWidget *pixmap = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
78
79 gtk_widget_show( pixmap );
80 gtk_container_add( GTK_CONTAINER(m_widget), pixmap );
81 };
82
83 if (newSize.x == -1) newSize.x = m_bitmap.GetHeight()+10;
84 if (newSize.y == -1) newSize.y = m_bitmap.GetWidth()+10;
85 SetSize( newSize.x, newSize.y );
86
87 gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
88 GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this );
89
90 PostCreation();
91
92 Show( TRUE );
93
94 return TRUE;
95 };
96
97 void wxBitmapButton::SetDefault(void)
98 {
99 };
100
101 void wxBitmapButton::SetLabel( const wxString &label )
102 {
103 wxControl::SetLabel( label );
104 };
105
106 wxString wxBitmapButton::GetLabel(void) const
107 {
108 return wxControl::GetLabel();
109 };