]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/statbmp.cpp
eea9bd71b997d6c7e5fda8cd5bae826b57f0b93c
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"
33 bool wxStaticBitmap::Create(wxWindow
*parent
, wxWindowID id
,
34 const wxBitmap
& bitmap
,
40 if( !CreateControl( parent
, id
, pos
, size
, style
, wxDefaultValidator
,
45 m_messageBitmap
= bitmap
;
46 m_messageBitmapOriginal
= bitmap
;
48 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
50 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
52 xmLabelGadgetClass
, parentWidget
,
54 xmLabelWidgetClass
, parentWidget
,
56 XmNalignment
, XmALIGNMENT_BEGINNING
,
59 wxSize
actualSize(size
);
60 // work around the cases where the bitmap is a wxNull(Icon/Bitmap)
61 if (actualSize
.x
== -1)
62 actualSize
.x
= bitmap
.IsOk() ? bitmap
.GetWidth() : 1;
63 if (actualSize
.y
== -1)
64 actualSize
.y
= bitmap
.IsOk() ? bitmap
.GetHeight() : 1;
68 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
69 pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
74 wxStaticBitmap::~wxStaticBitmap()
76 SetBitmap(wxNullBitmap
);
79 void wxStaticBitmap::DoSetBitmap()
81 Widget widget
= (Widget
) m_mainWidget
;
84 if (m_messageBitmapOriginal
.IsOk())
86 w2
= m_messageBitmapOriginal
.GetWidth();
87 h2
= m_messageBitmapOriginal
.GetHeight();
91 // Must re-make the bitmap to have its transparent areas drawn
92 // in the current widget background colour.
93 if (m_messageBitmapOriginal
.GetMask())
95 WXPixel backgroundPixel
;
96 XtVaGetValues( widget
, XmNbackground
, &backgroundPixel
,
100 col
.SetPixel(backgroundPixel
);
102 wxBitmap newBitmap
= wxCreateMaskedBitmap(m_messageBitmapOriginal
, col
);
103 m_messageBitmap
= newBitmap
;
105 pixmap
= (Pixmap
) m_messageBitmap
.GetDrawable();
109 m_bitmapCache
.SetBitmap( m_messageBitmap
);
110 pixmap
= (Pixmap
)m_bitmapCache
.GetLabelPixmap(widget
);
113 XtVaSetValues (widget
,
114 XmNlabelPixmap
, pixmap
,
115 XmNlabelType
, XmPIXMAP
,
122 // Null bitmap: must not use current pixmap
123 // since it is no longer valid.
124 XtVaSetValues (widget
,
125 XmNlabelType
, XmSTRING
,
126 XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
,
131 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
133 m_messageBitmap
= bitmap
;
134 m_messageBitmapOriginal
= bitmap
;
139 void wxStaticBitmap::ChangeBackgroundColour()
141 wxWindow::ChangeBackgroundColour();
143 // must recalculate the background colour
144 m_bitmapCache
.SetColoursChanged();
148 void wxStaticBitmap::ChangeForegroundColour()
150 m_bitmapCache
.SetColoursChanged();
151 wxWindow::ChangeForegroundColour();