Add wxDataViewCtrl::GetCurrentColumn().

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70375 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2012-01-17 14:05:07 +00:00
parent 590a0f8bcb
commit ee1377e1fa
14 changed files with 77 additions and 1 deletions

View File

@@ -668,6 +668,9 @@ public:
wxDataViewItem GetCurrentItem() const; wxDataViewItem GetCurrentItem() const;
void SetCurrentItem(const wxDataViewItem& item); void SetCurrentItem(const wxDataViewItem& item);
// Currently focused column of the current item or NULL if no column has focus
virtual wxDataViewColumn *GetCurrentColumn() const = 0;
// Selection: both GetSelection() and GetSelections() can be used for the // Selection: both GetSelection() and GetSelections() can be used for the
// controls both with and without wxDV_MULTIPLE style. For single selection // controls both with and without wxDV_MULTIPLE style. For single selection
// controls GetSelections() is not very useful however. And for multi // controls GetSelections() is not very useful however. And for multi

View File

@@ -222,6 +222,8 @@ public: // utility functions not part of the API
// return the column displayed at the given position in the control // return the column displayed at the given position in the control
wxDataViewColumn *GetColumnAt(unsigned int pos) const; wxDataViewColumn *GetColumnAt(unsigned int pos) const;
virtual wxDataViewColumn *GetCurrentColumn() const;
virtual void OnInternalIdle(); virtual void OnInternalIdle();
private: private:

View File

@@ -169,6 +169,8 @@ public:
virtual bool EnableDragSource( const wxDataFormat &format ); virtual bool EnableDragSource( const wxDataFormat &format );
virtual bool EnableDropTarget( const wxDataFormat &format ); virtual bool EnableDropTarget( const wxDataFormat &format );
virtual wxDataViewColumn *GetCurrentColumn() const;
static wxVisualAttributes static wxVisualAttributes
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);

View File

@@ -406,6 +406,7 @@ public:
// //
virtual wxDataViewItem GetCurrentItem() const; virtual wxDataViewItem GetCurrentItem() const;
virtual void SetCurrentItem(const wxDataViewItem& item); virtual void SetCurrentItem(const wxDataViewItem& item);
virtual wxDataViewColumn *GetCurrentColumn() const;
virtual int GetSelectedItemsCount() const; virtual int GetSelectedItemsCount() const;
virtual int GetSelections(wxDataViewItemArray& sel) const; virtual int GetSelections(wxDataViewItemArray& sel) const;
virtual bool IsSelected (wxDataViewItem const& item) const; virtual bool IsSelected (wxDataViewItem const& item) const;

View File

@@ -474,6 +474,7 @@ public:
// //
virtual wxDataViewItem GetCurrentItem() const; virtual wxDataViewItem GetCurrentItem() const;
virtual void SetCurrentItem(const wxDataViewItem& item); virtual void SetCurrentItem(const wxDataViewItem& item);
virtual wxDataViewColumn *GetCurrentColumn() const;
virtual int GetSelectedItemsCount() const; virtual int GetSelectedItemsCount() const;
virtual int GetSelections(wxDataViewItemArray& sel) const; virtual int GetSelections(wxDataViewItemArray& sel) const;
virtual bool IsSelected(const wxDataViewItem& item) const; virtual bool IsSelected(const wxDataViewItem& item) const;

View File

@@ -89,6 +89,8 @@ public:
virtual wxDataViewItem GetCurrentItem() const = 0; virtual wxDataViewItem GetCurrentItem() const = 0;
virtual void SetCurrentItem(const wxDataViewItem& item) = 0; virtual void SetCurrentItem(const wxDataViewItem& item) = 0;
virtual wxDataViewColumn *GetCurrentColumn() const = 0;
virtual int GetSelectedItemsCount() const = 0; virtual int GetSelectedItemsCount() const = 0;
virtual int GetSelections(wxDataViewItemArray& sel) const = 0; // returns all selected items in the native control virtual int GetSelections(wxDataViewItemArray& sel) const = 0; // returns all selected items in the native control
virtual bool IsSelected (wxDataViewItem const& item) const = 0; // checks if the passed item is selected in the native control virtual bool IsSelected (wxDataViewItem const& item) const = 0; // checks if the passed item is selected in the native control

View File

