]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "statbmp.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
19 #include "wx/statbmp.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
,wxControl
)
30 wxStaticBitmap::wxStaticBitmap(void)
34 wxStaticBitmap::wxStaticBitmap( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
35 const wxPoint
&pos
, const wxSize
&size
,
36 long style
, const wxString
&name
)
38 Create( parent
, id
, bitmap
, pos
, size
, style
, name
);
42 // empty bitmap, so that we can create GtkPixmap widget:
43 static char * bogus_xpm
[] = {
50 bool wxStaticBitmap::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
51 const wxPoint
&pos
, const wxSize
&size
,
52 long style
, const wxString
&name
)
56 if (!PreCreation( parent
, pos
, size
) ||
57 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
59 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
66 m_widget
= gtk_image_new();
68 wxBitmap
bmp(bitmap
.Ok() ? bitmap
: wxBitmap(bogus_xpm
));
69 m_widget
= gtk_pixmap_new(bmp
.GetPixmap(), NULL
);
76 m_parent
->DoAddChild( this );
81 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
87 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
88 if (m_bitmap
.GetMask())
89 mask
= m_bitmap
.GetMask()->GetBitmap();
92 if (m_bitmap
.HasPixbuf())
94 gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget
),
95 m_bitmap
.GetPixbuf());
98 gtk_image_set_from_pixmap(GTK_IMAGE(m_widget
),
99 m_bitmap
.GetPixmap(), mask
);
101 gtk_pixmap_set(GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
104 InvalidateBestSize();
105 SetSize(GetBestSize());
111 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
113 // TODO: overload to allow using gtk_pixmap_new?
114 return GetDefaultAttributesFromGTKWidget(gtk_label_new
);
117 #endif // wxUSE_STATBMP