]> git.saurik.com Git - wxWidgets.git/blame - src/motif/statbmp.cpp
fixed crash under GTK+ 2.0
[wxWidgets.git] / src / motif / statbmp.cpp
CommitLineData
4bb6408c
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: statbmp.cpp
3// Purpose: wxStaticBitmap
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
31528cd3 9// Licence: wxWindows licence
4bb6408c
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "statbmp.h"
14#endif
15
f6045f99
GD
16#include "wx/defs.h"
17
4bb6408c
JS
18#include "wx/statbmp.h"
19
338dd992
JJ
20#ifdef __VMS__
21#pragma message disable nosimpint
22#endif
a4294b78
JS
23#include <Xm/Xm.h>
24#include <Xm/Label.h>
25#include <Xm/LabelG.h>
26#include <Xm/RowColumn.h>
338dd992
JJ
27#ifdef __VMS__
28#pragma message enable nosimpint
29#endif
a4294b78 30
3096bd2f 31#include "wx/motif/private.h"
a4294b78 32
4bb6408c 33IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
4bb6408c
JS
34
35/*
36 * wxStaticBitmap
37 */
38
39bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
40 const wxBitmap& bitmap,
41 const wxPoint& pos,
42 const wxSize& size,
43 long style,
44 const wxString& name)
45{
46 m_messageBitmap = bitmap;
47 SetName(name);
0d57be45
JS
48 m_backgroundColour = parent->GetBackgroundColour();
49 m_foregroundColour = parent->GetForegroundColour();
4bb6408c
JS
50 if (parent) parent->AddChild(this);
51
52 if ( id == -1 )
31528cd3 53 m_windowId = (int)NewControlId();
4bb6408c 54 else
31528cd3 55 m_windowId = id;
4bb6408c
JS
56
57 m_windowStyle = style;
58
a4294b78
JS
59 Widget parentWidget = (Widget) parent->GetClientWidget();
60
61 m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("staticBitmap",
62#if USE_GADGETS
63 xmLabelGadgetClass, parentWidget,
64#else
65 xmLabelWidgetClass, parentWidget,
66#endif
67 XmNalignment, XmALIGNMENT_BEGINNING,
68 NULL);
69
70 XtVaSetValues ((Widget) m_mainWidget,
71 XmNlabelPixmap, (Pixmap) ((wxBitmap&)bitmap).GetLabelPixmap (m_mainWidget),
72 XmNlabelType, XmPIXMAP,
73 NULL);
74
da175b2c 75 m_font = parent->GetFont();
4b5f3fe6
JS
76 ChangeFont(FALSE);
77
a4294b78 78 SetCanAddEventHandler(TRUE);
dc1efb1d
JS
79
80 wxSize actualSize(size);
81 if (actualSize.x == -1)
82 actualSize.x = bitmap.GetWidth();
83 if (actualSize.y == -1)
84 actualSize.y = bitmap.GetHeight();
85 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, actualSize.x, actualSize.y);
a4294b78 86
0d57be45 87 ChangeBackgroundColour ();
a4294b78
JS
88
89 return TRUE;
90}
91
92wxStaticBitmap::~wxStaticBitmap()
93{
94 SetBitmap(wxNullBitmap);
4bb6408c
JS
95}
96
4bb6408c
JS
97void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
98{
99 m_messageBitmap = bitmap;
100
a4294b78
JS
101 Widget widget = (Widget) m_mainWidget;
102 int x, y, w1, h1, w2, h2;
103
104 GetPosition(&x, &y);
105
106 if (bitmap.Ok())
107 {
108 w2 = bitmap.GetWidth();
109 h2 = bitmap.GetHeight();
110 XtVaSetValues (widget,
111 XmNlabelPixmap, ((wxBitmap&)bitmap).GetLabelPixmap (widget),
112 XmNlabelType, XmPIXMAP,
31528cd3 113 NULL);
a4294b78
JS
114 GetSize(&w1, &h1);
115
116 if (! (w1 == w2) && (h1 == h2))
117 SetSize(x, y, w2, h2);
118 }
119 else
120 {
121 // Null bitmap: must not use current pixmap
122 // since it is no longer valid.
123 XtVaSetValues (widget,
124 XmNlabelType, XmSTRING,
1a3ac83f 125 XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
a4294b78
JS
126 NULL);
127 }
4bb6408c
JS
128}
129
4b5f3fe6 130void wxStaticBitmap::ChangeFont(bool keepOriginalSize)
0d57be45 131{
4b5f3fe6 132 wxWindow::ChangeFont(keepOriginalSize);
0d57be45
JS
133}
134
135void wxStaticBitmap::ChangeBackgroundColour()
136{
321db4b6 137 wxWindow::ChangeBackgroundColour();
0d57be45
JS
138}
139
140void wxStaticBitmap::ChangeForegroundColour()
141{
321db4b6 142 wxWindow::ChangeForegroundColour();
0d57be45
JS
143}
144