]>
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 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
17 #include "wx/statbmp.h"
20 #pragma message disable nosimpint
24 #include <Xm/LabelG.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 if( !CreateControl( parent
, id
, pos
, size
, style
, wxDefaultValidator
,
48 m_messageBitmap
= bitmap
;
49 m_messageBitmapOriginal
= bitmap
;
51 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
53 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
55 xmLabelGadgetClass
, parentWidget
,
57 xmLabelWidgetClass
, parentWidget
,
59 XmNalignment
, XmALIGNMENT_BEGINNING
,
62 ChangeBackgroundColour ();
68 wxSize
actualSize(size
);
69 // work around the cases where the bitmap is a wxNull(Icon/Bitmap)
70 if (actualSize
.x
== -1)
71 actualSize
.x
= bitmap
.Ok() ? bitmap
.GetWidth() : 1;
72 if (actualSize
.y
== -1)
73 actualSize
.y
= bitmap
.Ok() ? bitmap
.GetHeight() : 1;
74 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
75 pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
80 wxStaticBitmap::~wxStaticBitmap()
82 SetBitmap(wxNullBitmap
);
85 void wxStaticBitmap::DoSetBitmap()
87 Widget widget
= (Widget
) m_mainWidget
;
90 if (m_messageBitmapOriginal
.Ok())
92 w2
= m_messageBitmapOriginal
.GetWidth();
93 h2
= m_messageBitmapOriginal
.GetHeight();
97 // Must re-make the bitmap to have its transparent areas drawn
98 // in the current widget background colour.
99 if (m_messageBitmapOriginal
.GetMask())
102 XtVaGetValues( widget
, XmNbackground
, &backgroundPixel
,
106 col
.SetPixel(backgroundPixel
);
108 wxBitmap newBitmap
= wxCreateMaskedBitmap(m_messageBitmapOriginal
, col
);
109 m_messageBitmap
= newBitmap
;
111 pixmap
= (Pixmap
) m_messageBitmap
.GetDrawable();
115 m_bitmapCache
.SetBitmap( m_messageBitmap
);
116 pixmap
= (Pixmap
)m_bitmapCache
.GetLabelPixmap(widget
);
119 XtVaSetValues (widget
,
120 XmNlabelPixmap
, pixmap
,
121 XmNlabelType
, XmPIXMAP
,
128 // Null bitmap: must not use current pixmap
129 // since it is no longer valid.
130 XtVaSetValues (widget
,
131 XmNlabelType
, XmSTRING
,
132 XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
,
137 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
139 m_messageBitmap
= bitmap
;
140 m_messageBitmapOriginal
= bitmap
;
145 void wxStaticBitmap::ChangeBackgroundColour()
147 wxWindow::ChangeBackgroundColour();
149 // must recalculate the background colour
150 m_bitmapCache
.SetColoursChanged();
154 void wxStaticBitmap::ChangeForegroundColour()
156 m_bitmapCache
.SetColoursChanged();
157 wxWindow::ChangeForegroundColour();