]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/statbmp.cpp
Convert argv[] to Unicode
[wxWidgets.git] / src / gtk1 / statbmp.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: statbmp.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "statbmp.h"
12#endif
13
14#include "wx/statbmp.h"
15
16#if wxUSE_STATBMP
17
18#include "gdk/gdk.h"
19#include "gtk/gtk.h"
20
21//-----------------------------------------------------------------------------
22// wxStaticBitmap
23//-----------------------------------------------------------------------------
24
25IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
26
27wxStaticBitmap::wxStaticBitmap(void)
28{
29}
30
31wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
32 const wxPoint &pos, const wxSize &size,
33 long style, const wxString &name )
34{
35 Create( parent, id, bitmap, pos, size, style, name );
36}
37
38void wxStaticBitmap::CreatePixmapWidget()
39{
40 wxCHECK_RET( m_bitmap.Ok(), "should only be called if we have a bitmap" );
41
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 );
46
47 /* insert GTK representation */
48 (*m_parent->m_insertCallback)(m_parent, this);
49
50 gtk_widget_show( m_widget );
51
52 PostCreation();
53}
54
55bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
56 const wxPoint &pos, const wxSize &size,
57 long style, const wxString &name )
58{
59 m_needParent = TRUE;
60
61 wxSize newSize = size;
62
63 PreCreation( parent, id, pos, size, style, name );
64
65 m_bitmap = bitmap;
66
67 if (m_bitmap.Ok())
68 {
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 );
73
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 );
77 }
78 else
79 {
80 m_widget = gtk_label_new( "Bitmap" );
81
82 PostCreation();
83 }
84
85 m_parent->DoAddChild( this );
86
87 Show( TRUE );
88
89 return TRUE;
90}
91
92void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
93{
94 bool hasWidget = m_bitmap.Ok();
95 m_bitmap = bitmap;
96
97 if (m_bitmap.Ok())
98 {
99 if (!hasWidget)
100 {
101 gtk_widget_destroy( m_widget );
102
103 /* recreate m_widget because we've created a label
104 and not a bitmap above */
105 CreatePixmapWidget();
106 }
107 else
108 {
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 );
112 }
113
114 SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
115 }
116}
117
118#endif