]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/statbmp.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/statbmp.cpp
3 // Purpose: wxStaticBitmap
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
14 #include "wx/statbmp.h"
17 #pragma message disable nosimpint
21 #include <Xm/LabelG.h>
23 #pragma message enable nosimpint
26 #include "wx/motif/private.h"
32 bool wxStaticBitmap::Create(wxWindow
*parent
, wxWindowID id
,
33 const wxBitmap
& bitmap
,
39 if( !CreateControl( parent
, id
, pos
, size
, style
, wxDefaultValidator
,
44 m_messageBitmap
= bitmap
;
45 m_messageBitmapOriginal
= bitmap
;
47 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
49 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
51 xmLabelGadgetClass
, parentWidget
,
53 xmLabelWidgetClass
, parentWidget
,
55 XmNalignment
, XmALIGNMENT_BEGINNING
,
58 wxSize
actualSize(size
);
59 // work around the cases where the bitmap is a wxNull(Icon/Bitmap)
60 if (actualSize
.x
== -1)
61 actualSize
.x
= bitmap
.IsOk() ? bitmap
.GetWidth() : 1;
62 if (actualSize
.y
== -1)
63 actualSize
.y
= bitmap
.IsOk() ? bitmap
.GetHeight() : 1;
67 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
68 pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
73 wxStaticBitmap::~wxStaticBitmap()
75 SetBitmap(wxNullBitmap
);
78 void wxStaticBitmap::DoSetBitmap()
80 Widget widget
= (Widget
) m_mainWidget
;
83 if (m_messageBitmapOriginal
.IsOk())
85 w2
= m_messageBitmapOriginal
.GetWidth();
86 h2
= m_messageBitmapOriginal
.GetHeight();
90 // Must re-make the bitmap to have its transparent areas drawn
91 // in the current widget background colour.
92 if (m_messageBitmapOriginal
.GetMask())
94 WXPixel backgroundPixel
;
95 XtVaGetValues( widget
, XmNbackground
, &backgroundPixel
,
99 col
.SetPixel(backgroundPixel
);
101 wxBitmap newBitmap
= wxCreateMaskedBitmap(m_messageBitmapOriginal
, col
);
102 m_messageBitmap
= newBitmap
;
104 pixmap
= (Pixmap
) m_messageBitmap
.GetDrawable();
108 m_bitmapCache
.SetBitmap( m_messageBitmap
);
109 pixmap
= (Pixmap
)m_bitmapCache
.GetLabelPixmap(widget
);
112 XtVaSetValues (widget
,
113 XmNlabelPixmap
, pixmap
,
114 XmNlabelType
, XmPIXMAP
,
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::SetBitmap(const wxBitmap
& bitmap
)
132 m_messageBitmap
= bitmap
;
133 m_messageBitmapOriginal
= bitmap
;
138 void wxStaticBitmap::ChangeBackgroundColour()
140 wxWindow::ChangeBackgroundColour();
142 // must recalculate the background colour
143 m_bitmapCache
.SetColoursChanged();
147 void wxStaticBitmap::ChangeForegroundColour()
149 m_bitmapCache
.SetColoursChanged();
150 wxWindow::ChangeForegroundColour();