]> git.saurik.com Git - wxWidgets.git/blob - src/motif/statbmp.cpp
removed 68K targets and preferences
[wxWidgets.git] / src / motif / statbmp.cpp
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "statbmp.h"
14 #endif
15
16 #include "wx/defs.h"
17
18 #include "wx/statbmp.h"
19
20 #ifdef __VMS__
21 #pragma message disable nosimpint
22 #endif
23 #include <Xm/Xm.h>
24 #include <Xm/Label.h>
25 #include <Xm/LabelG.h>
26 #include <Xm/RowColumn.h>
27 #ifdef __VMS__
28 #pragma message enable nosimpint
29 #endif
30
31 #include "wx/motif/private.h"
32
33 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
34
35 /*
36 * wxStaticBitmap
37 */
38
39 bool 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);
48 m_backgroundColour = parent->GetBackgroundColour();
49 m_foregroundColour = parent->GetForegroundColour();
50 if (parent) parent->AddChild(this);
51
52 if ( id == -1 )
53 m_windowId = (int)NewControlId();
54 else
55 m_windowId = id;
56
57 m_windowStyle = style;
58
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
75 m_font = parent->GetFont();
76 ChangeFont(FALSE);
77
78 SetCanAddEventHandler(TRUE);
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);
86
87 ChangeBackgroundColour ();
88
89 return TRUE;
90 }
91
92 wxStaticBitmap::~wxStaticBitmap()
93 {
94 SetBitmap(wxNullBitmap);
95 }
96
97 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
98 {
99 m_messageBitmap = bitmap;
100
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,
113 NULL);
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,
125 XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
126 NULL);
127 }
128 }
129
130 void wxStaticBitmap::ChangeFont(bool keepOriginalSize)
131 {
132 wxWindow::ChangeFont(keepOriginalSize);
133 }
134
135 void wxStaticBitmap::ChangeBackgroundColour()
136 {
137 wxWindow::ChangeBackgroundColour();
138 }
139
140 void wxStaticBitmap::ChangeForegroundColour()
141 {
142 wxWindow::ChangeForegroundColour();
143 }
144