]> git.saurik.com Git - wxWidgets.git/blob - src/motif/statbmp.cpp
debug check for infinite loop in InitializeClasses() added
[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/statbmp.h"
17
18 #ifdef __VMS__
19 #pragma message disable nosimpint
20 #endif
21 #include <Xm/Xm.h>
22 #include <Xm/Label.h>
23 #include <Xm/LabelG.h>
24 #include <Xm/RowColumn.h>
25 #ifdef __VMS__
26 #pragma message enable nosimpint
27 #endif
28
29 #include "wx/motif/private.h"
30
31 #if !USE_SHARED_LIBRARY
32 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
33 #endif
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 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
80
81 ChangeBackgroundColour ();
82
83 return TRUE;
84 }
85
86 wxStaticBitmap::~wxStaticBitmap()
87 {
88 SetBitmap(wxNullBitmap);
89 }
90
91 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
92 {
93 m_messageBitmap = bitmap;
94
95 Widget widget = (Widget) m_mainWidget;
96 int x, y, w1, h1, w2, h2;
97
98 GetPosition(&x, &y);
99
100 if (bitmap.Ok())
101 {
102 w2 = bitmap.GetWidth();
103 h2 = bitmap.GetHeight();
104 XtVaSetValues (widget,
105 XmNlabelPixmap, ((wxBitmap&)bitmap).GetLabelPixmap (widget),
106 XmNlabelType, XmPIXMAP,
107 NULL);
108 GetSize(&w1, &h1);
109
110 if (! (w1 == w2) && (h1 == h2))
111 SetSize(x, y, w2, h2);
112 }
113 else
114 {
115 // Null bitmap: must not use current pixmap
116 // since it is no longer valid.
117 XtVaSetValues (widget,
118 XmNlabelType, XmSTRING,
119 XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
120 NULL);
121 }
122 }
123
124 void wxStaticBitmap::ChangeFont(bool keepOriginalSize)
125 {
126 wxWindow::ChangeFont(keepOriginalSize);
127 }
128
129 void wxStaticBitmap::ChangeBackgroundColour()
130 {
131 wxWindow::ChangeBackgroundColour();
132 }
133
134 void wxStaticBitmap::ChangeForegroundColour()
135 {
136 wxWindow::ChangeForegroundColour();
137 }
138