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