]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/gtk/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 <gtk/gtk.h> | |
18 | ||
19 | //----------------------------------------------------------------------------- | |
20 | // wxStaticBitmap | |
21 | //----------------------------------------------------------------------------- | |
22 | ||
23 | wxStaticBitmap::wxStaticBitmap(void) | |
24 | { | |
25 | } | |
26 | ||
27 | wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, | |
28 | const wxPoint &pos, const wxSize &size, | |
29 | long style, const wxString &name ) | |
30 | { | |
31 | Create( parent, id, bitmap, pos, size, style, name ); | |
32 | } | |
33 | ||
34 | bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, | |
35 | const wxPoint &pos, const wxSize &size, | |
36 | long style, const wxString &name ) | |
37 | { | |
38 | if (!PreCreation( parent, pos, size ) || | |
39 | !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) | |
40 | { | |
41 | wxFAIL_MSG( wxT("wxStaticBitmap creation failed") ); | |
42 | return false; | |
43 | } | |
44 | ||
45 | m_bitmap = bitmap; | |
46 | ||
47 | m_widget = gtk_image_new(); | |
48 | g_object_ref(m_widget); | |
49 | ||
50 | if (bitmap.IsOk()) | |
51 | SetBitmap(bitmap); | |
52 | ||
53 | PostCreation(size); | |
54 | m_parent->DoAddChild( this ); | |
55 | ||
56 | return true; | |
57 | } | |
58 | ||
59 | void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap ) | |
60 | { | |
61 | m_bitmap = bitmap; | |
62 | ||
63 | if (m_bitmap.IsOk()) | |
64 | { | |
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()); | |
68 | ||
69 | InvalidateBestSize(); | |
70 | SetSize(GetBestSize()); | |
71 | } | |
72 | } | |
73 | ||
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 | ||
82 | #endif // wxUSE_STATBMP | |
83 |