]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/statbmp.cpp
Fixed wxRichTextCtrl caret test case
[wxWidgets.git] / src / gtk1 / statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/statbmp.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #if wxUSE_STATBMP
14
15 #include "wx/statbmp.h"
16
17 #include "gdk/gdk.h"
18 #include "gtk/gtk.h"
19
20 //-----------------------------------------------------------------------------
21 // wxStaticBitmap
22 //-----------------------------------------------------------------------------
23
24 wxStaticBitmap::wxStaticBitmap(void)
25 {
26 }
27
28 wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
29 const wxPoint &pos, const wxSize &size,
30 long style, const wxString &name )
31 {
32 Create( parent, id, bitmap, pos, size, style, name );
33 }
34
35 // empty bitmap, so that we can create GtkPixmap widget:
36 static char * bogus_xpm[] = {
37 "2 2 1 1",
38 " c None",
39 " ",
40 " "};
41
42 bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
43 const wxPoint &pos, const wxSize &size,
44 long style, const wxString &name )
45 {
46 m_needParent = TRUE;
47
48 if (!PreCreation( parent, pos, size ) ||
49 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
50 {
51 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
52 return false;
53 }
54
55 m_bitmap = bitmap;
56
57 wxBitmap bmp(bitmap.IsOk() ? bitmap : wxBitmap(bogus_xpm));
58 m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
59
60 if (bitmap.IsOk())
61 SetBitmap(bitmap);
62
63 PostCreation(size);
64 m_parent->DoAddChild( this );
65
66 return true;
67 }
68
69 void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
70 {
71 m_bitmap = bitmap;
72
73 if (m_bitmap.IsOk())
74 {
75 GdkBitmap *mask = NULL;
76 if (m_bitmap.GetMask())
77 mask = m_bitmap.GetMask()->GetBitmap();
78
79 gtk_pixmap_set(GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask);
80
81 InvalidateBestSize();
82 SetSize(GetBestSize());
83 }
84 }
85
86 // static
87 wxVisualAttributes
88 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
89 {
90 // TODO: overload to allow using gtk_pixmap_new?
91 return GetDefaultAttributesFromGTKWidget(gtk_label_new);
92 }
93
94 #endif // wxUSE_STATBMP
95