]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/statbmp.cpp
bcc80259273a94f466416428d5bf6863a858b51c
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "statbmp.h"
14 #include "wx/statbmp.h"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
,wxControl
)
27 wxStaticBitmap::wxStaticBitmap(void)
31 wxStaticBitmap::wxStaticBitmap( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
32 const wxPoint
&pos
, const wxSize
&size
,
33 long style
, const wxString
&name
)
35 Create( parent
, id
, bitmap
, pos
, size
, style
, name
);
38 void wxStaticBitmap::CreatePixmapWidget()
40 wxCHECK_RET( m_bitmap
.Ok(), "should only be called if we have a bitmap" );
42 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
43 if ( m_bitmap
.GetMask() )
44 mask
= m_bitmap
.GetMask()->GetBitmap();
45 m_widget
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask
);
47 /* insert GTK representation */
48 (*m_parent
->m_insertCallback
)(m_parent
, this);
50 gtk_widget_show( m_widget
);
55 bool wxStaticBitmap::Create( wxWindow
*parent
, wxWindowID id
, const wxBitmap
&bitmap
,
56 const wxPoint
&pos
, const wxSize
&size
,
57 long style
, const wxString
&name
)
61 wxSize newSize
= size
;
63 PreCreation( parent
, id
, pos
, size
, style
, name
);
69 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
70 if ( m_bitmap
.GetMask() )
71 mask
= m_bitmap
.GetMask()->GetBitmap();
72 m_widget
= gtk_pixmap_new( m_bitmap
.GetPixmap(), mask
);
74 if (newSize
.x
== -1) newSize
.x
= m_bitmap
.GetWidth();
75 if (newSize
.y
== -1) newSize
.y
= m_bitmap
.GetHeight();
76 SetSize( newSize
.x
, newSize
.y
);
80 m_widget
= gtk_label_new( "Bitmap" );
85 m_parent
->DoAddChild( this );
92 void wxStaticBitmap::SetBitmap( const wxBitmap
&bitmap
)
94 bool hasWidget
= m_bitmap
.Ok();
101 gtk_widget_destroy( m_widget
);
103 /* recreate m_widget because we've created a label
104 and not a bitmap above */
105 CreatePixmapWidget();
109 GdkBitmap
*mask
= (GdkBitmap
*) NULL
;
110 if (m_bitmap
.GetMask()) mask
= m_bitmap
.GetMask()->GetBitmap();
111 gtk_pixmap_set( GTK_PIXMAP(m_widget
), m_bitmap
.GetPixmap(), mask
);
114 SetSize( m_bitmap
.GetWidth(), m_bitmap
.GetHeight() );