]>
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"
16 #include "wx/statbmp.h"
19 #pragma message disable nosimpint
23 #include <Xm/LabelG.h>
24 #include <Xm/RowColumn.h>
26 #pragma message enable nosimpint
29 #include "wx/motif/private.h"
31 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
37 bool wxStaticBitmap::Create(wxWindow
*parent
, wxWindowID id
,
38 const wxBitmap
& bitmap
,
44 m_messageBitmap
= bitmap
;
46 m_backgroundColour
= parent
->GetBackgroundColour();
47 m_foregroundColour
= parent
->GetForegroundColour();
48 if (parent
) parent
->AddChild(this);
51 m_windowId
= (int)NewControlId();
55 m_windowStyle
= style
;
57 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
59 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
61 xmLabelGadgetClass
, parentWidget
,
63 xmLabelWidgetClass
, parentWidget
,
65 XmNalignment
, XmALIGNMENT_BEGINNING
,
68 XtVaSetValues ((Widget
) m_mainWidget
,
69 XmNlabelPixmap
, (Pixmap
) ((wxBitmap
&)bitmap
).GetLabelPixmap (m_mainWidget
),
70 XmNlabelType
, XmPIXMAP
,
73 m_font
= parent
->GetFont();
76 SetCanAddEventHandler(TRUE
);
78 wxSize
actualSize(size
);
79 if (actualSize
.x
== -1)
80 actualSize
.x
= bitmap
.GetWidth();
81 if (actualSize
.y
== -1)
82 actualSize
.y
= bitmap
.GetHeight();
83 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
, pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
85 ChangeBackgroundColour ();
90 wxStaticBitmap::~wxStaticBitmap()
92 SetBitmap(wxNullBitmap
);
95 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
97 m_messageBitmap
= bitmap
;
99 Widget widget
= (Widget
) m_mainWidget
;
100 int x
, y
, w1
, h1
, w2
, h2
;
106 w2
= bitmap
.GetWidth();
107 h2
= bitmap
.GetHeight();
108 XtVaSetValues (widget
,
109 XmNlabelPixmap
, ((wxBitmap
&)bitmap
).GetLabelPixmap (widget
),
110 XmNlabelType
, XmPIXMAP
,
114 if (! (w1
== w2
) && (h1
== h2
))
115 SetSize(x
, y
, w2
, h2
);
119 // Null bitmap: must not use current pixmap
120 // since it is no longer valid.
121 XtVaSetValues (widget
,
122 XmNlabelType
, XmSTRING
,
123 XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
,
128 void wxStaticBitmap::ChangeFont(bool keepOriginalSize
)
130 wxWindow::ChangeFont(keepOriginalSize
);
133 void wxStaticBitmap::ChangeBackgroundColour()
135 wxWindow::ChangeBackgroundColour();
138 void wxStaticBitmap::ChangeForegroundColour()
140 wxWindow::ChangeForegroundColour();