]>
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>
26 #include <Xm/RowColumn.h>
28 #pragma message enable nosimpint
31 #include "wx/motif/private.h"
33 IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap
, wxControl
)
39 bool wxStaticBitmap::Create(wxWindow
*parent
, wxWindowID id
,
40 const wxBitmap
& bitmap
,
46 m_messageBitmap
= bitmap
;
47 m_messageBitmapOriginal
= bitmap
;
49 m_backgroundColour
= parent
->GetBackgroundColour();
50 m_foregroundColour
= parent
->GetForegroundColour();
51 if (parent
) parent
->AddChild(this);
54 m_windowId
= (int)NewControlId();
58 m_windowStyle
= style
;
60 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
62 m_mainWidget
= (WXWidget
) XtVaCreateManagedWidget ("staticBitmap",
64 xmLabelGadgetClass
, parentWidget
,
66 xmLabelWidgetClass
, parentWidget
,
68 XmNalignment
, XmALIGNMENT_BEGINNING
,
71 ChangeBackgroundColour ();
75 m_font
= parent
->GetFont();
78 wxSize
actualSize(size
);
79 // work around the cases where the bitmap is a wxNull(Icon/Bitmap)
80 if (actualSize
.x
== -1)
81 actualSize
.x
= bitmap
.GetWidth() ? bitmap
.GetWidth() : 1;
82 if (actualSize
.y
== -1)
83 actualSize
.y
= bitmap
.GetHeight() ? bitmap
.GetHeight() : 1;
84 AttachWidget (parent
, m_mainWidget
, (WXWidget
) NULL
, pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
89 wxStaticBitmap::~wxStaticBitmap()
91 SetBitmap(wxNullBitmap
);
94 void wxStaticBitmap::DoSetBitmap()
96 Widget widget
= (Widget
) m_mainWidget
;
97 int x
, y
, w1
, h1
, w2
, h2
;
101 if (m_messageBitmapOriginal
.Ok())
103 w2
= m_messageBitmapOriginal
.GetWidth();
104 h2
= m_messageBitmapOriginal
.GetHeight();
108 // Must re-make the bitmap to have its transparent areas drawn
109 // in the current widget background colour.
110 if (m_messageBitmapOriginal
.GetMask())
113 XtVaGetValues( widget
, XmNbackground
, &backgroundPixel
,
117 col
.SetPixel(backgroundPixel
);
119 wxBitmap newBitmap
= wxCreateMaskedBitmap(m_messageBitmapOriginal
, col
);
120 m_messageBitmap
= newBitmap
;
122 pixmap
= (Pixmap
) m_messageBitmap
.GetDrawable();
126 m_bitmapCache
.SetBitmap( m_messageBitmap
);
127 pixmap
= (Pixmap
)m_bitmapCache
.GetLabelPixmap(widget
);
130 XtVaSetValues (widget
,
131 XmNlabelPixmap
, pixmap
,
132 XmNlabelType
, XmPIXMAP
,
136 if (! (w1
== w2
) && (h1
== h2
))
137 SetSize(x
, y
, w2
, h2
);
141 // Null bitmap: must not use current pixmap
142 // since it is no longer valid.
143 XtVaSetValues (widget
,
144 XmNlabelType
, XmSTRING
,
145 XmNlabelPixmap
, XmUNSPECIFIED_PIXMAP
,
150 void wxStaticBitmap::SetBitmap(const wxBitmap
& bitmap
)
152 m_messageBitmap
= bitmap
;
153 m_messageBitmapOriginal
= bitmap
;
158 void wxStaticBitmap::ChangeFont(bool keepOriginalSize
)
160 wxWindow::ChangeFont(keepOriginalSize
);
163 void wxStaticBitmap::ChangeBackgroundColour()
165 wxWindow::ChangeBackgroundColour();
167 // must recalculate the background colour
168 m_bitmapCache
.SetColoursChanged();
172 void wxStaticBitmap::ChangeForegroundColour()
174 m_bitmapCache
.SetColoursChanged();
175 wxWindow::ChangeForegroundColour();