]>
Commit | Line | Data |
---|---|---|
1a56f55c RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: statbmp.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
a81258be RR |
5 | // Id: $Id$ |
6 | // Copyright: (c) 1998 Robert Roebling | |
1a56f55c RR |
7 | // Licence: wxWindows licence |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifdef __GNUG__ | |
11 | #pragma implementation "statbmp.h" | |
12 | #endif | |
13 | ||
14 | #include "wx/statbmp.h" | |
15 | ||
16 | //----------------------------------------------------------------------------- | |
17 | // wxStaticBitmap | |
18 | //----------------------------------------------------------------------------- | |
19 | ||
20 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl) | |
21 | ||
22 | wxStaticBitmap::wxStaticBitmap(void) | |
23 | { | |
58614078 | 24 | } |
1a56f55c RR |
25 | |
26 | wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, | |
27 | const wxPoint &pos, const wxSize &size, | |
debe6624 | 28 | long style, const wxString &name ) |
1a56f55c | 29 | { |
a93109d5 | 30 | Create( parent, id, bitmap, pos, size, style, name ); |
58614078 | 31 | } |
1a56f55c RR |
32 | |
33 | bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, | |
34 | const wxPoint &pos, const wxSize &size, | |
debe6624 | 35 | long style, const wxString &name ) |
1a56f55c | 36 | { |
a93109d5 | 37 | m_needParent = TRUE; |
1a56f55c | 38 | |
a93109d5 | 39 | wxSize newSize = size; |
1a56f55c | 40 | |
a93109d5 | 41 | PreCreation( parent, id, pos, size, style, name ); |
1a56f55c | 42 | |
a93109d5 | 43 | m_bitmap = bitmap; |
1a56f55c | 44 | |
a93109d5 RR |
45 | if (m_bitmap.Ok()) |
46 | { | |
47 | GdkBitmap *mask = (GdkBitmap *) NULL; | |
48 | if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); | |
49 | m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); | |
1a56f55c | 50 | |
a93109d5 RR |
51 | if (newSize.x == -1) newSize.x = m_bitmap.GetWidth(); |
52 | if (newSize.y == -1) newSize.y = m_bitmap.GetHeight(); | |
53 | SetSize( newSize.x, newSize.y ); | |
54 | } | |
55 | else | |
56 | { | |
57 | m_widget = gtk_label_new( "Bitmap" ); | |
58 | } | |
1a56f55c | 59 | |
a93109d5 | 60 | m_parent->AddChild( this ); |
6ca41e57 | 61 | |
a93109d5 | 62 | (m_parent->m_insertCallback)( m_parent, this ); |
6ca41e57 | 63 | |
a93109d5 | 64 | PostCreation(); |
1a56f55c | 65 | |
a93109d5 | 66 | Show( TRUE ); |
1a56f55c | 67 | |
a93109d5 | 68 | return TRUE; |
58614078 | 69 | } |
1a56f55c RR |
70 | |
71 | void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap ) | |
72 | { | |
a93109d5 | 73 | m_bitmap = bitmap; |
1a56f55c | 74 | |
a93109d5 RR |
75 | if (m_bitmap.Ok()) |
76 | { | |
77 | GdkBitmap *mask = (GdkBitmap *) NULL; | |
78 | if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); | |
79 | gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask ); | |
80 | } | |
58614078 | 81 | } |