]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/bmpbuttn.cpp
memdc and bitmap fixes
[wxWidgets.git] / src / gtk1 / bmpbuttn.cpp
CommitLineData
151ccd11
RR
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
21class wxBitmapButton;
22
23//-----------------------------------------------------------------------------
24// wxBitmapButton
25//-----------------------------------------------------------------------------
26
27IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl)
28
112892b9 29void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data )
151ccd11
RR
30{
31 wxBitmapButton *button = (wxBitmapButton*)data;
32 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
33 event.SetEventObject(button);
34 button->ProcessEvent(event);
35};
36
37//-----------------------------------------------------------------------------
38
39wxBitmapButton::wxBitmapButton(void)
40{
41};
42
43wxBitmapButton::wxBitmapButton( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
44 const wxPoint &pos, const wxSize &size,
debe6624 45 long style, const wxString &name )
151ccd11
RR
46{
47 Create( parent, id, bitmap, pos, size, style, name );
48};
49
50bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
51 const wxPoint &pos, const wxSize &size,
debe6624 52 long style, const wxString &name )
151ccd11
RR
53{
54 m_needParent = TRUE;
55
56 wxSize newSize = size;
57
58 PreCreation( parent, id, pos, newSize, style, name );
59
60 m_bitmap = bitmap;
61 m_label = "";
62
63 m_widget = gtk_button_new();
64
65 if (m_bitmap.Ok())
66 {
67 GdkBitmap *mask = NULL;
68 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
69 GtkWidget *pixmap = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
70
71 gtk_widget_show( pixmap );
72 gtk_container_add( GTK_CONTAINER(m_widget), pixmap );
73 };
74
151ccd11
RR
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 );
78
79 gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
112892b9 80 GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this );
151ccd11
RR
81
82 PostCreation();
83
84 Show( TRUE );
85
86 return TRUE;
87};
88
89void wxBitmapButton::SetDefault(void)
90{
91};
92
93void wxBitmapButton::SetLabel( const wxString &label )
94{
95 wxControl::SetLabel( label );
96};
97
98wxString wxBitmapButton::GetLabel(void) const
99{
100 return wxControl::GetLabel();
101};