Added zillions of #if wxUSE_XXX
[wxWidgets.git] / src / gtk / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: statbmp.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 "statbmp.h"
12 #endif
13
14 #include "wx/statbmp.h"
15
16 #if wxUSE_STATBMP
17
18 #include "gdk/gdk.h"
19 #include "gtk/gtk.h"
20
21 //-----------------------------------------------------------------------------
22 // wxStaticBitmap
23 //-----------------------------------------------------------------------------
24
25 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
26
27 wxStaticBitmap::wxStaticBitmap(void)
28 {
29 }
30
31 wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
32 const wxPoint &pos, const wxSize &size,
33 long style, const wxString &name )
34 {
35 Create( parent, id, bitmap, pos, size, style, name );
36 }
37
38 bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
39 const wxPoint &pos, const wxSize &size,
40 long style, const wxString &name )
41 {
42 m_needParent = TRUE;
43
44 wxSize newSize = size;
45
46 PreCreation( parent, id, pos, size, style, name );
47
48 m_bitmap = bitmap;
49
50 if (m_bitmap.Ok())
51 {
52 GdkBitmap *mask = (GdkBitmap *) NULL;
53 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
54 m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
55
56 if (newSize.x == -1) newSize.x = m_bitmap.GetWidth();
57 if (newSize.y == -1) newSize.y = m_bitmap.GetHeight();
58 SetSize( newSize.x, newSize.y );
59 }
60 else
61 {
62 m_widget = gtk_label_new( "Bitmap" );
63 }
64
65 m_parent->DoAddChild( this );
66
67 PostCreation();
68
69 Show( TRUE );
70
71 return TRUE;
72 }
73
74 void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
75 {
76 m_bitmap = bitmap;
77
78 if (m_bitmap.Ok())
79 {
80 GdkBitmap *mask = (GdkBitmap *) NULL;
81 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
82 gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
83 }
84 }
85
86 #endif