]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/gridsel.h
Destroy the wxDialog::ShowWindowModalThenDo() functor a.s.a.p.
[wxWidgets.git] / include / wx / generic / gridsel.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/gridsel.h
3 // Purpose: wxGridSelection
4 // Author: Stefan Neis
5 // Modified by:
6 // Created: 20/02/2000
7 // Copyright: (c) Stefan Neis
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_GENERIC_GRIDSEL_H_
12 #define _WX_GENERIC_GRIDSEL_H_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_GRID
17
18 #include "wx/grid.h"
19
20 class WXDLLIMPEXP_ADV wxGridSelection
21 {
22 public:
23 wxGridSelection(wxGrid *grid,
24 wxGrid::wxGridSelectionModes sel = wxGrid::wxGridSelectCells);
25
26 bool IsSelection();
27 bool IsInSelection(int row, int col);
28 bool IsInSelection(const wxGridCellCoords& coords)
29 {
30 return IsInSelection(coords.GetRow(), coords.GetCol());
31 }
32
33 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode);
34 wxGrid::wxGridSelectionModes GetSelectionMode() { return m_selectionMode; }
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 )
45 {
46 SelectBlock(topLeft.GetRow(), topLeft.GetCol(),
47 bottomRight.GetRow(), bottomRight.GetCol(),
48 kbd, sendEvent);
49 }
50
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 }
60
61 void ToggleCellSelection(int row, int col,
62 const wxKeyboardState& kbd = wxKeyboardState());
63 void ToggleCellSelection(const wxGridCellCoords& coords,
64 const wxKeyboardState& kbd = wxKeyboardState())
65 {
66 ToggleCellSelection(coords.GetRow(), coords.GetCol(), kbd);
67 }
68
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,
76 int bottomRow1, int rightCol1,
77 int topRow2, int leftCol2,
78 int bottomRow2, int rightCol2 );
79 // returns 1, if Block1 contains Block2,
80 // -1, if Block2 contains Block1,
81 // 0, otherwise
82
83 int BlockContainsCell( int topRow, int leftCol,
84 int bottomRow, int rightCol,
85 int row, int col )
86 // returns 1, if Block contains Cell,
87 // 0, otherwise
88 {
89 return ( topRow <= row && row <= bottomRow &&
90 leftCol <= col && col <= rightCol );
91 }
92
93 void SelectBlockNoEvent(int topRow, int leftCol,
94 int bottomRow, int rightCol)
95 {
96 SelectBlock(topRow, leftCol, bottomRow, rightCol,
97 wxKeyboardState(), false);
98 }
99
100 wxGridCellCoordsArray m_cellSelection;
101 wxGridCellCoordsArray m_blockSelectionTopLeft;
102 wxGridCellCoordsArray m_blockSelectionBottomRight;
103 wxArrayInt m_rowSelection;
104 wxArrayInt m_colSelection;
105
106 wxGrid *m_grid;
107 wxGrid::wxGridSelectionModes m_selectionMode;
108
109 friend class WXDLLIMPEXP_FWD_ADV wxGrid;
110
111 wxDECLARE_NO_COPY_CLASS(wxGridSelection);
112 };
113
114 #endif // wxUSE_GRID
115 #endif // _WX_GENERIC_GRIDSEL_H_