]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxStaticBitmap
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "statbmp.h"
18 #include "wx/statbmp.h"
21 #pragma message disable nosimpint
25 #include <Xm/LabelG.h>
26 #include <Xm/RowColumn.h>
28 #pragma message enable nosimpint
31 #include "wx/motif/private.h"
33 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
39 bool wxStaticBitmap::Create(wxWindow
*parent
, wxWindowID id
,
40 const wxBitmap
& bitmap
,
46 m_messageBitmap
= bitmap
;
48 m_backgroundColour
= parent
->GetBackgroundColour();
49 m_foregroundColour
= parent
->GetForegroundColour();
50 if (parent
) parent
->AddChild(this);
53 m_windowId
= (int)NewControlId();
57 m_windowStyle
= style
;
59 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
61 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
63 xmLabelGadgetClass
, parentWidget
,
65 xmLabelWidgetClass
, parentWidget
,
67 XmNalignment
, XmALIGNMENT_BEGINNING
,
70 XtVaSetValues ((Widget
) m_mainWidget
,
71 XmNlabelPixmap
, (Pixmap
) ((wxBitmap
&)bitmap
).GetLabelPixmap (m_mainWidget
),
72 XmNlabelType
, XmPIXMAP
,
75 m_font
= parent
->GetFont();
78 SetCanAddEventHandler(TRUE
);
80 wxSize
actualSize(size
);
81 if (actualSize
.x
== -1)
82 actualSize
.x
= bitmap
.GetWidth();
83 if (actualSize
.y
== -1)
84 actualSize
.y
= bitmap
.GetHeight();
85 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
, pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
87 ChangeBackgroundColour ();
92 wxStaticBitmap::~wxStaticBitmap()
94 SetBitmap(wxNullBitmap
);
97 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
99 m_messageBitmap
= bitmap
;
101 Widget widget
= (Widget
) m_mainWidget
;
102 int x
, y
, w1
, h1
, w2
, h2
;
108 w2
= bitmap
.GetWidth();
109 h2
= bitmap
.GetHeight();
110 XtVaSetValues (widget
,
111 XmNlabelPixmap
, ((wxBitmap
&)bitmap
).GetLabelPixmap (widget
),
112 XmNlabelType
, XmPIXMAP
,
116 if (! (w1
== w2
) && (h1
== h2
))
117 SetSize(x
, y
, w2
, h2
);
121 // Null bitmap: must not use current pixmap
122 // since it is no longer valid.
123 XtVaSetValues (widget
,
124 XmNlabelType
, XmSTRING
,
125 XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
,
130 void wxStaticBitmap::ChangeFont(bool keepOriginalSize
)
132 wxWindow::ChangeFont(keepOriginalSize
);
135 void wxStaticBitmap::ChangeBackgroundColour()
137 wxWindow::ChangeBackgroundColour();
140 void wxStaticBitmap::ChangeForegroundColour()
142 wxWindow::ChangeForegroundColour();