]>
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 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "statbmp.h"
18 #include "wx/statbmp.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
,wxControl
)
29 wxStaticBitmap::wxStaticBitmap(void)
33 wxStaticBitmap::wxStaticBitmap( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
34 const wxPoint
&pos
, const wxSize
&size
,
35 long style
, const wxString
&name
)
37 Create( parent
, id
, bitmap
, pos
, size
, style
, name
);
40 void wxStaticBitmap::CreatePixmapWidget()
42 wxCHECK_RET( m_bitmap
.Ok(), wxT("should only be called if we have a bitmap") );
44 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
45 if ( m_bitmap
.GetMask() )
46 mask
= m_bitmap
.GetMask()->GetBitmap();
47 m_widget
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask
);
49 /* insert GTK representation */
50 (*m_parent
->m_insertCallback
)(m_parent
, this);
52 gtk_widget_show( m_widget
);
57 bool wxStaticBitmap::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
58 const wxPoint
&pos
, const wxSize
&size
,
59 long style
, const wxString
&name
)
63 if (!PreCreation( parent
, pos
, size
) ||
64 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
66 wxFAIL_MSG( wxT("wxXX creation failed") );
74 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
75 if ( m_bitmap
.GetMask() )
76 mask
= m_bitmap
.GetMask()->GetBitmap();
77 m_widget
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask
);
83 m_widget
= gtk_label_new( "Bitmap" );
88 m_parent
->DoAddChild( this );
95 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
97 bool hasWidget
= m_bitmap
.Ok();
104 gtk_widget_destroy( m_widget
);
106 /* recreate m_widget because we've created a label
107 and not a bitmap above */
108 CreatePixmapWidget();
112 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
113 if (m_bitmap
.GetMask()) mask
= m_bitmap
.GetMask()->GetBitmap();
114 gtk_pixmap_set( GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
117 SetBestSize(wxSize(bitmap
.GetWidth(), bitmap
.GetHeight()));
121 #endif // wxUSE_STATBMP