]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/gridsel.h
detect and report errors in XRC specification of grid sizers
[wxWidgets.git] / include / wx / generic / gridsel.h
CommitLineData
294f6bcb
SN
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/gridsel.h
3// Purpose: wxGridSelection
4// Author: Stefan Neis
5// Modified by:
6// Created: 20/02/2000
2903e699 7// RCS-ID: $Id$
294f6bcb 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
21class WXDLLIMPEXP_ADV wxGridSelection
22{
294f6bcb 23public:
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; }
8b5f6d9d
VZ
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 )
8a3e536c
VZ
46 {
47 SelectBlock(topLeft.GetRow(), topLeft.GetCol(),
48 bottomRight.GetRow(), bottomRight.GetCol(),
8b5f6d9d 49 kbd, sendEvent);
8a3e536c
VZ
50 }
51
8b5f6d9d
VZ
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 }
8a3e536c 61
8b5f6d9d
VZ
62 void ToggleCellSelection(int row, int col,
63 const wxKeyboardState& kbd = wxKeyboardState());
64 void ToggleCellSelection(const wxGridCellCoords& coords,
65 const wxKeyboardState& kbd = wxKeyboardState())
bec70262 66 {
8b5f6d9d 67 ToggleCellSelection(coords.GetRow(), coords.GetCol(), kbd);
bec70262
VZ
68 }
69
294f6bcb
SN
70 void ClearSelection();
71
72 void UpdateRows( size_t pos, int numRows );
73 void UpdateCols( size_t pos, int numCols );
74
75private:
76 int BlockContain( int topRow1, int leftCol1,
b5808881
SN
77 int bottomRow1, int rightCol1,
78 int topRow2, int leftCol2,
79 int bottomRow2, int rightCol2 );
294f6bcb
SN
80 // returns 1, if Block1 contains Block2,
81 // -1, if Block2 contains Block1,
82 // 0, otherwise
83
84 int BlockContainsCell( int topRow, int leftCol,
b5808881
SN
85 int bottomRow, int rightCol,
86 int row, int col )
294f6bcb
SN
87 // returns 1, if Block contains Cell,
88 // 0, otherwise
89 {
90 return ( topRow <= row && row <= bottomRow &&
b5808881 91 leftCol <= col && col <= rightCol );
294f6bcb
SN
92 }
93
8b5f6d9d
VZ
94 void SelectBlockNoEvent(int topRow, int leftCol,
95 int bottomRow, int rightCol)
96 {
97 SelectBlock(topRow, leftCol, bottomRow, rightCol,
98 wxKeyboardState(), false);
99 }
100
b5808881
SN
101 wxGridCellCoordsArray m_cellSelection;
102 wxGridCellCoordsArray m_blockSelectionTopLeft;
103 wxGridCellCoordsArray m_blockSelectionBottomRight;
104 wxArrayInt m_rowSelection;
105 wxArrayInt m_colSelection;
294f6bcb 106
b5808881
SN
107 wxGrid *m_grid;
108 wxGrid::wxGridSelectionModes m_selectionMode;
aa5b8857 109
b5dbe15d 110 friend class WXDLLIMPEXP_FWD_ADV wxGrid;
22f3361e 111
c0c133e1 112 wxDECLARE_NO_COPY_CLASS(wxGridSelection);
294f6bcb
SN
113};
114
df9fac6d
PC
115#endif // wxUSE_GRID
116#endif // _WX_GENERIC_GRIDSEL_H_