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