1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "bmpbuttn.h"
15 #include "wx/bmpbuttn.h"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton
,wxControl
)
29 void gtk_bmpbutton_clicked_callback( GtkWidget
*WXUNUSED(widget
), gpointer data
)
31 wxBitmapButton
*button
= (wxBitmapButton
*)data
;
32 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, button
->GetId());
33 event
.SetEventObject(button
);
34 button
->ProcessEvent(event
);
37 //-----------------------------------------------------------------------------
39 wxBitmapButton::wxBitmapButton(void)
43 wxBitmapButton::wxBitmapButton( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
44 const wxPoint
&pos
, const wxSize
&size
,
45 long style
, const wxString
&name
)
47 Create( parent
, id
, bitmap
, pos
, size
, style
, name
);
50 bool wxBitmapButton::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
51 const wxPoint
&pos
, const wxSize
&size
,
52 long style
, const wxString
&name
)
56 wxSize newSize
= size
;
58 PreCreation( parent
, id
, pos
, newSize
, style
, name
);
63 m_widget
= gtk_button_new();
67 GdkBitmap
*mask
= NULL
;
68 if (m_bitmap
.GetMask()) mask
= m_bitmap
.GetMask()->GetBitmap();
69 GtkWidget
*pixmap
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask
);
71 gtk_widget_show( pixmap
);
72 gtk_container_add( GTK_CONTAINER(m_widget
), pixmap
);
75 if (newSize
.x
== -1) newSize
.x
= m_bitmap
.GetHeight()+10;
76 if (newSize
.y
== -1) newSize
.y
= m_bitmap
.GetWidth()+10;
77 SetSize( newSize
.x
, newSize
.y
);
79 gtk_signal_connect( GTK_OBJECT(m_widget
), "clicked",
80 GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback
), (gpointer
*)this );
89 void wxBitmapButton::SetDefault(void)
93 void wxBitmapButton::SetLabel( const wxString
&label
)
95 wxControl::SetLabel( label
);
98 wxString
wxBitmapButton::GetLabel(void) const
100 return wxControl::GetLabel();