]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/statbmp.cpp
reverted DrawRotatedText change, it's broken
[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#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11#pragma implementation "statbmp.h"
12#endif
13
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
17#if wxUSE_STATBMP
18
19#include "wx/statbmp.h"
20
21#include "gdk/gdk.h"
22#include "gtk/gtk.h"
23
24//-----------------------------------------------------------------------------
25// wxStaticBitmap
26//-----------------------------------------------------------------------------
27
28IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl)
29
30wxStaticBitmap::wxStaticBitmap(void)
31{
32}
33
34wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
35 const wxPoint &pos, const wxSize &size,
36 long style, const wxString &name )
37{
38 Create( parent, id, bitmap, pos, size, style, name );
39}
40
41#ifndef __WXGTK20__
42// empty bitmap, so that we can create GtkPixmap widget:
43static char * bogus_xpm[] = {
44"2 2 1 1",
45" c None",
46" ",
47" "};
48#endif
49
50bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap,
51 const wxPoint &pos, const wxSize &size,
52 long style, const wxString &name )
53{
54 m_needParent = TRUE;
55
56 if (!PreCreation( parent, pos, size ) ||
57 !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
58 {
59 wxFAIL_MSG( wxT("wxStaticBitmap creation failed") );
60 return false;
61 }
62
63 m_bitmap = bitmap;
64
65#ifdef __WXGTK20__
66 m_widget = gtk_image_new();
67#else
68 wxBitmap bmp(bitmap.Ok() ? bitmap : wxBitmap(bogus_xpm));
69 m_widget = gtk_pixmap_new(bmp.GetPixmap(), NULL);
70#endif
71
72 if (bitmap.Ok())
73 SetBitmap(bitmap);
74
75 PostCreation(size);
76 m_parent->DoAddChild( this );
77
78 return true;
79}
80
81void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
82{
83 m_bitmap = bitmap;
84
85 if (m_bitmap.Ok())
86 {
87 GdkBitmap *mask = (GdkBitmap *) NULL;
88 if (m_bitmap.GetMask())
89 mask = m_bitmap.GetMask()->GetBitmap();
90
91#ifdef __WXGTK20__
92 if (m_bitmap.HasPixbuf())
93 {
94 gtk_image_set_from_pixbuf(GTK_IMAGE(m_widget),
95 m_bitmap.GetPixbuf());
96 }
97 else
98 gtk_image_set_from_pixmap(GTK_IMAGE(m_widget),
99 m_bitmap.GetPixmap(), mask);
100#else
101 gtk_pixmap_set(GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask);
102#endif
103
104 InvalidateBestSize();
105 SetSize(GetBestSize());
106 }
107}
108
109// static
110wxVisualAttributes
111wxStaticBitmap::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
112{
113 // TODO: overload to allow using gtk_pixmap_new?
114 return GetDefaultAttributesFromGTKWidget(gtk_label_new);
115}
116
117#endif // wxUSE_STATBMP
118