]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/gridsel.h
Added separate SetFocusOnCanvas() function so that m_editorFocused will be more relia...
[wxWidgets.git] / include / wx / generic / gridsel.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/gridsel.h
3// Purpose: wxGridSelection
4// Author: Stefan Neis
5// Modified by:
6// Created: 20/02/2000
7// RCS-ID: $$
8// Copyright: (c) Stefan Neis
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_GENERIC_GRIDSEL_H_
13#define _WX_GENERIC_GRIDSEL_H_
14
15#include "wx/defs.h"
16
17#if wxUSE_GRID
18
19#include "wx/grid.h"
20
21class WXDLLIMPEXP_ADV wxGridSelection
22{
23public:
24 wxGridSelection(wxGrid *grid,
25 wxGrid::wxGridSelectionModes sel = wxGrid::wxGridSelectCells);
26
27 bool IsSelection();
28 bool IsInSelection(int row, int col);
29 bool IsInSelection(const wxGridCellCoords& coords)
30 {
31 return IsInSelection(coords.GetRow(), coords.GetCol());
32 }
33
34 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode);
35 wxGrid::wxGridSelectionModes GetSelectionMode() { return m_selectionMode; }
36 void SelectRow( int row,
37 bool ControlDown = false, bool ShiftDown = false,
38 bool AltDown = false, bool MetaDown = false );
39 void SelectCol( int col,
40 bool ControlDown = false, bool ShiftDown = false,
41 bool AltDown = false, bool MetaDown = false );
42 void SelectBlock( int topRow, int leftCol,
43 int bottomRow, int rightCol,
44 bool ControlDown = false, bool ShiftDown = false,
45 bool AltDown = false, bool MetaDown = false,
46 bool sendEvent = true );
47 void SelectCell( int row, int col,
48 bool ControlDown = false, bool ShiftDown = false,
49 bool AltDown = false, bool MetaDown = false,
50 bool sendEvent = true );
51 void ToggleCellSelection( int row, int col,
52 bool ControlDown = false,
53 bool ShiftDown = false,
54 bool AltDown = false, bool MetaDown = false );
55 void ToggleCellSelection( const wxGridCellCoords& coords,
56 bool ControlDown = false,
57 bool ShiftDown = false,
58 bool AltDown = false, bool MetaDown = false )
59 {
60 ToggleCellSelection(coords.GetRow(), coords.GetCol(),
61 ControlDown, ShiftDown, AltDown, MetaDown);
62 }
63
64 void ClearSelection();
65
66 void UpdateRows( size_t pos, int numRows );
67 void UpdateCols( size_t pos, int numCols );
68
69private:
70 int BlockContain( int topRow1, int leftCol1,
71 int bottomRow1, int rightCol1,
72 int topRow2, int leftCol2,
73 int bottomRow2, int rightCol2 );
74 // returns 1, if Block1 contains Block2,
75 // -1, if Block2 contains Block1,
76 // 0, otherwise
77
78 int BlockContainsCell( int topRow, int leftCol,
79 int bottomRow, int rightCol,
80 int row, int col )
81 // returns 1, if Block contains Cell,
82 // 0, otherwise
83 {
84 return ( topRow <= row && row <= bottomRow &&
85 leftCol <= col && col <= rightCol );
86 }
87
88 wxGridCellCoordsArray m_cellSelection;
89 wxGridCellCoordsArray m_blockSelectionTopLeft;
90 wxGridCellCoordsArray m_blockSelectionBottomRight;
91 wxArrayInt m_rowSelection;
92 wxArrayInt m_colSelection;
93
94 wxGrid *m_grid;
95 wxGrid::wxGridSelectionModes m_selectionMode;
96
97 friend class WXDLLIMPEXP_FWD_ADV wxGrid;
98
99 DECLARE_NO_COPY_CLASS(wxGridSelection)
100};
101
102#endif // wxUSE_GRID
103#endif // _WX_GENERIC_GRIDSEL_H_