]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/gridsel.h
Add wxUSE_RIBBON to wx/setup_inc.h and wx/chkconf.h.
[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 // RCS-ID: $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
21 class WXDLLIMPEXP_ADV wxGridSelection
22 {
23 public:
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, const wxKeyboardState& kbd = wxKeyboardState());
37 void SelectCol(int col, const wxKeyboardState& kbd = wxKeyboardState());
38 void SelectBlock(int topRow, int leftCol,
39 int bottomRow, int rightCol,
40 const wxKeyboardState& kbd = wxKeyboardState(),
41 bool sendEvent = true );
42 void SelectBlock(const wxGridCellCoords& topLeft,
43 const wxGridCellCoords& bottomRight,
44 const wxKeyboardState& kbd = wxKeyboardState(),
45 bool sendEvent = true )
46 {
47 SelectBlock(topLeft.GetRow(), topLeft.GetCol(),
48 bottomRight.GetRow(), bottomRight.GetCol(),
49 kbd, sendEvent);
50 }
51
52 void SelectCell(int row, int col,
53 const wxKeyboardState& kbd = wxKeyboardState(),
54 bool sendEvent = true);
55 void SelectCell(const wxGridCellCoords& coords,
56 const wxKeyboardState& kbd = wxKeyboardState(),
57 bool sendEvent = true)
58 {
59 SelectCell(coords.GetRow(), coords.GetCol(), kbd, sendEvent);
60 }
61
62 void ToggleCellSelection(int row, int col,
63 const wxKeyboardState& kbd = wxKeyboardState());
64 void ToggleCellSelection(const wxGridCellCoords& coords,
65 const wxKeyboardState& kbd = wxKeyboardState())
66 {
67 ToggleCellSelection(coords.GetRow(), coords.GetCol(), kbd);
68 }
69
70 void ClearSelection();
71
72 void UpdateRows( size_t pos, int numRows );
73 void UpdateCols( size_t pos, int numCols );
74
75 private:
76 int BlockContain( int topRow1, int leftCol1,
77 int bottomRow1, int rightCol1,
78 int topRow2, int leftCol2,
79 int bottomRow2, int rightCol2 );
80 // returns 1, if Block1 contains Block2,
81 // -1, if Block2 contains Block1,
82 // 0, otherwise
83
84 int BlockContainsCell( int topRow, int leftCol,
85 int bottomRow, int rightCol,
86 int row, int col )
87 // returns 1, if Block contains Cell,
88 // 0, otherwise
89 {
90 return ( topRow <= row && row <= bottomRow &&
91 leftCol <= col && col <= rightCol );
92 }
93
94 void SelectBlockNoEvent(int topRow, int leftCol,
95 int bottomRow, int rightCol)
96 {
97 SelectBlock(topRow, leftCol, bottomRow, rightCol,
98 wxKeyboardState(), false);
99 }
100
101 wxGridCellCoordsArray m_cellSelection;
102 wxGridCellCoordsArray m_blockSelectionTopLeft;
103 wxGridCellCoordsArray m_blockSelectionBottomRight;
104 wxArrayInt m_rowSelection;
105 wxArrayInt m_colSelection;
106
107 wxGrid *m_grid;
108 wxGrid::wxGridSelectionModes m_selectionMode;
109
110 friend class WXDLLIMPEXP_FWD_ADV wxGrid;
111
112 wxDECLARE_NO_COPY_CLASS(wxGridSelection);
113 };
114
115 #endif // wxUSE_GRID
116 #endif // _WX_GENERIC_GRIDSEL_H_