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 extern bool g_blockEventsOnDrag
;
29 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton
,wxControl
)
35 static void gtk_bmpbutton_clicked_callback( GtkWidget
*WXUNUSED(widget
), wxBitmapButton
*button
)
37 if (!button
->HasVMT()) return;
38 if (g_blockEventsOnDrag
) return;
40 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, button
->GetId());
41 event
.SetEventObject(button
);
42 button
->GetEventHandler()->ProcessEvent(event
);
45 //-----------------------------------------------------------------------------
47 wxBitmapButton
::wxBitmapButton(void)
51 bool wxBitmapButton
::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
52 const wxPoint
&pos
, const wxSize
&size
,
53 long style
, const wxValidator
& validator
, const wxString
&name
)
57 wxSize newSize
= size
;
59 PreCreation( parent
, id
, pos
, newSize
, style
, name
);
61 SetValidator( validator
);
66 m_widget
= gtk_button_new();
70 GdkBitmap
*mask
= NULL
;
71 if (m_bitmap
.GetMask()) mask
= m_bitmap
.GetMask()->GetBitmap();
72 GtkWidget
*pixmap
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask
);
74 gtk_widget_show( pixmap
);
75 gtk_container_add( GTK_CONTAINER(m_widget
), pixmap
);
78 if (newSize
.x
== -1) newSize
.x
= m_bitmap
.GetHeight()+10;
79 if (newSize
.y
== -1) newSize
.y
= m_bitmap
.GetWidth()+10;
80 SetSize( newSize
.x
, newSize
.y
);
82 gtk_signal_connect( GTK_OBJECT(m_widget
), "clicked",
83 GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback
), (gpointer
*)this );
92 void wxBitmapButton
::SetDefault(void)
94 gtk_widget_grab_default( m_widget
);
97 void wxBitmapButton
::SetLabel( const wxString
&label
)
99 wxControl
::SetLabel( label
);
102 wxString wxBitmapButton
::GetLabel(void) const
104 return wxControl
::GetLabel();