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