]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/statbmp.cpp
another 64 bit fix: make SendMsg() return wxIntPtr instead of long too
[wxWidgets.git] / src / gtk / statbmp.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: statbmp.cpp
3// Purpose:
4// Author: Robert Roebling
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#if wxUSE_STATBMP
14
15#include "wx/statbmp.h"
16
17#include "gdk/gdk.h"
18#include "gtk/gtk.h"
19
20//-----------------------------------------------------------------------------
21// wxStaticBitmap
22//-----------------------------------------------------------------------------
23
24IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
25
26wxStaticBitmap::wxStaticBitmap(void)
27{
28}
29
30wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
31 const wxPoint &pos, const wxSize &size,
32 long style, const wxString &name )
33{
34 Create( parent, id, bitmap, pos, size, style, name );
35}
36
37bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
38 const wxPoint &pos, const wxSize &size,
39 long style, const wxString &name )
40{
41 if (!PreCreation( parent, pos, size ) ||
42 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
43 {
44 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
45 return false;
46 }
47
48 m_bitmap = bitmap;
49
50 m_widget = gtk_image_new();
51
52 if (bitmap.Ok())
53 SetBitmap(bitmap);
54
55 PostCreation(size);
56 m_parent->DoAddChild( this );
57
58 return true;
59}
60
61void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
62{
63 m_bitmap = bitmap;
64
65 if (m_bitmap.Ok())
66 {
67 GdkBitmap *mask = (GdkBitmap *) NULL;
68 if (m_bitmap.GetMask())
69 mask = m_bitmap.GetMask()->GetBitmap();
70
71 if (m_bitmap.HasPixbuf())
72 {
73 gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget),
74 m_bitmap.GetPixbuf());
75 }
76 else
77 gtk_image_set_from_pixmap(GTK_IMAGE(m_widget),
78 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