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