]> git.saurik.com Git - wxWidgets.git/blame - src/motif/statbmp.cpp
Committing in .
[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
JS
31#if !USE_SHARED_LIBRARY
32IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
33#endif
34
35/*
36 * wxStaticBitmap
37 */
38
39bool 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);
0d57be45
JS
48 m_backgroundColour = parent->GetBackgroundColour();
49 m_foregroundColour = parent->GetForegroundColour();
4bb6408c
JS
50 if (parent) parent->AddChild(this);
51
52 if ( id == -1 )
31528cd3 53 m_windowId = (int)NewControlId();
4bb6408c 54 else
31528cd3 55 m_windowId = id;
4bb6408c
JS
56
57 m_windowStyle = style;
58
a4294b78
JS
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
da175b2c 75 m_font = parent->GetFont();
4b5f3fe6
JS
76 ChangeFont(FALSE);
77
a4294b78
JS
78 SetCanAddEventHandler(TRUE);
79 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
80
0d57be45 81 ChangeBackgroundColour ();
a4294b78
JS
82
83 return TRUE;
84}
85
86wxStaticBitmap::~wxStaticBitmap()
87{
88 SetBitmap(wxNullBitmap);
4bb6408c
JS
89}
90
4bb6408c
JS
91void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
92{
93 m_messageBitmap = bitmap;
94
a4294b78
JS
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,
31528cd3 107 NULL);
a4294b78
JS
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,
1a3ac83f 119 XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
a4294b78
JS
120 NULL);
121 }
4bb6408c
JS
122}
123
4b5f3fe6 124void wxStaticBitmap::ChangeFont(bool keepOriginalSize)
0d57be45 125{
4b5f3fe6 126 wxWindow::ChangeFont(keepOriginalSize);
0d57be45
JS
127}
128
129void wxStaticBitmap::ChangeBackgroundColour()
130{
321db4b6 131 wxWindow::ChangeBackgroundColour();
0d57be45
JS
132}
133
134void wxStaticBitmap::ChangeForegroundColour()
135{
321db4b6 136 wxWindow::ChangeForegroundColour();
0d57be45
JS
137}
138