]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/motif/statbmp.cpp
More Motif additions: mdi and sashtest samples now just about work!
[wxWidgets.git] / src / motif / statbmp.cpp
... / ...
CommitLineData
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
26IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
27#endif
28
29/*
30 * wxStaticBitmap
31 */
32
33bool 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 if (parent) parent->AddChild(this);
43
44 if ( id == -1 )
45 m_windowId = (int)NewControlId();
46 else
47 m_windowId = id;
48
49 m_windowStyle = style;
50
51 Widget parentWidget = (Widget) parent->GetClientWidget();
52
53 m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("staticBitmap",
54#if USE_GADGETS
55 xmLabelGadgetClass, parentWidget,
56#else
57 xmLabelWidgetClass, parentWidget,
58#endif
59 XmNalignment, XmALIGNMENT_BEGINNING,
60 NULL);
61
62 XtVaSetValues ((Widget) m_mainWidget,
63 XmNlabelPixmap, (Pixmap) ((wxBitmap&)bitmap).GetLabelPixmap (m_mainWidget),
64 XmNlabelType, XmPIXMAP,
65 NULL);
66
67 SetCanAddEventHandler(TRUE);
68 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
69
70 SetFont(* parent->GetFont());
71
72 ChangeColour (m_mainWidget);
73
74 return TRUE;
75}
76
77wxStaticBitmap::~wxStaticBitmap()
78{
79 SetBitmap(wxNullBitmap);
80}
81
82void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags)
83{
84 wxControl::SetSize(x, y, width, height, sizeFlags);
85}
86
87void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
88{
89 m_messageBitmap = bitmap;
90
91 Widget widget = (Widget) m_mainWidget;
92 int x, y, w1, h1, w2, h2;
93
94 GetPosition(&x, &y);
95
96 if (bitmap.Ok())
97 {
98 w2 = bitmap.GetWidth();
99 h2 = bitmap.GetHeight();
100 XtVaSetValues (widget,
101 XmNlabelPixmap, ((wxBitmap&)bitmap).GetLabelPixmap (widget),
102 XmNlabelType, XmPIXMAP,
103 NULL);
104 GetSize(&w1, &h1);
105
106 if (! (w1 == w2) && (h1 == h2))
107 SetSize(x, y, w2, h2);
108 }
109 else
110 {
111 // Null bitmap: must not use current pixmap
112 // since it is no longer valid.
113 XtVaSetValues (widget,
114 XmNlabelType, XmSTRING,
115 XmNlabelPixmap, NULL, // TODO: Does this work?
116 NULL);
117 }
118}
119