1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/gridsel.h
3 // Purpose: wxGridSelection
8 // Copyright: (c) Stefan Neis
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GENERIC_GRIDSEL_H_
13 #define _WX_GENERIC_GRIDSEL_H_
21 class WXDLLIMPEXP_ADV wxGridSelection
24 wxGridSelection(wxGrid
*grid
,
25 wxGrid::wxGridSelectionModes sel
= wxGrid::wxGridSelectCells
);
28 bool IsInSelection(int row
, int col
);
29 bool IsInSelection(const wxGridCellCoords
& coords
)
31 return IsInSelection(coords
.GetRow(), coords
.GetCol());
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 )
47 SelectBlock(topLeft
.GetRow(), topLeft
.GetCol(),
48 bottomRight
.GetRow(), bottomRight
.GetCol(),
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)
59 SelectCell(coords
.GetRow(), coords
.GetCol(), kbd
, sendEvent
);
62 void ToggleCellSelection(int row
, int col
,
63 const wxKeyboardState
& kbd
= wxKeyboardState());
64 void ToggleCellSelection(const wxGridCellCoords
& coords
,
65 const wxKeyboardState
& kbd
= wxKeyboardState())
67 ToggleCellSelection(coords
.GetRow(), coords
.GetCol(), kbd
);
70 void ClearSelection();
72 void UpdateRows( size_t pos
, int numRows
);
73 void UpdateCols( size_t pos
, int numCols
);
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,
84 int BlockContainsCell( int topRow
, int leftCol
,
85 int bottomRow
, int rightCol
,
87 // returns 1, if Block contains Cell,
90 return ( topRow
<= row
&& row
<= bottomRow
&&
91 leftCol
<= col
&& col
<= rightCol
);
94 void SelectBlockNoEvent(int topRow
, int leftCol
,
95 int bottomRow
, int rightCol
)
97 SelectBlock(topRow
, leftCol
, bottomRow
, rightCol
,
98 wxKeyboardState(), false);
101 wxGridCellCoordsArray m_cellSelection
;
102 wxGridCellCoordsArray m_blockSelectionTopLeft
;
103 wxGridCellCoordsArray m_blockSelectionBottomRight
;
104 wxArrayInt m_rowSelection
;
105 wxArrayInt m_colSelection
;
108 wxGrid::wxGridSelectionModes m_selectionMode
;
110 friend class WXDLLIMPEXP_FWD_ADV wxGrid
;
112 wxDECLARE_NO_COPY_CLASS(wxGridSelection
);
116 #endif // _WX_GENERIC_GRIDSEL_H_