]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "statbmp.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
19 #include "wx/statbmp.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
,wxControl
)
30 wxStaticBitmap::wxStaticBitmap(void)
34 wxStaticBitmap::wxStaticBitmap( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
35 const wxPoint
&pos
, const wxSize
&size
,
36 long style
, const wxString
&name
)
38 Create( parent
, id
, bitmap
, pos
, size
, style
, name
);
41 void wxStaticBitmap::CreatePixmapWidget()
43 wxCHECK_RET( m_bitmap
.Ok(), wxT("should only be called if we have a bitmap") );
45 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
46 if ( m_bitmap
.GetMask() )
47 mask
= m_bitmap
.GetMask()->GetBitmap();
48 m_widget
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask
);
50 // insert GTK representation
51 (*m_parent
->m_insertCallback
)(m_parent
, this);
53 gtk_widget_show( m_widget
);
55 m_focusWidget
= m_widget
;
60 bool wxStaticBitmap::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
61 const wxPoint
&pos
, const wxSize
&size
,
62 long style
, const wxString
&name
)
66 if (!PreCreation( parent
, pos
, size
) ||
67 !CreateBase( parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
))
69 wxFAIL_MSG( wxT("wxXX creation failed") );
77 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
78 if ( m_bitmap
.GetMask() )
79 mask
= m_bitmap
.GetMask()->GetBitmap();
80 m_widget
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask
);
86 m_widget
= gtk_label_new( "Bitmap" );
87 m_focusWidget
= m_widget
;
91 m_parent
->DoAddChild( this );
96 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
98 bool hasWidget
= m_bitmap
.Ok();
105 gtk_widget_destroy( m_widget
);
107 /* recreate m_widget because we've created a label
108 and not a bitmap above */
109 CreatePixmapWidget();
113 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
114 if (m_bitmap
.GetMask()) mask
= m_bitmap
.GetMask()->GetBitmap();
115 gtk_pixmap_set( GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
118 SetBestSize(wxSize(bitmap
.GetWidth(), bitmap
.GetHeight()));
122 #endif // wxUSE_STATBMP