]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/statbmp.cpp
Avoid outputting the assert message twice in non-GUI code.
[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
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
4a4a02ac 17#include <gtk/gtk.h>
83624f79 18
1a56f55c
RR
19//-----------------------------------------------------------------------------
20// wxStaticBitmap
21//-----------------------------------------------------------------------------
22
23IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
24
25wxStaticBitmap::wxStaticBitmap(void)
26{
58614078 27}
1a56f55c 28
c35414db
VZ
29wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
30 const wxPoint &pos, const wxSize &size,
debe6624 31 long style, const wxString &name )
1a56f55c 32{
a93109d5 33 Create( parent, id, bitmap, pos, size, style, name );
58614078 34}
1a56f55c 35
c35414db 36bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
32d4bfd1
VZ
37 const wxPoint &pos, const wxSize &size,
38 long style, const wxString &name )
1a56f55c 39{
4dcaf11a
RR
40 if (!PreCreation( parent, pos, size ) ||
41 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
42 {
4fab7128
VS
43 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
44 return false;
4dcaf11a 45 }
1a56f55c 46
a93109d5 47 m_bitmap = bitmap;
c35414db 48
4fab7128 49 m_widget = gtk_image_new();
9ff9d30c 50 g_object_ref(m_widget);
4fab7128
VS
51
52 if (bitmap.Ok())
53 SetBitmap(bitmap);
31528cd3 54
abdeb9e7 55 PostCreation(size);
f03fc89f 56 m_parent->DoAddChild( this );
c35414db 57
4fab7128 58 return true;
58614078 59}
1a56f55c 60
c35414db 61void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
1a56f55c 62{
a93109d5 63 m_bitmap = bitmap;
c35414db 64
a93109d5
RR
65 if (m_bitmap.Ok())
66 {
4a4a02ac
PC
67 // always use pixbuf, because pixmap mask does not
68 // work with disabled images in some themes
69 gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget), m_bitmap.GetPixbuf());
31528cd3 70
9f884528
RD
71 InvalidateBestSize();
72 SetSize(GetBestSize());
a93109d5 73 }
58614078 74}
dcf924a3 75
9d522606
RD
76// static
77wxVisualAttributes
78wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
79{
80 // TODO: overload to allow using gtk_pixmap_new?
81 return GetDefaultAttributesFromGTKWidget(gtk_label_new);
82}
83
1e6feb95 84#endif // wxUSE_STATBMP
f68586e5 85