From aa5b885706e9a5bee8ad5346f024710a72356108 Mon Sep 17 00:00:00 2001 From: Stefan Neis Date: Sat, 7 Sep 2002 13:58:25 +0000 Subject: [PATCH] Commited John Labenski's patch giving access to the low level selection representation (Patch 579754). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17043 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/grid.tex | 54 ++++++++++++++++++++++++++++++------ include/wx/generic/grid.h | 10 +++++-- include/wx/generic/gridsel.h | 2 ++ src/generic/grid.cpp | 35 +++++++++++++++++++++++ 4 files changed, 91 insertions(+), 10 deletions(-) diff --git a/docs/latex/wx/grid.tex b/docs/latex/wx/grid.tex index ef18fc067e..99971585be 100644 --- a/docs/latex/wx/grid.tex +++ b/docs/latex/wx/grid.tex @@ -647,6 +647,44 @@ your own labels. Returns the height of the specified row. +\membersection{wxGrid::GetSelectionMode}\label{wxgridgetselectionmode} + +\constfunc{wxGrid::wxGridSelectionModes}{GetSelectionMode}{\void} + +Returns the current selection mode, see \helpref{wxGrid::SetSelectionMode}{wxgridsetselectionmode}. + +\membersection{wxGrid::GetSelectedCells}\label{wxgridgetselectedcells} + +\constfunc{wxGridCellCoordsArray}{GetSelectedCells}{\void} + +Returns an array of singly selected cells. + +\membersection{wxGrid::GetSelectedCols}\label{wxgridgetselectedcols} + +\constfunc{wxArrayInt}{GetSelectedCols}{\void} + +Returns an array of selected cols. + +\membersection{wxGrid::GetSelectedRows}\label{wxgridgetselectedrows} + +\constfunc{wxArrayInt}{GetSelectedRows}{\void} + +Returns an array of selected rows. + +\membersection{wxGrid::GetSelectionBlockTopLeft}\label{wxgridgetselectionblocktopleft} + +\constfunc{wxGridCellCoordsArray}{GetSelectionBlockTopLeft}{\void} + +Returns an array of the top left corners of blocks of selected cells, +see \helpref{wxGrid::GetSelectionBlockBottomRight}{wxgridgetselectionblockbottomright}. + +\membersection{wxGrid::GetSelectionBlockBottomRight}\label{wxgridgetselectionblockbottomright} + +\constfunc{wxGridCellCoordsArray}{GetSelectionBlockBottomRight}{\void} + +Returns an array of the bottom right corners of blocks of selected cells, +see \helpref{wxGrid::GetSelectionBlockTopLeft}{wxgridgetselectionblocktopleft}. + \membersection{wxGrid::GetTable}\label{wxgridgettable} \constfunc{wxGridTableBase *}{GetTable}{\void} @@ -714,6 +752,14 @@ Returns FALSE if the whole grid has been set as read-only or TRUE otherwise. See \helpref{wxGrid::EnableEditing}{wxgridenableediting} for more information about controlling the editing status of grid cells. +\membersection{wxGrid::IsInSelection}\label{wxgridisinselection} + +\constfunc{bool}{IsInSelection}{\param{int }{row}, \param{int }{col}} + +\constfunc{bool}{IsInSelection}{\param{const wxGridCellCoords\& }{coords}} + +Is this cell currently selected. + \membersection{wxGrid::IsReadOnly}\label{wxgridisreadonly} \constfunc{bool}{IsReadOnly}{\param{int }{row}, \param{int }{col}} @@ -1251,14 +1297,6 @@ Returns the grid row that corresponds to the logical y coordinate. Returns wxNOT\_FOUND if there is no row at the y position. - -\membersection{wxGrid::IsInSelection}\label{wxgridisinselection} - -\func{bool}{IsInSelection}{\param{int }{row}, \param{int }{col}} - -\func{bool}{IsInSelection}{\param{const wxGridCellCoords\& }{coords}} - - \membersection{wxGrid::BlockToDeviceRect}\label{wxgridblocktodevicerect} \func{wxRect}{BlockToDeviceRect}{\param{const wxGridCellCoords \& }{topLeft}, \param{const wxGridCellCoords \& }{bottomRight}} diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 364339877a..8825ffe555 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -1029,6 +1029,7 @@ public: wxGrid::wxGridSelectCells ); void SetSelectionMode(wxGrid::wxGridSelectionModes selmode); + wxGrid::wxGridSelectionModes GetSelectionMode() const; // ------ grid dimensions // @@ -1355,7 +1356,7 @@ public: // make the cell editable/readonly void SetReadOnly(int row, int col, bool isReadOnly = TRUE); - // ------ selections of blocks of cells + // ------ select blocks of cells // void SelectRow( int row, bool addToSelected = FALSE ); void SelectCol( int col, bool addToSelected = FALSE ); @@ -1374,7 +1375,7 @@ public: bool IsSelection(); - // ------ deselection + // ------ deselect blocks or cells // void DeselectRow( int row ); void DeselectCol( int col ); @@ -1387,6 +1388,11 @@ public: bool IsInSelection( const wxGridCellCoords& coords ) const { return IsInSelection( coords.GetRow(), coords.GetCol() ); } + wxGridCellCoordsArray GetSelectedCells() const; + wxGridCellCoordsArray GetSelectionBlockTopLeft() const; + wxGridCellCoordsArray GetSelectionBlockBottomRight() const; + wxArrayInt GetSelectedRows() const; + wxArrayInt GetSelectedCols() const; // This function returns the rectangle that encloses the block of cells // limited by TopLeft and BottomRight cell in device coords and clipped diff --git a/include/wx/generic/gridsel.h b/include/wx/generic/gridsel.h index 6567e38bfa..4645f2c142 100644 --- a/include/wx/generic/gridsel.h +++ b/include/wx/generic/gridsel.h @@ -81,6 +81,8 @@ private: wxGrid *m_grid; wxGrid::wxGridSelectionModes m_selectionMode; + + friend class wxGrid; }; #endif // #ifdef __WXGRIDSEL_H__ diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 837f7e3252..96448743d0 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -3721,6 +3721,14 @@ void wxGrid::SetSelectionMode(wxGrid::wxGridSelectionModes selmode) m_selection->SetSelectionMode( selmode ); } +wxGrid::wxGridSelectionModes wxGrid::GetSelectionMode() const +{ + wxCHECK_MSG( m_created, wxGrid::wxGridSelectCells, + wxT("Called wxGrid::GetSelectionMode() before calling CreateGrid()") ); + + return m_selection->GetSelectionMode(); +} + bool wxGrid::SetTable( wxGridTableBase *table, bool takeOwnership, wxGrid::wxGridSelectionModes selmode ) { @@ -9375,6 +9383,33 @@ bool wxGrid::IsInSelection( int row, int col ) const col <= m_selectingBottomRight.GetCol() )) ); } +wxGridCellCoordsArray wxGrid::GetSelectedCells() const +{ + if (!m_selection) { wxGridCellCoordsArray a; return a; } + return m_selection->m_cellSelection; +} +wxGridCellCoordsArray wxGrid::GetSelectionBlockTopLeft() const +{ + if (!m_selection) { wxGridCellCoordsArray a; return a; } + return m_selection->m_blockSelectionTopLeft; +} +wxGridCellCoordsArray wxGrid::GetSelectionBlockBottomRight() const +{ + if (!m_selection) { wxGridCellCoordsArray a; return a; } + return m_selection->m_blockSelectionTopLeft; +} +wxArrayInt wxGrid::GetSelectedRows() const +{ + if (!m_selection) { wxArrayInt a; return a; } + return m_selection->m_rowSelection; +} +wxArrayInt wxGrid::GetSelectedCols() const +{ + if (!m_selection) { wxArrayInt a; return a; } + return m_selection->m_colSelection; +} + + void wxGrid::ClearSelection() { m_selectingTopLeft = wxGridNoCellCoords; -- 2.45.2