Added extended selection support.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6412 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Neis
2000-03-03 16:44:33 +00:00
parent d2e4966591
commit b58088819b
5 changed files with 475 additions and 561 deletions

View File

@@ -76,6 +76,7 @@ class WXDLLEXPORT wxGridRowLabelWindow;
class WXDLLEXPORT wxGridTableBase;
class WXDLLEXPORT wxGridWindow;
class WXDLLEXPORT wxGridTypeRegistry;
class WXDLLEXPORT wxGridSelection;
class WXDLLEXPORT wxCheckBox;
class WXDLLEXPORT wxComboBox;
@@ -960,7 +961,13 @@ public:
~wxGrid();
bool CreateGrid( int numRows, int numCols );
enum wxGridSelectionModes {wxGridSelectCells,
wxGridSelectRows,
wxGridSelectColumns};
bool CreateGrid( int numRows, int numCols,
wxGrid::wxGridSelectionModes selmode =
wxGrid::wxGridSelectCells );
// ------ grid dimensions
@@ -1269,34 +1276,15 @@ public:
void SelectAll();
bool IsSelection()
{ return ( m_selectedTopLeft != wxGridNoCellCoords &&
m_selectedBottomRight != wxGridNoCellCoords );
}
bool IsSelection();
void ClearSelection();
bool IsInSelection( int row, int col )
{ return ( IsSelection() &&
row >= m_selectedTopLeft.GetRow() &&
col >= m_selectedTopLeft.GetCol() &&
row <= m_selectedBottomRight.GetRow() &&
col <= m_selectedBottomRight.GetCol() );
}
bool IsInSelection( int row, int col );
bool IsInSelection( const wxGridCellCoords& coords )
{ return IsInSelection( coords.GetRow(), coords.GetCol() ); }
void GetSelection( int* topRow, int* leftCol, int* bottomRow, int* rightCol )
{
// these will all be -1 if there is no selected block
//
*topRow = m_selectedTopLeft.GetRow();
*leftCol = m_selectedTopLeft.GetCol();
*bottomRow = m_selectedBottomRight.GetRow();
*rightCol = m_selectedBottomRight.GetCol();
}
// This function returns the rectangle that encloses the block of cells
// limited by TopLeft and BottomRight cell in device coords and clipped
@@ -1310,8 +1298,8 @@ public:
//
wxRect SelectionToDeviceRect()
{
return BlockToDeviceRect( m_selectedTopLeft,
m_selectedBottomRight );
return BlockToDeviceRect( m_selectingTopLeft,
m_selectingBottomRight );
}
// Access or update the selection fore/back colours
@@ -1531,8 +1519,9 @@ protected:
wxGridCellCoords m_currentCellCoords;
wxGridCellCoords m_selectedTopLeft;
wxGridCellCoords m_selectedBottomRight;
wxGridCellCoords m_selectingTopLeft;
wxGridCellCoords m_selectingBottomRight;
wxGridSelection *m_selection;
wxColour m_selectionBackground;
wxColour m_selectionForeground;
@@ -1725,7 +1714,7 @@ protected:
bool GetModelValues();
bool SetModelValues();
friend class wxGridSelection;
friend class wxGridSelection;
DECLARE_DYNAMIC_CLASS( wxGrid )
DECLARE_EVENT_TABLE()
@@ -1898,4 +1887,3 @@ const wxEventType wxEVT_GRID_CHANGE_SEL_LABEL = wxEVT_FIRST + 1578;
#endif // #ifndef __WXGRID_H__
#endif // ifndef wxUSE_NEW_GRID

View File

@@ -24,11 +24,8 @@
class WXDLLEXPORT wxGridSelection{
public:
enum wxGridSelectionModes {wxGridSelectCells,
wxGridSelectRows,
wxGridSelectColumns};
wxGridSelection( wxGrid * grid, wxGridSelection::wxGridSelectionModes sel =
wxGridSelection::wxGridSelectCells );
wxGridSelection( wxGrid * grid, wxGrid::wxGridSelectionModes sel =
wxGrid::wxGridSelectCells );
bool IsSelection();
bool IsInSelection ( int row, int col );
void SelectRow( int row, bool addToSelected = FALSE );
@@ -43,32 +40,32 @@ public:
private:
int BlockContain( int topRow1, int leftCol1,
int bottomRow1, int rightCol1,
int topRow2, int leftCol2,
int bottomRow2, int rightCol2 );
int bottomRow1, int rightCol1,
int topRow2, int leftCol2,
int bottomRow2, int rightCol2 );
// returns 1, if Block1 contains Block2,
// -1, if Block2 contains Block1,
// 0, otherwise
int BlockContainsCell( int topRow, int leftCol,
int bottomRow, int rightCol,
int row, int col )
int bottomRow, int rightCol,
int row, int col )
// returns 1, if Block contains Cell,
// 0, otherwise
{
return ( topRow <= row && row <= bottomRow &&
leftCol <= col && col <= rightCol );
leftCol <= col && col <= rightCol );
}
wxGridCellCoordsArray m_cellSelection;
wxGridCellCoordsArray m_blockSelectionTopLeft;
wxGridCellCoordsArray m_blockSelectionBottomRight;
wxArrayInt m_rowSelection;
wxArrayInt m_colSelection;
wxGridCellCoordsArray m_cellSelection;
wxGridCellCoordsArray m_blockSelectionTopLeft;
wxGridCellCoordsArray m_blockSelectionBottomRight;
wxArrayInt m_rowSelection;
wxArrayInt m_colSelection;
wxGrid *m_grid;
wxGridSelectionModes m_selectionMode;
wxGrid *m_grid;
wxGrid::wxGridSelectionModes m_selectionMode;
};
#endif // #ifdef __WXGRIDSEL_H__
#endif // #ifndef wxUSE_NEW_GRID
#endif // #ifdef __WXGRIDSEL_H__
#endif // #ifndef wxUSE_NEW_GRID