]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/statbmp.cpp
Applied #15375 to stop event-sending in generic wxSpinCtrl ctor (eco)
[wxWidgets.git] / src / gtk1 / statbmp.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk1/statbmp.cpp
3// Purpose:
4// Author: Robert Roebling
5// Copyright: (c) 1998 Robert Roebling
6// Licence: wxWindows licence
7/////////////////////////////////////////////////////////////////////////////
8
9// For compilers that support precompilation, includes "wx.h".
10#include "wx/wxprec.h"
11
12#if wxUSE_STATBMP
13
14#include "wx/statbmp.h"
15
16#include "gdk/gdk.h"
17#include "gtk/gtk.h"
18
19//-----------------------------------------------------------------------------
20// wxStaticBitmap
21//-----------------------------------------------------------------------------
22
23wxStaticBitmap::wxStaticBitmap(void)
24{
25}
26
27wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
28 const wxPoint &pos, const wxSize &size,
29 long style, const wxString &name )
30{
31 Create( parent, id, bitmap, pos, size, style, name );
32}
33
34// empty bitmap, so that we can create GtkPixmap widget:
35static char * bogus_xpm[] = {
36"2 2 1 1",
37" c None",
38" ",
39" "};
40
41bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
42 const wxPoint &pos, const wxSize &size,
43 long style, const wxString &name )
44{
45 m_needParent = TRUE;
46
47 if (!PreCreation( parent, pos, size ) ||
48 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
49 {
50 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
51 return false;
52 }
53
54 m_bitmap = bitmap;
55
56 wxBitmap bmp(bitmap.IsOk() ? bitmap : wxBitmap(bogus_xpm));
57 m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
58
59 if (bitmap.IsOk())
60 SetBitmap(bitmap);
61
62 PostCreation(size);
63 m_parent->DoAddChild( this );
64
65 return true;
66}
67
68void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
69{
70 m_bitmap = bitmap;
71
72 if (m_bitmap.IsOk())
73 {
74 GdkBitmap *mask = NULL;
75 if (m_bitmap.GetMask())
76 mask = m_bitmap.GetMask()->GetBitmap();
77
78 gtk_pixmap_set(GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask);
79
80 InvalidateBestSize();
81 SetSize(GetBestSize());
82 }
83}
84
85// static
86wxVisualAttributes
87wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
88{
89 // TODO: overload to allow using gtk_pixmap_new?
90 return GetDefaultAttributesFromGTKWidget(gtk_label_new);
91}
92
93#endif // wxUSE_STATBMP
94