X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8584b0e64b273273bad122d28b10176bd5a3bc84..fb8d7eb7a880f1f2e32d8830f9c5e12b2536e05f:/src/gtk/listbox.cpp diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 9a406184bd..4f44746313 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -25,16 +25,20 @@ #include "wx/arrstr.h" #endif -#include "wx/gtk/private.h" -#include "wx/gtk/private/object.h" -#include "wx/gtk/treeentry_gtk.h" - #if wxUSE_TOOLTIPS #include "wx/tooltip.h" #endif #include +#include "wx/gtk/private.h" +#include "wx/gtk/private/gtk2-compat.h" +#include "wx/gtk/private/object.h" +#include "wx/gtk/treeentry_gtk.h" + #include +#ifdef __WXGTK3__ +#include +#endif //----------------------------------------------------------------------------- // data @@ -206,7 +210,7 @@ static gint gtk_listbox_sort_callback(GtkTreeModel * WXUNUSED(model), wxCHECK_MSG(entry2, 0, wxT("Could not get second entry")); //We compare collate keys here instead of calling g_utf8_collate - //as it is rather slow (and even the docs reccommend this) + //as it is rather slow (and even the docs recommend this) return strcmp(gtk_tree_entry_get_collate_key(entry1), gtk_tree_entry_get_collate_key(entry2)) >= 0; } @@ -400,7 +404,13 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, wxListBox::~wxListBox() { - m_hasVMT = false; + if (m_treeview) + { + GTKDisconnect(m_treeview); + GtkTreeSelection* selection = gtk_tree_view_get_selection(m_treeview); + if (selection) + GTKDisconnect(selection); + } Clear(); } @@ -429,7 +439,7 @@ void wxListBox::Update() wxWindow::Update(); if (m_treeview) - gdk_window_process_updates(GTK_WIDGET(m_treeview)->window, TRUE); + gdk_window_process_updates(gtk_widget_get_window(GTK_WIDGET(m_treeview)), true); } // ---------------------------------------------------------------------------- @@ -493,6 +503,8 @@ void wxListBox::DoClear() gtk_list_store_clear( m_liststore ); /* well, THAT was easy :) */ GTKEnableEvents(); + + UpdateOldSelections(); } void wxListBox::DoDeleteOneItem(unsigned int n) @@ -657,7 +669,7 @@ int wxListBox::FindString( const wxString &item, bool bCase ) const void wxListBox::GTKOnActivated(int item) { - SendEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, item, IsSelected(item)); + SendEvent(wxEVT_LISTBOX_DCLICK, item, IsSelected(item)); } void wxListBox::GTKOnSelectionChanged() @@ -670,7 +682,7 @@ void wxListBox::GTKOnSelectionChanged() { const int item = GetSelection(); if ( DoChangeSingleSelection(item) ) - SendEvent(wxEVT_COMMAND_LISTBOX_SELECTED, item, true); + SendEvent(wxEVT_LISTBOX, item, true); } } @@ -723,7 +735,7 @@ bool wxListBox::IsSelected( int n ) const GtkTreeIter iter; wxCHECK_MSG( GTKGetIteratorFor(n, &iter), false, wxT("Invalid index") ); - return gtk_tree_selection_iter_is_selected(selection, &iter); + return gtk_tree_selection_iter_is_selected(selection, &iter) != 0; } void wxListBox::DoSetSelection( int n, bool select ) @@ -769,7 +781,7 @@ void wxListBox::DoScrollToCell(int n, float alignY, float alignX) wxCHECK_RET( IsValid(n), wxT("invalid index")); //RN: I have no idea why this line is needed... - if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (m_treeview)) + if (gtk_widget_has_grab(GTK_WIDGET(m_treeview))) return; GtkTreeIter iter; @@ -810,7 +822,7 @@ int wxListBox::DoListHitTest(const wxPoint& point) const // need to translate from master window since it is in client coords gint binx, biny; gdk_window_get_geometry(gtk_tree_view_get_bin_window(m_treeview), - &binx, &biny, NULL, NULL, NULL); + &binx, &biny, NULL, NULL); GtkTreePath* path; if ( !gtk_tree_view_get_path_at_pos @@ -837,23 +849,6 @@ int wxListBox::DoListHitTest(const wxPoint& point) const // helpers // ---------------------------------------------------------------------------- -#if wxUSE_TOOLTIPS -void wxListBox::GTKApplyToolTip( GtkTooltips *tips, const gchar *tip ) -{ -#if GTK_CHECK_VERSION(2, 12, 0) - if (!gtk_check_version(2, 12, 0)) - { - gtk_widget_set_tooltip_text(GTK_WIDGET( m_treeview ), tip); - } - else -#endif - { - // RN: Is this needed anymore? - gtk_tooltips_set_tip( tips, GTK_WIDGET( m_treeview ), tip, NULL ); - } -} -#endif // wxUSE_TOOLTIPS - GtkWidget *wxListBox::GetConnectWidget() { // the correct widget for listbox events (such as mouse clicks for example) @@ -868,7 +863,10 @@ GdkWindow *wxListBox::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const void wxListBox::DoApplyWidgetStyle(GtkRcStyle *style) { - if (m_hasBgCol && m_backgroundColour.Ok()) +#ifdef __WXGTK3__ + // don't know if this is even necessary, or how to do it +#else + if (m_hasBgCol && m_backgroundColour.IsOk()) { GdkWindow *window = gtk_tree_view_get_bin_window(m_treeview); if (window) @@ -878,8 +876,9 @@ void wxListBox::DoApplyWidgetStyle(GtkRcStyle *style) gdk_window_clear( window ); } } +#endif - gtk_widget_modify_style( GTK_WIDGET(m_treeview), style ); + GTKApplyStyle(GTK_WIDGET(m_treeview), style); } wxSize wxListBox::DoGetBestSize() const @@ -932,7 +931,7 @@ wxSize wxListBox::DoGetBestSize() const wxVisualAttributes wxListBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) { - return GetDefaultAttributesFromGTKWidget(gtk_tree_view_new, true); + return GetDefaultAttributesFromGTKWidget(gtk_tree_view_new(), true); } #endif // wxUSE_LISTBOX