]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/statbmp.cpp
corrected pragma interface/implementation for Mac OS X
[wxWidgets.git] / src / gtk1 / statbmp.cpp
CommitLineData
1a56f55c
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: statbmp.cpp
3// Purpose:
4// Author: Robert Roebling
a81258be
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
f03fc89f 7// Licence: wxWindows licence
1a56f55c
RR
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "statbmp.h"
12#endif
13
1e6feb95 14#include "wx/defs.h"
1a56f55c 15
dcf924a3
RR
16#if wxUSE_STATBMP
17
1e6feb95
VZ
18#include "wx/statbmp.h"
19
83624f79
RR
20#include "gdk/gdk.h"
21#include "gtk/gtk.h"
22
1a56f55c
RR
23//-----------------------------------------------------------------------------
24// wxStaticBitmap
25//-----------------------------------------------------------------------------
26
27IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
28
29wxStaticBitmap::wxStaticBitmap(void)
30{
58614078 31}
1a56f55c 32
c35414db
VZ
33wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
34 const wxPoint &pos, const wxSize &size,
debe6624 35 long style, const wxString &name )
1a56f55c 36{
a93109d5 37 Create( parent, id, bitmap, pos, size, style, name );
58614078 38}
1a56f55c 39
32d4bfd1
VZ
40void wxStaticBitmap::CreatePixmapWidget()
41{
223d09f6 42 wxCHECK_RET( m_bitmap.Ok(), wxT("should only be called if we have a bitmap") );
32d4bfd1
VZ
43
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 );
48
953704c1
RR
49 /* insert GTK representation */
50 (*m_parent->m_insertCallback)(m_parent, this);
31528cd3 51
953704c1
RR
52 gtk_widget_show( m_widget );
53
32d4bfd1
VZ
54 PostCreation();
55}
56
c35414db 57bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
32d4bfd1
VZ
58 const wxPoint &pos, const wxSize &size,
59 long style, const wxString &name )
1a56f55c 60{
a93109d5 61 m_needParent = TRUE;
c35414db 62
4dcaf11a
RR
63 if (!PreCreation( parent, pos, size ) ||
64 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
65 {
223d09f6 66 wxFAIL_MSG( wxT("wxXX creation failed") );
4dcaf11a
RR
67 return FALSE;
68 }
1a56f55c 69
a93109d5 70 m_bitmap = bitmap;
c35414db 71
a93109d5
RR
72 if (m_bitmap.Ok())
73 {
953704c1
RR
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 );
c35414db 78
1e6feb95 79 SetBestSize( size );
a93109d5
RR
80 }
81 else
82 {
83 m_widget = gtk_label_new( "Bitmap" );
c35414db 84
953704c1
RR
85 PostCreation();
86 }
31528cd3 87
f03fc89f 88 m_parent->DoAddChild( this );
c35414db 89
a93109d5 90 Show( TRUE );
c35414db 91
a93109d5 92 return TRUE;
58614078 93}
1a56f55c 94
c35414db 95void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
1a56f55c 96{
32d4bfd1 97 bool hasWidget = m_bitmap.Ok();
a93109d5 98 m_bitmap = bitmap;
c35414db 99
a93109d5
RR
100 if (m_bitmap.Ok())
101 {
953704c1 102 if (!hasWidget)
32d4bfd1
VZ
103 {
104 gtk_widget_destroy( m_widget );
105
31528cd3
VZ
106 /* recreate m_widget because we've created a label
107 and not a bitmap above */
32d4bfd1
VZ
108 CreatePixmapWidget();
109 }
31528cd3
VZ
110 else
111 {
953704c1
RR
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 );
31528cd3
VZ
115 }
116
1e6feb95 117 SetBestSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight()));
a93109d5 118 }
58614078 119}
dcf924a3 120
1e6feb95 121#endif // wxUSE_STATBMP
f68586e5 122