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