]>
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
.GetWidth() ? bitmap
.GetWidth() : 1;
73 if (actualSize
.y
== -1)
74 actualSize
.y
= bitmap
.GetHeight() ? 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
;
89 int x
, y
, w1
, h1
, w2
, h2
;
93 if (m_messageBitmapOriginal
.Ok())
95 w2
= m_messageBitmapOriginal
.GetWidth();
96 h2
= m_messageBitmapOriginal
.GetHeight();
100 // Must re-make the bitmap to have its transparent areas drawn
101 // in the current widget background colour.
102 if (m_messageBitmapOriginal
.GetMask())
105 XtVaGetValues( widget
, XmNbackground
, &backgroundPixel
,
109 col
.SetPixel(backgroundPixel
);
111 wxBitmap newBitmap
= wxCreateMaskedBitmap(m_messageBitmapOriginal
, col
);
112 m_messageBitmap
= newBitmap
;
114 pixmap
= (Pixmap
) m_messageBitmap
.GetDrawable();
118 m_bitmapCache
.SetBitmap( m_messageBitmap
);
119 pixmap
= (Pixmap
)m_bitmapCache
.GetLabelPixmap(widget
);
122 XtVaSetValues (widget
,
123 XmNlabelPixmap
, pixmap
,
124 XmNlabelType
, XmPIXMAP
,
128 if (! (w1
== w2
) && (h1
== h2
))
129 SetSize(x
, y
, w2
, h2
);
133 // Null bitmap: must not use current pixmap
134 // since it is no longer valid.
135 XtVaSetValues (widget
,
136 XmNlabelType
, XmSTRING
,
137 XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
,
142 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
144 m_messageBitmap
= bitmap
;
145 m_messageBitmapOriginal
= bitmap
;
150 void wxStaticBitmap::ChangeBackgroundColour()
152 wxWindow::ChangeBackgroundColour();
154 // must recalculate the background colour
155 m_bitmapCache
.SetColoursChanged();
159 void wxStaticBitmap::ChangeForegroundColour()
161 m_bitmapCache
.SetColoursChanged();
162 wxWindow::ChangeForegroundColour();