+bool wxBitmapToggleButton::GetValue() const
+{
+ return m_depressed;
+}
+
+void wxBitmapToggleButton::SetLabel(const wxBitmap& label)
+{
+ m_bitmap = label;
+ m_disabledBitmap = wxBitmap();
+
+ Refresh();
+}
+
+bool wxBitmapToggleButton::Enable(bool enable)
+{
+ if (m_capturing) return false;
+
+ if (!wxToggleButtonBase::Enable( enable ))
+ return false;
+
+ Refresh();
+
+ return true;
+}
+
+void wxBitmapToggleButton::OnPaint(wxPaintEvent &WXUNUSED(event))
+{
+ wxSize size = GetSize();
+
+ wxBitmap bitmap = m_bitmap;
+
+ wxPaintDC dc(this);
+ wxRendererNative &renderer = wxRendererNative::Get();
+ int flags = 0;
+ if (m_depressed)
+ flags |= wxCONTROL_PRESSED;
+ wxRect rect(0,0,size.x,size.y);
+ renderer.DrawPushButton( this, dc, rect, flags );
+
+ if (bitmap.IsOk())
+ {
+ if (!IsEnabled())
+ {
+ if (!m_disabledBitmap.IsOk())
+ {
+ wxImage image = m_bitmap.ConvertToImage();
+ m_disabledBitmap = wxBitmap( image.ConvertToGreyscale() );
+ }
+
+ bitmap = m_disabledBitmap;
+ }
+
+ wxSize bsize = bitmap.GetSize();
+ int offset = 0;
+ if (m_depressed) offset = 1;
+ dc.DrawBitmap( bitmap, (size.x-bsize.x) / 2 + offset, (size.y-bsize.y) / 2 + offset, true );
+ }