No real changes, just refactor the code to use a function mapping GtkTreeIter
to our wxDataViewItem and use it instead of duplicating its code everywhere.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65211
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal;
class WXDLLIMPEXP_FWD_ADV wxDataViewCtrlInternal;
// ---------------------------------------------------------
// wxDataViewColumn
// ---------------------------------------------------------
// ---------------------------------------------------------
// wxDataViewColumn
// ---------------------------------------------------------
GtkWidget *GtkGetTreeView() { return m_treeview; }
wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; }
GtkWidget *GtkGetTreeView() { return m_treeview; }
wxDataViewCtrlInternal* GtkGetInternal() { return m_internal; }
+ // Convert GTK path to our item. Returned item may be invalid if get_iter()
+ // failed.
+ wxDataViewItem GTKPathToItem(struct _GtkTreePath *path) const;
+
virtual void OnInternalIdle();
protected:
virtual void OnInternalIdle();
protected:
wxDataViewRenderer *wx_renderer = wxgtk_renderer->wx_renderer;
GtkTreePath *treepath = gtk_tree_path_new_from_string( path );
wxDataViewRenderer *wx_renderer = wxgtk_renderer->wx_renderer;
GtkTreePath *treepath = gtk_tree_path_new_from_string( path );
- GtkTreeIter iter;
- wx_renderer->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter, treepath );
- wxDataViewItem item( (void*) iter.user_data );;
+ wxDataViewItem
+ item(wx_renderer->GetOwner()->GetOwner()->GTKPathToItem(treepath));
gtk_tree_path_free( treepath );
wxDataViewColumn *column = wx_renderer->GetOwner();
gtk_tree_path_free( treepath );
wxDataViewColumn *column = wx_renderer->GetOwner();
wxRect renderrect(wxRectFromGDKRect(cell_area));
GtkTreePath *treepath = gtk_tree_path_new_from_string( path );
wxRect renderrect(wxRectFromGDKRect(cell_area));
GtkTreePath *treepath = gtk_tree_path_new_from_string( path );
- GtkTreeIter iter;
- cell->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter, treepath );
- wxDataViewItem item( (void*) iter.user_data );
+ wxDataViewItem item(cell->GetOwner()->GetOwner()->GTKPathToItem(treepath));
gtk_tree_path_free( treepath );
cell->StartEditing( item, renderrect );
gtk_tree_path_free( treepath );
cell->StartEditing( item, renderrect );
wxDataViewModel *model = cell->GetOwner()->GetOwner()->GetModel();
GtkTreePath *treepath = gtk_tree_path_new_from_string( path );
wxDataViewModel *model = cell->GetOwner()->GetOwner()->GetModel();
GtkTreePath *treepath = gtk_tree_path_new_from_string( path );
-
- GtkTreeIter iter;
- cell->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter, treepath );
- wxDataViewItem item( iter.user_data );
+ wxDataViewItem item(cell->GetOwner()->GetOwner()->GTKPathToItem(treepath));
gtk_tree_path_free( treepath );
unsigned int model_col = cell->GetOwner()->GetModelColumn();
gtk_tree_path_free( treepath );
unsigned int model_col = cell->GetOwner()->GetModelColumn();
event.SetDataViewColumn( column );
event.SetModel( dv->GetModel() );
GtkTreePath *tree_path = gtk_tree_path_new_from_string( path );
event.SetDataViewColumn( column );
event.SetModel( dv->GetModel() );
GtkTreePath *tree_path = gtk_tree_path_new_from_string( path );
- GtkTreeIter iter;
- dv->GtkGetInternal()->get_iter( &iter, tree_path );
+ wxDataViewItem item(dv->GTKPathToItem(tree_path));
gtk_tree_path_free( tree_path );
gtk_tree_path_free( tree_path );
- wxDataViewItem item( iter.user_data );
event.SetItem( item );
dv->HandleWindowEvent( event );
if (GTK_IS_CELL_EDITABLE(editable))
{
event.SetItem( item );
dv->HandleWindowEvent( event );
if (GTK_IS_CELL_EDITABLE(editable))
{
- s_user_data = iter.user_data;
+ s_user_data = item.GetID();
g_signal_connect (GTK_CELL_EDITABLE (editable), "editing_done",
G_CALLBACK (wxgtk_cell_editable_editing_done),
g_signal_connect (GTK_CELL_EDITABLE (editable), "editing_done",
G_CALLBACK (wxgtk_cell_editable_editing_done),
return;
GtkTreePath *path = gtk_tree_path_new_from_string( itempath );
return;
GtkTreePath *path = gtk_tree_path_new_from_string( itempath );
- GtkTreeIter iter;
- GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter, path );
- wxDataViewItem item( (void*) iter.user_data );;
+ wxDataViewItem item(GetOwner()->GetOwner()->GTKPathToItem(path));
gtk_tree_path_free( path );
GtkOnCellChanged(value, item, GetOwner()->GetModelColumn());
gtk_tree_path_free( path );
GtkOnCellChanged(value, item, GetOwner()->GetModelColumn());
wxDataViewModel *model = cell->GetOwner()->GetOwner()->GetModel();
GtkTreePath *gtk_path = gtk_tree_path_new_from_string( path );
wxDataViewModel *model = cell->GetOwner()->GetOwner()->GetModel();
GtkTreePath *gtk_path = gtk_tree_path_new_from_string( path );
- GtkTreeIter iter;
- cell->GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter, gtk_path );
- wxDataViewItem item( (void*) iter.user_data );;
+ wxDataViewItem item(cell->GetOwner()->GetOwner()->GTKPathToItem(gtk_path));
gtk_tree_path_free( gtk_path );
unsigned int model_col = cell->GetOwner()->GetModelColumn();
gtk_tree_path_free( gtk_path );
unsigned int model_col = cell->GetOwner()->GetModelColumn();
return;
GtkTreePath *path = gtk_tree_path_new_from_string( itempath );
return;
GtkTreePath *path = gtk_tree_path_new_from_string( itempath );
- GtkTreeIter iter;
- GetOwner()->GetOwner()->GtkGetInternal()->get_iter( &iter, path );
- wxDataViewItem item( (void*) iter.user_data );;
+ wxDataViewItem item(GetOwner()->GetOwner()->GTKPathToItem(path));
gtk_tree_path_free( path );
GtkOnCellChanged(value, item, GetOwner()->GetModelColumn());
gtk_tree_path_free( path );
GtkOnCellChanged(value, item, GetOwner()->GetModelColumn());
{
delete m_dragDataObject;
{
delete m_dragDataObject;
- GtkTreeIter iter;
- if (!get_iter( &iter, path )) return FALSE;
- wxDataViewItem item( (void*) iter.user_data );
+ wxDataViewItem item(GetOwner()->GTKPathToItem(path));
+ if ( !item )
+ return FALSE;
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() );
event.SetEventObject( m_owner );
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() );
event.SetEventObject( m_owner );
gboolean wxDataViewCtrlInternal::drag_data_get( GtkTreeDragSource *WXUNUSED(drag_source),
GtkTreePath *path, GtkSelectionData *selection_data )
{
gboolean wxDataViewCtrlInternal::drag_data_get( GtkTreeDragSource *WXUNUSED(drag_source),
GtkTreePath *path, GtkSelectionData *selection_data )
{
- GtkTreeIter iter;
- if (!get_iter( &iter, path )) return FALSE;
- wxDataViewItem item( (void*) iter.user_data );
+ wxDataViewItem item(GetOwner()->GTKPathToItem(path));
+ if ( !item )
+ return FALSE;
if (!m_dragDataObject->IsSupported( selection_data->target ))
return FALSE;
if (!m_dragDataObject->IsSupported( selection_data->target ))
return FALSE;
GtkTreePath *path,
GtkSelectionData *selection_data)
{
GtkTreePath *path,
GtkSelectionData *selection_data)
{
- GtkTreeIter iter;
- if (!get_iter( &iter, path )) return FALSE;
- wxDataViewItem item( (void*) iter.user_data );
+ wxDataViewItem item(GetOwner()->GTKPathToItem(path));
+ if ( !item )
+ return FALSE;
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP, m_owner->GetId() );
event.SetEventObject( m_owner );
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP, m_owner->GetId() );
event.SetEventObject( m_owner );
GtkTreePath *path,
GtkSelectionData *selection_data)
{
GtkTreePath *path,
GtkSelectionData *selection_data)
{
- GtkTreeIter iter;
- if (!get_iter( &iter, path )) return FALSE;
- wxDataViewItem item( (void*) iter.user_data );
+ wxDataViewItem item(GetOwner()->GTKPathToItem(path));
+ if ( !item )
+ return FALSE;
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() );
event.SetEventObject( m_owner );
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_DROP_POSSIBLE, m_owner->GetId() );
event.SetEventObject( m_owner );
{
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, dv->GetId() );
{
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, dv->GetId() );
- GtkTreeIter iter;
- dv->GtkGetInternal()->get_iter( &iter, path );
- wxDataViewItem item( (void*) iter.user_data );;
+ wxDataViewItem item(dv->GTKPathToItem(path));
event.SetItem( item );
event.SetModel( dv->GetModel() );
dv->HandleWindowEvent( event );
event.SetItem( item );
event.SetModel( dv->GetModel() );
dv->HandleWindowEvent( event );
- GtkTreeIter iter;
- dv->GtkGetInternal()->get_iter( &iter, path );
-
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, dv->GetId() );
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, dv->GetId() );
- wxDataViewItem item( (void*) iter.user_data );;
- event.SetItem( item );
+ event.SetItem(dv->GTKPathToItem(path));
event.SetModel( dv->GetModel() );
bool ret = dv->HandleWindowEvent( event );
gtk_tree_path_free( path );
event.SetModel( dv->GetModel() );
bool ret = dv->HandleWindowEvent( event );
gtk_tree_path_free( path );
+wxDataViewItem wxDataViewCtrl::GTKPathToItem(GtkTreePath *path) const
+{
+ GtkTreeIter iter;
+ return wxDataViewItem(path && m_internal->get_iter(&iter, path)
+ ? iter.user_data
+ : NULL);
+}
+
void wxDataViewCtrl::OnInternalIdle()
{
wxWindow::OnInternalIdle();
void wxDataViewCtrl::OnInternalIdle()
{
wxWindow::OnInternalIdle();
if (list)
{
GtkTreePath *path = (GtkTreePath*) list->data;
if (list)
{
GtkTreePath *path = (GtkTreePath*) list->data;
- GtkTreeIter iter;
- m_internal->get_iter( &iter, path );
+ wxDataViewItem item(GTKPathToItem(path));
// delete list
g_list_foreach( list, (GFunc) gtk_tree_path_free, NULL );
g_list_free( list );
// delete list
g_list_foreach( list, (GFunc) gtk_tree_path_free, NULL );
g_list_free( list );
- return wxDataViewItem( (void*) iter.user_data );
GtkTreeIter iter;
if (gtk_tree_selection_get_selected( selection, NULL, &iter ))
{
GtkTreeIter iter;
if (gtk_tree_selection_get_selected( selection, NULL, &iter ))
{
- wxDataViewItem item( (void*) iter.user_data );
+ wxDataViewItem item( iter.user_data );
{
GtkTreePath *path = (GtkTreePath*) list->data;
{
GtkTreePath *path = (GtkTreePath*) list->data;
- GtkTreeIter iter;
- m_internal->get_iter( &iter, path );
-
- sel.Add( wxDataViewItem( (void*) iter.user_data ) );
+ sel.Add(GTKPathToItem(path));
list = g_list_next( list );
count++;
list = g_list_next( list );
count++;