@@ -256,6 +256,8 @@ public:
m_Deleting = deleting; m_Deleting = deleting;
} }
virtual wxDataViewColumn *GetCurrentColumn() const;
virtual wxVisualAttributes GetDefaultAttributes() const virtual wxVisualAttributes GetDefaultAttributes() const
{ {
return GetClassDefaultAttributes(GetWindowVariant()); return GetClassDefaultAttributes(GetWindowVariant());

View File

@@ -1060,12 +1060,27 @@ public:
item may be selected or not but under OS X the current item is always item may be selected or not but under OS X the current item is always
selected. selected.
@see SetCurrentItem() @see SetCurrentItem(), GetCurrentColumn()
@since 2.9.2 @since 2.9.2
*/ */
wxDataViewItem GetCurrentItem() const; wxDataViewItem GetCurrentItem() const;
/**
Returns the column that currently has focus.
If the focus is set to individual cell within the currently focused
item (as opposed to being on the item as a whole), then this is the
column that the focus is on.
Returns NULL if no column currently has focus.
@see GetCurrentItem()
@since 2.9.4
*/
wxDataViewColumn *GetCurrentColumn() const;
/** /**
Returns indentation. Returns indentation.
*/ */

View File

@@ -943,6 +943,17 @@ void MyFrame::OnShowCurrent(wxCommandEvent& WXUNUSED(event))
{ {
wxLogMessage("There is no current item."); wxLogMessage("There is no current item.");
} }
wxDataViewColumn *col = m_ctrl[0]->GetCurrentColumn();
if ( col )
{
wxLogMessage("Current column: %d",
m_ctrl[0]->GetColumnPosition(col));
}
else
{
wxLogMessage("There is no current column.");
}
} }
void MyFrame::OnSetNinthCurrent(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnSetNinthCurrent(wxCommandEvent& WXUNUSED(event))

View File

@@ -4858,6 +4858,11 @@ void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item)
} }
} }
wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const
{
return m_clientArea->GetCurrentColumn();
}
int wxDataViewCtrl::GetSelectedItemsCount() const int wxDataViewCtrl::GetSelectedItemsCount() const
{ {
return m_clientArea->GetSelections().size(); return m_clientArea->GetSelections().size();

View File

@@ -4840,6 +4840,19 @@ void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item)
gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_treeview), path, NULL, FALSE); gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_treeview), path, NULL, FALSE);
} }
wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const
{
// The tree doesn't have any current item if it hadn't been created yet but
// it's arguably not an error to call this function in this case so just
// return NULL without asserting.
if ( !m_treeview )
return NULL;
GtkTreeViewColumn *col;
gtk_tree_view_get_cursor(GTK_TREE_VIEW(m_treeview), NULL, &col);
return FromGTKColumn(col);
}
void wxDataViewCtrl::StartEditor(const wxDataViewItem& item, unsigned int column) void wxDataViewCtrl::StartEditor(const wxDataViewItem& item, unsigned int column)
{ {
wxCHECK_RET( m_treeview, wxCHECK_RET( m_treeview,

View File

@@ -1102,6 +1102,12 @@ wxDataViewItem wxMacDataViewDataBrowserListViewControl::GetCurrentItem() const
return wxDataViewItem(); return wxDataViewItem();
} }
wxDataViewColumn *wxMacDataViewDataBrowserListViewControl::GetCurrentColumn() const
{
wxFAIL_MSG( "unimplemented for Carbon" );
return NULL;
}
void wxMacDataViewDataBrowserListViewControl::SetCurrentItem(const wxDataViewItem& WXUNUSED(item)) void wxMacDataViewDataBrowserListViewControl::SetCurrentItem(const wxDataViewItem& WXUNUSED(item))
{ {
wxFAIL_MSG( "unimplemented for Carbon" ); wxFAIL_MSG( "unimplemented for Carbon" );

View File

@@ -2287,6 +2287,14 @@ wxDataViewItem wxCocoaDataViewControl::GetCurrentItem() const
return wxDataViewItem([[m_OutlineView itemAtRow:[m_OutlineView selectedRow]] pointer]); return wxDataViewItem([[m_OutlineView itemAtRow:[m_OutlineView selectedRow]] pointer]);
} }
wxDataViewColumn *wxCocoaDataViewControl::GetCurrentColumn() const
{
int col = [m_OutlineView selectedColumn];
if ( col == -1 )
return NULL;
return GetColumn(col);
}
void wxCocoaDataViewControl::SetCurrentItem(const wxDataViewItem& item) void wxCocoaDataViewControl::SetCurrentItem(const wxDataViewItem& item)
{ {
// We can't have unselected current item in a NSTableView, as the // We can't have unselected current item in a NSTableView, as the

View File

@@ -530,6 +530,11 @@ void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item)
GetDataViewPeer()->SetCurrentItem(item); GetDataViewPeer()->SetCurrentItem(item);
} }
wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const
{
return GetDataViewPeer()->GetCurrentColumn();
}
wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const wxRect wxDataViewCtrl::GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const
{ {
if (item.IsOk() && (columnPtr != NULL)) if (item.IsOk() && (columnPtr != NULL))