]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/statbmp.cpp
59c3c7e555c2a6c14bf6d2e8c06bf26b7f264420
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 if (m_bitmap
.HasPixbuf())
83 gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget
),
84 m_bitmap
.GetPixbuf());
87 gtk_image_set_from_pixmap(GTK_IMAGE(m_widget
),
88 m_bitmap
.GetPixmap(), mask
);
91 SetSize(GetBestSize());
97 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
99 // TODO: overload to allow using gtk_pixmap_new?
100 return GetDefaultAttributesFromGTKWidget(gtk_label_new
);
103 #endif // wxUSE_STATBMP