]>
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"
20 #include <Xm/LabelG.h>
21 #include <Xm/RowColumn.h>
23 #include <wx/motif/private.h>
25 #if !USE_SHARED_LIBRARY
26 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
33 bool wxStaticBitmap::Create(wxWindow
*parent
, wxWindowID id
,
34 const wxBitmap
& bitmap
,
40 m_messageBitmap
= bitmap
;
42 if (parent
) parent
->AddChild(this);
45 m_windowId
= (int)NewControlId();
49 m_windowStyle
= style
;
51 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
53 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
55 xmLabelGadgetClass
, parentWidget
,
57 xmLabelWidgetClass
, parentWidget
,
59 XmNalignment
, XmALIGNMENT_BEGINNING
,
62 XtVaSetValues ((Widget
) m_mainWidget
,
63 XmNlabelPixmap
, (Pixmap
) ((wxBitmap
&)bitmap
).GetLabelPixmap (m_mainWidget
),
64 XmNlabelType
, XmPIXMAP
,
67 SetCanAddEventHandler(TRUE
);
68 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
, pos
.x
, pos
.y
, size
.x
, size
.y
);
70 SetFont(* parent
->GetFont());
72 ChangeColour (m_mainWidget
);
77 wxStaticBitmap::~wxStaticBitmap()
79 SetBitmap(wxNullBitmap
);
82 void wxStaticBitmap::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
84 wxControl::SetSize(x
, y
, width
, height
, sizeFlags
);
87 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
89 m_messageBitmap
= bitmap
;
91 Widget widget
= (Widget
) m_mainWidget
;
92 int x
, y
, w1
, h1
, w2
, h2
;
98 w2
= bitmap
.GetWidth();
99 h2
= bitmap
.GetHeight();
100 XtVaSetValues (widget
,
101 XmNlabelPixmap
, ((wxBitmap
&)bitmap
).GetLabelPixmap (widget
),
102 XmNlabelType
, XmPIXMAP
,
106 if (! (w1
== w2
) && (h1
== h2
))
107 SetSize(x
, y
, w2
, h2
);
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?