]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/statbmp.cpp
Add default constructor to wxGraphicsGradientStop.
[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
65571936 7// Licence: wxWindows licence
1a56f55c
RR
8/////////////////////////////////////////////////////////////////////////////
9
14f355c2
VS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
1a56f55c 12
dcf924a3
RR
13#if wxUSE_STATBMP
14
1e6feb95
VZ
15#include "wx/statbmp.h"
16
83624f79
RR
17#include "gdk/gdk.h"
18#include "gtk/gtk.h"
19
1a56f55c
RR
20//-----------------------------------------------------------------------------
21// wxStaticBitmap
22//-----------------------------------------------------------------------------
23
24IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
25
26wxStaticBitmap::wxStaticBitmap(void)
27{
58614078 28}
1a56f55c 29
c35414db
VZ
30wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
31 const wxPoint &pos, const wxSize &size,
debe6624 32 long style, const wxString &name )
1a56f55c 33{
a93109d5 34 Create( parent, id, bitmap, pos, size, style, name );
58614078 35}
1a56f55c 36
4fab7128
VS
37// empty bitmap, so that we can create GtkPixmap widget:
38static char * bogus_xpm[] = {
39"2 2 1 1",
03647350 40" c None",
4fab7128
VS
41" ",
42" "};
32d4bfd1 43
c35414db 44bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
32d4bfd1
VZ
45 const wxPoint &pos, const wxSize &size,
46 long style, const wxString &name )
1a56f55c 47{
a93109d5 48 m_needParent = TRUE;
c35414db 49
4dcaf11a
RR
50 if (!PreCreation( parent, pos, size ) ||
51 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
52 {
4fab7128
VS
53 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
54 return false;
4dcaf11a 55 }
1a56f55c 56
a93109d5 57 m_bitmap = bitmap;
c35414db 58
4fab7128
VS
59 wxBitmap bmp(bitmap.Ok() ? bitmap : wxBitmap(bogus_xpm));
60 m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
4fab7128
VS
61
62 if (bitmap.Ok())
63 SetBitmap(bitmap);
31528cd3 64
abdeb9e7 65 PostCreation(size);
f03fc89f 66 m_parent->DoAddChild( this );
c35414db 67
4fab7128 68 return true;
58614078 69}
1a56f55c 70
c35414db 71void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
1a56f55c 72{
a93109d5 73 m_bitmap = bitmap;
c35414db 74
a93109d5
RR
75 if (m_bitmap.Ok())
76 {
d3b9f782 77 GdkBitmap *mask = NULL;
4fab7128
VS
78 if (m_bitmap.GetMask())
79 mask = m_bitmap.GetMask()->GetBitmap();
3d257b8d 80
7e52dfd2 81 gtk_pixmap_set(GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask);
31528cd3 82
9f884528
RD
83 InvalidateBestSize();
84 SetSize(GetBestSize());
a93109d5 85 }
58614078 86}
dcf924a3 87
9d522606
RD
88// static
89wxVisualAttributes
90wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
91{
92 // TODO: overload to allow using gtk_pixmap_new?
93 return GetDefaultAttributesFromGTKWidget(gtk_label_new);
94}
95
1e6feb95 96#endif // wxUSE_STATBMP
f68586e5 97