Virtualize StartEditor and add implementations for the ports that can do it.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67817 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2011-05-31 19:36:47 +00:00
parent 9f2b6b31b7
commit eeea3b039e
13 changed files with 67 additions and 3 deletions

View File

@@ -701,6 +701,8 @@ public:
virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0;
virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0;
virtual void StartEditor( const wxDataViewItem & item, unsigned int column ) { }
#if wxUSE_DRAG_AND_DROP
virtual bool EnableDragSource(const wxDataFormat& WXUNUSED(format))
{ return false; }

View File

@@ -185,7 +185,7 @@ public:
virtual wxBorder GetDefaultBorder() const;
void StartEditor( const wxDataViewItem & item, unsigned int column );
virtual void StartEditor( const wxDataViewItem & item, unsigned int column );
protected:
virtual int GetSelections( wxArrayInt & sel ) const;

View File

@@ -159,6 +159,8 @@ public:
virtual wxRect GetItemRect( const wxDataViewItem &item,
const wxDataViewColumn *column = NULL ) const;
virtual void StartEditor( const wxDataViewItem & item, unsigned int column );
virtual void Expand( const wxDataViewItem & item );
virtual void Collapse( const wxDataViewItem & item );
virtual bool IsExpanded( const wxDataViewItem & item ) const;

View File

@@ -427,6 +427,8 @@ public:
virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height);
virtual void OnSize ();
virtual void StartEditor( const wxDataViewItem & item, unsigned int column );
//
// other methods
//

View File

@@ -497,6 +497,8 @@ public:
virtual void SetRowHeight(const wxDataViewItem& item, unsigned int height);
virtual void OnSize();
virtual void StartEditor( const wxDataViewItem & item, unsigned int column );
// drag & drop helper methods
wxDataFormat GetDnDDataFormat(wxDataObjectComposite* dataObjects);
wxDataObjectComposite* GetDnDDataObjects(NSData* dataObject) const;

View File

@@ -109,6 +109,7 @@ public:
virtual void HitTest (wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const = 0; // return the item and column pointer that contains with the passed point
virtual void SetRowHeight(wxDataViewItem const& item, unsigned int height) = 0; // sets the height of the row containg the passed item in the native control
virtual void OnSize (void) = 0; // updates the layout of the native control after a size event
virtual void StartEditor( const wxDataViewItem & item, unsigned int column ) = 0; // starts editing the passed in item and column
};
#endif // _WX_DATAVIEWCTRL_CORE_H_

View File

@@ -202,6 +202,8 @@ public:
// finishes editing of custom items; if no custom item is currently edited the method does nothing
void FinishCustomItemEditing();
virtual void StartEditor( const wxDataViewItem & item, unsigned int column );
// returns the n-th pointer to a column;
// this method is different from GetColumn(unsigned int pos) because here 'n' is not a position in the control but the n-th
// position in the internal list/array of column pointers

View File

@@ -1095,6 +1095,14 @@ public:
*/
virtual void SetSelections(const wxDataViewItemArray& sel);
/**
Programmatically starts editing the given item on the given column.
Currently not implemented on wxOSX Carbon.
@since 2.9.2
*/
virtual void StartEditor(const wxDataViewItem & item, unsigned int column);
/**
Unselect the given item.
*/

View File

@@ -1160,8 +1160,11 @@ void MyFrame::OnAddTreeItem(wxCommandEvent& WXUNUSED(event))
{
wxDataViewTreeCtrl* ctrl = (wxDataViewTreeCtrl*) m_ctrl[3];
wxDataViewItem selected = ctrl->GetSelection();
if (ctrl->IsContainer(selected))
ctrl->AppendItem( selected, "Item", 0 );
if (ctrl->IsContainer(selected)) {
wxDataViewItem newitem = ctrl->AppendItem( selected, "Item", 0 );
ctrl->Select(newitem);
ctrl->StartEditor(newitem, 0);
}
}
void MyFrame::OnAddTreeContainerItem(wxCommandEvent& WXUNUSED(event))

View File

@@ -4836,6 +4836,33 @@ void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item)
gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_treeview), path, NULL, FALSE);
}
void wxDataViewCtrl::StartEditor(const wxDataViewItem& item, unsigned int column)
{
wxCHECK_RET( m_treeview,
"Current item can't be set before creating the control." );
// We need to make sure the model knows about this item or the path would
// be invalid and gtk_tree_view_set_cursor() would silently do nothing.
ExpandAncestors(item);
wxDataViewColumn *dvcolumn = GetColumn(column);
wxASSERT_MSG(dvcolumn, "Could not retrieve column");
GtkTreeViewColumn *gcolumn = GTK_TREE_VIEW_COLUMN(dvcolumn->GetGtkHandle());
// We also need to preserve the existing selection from changing.
// Unfortunately the only way to do it seems to use our own selection
// function and forbid any selection changes during set cursor call.
wxGtkTreeSelectionLock
lock(gtk_tree_view_get_selection(GTK_TREE_VIEW(m_treeview)));
// Do move the cursor now.
GtkTreeIter iter;
iter.user_data = item.GetID();
wxGtkTreePath path(m_internal->get_path( &iter ));
gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_treeview), path, gcolumn, TRUE);
}
wxDataViewItem wxDataViewCtrl::GetSelection() const
{
GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(m_treeview) );

View File

@@ -1236,6 +1236,11 @@ void wxMacDataViewDataBrowserListViewControl::OnSize()
SetHasScrollBars(true,true);
}
void wxMacDataViewDataBrowserListViewControl::StartEditor( const wxDataViewItem & item, unsigned int column )
{
// implement me
}
//
// callback functions (inherited from wxMacDataBrowserTableViewControl)
//

View File

@@ -2314,6 +2314,11 @@ void wxCocoaDataViewControl::Resort()
[m_OutlineView reloadData];
}
void wxCocoaDataViewControl::StartEditor( const wxDataViewItem & item, unsigned int column )
{
[m_OutlineView editColumn:column row:[m_OutlineView rowForItem:[m_DataSource getDataViewItemFromBuffer:item]] withEvent:nil select:YES];
}
//
// other methods (inherited from wxDataViewWidgetImpl)
//

View File

@@ -633,6 +633,11 @@ void wxDataViewCtrl::AddChildren(wxDataViewItem const& parentItem)
(void) GetModel()->ItemsAdded(parentItem,items);
}
void wxDataViewCtrl::StartEditor( const wxDataViewItem & item, unsigned int column )
{
GetDataViewPeer()->StartEditor(item, column);
}
void wxDataViewCtrl::FinishCustomItemEditing()
{
if (GetCustomRendererItem().IsOk())