]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
15 #include "wx/statbmp.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
,wxControl
)
26 wxStaticBitmap::wxStaticBitmap(void)
30 wxStaticBitmap::wxStaticBitmap( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
31 const wxPoint
&pos
, const wxSize
&size
,
32 long style
, const wxString
&name
)
34 Create( parent
, id
, bitmap
, pos
, size
, style
, name
);
37 bool wxStaticBitmap::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
38 const wxPoint
&pos
, const wxSize
&size
,
39 long style
, const wxString
&name
)
43 if (!PreCreation( parent
, pos
, size
) ||
44 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
46 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
52 m_widget
= gtk_image_new();
58 m_parent
->DoAddChild( this );
63 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
69 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
70 if (m_bitmap
.GetMask())
71 mask
= m_bitmap
.GetMask()->GetBitmap();
73 if (m_bitmap
.HasPixbuf())
75 gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget
),
76 m_bitmap
.GetPixbuf());
79 gtk_image_set_from_pixmap(GTK_IMAGE(m_widget
),
80 m_bitmap
.GetPixmap(), mask
);
83 SetSize(GetBestSize());
89 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
91 // TODO: overload to allow using gtk_pixmap_new?
92 return GetDefaultAttributesFromGTKWidget(gtk_label_new
);
95 #endif // wxUSE_STATBMP