X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6c8a980fc412792e64256724e02e9d387ee38e21..d3acd3697ad19e0edbff62db7f94bd025cf8883b:/src/gtk/choice.cpp diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index e1868bbd1c..d794e2a915 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -16,8 +16,8 @@ #if wxUSE_CHOICE -#include "gdk/gdk.h" -#include "gtk/gtk.h" +#include +#include //----------------------------------------------------------------------------- // idle system @@ -90,13 +90,6 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, m_widget = gtk_option_menu_new(); - wxSize newSize(size); - if (newSize.x == -1) - newSize.x = 80; - if (newSize.y == -1) - newSize.y = 26; - SetSize( newSize.x, newSize.y ); - if ( style & wxCB_SORT ) { // if our m_strings != NULL, DoAppend() will check for it and insert @@ -108,7 +101,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, for (int i = 0; i < n; i++) { - AppendHelper(menu, choices[i]); + GtkAppendHelper(menu, choices[i]); } gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); @@ -117,9 +110,19 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, PostCreation(); + 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 ); + SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); Show( TRUE ); @@ -139,7 +142,7 @@ int wxChoice::DoAppend( const wxString &item ) GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ); - return AppendHelper(menu, item); + return GtkAppendHelper(menu, item); } void wxChoice::DoSetItemClientData( int n, void* clientData ) @@ -323,36 +326,6 @@ void wxChoice::SetSelection( int n ) gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); } -void wxChoice::DisableEvents() -{ -/* - GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - GList *child = menu_shell->children; - while (child) - { - gtk_signal_disconnect_by_func( GTK_OBJECT( child->data ), - GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this ); - - child = child->next; - } -*/ -} - -void wxChoice::EnableEvents() -{ -/* - GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - GList *child = menu_shell->children; - while (child) - { - gtk_signal_connect( GTK_OBJECT( child->data ), "activate", - GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this ); - - child = child->next; - } -*/ -} - void wxChoice::ApplyWidgetStyle() { SetWidgetStyle(); @@ -378,7 +351,7 @@ void wxChoice::ApplyWidgetStyle() } } -size_t wxChoice::AppendHelper(GtkWidget *menu, const wxString& item) +size_t wxChoice::GtkAppendHelper(GtkWidget *menu, const wxString& item) { GtkWidget *menu_item = gtk_menu_item_new_with_label( item.mbc_str() ); @@ -409,7 +382,7 @@ size_t wxChoice::AppendHelper(GtkWidget *menu, const wxString& item) // don't call wxChoice::GetCount() from here because it doesn't work // if we're called from ctor (and GtkMenuShell is still NULL) - index = m_clientList.GetCount(); + index = m_clientList.GetCount() - 1; } if (GTK_WIDGET_REALIZED(m_widget)) @@ -429,4 +402,12 @@ size_t wxChoice::AppendHelper(GtkWidget *menu, const wxString& item) return index; } +wxSize wxChoice::DoGetBestSize() const +{ + wxSize ret( wxControl::DoGetBestSize() ); + if (ret.x < 80) ret.x = 80; + ret.y = 16 + gdk_char_height( m_widget->style->font, 'H' ); + return ret; +} + #endif