1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/gridsel.h
3 // Purpose: wxGridSelection
7 // Copyright: (c) Stefan Neis
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GENERIC_GRIDSEL_H_
12 #define _WX_GENERIC_GRIDSEL_H_
20 class WXDLLIMPEXP_ADV wxGridSelection
23 wxGridSelection(wxGrid
*grid
,
24 wxGrid::wxGridSelectionModes sel
= wxGrid::wxGridSelectCells
);
27 bool IsInSelection(int row
, int col
);
28 bool IsInSelection(const wxGridCellCoords
& coords
)
30 return IsInSelection(coords
.GetRow(), coords
.GetCol());
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 )
46 SelectBlock(topLeft
.GetRow(), topLeft
.GetCol(),
47 bottomRight
.GetRow(), bottomRight
.GetCol(),
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)
58 SelectCell(coords
.GetRow(), coords
.GetCol(), kbd
, sendEvent
);
61 void ToggleCellSelection(int row
, int col
,
62 const wxKeyboardState
& kbd
= wxKeyboardState());
63 void ToggleCellSelection(const wxGridCellCoords
& coords
,
64 const wxKeyboardState
& kbd
= wxKeyboardState())
66 ToggleCellSelection(coords
.GetRow(), coords
.GetCol(), kbd
);
69 void ClearSelection();
71 void UpdateRows( size_t pos
, int numRows
);
72 void UpdateCols( size_t pos
, int numCols
);
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,
83 int BlockContainsCell( int topRow
, int leftCol
,
84 int bottomRow
, int rightCol
,
86 // returns 1, if Block contains Cell,
89 return ( topRow
<= row
&& row
<= bottomRow
&&
90 leftCol
<= col
&& col
<= rightCol
);
93 void SelectBlockNoEvent(int topRow
, int leftCol
,
94 int bottomRow
, int rightCol
)
96 SelectBlock(topRow
, leftCol
, bottomRow
, rightCol
,
97 wxKeyboardState(), false);
100 wxGridCellCoordsArray m_cellSelection
;
101 wxGridCellCoordsArray m_blockSelectionTopLeft
;
102 wxGridCellCoordsArray m_blockSelectionBottomRight
;
103 wxArrayInt m_rowSelection
;
104 wxArrayInt m_colSelection
;
107 wxGrid::wxGridSelectionModes m_selectionMode
;
109 friend class WXDLLIMPEXP_FWD_ADV wxGrid
;
111 wxDECLARE_NO_COPY_CLASS(wxGridSelection
);
115 #endif // _WX_GENERIC_GRIDSEL_H_