X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/29f54b9b37c49eccd2f1a5e5649dfee5a0c949b9..10ef30eb534117ae854c9d099101c862fe96bcb0:/src/gtk1/choice.cpp diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index ca9d9c1785..103ebf3901 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -18,8 +18,7 @@ #include "wx/choice.h" -#include -#include +#include "wx/gtk/private.h" //----------------------------------------------------------------------------- // idle system @@ -114,14 +113,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, SetFont( parent->GetFont() ); - wxSize size_best( DoGetBestSize() ); - wxSize new_size( size ); - if (new_size.x == -1) - new_size.x = size_best.x; - if (new_size.y == -1) - new_size.y = size_best.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); + SetBestSize(size); SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); @@ -236,16 +228,18 @@ int wxChoice::FindString( const wxString &string ) const { GtkBin *bin = GTK_BIN( child->data ); GtkLabel *label = (GtkLabel *) NULL; - if (bin->child) label = GTK_LABEL(bin->child); - if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); + if (bin->child) + label = GTK_LABEL(bin->child); + if (!label) + label = GTK_LABEL( BUTTON_CHILD(m_widget) ); wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); - if (string == wxString(label->label,*wxConvCurrent)) - return count; + if (string == wxString(label->label,*wxConvCurrent)) + return count; - child = child->next; - count++; + child = child->next; + count++; } return -1; @@ -289,8 +283,10 @@ wxString wxChoice::GetString( int n ) const if (count == n) { GtkLabel *label = (GtkLabel *) NULL; - if (bin->child) label = GTK_LABEL(bin->child); - if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); + if (bin->child) + label = GTK_LABEL(bin->child); + if (!label) + label = GTK_LABEL( BUTTON_CHILD(m_widget) ); wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); @@ -344,8 +340,10 @@ void wxChoice::ApplyWidgetStyle() GtkBin *bin = GTK_BIN( child->data ); GtkWidget *label = (GtkWidget *) NULL; - if (bin->child) label = bin->child; - if (!label) label = GTK_BUTTON(m_widget)->child; + if (bin->child) + label = bin->child; + if (!label) + label = BUTTON_CHILD(m_widget); gtk_widget_set_style( label, m_widgetStyle ); @@ -424,16 +422,27 @@ wxSize wxChoice::DoGetBestSize() const ret.x = width; } - // for the choice "=" button - ret.x += 20; + // add extra for the choice "=" button + + // VZ: I don't know how to get the right value, it seems to be in + // GtkOptionMenuProps struct from gtkoptionmenu.c but we can't get + // to it - maybe we can use gtk_option_menu_size_request() for this + // somehow? + // + // This default value works only for the default GTK+ theme (i.e. + // no theme at all) (FIXME) + static const int widthChoiceIndicator = 35; + ret.x += widthChoiceIndicator; } // but not less than the minimal width if ( ret.x < 80 ) ret.x = 80; - ret.y = 16 + gdk_char_height( m_widget->style->font, 'H' ); + ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H'); + return ret; } -#endif +#endif // wxUSE_CHOICE +