]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/statbmp.cpp
Applied patch for Intel compiler.
[wxWidgets.git] / src / gtk / 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
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
1a56f55c
RR
11#pragma implementation "statbmp.h"
12#endif
13
14f355c2
VS
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
1a56f55c 16
dcf924a3
RR
17#if wxUSE_STATBMP
18
1e6feb95
VZ
19#include "wx/statbmp.h"
20
83624f79
RR
21#include "gdk/gdk.h"
22#include "gtk/gtk.h"
23
1a56f55c
RR
24//-----------------------------------------------------------------------------
25// wxStaticBitmap
26//-----------------------------------------------------------------------------
27
28IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
29
30wxStaticBitmap::wxStaticBitmap(void)
31{
58614078 32}
1a56f55c 33
c35414db
VZ
34wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
35 const wxPoint &pos, const wxSize &size,
debe6624 36 long style, const wxString &name )
1a56f55c 37{
a93109d5 38 Create( parent, id, bitmap, pos, size, style, name );
58614078 39}
1a56f55c 40
32d4bfd1
VZ
41void wxStaticBitmap::CreatePixmapWidget()
42{
223d09f6 43 wxCHECK_RET( m_bitmap.Ok(), wxT("should only be called if we have a bitmap") );
32d4bfd1
VZ
44
45 GdkBitmap *mask = (GdkBitmap *) NULL;
46 if ( m_bitmap.GetMask() )
47 mask = m_bitmap.GetMask()->GetBitmap();
48 m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
49
76fcf0f2 50 // insert GTK representation
953704c1 51 (*m_parent->m_insertCallback)(m_parent, this);
31528cd3 52
953704c1
RR
53 gtk_widget_show( m_widget );
54
76fcf0f2
RR
55 m_focusWidget = m_widget;
56
32d4bfd1
VZ
57 PostCreation();
58}
59
c35414db 60bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
32d4bfd1
VZ
61 const wxPoint &pos, const wxSize &size,
62 long style, const wxString &name )
1a56f55c 63{
a93109d5 64 m_needParent = TRUE;
c35414db 65
4dcaf11a
RR
66 if (!PreCreation( parent, pos, size ) ||
67 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
68 {
223d09f6 69 wxFAIL_MSG( wxT("wxXX creation failed") );
76fcf0f2 70 return FALSE;
4dcaf11a 71 }
1a56f55c 72
a93109d5 73 m_bitmap = bitmap;
c35414db 74
a93109d5
RR
75 if (m_bitmap.Ok())
76 {
953704c1
RR
77 GdkBitmap *mask = (GdkBitmap *) NULL;
78 if ( m_bitmap.GetMask() )
79 mask = m_bitmap.GetMask()->GetBitmap();
80 m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask );
c35414db 81
1e6feb95 82 SetBestSize( size );
a93109d5
RR
83 }
84 else
85 {
86 m_widget = gtk_label_new( "Bitmap" );
76fcf0f2
RR
87
88 m_focusWidget = m_widget;
c35414db 89
953704c1
RR
90 PostCreation();
91 }
31528cd3 92
f03fc89f 93 m_parent->DoAddChild( this );
c35414db 94
a93109d5 95 Show( TRUE );
c35414db 96
a93109d5 97 return TRUE;
58614078 98}
1a56f55c 99
c35414db 100void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
1a56f55c 101{
32d4bfd1 102 bool hasWidget = m_bitmap.Ok();
a93109d5 103 m_bitmap = bitmap;
c35414db 104
a93109d5
RR
105 if (m_bitmap.Ok())
106 {
953704c1 107 if (!hasWidget)
32d4bfd1
VZ
108 {
109 gtk_widget_destroy( m_widget );
110
31528cd3
VZ
111 /* recreate m_widget because we've created a label
112 and not a bitmap above */
32d4bfd1
VZ
113 CreatePixmapWidget();
114 }
31528cd3
VZ
115 else
116 {
953704c1
RR
117 GdkBitmap *mask = (GdkBitmap *) NULL;
118 if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
119 gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
31528cd3
VZ
120 }
121
1e6feb95 122 SetBestSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight()));
a93109d5 123 }
58614078 124}
dcf924a3 125
1e6feb95 126#endif // wxUSE_STATBMP
f68586e5 127