]> git.saurik.com Git - wxWidgets.git/blame - src/motif/statbmp.cpp
Prealpha, prebeta of new wxTreeCtrl for GTK. It is possible to AddRoot,
[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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "statbmp.h"
14#endif
15
16#include "wx/statbmp.h"
17
a4294b78
JS
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
4bb6408c
JS
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);
0d57be45
JS
42 m_backgroundColour = parent->GetBackgroundColour();
43 m_foregroundColour = parent->GetForegroundColour();
4bb6408c
JS
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
a4294b78
JS
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 SetCanAddEventHandler(TRUE);
70 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
71
72 SetFont(* parent->GetFont());
73
0d57be45 74 ChangeBackgroundColour ();
a4294b78
JS
75
76 return TRUE;
77}
78
79wxStaticBitmap::~wxStaticBitmap()
80{
81 SetBitmap(wxNullBitmap);
4bb6408c
JS
82}
83
84void wxStaticBitmap::SetSize(int x, int y, int width, int height, int sizeFlags)
85{
a4294b78 86 wxControl::SetSize(x, y, width, height, sizeFlags);
4bb6408c
JS
87}
88
89void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
90{
91 m_messageBitmap = bitmap;
92
a4294b78
JS
93 Widget widget = (Widget) m_mainWidget;
94 int x, y, w1, h1, w2, h2;
95
96 GetPosition(&x, &y);
97
98 if (bitmap.Ok())
99 {
100 w2 = bitmap.GetWidth();
101 h2 = bitmap.GetHeight();
102 XtVaSetValues (widget,
103 XmNlabelPixmap, ((wxBitmap&)bitmap).GetLabelPixmap (widget),
104 XmNlabelType, XmPIXMAP,
105 NULL);
106 GetSize(&w1, &h1);
107
108 if (! (w1 == w2) && (h1 == h2))
109 SetSize(x, y, w2, h2);
110 }
111 else
112 {
113 // Null bitmap: must not use current pixmap
114 // since it is no longer valid.
115 XtVaSetValues (widget,
116 XmNlabelType, XmSTRING,
1a3ac83f 117 XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
a4294b78
JS
118 NULL);
119 }
4bb6408c
JS
120}
121
0d57be45
JS
122void wxStaticBitmap::ChangeFont()
123{
321db4b6 124 wxWindow::ChangeFont();
0d57be45
JS
125}
126
127void wxStaticBitmap::ChangeBackgroundColour()
128{
321db4b6 129 wxWindow::ChangeBackgroundColour();
0d57be45
JS
130}
131
132void wxStaticBitmap::ChangeForegroundColour()
133{
321db4b6 134 wxWindow::ChangeForegroundColour();
0d57be45
JS
135}
136