]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/statbmp.cpp
don't use deprecated toolbar API
[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 <gtk/gtk.h>
18
19//-----------------------------------------------------------------------------
20// wxStaticBitmap
21//-----------------------------------------------------------------------------
22
23IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
24
25wxStaticBitmap::wxStaticBitmap(void)
26{
27}
28
29wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
30 const wxPoint &pos, const wxSize &size,
31 long style, const wxString &name )
32{
33 Create( parent, id, bitmap, pos, size, style, name );
34}
35
36bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
37 const wxPoint &pos, const wxSize &size,
38 long style, const wxString &name )
39{
40 if (!PreCreation( parent, pos, size ) ||
41 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
42 {
43 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
44 return false;
45 }
46
47 m_bitmap = bitmap;
48
49 m_widget = gtk_image_new();
50
51 if (bitmap.Ok())
52 SetBitmap(bitmap);
53
54 PostCreation(size);
55 m_parent->DoAddChild( this );
56
57 return true;
58}
59
60void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
61{
62 m_bitmap = bitmap;
63
64 if (m_bitmap.Ok())
65 {
66 // always use pixbuf, because pixmap mask does not
67 // work with disabled images in some themes
68 gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget), m_bitmap.GetPixbuf());
69
70 InvalidateBestSize();
71 SetSize(GetBestSize());
72 }
73}
74
75// static
76wxVisualAttributes
77wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
78{
79 // TODO: overload to allow using gtk_pixmap_new?
80 return GetDefaultAttributesFromGTKWidget(gtk_label_new);
81}
82
83#endif // wxUSE_STATBMP
84