]>
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 // 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 // empty bitmap, so that we can create GtkPixmap widget:
38 static char * bogus_xpm
[] = {
44 bool wxStaticBitmap::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
45 const wxPoint
&pos
, const wxSize
&size
,
46 long style
, const wxString
&name
)
50 if (!PreCreation( parent
, pos
, size
) ||
51 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
53 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
59 wxBitmap
bmp(bitmap
.Ok() ? bitmap
: wxBitmap(bogus_xpm
));
60 m_widget
= gtk_pixmap_new(bmp
.GetPixmap(), NULL
);
66 m_parent
->DoAddChild( this );
71 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
77 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
78 if (m_bitmap
.GetMask())
79 mask
= m_bitmap
.GetMask()->GetBitmap();
81 gtk_pixmap_set(GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
84 SetSize(GetBestSize());
90 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
92 // TODO: overload to allow using gtk_pixmap_new?
93 return GetDefaultAttributesFromGTKWidget(gtk_label_new
);
96 #endif // wxUSE_STATBMP