]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/statbmp.cpp
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 wxStaticBitmap::wxStaticBitmap(void)
28 wxStaticBitmap::wxStaticBitmap( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
29 const wxPoint
&pos
, const wxSize
&size
,
30 long style
, const wxString
&name
)
32 Create( parent
, id
, bitmap
, pos
, size
, style
, name
);
35 // empty bitmap, so that we can create GtkPixmap widget:
36 static char * bogus_xpm
[] = {
42 bool wxStaticBitmap::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
43 const wxPoint
&pos
, const wxSize
&size
,
44 long style
, const wxString
&name
)
48 if (!PreCreation( parent
, pos
, size
) ||
49 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
51 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
57 wxBitmap
bmp(bitmap
.Ok() ? bitmap
: wxBitmap(bogus_xpm
));
58 m_widget
= gtk_pixmap_new(bmp
.GetPixmap(), NULL
);
64 m_parent
->DoAddChild( this );
69 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
75 GdkBitmap
*mask
= NULL
;
76 if (m_bitmap
.GetMask())
77 mask
= m_bitmap
.GetMask()->GetBitmap();
79 gtk_pixmap_set(GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
82 SetSize(GetBestSize());
88 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
90 // TODO: overload to allow using gtk_pixmap_new?
91 return GetDefaultAttributesFromGTKWidget(gtk_label_new
);
94 #endif // wxUSE_STATBMP