]>
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
);
38 // empty bitmap, so that we can create GtkPixmap widget:
39 static char * bogus_xpm
[] = {
46 bool wxStaticBitmap::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
47 const wxPoint
&pos
, const wxSize
&size
,
48 long style
, const wxString
&name
)
52 if (!PreCreation( parent
, pos
, size
) ||
53 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
55 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
62 m_widget
= gtk_image_new();
64 wxBitmap
bmp(bitmap
.Ok() ? bitmap
: wxBitmap(bogus_xpm
));
65 m_widget
= gtk_pixmap_new(bmp
.GetPixmap(), NULL
);
72 m_parent
->DoAddChild( this );
77 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
83 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
84 if (m_bitmap
.GetMask())
85 mask
= m_bitmap
.GetMask()->GetBitmap();
88 if (m_bitmap
.HasPixbuf())
90 gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget
),
91 m_bitmap
.GetPixbuf());
94 gtk_image_set_from_pixmap(GTK_IMAGE(m_widget
),
95 m_bitmap
.GetPixmap(), mask
);
97 gtk_pixmap_set(GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
100 InvalidateBestSize();
101 SetSize(GetBestSize());
107 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
109 // TODO: overload to allow using gtk_pixmap_new?
110 return GetDefaultAttributesFromGTKWidget(gtk_label_new
);
113 #endif // wxUSE_STATBMP