X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..87df17a11b0017d31c09f767bd921abb27193bee:/src/gtk/bmpbuttn.cpp diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp index b056ecbcbd..8fb62fc085 100644 --- a/src/gtk/bmpbuttn.cpp +++ b/src/gtk/bmpbuttn.cpp @@ -144,19 +144,11 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi if (m_bitmap.Ok()) { wxSize newSize = size; - - GdkBitmap *mask = (GdkBitmap *) NULL; - if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); - GtkWidget *pixmap = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); - - gtk_widget_show( pixmap ); - gtk_container_add( GTK_CONTAINER(m_widget), pixmap ); - - int border = 10; - if (style & wxNO_BORDER) border = 4; + int border = (style & wxNO_BORDER) ? 4 : 10; if (newSize.x == -1) newSize.x = m_bitmap.GetWidth()+border; if (newSize.y == -1) newSize.y = m_bitmap.GetHeight()+border; SetSize( newSize.x, newSize.y ); + SetBitmap(); } gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", @@ -206,6 +198,9 @@ wxString wxBitmapButton::GetLabel() const void wxBitmapButton::ApplyWidgetStyle() { + if (GTK_BUTTON(m_widget)->child == NULL) return; + + wxButton::ApplyWidgetStyle(); } void wxBitmapButton::SetBitmap() @@ -213,51 +208,46 @@ void wxBitmapButton::SetBitmap() wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); wxBitmap the_one; - if (!m_isEnabled) the_one = m_disabled; + else if (m_isSelected) + the_one = m_selected; + else if (m_hasFocus) + the_one = m_focus; else - { - if (m_isSelected) - { - the_one = m_selected; - } - else - { - if (m_hasFocus) - the_one = m_focus; - else - the_one = m_bitmap; - } - } + the_one = m_bitmap; if (!the_one.Ok()) the_one = m_bitmap; if (!the_one.Ok()) return; - GtkButton *bin = GTK_BUTTON( m_widget ); - GtkPixmap *g_pixmap = GTK_PIXMAP( bin->child ); - GdkBitmap *mask = (GdkBitmap *) NULL; if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap(); - gtk_pixmap_set( g_pixmap, the_one.GetPixmap(), mask ); + GtkButton *bin = GTK_BUTTON(m_widget); + if (bin->child == NULL) + { // initial bitmap + GtkWidget *pixmap = gtk_pixmap_new(the_one.GetPixmap(), mask); + gtk_widget_show(pixmap); + gtk_container_add(GTK_CONTAINER(m_widget), pixmap); + } + else + { // subsequent bitmaps + GtkPixmap *g_pixmap = GTK_PIXMAP(bin->child); + gtk_pixmap_set(g_pixmap, the_one.GetPixmap(), mask); + } } void wxBitmapButton::SetBitmapDisabled( const wxBitmap& bitmap ) { - wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); - - if ( ! m_disabled.Ok() ) return; - m_disabled = bitmap; + if (!bitmap.Ok()) return; + m_disabled = bitmap; - SetBitmap(); + SetBitmap(); } void wxBitmapButton::SetBitmapFocus( const wxBitmap& bitmap ) { - wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); - - if ( ! m_focus.Ok() ) return; + if (!bitmap.Ok()) return; m_focus = bitmap; SetBitmap(); @@ -265,9 +255,7 @@ void wxBitmapButton::SetBitmapFocus( const wxBitmap& bitmap ) void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap ) { - wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); - - if (!m_bitmap.Ok()) return; + if (!bitmap.Ok()) return; m_bitmap = bitmap; SetBitmap(); @@ -275,9 +263,7 @@ void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap ) void wxBitmapButton::SetBitmapSelected( const wxBitmap& bitmap ) { - wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); - - if ( ! m_selected.Ok() ) return; + if (!bitmap.Ok()) return; m_selected = bitmap; SetBitmap();