]>
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" );
88 m_focusWidget
= m_widget
;
93 m_parent
->DoAddChild( this );
100 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
102 bool hasWidget
= m_bitmap
.Ok();
109 gtk_widget_destroy( m_widget
);
111 /* recreate m_widget because we've created a label
112 and not a bitmap above */
113 CreatePixmapWidget();
117 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
118 if (m_bitmap
.GetMask()) mask
= m_bitmap
.GetMask()->GetBitmap();
119 gtk_pixmap_set( GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
122 SetBestSize(wxSize(bitmap
.GetWidth(), bitmap
.GetHeight()));
126 #endif // wxUSE_STATBMP