]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/bmpbuttn.cpp
Tought Systemettings that sysfont has 12 pts
[wxWidgets.git] / src / gtk / bmpbuttn.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: bmpbuttn.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "bmpbuttn.h"
12#endif
13
14#include "wx/bmpbuttn.h"
15
16//-----------------------------------------------------------------------------
17// classes
18//-----------------------------------------------------------------------------
19
20class wxBitmapButton;
21
22//-----------------------------------------------------------------------------
23// data
24//-----------------------------------------------------------------------------
25
26extern bool g_blockEventsOnDrag;
27
28//-----------------------------------------------------------------------------
29// "clicked"
30//-----------------------------------------------------------------------------
31
32static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button )
33{
34 if (!button->HasVMT()) return;
35 if (g_blockEventsOnDrag) return;
36
37 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId());
38 event.SetEventObject(button);
39 button->GetEventHandler()->ProcessEvent(event);
40}
41
42//-----------------------------------------------------------------------------
43// wxBitmapButton
44//-----------------------------------------------------------------------------
45
46IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl)
47
48wxBitmapButton::wxBitmapButton(void)
49{
50}
51
52bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
53 const wxPoint &pos, const wxSize &size,
54 long style, const wxValidator& validator, const wxString &name )
55{
56 m_needParent = TRUE;
57
58 wxSize newSize = size;
59
60 PreCreation( parent, id, pos, newSize, style, name );
61
62 SetValidator( validator );
63
64 m_bitmap = bitmap;
65 m_label = "";
66
67 m_widget = gtk_button_new();
68
69 if (m_bitmap.Ok())
70 {
71 GdkBitmap *mask = (GdkBitmap *) NULL;
72 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
73 GtkWidget *pixmap = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
74
75 gtk_widget_show( pixmap );
76 gtk_container_add( GTK_CONTAINER(m_widget), pixmap );
77 }
78
79 if (newSize.x == -1) newSize.x = m_bitmap.GetHeight()+10;
80 if (newSize.y == -1) newSize.y = m_bitmap.GetWidth()+10;
81 SetSize( newSize.x, newSize.y );
82
83 gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
84 GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this );
85
86 PostCreation();
87
88 SetBackgroundColour( parent->GetBackgroundColour() );
89
90 Show( TRUE );
91
92 return TRUE;
93}
94
95void wxBitmapButton::SetDefault(void)
96{
97/*
98 GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT );
99 gtk_widget_grab_default( m_widget );
100*/
101}
102
103void wxBitmapButton::SetLabel( const wxString &label )
104{
105 wxCHECK_RET( m_widget != NULL, "invalid button" );
106
107 wxControl::SetLabel( label );
108}
109
110wxString wxBitmapButton::GetLabel(void) const
111{
112 wxCHECK_MSG( m_widget != NULL, "", "invalid button" );
113
114 return wxControl::GetLabel();
115}
116
117void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap )
118{
119 wxCHECK_RET( m_widget != NULL, "invalid button" );
120
121 m_bitmap = bitmap;
122 if (!m_bitmap.Ok()) return;
123
124 GtkButton *bin = GTK_BUTTON( m_widget );
125 GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child );
126
127 GdkBitmap *mask = (GdkBitmap *) NULL;
128 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
129
130 gtk_pixmap_set( g_pixmap, m_bitmap.GetPixmap(), mask );
131}
132
133void wxBitmapButton::ApplyWidgetStyle()
134{
135}
136