]>
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 #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
;
57 PostCreation(wxDefaultSize
);
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
);
84 m_widget
= gtk_label_new( "Bitmap" );
85 m_focusWidget
= m_widget
;
89 m_parent
->DoAddChild( this );
94 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
96 bool hasWidget
= m_bitmap
.Ok();
103 gtk_widget_destroy( m_widget
);
105 /* recreate m_widget because we've created a label
106 and not a bitmap above */
107 CreatePixmapWidget();
111 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
112 if (m_bitmap
.GetMask()) mask
= m_bitmap
.GetMask()->GetBitmap();
113 gtk_pixmap_set( GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
116 InvalidateBestSize();
117 SetSize(GetBestSize());
123 wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant
WXUNUSED(variant
))
125 // TODO: overload to allow using gtk_pixmap_new?
126 return GetDefaultAttributesFromGTKWidget(gtk_label_new
);
129 #endif // wxUSE_STATBMP