Add wxDataViewCtrl::GetTopItem() and GetCountPerPage()
Add methods doing the same thing for wxDataViewCtrl as the existing wxListBox methods. Closes #17498.
This commit is contained in:
committed by
Vadim Zeitlin
parent
e77cb6f31f
commit
eb035485d7
@@ -113,6 +113,7 @@ All (GUI):
|
||||
- Make wxDataViewCtrl::Expand() expand ancestors in native ports too.
|
||||
- Add wxDataViewTextRenderer::EnableMarkup().
|
||||
- Add wxDataViewCtrl::SetHeaderAttr().
|
||||
- Add wxDataViewCtrl::GetTopItem() and GetCountPerPage() (Andreas Falkenhahn).
|
||||
- Add wxListCtrl::SetHeaderAttr().
|
||||
- Add support for using markup in wxDataViewCtrl text items.
|
||||
- Implement auto complete in generic wxSearchCtrl (Eric Jensen).
|
||||
|
@@ -699,6 +699,9 @@ public:
|
||||
wxDataViewItem GetCurrentItem() const;
|
||||
void SetCurrentItem(const wxDataViewItem& item);
|
||||
|
||||
virtual wxDataViewItem GetTopItem() const { return wxDataViewItem(0); }
|
||||
virtual int GetCountPerPage() const { return wxNOT_FOUND; }
|
||||
|
||||
// Currently focused column of the current item or NULL if no column has focus
|
||||
virtual wxDataViewColumn *GetCurrentColumn() const = 0;
|
||||
|
||||
|
@@ -226,6 +226,9 @@ public:
|
||||
virtual wxDataViewColumn *GetSortingColumn() const wxOVERRIDE;
|
||||
virtual wxVector<wxDataViewColumn *> GetSortingColumns() const wxOVERRIDE;
|
||||
|
||||
virtual wxDataViewItem GetTopItem() const wxOVERRIDE;
|
||||
virtual int GetCountPerPage() const wxOVERRIDE;
|
||||
|
||||
virtual int GetSelectedItemsCount() const wxOVERRIDE;
|
||||
virtual int GetSelections( wxDataViewItemArray & sel ) const wxOVERRIDE;
|
||||
virtual void SetSelections( const wxDataViewItemArray & sel ) wxOVERRIDE;
|
||||
|
@@ -169,6 +169,9 @@ public:
|
||||
|
||||
virtual wxDataViewColumn *GetCurrentColumn() const wxOVERRIDE;
|
||||
|
||||
virtual wxDataViewItem GetTopItem() const wxOVERRIDE;
|
||||
virtual int GetCountPerPage() const wxOVERRIDE;
|
||||
|
||||
static wxVisualAttributes
|
||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||
|
||||
|
@@ -480,8 +480,10 @@ public:
|
||||
virtual void EnsureVisible(const wxDataViewItem& item,
|
||||
wxDataViewColumn const* columnPtr);
|
||||
virtual unsigned int GetCount() const;
|
||||
virtual int GetCountPerPage() const;
|
||||
virtual wxRect GetRectangle(const wxDataViewItem& item,
|
||||
wxDataViewColumn const* columnPtr);
|
||||
virtual wxDataViewItem GetTopItem() const;
|
||||
virtual bool IsExpanded(const wxDataViewItem& item) const;
|
||||
virtual bool Reload();
|
||||
virtual bool Remove(const wxDataViewItem& parent,
|
||||
|
@@ -63,7 +63,9 @@ public:
|
||||
virtual void Collapse (wxDataViewItem const& item) = 0; // collapses the passed item in the native control
|
||||
virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) = 0; // ensures that the passed item's value in the passed column is visible (column pointer can be NULL)
|
||||
virtual unsigned int GetCount (void) const = 0; // returns the number of items in the native control
|
||||
virtual int GetCountPerPage(void) const = 0; // get number of items that fit into a single page
|
||||
virtual wxRect GetRectangle (wxDataViewItem const& item, wxDataViewColumn const* columnPtr) = 0; // returns the rectangle that is used by the passed item and column in the native control
|
||||
virtual wxDataViewItem GetTopItem (void) const = 0; // get top-most visible item
|
||||
virtual bool IsExpanded (wxDataViewItem const& item) const = 0; // checks if the passed item is expanded in the native control
|
||||
virtual bool Reload (void) = 0; // clears the native control and reloads all data
|
||||
virtual bool Remove (wxDataViewItem const& parent, wxDataViewItem const& item) = 0; // removes an item from the native control
|
||||
|
@@ -172,11 +172,14 @@ public:
|
||||
virtual bool IsExpanded(const wxDataViewItem & item) const wxOVERRIDE;
|
||||
|
||||
virtual unsigned int GetCount() const;
|
||||
virtual int GetCountPerPage() const wxOVERRIDE;
|
||||
virtual wxRect GetItemRect(const wxDataViewItem& item,
|
||||
const wxDataViewColumn* columnPtr = NULL) const wxOVERRIDE;
|
||||
virtual int GetSelectedItemsCount() const wxOVERRIDE;
|
||||
virtual int GetSelections(wxDataViewItemArray& sel) const wxOVERRIDE;
|
||||
|
||||
virtual wxDataViewItem GetTopItem() const wxOVERRIDE;
|
||||
|
||||
virtual void HitTest(const wxPoint& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const wxOVERRIDE;
|
||||
|
||||
virtual bool SetRowHeight(int rowHeight) wxOVERRIDE;
|
||||
|
@@ -1647,6 +1647,28 @@ public:
|
||||
@since 3.1.0
|
||||
*/
|
||||
virtual void ToggleSortByColumn(int column);
|
||||
|
||||
/**
|
||||
Return the number of items that can fit vertically in the visible area of
|
||||
the control.
|
||||
|
||||
Returns -1 if the number of items per page couldn't be determined. On
|
||||
wxGTK this method can only determine the number of items per page if
|
||||
there is at least one item in the control.
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
int GetCountPerPage() const;
|
||||
|
||||
/**
|
||||
Return the topmost visible item.
|
||||
|
||||
Returns an invalid item if there is no topmost visible item or if the method
|
||||
is not implemented for the current platform.
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
wxDataViewItem GetTopItem() const;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -751,6 +751,7 @@ public:
|
||||
int GetCountPerPage() const;
|
||||
int GetEndOfLastCol() const;
|
||||
unsigned int GetFirstVisibleRow() const;
|
||||
wxDataViewItem GetTopItem() const;
|
||||
|
||||
// I change this method to un const because in the tree view,
|
||||
// the displaying number of the tree are changing along with the
|
||||
@@ -2842,6 +2843,27 @@ int wxDataViewMainWindow::GetCountPerPage() const
|
||||
return size.y / m_lineHeight;
|
||||
}
|
||||
|
||||
wxDataViewItem wxDataViewMainWindow::GetTopItem() const
|
||||
{
|
||||
unsigned int item = GetFirstVisibleRow();
|
||||
wxDataViewTreeNode *node = NULL;
|
||||
wxDataViewItem dataitem;
|
||||
|
||||
if ( !IsVirtualList() )
|
||||
{
|
||||
node = GetTreeNodeByRow(item);
|
||||
if( node == NULL ) return wxDataViewItem(0);
|
||||
|
||||
dataitem = node->GetItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
dataitem = wxDataViewItem( wxUIntToPtr(item+1) );
|
||||
}
|
||||
|
||||
return dataitem;
|
||||
}
|
||||
|
||||
int wxDataViewMainWindow::GetEndOfLastCol() const
|
||||
{
|
||||
int width = 0;
|
||||
@@ -5386,6 +5408,16 @@ int wxDataViewCtrl::GetSelectedItemsCount() const
|
||||
return m_clientArea->GetSelections().GetSelectedCount();
|
||||
}
|
||||
|
||||
wxDataViewItem wxDataViewCtrl::GetTopItem() const
|
||||
{
|
||||
return m_clientArea->GetTopItem();
|
||||
}
|
||||
|
||||
int wxDataViewCtrl::GetCountPerPage() const
|
||||
{
|
||||
return m_clientArea->GetCountPerPage();
|
||||
}
|
||||
|
||||
int wxDataViewCtrl::GetSelections( wxDataViewItemArray & sel ) const
|
||||
{
|
||||
sel.Empty();
|
||||
|
@@ -4917,6 +4917,53 @@ void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item)
|
||||
gtk_tree_view_set_cursor(GTK_TREE_VIEW(m_treeview), path, NULL, FALSE);
|
||||
}
|
||||
|
||||
wxDataViewItem wxDataViewCtrl::GetTopItem() const
|
||||
{
|
||||
wxGtkTreePath start;
|
||||
if ( !gtk_tree_view_get_visible_range
|
||||
(
|
||||
GTK_TREE_VIEW(m_treeview),
|
||||
start.ByRef(),
|
||||
NULL
|
||||
) )
|
||||
{
|
||||
return wxDataViewItem();
|
||||
}
|
||||
|
||||
return GTKPathToItem(start);
|
||||
}
|
||||
|
||||
int wxDataViewCtrl::GetCountPerPage() const
|
||||
{
|
||||
wxGtkTreePath path;
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
if ( !gtk_tree_view_get_path_at_pos
|
||||
(
|
||||
GTK_TREE_VIEW(m_treeview),
|
||||
0,
|
||||
0,
|
||||
path.ByRef(),
|
||||
&column,
|
||||
NULL,
|
||||
NULL
|
||||
) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
GdkRectangle rect;
|
||||
gtk_tree_view_get_cell_area(GTK_TREE_VIEW(m_treeview), path, column, &rect);
|
||||
|
||||
if ( !rect.height )
|
||||
return -1;
|
||||
|
||||
GdkRectangle vis;
|
||||
gtk_tree_view_get_visible_rect(GTK_TREE_VIEW(m_treeview), &vis);
|
||||
|
||||
return vis.height / rect.height;
|
||||
}
|
||||
|
||||
wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const
|
||||
{
|
||||
// The tree doesn't have any current item if it hadn't been created yet but
|
||||
|
@@ -2313,6 +2313,27 @@ unsigned int wxCocoaDataViewControl::GetCount() const
|
||||
return [m_OutlineView numberOfRows];
|
||||
}
|
||||
|
||||
int wxCocoaDataViewControl::GetCountPerPage() const
|
||||
{
|
||||
NSScrollView *scrollView = [m_OutlineView enclosingScrollView];
|
||||
NSTableHeaderView *headerView = [m_OutlineView headerView];
|
||||
NSRect visibleRect = scrollView.contentView.visibleRect;
|
||||
if ( headerView )
|
||||
visibleRect.size.height -= headerView.visibleRect.size.height;
|
||||
return (int) (visibleRect.size.height / [m_OutlineView rowHeight]);
|
||||
}
|
||||
|
||||
wxDataViewItem wxCocoaDataViewControl::GetTopItem() const
|
||||
{
|
||||
NSScrollView *scrollView = [m_OutlineView enclosingScrollView];
|
||||
NSTableHeaderView *headerView = [m_OutlineView headerView];
|
||||
NSRect visibleRect = scrollView.contentView.visibleRect;
|
||||
if ( headerView )
|
||||
visibleRect.origin.y += headerView.visibleRect.size.height;
|
||||
NSRange range = [m_OutlineView rowsInRect:visibleRect];
|
||||
return wxDataViewItem([[m_OutlineView itemAtRow:range.location] pointer]);
|
||||
}
|
||||
|
||||
wxRect wxCocoaDataViewControl::GetRectangle(const wxDataViewItem& item, const wxDataViewColumn *columnPtr)
|
||||
{
|
||||
return wxFromNSRect([m_osxView superview],[m_OutlineView frameOfCellAtColumn:GetColumnPosition(columnPtr)
|
||||
|
@@ -563,6 +563,16 @@ int wxDataViewCtrl::GetSelections(wxDataViewItemArray& sel) const
|
||||
return GetDataViewPeer()->GetSelections(sel);
|
||||
}
|
||||
|
||||
wxDataViewItem wxDataViewCtrl::GetTopItem() const
|
||||
{
|
||||
return GetDataViewPeer()->GetTopItem();
|
||||
}
|
||||
|
||||
int wxDataViewCtrl::GetCountPerPage() const
|
||||
{
|
||||
return GetDataViewPeer()->GetCountPerPage();
|
||||
}
|
||||
|
||||
void wxDataViewCtrl::HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const
|
||||
{
|
||||
return GetDataViewPeer()->HitTest(point,item,columnPtr);
|
||||
|
Reference in New Issue
Block a user