]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/statbmp.cpp
wxRTC: fixed guidelines overwriting adjacent cell borders; corrected capitalisation...
[wxWidgets.git] / src / gtk / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/statbmp.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
11
12 #if wxUSE_STATBMP
13
14 #include "wx/statbmp.h"
15
16 #include <gtk/gtk.h>
17
18 //-----------------------------------------------------------------------------
19 // wxStaticBitmap
20 //-----------------------------------------------------------------------------
21
22 wxStaticBitmap::wxStaticBitmap(void)
23 {
24 }
25
26 wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
27 const wxPoint &pos, const wxSize &size,
28 long style, const wxString &name )
29 {
30 Create( parent, id, bitmap, pos, size, style, name );
31 }
32
33 bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
34 const wxPoint &pos, const wxSize &size,
35 long style, const wxString &name )
36 {
37 if (!PreCreation( parent, pos, size ) ||
38 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
39 {
40 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
41 return false;
42 }
43
44 m_bitmap = bitmap;
45
46 m_widget = gtk_image_new();
47 g_object_ref(m_widget);
48
49 if (bitmap.IsOk())
50 SetBitmap(bitmap);
51
52 PostCreation(size);
53 m_parent->DoAddChild( this );
54
55 return true;
56 }
57
58 void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
59 {
60 m_bitmap = bitmap;
61
62 if (m_bitmap.IsOk())
63 {
64 // always use pixbuf, because pixmap mask does not
65 // work with disabled images in some themes
66 gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget), m_bitmap.GetPixbuf());
67
68 InvalidateBestSize();
69 SetSize(GetBestSize());
70 }
71 }
72
73 // static
74 wxVisualAttributes
75 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
76 {
77 return GetDefaultAttributesFromGTKWidget(gtk_image_new());
78 }
79
80 #endif // wxUSE_STATBMP
81