]>
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>
27 #pragma message enable nosimpint
30 #include "wx/motif/private.h"
32 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
38 bool wxStaticBitmap::Create(wxWindow
*parent
, wxWindowID id
,
39 const wxBitmap
& bitmap
,
45 if( !CreateControl( parent
, id
, pos
, size
, style
, wxDefaultValidator
,
49 m_messageBitmap
= bitmap
;
50 m_messageBitmapOriginal
= bitmap
;
52 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
54 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
56 xmLabelGadgetClass
, parentWidget
,
58 xmLabelWidgetClass
, parentWidget
,
60 XmNalignment
, XmALIGNMENT_BEGINNING
,
63 ChangeBackgroundColour ();
69 wxSize
actualSize(size
);
70 // work around the cases where the bitmap is a wxNull(Icon/Bitmap)
71 if (actualSize
.x
== -1)
72 actualSize
.x
= bitmap
.Ok() ? bitmap
.GetWidth() : 1;
73 if (actualSize
.y
== -1)
74 actualSize
.y
= bitmap
.Ok() ? bitmap
.GetHeight() : 1;
75 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
76 pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
81 wxStaticBitmap::~wxStaticBitmap()
83 SetBitmap(wxNullBitmap
);
86 void wxStaticBitmap::DoSetBitmap()
88 Widget widget
= (Widget
) m_mainWidget
;
91 if (m_messageBitmapOriginal
.Ok())
93 w2
= m_messageBitmapOriginal
.GetWidth();
94 h2
= m_messageBitmapOriginal
.GetHeight();
98 // Must re-make the bitmap to have its transparent areas drawn
99 // in the current widget background colour.
100 if (m_messageBitmapOriginal
.GetMask())
103 XtVaGetValues( widget
, XmNbackground
, &backgroundPixel
,
107 col
.SetPixel(backgroundPixel
);
109 wxBitmap newBitmap
= wxCreateMaskedBitmap(m_messageBitmapOriginal
, col
);
110 m_messageBitmap
= newBitmap
;
112 pixmap
= (Pixmap
) m_messageBitmap
.GetDrawable();
116 m_bitmapCache
.SetBitmap( m_messageBitmap
);
117 pixmap
= (Pixmap
)m_bitmapCache
.GetLabelPixmap(widget
);
120 XtVaSetValues (widget
,
121 XmNlabelPixmap
, pixmap
,
122 XmNlabelType
, XmPIXMAP
,
129 // Null bitmap: must not use current pixmap
130 // since it is no longer valid.
131 XtVaSetValues (widget
,
132 XmNlabelType
, XmSTRING
,
133 XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
,
138 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
140 m_messageBitmap
= bitmap
;
141 m_messageBitmapOriginal
= bitmap
;
146 void wxStaticBitmap::ChangeBackgroundColour()
148 wxWindow::ChangeBackgroundColour();
150 // must recalculate the background colour
151 m_bitmapCache
.SetColoursChanged();
155 void wxStaticBitmap::ChangeForegroundColour()
157 m_bitmapCache
.SetColoursChanged();
158 wxWindow::ChangeForegroundColour();