]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/statbmp.cpp
wxPython 2.1b1 for wxMSW (wxGTK coming soon)
[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
14#include "wx/statbmp.h"
15
dcf924a3
RR
16#if wxUSE_STATBMP
17
83624f79
RR
18#include "gdk/gdk.h"
19#include "gtk/gtk.h"
20
1a56f55c
RR
21//-----------------------------------------------------------------------------
22// wxStaticBitmap
23//-----------------------------------------------------------------------------
24
25IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
26
27wxStaticBitmap::wxStaticBitmap(void)
28{
58614078 29}
1a56f55c
RR
30
31wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
32 const wxPoint &pos, const wxSize &size,
debe6624 33 long style, const wxString &name )
1a56f55c 34{
a93109d5 35 Create( parent, id, bitmap, pos, size, style, name );
58614078 36}
1a56f55c
RR
37
38bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
39 const wxPoint &pos, const wxSize &size,
debe6624 40 long style, const wxString &name )
1a56f55c 41{
a93109d5 42 m_needParent = TRUE;
1a56f55c 43
a93109d5 44 wxSize newSize = size;
1a56f55c 45
a93109d5 46 PreCreation( parent, id, pos, size, style, name );
1a56f55c 47
a93109d5 48 m_bitmap = bitmap;
1a56f55c 49
a93109d5
RR
50 if (m_bitmap.Ok())
51 {
52 GdkBitmap *mask = (GdkBitmap *) NULL;
53 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
54 m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
1a56f55c 55
a93109d5
RR
56 if (newSize.x == -1) newSize.x = m_bitmap.GetWidth();
57 if (newSize.y == -1) newSize.y = m_bitmap.GetHeight();
58 SetSize( newSize.x, newSize.y );
59 }
60 else
61 {
62 m_widget = gtk_label_new( "Bitmap" );
63 }
1a56f55c 64
f03fc89f 65 m_parent->DoAddChild( this );
6ca41e57 66
a93109d5 67 PostCreation();
1a56f55c 68
a93109d5 69 Show( TRUE );
1a56f55c 70
a93109d5 71 return TRUE;
58614078 72}
1a56f55c
RR
73
74void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
75{
a93109d5 76 m_bitmap = bitmap;
1a56f55c 77
a93109d5
RR
78 if (m_bitmap.Ok())
79 {
80 GdkBitmap *mask = (GdkBitmap *) NULL;
81 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
82 gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
83 }
58614078 84}
dcf924a3
RR
85
86#endif