]> git.saurik.com Git - wxWidgets.git/blob - src/gtk1/statbmp.cpp
set m_itemIndex in the list events for key down event too
[wxWidgets.git] / src / gtk1 / statbmp.cpp
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/defs.h"
15
16 #if wxUSE_STATBMP
17
18 #include "wx/statbmp.h"
19
20 #include "gdk/gdk.h"
21 #include "gtk/gtk.h"
22
23 //-----------------------------------------------------------------------------
24 // wxStaticBitmap
25 //-----------------------------------------------------------------------------
26
27 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
28
29 wxStaticBitmap::wxStaticBitmap(void)
30 {
31 }
32
33 wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
34 const wxPoint &pos, const wxSize &size,
35 long style, const wxString &name )
36 {
37 Create( parent, id, bitmap, pos, size, style, name );
38 }
39
40 void wxStaticBitmap::CreatePixmapWidget()
41 {
42 wxCHECK_RET( m_bitmap.Ok(), wxT("should only be called if we have a bitmap") );
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
49 /* insert GTK representation */
50 (*m_parent->m_insertCallback)(m_parent, this);
51
52 gtk_widget_show( m_widget );
53
54 PostCreation();
55 }
56
57 bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
58 const wxPoint &pos, const wxSize &size,
59 long style, const wxString &name )
60 {
61 m_needParent = TRUE;
62
63 if (!PreCreation( parent, pos, size ) ||
64 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
65 {
66 wxFAIL_MSG( wxT("wxXX creation failed") );
67 return FALSE;
68 }
69
70 m_bitmap = bitmap;
71
72 if (m_bitmap.Ok())
73 {
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 );
78
79 SetBestSize( size );
80 }
81 else
82 {
83 m_widget = gtk_label_new( "Bitmap" );
84
85 PostCreation();
86 }
87
88 m_parent->DoAddChild( this );
89
90 Show( TRUE );
91
92 return TRUE;
93 }
94
95 void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
96 {
97 bool hasWidget = m_bitmap.Ok();
98 m_bitmap = bitmap;
99
100 if (m_bitmap.Ok())
101 {
102 if (!hasWidget)
103 {
104 gtk_widget_destroy( m_widget );
105
106 /* recreate m_widget because we've created a label
107 and not a bitmap above */
108 CreatePixmapWidget();
109 }
110 else
111 {
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 );
115 }
116
117 SetBestSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight()));
118 }
119 }
120
121 #endif // wxUSE_STATBMP
122