]>
Commit | Line | Data |
---|---|---|
f85afd4e | 1 | ///////////////////////////////////////////////////////////////////////////// |
43947979 | 2 | // Name: wx/generic/grid.h |
f85afd4e MB |
3 | // Purpose: wxGrid and related classes |
4 | // Author: Michael Bedward (based on code by Julian Smart, Robin Dunn) | |
d4175745 | 5 | // Modified by: Santiago Palacios |
f85afd4e MB |
6 | // Created: 1/08/1999 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Michael Bedward | |
65571936 | 9 | // Licence: wxWindows licence |
f85afd4e MB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
df9fac6d PC |
12 | #ifndef _WX_GENERIC_GRID_H_ |
13 | #define _WX_GENERIC_GRID_H_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_GRID | |
f85afd4e | 18 | |
82edfbe7 VZ |
19 | #include "wx/hashmap.h" |
20 | ||
2d66e025 | 21 | #include "wx/scrolwin.h" |
f85afd4e | 22 | |
816be743 VZ |
23 | // ---------------------------------------------------------------------------- |
24 | // constants | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
23318a53 | 27 | extern WXDLLIMPEXP_DATA_ADV(const char) wxGridNameStr[]; |
61961a3c | 28 | |
f85afd4e MB |
29 | // Default parameters for wxGrid |
30 | // | |
31 | #define WXGRID_DEFAULT_NUMBER_ROWS 10 | |
32 | #define WXGRID_DEFAULT_NUMBER_COLS 10 | |
e6002250 | 33 | #if defined(__WXMSW__) || defined(__WXGTK20__) |
f85afd4e MB |
34 | #define WXGRID_DEFAULT_ROW_HEIGHT 25 |
35 | #else | |
36 | #define WXGRID_DEFAULT_ROW_HEIGHT 30 | |
37 | #endif // __WXMSW__ | |
38 | #define WXGRID_DEFAULT_COL_WIDTH 80 | |
39 | #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 32 | |
40 | #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 82 | |
f1567cdd | 41 | #define WXGRID_LABEL_EDGE_ZONE 2 |
f85afd4e MB |
42 | #define WXGRID_MIN_ROW_HEIGHT 15 |
43 | #define WXGRID_MIN_COL_WIDTH 15 | |
44 | #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 16 | |
f85afd4e | 45 | |
816be743 | 46 | // type names for grid table values |
9a83f860 VZ |
47 | #define wxGRID_VALUE_STRING wxT("string") |
48 | #define wxGRID_VALUE_BOOL wxT("bool") | |
49 | #define wxGRID_VALUE_NUMBER wxT("long") | |
50 | #define wxGRID_VALUE_FLOAT wxT("double") | |
51 | #define wxGRID_VALUE_CHOICE wxT("choice") | |
816be743 VZ |
52 | |
53 | #define wxGRID_VALUE_TEXT wxGRID_VALUE_STRING | |
54 | #define wxGRID_VALUE_LONG wxGRID_VALUE_NUMBER | |
55 | ||
733f486a VZ |
56 | // magic constant which tells (to some functions) to automatically calculate |
57 | // the appropriate size | |
58 | #define wxGRID_AUTOSIZE (-1) | |
59 | ||
60 | // many wxGrid methods work either with columns or rows, this enum is used for | |
61 | // the parameter indicating which one should it be | |
62 | enum wxGridDirection | |
63 | { | |
64 | wxGRID_COLUMN, | |
05cc594a | 65 | wxGRID_ROW |
733f486a VZ |
66 | }; |
67 | ||
b99be8fb VZ |
68 | // ---------------------------------------------------------------------------- |
69 | // forward declarations | |
70 | // ---------------------------------------------------------------------------- | |
71 | ||
b5dbe15d VS |
72 | class WXDLLIMPEXP_FWD_ADV wxGrid; |
73 | class WXDLLIMPEXP_FWD_ADV wxGridCellAttr; | |
74 | class WXDLLIMPEXP_FWD_ADV wxGridCellAttrProviderData; | |
75 | class WXDLLIMPEXP_FWD_ADV wxGridColLabelWindow; | |
76 | class WXDLLIMPEXP_FWD_ADV wxGridCornerLabelWindow; | |
77 | class WXDLLIMPEXP_FWD_ADV wxGridRowLabelWindow; | |
78 | class WXDLLIMPEXP_FWD_ADV wxGridWindow; | |
79 | class WXDLLIMPEXP_FWD_ADV wxGridTypeRegistry; | |
80 | class WXDLLIMPEXP_FWD_ADV wxGridSelection; | |
81 | ||
ad805b9e | 82 | class WXDLLIMPEXP_FWD_CORE wxHeaderCtrl; |
b5dbe15d VS |
83 | class WXDLLIMPEXP_FWD_CORE wxCheckBox; |
84 | class WXDLLIMPEXP_FWD_CORE wxComboBox; | |
85 | class WXDLLIMPEXP_FWD_CORE wxTextCtrl; | |
0e871ad0 | 86 | #if wxUSE_SPINCTRL |
b5dbe15d | 87 | class WXDLLIMPEXP_FWD_CORE wxSpinCtrl; |
0e871ad0 | 88 | #endif |
508011ce | 89 | |
82edfbe7 VZ |
90 | class wxGridFixedIndicesSet; |
91 | ||
bec70262 VZ |
92 | class wxGridOperations; |
93 | class wxGridRowOperations; | |
94 | class wxGridColumnOperations; | |
10a4531d | 95 | class wxGridDirectionOperations; |
bec70262 | 96 | |
29efc6e4 | 97 | |
39bcce60 VZ |
98 | // ---------------------------------------------------------------------------- |
99 | // macros | |
100 | // ---------------------------------------------------------------------------- | |
101 | ||
102 | #define wxSafeIncRef(p) if ( p ) (p)->IncRef() | |
103 | #define wxSafeDecRef(p) if ( p ) (p)->DecRef() | |
104 | ||
ab79958a | 105 | // ---------------------------------------------------------------------------- |
c4608a8a VZ |
106 | // wxGridCellWorker: common base class for wxGridCellRenderer and |
107 | // wxGridCellEditor | |
108 | // | |
109 | // NB: this is more an implementation convenience than a design issue, so this | |
110 | // class is not documented and is not public at all | |
ab79958a VZ |
111 | // ---------------------------------------------------------------------------- |
112 | ||
b42d5f75 | 113 | class WXDLLIMPEXP_ADV wxGridCellWorker : public wxClientDataContainer, public wxRefCounter |
ab79958a VZ |
114 | { |
115 | public: | |
92ffc98a | 116 | wxGridCellWorker() { } |
39bcce60 | 117 | |
c4608a8a VZ |
118 | // interpret renderer parameters: arbitrary string whose interpretatin is |
119 | // left to the derived classes | |
120 | virtual void SetParameters(const wxString& params); | |
121 | ||
122 | protected: | |
123 | // virtual dtor for any base class - private because only DecRef() can | |
124 | // delete us | |
125 | virtual ~wxGridCellWorker(); | |
126 | ||
127 | private: | |
c4608a8a VZ |
128 | // suppress the stupid gcc warning about the class having private dtor and |
129 | // no friends | |
130 | friend class wxGridCellWorkerDummyFriend; | |
131 | }; | |
132 | ||
133 | // ---------------------------------------------------------------------------- | |
134 | // wxGridCellRenderer: this class is responsible for actually drawing the cell | |
135 | // in the grid. You may pass it to the wxGridCellAttr (below) to change the | |
136 | // format of one given cell or to wxGrid::SetDefaultRenderer() to change the | |
137 | // view of all cells. This is an ABC, you will normally use one of the | |
138 | // predefined derived classes or derive your own class from it. | |
139 | // ---------------------------------------------------------------------------- | |
140 | ||
12f190b0 | 141 | class WXDLLIMPEXP_ADV wxGridCellRenderer : public wxGridCellWorker |
c4608a8a VZ |
142 | { |
143 | public: | |
ab79958a VZ |
144 | // draw the given cell on the provided DC inside the given rectangle |
145 | // using the style specified by the attribute and the default or selected | |
146 | // state corresponding to the isSelected value. | |
147 | // | |
148 | // this pure virtual function has a default implementation which will | |
149 | // prepare the DC using the given attribute: it will draw the rectangle | |
150 | // with the bg colour from attr and set the text colour and font | |
151 | virtual void Draw(wxGrid& grid, | |
2796cce3 | 152 | wxGridCellAttr& attr, |
ab79958a VZ |
153 | wxDC& dc, |
154 | const wxRect& rect, | |
155 | int row, int col, | |
156 | bool isSelected) = 0; | |
816be743 | 157 | |
65e4e78e VZ |
158 | // get the preferred size of the cell for its contents |
159 | virtual wxSize GetBestSize(wxGrid& grid, | |
160 | wxGridCellAttr& attr, | |
161 | wxDC& dc, | |
162 | int row, int col) = 0; | |
163 | ||
e72b4213 VZ |
164 | // create a new object which is the copy of this one |
165 | virtual wxGridCellRenderer *Clone() const = 0; | |
ab79958a VZ |
166 | }; |
167 | ||
2796cce3 RD |
168 | // ---------------------------------------------------------------------------- |
169 | // wxGridCellEditor: This class is responsible for providing and manipulating | |
170 | // the in-place edit controls for the grid. Instances of wxGridCellEditor | |
171 | // (actually, instances of derived classes since it is an ABC) can be | |
172 | // associated with the cell attributes for individual cells, rows, columns, or | |
173 | // even for the entire grid. | |
174 | // ---------------------------------------------------------------------------- | |
175 | ||
12f190b0 | 176 | class WXDLLIMPEXP_ADV wxGridCellEditor : public wxGridCellWorker |
2796cce3 RD |
177 | { |
178 | public: | |
179 | wxGridCellEditor(); | |
39bcce60 | 180 | |
2796cce3 | 181 | bool IsCreated() { return m_control != NULL; } |
f6bcfd97 BP |
182 | wxControl* GetControl() { return m_control; } |
183 | void SetControl(wxControl* control) { m_control = control; } | |
2796cce3 | 184 | |
1bd71df9 JS |
185 | wxGridCellAttr* GetCellAttr() { return m_attr; } |
186 | void SetCellAttr(wxGridCellAttr* attr) { m_attr = attr; } | |
187 | ||
2796cce3 RD |
188 | // Creates the actual edit control |
189 | virtual void Create(wxWindow* parent, | |
190 | wxWindowID id, | |
2796cce3 RD |
191 | wxEvtHandler* evtHandler) = 0; |
192 | ||
193 | // Size and position the edit control | |
194 | virtual void SetSize(const wxRect& rect); | |
195 | ||
3da93aae VZ |
196 | // Show or hide the edit control, use the specified attributes to set |
197 | // colours/fonts for it | |
8a3e536c | 198 | virtual void Show(bool show, wxGridCellAttr *attr = NULL); |
2796cce3 | 199 | |
189d0213 VZ |
200 | // Draws the part of the cell not occupied by the control: the base class |
201 | // version just fills it with background colour from the attribute | |
202 | virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr); | |
203 | ||
763163a8 VZ |
204 | |
205 | // The methods called by wxGrid when a cell is edited: first BeginEdit() is | |
206 | // called, then EndEdit() is and if it returns true and if the change is | |
207 | // not vetoed by a user-defined event handler, finally ApplyEdit() is called | |
208 | ||
2796cce3 RD |
209 | // Fetch the value from the table and prepare the edit control |
210 | // to begin editing. Set the focus to the edit control. | |
3da93aae | 211 | virtual void BeginEdit(int row, int col, wxGrid* grid) = 0; |
2796cce3 | 212 | |
763163a8 VZ |
213 | // Returns false if nothing changed, otherwise returns true and return the |
214 | // new value in its string form in the newval output parameter. | |
215 | // | |
216 | // This should also store the new value in its real type internally so that | |
78e78812 VZ |
217 | // it could be used by ApplyEdit() but it must not modify the grid as the |
218 | // change could still be vetoed. | |
219 | virtual bool EndEdit(int row, int col, const wxGrid *grid, | |
220 | const wxString& oldval, wxString *newval) = 0; | |
763163a8 VZ |
221 | |
222 | // Complete the editing of the current cell by storing the value saved by | |
223 | // the previous call to EndEdit() in the grid | |
224 | virtual void ApplyEdit(int row, int col, wxGrid* grid) = 0; | |
225 | ||
2796cce3 RD |
226 | |
227 | // Reset the value in the control back to its starting value | |
228 | virtual void Reset() = 0; | |
229 | ||
ca65c044 | 230 | // return true to allow the given key to start editing: the base class |
f6bcfd97 BP |
231 | // version only checks that the event has no modifiers. The derived |
232 | // classes are supposed to do "if ( base::IsAcceptedKey() && ... )" in | |
233 | // their IsAcceptedKey() implementation, although, of course, it is not a | |
234 | // mandatory requirment. | |
235 | // | |
236 | // NB: if the key is F2 (special), editing will always start and this | |
237 | // method will not be called at all (but StartingKey() will) | |
238 | virtual bool IsAcceptedKey(wxKeyEvent& event); | |
239 | ||
240 | // If the editor is enabled by pressing keys on the grid, this will be | |
241 | // called to let the editor do something about that first key if desired | |
2c9a89e0 RD |
242 | virtual void StartingKey(wxKeyEvent& event); |
243 | ||
e195a54c VZ |
244 | // if the editor is enabled by clicking on the cell, this method will be |
245 | // called | |
246 | virtual void StartingClick(); | |
247 | ||
2796cce3 RD |
248 | // Some types of controls on some platforms may need some help |
249 | // with the Return key. | |
250 | virtual void HandleReturn(wxKeyEvent& event); | |
251 | ||
252 | // Final cleanup | |
253 | virtual void Destroy(); | |
254 | ||
c4608a8a VZ |
255 | // create a new object which is the copy of this one |
256 | virtual wxGridCellEditor *Clone() const = 0; | |
257 | ||
73145b0e JS |
258 | // added GetValue so we can get the value which is in the control |
259 | virtual wxString GetValue() const = 0; | |
260 | ||
2796cce3 | 261 | protected: |
39bcce60 VZ |
262 | // the dtor is private because only DecRef() can delete us |
263 | virtual ~wxGridCellEditor(); | |
264 | ||
3da93aae | 265 | // the control we show on screen |
2796cce3 | 266 | wxControl* m_control; |
3da93aae | 267 | |
1bd71df9 JS |
268 | // a temporary pointer to the attribute being edited |
269 | wxGridCellAttr* m_attr; | |
270 | ||
3da93aae VZ |
271 | // if we change the colours/font of the control from the default ones, we |
272 | // must restore the default later and we save them here between calls to | |
ca65c044 | 273 | // Show(true) and Show(false) |
3da93aae VZ |
274 | wxColour m_colFgOld, |
275 | m_colBgOld; | |
276 | wxFont m_fontOld; | |
39bcce60 VZ |
277 | |
278 | // suppress the stupid gcc warning about the class having private dtor and | |
279 | // no friends | |
280 | friend class wxGridCellEditorDummyFriend; | |
22f3361e | 281 | |
c0c133e1 | 282 | wxDECLARE_NO_COPY_CLASS(wxGridCellEditor); |
2796cce3 RD |
283 | }; |
284 | ||
ba9574c3 VZ |
285 | // ---------------------------------------------------------------------------- |
286 | // wxGridHeaderRenderer and company: like wxGridCellRenderer but for headers | |
287 | // ---------------------------------------------------------------------------- | |
288 | ||
289 | // Base class for corner window renderer: it is the simplest of all renderers | |
290 | // and only has a single function | |
291 | class WXDLLIMPEXP_ADV wxGridCornerHeaderRenderer | |
292 | { | |
293 | public: | |
294 | // Draw the border around the corner window. | |
295 | virtual void DrawBorder(const wxGrid& grid, | |
296 | wxDC& dc, | |
297 | wxRect& rect) const = 0; | |
c9a199c6 VZ |
298 | |
299 | // make the dtor of a class with virtual functions virtual to avoid g++ | |
300 | // warnings, even though this class is not supposed to be used | |
301 | // polymorphically | |
302 | virtual ~wxGridCornerHeaderRenderer() { } | |
ba9574c3 VZ |
303 | }; |
304 | ||
305 | ||
306 | // Base class for the row/column header cells renderers | |
307 | class WXDLLIMPEXP_ADV wxGridHeaderLabelsRenderer | |
308 | : public wxGridCornerHeaderRenderer | |
309 | { | |
310 | public: | |
311 | // Draw header cell label | |
312 | virtual void DrawLabel(const wxGrid& grid, | |
313 | wxDC& dc, | |
314 | const wxString& value, | |
315 | const wxRect& rect, | |
316 | int horizAlign, | |
317 | int vertAlign, | |
318 | int textOrientation) const; | |
319 | }; | |
320 | ||
321 | // Currently the row/column/corner renders don't need any methods other than | |
322 | // those already in wxGridHeaderLabelsRenderer but still define separate classes | |
323 | // for them for future extensions and also for better type safety (i.e. to | |
324 | // avoid inadvertently using a column header renderer for the row headers) | |
325 | class WXDLLIMPEXP_ADV wxGridRowHeaderRenderer | |
326 | : public wxGridHeaderLabelsRenderer | |
327 | { | |
328 | }; | |
329 | ||
330 | class WXDLLIMPEXP_ADV wxGridColumnHeaderRenderer | |
331 | : public wxGridHeaderLabelsRenderer | |
332 | { | |
333 | }; | |
334 | ||
335 | // Also define the default renderers which are used by wxGridCellAttrProvider | |
336 | // by default | |
337 | class WXDLLIMPEXP_ADV wxGridRowHeaderRendererDefault | |
338 | : public wxGridRowHeaderRenderer | |
339 | { | |
340 | public: | |
341 | virtual void DrawBorder(const wxGrid& grid, | |
342 | wxDC& dc, | |
343 | wxRect& rect) const; | |
344 | }; | |
345 | ||
346 | // Column header cells renderers | |
347 | class WXDLLIMPEXP_ADV wxGridColumnHeaderRendererDefault | |
348 | : public wxGridColumnHeaderRenderer | |
349 | { | |
350 | public: | |
351 | virtual void DrawBorder(const wxGrid& grid, | |
352 | wxDC& dc, | |
353 | wxRect& rect) const; | |
354 | }; | |
355 | ||
356 | // Header corner renderer | |
357 | class WXDLLIMPEXP_ADV wxGridCornerHeaderRendererDefault | |
358 | : public wxGridCornerHeaderRenderer | |
359 | { | |
360 | public: | |
361 | virtual void DrawBorder(const wxGrid& grid, | |
362 | wxDC& dc, | |
363 | wxRect& rect) const; | |
364 | }; | |
365 | ||
3379ed37 | 366 | |
b99be8fb VZ |
367 | // ---------------------------------------------------------------------------- |
368 | // wxGridCellAttr: this class can be used to alter the cells appearance in | |
369 | // the grid by changing their colour/font/... from default. An object of this | |
370 | // class may be returned by wxGridTable::GetAttr(). | |
371 | // ---------------------------------------------------------------------------- | |
372 | ||
b42d5f75 | 373 | class WXDLLIMPEXP_ADV wxGridCellAttr : public wxClientDataContainer, public wxRefCounter |
b99be8fb VZ |
374 | { |
375 | public: | |
19d7140e VZ |
376 | enum wxAttrKind |
377 | { | |
378 | Any, | |
379 | Default, | |
380 | Cell, | |
381 | Row, | |
382 | Col, | |
383 | Merged | |
384 | }; | |
385 | ||
b99be8fb | 386 | // ctors |
1df4050d | 387 | wxGridCellAttr(wxGridCellAttr *attrDefault = NULL) |
b99be8fb | 388 | { |
1df4050d VZ |
389 | Init(attrDefault); |
390 | ||
ba0185b5 | 391 | SetAlignment(wxALIGN_INVALID, wxALIGN_INVALID); |
b99be8fb VZ |
392 | } |
393 | ||
283b7808 VZ |
394 | // VZ: considering the number of members wxGridCellAttr has now, this ctor |
395 | // seems to be pretty useless... may be we should just remove it? | |
b99be8fb VZ |
396 | wxGridCellAttr(const wxColour& colText, |
397 | const wxColour& colBack, | |
398 | const wxFont& font, | |
399 | int hAlign, | |
400 | int vAlign) | |
401 | : m_colText(colText), m_colBack(colBack), m_font(font) | |
402 | { | |
2e9a6788 | 403 | Init(); |
b99be8fb VZ |
404 | SetAlignment(hAlign, vAlign); |
405 | } | |
406 | ||
39bcce60 VZ |
407 | // creates a new copy of this object |
408 | wxGridCellAttr *Clone() const; | |
19d7140e | 409 | void MergeWith(wxGridCellAttr *mergefrom); |
b99be8fb VZ |
410 | |
411 | // setters | |
412 | void SetTextColour(const wxColour& colText) { m_colText = colText; } | |
413 | void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; } | |
414 | void SetFont(const wxFont& font) { m_font = font; } | |
415 | void SetAlignment(int hAlign, int vAlign) | |
416 | { | |
417 | m_hAlign = hAlign; | |
418 | m_vAlign = vAlign; | |
419 | } | |
27f35b66 | 420 | void SetSize(int num_rows, int num_cols); |
ca65c044 | 421 | void SetOverflow(bool allow = true) |
ef5df12b | 422 | { m_overflow = allow ? Overflow : SingleCell; } |
ca65c044 | 423 | void SetReadOnly(bool isReadOnly = true) |
19d7140e | 424 | { m_isReadOnly = isReadOnly ? ReadOnly : ReadWrite; } |
b99be8fb | 425 | |
ab79958a VZ |
426 | // takes ownership of the pointer |
427 | void SetRenderer(wxGridCellRenderer *renderer) | |
39bcce60 | 428 | { wxSafeDecRef(m_renderer); m_renderer = renderer; } |
07296f0b | 429 | void SetEditor(wxGridCellEditor* editor) |
39bcce60 | 430 | { wxSafeDecRef(m_editor); m_editor = editor; } |
ab79958a | 431 | |
19d7140e VZ |
432 | void SetKind(wxAttrKind kind) { m_attrkind = kind; } |
433 | ||
b99be8fb | 434 | // accessors |
a1b806b9 DS |
435 | bool HasTextColour() const { return m_colText.IsOk(); } |
436 | bool HasBackgroundColour() const { return m_colBack.IsOk(); } | |
437 | bool HasFont() const { return m_font.IsOk(); } | |
ba0185b5 VZ |
438 | bool HasAlignment() const |
439 | { | |
440 | return m_hAlign != wxALIGN_INVALID || m_vAlign != wxALIGN_INVALID; | |
441 | } | |
2796cce3 | 442 | bool HasRenderer() const { return m_renderer != NULL; } |
07296f0b | 443 | bool HasEditor() const { return m_editor != NULL; } |
19d7140e | 444 | bool HasReadWriteMode() const { return m_isReadOnly != Unset; } |
b63fce94 | 445 | bool HasOverflowMode() const { return m_overflow != UnsetOverflow; } |
3100c3db | 446 | bool HasSize() const { return m_sizeRows != 1 || m_sizeCols != 1; } |
b99be8fb | 447 | |
2796cce3 RD |
448 | const wxColour& GetTextColour() const; |
449 | const wxColour& GetBackgroundColour() const; | |
450 | const wxFont& GetFont() const; | |
451 | void GetAlignment(int *hAlign, int *vAlign) const; | |
cfbc15ee VZ |
452 | |
453 | // unlike GetAlignment() which always overwrites its output arguments with | |
454 | // the alignment values to use, falling back on default alignment if this | |
455 | // attribute doesn't have any, this function will preserve the values of | |
456 | // parameters on entry if the corresponding alignment is not set in this | |
457 | // attribute meaning that they can be initialized to default alignment (and | |
458 | // also that they must be initialized, unlike with GetAlignment()) | |
459 | void GetNonDefaultAlignment(int *hAlign, int *vAlign) const; | |
460 | ||
27f35b66 | 461 | void GetSize(int *num_rows, int *num_cols) const; |
ef5df12b | 462 | bool GetOverflow() const |
b63fce94 | 463 | { return m_overflow != SingleCell; } |
ef316e23 VZ |
464 | wxGridCellRenderer *GetRenderer(const wxGrid* grid, int row, int col) const; |
465 | wxGridCellEditor *GetEditor(const wxGrid* grid, int row, int col) const; | |
b99be8fb | 466 | |
19d7140e VZ |
467 | bool IsReadOnly() const { return m_isReadOnly == wxGridCellAttr::ReadOnly; } |
468 | ||
469 | wxAttrKind GetKind() { return m_attrkind; } | |
283b7808 | 470 | |
2796cce3 | 471 | void SetDefAttr(wxGridCellAttr* defAttr) { m_defGridAttr = defAttr; } |
ab79958a | 472 | |
338d1deb VZ |
473 | protected: |
474 | // the dtor is private because only DecRef() can delete us | |
475 | virtual ~wxGridCellAttr() | |
476 | { | |
477 | wxSafeDecRef(m_renderer); | |
478 | wxSafeDecRef(m_editor); | |
479 | } | |
480 | ||
b99be8fb | 481 | private: |
19d7140e VZ |
482 | enum wxAttrReadMode |
483 | { | |
484 | Unset = -1, | |
485 | ReadWrite, | |
486 | ReadOnly | |
30bc4a8f | 487 | }; |
19d7140e | 488 | |
b63fce94 RD |
489 | enum wxAttrOverflowMode |
490 | { | |
491 | UnsetOverflow = -1, | |
492 | Overflow, | |
493 | SingleCell | |
494 | }; | |
495 | ||
2e9a6788 | 496 | // the common part of all ctors |
1df4050d | 497 | void Init(wxGridCellAttr *attrDefault = NULL); |
2e9a6788 | 498 | |
2e9a6788 | 499 | |
b99be8fb VZ |
500 | wxColour m_colText, |
501 | m_colBack; | |
502 | wxFont m_font; | |
503 | int m_hAlign, | |
504 | m_vAlign; | |
27f35b66 SN |
505 | int m_sizeRows, |
506 | m_sizeCols; | |
ef5df12b RD |
507 | |
508 | wxAttrOverflowMode m_overflow; | |
2e9a6788 | 509 | |
07296f0b RD |
510 | wxGridCellRenderer* m_renderer; |
511 | wxGridCellEditor* m_editor; | |
512 | wxGridCellAttr* m_defGridAttr; | |
ab79958a | 513 | |
19d7140e VZ |
514 | wxAttrReadMode m_isReadOnly; |
515 | ||
516 | wxAttrKind m_attrkind; | |
283b7808 | 517 | |
a68c1246 | 518 | // use Clone() instead |
c0c133e1 | 519 | wxDECLARE_NO_COPY_CLASS(wxGridCellAttr); |
a68c1246 | 520 | |
2e9a6788 VZ |
521 | // suppress the stupid gcc warning about the class having private dtor and |
522 | // no friends | |
523 | friend class wxGridCellAttrDummyFriend; | |
b99be8fb VZ |
524 | }; |
525 | ||
526 | // ---------------------------------------------------------------------------- | |
527 | // wxGridCellAttrProvider: class used by wxGridTableBase to retrieve/store the | |
528 | // cell attributes. | |
529 | // ---------------------------------------------------------------------------- | |
530 | ||
531 | // implementation note: we separate it from wxGridTableBase because we wish to | |
532 | // avoid deriving a new table class if possible, and sometimes it will be | |
533 | // enough to just derive another wxGridCellAttrProvider instead | |
758cbedf VZ |
534 | // |
535 | // the default implementation is reasonably efficient for the generic case, | |
536 | // but you might still wish to implement your own for some specific situations | |
537 | // if you have performance problems with the stock one | |
12f190b0 | 538 | class WXDLLIMPEXP_ADV wxGridCellAttrProvider : public wxClientDataContainer |
b99be8fb VZ |
539 | { |
540 | public: | |
541 | wxGridCellAttrProvider(); | |
542 | virtual ~wxGridCellAttrProvider(); | |
543 | ||
2e9a6788 | 544 | // DecRef() must be called on the returned pointer |
19d7140e VZ |
545 | virtual wxGridCellAttr *GetAttr(int row, int col, |
546 | wxGridCellAttr::wxAttrKind kind ) const; | |
2e9a6788 | 547 | |
758cbedf VZ |
548 | // all these functions take ownership of the pointer, don't call DecRef() |
549 | // on it | |
2e9a6788 | 550 | virtual void SetAttr(wxGridCellAttr *attr, int row, int col); |
758cbedf VZ |
551 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); |
552 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
d1c0b4f9 VZ |
553 | |
554 | // these functions must be called whenever some rows/cols are deleted | |
555 | // because the internal data must be updated then | |
4d60017a SN |
556 | void UpdateAttrRows( size_t pos, int numRows ); |
557 | void UpdateAttrCols( size_t pos, int numCols ); | |
b99be8fb | 558 | |
ba9574c3 VZ |
559 | |
560 | // get renderers for the given row/column header label and the corner | |
561 | // window: unlike cell renderers, these objects are not reference counted | |
562 | // and are never NULL so they are returned by reference | |
670d0177 VZ |
563 | virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col); |
564 | virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row); | |
565 | virtual const wxGridCornerHeaderRenderer& GetCornerRenderer(); | |
ba9574c3 | 566 | |
b99be8fb VZ |
567 | private: |
568 | void InitData(); | |
569 | ||
570 | wxGridCellAttrProviderData *m_data; | |
22f3361e | 571 | |
c0c133e1 | 572 | wxDECLARE_NO_COPY_CLASS(wxGridCellAttrProvider); |
b99be8fb | 573 | }; |
f85afd4e | 574 | |
10a4531d VZ |
575 | // ---------------------------------------------------------------------------- |
576 | // wxGridCellCoords: location of a cell in the grid | |
577 | // ---------------------------------------------------------------------------- | |
578 | ||
579 | class WXDLLIMPEXP_ADV wxGridCellCoords | |
580 | { | |
581 | public: | |
582 | wxGridCellCoords() { m_row = m_col = -1; } | |
583 | wxGridCellCoords( int r, int c ) { m_row = r; m_col = c; } | |
584 | ||
585 | // default copy ctor is ok | |
586 | ||
587 | int GetRow() const { return m_row; } | |
588 | void SetRow( int n ) { m_row = n; } | |
589 | int GetCol() const { return m_col; } | |
590 | void SetCol( int n ) { m_col = n; } | |
591 | void Set( int row, int col ) { m_row = row; m_col = col; } | |
592 | ||
593 | wxGridCellCoords& operator=( const wxGridCellCoords& other ) | |
594 | { | |
595 | if ( &other != this ) | |
596 | { | |
597 | m_row=other.m_row; | |
598 | m_col=other.m_col; | |
599 | } | |
600 | return *this; | |
601 | } | |
602 | ||
603 | bool operator==( const wxGridCellCoords& other ) const | |
604 | { | |
605 | return (m_row == other.m_row && m_col == other.m_col); | |
606 | } | |
607 | ||
608 | bool operator!=( const wxGridCellCoords& other ) const | |
609 | { | |
610 | return (m_row != other.m_row || m_col != other.m_col); | |
611 | } | |
612 | ||
613 | bool operator!() const | |
614 | { | |
615 | return (m_row == -1 && m_col == -1 ); | |
616 | } | |
617 | ||
618 | private: | |
619 | int m_row; | |
620 | int m_col; | |
621 | }; | |
622 | ||
623 | ||
624 | // For comparisons... | |
f85afd4e | 625 | // |
10a4531d VZ |
626 | extern WXDLLIMPEXP_ADV wxGridCellCoords wxGridNoCellCoords; |
627 | extern WXDLLIMPEXP_ADV wxRect wxGridNoCellRect; | |
628 | ||
629 | // An array of cell coords... | |
f85afd4e | 630 | // |
10a4531d VZ |
631 | WX_DECLARE_OBJARRAY_WITH_DECL(wxGridCellCoords, wxGridCellCoordsArray, |
632 | class WXDLLIMPEXP_ADV); | |
f85afd4e | 633 | |
10a4531d VZ |
634 | // ---------------------------------------------------------------------------- |
635 | // Grid table classes | |
636 | // ---------------------------------------------------------------------------- | |
f85afd4e | 637 | |
10a4531d VZ |
638 | // the abstract base class |
639 | class WXDLLIMPEXP_ADV wxGridTableBase : public wxObject, | |
640 | public wxClientDataContainer | |
f85afd4e | 641 | { |
60ff3b99 | 642 | public: |
f85afd4e MB |
643 | wxGridTableBase(); |
644 | virtual ~wxGridTableBase(); | |
645 | ||
646 | // You must override these functions in a derived table class | |
647 | // | |
77d2c45c VZ |
648 | |
649 | // return the number of rows and columns in this table | |
e32352cf SN |
650 | virtual int GetNumberRows() = 0; |
651 | virtual int GetNumberCols() = 0; | |
77d2c45c VZ |
652 | |
653 | // the methods above are unfortunately non-const even though they should | |
654 | // have been const -- but changing it now is not possible any longer as it | |
655 | // would break the existing code overriding them, so instead we provide | |
656 | // these const synonyms which can be used from const-correct code | |
657 | int GetRowsCount() const | |
5c33522f | 658 | { return const_cast<wxGridTableBase *>(this)->GetNumberRows(); } |
77d2c45c | 659 | int GetColsCount() const |
5c33522f | 660 | { return const_cast<wxGridTableBase *>(this)->GetNumberCols(); } |
77d2c45c VZ |
661 | |
662 | ||
8acad210 VZ |
663 | virtual bool IsEmptyCell( int row, int col ) |
664 | { | |
665 | return GetValue(row, col).empty(); | |
666 | } | |
10a4531d VZ |
667 | |
668 | bool IsEmpty(const wxGridCellCoords& coord) | |
669 | { | |
670 | return IsEmptyCell(coord.GetRow(), coord.GetCol()); | |
671 | } | |
672 | ||
f2d76237 RD |
673 | virtual wxString GetValue( int row, int col ) = 0; |
674 | virtual void SetValue( int row, int col, const wxString& value ) = 0; | |
675 | ||
676 | // Data type determination and value access | |
677 | virtual wxString GetTypeName( int row, int col ); | |
678 | virtual bool CanGetValueAs( int row, int col, const wxString& typeName ); | |
679 | virtual bool CanSetValueAs( int row, int col, const wxString& typeName ); | |
680 | ||
681 | virtual long GetValueAsLong( int row, int col ); | |
682 | virtual double GetValueAsDouble( int row, int col ); | |
683 | virtual bool GetValueAsBool( int row, int col ); | |
684 | ||
685 | virtual void SetValueAsLong( int row, int col, long value ); | |
686 | virtual void SetValueAsDouble( int row, int col, double value ); | |
687 | virtual void SetValueAsBool( int row, int col, bool value ); | |
688 | ||
689 | // For user defined types | |
690 | virtual void* GetValueAsCustom( int row, int col, const wxString& typeName ); | |
691 | virtual void SetValueAsCustom( int row, int col, const wxString& typeName, void* value ); | |
692 | ||
60ff3b99 | 693 | |
f85afd4e MB |
694 | // Overriding these is optional |
695 | // | |
696 | virtual void SetView( wxGrid *grid ) { m_view = grid; } | |
697 | virtual wxGrid * GetView() const { return m_view; } | |
698 | ||
699 | virtual void Clear() {} | |
700 | virtual bool InsertRows( size_t pos = 0, size_t numRows = 1 ); | |
701 | virtual bool AppendRows( size_t numRows = 1 ); | |
702 | virtual bool DeleteRows( size_t pos = 0, size_t numRows = 1 ); | |
703 | virtual bool InsertCols( size_t pos = 0, size_t numCols = 1 ); | |
704 | virtual bool AppendCols( size_t numCols = 1 ); | |
705 | virtual bool DeleteCols( size_t pos = 0, size_t numCols = 1 ); | |
706 | ||
707 | virtual wxString GetRowLabelValue( int row ); | |
708 | virtual wxString GetColLabelValue( int col ); | |
af111fc3 JS |
709 | virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {} |
710 | virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {} | |
60ff3b99 | 711 | |
b99be8fb VZ |
712 | // Attribute handling |
713 | // | |
714 | ||
715 | // give us the attr provider to use - we take ownership of the pointer | |
716 | void SetAttrProvider(wxGridCellAttrProvider *attrProvider); | |
717 | ||
718 | // get the currently used attr provider (may be NULL) | |
719 | wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; } | |
720 | ||
f2d76237 RD |
721 | // Does this table allow attributes? Default implementation creates |
722 | // a wxGridCellAttrProvider if necessary. | |
723 | virtual bool CanHaveAttributes(); | |
724 | ||
b99be8fb | 725 | // by default forwarded to wxGridCellAttrProvider if any. May be |
f2d76237 | 726 | // overridden to handle attributes directly in the table. |
19d7140e VZ |
727 | virtual wxGridCellAttr *GetAttr( int row, int col, |
728 | wxGridCellAttr::wxAttrKind kind ); | |
729 | ||
b99be8fb | 730 | |
758cbedf VZ |
731 | // these functions take ownership of the pointer |
732 | virtual void SetAttr(wxGridCellAttr* attr, int row, int col); | |
733 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); | |
734 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
b99be8fb | 735 | |
60ff3b99 VZ |
736 | private: |
737 | wxGrid * m_view; | |
b99be8fb | 738 | wxGridCellAttrProvider *m_attrProvider; |
60ff3b99 | 739 | |
3839f37e | 740 | DECLARE_ABSTRACT_CLASS(wxGridTableBase) |
c0c133e1 | 741 | wxDECLARE_NO_COPY_CLASS(wxGridTableBase); |
f85afd4e MB |
742 | }; |
743 | ||
744 | ||
b99be8fb VZ |
745 | // ---------------------------------------------------------------------------- |
746 | // wxGridTableMessage | |
747 | // ---------------------------------------------------------------------------- | |
f85afd4e MB |
748 | |
749 | // IDs for messages sent from grid table to view | |
750 | // | |
60ff3b99 VZ |
751 | enum wxGridTableRequest |
752 | { | |
f85afd4e MB |
753 | wxGRIDTABLE_REQUEST_VIEW_GET_VALUES = 2000, |
754 | wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES, | |
755 | wxGRIDTABLE_NOTIFY_ROWS_INSERTED, | |
756 | wxGRIDTABLE_NOTIFY_ROWS_APPENDED, | |
757 | wxGRIDTABLE_NOTIFY_ROWS_DELETED, | |
758 | wxGRIDTABLE_NOTIFY_COLS_INSERTED, | |
759 | wxGRIDTABLE_NOTIFY_COLS_APPENDED, | |
760 | wxGRIDTABLE_NOTIFY_COLS_DELETED | |
761 | }; | |
762 | ||
12f190b0 | 763 | class WXDLLIMPEXP_ADV wxGridTableMessage |
f85afd4e | 764 | { |
60ff3b99 | 765 | public: |
f85afd4e MB |
766 | wxGridTableMessage(); |
767 | wxGridTableMessage( wxGridTableBase *table, int id, | |
768 | int comInt1 = -1, | |
769 | int comInt2 = -1 ); | |
770 | ||
771 | void SetTableObject( wxGridTableBase *table ) { m_table = table; } | |
772 | wxGridTableBase * GetTableObject() const { return m_table; } | |
773 | void SetId( int id ) { m_id = id; } | |
774 | int GetId() { return m_id; } | |
775 | void SetCommandInt( int comInt1 ) { m_comInt1 = comInt1; } | |
776 | int GetCommandInt() { return m_comInt1; } | |
777 | void SetCommandInt2( int comInt2 ) { m_comInt2 = comInt2; } | |
60ff3b99 VZ |
778 | int GetCommandInt2() { return m_comInt2; } |
779 | ||
780 | private: | |
781 | wxGridTableBase *m_table; | |
782 | int m_id; | |
783 | int m_comInt1; | |
784 | int m_comInt2; | |
22f3361e | 785 | |
c0c133e1 | 786 | wxDECLARE_NO_COPY_CLASS(wxGridTableMessage); |
f85afd4e MB |
787 | }; |
788 | ||
789 | ||
790 | ||
791 | // ------ wxGridStringArray | |
792 | // A 2-dimensional array of strings for data values | |
793 | // | |
794 | ||
160ba750 VS |
795 | WX_DECLARE_OBJARRAY_WITH_DECL(wxArrayString, wxGridStringArray, |
796 | class WXDLLIMPEXP_ADV); | |
2d66e025 | 797 | |
f85afd4e MB |
798 | |
799 | ||
800 | // ------ wxGridStringTable | |
801 | // | |
802 | // Simplest type of data table for a grid for small tables of strings | |
803 | // that are stored in memory | |
804 | // | |
805 | ||
12f190b0 | 806 | class WXDLLIMPEXP_ADV wxGridStringTable : public wxGridTableBase |
f85afd4e | 807 | { |
60ff3b99 | 808 | public: |
f85afd4e MB |
809 | wxGridStringTable(); |
810 | wxGridStringTable( int numRows, int numCols ); | |
f85afd4e MB |
811 | |
812 | // these are pure virtual in wxGridTableBase | |
813 | // | |
5c3313a9 VZ |
814 | virtual int GetNumberRows() { return m_data.size(); } |
815 | virtual int GetNumberCols() { return m_numCols; } | |
816 | virtual wxString GetValue( int row, int col ); | |
817 | virtual void SetValue( int row, int col, const wxString& s ); | |
60ff3b99 | 818 | |
f85afd4e MB |
819 | // overridden functions from wxGridTableBase |
820 | // | |
821 | void Clear(); | |
822 | bool InsertRows( size_t pos = 0, size_t numRows = 1 ); | |
823 | bool AppendRows( size_t numRows = 1 ); | |
824 | bool DeleteRows( size_t pos = 0, size_t numRows = 1 ); | |
825 | bool InsertCols( size_t pos = 0, size_t numCols = 1 ); | |
826 | bool AppendCols( size_t numCols = 1 ); | |
827 | bool DeleteCols( size_t pos = 0, size_t numCols = 1 ); | |
828 | ||
829 | void SetRowLabelValue( int row, const wxString& ); | |
830 | void SetColLabelValue( int col, const wxString& ); | |
831 | wxString GetRowLabelValue( int row ); | |
832 | wxString GetColLabelValue( int col ); | |
60ff3b99 VZ |
833 | |
834 | private: | |
835 | wxGridStringArray m_data; | |
836 | ||
5c3313a9 VZ |
837 | // notice that while we don't need to store the number of our rows as it's |
838 | // always equal to the size of m_data array, we do need to store the number | |
839 | // of our columns as we can't retrieve it from m_data when the number of | |
840 | // rows is 0 (see #10818) | |
841 | int m_numCols; | |
842 | ||
60ff3b99 VZ |
843 | // These only get used if you set your own labels, otherwise the |
844 | // GetRow/ColLabelValue functions return wxGridTableBase defaults | |
845 | // | |
846 | wxArrayString m_rowLabels; | |
847 | wxArrayString m_colLabels; | |
848 | ||
fc7a2a60 | 849 | DECLARE_DYNAMIC_CLASS_NO_COPY( wxGridStringTable ) |
f85afd4e MB |
850 | }; |
851 | ||
852 | ||
853 | ||
43947979 | 854 | // ============================================================================ |
f85afd4e | 855 | // Grid view classes |
43947979 VZ |
856 | // ============================================================================ |
857 | ||
574e1c5a VZ |
858 | // ---------------------------------------------------------------------------- |
859 | // wxGridSizesInfo stores information about sizes of the rows or columns. | |
860 | // | |
861 | // It assumes that most of the columns or rows have default size and so stores | |
862 | // the default size separately and uses a hash to map column or row numbers to | |
863 | // their non default size for those which don't have the default size. | |
864 | // ---------------------------------------------------------------------------- | |
865 | ||
82edfbe7 | 866 | // hash map to store positions as the keys and sizes as the values |
574e1c5a VZ |
867 | WX_DECLARE_HASH_MAP_WITH_DECL( unsigned, int, wxIntegerHash, wxIntegerEqual, |
868 | wxUnsignedToIntHashMap, class WXDLLIMPEXP_ADV ); | |
869 | ||
870 | struct WXDLLIMPEXP_ADV wxGridSizesInfo | |
871 | { | |
872 | // default ctor, initialize m_sizeDefault and m_customSizes later | |
873 | wxGridSizesInfo() { } | |
874 | ||
875 | // ctor used by wxGrid::Get{Col,Row}Sizes() | |
876 | wxGridSizesInfo(int defSize, const wxArrayInt& allSizes); | |
877 | ||
878 | // default copy ctor, assignment operator and dtor are ok | |
879 | ||
880 | // Get the size of the element with the given index | |
881 | int GetSize(unsigned pos) const; | |
882 | ||
883 | ||
884 | // default size | |
885 | int m_sizeDefault; | |
886 | ||
887 | // position -> size map containing all elements with non-default size | |
888 | wxUnsignedToIntHashMap m_customSizes; | |
889 | }; | |
890 | ||
b99be8fb VZ |
891 | // ---------------------------------------------------------------------------- |
892 | // wxGrid | |
893 | // ---------------------------------------------------------------------------- | |
f85afd4e | 894 | |
12f190b0 | 895 | class WXDLLIMPEXP_ADV wxGrid : public wxScrolledWindow |
60ff3b99 VZ |
896 | { |
897 | public: | |
bf2c8b31 VZ |
898 | // possible selection modes |
899 | enum wxGridSelectionModes | |
900 | { | |
901 | wxGridSelectCells = 0, // allow selecting anything | |
902 | wxGridSelectRows = 1, // allow selecting only entire rows | |
903 | wxGridSelectColumns = 2, // allow selecting only entire columns | |
904 | wxGridSelectRowsOrColumns = wxGridSelectRows | wxGridSelectColumns | |
905 | }; | |
906 | ||
907 | // creation and destruction | |
908 | // ------------------------ | |
909 | ||
910 | // ctor and Create() create the grid window, as with the other controls | |
ad805b9e | 911 | wxGrid() { Init(); } |
986a98c6 | 912 | |
bf2c8b31 | 913 | wxGrid(wxWindow *parent, |
986a98c6 SC |
914 | wxWindowID id, |
915 | const wxPoint& pos = wxDefaultPosition, | |
916 | const wxSize& size = wxDefaultSize, | |
917 | long style = wxWANTS_CHARS, | |
ad805b9e VZ |
918 | const wxString& name = wxGridNameStr) |
919 | { | |
920 | Init(); | |
921 | ||
922 | Create(parent, id, pos, size, style, name); | |
923 | } | |
60ff3b99 | 924 | |
bf2c8b31 VZ |
925 | bool Create(wxWindow *parent, |
926 | wxWindowID id, | |
927 | const wxPoint& pos = wxDefaultPosition, | |
928 | const wxSize& size = wxDefaultSize, | |
929 | long style = wxWANTS_CHARS, | |
930 | const wxString& name = wxGridNameStr); | |
2d66e025 | 931 | |
e669d97a | 932 | virtual ~wxGrid(); |
f85afd4e | 933 | |
bf2c8b31 VZ |
934 | // however to initialize grid data either CreateGrid() or SetTable() must |
935 | // be also called | |
b5808881 | 936 | |
bf2c8b31 VZ |
937 | // this is basically equivalent to |
938 | // | |
939 | // SetTable(new wxGridStringTable(numRows, numCols), true, selmode) | |
940 | // | |
b5808881 | 941 | bool CreateGrid( int numRows, int numCols, |
801a9641 | 942 | wxGridSelectionModes selmode = wxGridSelectCells ); |
2d66e025 | 943 | |
bf2c8b31 VZ |
944 | bool SetTable( wxGridTableBase *table, |
945 | bool takeOwnership = false, | |
946 | wxGridSelectionModes selmode = wxGridSelectCells ); | |
947 | ||
8a3e536c VZ |
948 | bool ProcessTableMessage(wxGridTableMessage&); |
949 | ||
950 | wxGridTableBase *GetTable() const { return m_table; } | |
951 | ||
bf2c8b31 | 952 | |
801a9641 VZ |
953 | void SetSelectionMode(wxGridSelectionModes selmode); |
954 | wxGridSelectionModes GetSelectionMode() const; | |
60ff3b99 | 955 | |
2d66e025 MB |
956 | // ------ grid dimensions |
957 | // | |
ef316e23 VZ |
958 | int GetNumberRows() const { return m_numRows; } |
959 | int GetNumberCols() const { return m_numCols; } | |
2d66e025 | 960 | |
60ff3b99 | 961 | |
2d66e025 MB |
962 | // ------ display update functions |
963 | // | |
ef316e23 | 964 | wxArrayInt CalcRowLabelsExposed( const wxRegion& reg ) const; |
8fb66724 | 965 | |
ef316e23 VZ |
966 | wxArrayInt CalcColLabelsExposed( const wxRegion& reg ) const; |
967 | wxGridCellCoordsArray CalcCellsExposed( const wxRegion& reg ) const; | |
60ff3b99 | 968 | |
2d66e025 | 969 | |
f85afd4e | 970 | void ClearGrid(); |
10a4531d VZ |
971 | bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true) |
972 | { | |
973 | return DoModifyLines(&wxGridTableBase::InsertRows, | |
974 | pos, numRows, updateLabels); | |
975 | } | |
976 | bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true) | |
977 | { | |
978 | return DoModifyLines(&wxGridTableBase::InsertCols, | |
979 | pos, numCols, updateLabels); | |
980 | } | |
981 | ||
982 | bool AppendRows(int numRows = 1, bool updateLabels = true) | |
983 | { | |
984 | return DoAppendLines(&wxGridTableBase::AppendRows, numRows, updateLabels); | |
985 | } | |
986 | bool AppendCols(int numCols = 1, bool updateLabels = true) | |
987 | { | |
988 | return DoAppendLines(&wxGridTableBase::AppendCols, numCols, updateLabels); | |
989 | } | |
990 | ||
991 | bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true) | |
992 | { | |
993 | return DoModifyLines(&wxGridTableBase::DeleteRows, | |
994 | pos, numRows, updateLabels); | |
995 | } | |
996 | bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true) | |
997 | { | |
998 | return DoModifyLines(&wxGridTableBase::DeleteCols, | |
999 | pos, numCols, updateLabels); | |
1000 | } | |
f85afd4e | 1001 | |
d10f4bf9 | 1002 | void DrawGridCellArea( wxDC& dc , const wxGridCellCoordsArray& cells ); |
7c8a8ad5 | 1003 | void DrawGridSpace( wxDC& dc ); |
2d66e025 | 1004 | void DrawCellBorder( wxDC& dc, const wxGridCellCoords& ); |
4634a5d6 | 1005 | void DrawAllGridLines( wxDC& dc, const wxRegion & reg ); |
2d66e025 | 1006 | void DrawCell( wxDC& dc, const wxGridCellCoords& ); |
d10f4bf9 | 1007 | void DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells); |
d16c04bb VZ |
1008 | |
1009 | // this function is called when the current cell highlight must be redrawn | |
1010 | // and may be overridden by the user | |
1011 | virtual void DrawCellHighlight( wxDC& dc, const wxGridCellAttr *attr ); | |
1f1ce288 | 1012 | |
6914b57a JS |
1013 | virtual void DrawRowLabels( wxDC& dc, const wxArrayInt& rows ); |
1014 | virtual void DrawRowLabel( wxDC& dc, int row ); | |
8fb66724 | 1015 | |
6914b57a JS |
1016 | virtual void DrawColLabels( wxDC& dc, const wxArrayInt& cols ); |
1017 | virtual void DrawColLabel( wxDC& dc, int col ); | |
60ff3b99 | 1018 | |
ff72f628 | 1019 | virtual void DrawCornerLabel(wxDC& dc); |
f85afd4e | 1020 | |
2d66e025 | 1021 | // ------ Cell text drawing functions |
f85afd4e | 1022 | // |
2d66e025 | 1023 | void DrawTextRectangle( wxDC& dc, const wxString&, const wxRect&, |
4c7277db | 1024 | int horizontalAlignment = wxALIGN_LEFT, |
d43851f7 | 1025 | int verticalAlignment = wxALIGN_TOP, |
ba9574c3 | 1026 | int textOrientation = wxHORIZONTAL ) const; |
30bc4a8f | 1027 | |
d10f4bf9 VZ |
1028 | void DrawTextRectangle( wxDC& dc, const wxArrayString& lines, const wxRect&, |
1029 | int horizontalAlignment = wxALIGN_LEFT, | |
d43851f7 | 1030 | int verticalAlignment = wxALIGN_TOP, |
ba9574c3 | 1031 | int textOrientation = wxHORIZONTAL ) const; |
d10f4bf9 | 1032 | |
f85afd4e | 1033 | |
ef316e23 | 1034 | // Split a string containing newline characters into an array of |
2d66e025 MB |
1035 | // strings and return the number of lines |
1036 | // | |
ef316e23 | 1037 | void StringToLines( const wxString& value, wxArrayString& lines ) const; |
60ff3b99 | 1038 | |
fbfb8bcc | 1039 | void GetTextBoxSize( const wxDC& dc, |
d10f4bf9 | 1040 | const wxArrayString& lines, |
ef316e23 | 1041 | long *width, long *height ) const; |
60ff3b99 | 1042 | |
2d66e025 | 1043 | |
f85afd4e MB |
1044 | // ------ |
1045 | // Code that does a lot of grid modification can be enclosed | |
1046 | // between BeginBatch() and EndBatch() calls to avoid screen | |
1047 | // flicker | |
1048 | // | |
1049 | void BeginBatch() { m_batchCount++; } | |
f6bcfd97 BP |
1050 | void EndBatch(); |
1051 | ||
f85afd4e MB |
1052 | int GetBatchCount() { return m_batchCount; } |
1053 | ||
8a3e536c | 1054 | virtual void Refresh(bool eraseb = true, const wxRect* rect = NULL); |
27f35b66 | 1055 | |
d8232393 MB |
1056 | // Use this, rather than wxWindow::Refresh(), to force an |
1057 | // immediate repainting of the grid. Has no effect if you are | |
1058 | // already inside a BeginBatch / EndBatch block. | |
1059 | // | |
1060 | // This function is necessary because wxGrid has a minimal OnPaint() | |
1061 | // handler to reduce screen flicker. | |
1062 | // | |
1063 | void ForceRefresh(); | |
d2520c85 | 1064 | |
2d66e025 MB |
1065 | |
1066 | // ------ edit control functions | |
1067 | // | |
84035150 | 1068 | bool IsEditable() const { return m_editable; } |
2d66e025 MB |
1069 | void EnableEditing( bool edit ); |
1070 | ||
ca65c044 WS |
1071 | void EnableCellEditControl( bool enable = true ); |
1072 | void DisableCellEditControl() { EnableCellEditControl(false); } | |
b54ba671 VZ |
1073 | bool CanEnableCellControl() const; |
1074 | bool IsCellEditControlEnabled() const; | |
f6bcfd97 | 1075 | bool IsCellEditControlShown() const; |
2d66e025 | 1076 | |
b54ba671 | 1077 | bool IsCurrentCellReadOnly() const; |
2d66e025 | 1078 | |
2d66e025 MB |
1079 | void ShowCellEditControl(); |
1080 | void HideCellEditControl(); | |
2d66e025 MB |
1081 | void SaveEditControlValue(); |
1082 | ||
60ff3b99 | 1083 | |
2d66e025 | 1084 | // ------ grid location functions |
60ff3b99 | 1085 | // Note that all of these functions work with the logical coordinates of |
2d66e025 MB |
1086 | // grid cells and labels so you will need to convert from device |
1087 | // coordinates for mouse events etc. | |
1088 | // | |
8a3e536c VZ |
1089 | wxGridCellCoords XYToCell(int x, int y) const; |
1090 | void XYToCell(int x, int y, wxGridCellCoords& coords) const | |
1091 | { coords = XYToCell(x, y); } | |
1092 | wxGridCellCoords XYToCell(const wxPoint& pos) const | |
1093 | { return XYToCell(pos.x, pos.y); } | |
1094 | ||
cd4f6f5f VZ |
1095 | // these functions return the index of the row/columns corresponding to the |
1096 | // given logical position in pixels | |
1097 | // | |
1098 | // if clipToMinMax is false (default, wxNOT_FOUND is returned if the | |
1099 | // position is outside any row/column, otherwise the first/last element is | |
1100 | // returned in this case | |
bec70262 | 1101 | int YToRow( int y, bool clipToMinMax = false ) const; |
ef316e23 | 1102 | int XToCol( int x, bool clipToMinMax = false ) const; |
2d66e025 | 1103 | |
ef316e23 VZ |
1104 | int YToEdgeOfRow( int y ) const; |
1105 | int XToEdgeOfCol( int x ) const; | |
2d66e025 | 1106 | |
ef316e23 VZ |
1107 | wxRect CellToRect( int row, int col ) const; |
1108 | wxRect CellToRect( const wxGridCellCoords& coords ) const | |
2d66e025 MB |
1109 | { return CellToRect( coords.GetRow(), coords.GetCol() ); } |
1110 | ||
ef316e23 VZ |
1111 | int GetGridCursorRow() const { return m_currentCellCoords.GetRow(); } |
1112 | int GetGridCursorCol() const { return m_currentCellCoords.GetCol(); } | |
60ff3b99 | 1113 | |
2d66e025 MB |
1114 | // check to see if a cell is either wholly visible (the default arg) or |
1115 | // at least partially visible in the grid window | |
1116 | // | |
ef316e23 VZ |
1117 | bool IsVisible( int row, int col, bool wholeCellVisible = true ) const; |
1118 | bool IsVisible( const wxGridCellCoords& coords, bool wholeCellVisible = true ) const | |
2d66e025 MB |
1119 | { return IsVisible( coords.GetRow(), coords.GetCol(), wholeCellVisible ); } |
1120 | void MakeCellVisible( int row, int col ); | |
1121 | void MakeCellVisible( const wxGridCellCoords& coords ) | |
1122 | { MakeCellVisible( coords.GetRow(), coords.GetCol() ); } | |
1123 | ||
60ff3b99 | 1124 | |
2d66e025 MB |
1125 | // ------ grid cursor movement functions |
1126 | // | |
8a3e536c VZ |
1127 | void SetGridCursor(int row, int col) { SetCurrentCell(row, col); } |
1128 | void SetGridCursor(const wxGridCellCoords& c) { SetCurrentCell(c); } | |
1129 | ||
1130 | void GoToCell(int row, int col) | |
1131 | { | |
1132 | if ( SetCurrentCell(row, col) ) | |
1133 | MakeCellVisible(row, col); | |
1134 | } | |
1135 | ||
1136 | void GoToCell(const wxGridCellCoords& coords) | |
1137 | { | |
1138 | if ( SetCurrentCell(coords) ) | |
1139 | MakeCellVisible(coords); | |
1140 | } | |
dfaf42d2 | 1141 | |
5c8fc7c1 SN |
1142 | bool MoveCursorUp( bool expandSelection ); |
1143 | bool MoveCursorDown( bool expandSelection ); | |
1144 | bool MoveCursorLeft( bool expandSelection ); | |
1145 | bool MoveCursorRight( bool expandSelection ); | |
2d66e025 MB |
1146 | bool MovePageDown(); |
1147 | bool MovePageUp(); | |
5c8fc7c1 SN |
1148 | bool MoveCursorUpBlock( bool expandSelection ); |
1149 | bool MoveCursorDownBlock( bool expandSelection ); | |
1150 | bool MoveCursorLeftBlock( bool expandSelection ); | |
1151 | bool MoveCursorRightBlock( bool expandSelection ); | |
2d66e025 | 1152 | |
60ff3b99 | 1153 | |
f85afd4e MB |
1154 | // ------ label and gridline formatting |
1155 | // | |
ef316e23 VZ |
1156 | int GetDefaultRowLabelSize() const { return WXGRID_DEFAULT_ROW_LABEL_WIDTH; } |
1157 | int GetRowLabelSize() const { return m_rowLabelWidth; } | |
1158 | int GetDefaultColLabelSize() const { return WXGRID_DEFAULT_COL_LABEL_HEIGHT; } | |
1159 | int GetColLabelSize() const { return m_colLabelHeight; } | |
1160 | wxColour GetLabelBackgroundColour() const { return m_labelBackgroundColour; } | |
1161 | wxColour GetLabelTextColour() const { return m_labelTextColour; } | |
1162 | wxFont GetLabelFont() const { return m_labelFont; } | |
1163 | void GetRowLabelAlignment( int *horiz, int *vert ) const; | |
1164 | void GetColLabelAlignment( int *horiz, int *vert ) const; | |
1165 | int GetColLabelTextOrientation() const; | |
1166 | wxString GetRowLabelValue( int row ) const; | |
1167 | wxString GetColLabelValue( int col ) const; | |
3d3f3e37 | 1168 | |
ef316e23 VZ |
1169 | wxColour GetCellHighlightColour() const { return m_cellHighlightColour; } |
1170 | int GetCellHighlightPenWidth() const { return m_cellHighlightPenWidth; } | |
1171 | int GetCellHighlightROPenWidth() const { return m_cellHighlightROPenWidth; } | |
f85afd4e | 1172 | |
ad805b9e VZ |
1173 | // this one will use wxHeaderCtrl for the column labels |
1174 | void UseNativeColHeader(bool native = true); | |
1175 | ||
1176 | // this one will still draw them manually but using the native renderer | |
1177 | // instead of using the same appearance as for the row labels | |
1178 | void SetUseNativeColLabels( bool native = true ); | |
1179 | ||
ab79958a | 1180 | void SetRowLabelSize( int width ); |
f85afd4e | 1181 | void SetColLabelSize( int height ); |
0a9ca9c4 RR |
1182 | void HideRowLabels() { SetRowLabelSize( 0 ); } |
1183 | void HideColLabels() { SetColLabelSize( 0 ); } | |
f85afd4e MB |
1184 | void SetLabelBackgroundColour( const wxColour& ); |
1185 | void SetLabelTextColour( const wxColour& ); | |
1186 | void SetLabelFont( const wxFont& ); | |
1187 | void SetRowLabelAlignment( int horiz, int vert ); | |
1188 | void SetColLabelAlignment( int horiz, int vert ); | |
d43851f7 | 1189 | void SetColLabelTextOrientation( int textOrientation ); |
f85afd4e MB |
1190 | void SetRowLabelValue( int row, const wxString& ); |
1191 | void SetColLabelValue( int col, const wxString& ); | |
f6bcfd97 | 1192 | void SetCellHighlightColour( const wxColour& ); |
d2520c85 RD |
1193 | void SetCellHighlightPenWidth(int width); |
1194 | void SetCellHighlightROPenWidth(int width); | |
28a77bc4 | 1195 | |
82edfbe7 VZ |
1196 | |
1197 | // interactive grid mouse operations control | |
1198 | // ----------------------------------------- | |
1199 | ||
1200 | // functions globally enabling row/column interactive resizing (enabled by | |
1201 | // default) | |
ca65c044 WS |
1202 | void EnableDragRowSize( bool enable = true ); |
1203 | void DisableDragRowSize() { EnableDragRowSize( false ); } | |
82edfbe7 | 1204 | |
ca65c044 WS |
1205 | void EnableDragColSize( bool enable = true ); |
1206 | void DisableDragColSize() { EnableDragColSize( false ); } | |
82edfbe7 VZ |
1207 | |
1208 | // if interactive resizing is enabled, some rows/columns can still have | |
1209 | // fixed size | |
1210 | void DisableRowResize(int row) { DoDisableLineResize(row, m_setFixedRows); } | |
1211 | void DisableColResize(int col) { DoDisableLineResize(col, m_setFixedCols); } | |
1212 | ||
1213 | // these functions return whether the given row/column can be | |
1214 | // effectively resized: for this interactive resizing must be enabled | |
1215 | // and this index must not have been passed to DisableRow/ColResize() | |
1216 | bool CanDragRowSize(int row) const | |
1217 | { return m_canDragRowSize && DoCanResizeLine(row, m_setFixedRows); } | |
1218 | bool CanDragColSize(int col) const | |
1219 | { return m_canDragColSize && DoCanResizeLine(col, m_setFixedCols); } | |
1220 | ||
1221 | // interactive column reordering (disabled by default) | |
d4175745 VZ |
1222 | void EnableDragColMove( bool enable = true ); |
1223 | void DisableDragColMove() { EnableDragColMove( false ); } | |
ef316e23 | 1224 | bool CanDragColMove() const { return m_canDragColMove; } |
82edfbe7 VZ |
1225 | |
1226 | // interactive resizing of grid cells (enabled by default) | |
ca65c044 WS |
1227 | void EnableDragGridSize(bool enable = true); |
1228 | void DisableDragGridSize() { EnableDragGridSize(false); } | |
ef316e23 | 1229 | bool CanDragGridSize() const { return m_canDragGridSize; } |
4cfa5de6 | 1230 | |
82edfbe7 | 1231 | // interactive dragging of cells (disabled by default) |
79dbea21 RD |
1232 | void EnableDragCell( bool enable = true ); |
1233 | void DisableDragCell() { EnableDragCell( false ); } | |
ef316e23 | 1234 | bool CanDragCell() const { return m_canDragCell; } |
79dbea21 | 1235 | |
9f7aee01 VZ |
1236 | |
1237 | // grid lines | |
1238 | // ---------- | |
1239 | ||
1240 | // enable or disable drawing of the lines | |
1241 | void EnableGridLines(bool enable = true); | |
1242 | bool GridLinesEnabled() const { return m_gridLinesEnabled; } | |
1243 | ||
1244 | // by default grid lines stop at last column/row, but this may be changed | |
1245 | void ClipHorzGridLines(bool clip) | |
1246 | { DoClipGridLines(m_gridLinesClipHorz, clip); } | |
1247 | void ClipVertGridLines(bool clip) | |
1248 | { DoClipGridLines(m_gridLinesClipVert, clip); } | |
1249 | bool AreHorzGridLinesClipped() const { return m_gridLinesClipHorz; } | |
1250 | bool AreVertGridLinesClipped() const { return m_gridLinesClipVert; } | |
1251 | ||
1252 | // this can be used to change the global grid lines colour | |
1253 | void SetGridLineColour(const wxColour& col); | |
1254 | wxColour GetGridLineColour() const { return m_gridLineColour; } | |
1255 | ||
1256 | // these methods may be overridden to customize individual grid lines | |
1257 | // appearance | |
1258 | virtual wxPen GetDefaultGridLinePen(); | |
1259 | virtual wxPen GetRowGridLinePen(int row); | |
1260 | virtual wxPen GetColGridLinePen(int col); | |
1261 | ||
1262 | ||
1263 | // attributes | |
1264 | // ---------- | |
1265 | ||
27f35b66 SN |
1266 | // this sets the specified attribute for this cell or in this row/col |
1267 | void SetAttr(int row, int col, wxGridCellAttr *attr); | |
758cbedf VZ |
1268 | void SetRowAttr(int row, wxGridCellAttr *attr); |
1269 | void SetColAttr(int col, wxGridCellAttr *attr); | |
1270 | ||
b99450ee VZ |
1271 | // the grid can cache attributes for the recently used cells (currently it |
1272 | // only caches one attribute for the most recently used one) and might | |
1273 | // notice that its value in the attribute provider has changed -- if this | |
1274 | // happens, call this function to force it | |
1275 | void RefreshAttr(int row, int col); | |
1276 | ||
71e60f70 RD |
1277 | // returns the attribute we may modify in place: a new one if this cell |
1278 | // doesn't have any yet or the existing one if it does | |
1279 | // | |
1280 | // DecRef() must be called on the returned pointer, as usual | |
1281 | wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const; | |
1282 | ||
d94c09cd | 1283 | |
0b190b0f VZ |
1284 | // shortcuts for setting the column parameters |
1285 | ||
1286 | // set the format for the data in the column: default is string | |
1287 | void SetColFormatBool(int col); | |
1288 | void SetColFormatNumber(int col); | |
1289 | void SetColFormatFloat(int col, int width = -1, int precision = -1); | |
1290 | void SetColFormatCustom(int col, const wxString& typeName); | |
1291 | ||
f85afd4e MB |
1292 | // ------ row and col formatting |
1293 | // | |
ef316e23 VZ |
1294 | int GetDefaultRowSize() const; |
1295 | int GetRowSize( int row ) const; | |
fe79f76b | 1296 | bool IsRowShown(int row) const { return GetRowSize(row) != 0; } |
ef316e23 VZ |
1297 | int GetDefaultColSize() const; |
1298 | int GetColSize( int col ) const; | |
fe79f76b | 1299 | bool IsColShown(int col) const { return GetColSize(col) != 0; } |
ef316e23 VZ |
1300 | wxColour GetDefaultCellBackgroundColour() const; |
1301 | wxColour GetCellBackgroundColour( int row, int col ) const; | |
1302 | wxColour GetDefaultCellTextColour() const; | |
1303 | wxColour GetCellTextColour( int row, int col ) const; | |
1304 | wxFont GetDefaultCellFont() const; | |
1305 | wxFont GetCellFont( int row, int col ) const; | |
1306 | void GetDefaultCellAlignment( int *horiz, int *vert ) const; | |
1307 | void GetCellAlignment( int row, int col, int *horiz, int *vert ) const; | |
1308 | bool GetDefaultCellOverflow() const; | |
1309 | bool GetCellOverflow( int row, int col ) const; | |
ea99e8e3 VZ |
1310 | |
1311 | // this function returns 1 in num_rows and num_cols for normal cells, | |
1312 | // positive numbers for a cell spanning multiple columns/rows (as set with | |
1313 | // SetCellSize()) and _negative_ numbers corresponding to the offset of the | |
1314 | // top left cell of the span from this one for the other cells covered by | |
1315 | // this cell | |
1316 | // | |
1317 | // the return value is CellSpan_None, CellSpan_Main or CellSpan_Inside for | |
1318 | // each of these cases respectively | |
1319 | enum CellSpan | |
1320 | { | |
1321 | CellSpan_Inside = -1, | |
1322 | CellSpan_None = 0, | |
1323 | CellSpan_Main | |
1324 | }; | |
1325 | ||
1326 | CellSpan GetCellSize( int row, int col, int *num_rows, int *num_cols ) const; | |
1327 | ||
bec70262 VZ |
1328 | wxSize GetCellSize(const wxGridCellCoords& coords) |
1329 | { | |
1330 | wxSize s; | |
1331 | GetCellSize(coords.GetRow(), coords.GetCol(), &s.x, &s.y); | |
1332 | return s; | |
1333 | } | |
60ff3b99 | 1334 | |
009c7216 | 1335 | // ------ row and col sizes |
ca65c044 | 1336 | void SetDefaultRowSize( int height, bool resizeExistingRows = false ); |
f85afd4e | 1337 | void SetRowSize( int row, int height ); |
009c7216 VZ |
1338 | void HideRow(int row) { SetRowSize(row, 0); } |
1339 | void ShowRow(int row) { SetRowSize(row, -1); } | |
8fb66724 | 1340 | |
009c7216 | 1341 | void SetDefaultColSize( int width, bool resizeExistingCols = false ); |
f85afd4e | 1342 | void SetColSize( int col, int width ); |
009c7216 VZ |
1343 | void HideCol(int col) { SetColSize(col, 0); } |
1344 | void ShowCol(int col) { SetColSize(col, -1); } | |
1345 | ||
574e1c5a VZ |
1346 | // the row and column sizes can be also set all at once using |
1347 | // wxGridSizesInfo which holds all of them at once | |
1348 | ||
1349 | wxGridSizesInfo GetColSizes() const | |
1350 | { return wxGridSizesInfo(GetDefaultColSize(), m_colWidths); } | |
1351 | wxGridSizesInfo GetRowSizes() const | |
1352 | { return wxGridSizesInfo(GetDefaultRowSize(), m_rowHeights); } | |
1353 | ||
1354 | void SetColSizes(const wxGridSizesInfo& sizeInfo); | |
1355 | void SetRowSizes(const wxGridSizesInfo& sizeInfo); | |
1356 | ||
009c7216 VZ |
1357 | |
1358 | // ------- columns (only, for now) reordering | |
43947979 | 1359 | |
cd4f6f5f VZ |
1360 | // columns index <-> positions mapping: by default, the position of the |
1361 | // column is the same as its index, but the columns can also be reordered | |
1362 | // (either by calling SetColPos() explicitly or by the user dragging the | |
1363 | // columns around) in which case their indices don't correspond to their | |
1364 | // positions on display any longer | |
1365 | // | |
1366 | // internally we always work with indices except for the functions which | |
1367 | // have "Pos" in their names (and which work with columns, not pixels) and | |
1368 | // only the display and hit testing code really cares about display | |
1369 | // positions at all | |
1370 | ||
31ec8b4e VZ |
1371 | // set the positions of all columns at once (this method uses the same |
1372 | // conventions as wxHeaderCtrl::SetColumnsOrder() for the order array) | |
1373 | void SetColumnsOrder(const wxArrayInt& order); | |
1374 | ||
cd4f6f5f VZ |
1375 | // return the column index corresponding to the given (valid) position |
1376 | int GetColAt(int pos) const | |
d4175745 | 1377 | { |
cd4f6f5f | 1378 | return m_colAt.empty() ? pos : m_colAt[pos]; |
d4175745 VZ |
1379 | } |
1380 | ||
cd4f6f5f VZ |
1381 | // reorder the columns so that the column with the given index is now shown |
1382 | // as the position pos | |
1383 | void SetColPos(int idx, int pos); | |
d4175745 | 1384 | |
cd4f6f5f VZ |
1385 | // return the position at which the column with the given index is |
1386 | // displayed: notice that this is a slow operation as we don't maintain the | |
1387 | // reverse mapping currently | |
1388 | int GetColPos(int idx) const | |
d4175745 VZ |
1389 | { |
1390 | if ( m_colAt.IsEmpty() ) | |
cd4f6f5f VZ |
1391 | return idx; |
1392 | ||
1393 | for ( int i = 0; i < m_numCols; i++ ) | |
d4175745 | 1394 | { |
cd4f6f5f VZ |
1395 | if ( m_colAt[i] == idx ) |
1396 | return i; | |
d4175745 VZ |
1397 | } |
1398 | ||
cd4f6f5f VZ |
1399 | wxFAIL_MSG( "invalid column index" ); |
1400 | ||
1401 | return wxNOT_FOUND; | |
d4175745 VZ |
1402 | } |
1403 | ||
009c7216 VZ |
1404 | // reset the columns positions to the default order |
1405 | void ResetColPos(); | |
cd4f6f5f VZ |
1406 | |
1407 | ||
af547d51 | 1408 | // automatically size the column or row to fit to its contents, if |
ca65c044 | 1409 | // setAsMin is true, this optimal width will also be set as minimal width |
af547d51 | 1410 | // for this column |
ca65c044 | 1411 | void AutoSizeColumn( int col, bool setAsMin = true ) |
733f486a | 1412 | { AutoSizeColOrRow(col, setAsMin, wxGRID_COLUMN); } |
ca65c044 | 1413 | void AutoSizeRow( int row, bool setAsMin = true ) |
733f486a | 1414 | { AutoSizeColOrRow(row, setAsMin, wxGRID_ROW); } |
65e4e78e VZ |
1415 | |
1416 | // auto size all columns (very ineffective for big grids!) | |
ca65c044 WS |
1417 | void AutoSizeColumns( bool setAsMin = true ) |
1418 | { (void)SetOrCalcColumnSizes(false, setAsMin); } | |
65e4e78e | 1419 | |
ca65c044 WS |
1420 | void AutoSizeRows( bool setAsMin = true ) |
1421 | { (void)SetOrCalcRowSizes(false, setAsMin); } | |
57c086ef VZ |
1422 | |
1423 | // auto size the grid, that is make the columns/rows of the "right" size | |
1424 | // and also set the grid size to just fit its contents | |
1425 | void AutoSize(); | |
1426 | ||
733f486a VZ |
1427 | // Note for both AutoSizeRowLabelSize and AutoSizeColLabelSize: |
1428 | // If col equals to wxGRID_AUTOSIZE value then function autosizes labels column | |
1429 | // instead of data column. Note that this operation may be slow for large | |
1430 | // tables. | |
d43851f7 JS |
1431 | // autosize row height depending on label text |
1432 | void AutoSizeRowLabelSize( int row ); | |
1433 | ||
1434 | // autosize column width depending on label text | |
1435 | void AutoSizeColLabelSize( int col ); | |
1436 | ||
43947979 VZ |
1437 | // column won't be resized to be lesser width - this must be called during |
1438 | // the grid creation because it won't resize the column if it's already | |
1439 | // narrower than the minimal width | |
1440 | void SetColMinimalWidth( int col, int width ); | |
af547d51 | 1441 | void SetRowMinimalHeight( int row, int width ); |
43947979 | 1442 | |
b8d24d4e RG |
1443 | /* These members can be used to query and modify the minimal |
1444 | * acceptable size of grid rows and columns. Call this function in | |
1445 | * your code which creates the grid if you want to display cells | |
1446 | * with a size smaller than the default acceptable minimum size. | |
1447 | * Like the members SetColMinimalWidth and SetRowMinimalWidth, | |
1448 | * the existing rows or columns will not be checked/resized. | |
1449 | */ | |
1450 | void SetColMinimalAcceptableWidth( int width ); | |
1451 | void SetRowMinimalAcceptableHeight( int width ); | |
1452 | int GetColMinimalAcceptableWidth() const; | |
1453 | int GetRowMinimalAcceptableHeight() const; | |
1454 | ||
f85afd4e MB |
1455 | void SetDefaultCellBackgroundColour( const wxColour& ); |
1456 | void SetCellBackgroundColour( int row, int col, const wxColour& ); | |
1457 | void SetDefaultCellTextColour( const wxColour& ); | |
8fb66724 | 1458 | |
f85afd4e | 1459 | void SetCellTextColour( int row, int col, const wxColour& ); |
f85afd4e MB |
1460 | void SetDefaultCellFont( const wxFont& ); |
1461 | void SetCellFont( int row, int col, const wxFont& ); | |
1462 | void SetDefaultCellAlignment( int horiz, int vert ); | |
1463 | void SetCellAlignment( int row, int col, int horiz, int vert ); | |
27f35b66 SN |
1464 | void SetDefaultCellOverflow( bool allow ); |
1465 | void SetCellOverflow( int row, int col, bool allow ); | |
1466 | void SetCellSize( int row, int col, int num_rows, int num_cols ); | |
f85afd4e | 1467 | |
ab79958a | 1468 | // takes ownership of the pointer |
2796cce3 | 1469 | void SetDefaultRenderer(wxGridCellRenderer *renderer); |
ab79958a | 1470 | void SetCellRenderer(int row, int col, wxGridCellRenderer *renderer); |
2796cce3 | 1471 | wxGridCellRenderer *GetDefaultRenderer() const; |
ef316e23 | 1472 | wxGridCellRenderer* GetCellRenderer(int row, int col) const; |
2796cce3 | 1473 | |
283b7808 | 1474 | // takes ownership of the pointer |
0ba143c9 | 1475 | void SetDefaultEditor(wxGridCellEditor *editor); |
9b4aede2 | 1476 | void SetCellEditor(int row, int col, wxGridCellEditor *editor); |
0ba143c9 | 1477 | wxGridCellEditor *GetDefaultEditor() const; |
ef316e23 | 1478 | wxGridCellEditor* GetCellEditor(int row, int col) const; |
9b4aede2 | 1479 | |
60a67569 | 1480 | |
f2d76237 | 1481 | |
f85afd4e MB |
1482 | // ------ cell value accessors |
1483 | // | |
ef316e23 | 1484 | wxString GetCellValue( int row, int col ) const |
f85afd4e MB |
1485 | { |
1486 | if ( m_table ) | |
1487 | { | |
1488 | return m_table->GetValue( row, col ); | |
1489 | } | |
1490 | else | |
1491 | { | |
1492 | return wxEmptyString; | |
1493 | } | |
1494 | } | |
1495 | ||
ef316e23 | 1496 | wxString GetCellValue( const wxGridCellCoords& coords ) const |
f85afd4e | 1497 | { return GetCellValue( coords.GetRow(), coords.GetCol() ); } |
60ff3b99 | 1498 | |
f85afd4e MB |
1499 | void SetCellValue( int row, int col, const wxString& s ); |
1500 | void SetCellValue( const wxGridCellCoords& coords, const wxString& s ) | |
1501 | { SetCellValue( coords.GetRow(), coords.GetCol(), s ); } | |
f85afd4e | 1502 | |
ca65c044 | 1503 | // returns true if the cell can't be edited |
283b7808 | 1504 | bool IsReadOnly(int row, int col) const; |
60ff3b99 | 1505 | |
283b7808 | 1506 | // make the cell editable/readonly |
ca65c044 | 1507 | void SetReadOnly(int row, int col, bool isReadOnly = true); |
f85afd4e | 1508 | |
aa5b8857 | 1509 | // ------ select blocks of cells |
f85afd4e | 1510 | // |
ca65c044 WS |
1511 | void SelectRow( int row, bool addToSelected = false ); |
1512 | void SelectCol( int col, bool addToSelected = false ); | |
60ff3b99 | 1513 | |
c9097836 | 1514 | void SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol, |
ca65c044 | 1515 | bool addToSelected = false ); |
f85afd4e MB |
1516 | |
1517 | void SelectBlock( const wxGridCellCoords& topLeft, | |
c9097836 | 1518 | const wxGridCellCoords& bottomRight, |
ca65c044 | 1519 | bool addToSelected = false ) |
f85afd4e | 1520 | { SelectBlock( topLeft.GetRow(), topLeft.GetCol(), |
c9097836 MB |
1521 | bottomRight.GetRow(), bottomRight.GetCol(), |
1522 | addToSelected ); } | |
f85afd4e MB |
1523 | |
1524 | void SelectAll(); | |
60ff3b99 | 1525 | |
ef316e23 | 1526 | bool IsSelection() const; |
f85afd4e | 1527 | |
aa5b8857 | 1528 | // ------ deselect blocks or cells |
f7b4b343 VZ |
1529 | // |
1530 | void DeselectRow( int row ); | |
1531 | void DeselectCol( int col ); | |
1532 | void DeselectCell( int row, int col ); | |
1533 | ||
f85afd4e MB |
1534 | void ClearSelection(); |
1535 | ||
84035150 | 1536 | bool IsInSelection( int row, int col ) const; |
f85afd4e | 1537 | |
84035150 | 1538 | bool IsInSelection( const wxGridCellCoords& coords ) const |
f85afd4e MB |
1539 | { return IsInSelection( coords.GetRow(), coords.GetCol() ); } |
1540 | ||
aa5b8857 SN |
1541 | wxGridCellCoordsArray GetSelectedCells() const; |
1542 | wxGridCellCoordsArray GetSelectionBlockTopLeft() const; | |
1543 | wxGridCellCoordsArray GetSelectionBlockBottomRight() const; | |
1544 | wxArrayInt GetSelectedRows() const; | |
1545 | wxArrayInt GetSelectedCols() const; | |
c3baf426 SN |
1546 | |
1547 | // This function returns the rectangle that encloses the block of cells | |
1548 | // limited by TopLeft and BottomRight cell in device coords and clipped | |
1549 | // to the client size of the grid window. | |
1550 | // | |
58dd5b3b | 1551 | wxRect BlockToDeviceRect( const wxGridCellCoords & topLeft, |
ef316e23 | 1552 | const wxGridCellCoords & bottomRight ) const; |
c3baf426 | 1553 | |
2796cce3 RD |
1554 | // Access or update the selection fore/back colours |
1555 | wxColour GetSelectionBackground() const | |
1556 | { return m_selectionBackground; } | |
1557 | wxColour GetSelectionForeground() const | |
1558 | { return m_selectionForeground; } | |
1559 | ||
1560 | void SetSelectionBackground(const wxColour& c) { m_selectionBackground = c; } | |
1561 | void SetSelectionForeground(const wxColour& c) { m_selectionForeground = c; } | |
1562 | ||
1563 | ||
f2d76237 RD |
1564 | // Methods for a registry for mapping data types to Renderers/Editors |
1565 | void RegisterDataType(const wxString& typeName, | |
1566 | wxGridCellRenderer* renderer, | |
1567 | wxGridCellEditor* editor); | |
73145b0e JS |
1568 | // DJC MAPTEK |
1569 | virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; | |
99306db2 VZ |
1570 | wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const |
1571 | { return GetDefaultEditorForCell(c.GetRow(), c.GetCol()); } | |
73145b0e JS |
1572 | virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; |
1573 | virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; | |
1574 | virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; | |
f2d76237 | 1575 | |
266e8367 VZ |
1576 | // grid may occupy more space than needed for its rows/columns, this |
1577 | // function allows to set how big this extra space is | |
1578 | void SetMargins(int extraWidth, int extraHeight) | |
1579 | { | |
1580 | m_extraWidth = extraWidth; | |
1581 | m_extraHeight = extraHeight; | |
b8125adf VZ |
1582 | |
1583 | CalcDimensions(); | |
266e8367 | 1584 | } |
f85afd4e | 1585 | |
d2520c85 | 1586 | // Accessors for component windows |
ef316e23 VZ |
1587 | wxWindow* GetGridWindow() const { return (wxWindow*)m_gridWin; } |
1588 | wxWindow* GetGridRowLabelWindow() const { return (wxWindow*)m_rowLabelWin; } | |
ad805b9e | 1589 | wxWindow* GetGridColLabelWindow() const { return m_colWindow; } |
ef316e23 | 1590 | wxWindow* GetGridCornerLabelWindow() const { return (wxWindow*)m_cornerLabelWin; } |
d2520c85 | 1591 | |
3039ade9 VZ |
1592 | // This one can only be called if we are using the native header window |
1593 | wxHeaderCtrl *GetGridColHeader() const | |
1594 | { | |
1595 | wxASSERT_MSG( m_useNativeHeader, "no column header window" ); | |
1596 | ||
1597 | // static_cast<> doesn't work without the full class declaration in | |
1598 | // view and we prefer to avoid adding more compile-time dependencies | |
1599 | // even at the cost of using reinterpret_cast<> | |
1600 | return reinterpret_cast<wxHeaderCtrl *>(m_colWindow); | |
1601 | } | |
1602 | ||
608754c4 | 1603 | // Allow adjustment of scroll increment. The default is (15, 15). |
fd76c6a7 VZ |
1604 | void SetScrollLineX(int x) { m_xScrollPixelsPerLine = x; } |
1605 | void SetScrollLineY(int y) { m_yScrollPixelsPerLine = y; } | |
1606 | int GetScrollLineX() const { return m_xScrollPixelsPerLine; } | |
1607 | int GetScrollLineY() const { return m_yScrollPixelsPerLine; } | |
608754c4 | 1608 | |
1edce33f VZ |
1609 | // ------- drag and drop |
1610 | #if wxUSE_DRAG_AND_DROP | |
1611 | virtual void SetDropTarget(wxDropTarget *dropTarget); | |
1612 | #endif // wxUSE_DRAG_AND_DROP | |
bf646121 | 1613 | |
bf2c8b31 | 1614 | |
11393d29 VZ |
1615 | // ------- sorting support |
1616 | ||
1617 | // wxGrid doesn't support sorting on its own but it can indicate the sort | |
1618 | // order in the column header (currently only if native header control is | |
1619 | // used though) | |
1620 | ||
1621 | // return the column currently displaying the sort indicator or wxNOT_FOUND | |
1622 | // if none | |
1623 | int GetSortingColumn() const { return m_sortCol; } | |
1624 | ||
1625 | // return true if this column is currently used for sorting | |
1626 | bool IsSortingBy(int col) const { return GetSortingColumn() == col; } | |
1627 | ||
1628 | // return the current sorting order (on GetSortingColumn()): true for | |
1629 | // ascending sort and false for descending; it doesn't make sense to call | |
1630 | // it if GetSortingColumn() returns wxNOT_FOUND | |
1631 | bool IsSortOrderAscending() const { return m_sortIsAscending; } | |
1632 | ||
1633 | // set the sorting column (or unsets any existing one if wxNOT_FOUND) and | |
1634 | // the order in which to sort | |
1635 | void SetSortingColumn(int col, bool ascending = true); | |
1636 | ||
1637 | // unset any existing sorting column | |
1638 | void UnsetSortingColumn() { SetSortingColumn(wxNOT_FOUND); } | |
1639 | ||
7bc57fd9 | 1640 | #if WXWIN_COMPATIBILITY_2_8 |
f85afd4e MB |
1641 | // ------ For compatibility with previous wxGrid only... |
1642 | // | |
1643 | // ************************************************ | |
1644 | // ** Don't use these in new code because they ** | |
1645 | // ** are liable to disappear in a future ** | |
1646 | // ** revision ** | |
1647 | // ************************************************ | |
1648 | // | |
1649 | ||
1650 | wxGrid( wxWindow *parent, | |
422d0ff0 | 1651 | int x, int y, int w = wxDefaultCoord, int h = wxDefaultCoord, |
ebd773c6 | 1652 | long style = wxWANTS_CHARS, |
f85afd4e | 1653 | const wxString& name = wxPanelNameStr ) |
ad805b9e VZ |
1654 | { |
1655 | Init(); | |
1656 | Create(parent, wxID_ANY, wxPoint(x, y), wxSize(w, h), style, name); | |
1657 | } | |
f85afd4e MB |
1658 | |
1659 | void SetCellValue( const wxString& val, int row, int col ) | |
1660 | { SetCellValue( row, col, val ); } | |
60ff3b99 | 1661 | |
f85afd4e MB |
1662 | void UpdateDimensions() |
1663 | { CalcDimensions(); } | |
1664 | ||
ef316e23 VZ |
1665 | int GetRows() const { return GetNumberRows(); } |
1666 | int GetCols() const { return GetNumberCols(); } | |
1667 | int GetCursorRow() const { return GetGridCursorRow(); } | |
1668 | int GetCursorColumn() const { return GetGridCursorCol(); } | |
60ff3b99 | 1669 | |
ef316e23 VZ |
1670 | int GetScrollPosX() const { return 0; } |
1671 | int GetScrollPosY() const { return 0; } | |
60ff3b99 | 1672 | |
aa5e1f75 SN |
1673 | void SetScrollX( int WXUNUSED(x) ) { } |
1674 | void SetScrollY( int WXUNUSED(y) ) { } | |
f85afd4e MB |
1675 | |
1676 | void SetColumnWidth( int col, int width ) | |
1677 | { SetColSize( col, width ); } | |
60ff3b99 | 1678 | |
ef316e23 | 1679 | int GetColumnWidth( int col ) const |
f85afd4e | 1680 | { return GetColSize( col ); } |
60ff3b99 | 1681 | |
f85afd4e MB |
1682 | void SetRowHeight( int row, int height ) |
1683 | { SetRowSize( row, height ); } | |
60ff3b99 | 1684 | |
7c1cb261 | 1685 | // GetRowHeight() is below |
60ff3b99 | 1686 | |
ef316e23 | 1687 | int GetViewHeight() const // returned num whole rows visible |
2d66e025 | 1688 | { return 0; } |
60ff3b99 | 1689 | |
ef316e23 | 1690 | int GetViewWidth() const // returned num whole cols visible |
2d66e025 | 1691 | { return 0; } |
f85afd4e MB |
1692 | |
1693 | void SetLabelSize( int orientation, int sz ) | |
1694 | { | |
1695 | if ( orientation == wxHORIZONTAL ) | |
1696 | SetColLabelSize( sz ); | |
1697 | else | |
1698 | SetRowLabelSize( sz ); | |
1699 | } | |
1700 | ||
ef316e23 | 1701 | int GetLabelSize( int orientation ) const |
f85afd4e MB |
1702 | { |
1703 | if ( orientation == wxHORIZONTAL ) | |
1704 | return GetColLabelSize(); | |
1705 | else | |
1706 | return GetRowLabelSize(); | |
1707 | } | |
1708 | ||
1709 | void SetLabelAlignment( int orientation, int align ) | |
1710 | { | |
1711 | if ( orientation == wxHORIZONTAL ) | |
ba0185b5 | 1712 | SetColLabelAlignment( align, wxALIGN_INVALID ); |
f85afd4e | 1713 | else |
ba0185b5 | 1714 | SetRowLabelAlignment( align, wxALIGN_INVALID ); |
f85afd4e MB |
1715 | } |
1716 | ||
ef316e23 | 1717 | int GetLabelAlignment( int orientation, int WXUNUSED(align) ) const |
f85afd4e MB |
1718 | { |
1719 | int h, v; | |
1720 | if ( orientation == wxHORIZONTAL ) | |
1721 | { | |
1722 | GetColLabelAlignment( &h, &v ); | |
1723 | return h; | |
1724 | } | |
1725 | else | |
1726 | { | |
1727 | GetRowLabelAlignment( &h, &v ); | |
1728 | return h; | |
1729 | } | |
1730 | } | |
1731 | ||
1732 | void SetLabelValue( int orientation, const wxString& val, int pos ) | |
1733 | { | |
1734 | if ( orientation == wxHORIZONTAL ) | |
1735 | SetColLabelValue( pos, val ); | |
1736 | else | |
1737 | SetRowLabelValue( pos, val ); | |
1738 | } | |
60ff3b99 | 1739 | |
ef316e23 | 1740 | wxString GetLabelValue( int orientation, int pos) const |
f85afd4e MB |
1741 | { |
1742 | if ( orientation == wxHORIZONTAL ) | |
1743 | return GetColLabelValue( pos ); | |
1744 | else | |
1745 | return GetRowLabelValue( pos ); | |
1746 | } | |
1747 | ||
60ff3b99 | 1748 | wxFont GetCellTextFont() const |
2796cce3 | 1749 | { return m_defaultCellAttr->GetFont(); } |
60ff3b99 | 1750 | |
af111fc3 | 1751 | wxFont GetCellTextFont(int WXUNUSED(row), int WXUNUSED(col)) const |
2796cce3 | 1752 | { return m_defaultCellAttr->GetFont(); } |
60ff3b99 | 1753 | |
f85afd4e MB |
1754 | void SetCellTextFont(const wxFont& fnt) |
1755 | { SetDefaultCellFont( fnt ); } | |
60ff3b99 | 1756 | |
f85afd4e MB |
1757 | void SetCellTextFont(const wxFont& fnt, int row, int col) |
1758 | { SetCellFont( row, col, fnt ); } | |
60ff3b99 | 1759 | |
f85afd4e MB |
1760 | void SetCellTextColour(const wxColour& val, int row, int col) |
1761 | { SetCellTextColour( row, col, val ); } | |
60ff3b99 | 1762 | |
f85afd4e MB |
1763 | void SetCellTextColour(const wxColour& col) |
1764 | { SetDefaultCellTextColour( col ); } | |
60ff3b99 | 1765 | |
f85afd4e MB |
1766 | void SetCellBackgroundColour(const wxColour& col) |
1767 | { SetDefaultCellBackgroundColour( col ); } | |
60ff3b99 | 1768 | |
f85afd4e MB |
1769 | void SetCellBackgroundColour(const wxColour& colour, int row, int col) |
1770 | { SetCellBackgroundColour( row, col, colour ); } | |
60ff3b99 | 1771 | |
ef316e23 | 1772 | bool GetEditable() const { return IsEditable(); } |
ca65c044 | 1773 | void SetEditable( bool edit = true ) { EnableEditing( edit ); } |
ef316e23 | 1774 | bool GetEditInPlace() const { return IsCellEditControlEnabled(); } |
8fb66724 | 1775 | |
ca65c044 | 1776 | void SetEditInPlace(bool WXUNUSED(edit) = true) { } |
f85afd4e | 1777 | |
60a67569 | 1778 | void SetCellAlignment( int align, int row, int col) |
4c7277db | 1779 | { SetCellAlignment(row, col, align, wxALIGN_CENTER); } |
60a67569 JS |
1780 | void SetCellAlignment( int WXUNUSED(align) ) {} |
1781 | void SetCellBitmap(wxBitmap *WXUNUSED(bitmap), int WXUNUSED(row), int WXUNUSED(col)) | |
1782 | { } | |
1783 | void SetDividerPen(const wxPen& WXUNUSED(pen)) { } | |
6fc0f38f | 1784 | wxPen& GetDividerPen() const; |
60a67569 | 1785 | void OnActivate(bool WXUNUSED(active)) {} |
60ff3b99 | 1786 | |
f85afd4e MB |
1787 | // ******** End of compatibility functions ********** |
1788 | ||
2d66e025 MB |
1789 | |
1790 | ||
f85afd4e | 1791 | // ------ control IDs |
2d66e025 | 1792 | enum { wxGRID_CELLCTRL = 2000, |
f85afd4e MB |
1793 | wxGRID_TOPCTRL }; |
1794 | ||
1795 | // ------ control types | |
2d66e025 | 1796 | enum { wxGRID_TEXTCTRL = 2100, |
f85afd4e MB |
1797 | wxGRID_CHECKBOX, |
1798 | wxGRID_CHOICE, | |
1799 | wxGRID_COMBOBOX }; | |
82edfbe7 VZ |
1800 | |
1801 | wxDEPRECATED_INLINE(bool CanDragRowSize() const, return m_canDragRowSize; ) | |
1802 | wxDEPRECATED_INLINE(bool CanDragColSize() const, return m_canDragColSize; ) | |
bf2c8b31 VZ |
1803 | #endif // WXWIN_COMPATIBILITY_2_8 |
1804 | ||
f85afd4e | 1805 | |
bf2c8b31 VZ |
1806 | // override some base class functions |
1807 | virtual bool Enable(bool enable = true); | |
1808 | virtual wxWindow *GetMainWindowOfCompositeControl() | |
1809 | { return (wxWindow*)m_gridWin; } | |
266e8367 VZ |
1810 | virtual void Fit(); |
1811 | ||
86033c4b VZ |
1812 | // implementation only |
1813 | void CancelMouseCapture(); | |
1814 | ||
60ff3b99 | 1815 | protected: |
266e8367 VZ |
1816 | virtual wxSize DoGetBestSize() const; |
1817 | ||
60ff3b99 VZ |
1818 | bool m_created; |
1819 | ||
1820 | wxGridWindow *m_gridWin; | |
60ff3b99 | 1821 | wxGridCornerLabelWindow *m_cornerLabelWin; |
ad805b9e VZ |
1822 | wxGridRowLabelWindow *m_rowLabelWin; |
1823 | ||
1824 | // the real type of the column window depends on m_useNativeHeader value: | |
1825 | // if it is true, its dynamic type is wxHeaderCtrl, otherwise it is | |
1826 | // wxGridColLabelWindow, use accessors below when the real type matters | |
1827 | wxWindow *m_colWindow; | |
1828 | ||
ad805b9e VZ |
1829 | wxGridColLabelWindow *GetColLabelWindow() const |
1830 | { | |
1831 | wxASSERT_MSG( !m_useNativeHeader, "no column label window" ); | |
1832 | ||
1833 | return reinterpret_cast<wxGridColLabelWindow *>(m_colWindow); | |
1834 | } | |
60ff3b99 | 1835 | |
60ff3b99 | 1836 | wxGridTableBase *m_table; |
2796cce3 | 1837 | bool m_ownTable; |
60ff3b99 | 1838 | |
60ff3b99 VZ |
1839 | int m_numRows; |
1840 | int m_numCols; | |
1841 | ||
1842 | wxGridCellCoords m_currentCellCoords; | |
1843 | ||
8a3e536c VZ |
1844 | // the corners of the block being currently selected or wxGridNoCellCoords |
1845 | wxGridCellCoords m_selectedBlockTopLeft; | |
1846 | wxGridCellCoords m_selectedBlockBottomRight; | |
1847 | ||
1848 | // when selecting blocks of cells (either from the keyboard using Shift | |
1849 | // with cursor keys, or by dragging the mouse), the selection is anchored | |
1850 | // at m_currentCellCoords which defines one of the corners of the rectangle | |
1851 | // being selected -- and this variable defines the other corner, i.e. it's | |
1852 | // either m_selectedBlockTopLeft or m_selectedBlockBottomRight depending on | |
1853 | // which of them is not m_currentCellCoords | |
1854 | // | |
1855 | // if no block selection is in process, it is set to wxGridNoCellCoords | |
1856 | wxGridCellCoords m_selectedBlockCorner; | |
1857 | ||
b5808881 | 1858 | wxGridSelection *m_selection; |
8a3e536c | 1859 | |
2796cce3 RD |
1860 | wxColour m_selectionBackground; |
1861 | wxColour m_selectionForeground; | |
60ff3b99 | 1862 | |
7c1cb261 VZ |
1863 | // NB: *never* access m_row/col arrays directly because they are created |
1864 | // on demand, *always* use accessor functions instead! | |
1865 | ||
1866 | // init the m_rowHeights/Bottoms arrays with default values | |
1867 | void InitRowHeights(); | |
1868 | ||
60ff3b99 | 1869 | int m_defaultRowHeight; |
b8d24d4e | 1870 | int m_minAcceptableRowHeight; |
60ff3b99 VZ |
1871 | wxArrayInt m_rowHeights; |
1872 | wxArrayInt m_rowBottoms; | |
1873 | ||
7c1cb261 VZ |
1874 | // init the m_colWidths/Rights arrays |
1875 | void InitColWidths(); | |
1876 | ||
60ff3b99 | 1877 | int m_defaultColWidth; |
b8d24d4e | 1878 | int m_minAcceptableColWidth; |
60ff3b99 VZ |
1879 | wxArrayInt m_colWidths; |
1880 | wxArrayInt m_colRights; | |
bf2c8b31 | 1881 | |
11393d29 VZ |
1882 | int m_sortCol; |
1883 | bool m_sortIsAscending; | |
1884 | ||
ad805b9e VZ |
1885 | bool m_useNativeHeader, |
1886 | m_nativeColumnLabels; | |
7c1cb261 VZ |
1887 | |
1888 | // get the col/row coords | |
1889 | int GetColWidth(int col) const; | |
1890 | int GetColLeft(int col) const; | |
1891 | int GetColRight(int col) const; | |
1892 | ||
1893 | // this function must be public for compatibility... | |
1894 | public: | |
1895 | int GetRowHeight(int row) const; | |
1896 | protected: | |
1897 | ||
1898 | int GetRowTop(int row) const; | |
1899 | int GetRowBottom(int row) const; | |
1900 | ||
60ff3b99 VZ |
1901 | int m_rowLabelWidth; |
1902 | int m_colLabelHeight; | |
1903 | ||
266e8367 VZ |
1904 | // the size of the margin left to the right and bottom of the cell area |
1905 | int m_extraWidth, | |
1906 | m_extraHeight; | |
1907 | ||
60ff3b99 VZ |
1908 | wxColour m_labelBackgroundColour; |
1909 | wxColour m_labelTextColour; | |
1910 | wxFont m_labelFont; | |
1911 | ||
1912 | int m_rowLabelHorizAlign; | |
1913 | int m_rowLabelVertAlign; | |
1914 | int m_colLabelHorizAlign; | |
1915 | int m_colLabelVertAlign; | |
d43851f7 | 1916 | int m_colLabelTextOrientation; |
60ff3b99 VZ |
1917 | |
1918 | bool m_defaultRowLabelValues; | |
1919 | bool m_defaultColLabelValues; | |
1920 | ||
1921 | wxColour m_gridLineColour; | |
1922 | bool m_gridLinesEnabled; | |
9f7aee01 VZ |
1923 | bool m_gridLinesClipHorz, |
1924 | m_gridLinesClipVert; | |
f6bcfd97 | 1925 | wxColour m_cellHighlightColour; |
d2520c85 RD |
1926 | int m_cellHighlightPenWidth; |
1927 | int m_cellHighlightROPenWidth; | |
1928 | ||
60ff3b99 | 1929 | |
266e8367 | 1930 | // common part of AutoSizeColumn/Row() and GetBestSize() |
ca65c044 WS |
1931 | int SetOrCalcColumnSizes(bool calcOnly, bool setAsMin = true); |
1932 | int SetOrCalcRowSizes(bool calcOnly, bool setAsMin = true); | |
266e8367 | 1933 | |
af547d51 | 1934 | // common part of AutoSizeColumn/Row() |
733f486a VZ |
1935 | void AutoSizeColOrRow(int n, bool setAsMin, wxGridDirection direction); |
1936 | ||
1937 | // Calculate the minimum acceptable size for labels area | |
1938 | wxCoord CalcColOrRowLabelAreaMinSize(wxGridDirection direction); | |
af547d51 | 1939 | |
43947979 VZ |
1940 | // if a column has a minimal width, it will be the value for it in this |
1941 | // hash table | |
ba8c1601 MB |
1942 | wxLongToLongHashMap m_colMinWidths, |
1943 | m_rowMinHeights; | |
43947979 | 1944 | |
af547d51 VZ |
1945 | // get the minimal width of the given column/row |
1946 | int GetColMinimalWidth(int col) const; | |
1947 | int GetRowMinimalHeight(int col) const; | |
b99be8fb VZ |
1948 | |
1949 | // do we have some place to store attributes in? | |
ef316e23 | 1950 | bool CanHaveAttributes() const; |
60ff3b99 | 1951 | |
0a976765 VZ |
1952 | // cell attribute cache (currently we only cache 1, may be will do |
1953 | // more/better later) | |
1954 | struct CachedAttr | |
1955 | { | |
1956 | int row, col; | |
1957 | wxGridCellAttr *attr; | |
1958 | } m_attrCache; | |
1959 | ||
1960 | // invalidates the attribute cache | |
1961 | void ClearAttrCache(); | |
1962 | ||
1963 | // adds an attribute to cache | |
1964 | void CacheAttr(int row, int col, wxGridCellAttr *attr) const; | |
1965 | ||
ca65c044 | 1966 | // looks for an attr in cache, returns true if found |
0a976765 VZ |
1967 | bool LookupAttr(int row, int col, wxGridCellAttr **attr) const; |
1968 | ||
1969 | // looks for the attr in cache, if not found asks the table and caches the | |
1970 | // result | |
2e9a6788 | 1971 | wxGridCellAttr *GetCellAttr(int row, int col) const; |
ef316e23 | 1972 | wxGridCellAttr *GetCellAttr(const wxGridCellCoords& coords ) const |
2c9a89e0 | 1973 | { return GetCellAttr( coords.GetRow(), coords.GetCol() ); } |
2e9a6788 | 1974 | |
2796cce3 RD |
1975 | // the default cell attr object for cells that don't have their own |
1976 | wxGridCellAttr* m_defaultCellAttr; | |
1977 | ||
1978 | ||
60ff3b99 VZ |
1979 | bool m_inOnKeyDown; |
1980 | int m_batchCount; | |
1981 | ||
f2d76237 RD |
1982 | |
1983 | wxGridTypeRegistry* m_typeRegistry; | |
1984 | ||
e2b42eeb VZ |
1985 | enum CursorMode |
1986 | { | |
1987 | WXGRID_CURSOR_SELECT_CELL, | |
1988 | WXGRID_CURSOR_RESIZE_ROW, | |
1989 | WXGRID_CURSOR_RESIZE_COL, | |
1990 | WXGRID_CURSOR_SELECT_ROW, | |
d4175745 VZ |
1991 | WXGRID_CURSOR_SELECT_COL, |
1992 | WXGRID_CURSOR_MOVE_COL | |
60ff3b99 VZ |
1993 | }; |
1994 | ||
e2b42eeb | 1995 | // this method not only sets m_cursorMode but also sets the correct cursor |
ca65c044 | 1996 | // for the given mode and, if captureMouse is not false releases the mouse |
e2b42eeb VZ |
1997 | // if it was captured and captures it if it must be captured |
1998 | // | |
1999 | // for this to work, you should always use it and not set m_cursorMode | |
2000 | // directly! | |
2001 | void ChangeCursorMode(CursorMode mode, | |
8a3e536c | 2002 | wxWindow *win = NULL, |
ca65c044 | 2003 | bool captureMouse = true); |
e2b42eeb VZ |
2004 | |
2005 | wxWindow *m_winCapture; // the window which captured the mouse | |
8a3e536c VZ |
2006 | |
2007 | // this variable is used not for finding the correct current cursor but | |
2008 | // mainly for finding out what is going to happen if the mouse starts being | |
2009 | // dragged right now | |
2010 | // | |
2011 | // by default it is WXGRID_CURSOR_SELECT_CELL meaning that nothing else is | |
2012 | // going on, and it is set to one of RESIZE/SELECT/MOVE values while the | |
2013 | // corresponding operation will be started if the user starts dragging the | |
2014 | // mouse from the current position | |
e2b42eeb VZ |
2015 | CursorMode m_cursorMode; |
2016 | ||
8a3e536c | 2017 | |
d4175745 VZ |
2018 | //Column positions |
2019 | wxArrayInt m_colAt; | |
d4175745 | 2020 | |
6e8524b1 MB |
2021 | bool m_canDragRowSize; |
2022 | bool m_canDragColSize; | |
d4175745 | 2023 | bool m_canDragColMove; |
4cfa5de6 | 2024 | bool m_canDragGridSize; |
79dbea21 | 2025 | bool m_canDragCell; |
bec70262 VZ |
2026 | |
2027 | // the last position (horizontal or vertical depending on whether the user | |
2028 | // is resizing a column or a row) where a row or column separator line was | |
2029 | // dragged by the user or -1 of there is no drag operation in progress | |
07296f0b RD |
2030 | int m_dragLastPos; |
2031 | int m_dragRowOrCol; | |
bec70262 | 2032 | |
8a3e536c VZ |
2033 | // true if a drag operation is in progress; when this is true, |
2034 | // m_startDragPos is valid, i.e. not wxDefaultPosition | |
07296f0b | 2035 | bool m_isDragging; |
8a3e536c VZ |
2036 | |
2037 | // the position (in physical coordinates) where the user started dragging | |
2038 | // the mouse or wxDefaultPosition if mouse isn't being dragged | |
2039 | // | |
2040 | // notice that this can be != wxDefaultPosition while m_isDragging is still | |
2041 | // false because we wait until the mouse is moved some distance away before | |
2042 | // setting m_isDragging to true | |
07296f0b | 2043 | wxPoint m_startDragPos; |
60ff3b99 | 2044 | |
75ecbe45 | 2045 | bool m_waitForSlowClick; |
025562fe | 2046 | |
60ff3b99 VZ |
2047 | wxGridCellCoords m_selectionStart; |
2048 | ||
2049 | wxCursor m_rowResizeCursor; | |
2050 | wxCursor m_colResizeCursor; | |
2051 | ||
b54ba671 VZ |
2052 | bool m_editable; // applies to whole grid |
2053 | bool m_cellEditCtrlEnabled; // is in-place edit currently shown? | |
60ff3b99 | 2054 | |
ad805b9e | 2055 | void Init(); // common part of all ctors |
60ff3b99 | 2056 | void Create(); |
ad805b9e | 2057 | void CreateColumnWindow(); |
60ff3b99 | 2058 | void CalcDimensions(); |
7807d81c | 2059 | void CalcWindowSizes(); |
60ff3b99 VZ |
2060 | bool Redimension( wxGridTableMessage& ); |
2061 | ||
2062 | ||
8a3e536c VZ |
2063 | // generate the appropriate grid event and return -1 if it was vetoed, 1 if |
2064 | // it was processed (but not vetoed) and 0 if it wasn't processed | |
2065 | int SendEvent(const wxEventType evtType, | |
2066 | int row, int col, | |
27bb2c8c | 2067 | const wxMouseEvent& e); |
8a3e536c VZ |
2068 | int SendEvent(const wxEventType evtType, |
2069 | const wxGridCellCoords& coords, | |
27bb2c8c | 2070 | const wxMouseEvent& e) |
8a3e536c | 2071 | { return SendEvent(evtType, coords.GetRow(), coords.GetCol(), e); } |
763163a8 VZ |
2072 | int SendEvent(const wxEventType evtType, |
2073 | int row, int col, | |
2074 | const wxString& s = wxString()); | |
2075 | int SendEvent(const wxEventType evtType, | |
2076 | const wxGridCellCoords& coords, | |
2077 | const wxString& s = wxString()) | |
2078 | { return SendEvent(evtType, coords.GetRow(), coords.GetCol(), s); } | |
2079 | int SendEvent(const wxEventType evtType, const wxString& s = wxString()) | |
2080 | { return SendEvent(evtType, m_currentCellCoords, s); } | |
60ff3b99 | 2081 | |
27bb2c8c | 2082 | // send wxEVT_GRID_{ROW,COL}_SIZE |
c5c1ea96 VZ |
2083 | void SendGridSizeEvent(wxEventType type, |
2084 | int row, int col, | |
2085 | const wxMouseEvent& mouseEv); | |
27bb2c8c | 2086 | |
60ff3b99 VZ |
2087 | void OnPaint( wxPaintEvent& ); |
2088 | void OnSize( wxSizeEvent& ); | |
2089 | void OnKeyDown( wxKeyEvent& ); | |
f6bcfd97 | 2090 | void OnKeyUp( wxKeyEvent& ); |
63e2147c | 2091 | void OnChar( wxKeyEvent& ); |
2796cce3 | 2092 | void OnEraseBackground( wxEraseEvent& ); |
60ff3b99 VZ |
2093 | |
2094 | ||
8a3e536c VZ |
2095 | bool SetCurrentCell( const wxGridCellCoords& coords ); |
2096 | bool SetCurrentCell( int row, int col ) | |
2097 | { return SetCurrentCell( wxGridCellCoords(row, col) ); } | |
2098 | ||
60ff3b99 | 2099 | |
8a3e536c VZ |
2100 | // this function is called to extend the block being currently selected |
2101 | // from mouse and keyboard event handlers | |
2102 | void UpdateBlockBeingSelected(int topRow, int leftCol, | |
2103 | int bottomRow, int rightCol); | |
c9097836 | 2104 | |
8a3e536c VZ |
2105 | void UpdateBlockBeingSelected(const wxGridCellCoords& topLeft, |
2106 | const wxGridCellCoords& bottomRight) | |
2107 | { UpdateBlockBeingSelected(topLeft.GetRow(), topLeft.GetCol(), | |
2108 | bottomRight.GetRow(), bottomRight.GetCol()); } | |
60ff3b99 VZ |
2109 | |
2110 | // ------ functions to get/send data (see also public functions) | |
2111 | // | |
2112 | bool GetModelValues(); | |
2113 | bool SetModelValues(); | |
2114 | ||
b5dbe15d | 2115 | friend class WXDLLIMPEXP_FWD_ADV wxGridSelection; |
bec70262 VZ |
2116 | friend class wxGridRowOperations; |
2117 | friend class wxGridColumnOperations; | |
60ff3b99 | 2118 | |
8a3e536c VZ |
2119 | // they call our private Process{{Corner,Col,Row}Label,GridCell}MouseEvent() |
2120 | friend class wxGridCornerLabelWindow; | |
2121 | friend class wxGridColLabelWindow; | |
2122 | friend class wxGridRowLabelWindow; | |
2123 | friend class wxGridWindow; | |
ba9574c3 | 2124 | friend class wxGridHeaderRenderer; |
8a3e536c | 2125 | |
ad805b9e VZ |
2126 | friend class wxGridHeaderCtrl; |
2127 | ||
69367c56 | 2128 | private: |
ba9574c3 | 2129 | |
69367c56 VZ |
2130 | // implement wxScrolledWindow method to return m_gridWin size |
2131 | virtual wxSize GetSizeAvailableForScrollTarget(const wxSize& size); | |
2132 | ||
9f7aee01 VZ |
2133 | // redraw the grid lines, should be called after changing their attributes |
2134 | void RedrawGridLines(); | |
2135 | ||
2136 | // common part of Clip{Horz,Vert}GridLines | |
2137 | void DoClipGridLines(bool& var, bool clip); | |
2138 | ||
11393d29 VZ |
2139 | // update the sorting indicator shown in the specified column (whose index |
2140 | // must be valid) | |
2141 | // | |
2142 | // this will use GetSortingColumn() and IsSortOrderAscending() to determine | |
2143 | // the sorting indicator to effectively show | |
2144 | void UpdateColumnSortingIndicator(int col); | |
2145 | ||
4797b014 VZ |
2146 | // update the grid after changing the columns order (common part of |
2147 | // SetColPos() and ResetColPos()) | |
2148 | void RefreshAfterColPosChange(); | |
009c7216 | 2149 | |
9f7aee01 | 2150 | |
cd4f6f5f VZ |
2151 | // return the position (not index) of the column at the given logical pixel |
2152 | // position | |
2153 | // | |
2154 | // this always returns a valid position, even if the coordinate is out of | |
2155 | // bounds (in which case first/last column is returned) | |
2156 | int XToPos(int x) const; | |
2157 | ||
2158 | ||
8a3e536c VZ |
2159 | // event handlers and their helpers |
2160 | // -------------------------------- | |
2161 | ||
2162 | // process mouse drag event in WXGRID_CURSOR_SELECT_CELL mode | |
2163 | void DoGridCellDrag(wxMouseEvent& event, | |
2164 | const wxGridCellCoords& coords, | |
2165 | bool isFirstDrag); | |
2166 | ||
2167 | // process row/column resizing drag event | |
2168 | void DoGridLineDrag(wxMouseEvent& event, const wxGridOperations& oper); | |
2169 | ||
2170 | // process mouse drag event in the grid window | |
2171 | void DoGridDragEvent(wxMouseEvent& event, const wxGridCellCoords& coords); | |
2172 | ||
2173 | // process different clicks on grid cells | |
2174 | void DoGridCellLeftDown(wxMouseEvent& event, | |
2175 | const wxGridCellCoords& coords, | |
2176 | const wxPoint& pos); | |
2177 | void DoGridCellLeftDClick(wxMouseEvent& event, | |
2178 | const wxGridCellCoords& coords, | |
2179 | const wxPoint& pos); | |
2180 | void DoGridCellLeftUp(wxMouseEvent& event, const wxGridCellCoords& coords); | |
2181 | ||
2182 | // process movement (but not dragging) event in the grid cell area | |
2183 | void DoGridMouseMoveEvent(wxMouseEvent& event, | |
2184 | const wxGridCellCoords& coords, | |
2185 | const wxPoint& pos); | |
2186 | ||
2187 | // process mouse events in the grid window | |
2188 | void ProcessGridCellMouseEvent(wxMouseEvent& event); | |
2189 | ||
2190 | // process mouse events in the row/column labels/corner windows | |
2191 | void ProcessRowLabelMouseEvent(wxMouseEvent& event); | |
2192 | void ProcessColLabelMouseEvent(wxMouseEvent& event); | |
2193 | void ProcessCornerLabelMouseEvent(wxMouseEvent& event); | |
2194 | ||
11393d29 VZ |
2195 | void DoColHeaderClick(int col); |
2196 | ||
ad805b9e VZ |
2197 | void DoStartResizeCol(int col); |
2198 | void DoUpdateResizeCol(int x); | |
2199 | void DoUpdateResizeColWidth(int w); | |
cd68daf5 | 2200 | void DoStartMoveCol(int col); |
ad805b9e | 2201 | |
27bb2c8c VZ |
2202 | void DoEndDragResizeRow(const wxMouseEvent& event); |
2203 | void DoEndDragResizeCol(const wxMouseEvent& event); | |
cd68daf5 | 2204 | void DoEndMoveCol(int pos); |
8a3e536c | 2205 | |
bec70262 VZ |
2206 | |
2207 | // common implementations of methods defined for both rows and columns | |
2208 | void DeselectLine(int line, const wxGridOperations& oper); | |
27bb2c8c | 2209 | bool DoEndDragResizeLine(const wxGridOperations& oper); |
cd4f6f5f VZ |
2210 | int PosToLinePos(int pos, bool clipToMinMax, |
2211 | const wxGridOperations& oper) const; | |
2212 | int PosToLine(int pos, bool clipToMinMax, | |
2213 | const wxGridOperations& oper) const; | |
10a4531d VZ |
2214 | int PosToEdgeOfLine(int pos, const wxGridOperations& oper) const; |
2215 | ||
2216 | bool DoMoveCursor(bool expandSelection, | |
2217 | const wxGridDirectionOperations& diroper); | |
2218 | bool DoMoveCursorByPage(const wxGridDirectionOperations& diroper); | |
2219 | bool DoMoveCursorByBlock(bool expandSelection, | |
2220 | const wxGridDirectionOperations& diroper); | |
2221 | void AdvanceToNextNonEmpty(wxGridCellCoords& coords, | |
2222 | const wxGridDirectionOperations& diroper); | |
2223 | ||
2224 | // common part of {Insert,Delete}{Rows,Cols} | |
2225 | bool DoModifyLines(bool (wxGridTableBase::*funcModify)(size_t, size_t), | |
2226 | int pos, int num, bool updateLabels); | |
2227 | // Append{Rows,Cols} is a bit different because of one less parameter | |
2228 | bool DoAppendLines(bool (wxGridTableBase::*funcAppend)(size_t), | |
2229 | int num, bool updateLabels); | |
bec70262 | 2230 | |
82edfbe7 | 2231 | // common part of Set{Col,Row}Sizes |
574e1c5a VZ |
2232 | void DoSetSizes(const wxGridSizesInfo& sizeInfo, |
2233 | const wxGridOperations& oper); | |
2234 | ||
82edfbe7 VZ |
2235 | // common part of Disable{Row,Col}Resize and CanDrag{Row,Col}Size |
2236 | void DoDisableLineResize(int line, wxGridFixedIndicesSet *& setFixed); | |
2237 | bool DoCanResizeLine(int line, const wxGridFixedIndicesSet *setFixed) const; | |
2238 | ||
2239 | ||
2240 | ||
2241 | // these sets contain the indices of fixed, i.e. non-resizable | |
2242 | // interactively, grid rows or columns and are NULL if there are no fixed | |
2243 | // elements (which is the default) | |
2244 | wxGridFixedIndicesSet *m_setFixedRows, | |
2245 | *m_setFixedCols; | |
2246 | ||
2d66e025 | 2247 | DECLARE_DYNAMIC_CLASS( wxGrid ) |
f85afd4e | 2248 | DECLARE_EVENT_TABLE() |
c0c133e1 | 2249 | wxDECLARE_NO_COPY_CLASS(wxGrid); |
f85afd4e MB |
2250 | }; |
2251 | ||
b62f94ff VZ |
2252 | // ---------------------------------------------------------------------------- |
2253 | // wxGridUpdateLocker prevents updates to a grid during its lifetime | |
2254 | // ---------------------------------------------------------------------------- | |
2255 | ||
2256 | class WXDLLIMPEXP_ADV wxGridUpdateLocker | |
2257 | { | |
2258 | public: | |
2259 | // if the pointer is NULL, Create() can be called later | |
2260 | wxGridUpdateLocker(wxGrid *grid = NULL) | |
2261 | { | |
2262 | Init(grid); | |
2263 | } | |
2264 | ||
2265 | // can be called if ctor was used with a NULL pointer, must not be called | |
2266 | // more than once | |
2267 | void Create(wxGrid *grid) | |
2268 | { | |
9a83f860 | 2269 | wxASSERT_MSG( !m_grid, wxT("shouldn't be called more than once") ); |
b62f94ff VZ |
2270 | |
2271 | Init(grid); | |
2272 | } | |
2273 | ||
2274 | ~wxGridUpdateLocker() | |
2275 | { | |
2276 | if ( m_grid ) | |
2277 | m_grid->EndBatch(); | |
2278 | } | |
2279 | ||
2280 | private: | |
2281 | void Init(wxGrid *grid) | |
2282 | { | |
2283 | m_grid = grid; | |
2284 | if ( m_grid ) | |
2285 | m_grid->BeginBatch(); | |
2286 | } | |
2287 | ||
2288 | wxGrid *m_grid; | |
2289 | ||
c0c133e1 | 2290 | wxDECLARE_NO_COPY_CLASS(wxGridUpdateLocker); |
b62f94ff VZ |
2291 | }; |
2292 | ||
43947979 VZ |
2293 | // ---------------------------------------------------------------------------- |
2294 | // Grid event class and event types | |
2295 | // ---------------------------------------------------------------------------- | |
f85afd4e | 2296 | |
8b5f6d9d VZ |
2297 | class WXDLLIMPEXP_ADV wxGridEvent : public wxNotifyEvent, |
2298 | public wxKeyboardState | |
f85afd4e | 2299 | { |
60ff3b99 | 2300 | public: |
f85afd4e | 2301 | wxGridEvent() |
8b5f6d9d VZ |
2302 | : wxNotifyEvent() |
2303 | { | |
2304 | Init(-1, -1, -1, -1, false); | |
2305 | } | |
f85afd4e | 2306 | |
8b5f6d9d VZ |
2307 | wxGridEvent(int id, |
2308 | wxEventType type, | |
2309 | wxObject* obj, | |
2310 | int row = -1, int col = -1, | |
2311 | int x = -1, int y = -1, | |
2312 | bool sel = true, | |
2313 | const wxKeyboardState& kbd = wxKeyboardState()) | |
2314 | : wxNotifyEvent(type, id), | |
2315 | wxKeyboardState(kbd) | |
2316 | { | |
2317 | Init(row, col, x, y, sel); | |
2318 | SetEventObject(obj); | |
2319 | } | |
2320 | ||
23318a53 FM |
2321 | // explicitly specifying inline allows gcc < 3.4 to |
2322 | // handle the deprecation attribute even in the constructor. | |
a05e6efe | 2323 | wxDEPRECATED_CONSTRUCTOR( |
8b5f6d9d VZ |
2324 | wxGridEvent(int id, |
2325 | wxEventType type, | |
2326 | wxObject* obj, | |
2327 | int row, int col, | |
2328 | int x, int y, | |
2329 | bool sel, | |
2330 | bool control, | |
2331 | bool shift = false, bool alt = false, bool meta = false)); | |
f85afd4e MB |
2332 | |
2333 | virtual int GetRow() { return m_row; } | |
2334 | virtual int GetCol() { return m_col; } | |
2335 | wxPoint GetPosition() { return wxPoint( m_x, m_y ); } | |
5c8fc7c1 | 2336 | bool Selecting() { return m_selecting; } |
2d66e025 | 2337 | |
e1f8ec29 RD |
2338 | virtual wxEvent *Clone() const { return new wxGridEvent(*this); } |
2339 | ||
60ff3b99 VZ |
2340 | protected: |
2341 | int m_row; | |
2342 | int m_col; | |
f85afd4e MB |
2343 | int m_x; |
2344 | int m_y; | |
5c8fc7c1 | 2345 | bool m_selecting; |
8b5f6d9d VZ |
2346 | |
2347 | private: | |
2348 | void Init(int row, int col, int x, int y, bool sel) | |
2349 | { | |
2350 | m_row = row; | |
2351 | m_col = col; | |
2352 | m_x = x; | |
2353 | m_y = y; | |
2354 | m_selecting = sel; | |
2355 | } | |
60ff3b99 | 2356 | |
e1f8ec29 | 2357 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEvent) |
60ff3b99 VZ |
2358 | }; |
2359 | ||
8b5f6d9d VZ |
2360 | class WXDLLIMPEXP_ADV wxGridSizeEvent : public wxNotifyEvent, |
2361 | public wxKeyboardState | |
60ff3b99 VZ |
2362 | { |
2363 | public: | |
f85afd4e | 2364 | wxGridSizeEvent() |
8b5f6d9d VZ |
2365 | : wxNotifyEvent() |
2366 | { | |
2367 | Init(-1, -1, -1); | |
2368 | } | |
2369 | ||
2370 | wxGridSizeEvent(int id, | |
2371 | wxEventType type, | |
2372 | wxObject* obj, | |
2373 | int rowOrCol = -1, | |
2374 | int x = -1, int y = -1, | |
2375 | const wxKeyboardState& kbd = wxKeyboardState()) | |
2376 | : wxNotifyEvent(type, id), | |
2377 | wxKeyboardState(kbd) | |
2378 | { | |
2379 | Init(rowOrCol, x, y); | |
f85afd4e | 2380 | |
8b5f6d9d VZ |
2381 | SetEventObject(obj); |
2382 | } | |
2383 | ||
a05e6efe | 2384 | wxDEPRECATED_CONSTRUCTOR( |
8b5f6d9d VZ |
2385 | wxGridSizeEvent(int id, |
2386 | wxEventType type, | |
2387 | wxObject* obj, | |
2388 | int rowOrCol, | |
2389 | int x, int y, | |
2390 | bool control, | |
2391 | bool shift = false, | |
2392 | bool alt = false, | |
2393 | bool meta = false) ); | |
f85afd4e MB |
2394 | |
2395 | int GetRowOrCol() { return m_rowOrCol; } | |
2396 | wxPoint GetPosition() { return wxPoint( m_x, m_y ); } | |
733f486a | 2397 | |
e1f8ec29 | 2398 | virtual wxEvent *Clone() const { return new wxGridSizeEvent(*this); } |
2d66e025 | 2399 | |
60ff3b99 VZ |
2400 | protected: |
2401 | int m_rowOrCol; | |
2402 | int m_x; | |
2403 | int m_y; | |
8b5f6d9d VZ |
2404 | |
2405 | private: | |
2406 | void Init(int rowOrCol, int x, int y) | |
2407 | { | |
2408 | m_rowOrCol = rowOrCol; | |
2409 | m_x = x; | |
2410 | m_y = y; | |
2411 | } | |
60ff3b99 | 2412 | |
e1f8ec29 | 2413 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridSizeEvent) |
f85afd4e MB |
2414 | }; |
2415 | ||
2416 | ||
8b5f6d9d VZ |
2417 | class WXDLLIMPEXP_ADV wxGridRangeSelectEvent : public wxNotifyEvent, |
2418 | public wxKeyboardState | |
f85afd4e | 2419 | { |
60ff3b99 | 2420 | public: |
f85afd4e | 2421 | wxGridRangeSelectEvent() |
60ff3b99 | 2422 | : wxNotifyEvent() |
8b5f6d9d VZ |
2423 | { |
2424 | Init(wxGridNoCellCoords, wxGridNoCellCoords, false); | |
2425 | } | |
f85afd4e | 2426 | |
8b5f6d9d VZ |
2427 | wxGridRangeSelectEvent(int id, |
2428 | wxEventType type, | |
2429 | wxObject* obj, | |
60ff3b99 VZ |
2430 | const wxGridCellCoords& topLeft, |
2431 | const wxGridCellCoords& bottomRight, | |
ca65c044 | 2432 | bool sel = true, |
8b5f6d9d VZ |
2433 | const wxKeyboardState& kbd = wxKeyboardState()) |
2434 | : wxNotifyEvent(type, id), | |
2435 | wxKeyboardState(kbd) | |
2436 | { | |
2437 | Init(topLeft, bottomRight, sel); | |
2438 | ||
2439 | SetEventObject(obj); | |
2440 | } | |
2441 | ||
a05e6efe | 2442 | wxDEPRECATED_CONSTRUCTOR( |
8b5f6d9d VZ |
2443 | wxGridRangeSelectEvent(int id, |
2444 | wxEventType type, | |
2445 | wxObject* obj, | |
2446 | const wxGridCellCoords& topLeft, | |
2447 | const wxGridCellCoords& bottomRight, | |
2448 | bool sel, | |
2449 | bool control, | |
2450 | bool shift = false, | |
2451 | bool alt = false, | |
2452 | bool meta = false) ); | |
f85afd4e MB |
2453 | |
2454 | wxGridCellCoords GetTopLeftCoords() { return m_topLeft; } | |
2455 | wxGridCellCoords GetBottomRightCoords() { return m_bottomRight; } | |
2456 | int GetTopRow() { return m_topLeft.GetRow(); } | |
2457 | int GetBottomRow() { return m_bottomRight.GetRow(); } | |
2458 | int GetLeftCol() { return m_topLeft.GetCol(); } | |
2459 | int GetRightCol() { return m_bottomRight.GetCol(); } | |
5c8fc7c1 | 2460 | bool Selecting() { return m_selecting; } |
733f486a | 2461 | |
e1f8ec29 | 2462 | virtual wxEvent *Clone() const { return new wxGridRangeSelectEvent(*this); } |
2d66e025 | 2463 | |
60ff3b99 | 2464 | protected: |
8b5f6d9d VZ |
2465 | void Init(const wxGridCellCoords& topLeft, |
2466 | const wxGridCellCoords& bottomRight, | |
2467 | bool selecting) | |
2468 | { | |
2469 | m_topLeft = topLeft; | |
2470 | m_bottomRight = bottomRight; | |
2471 | m_selecting = selecting; | |
2472 | } | |
2473 | ||
60ff3b99 VZ |
2474 | wxGridCellCoords m_topLeft; |
2475 | wxGridCellCoords m_bottomRight; | |
5c8fc7c1 | 2476 | bool m_selecting; |
60ff3b99 | 2477 | |
e1f8ec29 | 2478 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridRangeSelectEvent) |
f85afd4e MB |
2479 | }; |
2480 | ||
bf7945ce | 2481 | |
8b5f6d9d VZ |
2482 | class WXDLLIMPEXP_ADV wxGridEditorCreatedEvent : public wxCommandEvent |
2483 | { | |
bf7945ce RD |
2484 | public: |
2485 | wxGridEditorCreatedEvent() | |
2486 | : wxCommandEvent() | |
2487 | { | |
2488 | m_row = 0; | |
2489 | m_col = 0; | |
2490 | m_ctrl = NULL; | |
2491 | } | |
2492 | ||
2493 | wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj, | |
2494 | int row, int col, wxControl* ctrl); | |
2495 | ||
2496 | int GetRow() { return m_row; } | |
2497 | int GetCol() { return m_col; } | |
2498 | wxControl* GetControl() { return m_ctrl; } | |
2499 | void SetRow(int row) { m_row = row; } | |
2500 | void SetCol(int col) { m_col = col; } | |
2501 | void SetControl(wxControl* ctrl) { m_ctrl = ctrl; } | |
733f486a | 2502 | |
e1f8ec29 | 2503 | virtual wxEvent *Clone() const { return new wxGridEditorCreatedEvent(*this); } |
bf7945ce RD |
2504 | |
2505 | private: | |
2506 | int m_row; | |
2507 | int m_col; | |
2508 | wxControl* m_ctrl; | |
2509 | ||
e1f8ec29 | 2510 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxGridEditorCreatedEvent) |
bf7945ce RD |
2511 | }; |
2512 | ||
2513 | ||
9b11752c VZ |
2514 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_LEFT_CLICK, wxGridEvent ); |
2515 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_RIGHT_CLICK, wxGridEvent ); | |
2516 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEvent ); | |
2517 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_RIGHT_DCLICK, wxGridEvent ); | |
2518 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_LEFT_CLICK, wxGridEvent ); | |
2519 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_RIGHT_CLICK, wxGridEvent ); | |
2520 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_LEFT_DCLICK, wxGridEvent ); | |
2521 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_LABEL_RIGHT_DCLICK, wxGridEvent ); | |
2522 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_ROW_SIZE, wxGridSizeEvent ); | |
2523 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_SIZE, wxGridSizeEvent ); | |
2524 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_RANGE_SELECT, wxGridRangeSelectEvent ); | |
2525 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGING, wxGridEvent ); | |
2526 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_CHANGED, wxGridEvent ); | |
2527 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_SELECT_CELL, wxGridEvent ); | |
2528 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_SHOWN, wxGridEvent ); | |
2529 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_HIDDEN, wxGridEvent ); | |
2530 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_EDITOR_CREATED, wxGridEditorCreatedEvent ); | |
2531 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_CELL_BEGIN_DRAG, wxGridEvent ); | |
2532 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_MOVE, wxGridEvent ); | |
2533 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_GRID_COL_SORT, wxGridEvent ); | |
749692cc | 2534 | |
f85afd4e MB |
2535 | typedef void (wxEvtHandler::*wxGridEventFunction)(wxGridEvent&); |
2536 | typedef void (wxEvtHandler::*wxGridSizeEventFunction)(wxGridSizeEvent&); | |
2537 | typedef void (wxEvtHandler::*wxGridRangeSelectEventFunction)(wxGridRangeSelectEvent&); | |
bf7945ce | 2538 | typedef void (wxEvtHandler::*wxGridEditorCreatedEventFunction)(wxGridEditorCreatedEvent&); |
f85afd4e | 2539 | |
7fa03f04 | 2540 | #define wxGridEventHandler(func) \ |
3c778901 | 2541 | wxEVENT_HANDLER_CAST(wxGridEventFunction, func) |
7fa03f04 VZ |
2542 | |
2543 | #define wxGridSizeEventHandler(func) \ | |
3c778901 | 2544 | wxEVENT_HANDLER_CAST(wxGridSizeEventFunction, func) |
7fa03f04 VZ |
2545 | |
2546 | #define wxGridRangeSelectEventHandler(func) \ | |
3c778901 | 2547 | wxEVENT_HANDLER_CAST(wxGridRangeSelectEventFunction, func) |
7fa03f04 VZ |
2548 | |
2549 | #define wxGridEditorCreatedEventHandler(func) \ | |
3c778901 | 2550 | wxEVENT_HANDLER_CAST(wxGridEditorCreatedEventFunction, func) |
7fa03f04 VZ |
2551 | |
2552 | #define wx__DECLARE_GRIDEVT(evt, id, fn) \ | |
2553 | wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEventHandler(fn)) | |
2554 | ||
2555 | #define wx__DECLARE_GRIDSIZEEVT(evt, id, fn) \ | |
2556 | wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridSizeEventHandler(fn)) | |
2557 | ||
2558 | #define wx__DECLARE_GRIDRANGESELEVT(evt, id, fn) \ | |
2559 | wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridRangeSelectEventHandler(fn)) | |
2560 | ||
2561 | #define wx__DECLARE_GRIDEDITOREVT(evt, id, fn) \ | |
2562 | wx__DECLARE_EVT1(wxEVT_GRID_ ## evt, id, wxGridEditorCreatedEventHandler(fn)) | |
2563 | ||
2564 | #define EVT_GRID_CMD_CELL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_CLICK, id, fn) | |
2565 | #define EVT_GRID_CMD_CELL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_CLICK, id, fn) | |
2566 | #define EVT_GRID_CMD_CELL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_LEFT_DCLICK, id, fn) | |
2567 | #define EVT_GRID_CMD_CELL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(CELL_RIGHT_DCLICK, id, fn) | |
2568 | #define EVT_GRID_CMD_LABEL_LEFT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_CLICK, id, fn) | |
2569 | #define EVT_GRID_CMD_LABEL_RIGHT_CLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_CLICK, id, fn) | |
2570 | #define EVT_GRID_CMD_LABEL_LEFT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_LEFT_DCLICK, id, fn) | |
2571 | #define EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, fn) wx__DECLARE_GRIDEVT(LABEL_RIGHT_DCLICK, id, fn) | |
2572 | #define EVT_GRID_CMD_ROW_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(ROW_SIZE, id, fn) | |
2573 | #define EVT_GRID_CMD_COL_SIZE(id, fn) wx__DECLARE_GRIDSIZEEVT(COL_SIZE, id, fn) | |
5d984f5d | 2574 | #define EVT_GRID_CMD_COL_MOVE(id, fn) wx__DECLARE_GRIDEVT(COL_MOVE, id, fn) |
11393d29 | 2575 | #define EVT_GRID_CMD_COL_SORT(id, fn) wx__DECLARE_GRIDEVT(COL_SORT, id, fn) |
7fa03f04 | 2576 | #define EVT_GRID_CMD_RANGE_SELECT(id, fn) wx__DECLARE_GRIDRANGESELEVT(RANGE_SELECT, id, fn) |
763163a8 VZ |
2577 | #define EVT_GRID_CMD_CELL_CHANGING(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGING, id, fn) |
2578 | #define EVT_GRID_CMD_CELL_CHANGED(id, fn) wx__DECLARE_GRIDEVT(CELL_CHANGED, id, fn) | |
7fa03f04 VZ |
2579 | #define EVT_GRID_CMD_SELECT_CELL(id, fn) wx__DECLARE_GRIDEVT(SELECT_CELL, id, fn) |
2580 | #define EVT_GRID_CMD_EDITOR_SHOWN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_SHOWN, id, fn) | |
2581 | #define EVT_GRID_CMD_EDITOR_HIDDEN(id, fn) wx__DECLARE_GRIDEVT(EDITOR_HIDDEN, id, fn) | |
2582 | #define EVT_GRID_CMD_EDITOR_CREATED(id, fn) wx__DECLARE_GRIDEDITOREVT(EDITOR_CREATED, id, fn) | |
2583 | #define EVT_GRID_CMD_CELL_BEGIN_DRAG(id, fn) wx__DECLARE_GRIDEVT(CELL_BEGIN_DRAG, id, fn) | |
2584 | ||
2585 | // same as above but for any id (exists mainly for backwards compatibility but | |
2586 | // then it's also true that you rarely have multiple grid in the same window) | |
2587 | #define EVT_GRID_CELL_LEFT_CLICK(fn) EVT_GRID_CMD_CELL_LEFT_CLICK(wxID_ANY, fn) | |
2588 | #define EVT_GRID_CELL_RIGHT_CLICK(fn) EVT_GRID_CMD_CELL_RIGHT_CLICK(wxID_ANY, fn) | |
2589 | #define EVT_GRID_CELL_LEFT_DCLICK(fn) EVT_GRID_CMD_CELL_LEFT_DCLICK(wxID_ANY, fn) | |
2590 | #define EVT_GRID_CELL_RIGHT_DCLICK(fn) EVT_GRID_CMD_CELL_RIGHT_DCLICK(wxID_ANY, fn) | |
2591 | #define EVT_GRID_LABEL_LEFT_CLICK(fn) EVT_GRID_CMD_LABEL_LEFT_CLICK(wxID_ANY, fn) | |
2592 | #define EVT_GRID_LABEL_RIGHT_CLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_CLICK(wxID_ANY, fn) | |
2593 | #define EVT_GRID_LABEL_LEFT_DCLICK(fn) EVT_GRID_CMD_LABEL_LEFT_DCLICK(wxID_ANY, fn) | |
2594 | #define EVT_GRID_LABEL_RIGHT_DCLICK(fn) EVT_GRID_CMD_LABEL_RIGHT_DCLICK(wxID_ANY, fn) | |
2595 | #define EVT_GRID_ROW_SIZE(fn) EVT_GRID_CMD_ROW_SIZE(wxID_ANY, fn) | |
2596 | #define EVT_GRID_COL_SIZE(fn) EVT_GRID_CMD_COL_SIZE(wxID_ANY, fn) | |
4d5a1b0a | 2597 | #define EVT_GRID_COL_MOVE(fn) EVT_GRID_CMD_COL_MOVE(wxID_ANY, fn) |
11393d29 | 2598 | #define EVT_GRID_COL_SORT(fn) EVT_GRID_CMD_COL_SORT(wxID_ANY, fn) |
7fa03f04 | 2599 | #define EVT_GRID_RANGE_SELECT(fn) EVT_GRID_CMD_RANGE_SELECT(wxID_ANY, fn) |
763163a8 VZ |
2600 | #define EVT_GRID_CELL_CHANGING(fn) EVT_GRID_CMD_CELL_CHANGING(wxID_ANY, fn) |
2601 | #define EVT_GRID_CELL_CHANGED(fn) EVT_GRID_CMD_CELL_CHANGED(wxID_ANY, fn) | |
7fa03f04 VZ |
2602 | #define EVT_GRID_SELECT_CELL(fn) EVT_GRID_CMD_SELECT_CELL(wxID_ANY, fn) |
2603 | #define EVT_GRID_EDITOR_SHOWN(fn) EVT_GRID_CMD_EDITOR_SHOWN(wxID_ANY, fn) | |
2604 | #define EVT_GRID_EDITOR_HIDDEN(fn) EVT_GRID_CMD_EDITOR_HIDDEN(wxID_ANY, fn) | |
2605 | #define EVT_GRID_EDITOR_CREATED(fn) EVT_GRID_CMD_EDITOR_CREATED(wxID_ANY, fn) | |
2606 | #define EVT_GRID_CELL_BEGIN_DRAG(fn) EVT_GRID_CMD_CELL_BEGIN_DRAG(wxID_ANY, fn) | |
f85afd4e | 2607 | |
763163a8 VZ |
2608 | // we used to have a single wxEVT_GRID_CELL_CHANGE event but it was split into |
2609 | // wxEVT_GRID_CELL_CHANGING and CHANGED ones in wx 2.9.0, however the CHANGED | |
2610 | // is basically the same as the old CHANGE event so we keep the name for | |
2611 | // compatibility | |
2612 | #if WXWIN_COMPATIBILITY_2_8 | |
2613 | #define wxEVT_GRID_CELL_CHANGE wxEVT_GRID_CELL_CHANGED | |
2614 | ||
2615 | #define EVT_GRID_CMD_CELL_CHANGE EVT_GRID_CMD_CELL_CHANGED | |
2616 | #define EVT_GRID_CELL_CHANGE EVT_GRID_CELL_CHANGED | |
2617 | #endif // WXWIN_COMPATIBILITY_2_8 | |
2618 | ||
f85afd4e MB |
2619 | #if 0 // TODO: implement these ? others ? |
2620 | ||
77d4384e RR |
2621 | extern const int wxEVT_GRID_CREATE_CELL; |
2622 | extern const int wxEVT_GRID_CHANGE_LABELS; | |
2623 | extern const int wxEVT_GRID_CHANGE_SEL_LABEL; | |
f85afd4e | 2624 | |
a0e9a5df FM |
2625 | #define EVT_GRID_CREATE_CELL(fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CREATE_CELL, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ), |
2626 | #define EVT_GRID_CHANGE_LABELS(fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_LABELS, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ), | |
2627 | #define EVT_GRID_CHANGE_SEL_LABEL(fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_GRID_CHANGE_SEL_LABEL, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxGridEventFunction, &fn ), NULL ), | |
f85afd4e MB |
2628 | |
2629 | #endif | |
2630 | ||
df9fac6d PC |
2631 | #endif // wxUSE_GRID |
2632 | #endif // _WX_GENERIC_GRID_H_ |