From: Robert Roebling Date: Mon, 16 Jul 2007 11:01:05 +0000 (+0000) Subject: change wxDataViewItem id to void* X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9d52aad39a4e3b52c5baa50b9cc55caaf91bb026?ds=sidebyside change wxDataViewItem id to void* git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47493 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 71d4b24101..90cb52b033 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -68,19 +68,15 @@ extern WXDLLIMPEXP_DATA_ADV(const wxChar) wxDataViewCtrlNameStr[]; class WXDLLIMPEXP_ADV wxDataViewItem { public: - wxDataViewItem( wxUint32 id = 0 ) - { m_id = id; m_reserved1 = 0; m_reserved2 = NULL; } + wxDataViewItem( void* id = NULL ) + { m_id = id; } wxDataViewItem( const wxDataViewItem &item ) - { m_id = item.m_id; m_reserved1 = item.m_reserved1; m_reserved2 = item.m_reserved2; } - bool IsOk() const { return m_id != 0; } - wxUint32 GetID() const { return m_id; } - -public: - wxUint32 m_reserved1; - void* m_reserved2; + { m_id = item.m_id; } + bool IsOk() const { return m_id != NULL; } + void* GetID() const { return m_id; } private: - wxUint32 m_id; + void* m_id; }; bool operator == (const wxDataViewItem &left, const wxDataViewItem &right); diff --git a/samples/dataview/dataview.cpp b/samples/dataview/dataview.cpp index 7cdd1ed605..50a7ca8258 100644 --- a/samples/dataview/dataview.cpp +++ b/samples/dataview/dataview.cpp @@ -156,8 +156,8 @@ public: if (m_classicalMusicIsKnownToControl) { // notify control - wxDataViewItem child( child_node->GetID() ); - wxDataViewItem parent( m_classical->GetID() ); + wxDataViewItem child( (void*) child_node->GetID() ); + wxDataViewItem parent( (void*) m_classical->GetID() ); ItemAdded( parent, child ); } } @@ -222,7 +222,7 @@ public: virtual wxDataViewItem GetFirstChild( const wxDataViewItem &parent ) const { if (parent.GetID() == 0) - return wxDataViewItem( m_root->GetID() ); + return wxDataViewItem( (void*) m_root->GetID() ); MyMusicModelNode *node = FindNode( parent ); @@ -236,7 +236,7 @@ public: } MyMusicModelNode *first_child = node->GetChildren().Item( 0 ); - return wxDataViewItem( first_child->GetID() ); + return wxDataViewItem( (void*) first_child->GetID() ); } virtual wxDataViewItem GetNextSibling( const wxDataViewItem &item ) const @@ -254,7 +254,7 @@ public: return wxDataViewItem(0); node = parent->GetChildren().Item( pos+1 ); - return wxDataViewItem( node->GetID() ); + return wxDataViewItem( (void*) node->GetID() ); } private: @@ -262,7 +262,7 @@ private: MyMusicModelNode *FindNodeRec( MyMusicModelNode *node, const wxDataViewItem &item ) const { - if (node->GetID() == item.GetID()) + if (node->GetID() == (wxUint32) item.GetID()) return node; size_t count = node->GetChildCount(); diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 2a471425b8..ffe43b2b1e 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1693,6 +1693,7 @@ void wxDataViewMainWindow::OnRenameTimer() GetOwner()->CalcScrolledPosition( labelRect.x, labelRect.y, &labelRect.x, &labelRect.y); + // TODO get wxDataViewItem from m_currentRow m_currentCol->GetRenderer()->StartEditing( m_currentRow, labelRect ); } diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 8f3b700e41..d0de7177ec 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -424,7 +424,7 @@ wxgtk_tree_model_get_value (GtkTreeModel *tree_model, { wxVariant variant; g_value_init( value, G_TYPE_STRING ); - wxDataViewItem item( (wxUint32) iter->user_data ); + wxDataViewItem item( (void*) iter->user_data ); model->GetValue( variant, item, (unsigned int) column ); g_value_set_string( value, variant.GetString().utf8_str() ); @@ -667,7 +667,7 @@ GtkTreePath *wxGtkTreeModel::get_path( GtkTreeIter *iter ) gboolean wxGtkTreeModel::iter_next( GtkTreeIter *iter ) { - wxDataViewItem item( (wxUint32) iter->user_data ); + wxDataViewItem item( (void*) iter->user_data ); item = m_wx_model->GetNextSibling( item ); if (!item.IsOk()) return FALSE; @@ -679,7 +679,7 @@ gboolean wxGtkTreeModel::iter_next( GtkTreeIter *iter ) gboolean wxGtkTreeModel::iter_children( GtkTreeIter *iter, GtkTreeIter *parent ) { - wxDataViewItem item( (wxUint32) parent->user_data ); + wxDataViewItem item( (void*) parent->user_data ); if (!m_wx_model->HasChildren( item )) return FALSE; @@ -697,14 +697,14 @@ gboolean wxGtkTreeModel::iter_children( GtkTreeIter *iter, GtkTreeIter *parent ) gboolean wxGtkTreeModel::iter_has_child( GtkTreeIter *iter ) { - wxDataViewItem item( (wxUint32) iter->user_data ); + wxDataViewItem item( (void*) iter->user_data ); return m_wx_model->HasChildren( item ); } gint wxGtkTreeModel::iter_n_children( GtkTreeIter *iter ) { - wxDataViewItem item( (wxUint32) iter->user_data ); + wxDataViewItem item( (void*) iter->user_data ); if (!m_wx_model->HasChildren( item )) return 0; @@ -717,8 +717,8 @@ gint wxGtkTreeModel::iter_n_children( GtkTreeIter *iter ) gboolean wxGtkTreeModel::iter_nth_child( GtkTreeIter *iter, GtkTreeIter *parent, gint n ) { - wxUint32 id = 0; - if (parent) id = (wxUint32) parent->user_data; + void* id = NULL; + if (parent) id = (void*) parent->user_data; wxDataViewItem item( id ); if (!m_wx_model->HasChildren( item )) @@ -739,7 +739,7 @@ gboolean wxGtkTreeModel::iter_nth_child( GtkTreeIter *iter, GtkTreeIter *parent, gboolean wxGtkTreeModel::iter_parent( GtkTreeIter *iter, GtkTreeIter *child ) { - wxDataViewItem item( (wxUint32) child->user_data ); + wxDataViewItem item( (void*) child->user_data ); wxGtkTreeModelNode *node = FindNode( child ); node = node->GetParent(); @@ -786,7 +786,7 @@ wxGtkTreeModelNode *wxGtkTreeModel::FindNode( GtkTreeIter *iter ) if (!iter) return m_root; - wxDataViewItem item( (wxUint32) iter->user_data ); + wxDataViewItem item( (void*) iter->user_data ); wxGtkTreeModelNode *result = wxGtkTreeModel_FindNode( m_root, item ); @@ -989,10 +989,11 @@ static GtkCellEditable *gtk_wx_cell_renderer_start_editing( // wxDataViewListModel *model = cell->GetOwner()->GetOwner()->GetModel(); GtkTreePath *treepath = gtk_tree_path_new_from_string( path ); - unsigned int model_row = (unsigned int)gtk_tree_path_get_indices (treepath)[0]; + // TODO + wxDataViewItem item; gtk_tree_path_free( treepath ); - cell->StartEditing( model_row, renderrect ); + cell->StartEditing( item, renderrect ); return NULL; } @@ -1123,7 +1124,8 @@ gtk_wx_cell_renderer_activate( wxDataViewModel *model = cell->GetOwner()->GetOwner()->GetModel(); GtkTreePath *treepath = gtk_tree_path_new_from_string( path ); - unsigned int model_row = (unsigned int)gtk_tree_path_get_indices (treepath)[0]; + // TODO + wxDataViewItem item; gtk_tree_path_free( treepath ); unsigned int model_col = cell->GetOwner()->GetModelColumn(); @@ -1133,7 +1135,7 @@ gtk_wx_cell_renderer_activate( bool ret = false; // activated by - if (cell->Activate( renderrect, model, model_col, model_row )) + if (cell->Activate( renderrect, model, item, model_col )) ret = true; return ret; @@ -1147,16 +1149,16 @@ gtk_wx_cell_renderer_activate( bool ret = false; if (button_event->button == 1) { - if (cell->LeftClick( pt, renderrect, model, model_col, model_row )) + if (cell->LeftClick( pt, renderrect, model, item, model_col )) ret = true; // TODO: query system double-click time if (button_event->time - wxrenderer->last_click < 400) - if (cell->Activate( renderrect, model, model_col, model_row )) + if (cell->Activate( renderrect, model, item, model_col )) ret = true; } if (button_event->button == 3) { - if (cell->RightClick( pt, renderrect, model, model_col, model_row )) + if (cell->RightClick( pt, renderrect, model, item, model_col )) ret = true; } @@ -1452,13 +1454,15 @@ static void wxGtkTextRendererEditedCallback( GtkCellRendererText *renderer, wxDataViewModel *model = cell->GetOwner()->GetOwner()->GetModel(); GtkTreePath *path = gtk_tree_path_new_from_string( arg1 ); - unsigned int model_row = (unsigned int)gtk_tree_path_get_indices (path)[0]; + GtkTreeIter iter; + // TODO + wxDataViewItem item; gtk_tree_path_free( path ); unsigned int model_col = cell->GetOwner()->GetModelColumn(); - model->SetValue( value, model_col, model_row ); - model->ValueChanged( model_col, model_row ); + model->SetValue( value, item, model_col ); + model->ValueChanged( item, model_col ); } IMPLEMENT_CLASS(wxDataViewTextRenderer, wxDataViewRenderer) @@ -1624,13 +1628,14 @@ static void wxGtkToggleRendererToggledCallback( GtkCellRendererToggle *renderer, wxDataViewModel *model = cell->GetOwner()->GetOwner()->GetModel(); GtkTreePath *gtk_path = gtk_tree_path_new_from_string( path ); - unsigned int model_row = (unsigned int)gtk_tree_path_get_indices (gtk_path)[0]; + // TODO + wxDataViewItem item; gtk_tree_path_free( gtk_path ); unsigned int model_col = cell->GetOwner()->GetModelColumn(); - model->SetValue( value, model_col, model_row ); - model->ValueChanged( model_col, model_row ); + model->SetValue( value, item, model_col ); + model->ValueChanged( item, model_col ); } IMPLEMENT_CLASS(wxDataViewToggleRenderer, wxDataViewRenderer) @@ -2004,7 +2009,7 @@ static void wxGtkTreeCellDataFunc( GtkTreeViewColumn *column, wxDataViewRenderer *cell = (wxDataViewRenderer*) data; - wxDataViewItem item( (wxUint32) iter->user_data ); + wxDataViewItem item( (void*) iter->user_data ); wxVariant value; tree_model->model->GetDataViewModel()->GetValue( value, item, cell->GetOwner()->GetModelColumn() ); @@ -2507,7 +2512,7 @@ wxDataViewItem wxDataViewCtrl::GetSelection() GtkTreeIter iter; if (gtk_tree_selection_get_selected( selection, NULL, &iter )) { - wxDataViewItem item( (wxUint32) iter.user_data ); + wxDataViewItem item( (void*) iter.user_data ); return item; } }