]>
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
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 #include "wx/statbmp.h"
18 #pragma message disable nosimpint
22 #include <Xm/LabelG.h>
24 #pragma message enable nosimpint
27 #include "wx/motif/private.h"
29 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
35 bool wxStaticBitmap::Create(wxWindow
*parent
, wxWindowID id
,
36 const wxBitmap
& bitmap
,
42 if( !CreateControl( parent
, id
, pos
, size
, style
, wxDefaultValidator
,
47 m_messageBitmap
= bitmap
;
48 m_messageBitmapOriginal
= bitmap
;
50 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
52 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
54 xmLabelGadgetClass
, parentWidget
,
56 xmLabelWidgetClass
, parentWidget
,
58 XmNalignment
, XmALIGNMENT_BEGINNING
,
61 wxSize
actualSize(size
);
62 // work around the cases where the bitmap is a wxNull(Icon/Bitmap)
63 if (actualSize
.x
== -1)
64 actualSize
.x
= bitmap
.Ok() ? bitmap
.GetWidth() : 1;
65 if (actualSize
.y
== -1)
66 actualSize
.y
= bitmap
.Ok() ? bitmap
.GetHeight() : 1;
70 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
71 pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
76 wxStaticBitmap::~wxStaticBitmap()
78 SetBitmap(wxNullBitmap
);
81 void wxStaticBitmap::DoSetBitmap()
83 Widget widget
= (Widget
) m_mainWidget
;
86 if (m_messageBitmapOriginal
.Ok())
88 w2
= m_messageBitmapOriginal
.GetWidth();
89 h2
= m_messageBitmapOriginal
.GetHeight();
93 // Must re-make the bitmap to have its transparent areas drawn
94 // in the current widget background colour.
95 if (m_messageBitmapOriginal
.GetMask())
97 WXPixel backgroundPixel
;
98 XtVaGetValues( widget
, XmNbackground
, &backgroundPixel
,
102 col
.SetPixel(backgroundPixel
);
104 wxBitmap newBitmap
= wxCreateMaskedBitmap(m_messageBitmapOriginal
, col
);
105 m_messageBitmap
= newBitmap
;
107 pixmap
= (Pixmap
) m_messageBitmap
.GetDrawable();
111 m_bitmapCache
.SetBitmap( m_messageBitmap
);
112 pixmap
= (Pixmap
)m_bitmapCache
.GetLabelPixmap(widget
);
115 XtVaSetValues (widget
,
116 XmNlabelPixmap
, pixmap
,
117 XmNlabelType
, XmPIXMAP
,
124 // Null bitmap: must not use current pixmap
125 // since it is no longer valid.
126 XtVaSetValues (widget
,
127 XmNlabelType
, XmSTRING
,
128 XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
,
133 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
135 m_messageBitmap
= bitmap
;
136 m_messageBitmapOriginal
= bitmap
;
141 void wxStaticBitmap::ChangeBackgroundColour()
143 wxWindow::ChangeBackgroundColour();
145 // must recalculate the background colour
146 m_bitmapCache
.SetColoursChanged();
150 void wxStaticBitmap::ChangeForegroundColour()
152 m_bitmapCache
.SetColoursChanged();
153 wxWindow::ChangeForegroundColour();