]>
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 | ||
4a4a02ac | 17 | #include <gtk/gtk.h> |
83624f79 | 18 | |
1a56f55c RR |
19 | //----------------------------------------------------------------------------- |
20 | // wxStaticBitmap | |
21 | //----------------------------------------------------------------------------- | |
22 | ||
1a56f55c RR |
23 | wxStaticBitmap::wxStaticBitmap(void) |
24 | { | |
58614078 | 25 | } |
1a56f55c | 26 | |
c35414db VZ |
27 | wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, |
28 | const wxPoint &pos, const wxSize &size, | |
debe6624 | 29 | long style, const wxString &name ) |
1a56f55c | 30 | { |
a93109d5 | 31 | Create( parent, id, bitmap, pos, size, style, name ); |
58614078 | 32 | } |
1a56f55c | 33 | |
c35414db | 34 | bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, |
32d4bfd1 VZ |
35 | const wxPoint &pos, const wxSize &size, |
36 | long style, const wxString &name ) | |
1a56f55c | 37 | { |
4dcaf11a RR |
38 | if (!PreCreation( parent, pos, size ) || |
39 | !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) | |
40 | { | |
4fab7128 VS |
41 | wxFAIL_MSG( wxT("wxStaticBitmap creation failed") ); |
42 | return false; | |
4dcaf11a | 43 | } |
1a56f55c | 44 | |
a93109d5 | 45 | m_bitmap = bitmap; |
c35414db | 46 | |
4fab7128 | 47 | m_widget = gtk_image_new(); |
9ff9d30c | 48 | g_object_ref(m_widget); |
4fab7128 VS |
49 | |
50 | if (bitmap.Ok()) | |
51 | SetBitmap(bitmap); | |
31528cd3 | 52 | |
abdeb9e7 | 53 | PostCreation(size); |
f03fc89f | 54 | m_parent->DoAddChild( this ); |
c35414db | 55 | |
4fab7128 | 56 | return true; |
58614078 | 57 | } |
1a56f55c | 58 | |
c35414db | 59 | void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap ) |
1a56f55c | 60 | { |
a93109d5 | 61 | m_bitmap = bitmap; |
c35414db | 62 | |
a93109d5 RR |
63 | if (m_bitmap.Ok()) |
64 | { | |
4a4a02ac PC |
65 | // always use pixbuf, because pixmap mask does not |
66 | // work with disabled images in some themes | |
67 | gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget), m_bitmap.GetPixbuf()); | |
31528cd3 | 68 | |
9f884528 RD |
69 | InvalidateBestSize(); |
70 | SetSize(GetBestSize()); | |
a93109d5 | 71 | } |
58614078 | 72 | } |
dcf924a3 | 73 | |
9d522606 RD |
74 | // static |
75 | wxVisualAttributes | |
76 | wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) | |
77 | { | |
78 | // TODO: overload to allow using gtk_pixmap_new? | |
79 | return GetDefaultAttributesFromGTKWidget(gtk_label_new); | |
80 | } | |
81 | ||
1e6feb95 | 82 | #endif // wxUSE_STATBMP |
f68586e5 | 83 |