]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/statbmp.cpp
added the makefile for tex2rtf compilation using configure, fixed compilation
[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 30
c35414db
VZ
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 37
32d4bfd1
VZ
38void wxStaticBitmap::CreatePixmapWidget()
39{
223d09f6 40 wxCHECK_RET( m_bitmap.Ok(), wxT("should only be called if we have a bitmap") );
32d4bfd1
VZ
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
953704c1
RR
47 /* insert GTK representation */
48 (*m_parent->m_insertCallback)(m_parent, this);
31528cd3 49
953704c1
RR
50 gtk_widget_show( m_widget );
51
32d4bfd1
VZ
52 PostCreation();
53}
54
c35414db 55bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
32d4bfd1
VZ
56 const wxPoint &pos, const wxSize &size,
57 long style, const wxString &name )
1a56f55c 58{
a93109d5 59 m_needParent = TRUE;
c35414db 60
4dcaf11a
RR
61 if (!PreCreation( parent, pos, size ) ||
62 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
63 {
223d09f6 64 wxFAIL_MSG( wxT("wxXX creation failed") );
4dcaf11a
RR
65 return FALSE;
66 }
1a56f55c 67
a93109d5 68 m_bitmap = bitmap;
c35414db 69
a93109d5
RR
70 if (m_bitmap.Ok())
71 {
4dcaf11a
RR
72 wxSize newSize = size;
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
a93109d5
RR
79 if (newSize.x == -1) newSize.x = m_bitmap.GetWidth();
80 if (newSize.y == -1) newSize.y = m_bitmap.GetHeight();
81 SetSize( newSize.x, newSize.y );
82 }
83 else
84 {
85 m_widget = gtk_label_new( "Bitmap" );
c35414db 86
953704c1
RR
87 PostCreation();
88 }
31528cd3 89
f03fc89f 90 m_parent->DoAddChild( this );
c35414db 91
a93109d5 92 Show( TRUE );
c35414db 93
a93109d5 94 return TRUE;
58614078 95}
1a56f55c 96
c35414db 97void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
1a56f55c 98{
32d4bfd1 99 bool hasWidget = m_bitmap.Ok();
a93109d5 100 m_bitmap = bitmap;
c35414db 101
a93109d5
RR
102 if (m_bitmap.Ok())
103 {
953704c1 104 if (!hasWidget)
32d4bfd1
VZ
105 {
106 gtk_widget_destroy( m_widget );
107
31528cd3
VZ
108 /* recreate m_widget because we've created a label
109 and not a bitmap above */
32d4bfd1
VZ
110 CreatePixmapWidget();
111 }
31528cd3
VZ
112 else
113 {
953704c1
RR
114 GdkBitmap *mask = (GdkBitmap *) NULL;
115 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
116 gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
31528cd3
VZ
117 }
118
953704c1 119 SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
a93109d5 120 }
58614078 121}
dcf924a3
RR
122
123#endif