]>
Commit | Line | Data |
---|---|---|
294f6bcb SN |
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 | |
65571936 | 9 | // Licence: wxWindows licence |
294f6bcb SN |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
df9fac6d PC |
12 | #ifndef _WX_GENERIC_GRIDSEL_H_ |
13 | #define _WX_GENERIC_GRIDSEL_H_ | |
20ceebaa | 14 | |
294f6bcb SN |
15 | #include "wx/defs.h" |
16 | ||
c176a11a | 17 | #if wxUSE_GRID |
294f6bcb | 18 | |
294f6bcb SN |
19 | #include "wx/grid.h" |
20 | ||
df9fac6d PC |
21 | class WXDLLIMPEXP_ADV wxGridSelection |
22 | { | |
294f6bcb | 23 | public: |
bec70262 VZ |
24 | wxGridSelection(wxGrid *grid, |
25 | wxGrid::wxGridSelectionModes sel = wxGrid::wxGridSelectCells); | |
26 | ||
294f6bcb | 27 | bool IsSelection(); |
bec70262 VZ |
28 | bool IsInSelection(int row, int col); |
29 | bool IsInSelection(const wxGridCellCoords& coords) | |
30 | { | |
31 | return IsInSelection(coords.GetRow(), coords.GetCol()); | |
32 | } | |
33 | ||
f1567cdd | 34 | void SetSelectionMode(wxGrid::wxGridSelectionModes selmode); |
399b60a0 | 35 | wxGrid::wxGridSelectionModes GetSelectionMode() { return m_selectionMode; } |
723d1b1d | 36 | void SelectRow( int row, |
ca65c044 WS |
37 | bool ControlDown = false, bool ShiftDown = false, |
38 | bool AltDown = false, bool MetaDown = false ); | |
723d1b1d | 39 | void SelectCol( int col, |
ca65c044 WS |
40 | bool ControlDown = false, bool ShiftDown = false, |
41 | bool AltDown = false, bool MetaDown = false ); | |
5c8fc7c1 SN |
42 | void SelectBlock( int topRow, int leftCol, |
43 | int bottomRow, int rightCol, | |
ca65c044 WS |
44 | bool ControlDown = false, bool ShiftDown = false, |
45 | bool AltDown = false, bool MetaDown = false, | |
46 | bool sendEvent = true ); | |
d95b0c2b | 47 | void SelectCell( int row, int col, |
ca65c044 WS |
48 | bool ControlDown = false, bool ShiftDown = false, |
49 | bool AltDown = false, bool MetaDown = false, | |
50 | bool sendEvent = true ); | |
d95b0c2b | 51 | void ToggleCellSelection( int row, int col, |
ca65c044 WS |
52 | bool ControlDown = false, |
53 | bool ShiftDown = false, | |
54 | bool AltDown = false, bool MetaDown = false ); | |
bec70262 VZ |
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 | ||
294f6bcb SN |
64 | void ClearSelection(); |
65 | ||
66 | void UpdateRows( size_t pos, int numRows ); | |
67 | void UpdateCols( size_t pos, int numCols ); | |
68 | ||
69 | private: | |
70 | int BlockContain( int topRow1, int leftCol1, | |
b5808881 SN |
71 | int bottomRow1, int rightCol1, |
72 | int topRow2, int leftCol2, | |
73 | int bottomRow2, int rightCol2 ); | |
294f6bcb SN |
74 | // returns 1, if Block1 contains Block2, |
75 | // -1, if Block2 contains Block1, | |
76 | // 0, otherwise | |
77 | ||
78 | int BlockContainsCell( int topRow, int leftCol, | |
b5808881 SN |
79 | int bottomRow, int rightCol, |
80 | int row, int col ) | |
294f6bcb SN |
81 | // returns 1, if Block contains Cell, |
82 | // 0, otherwise | |
83 | { | |
84 | return ( topRow <= row && row <= bottomRow && | |
b5808881 | 85 | leftCol <= col && col <= rightCol ); |
294f6bcb SN |
86 | } |
87 | ||
b5808881 SN |
88 | wxGridCellCoordsArray m_cellSelection; |
89 | wxGridCellCoordsArray m_blockSelectionTopLeft; | |
90 | wxGridCellCoordsArray m_blockSelectionBottomRight; | |
91 | wxArrayInt m_rowSelection; | |
92 | wxArrayInt m_colSelection; | |
294f6bcb | 93 | |
b5808881 SN |
94 | wxGrid *m_grid; |
95 | wxGrid::wxGridSelectionModes m_selectionMode; | |
aa5b8857 | 96 | |
b5dbe15d | 97 | friend class WXDLLIMPEXP_FWD_ADV wxGrid; |
22f3361e VZ |
98 | |
99 | DECLARE_NO_COPY_CLASS(wxGridSelection) | |
294f6bcb SN |
100 | }; |
101 | ||
df9fac6d PC |
102 | #endif // wxUSE_GRID |
103 | #endif // _WX_GENERIC_GRIDSEL_H_ |