]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/statbmp.cpp
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
14 #include "wx/statbmp.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 wxStaticBitmap::wxStaticBitmap(void)
27 wxStaticBitmap::wxStaticBitmap( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
28 const wxPoint
&pos
, const wxSize
&size
,
29 long style
, const wxString
&name
)
31 Create( parent
, id
, bitmap
, pos
, size
, style
, name
);
34 // empty bitmap, so that we can create GtkPixmap widget:
35 static char * bogus_xpm
[] = {
41 bool wxStaticBitmap::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
42 const wxPoint
&pos
, const wxSize
&size
,
43 long style
, const wxString
&name
)
47 if (!PreCreation( parent
, pos
, size
) ||
48 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
50 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
56 wxBitmap
bmp(bitmap
.IsOk() ? bitmap
: wxBitmap(bogus_xpm
));
57 m_widget
= gtk_pixmap_new(bmp
.GetPixmap(), NULL
);
63 m_parent
->DoAddChild( this );
68 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
74 GdkBitmap
*mask
= NULL
;
75 if (m_bitmap
.GetMask())
76 mask
= m_bitmap
.GetMask()->GetBitmap();
78 gtk_pixmap_set(GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
81 SetSize(GetBestSize());
87 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
89 // TODO: overload to allow using gtk_pixmap_new?
90 return GetDefaultAttributesFromGTKWidget(gtk_label_new
);
93 #endif // wxUSE_STATBMP