]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "statbmp.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
21 #include "wx/statbmp.h"
24 #pragma message disable nosimpint
28 #include <Xm/LabelG.h>
30 #pragma message enable nosimpint
33 #include "wx/motif/private.h"
35 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
41 bool wxStaticBitmap::Create(wxWindow
*parent
, wxWindowID id
,
42 const wxBitmap
& bitmap
,
48 if( !CreateControl( parent
, id
, pos
, size
, style
, wxDefaultValidator
,
52 m_messageBitmap
= bitmap
;
53 m_messageBitmapOriginal
= bitmap
;
55 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
57 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
59 xmLabelGadgetClass
, parentWidget
,
61 xmLabelWidgetClass
, parentWidget
,
63 XmNalignment
, XmALIGNMENT_BEGINNING
,
66 ChangeBackgroundColour ();
72 wxSize
actualSize(size
);
73 // work around the cases where the bitmap is a wxNull(Icon/Bitmap)
74 if (actualSize
.x
== -1)
75 actualSize
.x
= bitmap
.Ok() ? bitmap
.GetWidth() : 1;
76 if (actualSize
.y
== -1)
77 actualSize
.y
= bitmap
.Ok() ? bitmap
.GetHeight() : 1;
78 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
,
79 pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
84 wxStaticBitmap::~wxStaticBitmap()
86 SetBitmap(wxNullBitmap
);
89 void wxStaticBitmap::DoSetBitmap()
91 Widget widget
= (Widget
) m_mainWidget
;
94 if (m_messageBitmapOriginal
.Ok())
96 w2
= m_messageBitmapOriginal
.GetWidth();
97 h2
= m_messageBitmapOriginal
.GetHeight();
101 // Must re-make the bitmap to have its transparent areas drawn
102 // in the current widget background colour.
103 if (m_messageBitmapOriginal
.GetMask())
106 XtVaGetValues( widget
, XmNbackground
, &backgroundPixel
,
110 col
.SetPixel(backgroundPixel
);
112 wxBitmap newBitmap
= wxCreateMaskedBitmap(m_messageBitmapOriginal
, col
);
113 m_messageBitmap
= newBitmap
;
115 pixmap
= (Pixmap
) m_messageBitmap
.GetDrawable();
119 m_bitmapCache
.SetBitmap( m_messageBitmap
);
120 pixmap
= (Pixmap
)m_bitmapCache
.GetLabelPixmap(widget
);
123 XtVaSetValues (widget
,
124 XmNlabelPixmap
, pixmap
,
125 XmNlabelType
, XmPIXMAP
,
132 // Null bitmap: must not use current pixmap
133 // since it is no longer valid.
134 XtVaSetValues (widget
,
135 XmNlabelType
, XmSTRING
,
136 XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
,
141 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
143 m_messageBitmap
= bitmap
;
144 m_messageBitmapOriginal
= bitmap
;
149 void wxStaticBitmap::ChangeBackgroundColour()
151 wxWindow::ChangeBackgroundColour();
153 // must recalculate the background colour
154 m_bitmapCache
.SetColoursChanged();
158 void wxStaticBitmap::ChangeForegroundColour()
160 m_bitmapCache
.SetColoursChanged();
161 wxWindow::ChangeForegroundColour();