+void wxBitmapButton::DoSetBitmap()
+{
+ if (m_bmpNormalOriginal.Ok())
+ {
+ Pixmap pixmap = 0;
+ Pixmap insensPixmap = 0;
+ Pixmap armPixmap = 0;
+
+ // Must re-make the bitmap to have its transparent areas drawn
+ // in the current widget background colour.
+ if (m_bmpNormalOriginal.GetMask())
+ {
+ int backgroundPixel;
+ XtVaGetValues((Widget) m_mainWidget,
+ XmNbackground, &backgroundPixel,
+ NULL);
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ wxBitmap newBitmap =
+ wxCreateMaskedBitmap(m_bmpNormalOriginal, col);
+ m_bmpNormal = newBitmap;
+ m_bitmapCache.SetBitmap( m_bmpNormal );
+
+ pixmap = (Pixmap) m_bmpNormal.GetDrawable();
+ }
+ else
+ {
+ m_bitmapCache.SetBitmap( m_bmpNormal );
+ pixmap = (Pixmap) m_bitmapCache.GetLabelPixmap(m_mainWidget);
+ }
+
+ if (m_bmpDisabledOriginal.Ok())
+ {
+ if (m_bmpDisabledOriginal.GetMask())
+ {
+ int backgroundPixel;
+ XtVaGetValues((Widget) m_mainWidget,
+ XmNbackground, &backgroundPixel,
+ NULL);
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ wxBitmap newBitmap =
+ wxCreateMaskedBitmap(m_bmpDisabledOriginal, col);
+ m_bmpDisabled = newBitmap;
+
+ insensPixmap = (Pixmap) m_bmpDisabled.GetDrawable();
+ }
+ else
+ insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
+ }
+ else
+ insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
+
+ // Now make the bitmap representing the armed state
+ if (m_bmpSelectedOriginal.Ok())
+ {
+ if (m_bmpSelectedOriginal.GetMask())
+ {
+ int backgroundPixel;
+ XtVaGetValues((Widget) m_mainWidget,
+ XmNarmColor, &backgroundPixel,
+ NULL);
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ wxBitmap newBitmap =
+ wxCreateMaskedBitmap(m_bmpSelectedOriginal, col);
+ m_bmpSelected = newBitmap;
+
+ armPixmap = (Pixmap) m_bmpSelected.GetDrawable();
+ }
+ else
+ armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget);
+ }
+ else
+ armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget);
+
+ XtVaSetValues ((Widget) m_mainWidget,
+ XmNlabelPixmap, pixmap,
+ XmNlabelInsensitivePixmap, insensPixmap,
+ XmNarmPixmap, armPixmap,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ }
+ else
+ {
+ // Null bitmap: must not use current pixmap
+ // since it is no longer valid.
+ XtVaSetValues ((Widget) m_mainWidget,
+ XmNlabelType, XmSTRING,
+ XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
+ XmNlabelInsensitivePixmap, XmUNSPECIFIED_PIXMAP,
+ XmNarmPixmap, XmUNSPECIFIED_PIXMAP,
+ NULL);
+ }
+}
+
+void wxBitmapButton::ChangeBackgroundColour()
+{
+ wxDoChangeBackgroundColour(m_mainWidget, m_backgroundColour, true);
+
+ // Must reset the bitmaps since the colours have changed.
+ DoSetBitmap();
+}
+
+wxSize wxBitmapButton::DoGetBestSize() const
+{
+ wxSize ret( 30,30 );
+
+ if (m_bmpNormal.Ok())
+ {
+ int border = (GetWindowStyle() & wxNO_BORDER) ? 4 : 10;
+ ret.x = m_bmpNormal.GetWidth()+border;
+ ret.y = m_bmpNormal.GetHeight()+border;
+ }
+
+ return ret;
+}