]>
Commit | Line | Data |
---|---|---|
1a56f55c RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: statbmp.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
a81258be RR |
5 | // Id: $Id$ |
6 | // Copyright: (c) 1998 Robert Roebling | |
65571936 | 7 | // Licence: wxWindows licence |
1a56f55c RR |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
14f355c2 VS |
10 | // For compilers that support precompilation, includes "wx.h". |
11 | #include "wx/wxprec.h" | |
1a56f55c | 12 | |
dcf924a3 RR |
13 | #if wxUSE_STATBMP |
14 | ||
1e6feb95 VZ |
15 | #include "wx/statbmp.h" |
16 | ||
83624f79 RR |
17 | #include "gdk/gdk.h" |
18 | #include "gtk/gtk.h" | |
19 | ||
1a56f55c RR |
20 | //----------------------------------------------------------------------------- |
21 | // wxStaticBitmap | |
22 | //----------------------------------------------------------------------------- | |
23 | ||
24 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl) | |
25 | ||
26 | wxStaticBitmap::wxStaticBitmap(void) | |
27 | { | |
58614078 | 28 | } |
1a56f55c | 29 | |
c35414db VZ |
30 | wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, |
31 | const wxPoint &pos, const wxSize &size, | |
debe6624 | 32 | long style, const wxString &name ) |
1a56f55c | 33 | { |
a93109d5 | 34 | Create( parent, id, bitmap, pos, size, style, name ); |
58614078 | 35 | } |
1a56f55c | 36 | |
c35414db | 37 | bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, |
32d4bfd1 VZ |
38 | const wxPoint &pos, const wxSize &size, |
39 | long style, const wxString &name ) | |
1a56f55c | 40 | { |
4dcaf11a RR |
41 | if (!PreCreation( parent, pos, size ) || |
42 | !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) | |
43 | { | |
4fab7128 VS |
44 | wxFAIL_MSG( wxT("wxStaticBitmap creation failed") ); |
45 | return false; | |
4dcaf11a | 46 | } |
1a56f55c | 47 | |
a93109d5 | 48 | m_bitmap = bitmap; |
c35414db | 49 | |
4fab7128 | 50 | m_widget = gtk_image_new(); |
4fab7128 VS |
51 | |
52 | if (bitmap.Ok()) | |
53 | SetBitmap(bitmap); | |
31528cd3 | 54 | |
abdeb9e7 | 55 | PostCreation(size); |
f03fc89f | 56 | m_parent->DoAddChild( this ); |
c35414db | 57 | |
4fab7128 | 58 | return true; |
58614078 | 59 | } |
1a56f55c | 60 | |
c35414db | 61 | void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap ) |
1a56f55c | 62 | { |
a93109d5 | 63 | m_bitmap = bitmap; |
c35414db | 64 | |
a93109d5 RR |
65 | if (m_bitmap.Ok()) |
66 | { | |
4fab7128 VS |
67 | GdkBitmap *mask = (GdkBitmap *) NULL; |
68 | if (m_bitmap.GetMask()) | |
69 | mask = m_bitmap.GetMask()->GetBitmap(); | |
3d257b8d | 70 | |
4fab7128 | 71 | if (m_bitmap.HasPixbuf()) |
32d4bfd1 | 72 | { |
4fab7128 VS |
73 | gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget), |
74 | m_bitmap.GetPixbuf()); | |
32d4bfd1 | 75 | } |
31528cd3 | 76 | else |
4fab7128 VS |
77 | gtk_image_set_from_pixmap(GTK_IMAGE(m_widget), |
78 | m_bitmap.GetPixmap(), mask); | |
31528cd3 | 79 | |
9f884528 RD |
80 | InvalidateBestSize(); |
81 | SetSize(GetBestSize()); | |
a93109d5 | 82 | } |
58614078 | 83 | } |
dcf924a3 | 84 | |
9d522606 RD |
85 | // static |
86 | wxVisualAttributes | |
87 | wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) | |
88 | { | |
89 | // TODO: overload to allow using gtk_pixmap_new? | |
90 | return GetDefaultAttributesFromGTKWidget(gtk_label_new); | |
91 | } | |
92 | ||
1e6feb95 | 93 | #endif // wxUSE_STATBMP |
f68586e5 | 94 |