]> git.saurik.com Git - wxWidgets.git/blob - src/motif/statbmp.cpp
check for LVS_OWNERDATA availability at compile and run-time
[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 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
32
33 /*
34 * wxStaticBitmap
35 */
36
37 bool 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);
46 m_backgroundColour = parent->GetBackgroundColour();
47 m_foregroundColour = parent->GetForegroundColour();
48 if (parent) parent->AddChild(this);
49
50 if ( id == -1 )
51 m_windowId = (int)NewControlId();
52 else
53 m_windowId = id;
54
55 m_windowStyle = style;
56
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
73 m_font = parent->GetFont();
74 ChangeFont(FALSE);
75
76 SetCanAddEventHandler(TRUE);
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);
84
85 ChangeBackgroundColour ();
86
87 return TRUE;
88 }
89
90 wxStaticBitmap::~wxStaticBitmap()
91 {
92 SetBitmap(wxNullBitmap);
93 }
94
95 void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
96 {
97 m_messageBitmap = bitmap;
98
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,
111 NULL);
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,
123 XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
124 NULL);
125 }
126 }
127
128 void wxStaticBitmap::ChangeFont(bool keepOriginalSize)
129 {
130 wxWindow::ChangeFont(keepOriginalSize);
131 }
132
133 void wxStaticBitmap::ChangeBackgroundColour()
134 {
135 wxWindow::ChangeBackgroundColour();
136 }
137
138 void wxStaticBitmap::ChangeForegroundColour()
139 {
140 wxWindow::ChangeForegroundColour();
141 }
142