]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: grid.h | |
afe0e400 | 3 | // Purpose: interface of wxGrid and related classes |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
8b9ef005 BP |
9 | /** |
10 | @class wxGridCellRenderer | |
11 | ||
12 | This class is responsible for actually drawing the cell in the grid. You | |
13 | may pass it to the wxGridCellAttr (below) to change the format of one given | |
14 | cell or to wxGrid::SetDefaultRenderer() to change the view of all cells. | |
15 | This is an abstract class, and you will normally use one of the predefined | |
16 | derived classes or derive your own class from it. | |
17 | ||
18 | @library{wxadv} | |
19 | @category{grid} | |
20 | ||
21 | @see wxGridCellBoolRenderer, wxGridCellFloatRenderer, | |
22 | wxGridCellNumberRenderer, wxGridCellStringRenderer | |
23 | */ | |
24 | class wxGridCellRenderer | |
25 | { | |
26 | public: | |
27 | /** | |
28 | This function must be implemented in derived classes to return a copy | |
29 | of itself. | |
30 | */ | |
31 | virtual wxGridCellRenderer* Clone() const = 0; | |
32 | ||
33 | /** | |
34 | Draw the given cell on the provided DC inside the given rectangle using | |
35 | the style specified by the attribute and the default or selected state | |
36 | corresponding to the isSelected value. | |
37 | ||
38 | This pure virtual function has a default implementation which will | |
39 | prepare the DC using the given attribute: it will draw the rectangle | |
40 | with the background colour from attr and set the text colour and font. | |
41 | */ | |
42 | virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
43 | const wxRect& rect, int row, int col, | |
44 | bool isSelected) = 0; | |
45 | ||
46 | /** | |
47 | Get the preferred size of the cell for its contents. | |
48 | */ | |
49 | virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
50 | int row, int col) = 0; | |
51 | }; | |
52 | ||
53 | /** | |
54 | @class wxGridCellBoolRenderer | |
55 | ||
56 | This class may be used to format boolean data in a cell. | |
57 | ||
58 | @library{wxadv} | |
59 | @category{grid} | |
60 | ||
61 | @see wxGridCellRenderer, wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
62 | wxGridCellStringRenderer | |
63 | */ | |
64 | class wxGridCellBoolRenderer : public wxGridCellRenderer | |
65 | { | |
66 | public: | |
67 | /** | |
68 | Default constructor. | |
69 | */ | |
70 | wxGridCellBoolRenderer(); | |
71 | }; | |
72 | ||
23324ae1 FM |
73 | /** |
74 | @class wxGridCellFloatRenderer | |
7c913512 | 75 | |
23324ae1 | 76 | This class may be used to format floating point data in a cell. |
7c913512 | 77 | |
23324ae1 | 78 | @library{wxadv} |
42b5841f | 79 | @category{grid} |
7c913512 | 80 | |
afe0e400 BP |
81 | @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellNumberRenderer, |
82 | wxGridCellStringRenderer | |
23324ae1 FM |
83 | */ |
84 | class wxGridCellFloatRenderer : public wxGridCellStringRenderer | |
85 | { | |
86 | public: | |
87 | /** | |
7c913512 | 88 | @param width |
4cc4bfaf | 89 | Minimum number of characters to be shown. |
7c913512 | 90 | @param precision |
4cc4bfaf | 91 | Number of digits after the decimal dot. |
23324ae1 FM |
92 | */ |
93 | wxGridCellFloatRenderer(int width = -1, int precision = -1); | |
94 | ||
95 | /** | |
42b5841f | 96 | Returns the precision. |
23324ae1 | 97 | */ |
328f5751 | 98 | int GetPrecision() const; |
23324ae1 FM |
99 | |
100 | /** | |
42b5841f | 101 | Returns the width. |
23324ae1 | 102 | */ |
328f5751 | 103 | int GetWidth() const; |
23324ae1 FM |
104 | |
105 | /** | |
106 | Parameters string format is "width[,precision]". | |
107 | */ | |
adaaa686 | 108 | virtual void SetParameters(const wxString& params); |
23324ae1 FM |
109 | |
110 | /** | |
42b5841f | 111 | Sets the precision. |
23324ae1 FM |
112 | */ |
113 | void SetPrecision(int precision); | |
114 | ||
115 | /** | |
42b5841f | 116 | Sets the width. |
23324ae1 FM |
117 | */ |
118 | void SetWidth(int width); | |
119 | }; | |
120 | ||
23324ae1 | 121 | /** |
8b9ef005 | 122 | @class wxGridCellNumberRenderer |
7c913512 | 123 | |
8b9ef005 | 124 | This class may be used to format integer data in a cell. |
5039f140 | 125 | |
8b9ef005 BP |
126 | @library{wxadv} |
127 | @category{grid} | |
5039f140 | 128 | |
8b9ef005 BP |
129 | @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellFloatRenderer, |
130 | wxGridCellStringRenderer | |
131 | */ | |
132 | class wxGridCellNumberRenderer : public wxGridCellStringRenderer | |
133 | { | |
134 | public: | |
135 | /** | |
136 | Default constructor. | |
137 | */ | |
138 | wxGridCellNumberRenderer(); | |
139 | }; | |
5039f140 | 140 | |
8b9ef005 BP |
141 | /** |
142 | @class wxGridCellStringRenderer | |
143 | ||
144 | This class may be used to format string data in a cell; it is the default | |
145 | for string cells. | |
7c913512 | 146 | |
23324ae1 | 147 | @library{wxadv} |
42b5841f | 148 | @category{grid} |
8b9ef005 BP |
149 | |
150 | @see wxGridCellRenderer, wxGridCellBoolRenderer, wxGridCellFloatRenderer, | |
151 | wxGridCellNumberRenderer | |
23324ae1 | 152 | */ |
8b9ef005 | 153 | class wxGridCellStringRenderer : public wxGridCellRenderer |
23324ae1 FM |
154 | { |
155 | public: | |
afe0e400 BP |
156 | /** |
157 | Default constructor. | |
8b9ef005 BP |
158 | */ |
159 | wxGridCellStringRenderer(); | |
160 | }; | |
23324ae1 | 161 | |
3c4f71cc | 162 | |
77d2c45c | 163 | |
8b9ef005 BP |
164 | /** |
165 | @class wxGridCellEditor | |
23324ae1 | 166 | |
8b9ef005 BP |
167 | This class is responsible for providing and manipulating the in-place edit |
168 | controls for the grid. Instances of wxGridCellEditor (actually, instances | |
169 | of derived classes since it is an abstract class) can be associated with | |
170 | the cell attributes for individual cells, rows, columns, or even for the | |
171 | entire grid. | |
77d2c45c | 172 | |
8b9ef005 BP |
173 | @library{wxadv} |
174 | @category{grid} | |
3c4f71cc | 175 | |
8b9ef005 BP |
176 | @see wxGridCellBoolEditor, wxGridCellChoiceEditor, wxGridCellFloatEditor, |
177 | wxGridCellNumberEditor, wxGridCellTextEditor | |
178 | */ | |
179 | class wxGridCellEditor | |
180 | { | |
181 | public: | |
77d2c45c | 182 | /** |
8b9ef005 BP |
183 | Default constructor. |
184 | */ | |
185 | wxGridCellEditor(); | |
77d2c45c VZ |
186 | |
187 | /** | |
8b9ef005 | 188 | Fetch the value from the table and prepare the edit control to begin |
763163a8 VZ |
189 | editing. |
190 | ||
191 | This function should save the original value of the grid cell at the | |
192 | given @a row and @a col and show the control allowing the user to | |
193 | change it. | |
194 | ||
195 | @see EndEdit() | |
8b9ef005 BP |
196 | */ |
197 | virtual void BeginEdit(int row, int col, wxGrid* grid) = 0; | |
77d2c45c | 198 | |
8b9ef005 BP |
199 | /** |
200 | Create a new object which is the copy of this one. | |
201 | */ | |
202 | virtual wxGridCellEditor* Clone() const = 0; | |
23324ae1 FM |
203 | |
204 | /** | |
8b9ef005 BP |
205 | Creates the actual edit control. |
206 | */ | |
207 | virtual void Create(wxWindow* parent, wxWindowID id, | |
208 | wxEvtHandler* evtHandler) = 0; | |
3c4f71cc | 209 | |
afe0e400 | 210 | /** |
8b9ef005 BP |
211 | Final cleanup. |
212 | */ | |
213 | virtual void Destroy(); | |
23324ae1 | 214 | |
10a4531d | 215 | /** |
763163a8 | 216 | End editing the cell. |
10a4531d | 217 | |
763163a8 VZ |
218 | This function must check if the current value of the editing control is |
219 | valid and different from the original value (available as @a oldval in | |
220 | its string form and possibly saved internally using its real type by | |
78e78812 VZ |
221 | BeginEdit()). If it isn't, it just returns @false, otherwise it must do |
222 | the following: | |
223 | # Save the new value internally so that ApplyEdit() could apply it. | |
224 | # Fill @a newval (which is never @NULL) with the string | |
225 | representation of the new value. | |
226 | # Return @true | |
227 | ||
228 | Notice that it must @em not modify the grid as the change could still | |
229 | be vetoed. | |
763163a8 VZ |
230 | |
231 | If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto | |
232 | this change, ApplyEdit() will be called next. | |
8b9ef005 | 233 | */ |
78e78812 VZ |
234 | virtual bool EndEdit(int row, int col, const wxGrid* grid, |
235 | const wxString& oldval, wxString* newval) = 0; | |
10a4531d | 236 | |
763163a8 VZ |
237 | /** |
238 | Effectively save the changes in the grid. | |
239 | ||
240 | This function should save the value of the control in the grid. It is | |
241 | called only after EndEdit() returns @true. | |
242 | */ | |
243 | virtual void ApplyEdit(int row, int col, wxGrid* grid) = 0; | |
244 | ||
afe0e400 | 245 | /** |
8b9ef005 BP |
246 | Some types of controls on some platforms may need some help with the |
247 | Return key. | |
248 | */ | |
249 | virtual void HandleReturn(wxKeyEvent& event); | |
3c4f71cc | 250 | |
afe0e400 | 251 | /** |
8b9ef005 BP |
252 | Returns @true if the edit control has been created. |
253 | */ | |
254 | bool IsCreated(); | |
23324ae1 FM |
255 | |
256 | /** | |
8b9ef005 BP |
257 | Draws the part of the cell not occupied by the control: the base class |
258 | version just fills it with background colour from the attribute. | |
259 | */ | |
260 | virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr* attr); | |
23324ae1 FM |
261 | |
262 | /** | |
8b9ef005 BP |
263 | Reset the value in the control back to its starting value. |
264 | */ | |
265 | virtual void Reset() = 0; | |
3c4f71cc | 266 | |
8b9ef005 BP |
267 | /** |
268 | Size and position the edit control. | |
269 | */ | |
270 | virtual void SetSize(const wxRect& rect); | |
23324ae1 FM |
271 | |
272 | /** | |
8b9ef005 BP |
273 | Show or hide the edit control, use the specified attributes to set |
274 | colours/fonts for it. | |
275 | */ | |
276 | virtual void Show(bool show, wxGridCellAttr* attr = NULL); | |
3c4f71cc | 277 | |
8b9ef005 BP |
278 | /** |
279 | If the editor is enabled by clicking on the cell, this method will be | |
280 | called. | |
281 | */ | |
282 | virtual void StartingClick(); | |
23324ae1 FM |
283 | |
284 | /** | |
8b9ef005 BP |
285 | If the editor is enabled by pressing keys on the grid, this will be |
286 | called to let the editor do something about that first key if desired. | |
287 | */ | |
288 | virtual void StartingKey(wxKeyEvent& event); | |
3c4f71cc | 289 | |
8b9ef005 | 290 | protected: |
23324ae1 FM |
291 | |
292 | /** | |
8b9ef005 BP |
293 | The destructor is private because only DecRef() can delete us. |
294 | */ | |
295 | virtual ~wxGridCellEditor(); | |
296 | }; | |
3c4f71cc | 297 | |
8b9ef005 BP |
298 | /** |
299 | @class wxGridCellBoolEditor | |
23324ae1 | 300 | |
8b9ef005 | 301 | Grid cell editor for boolean data. |
23324ae1 | 302 | |
8b9ef005 BP |
303 | @library{wxadv} |
304 | @category{grid} | |
23324ae1 | 305 | |
8b9ef005 BP |
306 | @see wxGridCellEditor, wxGridCellChoiceEditor, wxGridCellFloatEditor, |
307 | wxGridCellNumberEditor, wxGridCellTextEditor | |
308 | */ | |
309 | class wxGridCellBoolEditor : public wxGridCellEditor | |
310 | { | |
311 | public: | |
23324ae1 | 312 | /** |
8b9ef005 BP |
313 | Default constructor. |
314 | */ | |
315 | wxGridCellBoolEditor(); | |
5039f140 | 316 | |
8b9ef005 BP |
317 | /** |
318 | Returns @true if the given @a value is equal to the string | |
319 | representation of the truth value we currently use (see | |
320 | UseStringValues()). | |
321 | */ | |
322 | static bool IsTrueValue(const wxString& value); | |
3c4f71cc | 323 | |
23324ae1 | 324 | /** |
8b9ef005 BP |
325 | This method allows you to customize the values returned by GetValue() |
326 | for the cell using this editor. By default, the default values of the | |
327 | arguments are used, i.e. @c "1" is returned if the cell is checked and | |
328 | an empty string otherwise. | |
329 | */ | |
330 | static void UseStringValues(const wxString& valueTrue = "1", | |
57bf907d | 331 | const wxString& valueFalse = wxEmptyString); |
8b9ef005 | 332 | }; |
3c4f71cc | 333 | |
8b9ef005 BP |
334 | /** |
335 | @class wxGridCellChoiceEditor | |
23324ae1 | 336 | |
8b9ef005 BP |
337 | Grid cell editor for string data providing the user a choice from a list of |
338 | strings. | |
5039f140 | 339 | |
8b9ef005 BP |
340 | @library{wxadv} |
341 | @category{grid} | |
23324ae1 | 342 | |
8b9ef005 BP |
343 | @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellFloatEditor, |
344 | wxGridCellNumberEditor, wxGridCellTextEditor | |
345 | */ | |
346 | class wxGridCellChoiceEditor : public wxGridCellEditor | |
347 | { | |
348 | public: | |
23324ae1 | 349 | /** |
8b9ef005 BP |
350 | @param count |
351 | Number of strings from which the user can choose. | |
352 | @param choices | |
353 | An array of strings from which the user can choose. | |
354 | @param allowOthers | |
355 | If allowOthers is @true, the user can type a string not in choices | |
356 | array. | |
357 | */ | |
358 | wxGridCellChoiceEditor(size_t count = 0, | |
359 | const wxString choices[] = NULL, | |
360 | bool allowOthers = false); | |
361 | /** | |
362 | @param choices | |
363 | An array of strings from which the user can choose. | |
364 | @param allowOthers | |
365 | If allowOthers is @true, the user can type a string not in choices | |
366 | array. | |
367 | */ | |
368 | wxGridCellChoiceEditor(const wxArrayString& choices, | |
369 | bool allowOthers = false); | |
23324ae1 FM |
370 | |
371 | /** | |
8b9ef005 BP |
372 | Parameters string format is "item1[,item2[...,itemN]]" |
373 | */ | |
374 | virtual void SetParameters(const wxString& params); | |
375 | }; | |
23324ae1 | 376 | |
8b9ef005 BP |
377 | /** |
378 | @class wxGridCellTextEditor | |
3c4f71cc | 379 | |
8b9ef005 | 380 | Grid cell editor for string/text data. |
23324ae1 | 381 | |
8b9ef005 BP |
382 | @library{wxadv} |
383 | @category{grid} | |
afe0e400 | 384 | |
8b9ef005 BP |
385 | @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, |
386 | wxGridCellFloatEditor, wxGridCellNumberEditor | |
387 | */ | |
388 | class wxGridCellTextEditor : public wxGridCellEditor | |
389 | { | |
390 | public: | |
23324ae1 | 391 | /** |
8b9ef005 BP |
392 | Default constructor. |
393 | */ | |
394 | wxGridCellTextEditor(); | |
23324ae1 FM |
395 | |
396 | /** | |
8b9ef005 BP |
397 | The parameters string format is "n" where n is a number representing |
398 | the maximum width. | |
399 | */ | |
400 | virtual void SetParameters(const wxString& params); | |
401 | }; | |
5039f140 | 402 | |
8b9ef005 BP |
403 | /** |
404 | @class wxGridCellFloatEditor | |
23324ae1 | 405 | |
8b9ef005 | 406 | The editor for floating point numbers data. |
3c4f71cc | 407 | |
8b9ef005 BP |
408 | @library{wxadv} |
409 | @category{grid} | |
23324ae1 | 410 | |
8b9ef005 BP |
411 | @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor, |
412 | wxGridCellTextEditor, wxGridCellChoiceEditor | |
413 | */ | |
414 | class wxGridCellFloatEditor : public wxGridCellTextEditor | |
415 | { | |
416 | public: | |
23324ae1 | 417 | /** |
8b9ef005 BP |
418 | @param width |
419 | Minimum number of characters to be shown. | |
420 | @param precision | |
421 | Number of digits after the decimal dot. | |
422 | */ | |
423 | wxGridCellFloatEditor(int width = -1, int precision = -1); | |
23324ae1 FM |
424 | |
425 | /** | |
8b9ef005 BP |
426 | Parameters string format is "width,precision" |
427 | */ | |
428 | virtual void SetParameters(const wxString& params); | |
429 | }; | |
23324ae1 | 430 | |
8b9ef005 BP |
431 | /** |
432 | @class wxGridCellNumberEditor | |
3c4f71cc | 433 | |
8b9ef005 | 434 | Grid cell editor for numeric integer data. |
5039f140 | 435 | |
8b9ef005 BP |
436 | @library{wxadv} |
437 | @category{grid} | |
23324ae1 | 438 | |
8b9ef005 BP |
439 | @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, |
440 | wxGridCellFloatEditor, wxGridCellTextEditor | |
441 | */ | |
442 | class wxGridCellNumberEditor : public wxGridCellTextEditor | |
443 | { | |
444 | public: | |
23324ae1 | 445 | /** |
8b9ef005 BP |
446 | Allows you to specify the range for acceptable data. Values equal to |
447 | -1 for both @a min and @a max indicate that no range checking should be | |
448 | done. | |
449 | */ | |
450 | wxGridCellNumberEditor(int min = -1, int max = -1); | |
3c4f71cc | 451 | |
23324ae1 | 452 | |
afe0e400 | 453 | /** |
8b9ef005 BP |
454 | Parameters string format is "min,max". |
455 | */ | |
456 | virtual void SetParameters(const wxString& params); | |
457 | ||
458 | protected: | |
3c4f71cc | 459 | |
afe0e400 | 460 | /** |
8b9ef005 BP |
461 | If the return value is @true, the editor uses a wxSpinCtrl to get user |
462 | input, otherwise it uses a wxTextCtrl. | |
463 | */ | |
464 | bool HasRange() const; | |
23324ae1 | 465 | |
afe0e400 | 466 | /** |
8b9ef005 BP |
467 | String representation of the value. |
468 | */ | |
469 | wxString GetString() const; | |
470 | }; | |
23324ae1 | 471 | |
23324ae1 | 472 | |
3c4f71cc | 473 | |
8b9ef005 BP |
474 | /** |
475 | @class wxGridCellAttr | |
23324ae1 | 476 | |
8b9ef005 BP |
477 | This class can be used to alter the cells' appearance in the grid by |
478 | changing their attributes from the defaults. An object of this class may be | |
479 | returned by wxGridTableBase::GetAttr(). | |
5039f140 | 480 | |
8b9ef005 BP |
481 | @library{wxadv} |
482 | @category{grid} | |
483 | */ | |
484 | class wxGridCellAttr | |
485 | { | |
486 | public: | |
62960a2c VZ |
487 | /** |
488 | Kind of the attribute to retrieve. | |
489 | ||
490 | @see wxGridCellAttrProvider::GetAttr(), wxGridTableBase::GetAttr() | |
491 | */ | |
492 | enum wxAttrKind | |
493 | { | |
494 | /// Return the combined effective attribute for the cell. | |
495 | Any, | |
496 | ||
497 | /// Return the attribute explicitly set for this cell. | |
498 | Cell, | |
499 | ||
500 | /// Return the attribute set for this cells row. | |
501 | Row, | |
502 | ||
503 | /// Return the attribute set for this cells column. | |
504 | Col | |
505 | }; | |
506 | ||
afe0e400 | 507 | /** |
8b9ef005 BP |
508 | Default constructor. |
509 | */ | |
ccf39540 | 510 | wxGridCellAttr(wxGridCellAttr* attrDefault = NULL); |
23324ae1 | 511 | /** |
8b9ef005 BP |
512 | Constructor specifying some of the often used attributes. |
513 | */ | |
514 | wxGridCellAttr(const wxColour& colText, const wxColour& colBack, | |
515 | const wxFont& font, int hAlign, int vAlign); | |
5039f140 | 516 | |
afe0e400 | 517 | /** |
8b9ef005 BP |
518 | Creates a new copy of this object. |
519 | */ | |
520 | wxGridCellAttr* Clone() const; | |
23324ae1 FM |
521 | |
522 | /** | |
8b9ef005 BP |
523 | This class is reference counted: it is created with ref count of 1, so |
524 | calling DecRef() once will delete it. Calling IncRef() allows to lock | |
525 | it until the matching DecRef() is called. | |
526 | */ | |
527 | void DecRef(); | |
23324ae1 FM |
528 | |
529 | /** | |
cfbc15ee VZ |
530 | Get the alignment to use for the cell with the given attribute. |
531 | ||
532 | If this attribute doesn't specify any alignment, the default attribute | |
533 | alignment is used (which can be changed using | |
534 | wxGrid::SetDefaultCellAlignment() but is left and top by default). | |
535 | ||
536 | Notice that @a hAlign and @a vAlign values are always overwritten by | |
537 | this function, use GetNonDefaultAlignment() if this is not desirable. | |
538 | ||
539 | @param hAlign | |
540 | Horizontal alignment is returned here if this argument is non-@NULL. | |
541 | It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. | |
542 | @param vAlign | |
543 | Vertical alignment is returned here if this argument is non-@NULL. | |
544 | It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM. | |
8b9ef005 BP |
545 | */ |
546 | void GetAlignment(int* hAlign, int* vAlign) const; | |
23324ae1 FM |
547 | |
548 | /** | |
8b9ef005 BP |
549 | Returns the background colour. |
550 | */ | |
551 | const wxColour& GetBackgroundColour() const; | |
23324ae1 | 552 | |
23324ae1 | 553 | /** |
8b9ef005 BP |
554 | Returns the cell editor. |
555 | */ | |
556 | wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const; | |
23324ae1 FM |
557 | |
558 | /** | |
8b9ef005 BP |
559 | Returns the font. |
560 | */ | |
561 | const wxFont& GetFont() const; | |
23324ae1 | 562 | |
cfbc15ee VZ |
563 | /** |
564 | Get the alignment defined by this attribute. | |
565 | ||
566 | Unlike GetAlignment() this function only modifies @a hAlign and @a | |
567 | vAlign if this attribute does define a non-default alignment. This | |
568 | means that they must be initialized before calling this function and | |
569 | that their values will be preserved unchanged if they are different | |
570 | from wxALIGN_INVALID. | |
571 | ||
572 | For example, the following fragment can be used to use the cell | |
573 | alignment if one is defined but right-align its contents by default | |
574 | (instead of left-aligning it by default) while still using the default | |
575 | vertical alignment: | |
576 | @code | |
577 | int hAlign = wxALIGN_RIGHT, | |
578 | vAlign = wxALIGN_INVALID; | |
579 | attr.GetNonDefaultAlignment(&hAlign, &vAlign); | |
580 | @endcode | |
581 | ||
582 | @since 2.9.1 | |
583 | */ | |
584 | void GetNonDefaultAlignment(int *hAlign, int *vAlign) const; | |
585 | ||
23324ae1 | 586 | /** |
8b9ef005 BP |
587 | Returns the cell renderer. |
588 | */ | |
589 | wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const; | |
23324ae1 FM |
590 | |
591 | /** | |
8b9ef005 BP |
592 | Returns the text colour. |
593 | */ | |
594 | const wxColour& GetTextColour() const; | |
5e6e278d FM |
595 | |
596 | /** | |
8b9ef005 BP |
597 | Returns @true if this attribute has a valid alignment set. |
598 | */ | |
599 | bool HasAlignment() const; | |
7c913512 | 600 | |
23324ae1 | 601 | /** |
8b9ef005 | 602 | Returns @true if this attribute has a valid background colour set. |
23324ae1 | 603 | */ |
8b9ef005 | 604 | bool HasBackgroundColour() const; |
23324ae1 | 605 | |
23324ae1 | 606 | /** |
8b9ef005 | 607 | Returns @true if this attribute has a valid cell editor set. |
23324ae1 | 608 | */ |
8b9ef005 | 609 | bool HasEditor() const; |
23324ae1 FM |
610 | |
611 | /** | |
8b9ef005 | 612 | Returns @true if this attribute has a valid font set. |
23324ae1 | 613 | */ |
8b9ef005 | 614 | bool HasFont() const; |
23324ae1 FM |
615 | |
616 | /** | |
8b9ef005 | 617 | Returns @true if this attribute has a valid cell renderer set. |
23324ae1 | 618 | */ |
8b9ef005 | 619 | bool HasRenderer() const; |
23324ae1 FM |
620 | |
621 | /** | |
8b9ef005 | 622 | Returns @true if this attribute has a valid text colour set. |
23324ae1 | 623 | */ |
8b9ef005 | 624 | bool HasTextColour() const; |
23324ae1 FM |
625 | |
626 | /** | |
8b9ef005 BP |
627 | This class is reference counted: it is created with ref count of 1, so |
628 | calling DecRef() once will delete it. Calling IncRef() allows to lock | |
629 | it until the matching DecRef() is called. | |
23324ae1 | 630 | */ |
8b9ef005 | 631 | void IncRef(); |
23324ae1 FM |
632 | |
633 | /** | |
8b9ef005 | 634 | Returns @true if this cell is set as read-only. |
23324ae1 | 635 | */ |
8b9ef005 | 636 | bool IsReadOnly() const; |
23324ae1 FM |
637 | |
638 | /** | |
8b9ef005 BP |
639 | Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT, |
640 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of | |
641 | @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
23324ae1 | 642 | */ |
8b9ef005 | 643 | void SetAlignment(int hAlign, int vAlign); |
23324ae1 FM |
644 | |
645 | /** | |
8b9ef005 | 646 | Sets the background colour. |
23324ae1 | 647 | */ |
8b9ef005 | 648 | void SetBackgroundColour(const wxColour& colBack); |
23324ae1 FM |
649 | |
650 | /** | |
8b9ef005 | 651 | @todo Needs documentation. |
23324ae1 | 652 | */ |
8b9ef005 | 653 | void SetDefAttr(wxGridCellAttr* defAttr); |
23324ae1 FM |
654 | |
655 | /** | |
8b9ef005 | 656 | Sets the editor to be used with the cells with this attribute. |
23324ae1 | 657 | */ |
8b9ef005 | 658 | void SetEditor(wxGridCellEditor* editor); |
23324ae1 FM |
659 | |
660 | /** | |
8b9ef005 | 661 | Sets the font. |
23324ae1 | 662 | */ |
8b9ef005 | 663 | void SetFont(const wxFont& font); |
23324ae1 FM |
664 | |
665 | /** | |
8b9ef005 | 666 | Sets the cell as read-only. |
23324ae1 | 667 | */ |
8b9ef005 | 668 | void SetReadOnly(bool isReadOnly = true); |
23324ae1 FM |
669 | |
670 | /** | |
8b9ef005 BP |
671 | Sets the renderer to be used for cells with this attribute. Takes |
672 | ownership of the pointer. | |
23324ae1 | 673 | */ |
8b9ef005 | 674 | void SetRenderer(wxGridCellRenderer* renderer); |
5e6e278d FM |
675 | |
676 | /** | |
8b9ef005 | 677 | Sets the text colour. |
5e6e278d | 678 | */ |
8b9ef005 | 679 | void SetTextColour(const wxColour& colText); |
23324ae1 FM |
680 | }; |
681 | ||
ba9574c3 VZ |
682 | /** |
683 | Base class for corner window renderer. | |
684 | ||
685 | This is the simplest of all header renderers and only has a single | |
686 | function. | |
687 | ||
688 | @see wxGridCellAttrProvider::GetCornerRenderer() | |
689 | ||
690 | @since 2.9.1 | |
691 | */ | |
692 | class wxGridCornerHeaderRenderer | |
693 | { | |
694 | public: | |
695 | /** | |
696 | Called by the grid to draw the corner window border. | |
697 | ||
698 | This method is responsible for drawing the border inside the given @a | |
699 | rect and adjusting the rectangle size to correspond to the area inside | |
700 | the border, i.e. usually call wxRect::Deflate() to account for the | |
701 | border width. | |
702 | ||
703 | @param grid | |
704 | The grid whose corner window is being drawn. | |
705 | @param dc | |
706 | The device context to use for drawing. | |
707 | @param rect | |
708 | Input/output parameter which contains the border rectangle on input | |
709 | and should be updated to contain the area inside the border on | |
710 | function return. | |
711 | */ | |
712 | virtual void DrawBorder(const wxGrid& grid, | |
713 | wxDC& dc, | |
714 | wxRect& rect) const = 0; | |
715 | }; | |
716 | /** | |
717 | Common base class for row and column headers renderers. | |
718 | ||
719 | @see wxGridColumnHeaderRenderer, wxGridRowHeaderRenderer | |
720 | ||
721 | @since 2.9.1 | |
722 | */ | |
723 | class wxGridHeaderLabelsRenderer : public wxGridCornerHeaderRenderer | |
724 | { | |
725 | public: | |
726 | /** | |
727 | Called by the grid to draw the specified label. | |
728 | ||
729 | Notice that the base class DrawBorder() method is called before this | |
730 | one. | |
731 | ||
732 | The default implementation uses wxGrid::GetLabelTextColour() and | |
733 | wxGrid::GetLabelFont() to draw the label. | |
734 | */ | |
735 | virtual void DrawLabel(const wxGrid& grid, | |
736 | wxDC& dc, | |
737 | const wxString& value, | |
738 | const wxRect& rect, | |
739 | int horizAlign, | |
740 | int vertAlign, | |
741 | int textOrientation) const; | |
742 | }; | |
743 | ||
744 | /** | |
745 | Base class for row headers renderer. | |
746 | ||
747 | This is the same as wxGridHeaderLabelsRenderer currently but we still use a | |
748 | separate class for it to distinguish it from wxGridColumnHeaderRenderer. | |
749 | ||
750 | @see wxGridRowHeaderRendererDefault | |
751 | ||
752 | @see wxGridCellAttrProvider::GetRowHeaderRenderer() | |
753 | ||
754 | @since 2.9.1 | |
755 | */ | |
756 | class wxGridRowHeaderRenderer : public wxGridHeaderLabelsRenderer | |
757 | { | |
758 | }; | |
759 | ||
760 | /** | |
761 | Base class for column headers renderer. | |
762 | ||
763 | This is the same as wxGridHeaderLabelsRenderer currently but we still use a | |
764 | separate class for it to distinguish it from wxGridRowHeaderRenderer. | |
765 | ||
766 | @see wxGridColumnHeaderRendererDefault | |
767 | ||
768 | @see wxGridCellAttrProvider::GetColumnHeaderRenderer() | |
769 | ||
770 | @since 2.9.1 | |
771 | */ | |
772 | class wxGridColumnHeaderRenderer : public wxGridHeaderLabelsRenderer | |
773 | { | |
774 | }; | |
775 | ||
776 | /** | |
777 | Default row header renderer. | |
778 | ||
779 | You may derive from this class if you need to only override one of its | |
780 | methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the | |
781 | default implementation for the other one. | |
782 | ||
783 | @see wxGridColumnHeaderRendererDefault | |
784 | ||
785 | @since 2.9.1 | |
786 | */ | |
163bd4f7 | 787 | class wxGridRowHeaderRendererDefault : public wxGridRowHeaderRenderer |
ba9574c3 VZ |
788 | { |
789 | public: | |
790 | /// Implement border drawing for the row labels. | |
791 | virtual void DrawBorder(const wxGrid& grid, | |
792 | wxDC& dc, | |
793 | wxRect& rect) const; | |
794 | }; | |
795 | ||
796 | /** | |
797 | Default column header renderer. | |
798 | ||
799 | @see wxGridRowHeaderRendererDefault | |
800 | ||
801 | @since 2.9.1 | |
802 | */ | |
803 | class wxGridColumnHeaderRendererDefault : public wxGridColumnHeaderRenderer | |
804 | { | |
805 | public: | |
806 | /// Implement border drawing for the column labels. | |
807 | virtual void DrawBorder(const wxGrid& grid, | |
808 | wxDC& dc, | |
809 | wxRect& rect) const; | |
810 | }; | |
811 | ||
812 | /** | |
813 | Default corner window renderer. | |
814 | ||
815 | @see wxGridColumnHeaderRendererDefault, wxGridRowHeaderRendererDefault | |
816 | ||
817 | @since 2.9.1 | |
818 | */ | |
819 | class wxGridCornerHeaderRendererDefault : public wxGridCornerHeaderRenderer | |
820 | { | |
821 | public: | |
822 | /// Implement border drawing for the corner window. | |
823 | virtual void DrawBorder(const wxGrid& grid, | |
824 | wxDC& dc, | |
825 | wxRect& rect) const; | |
826 | }; | |
827 | ||
62960a2c VZ |
828 | /** |
829 | Class providing attributes to be used for the grid cells. | |
830 | ||
831 | This class both defines an interface which grid cell attributes providers | |
832 | should implement -- and which can be implemented differently in derived | |
833 | classes -- and a default implementation of this interface which is often | |
834 | good enough to be used without modification, especially with not very large | |
835 | grids for which the efficiency of attributes storage hardly matters (see | |
836 | the discussion below). | |
837 | ||
838 | An object of this class can be associated with a wxGrid using | |
839 | wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you | |
840 | intend to use the default provider as it is used by wxGridTableBase by | |
841 | default anyhow. | |
842 | ||
843 | Notice that while attributes provided by this class can be set for | |
844 | individual cells using SetAttr() or the entire rows or columns using | |
845 | SetRowAttr() and SetColAttr() they are always retrieved using GetAttr() | |
846 | function. | |
847 | ||
848 | ||
849 | The default implementation of this class stores the attributes passed to | |
850 | its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A | |
851 | derived class may use its knowledge about how the attributes are used in | |
852 | your program to implement it much more efficiently: for example, using a | |
853 | special background colour for all even-numbered rows can be implemented by | |
854 | simply returning the same attribute from GetAttr() if the row number is | |
855 | even instead of having to store N/2 row attributes where N is the total | |
856 | number of rows in the grid. | |
857 | ||
858 | Notice that objects of this class can't be copied. | |
859 | */ | |
860 | class wxGridCellAttrProvider : public wxClientDataContainer | |
861 | { | |
862 | public: | |
863 | /// Trivial default constructor. | |
864 | wxGridCellAttrProvider(); | |
865 | ||
866 | /// Destructor releases any attributes held by this class. | |
867 | virtual ~wxGridCellAttrProvider(); | |
868 | ||
869 | /** | |
870 | Get the attribute to use for the specified cell. | |
871 | ||
872 | If wxGridCellAttr::Any is used as @a kind value, this function combines | |
873 | the attributes set for this cell using SetAttr() and those for its row | |
874 | or column (set with SetRowAttr() or SetColAttr() respectively), with | |
875 | the cell attribute having the highest precedence. | |
876 | ||
877 | Notice that the caller must call DecRef() on the returned pointer if it | |
878 | is non-@NULL. | |
879 | ||
880 | @param row | |
881 | The row of the cell. | |
882 | @param col | |
883 | The column of the cell. | |
884 | @param kind | |
885 | The kind of the attribute to return. | |
886 | @return | |
887 | The attribute to use which should be DecRef()'d by caller or @NULL | |
888 | if no attributes are defined for this cell. | |
889 | */ | |
890 | virtual wxGridCellAttr *GetAttr(int row, int col, | |
891 | wxGridCellAttr::wxAttrKind kind) const; | |
892 | ||
893 | /** | |
894 | Setting attributes. | |
895 | ||
896 | All these functions take ownership of the attribute passed to them, | |
897 | i.e. will call DecRef() on it themselves later and so it should not be | |
898 | destroyed by the caller. And the attribute can be @NULL to reset a | |
899 | previously set value. | |
900 | */ | |
901 | //@{ | |
902 | ||
903 | /// Set attribute for the specified cell. | |
904 | virtual void SetAttr(wxGridCellAttr *attr, int row, int col); | |
905 | ||
906 | /// Set attribute for the specified row. | |
907 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); | |
908 | ||
909 | /// Set attribute for the specified column. | |
910 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
911 | ||
912 | //@} | |
ba9574c3 VZ |
913 | |
914 | /** | |
915 | Getting header renderers. | |
916 | ||
917 | These functions return the renderers for the given row or column header | |
918 | label and the corner window. Unlike cell attributes, these objects are | |
919 | not reference counted and are never @NULL so they are returned by | |
920 | reference and not pointer and DecRef() shouldn't (and can't) be called | |
921 | for them. | |
922 | ||
923 | All these functions were added in wxWidgets 2.9.1. | |
924 | */ | |
925 | //@{ | |
926 | ||
927 | /** | |
928 | Return the renderer used for drawing column headers. | |
929 | ||
930 | By default wxGridColumnHeaderRendererDefault is returned. | |
931 | ||
932 | @see wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader() | |
933 | ||
934 | @since 2.9.1 | |
935 | */ | |
936 | virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col); | |
937 | ||
938 | /** | |
939 | Return the renderer used for drawing row headers. | |
940 | ||
941 | By default wxGridRowHeaderRendererDefault is returned. | |
942 | ||
943 | @since 2.9.1 | |
944 | */ | |
945 | virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row); | |
946 | ||
947 | /** | |
948 | Return the renderer used for drawing the corner window. | |
949 | ||
950 | By default wxGridCornerHeaderRendererDefault is returned. | |
951 | ||
952 | @since 2.9.1 | |
953 | */ | |
954 | virtual const wxGridCornerHeaderRenderer& GetCornerRenderer(); | |
955 | ||
956 | //@} | |
62960a2c | 957 | }; |
23324ae1 | 958 | |
e54c96f1 | 959 | |
23324ae1 | 960 | /** |
8b9ef005 | 961 | @class wxGridTableBase |
7c913512 | 962 | |
8b9ef005 BP |
963 | The almost abstract base class for grid tables. |
964 | ||
965 | A grid table is responsible for storing the grid data and, indirectly, grid | |
966 | cell attributes. The data can be stored in the way most convenient for the | |
967 | application but has to be provided in string form to wxGrid. It is also | |
968 | possible to provide cells values in other formats if appropriate, e.g. as | |
969 | numbers. | |
970 | ||
971 | This base class is not quite abstract as it implements a trivial strategy | |
972 | for storing the attributes by forwarding it to wxGridCellAttrProvider and | |
973 | also provides stubs for some other functions. However it does have a number | |
974 | of pure virtual methods which must be implemented in the derived classes. | |
975 | ||
976 | @see wxGridStringTable | |
7c913512 | 977 | |
23324ae1 | 978 | @library{wxadv} |
42b5841f | 979 | @category{grid} |
23324ae1 | 980 | */ |
8b9ef005 | 981 | class wxGridTableBase : public wxObject |
23324ae1 FM |
982 | { |
983 | public: | |
984 | /** | |
985 | Default constructor. | |
8b9ef005 BP |
986 | */ |
987 | wxGridTableBase(); | |
23324ae1 FM |
988 | |
989 | /** | |
8b9ef005 BP |
990 | Destructor frees the attribute provider if it was created. |
991 | */ | |
992 | virtual ~wxGridTableBase(); | |
23324ae1 | 993 | |
8b9ef005 BP |
994 | /** |
995 | Must be overridden to return the number of rows in the table. | |
e54c96f1 | 996 | |
8b9ef005 BP |
997 | For backwards compatibility reasons, this method is not const. |
998 | Use GetRowsCount() instead of it in const methods of derived table | |
999 | classes. | |
1000 | */ | |
1001 | virtual int GetNumberRows() = 0; | |
7c913512 | 1002 | |
8b9ef005 BP |
1003 | /** |
1004 | Must be overridden to return the number of columns in the table. | |
7c913512 | 1005 | |
8b9ef005 BP |
1006 | For backwards compatibility reasons, this method is not const. |
1007 | Use GetColsCount() instead of it in const methods of derived table | |
1008 | classes, | |
1009 | */ | |
1010 | virtual int GetNumberCols() = 0; | |
7c913512 | 1011 | |
23324ae1 | 1012 | /** |
8b9ef005 | 1013 | Return the number of rows in the table. |
23324ae1 | 1014 | |
8b9ef005 BP |
1015 | This method is not virtual and is only provided as a convenience for |
1016 | the derived classes which can't call GetNumberRows() without a | |
1017 | @c const_cast from their const methods. | |
1018 | */ | |
1019 | int GetRowsCount() const; | |
23324ae1 | 1020 | |
8b9ef005 BP |
1021 | /** |
1022 | Return the number of columns in the table. | |
e54c96f1 | 1023 | |
8b9ef005 BP |
1024 | This method is not virtual and is only provided as a convenience for |
1025 | the derived classes which can't call GetNumberCols() without a | |
1026 | @c const_cast from their const methods. | |
1027 | */ | |
1028 | int GetColsCount() const; | |
7c913512 | 1029 | |
7c913512 | 1030 | |
23324ae1 | 1031 | /** |
8b9ef005 BP |
1032 | @name Table Cell Accessors |
1033 | */ | |
1034 | //@{ | |
23324ae1 FM |
1035 | |
1036 | /** | |
8acad210 VZ |
1037 | May be overridden to implement testing for empty cells. |
1038 | ||
1039 | This method is used by the grid to test if the given cell is not used | |
1040 | and so whether a neighbouring cell may overflow into it. By default it | |
1041 | only returns true if the value of the given cell, as returned by | |
1042 | GetValue(), is empty. | |
8b9ef005 | 1043 | */ |
8acad210 | 1044 | virtual bool IsEmptyCell(int row, int col); |
e54c96f1 | 1045 | |
8b9ef005 BP |
1046 | /** |
1047 | Same as IsEmptyCell() but taking wxGridCellCoords. | |
7c913512 | 1048 | |
8b9ef005 BP |
1049 | Notice that this method is not virtual, only IsEmptyCell() should be |
1050 | overridden. | |
1051 | */ | |
1052 | bool IsEmpty(const wxGridCellCoords& coords); | |
7c913512 | 1053 | |
afe0e400 | 1054 | /** |
8b9ef005 BP |
1055 | Must be overridden to implement accessing the table values as text. |
1056 | */ | |
1057 | virtual wxString GetValue(int row, int col) = 0; | |
23324ae1 FM |
1058 | |
1059 | /** | |
8b9ef005 BP |
1060 | Must be overridden to implement setting the table values as text. |
1061 | */ | |
1062 | virtual void SetValue(int row, int col, const wxString& value) = 0; | |
23324ae1 FM |
1063 | |
1064 | /** | |
8b9ef005 | 1065 | Returns the type of the value in the given cell. |
23324ae1 | 1066 | |
8b9ef005 BP |
1067 | By default all cells are strings and this method returns |
1068 | @c wxGRID_VALUE_STRING. | |
1069 | */ | |
1070 | virtual wxString GetTypeName(int row, int col); | |
23324ae1 FM |
1071 | |
1072 | /** | |
8b9ef005 BP |
1073 | Returns true if the value of the given cell can be accessed as if it |
1074 | were of the specified type. | |
23324ae1 | 1075 | |
8b9ef005 BP |
1076 | By default the cells can only be accessed as strings. Note that a cell |
1077 | could be accessible in different ways, e.g. a numeric cell may return | |
1078 | @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING | |
1079 | indicating that the value can be coerced to a string form. | |
1080 | */ | |
1081 | virtual bool CanGetValueAs(int row, int col, const wxString& typeName); | |
23324ae1 FM |
1082 | |
1083 | /** | |
8b9ef005 BP |
1084 | Returns true if the value of the given cell can be set as if it were of |
1085 | the specified type. | |
23324ae1 | 1086 | |
8b9ef005 BP |
1087 | @see CanGetValueAs() |
1088 | */ | |
1089 | virtual bool CanSetValueAs(int row, int col, const wxString& typeName); | |
e54c96f1 | 1090 | |
8b9ef005 BP |
1091 | /** |
1092 | Returns the value of the given cell as a long. | |
7c913512 | 1093 | |
8b9ef005 BP |
1094 | This should only be called if CanGetValueAs() returns @true when called |
1095 | with @c wxGRID_VALUE_NUMBER argument. Default implementation always | |
1096 | return 0. | |
1097 | */ | |
1098 | virtual long GetValueAsLong(int row, int col); | |
7c913512 | 1099 | |
afe0e400 | 1100 | /** |
8b9ef005 | 1101 | Returns the value of the given cell as a double. |
23324ae1 | 1102 | |
8b9ef005 BP |
1103 | This should only be called if CanGetValueAs() returns @true when called |
1104 | with @c wxGRID_VALUE_FLOAT argument. Default implementation always | |
1105 | return 0.0. | |
1106 | */ | |
1107 | virtual double GetValueAsDouble(int row, int col); | |
23324ae1 FM |
1108 | |
1109 | /** | |
8b9ef005 | 1110 | Returns the value of the given cell as a boolean. |
23324ae1 | 1111 | |
8b9ef005 BP |
1112 | This should only be called if CanGetValueAs() returns @true when called |
1113 | with @c wxGRID_VALUE_BOOL argument. Default implementation always | |
1114 | return false. | |
1115 | */ | |
1116 | virtual bool GetValueAsBool(int row, int col); | |
23324ae1 FM |
1117 | |
1118 | /** | |
8b9ef005 BP |
1119 | Returns the value of the given cell as a user-defined type. |
1120 | ||
1121 | This should only be called if CanGetValueAs() returns @true when called | |
1122 | with @a typeName. Default implementation always return @NULL. | |
1123 | */ | |
1124 | virtual void *GetValueAsCustom(int row, int col, const wxString& typeName); | |
23324ae1 FM |
1125 | |
1126 | /** | |
8b9ef005 BP |
1127 | Sets the value of the given cell as a long. |
1128 | ||
1129 | This should only be called if CanSetValueAs() returns @true when called | |
1130 | with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do | |
1131 | anything. | |
1132 | */ | |
1133 | virtual void SetValueAsLong(int row, int col, long value); | |
23324ae1 FM |
1134 | |
1135 | /** | |
8b9ef005 BP |
1136 | Sets the value of the given cell as a double. |
1137 | ||
1138 | This should only be called if CanSetValueAs() returns @true when called | |
1139 | with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do | |
1140 | anything. | |
1141 | */ | |
1142 | virtual void SetValueAsDouble(int row, int col, double value); | |
23324ae1 FM |
1143 | |
1144 | /** | |
8b9ef005 BP |
1145 | Sets the value of the given cell as a boolean. |
1146 | ||
1147 | This should only be called if CanSetValueAs() returns @true when called | |
1148 | with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do | |
1149 | anything. | |
1150 | */ | |
1151 | virtual void SetValueAsBool( int row, int col, bool value ); | |
23324ae1 FM |
1152 | |
1153 | /** | |
8b9ef005 BP |
1154 | Sets the value of the given cell as a user-defined type. |
1155 | ||
1156 | This should only be called if CanSetValueAs() returns @true when called | |
1157 | with @a typeName. Default implementation doesn't do anything. | |
1158 | */ | |
1159 | virtual void SetValueAsCustom(int row, int col, const wxString& typeName, | |
1160 | void *value); | |
1161 | ||
1162 | //@} | |
1163 | ||
23324ae1 FM |
1164 | |
1165 | /** | |
8b9ef005 BP |
1166 | Called by the grid when the table is associated with it. |
1167 | ||
1168 | The default implementation stores the pointer and returns it from its | |
1169 | GetView() and so only makes sense if the table cannot be associated | |
1170 | with more than one grid at a time. | |
1171 | */ | |
1172 | virtual void SetView(wxGrid *grid); | |
23324ae1 FM |
1173 | |
1174 | /** | |
8b9ef005 BP |
1175 | Returns the last grid passed to SetView(). |
1176 | */ | |
1177 | virtual wxGrid *GetView() const; | |
1178 | ||
23324ae1 FM |
1179 | |
1180 | /** | |
8b9ef005 | 1181 | @name Table Structure Modifiers |
23324ae1 | 1182 | |
8b9ef005 BP |
1183 | Notice that none of these functions are pure virtual as they don't have |
1184 | to be implemented if the table structure is never modified after | |
1185 | creation, i.e. neither rows nor columns are never added or deleted but | |
1186 | that you do need to implement them if they are called, i.e. if your | |
1187 | code either calls them directly or uses the matching wxGrid methods, as | |
1188 | by default they simply do nothing which is definitely inappropriate. | |
1189 | */ | |
1190 | //@{ | |
23324ae1 | 1191 | |
8b9ef005 BP |
1192 | /** |
1193 | Clear the table contents. | |
e54c96f1 | 1194 | |
8b9ef005 BP |
1195 | This method is used by wxGrid::ClearGrid(). |
1196 | */ | |
1197 | virtual void Clear(); | |
7c913512 | 1198 | |
8b9ef005 BP |
1199 | /** |
1200 | Insert additional rows into the table. | |
7c913512 | 1201 | |
8b9ef005 BP |
1202 | @param pos |
1203 | The position of the first new row. | |
1204 | @param numRows | |
1205 | The number of rows to insert. | |
1206 | */ | |
1207 | virtual bool InsertRows(size_t pos = 0, size_t numRows = 1); | |
7c913512 | 1208 | |
23324ae1 | 1209 | /** |
8b9ef005 BP |
1210 | Append additional rows at the end of the table. |
1211 | ||
1212 | This method is provided in addition to InsertRows() as some data models | |
1213 | may only support appending rows to them but not inserting them at | |
1214 | arbitrary locations. In such case you may implement this method only | |
1215 | and leave InsertRows() unimplemented. | |
1216 | ||
1217 | @param numRows | |
1218 | The number of rows to add. | |
1219 | */ | |
1220 | virtual bool AppendRows(size_t numRows = 1); | |
23324ae1 FM |
1221 | |
1222 | /** | |
8b9ef005 | 1223 | Delete rows from the table. |
afe0e400 | 1224 | |
8b9ef005 BP |
1225 | @param pos |
1226 | The first row to delete. | |
1227 | @param numRows | |
1228 | The number of rows to delete. | |
1229 | */ | |
1230 | virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1); | |
1231 | ||
1232 | /** | |
1233 | Exactly the same as InsertRows() but for columns. | |
1234 | */ | |
1235 | virtual bool InsertCols(size_t pos = 0, size_t numCols = 1); | |
23324ae1 FM |
1236 | |
1237 | /** | |
8b9ef005 BP |
1238 | Exactly the same as AppendRows() but for columns. |
1239 | */ | |
1240 | virtual bool AppendCols(size_t numCols = 1); | |
23324ae1 | 1241 | |
8b9ef005 BP |
1242 | /** |
1243 | Exactly the same as DeleteRows() but for columns. | |
1244 | */ | |
1245 | virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1); | |
e54c96f1 | 1246 | |
8b9ef005 | 1247 | //@} |
7c913512 | 1248 | |
8b9ef005 BP |
1249 | /** |
1250 | @name Table Row and Column Labels | |
7c913512 | 1251 | |
8b9ef005 BP |
1252 | By default the numbers are used for labeling rows and Latin letters for |
1253 | labeling columns. If the table has more than 26 columns, the pairs of | |
1254 | letters are used starting from the 27-th one and so on, i.e. the | |
1255 | sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ, | |
1256 | AAA, ... | |
1257 | */ | |
1258 | //@{ | |
7c913512 | 1259 | |
23324ae1 | 1260 | /** |
8b9ef005 BP |
1261 | Return the label of the specified row. |
1262 | */ | |
1263 | virtual wxString GetRowLabelValue(int row); | |
23324ae1 | 1264 | |
8b9ef005 BP |
1265 | /** |
1266 | Return the label of the specified column. | |
1267 | */ | |
1268 | virtual wxString GetColLabelValue(int col); | |
5e6e278d | 1269 | |
23324ae1 | 1270 | /** |
8b9ef005 | 1271 | Set the given label for the specified row. |
5e6e278d | 1272 | |
8b9ef005 BP |
1273 | The default version does nothing, i.e. the label is not stored. You |
1274 | must override this method in your derived class if you wish | |
1275 | wxGrid::SetRowLabelValue() to work. | |
1276 | */ | |
1277 | virtual void SetRowLabelValue(int row, const wxString& label); | |
23324ae1 FM |
1278 | |
1279 | /** | |
8b9ef005 BP |
1280 | Exactly the same as SetRowLabelValue() but for columns. |
1281 | */ | |
1282 | virtual void SetColLabelValue(int col, const wxString& label); | |
23324ae1 | 1283 | |
8b9ef005 | 1284 | //@} |
23324ae1 FM |
1285 | |
1286 | ||
8b9ef005 BP |
1287 | /** |
1288 | @name Attributes Management | |
e54c96f1 | 1289 | |
8b9ef005 BP |
1290 | By default the attributes management is delegated to |
1291 | wxGridCellAttrProvider class. You may override the methods in this | |
1292 | section to handle the attributes directly if, for example, they can be | |
1293 | computed from the cell values. | |
1294 | */ | |
1295 | //@{ | |
7c913512 | 1296 | |
8b9ef005 BP |
1297 | /** |
1298 | Associate this attributes provider with the table. | |
7c913512 | 1299 | |
8b9ef005 BP |
1300 | The table takes ownership of @a attrProvider pointer and will delete it |
1301 | when it doesn't need it any more. The pointer can be @NULL, however | |
1302 | this won't disable attributes management in the table but will just | |
1303 | result in a default attributes being recreated the next time any of the | |
1304 | other functions in this section is called. To completely disable the | |
1305 | attributes support, should this be needed, you need to override | |
1306 | CanHaveAttributes() to return @false. | |
1307 | */ | |
1308 | void SetAttrProvider(wxGridCellAttrProvider *attrProvider); | |
afe0e400 | 1309 | |
23324ae1 | 1310 | /** |
8b9ef005 | 1311 | Returns the attribute provider currently being used. |
23324ae1 | 1312 | |
8b9ef005 BP |
1313 | This function may return @NULL if the attribute provider hasn't been |
1314 | neither associated with this table by SetAttrProvider() nor created on | |
1315 | demand by any other methods. | |
1316 | */ | |
1317 | wxGridCellAttrProvider *GetAttrProvider() const; | |
23324ae1 FM |
1318 | |
1319 | /** | |
8b9ef005 | 1320 | Return the attribute for the given cell. |
23324ae1 | 1321 | |
8b9ef005 BP |
1322 | By default this function is simply forwarded to |
1323 | wxGridCellAttrProvider::GetAttr() but it may be overridden to handle | |
1324 | attributes directly in the table. | |
1325 | */ | |
1326 | virtual wxGridCellAttr *GetAttr(int row, int col, | |
1327 | wxGridCellAttr::wxAttrKind kind); | |
23324ae1 FM |
1328 | |
1329 | /** | |
8b9ef005 | 1330 | Set attribute of the specified cell. |
23324ae1 | 1331 | |
8b9ef005 BP |
1332 | By default this function is simply forwarded to |
1333 | wxGridCellAttrProvider::SetAttr(). | |
1334 | ||
1335 | The table takes ownership of @a attr, i.e. will call DecRef() on it. | |
1336 | */ | |
1337 | virtual void SetAttr(wxGridCellAttr* attr, int row, int col); | |
23324ae1 FM |
1338 | |
1339 | /** | |
8b9ef005 | 1340 | Set attribute of the specified row. |
23324ae1 | 1341 | |
8b9ef005 BP |
1342 | By default this function is simply forwarded to |
1343 | wxGridCellAttrProvider::SetRowAttr(). | |
23324ae1 | 1344 | |
8b9ef005 BP |
1345 | The table takes ownership of @a attr, i.e. will call DecRef() on it. |
1346 | */ | |
1347 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); | |
e54c96f1 | 1348 | |
8b9ef005 BP |
1349 | /** |
1350 | Set attribute of the specified column. | |
7c913512 | 1351 | |
8b9ef005 BP |
1352 | By default this function is simply forwarded to |
1353 | wxGridCellAttrProvider::SetColAttr(). | |
7c913512 | 1354 | |
8b9ef005 BP |
1355 | The table takes ownership of @a attr, i.e. will call DecRef() on it. |
1356 | */ | |
1357 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
1358 | ||
1359 | //@} | |
7c913512 | 1360 | |
23324ae1 | 1361 | /** |
8b9ef005 BP |
1362 | Returns true if this table supports attributes or false otherwise. |
1363 | ||
1364 | By default, the table automatically creates a wxGridCellAttrProvider | |
1365 | when this function is called if it had no attribute provider before and | |
1366 | returns @true. | |
1367 | */ | |
1368 | virtual bool CanHaveAttributes(); | |
23324ae1 FM |
1369 | }; |
1370 | ||
574e1c5a VZ |
1371 | /** |
1372 | @class wxGridSizesInfo | |
1373 | ||
1374 | wxGridSizesInfo stores information about sizes of all wxGrid rows or | |
d455444a | 1375 | columns. |
574e1c5a VZ |
1376 | |
1377 | It assumes that most of the rows or columns (which are both called elements | |
1378 | here as the difference between them doesn't matter at this class level) | |
1379 | have the default size and so stores it separately. And it uses a wxHashMap | |
1380 | to store the sizes of all elements which have the non-default size. | |
1381 | ||
1382 | This structure is particularly useful for serializing the sizes of all | |
1383 | wxGrid elements at once. | |
1384 | ||
1385 | @library{wxadv} | |
1386 | @category{grid} | |
1387 | */ | |
1388 | struct wxGridSizesInfo | |
1389 | { | |
1390 | /** | |
1391 | Default constructor. | |
1392 | ||
1393 | m_sizeDefault and m_customSizes must be initialized later. | |
1394 | */ | |
1395 | wxGridSizesInfo(); | |
1396 | ||
1397 | /** | |
1398 | Constructor. | |
1399 | ||
1400 | This constructor is used by wxGrid::GetRowSizes() and GetColSizes() | |
1401 | methods. User code will usually use the default constructor instead. | |
1402 | ||
1403 | @param defSize | |
1404 | The default element size. | |
d455444a | 1405 | @param allSizes |
574e1c5a VZ |
1406 | Array containing the sizes of @em all elements, including those |
1407 | which have the default size. | |
1408 | */ | |
1409 | wxGridSizesInfo(int defSize, const wxArrayInt& allSizes); | |
1410 | ||
1411 | /** | |
1412 | Get the element size. | |
1413 | ||
1414 | @param pos | |
1415 | The index of the element. | |
1416 | @return | |
1417 | The size for this element, using m_customSizes if @a pos is in it | |
1418 | or m_sizeDefault otherwise. | |
1419 | */ | |
1420 | int GetSize(unsigned pos) const; | |
1421 | ||
1422 | ||
1423 | /// Default size | |
1424 | int m_sizeDefault; | |
1425 | ||
1426 | /** | |
1427 | Map with element indices as keys and their sizes as values. | |
1428 | ||
1429 | This map only contains the elements with non-default size. | |
1430 | */ | |
1431 | wxUnsignedToIntHashMap m_customSizes; | |
1432 | }; | |
23324ae1 | 1433 | |
e54c96f1 | 1434 | |
23324ae1 | 1435 | /** |
8b9ef005 | 1436 | @class wxGrid |
7c913512 | 1437 | |
8b9ef005 | 1438 | wxGrid and its related classes are used for displaying and editing tabular |
caac7804 BP |
1439 | data. They provide a rich set of features for display, editing, and |
1440 | interacting with a variety of data sources. For simple applications, and to | |
1441 | help you get started, wxGrid is the only class you need to refer to | |
1442 | directly. It will set up default instances of the other classes and manage | |
1443 | them for you. For more complex applications you can derive your own classes | |
1444 | for custom grid views, grid data tables, cell editors and renderers. The | |
1445 | @ref overview_grid has examples of simple and more complex applications, | |
8b9ef005 BP |
1446 | explains the relationship between the various grid classes and has a |
1447 | summary of the keyboard shortcuts and mouse functions provided by wxGrid. | |
7c913512 | 1448 | |
8b9ef005 BP |
1449 | A wxGridTableBase class holds the actual data to be displayed by a wxGrid |
1450 | class. One or more wxGrid classes may act as a view for one table class. | |
1451 | The default table class is called wxGridStringTable and holds an array of | |
caac7804 | 1452 | strings. An instance of such a class is created by CreateGrid(). |
23324ae1 | 1453 | |
8b9ef005 BP |
1454 | wxGridCellRenderer is the abstract base class for rendereing contents in a |
1455 | cell. The following renderers are predefined: | |
caac7804 BP |
1456 | |
1457 | - wxGridCellBoolRenderer | |
1458 | - wxGridCellFloatRenderer | |
1459 | - wxGridCellNumberRenderer | |
1460 | - wxGridCellStringRenderer | |
1461 | ||
8b9ef005 | 1462 | The look of a cell can be further defined using wxGridCellAttr. An object |
caac7804 | 1463 | of this type may be returned by wxGridTableBase::GetAttr(). |
3c4f71cc | 1464 | |
8b9ef005 BP |
1465 | wxGridCellEditor is the abstract base class for editing the value of a |
1466 | cell. The following editors are predefined: | |
caac7804 BP |
1467 | |
1468 | - wxGridCellBoolEditor | |
1469 | - wxGridCellChoiceEditor | |
1470 | - wxGridCellFloatEditor | |
1471 | - wxGridCellNumberEditor | |
1472 | - wxGridCellTextEditor | |
f8f31de6 | 1473 | |
caac7804 BP |
1474 | Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and |
1475 | wxGridEditorCreatedEvent for the documentation of all event types you can | |
1476 | use with wxGrid. | |
8b9ef005 BP |
1477 | |
1478 | @library{wxadv} | |
1479 | @category{grid} | |
23324ae1 | 1480 | |
caac7804 | 1481 | @see @ref overview_grid, wxGridUpdateLocker |
8b9ef005 BP |
1482 | */ |
1483 | class wxGrid : public wxScrolledWindow | |
1484 | { | |
1485 | public: | |
caac7804 | 1486 | |
23324ae1 | 1487 | /** |
8b9ef005 BP |
1488 | Different selection modes supported by the grid. |
1489 | */ | |
1490 | enum wxGridSelectionModes | |
1491 | { | |
1492 | /** | |
1493 | The default selection mode allowing selection of the individual | |
1494 | cells as well as of the entire rows and columns. | |
1495 | */ | |
1496 | wxGridSelectCells, | |
23324ae1 | 1497 | |
8b9ef005 BP |
1498 | /** |
1499 | The selection mode allowing the selection of the entire rows only. | |
3c4f71cc | 1500 | |
8b9ef005 BP |
1501 | The user won't be able to select any cells or columns in this mode. |
1502 | */ | |
1503 | wxGridSelectRows, | |
23324ae1 | 1504 | |
8b9ef005 BP |
1505 | /** |
1506 | The selection mode allowing the selection of the entire columns only. | |
3c4f71cc | 1507 | |
8b9ef005 BP |
1508 | The user won't be able to select any cells or rows in this mode. |
1509 | */ | |
1510 | wxGridSelectColumns | |
1511 | }; | |
23324ae1 | 1512 | |
ea99e8e3 VZ |
1513 | /** |
1514 | Return values for GetCellSize(). | |
1515 | ||
1516 | @since 2.9.1 | |
1517 | */ | |
1518 | enum CellSpan | |
1519 | { | |
1520 | /// This cell is inside a span covered by another cell. | |
1521 | CellSpan_Inside = -1, | |
1522 | ||
1523 | /// This is a normal, non-spanning cell. | |
1524 | CellSpan_None = 0, | |
1525 | ||
1526 | /// This cell spans several physical wxGrid cells. | |
1527 | CellSpan_Main | |
1528 | }; | |
caac7804 BP |
1529 | |
1530 | /** | |
1531 | @name Constructors and Initialization | |
1532 | */ | |
1533 | //@{ | |
1534 | ||
23324ae1 | 1535 | /** |
8b9ef005 | 1536 | Default constructor. |
3c4f71cc | 1537 | |
8b9ef005 BP |
1538 | You must call Create() to really create the grid window and also call |
1539 | CreateGrid() or SetTable() to initialize the grid contents. | |
1540 | */ | |
1541 | wxGrid(); | |
23324ae1 | 1542 | /** |
8b9ef005 | 1543 | Constructor creating the grid window. |
3c4f71cc | 1544 | |
8b9ef005 BP |
1545 | You must call either CreateGrid() or SetTable() to initialize the grid |
1546 | contents before using it. | |
23324ae1 | 1547 | */ |
caac7804 | 1548 | wxGrid(wxWindow* parent, wxWindowID id, |
8b9ef005 BP |
1549 | const wxPoint& pos = wxDefaultPosition, |
1550 | const wxSize& size = wxDefaultSize, | |
1551 | long style = wxWANTS_CHARS, | |
1552 | const wxString& name = wxGridNameStr); | |
23324ae1 | 1553 | |
caac7804 BP |
1554 | /** |
1555 | Destructor. | |
1556 | ||
1557 | This will also destroy the associated grid table unless you passed a | |
1558 | table object to the grid and specified that the grid should not take | |
1559 | ownership of the table (see SetTable()). | |
1560 | */ | |
1561 | virtual ~wxGrid(); | |
1562 | ||
23324ae1 | 1563 | /** |
8b9ef005 BP |
1564 | Creates the grid window for an object initialized using the default |
1565 | constructor. | |
3c4f71cc | 1566 | |
8b9ef005 BP |
1567 | You must call either CreateGrid() or SetTable() to initialize the grid |
1568 | contents before using it. | |
1569 | */ | |
caac7804 | 1570 | bool Create(wxWindow* parent, wxWindowID id, |
8b9ef005 BP |
1571 | const wxPoint& pos = wxDefaultPosition, |
1572 | const wxSize& size = wxDefaultSize, | |
1573 | long style = wxWANTS_CHARS, | |
1574 | const wxString& name = wxGridNameStr); | |
23324ae1 FM |
1575 | |
1576 | /** | |
caac7804 | 1577 | Creates a grid with the specified initial number of rows and columns. |
3c4f71cc | 1578 | |
caac7804 BP |
1579 | Call this directly after the grid constructor. When you use this |
1580 | function wxGrid will create and manage a simple table of string values | |
1581 | for you. All of the grid data will be stored in memory. | |
1582 | ||
1583 | For applications with more complex data types or relationships, or for | |
1584 | dealing with very large datasets, you should derive your own grid table | |
1585 | class and pass a table object to the grid with SetTable(). | |
23324ae1 | 1586 | */ |
caac7804 BP |
1587 | bool CreateGrid(int numRows, int numCols, |
1588 | wxGridSelectionModes selmode = wxGridSelectCells); | |
23324ae1 FM |
1589 | |
1590 | /** | |
caac7804 | 1591 | Passes a pointer to a custom grid table to be used by the grid. |
3c4f71cc | 1592 | |
caac7804 BP |
1593 | This should be called after the grid constructor and before using the |
1594 | grid object. If @a takeOwnership is set to @true then the table will be | |
1595 | deleted by the wxGrid destructor. | |
3c4f71cc | 1596 | |
caac7804 BP |
1597 | Use this function instead of CreateGrid() when your application |
1598 | involves complex or non-string data or data sets that are too large to | |
1599 | fit wholly in memory. | |
23324ae1 | 1600 | */ |
caac7804 BP |
1601 | bool SetTable(wxGridTableBase* table, bool takeOwnership = false, |
1602 | wxGridSelectionModes selmode = wxGridSelectCells); | |
23324ae1 | 1603 | |
caac7804 | 1604 | //@} |
8b9ef005 | 1605 | |
3c4f71cc | 1606 | |
caac7804 BP |
1607 | /** |
1608 | @name Grid Line Formatting | |
1609 | */ | |
1610 | //@{ | |
1611 | ||
1612 | /** | |
1613 | Turns the drawing of grid lines on or off. | |
23324ae1 | 1614 | */ |
caac7804 | 1615 | void EnableGridLines(bool enable = true); |
23324ae1 FM |
1616 | |
1617 | /** | |
caac7804 | 1618 | Returns the pen used for vertical grid lines. |
3c4f71cc | 1619 | |
caac7804 BP |
1620 | This virtual function may be overridden in derived classes in order to |
1621 | change the appearance of individual grid lines for the given column | |
1622 | @a col. | |
23324ae1 | 1623 | |
caac7804 BP |
1624 | See GetRowGridLinePen() for an example. |
1625 | */ | |
1626 | virtual wxPen GetColGridLinePen(int col); | |
23324ae1 FM |
1627 | |
1628 | /** | |
caac7804 | 1629 | Returns the pen used for grid lines. |
23324ae1 | 1630 | |
caac7804 BP |
1631 | This virtual function may be overridden in derived classes in order to |
1632 | change the appearance of grid lines. Note that currently the pen width | |
1633 | must be 1. | |
3c4f71cc | 1634 | |
caac7804 BP |
1635 | @see GetColGridLinePen(), GetRowGridLinePen() |
1636 | */ | |
1637 | virtual wxPen GetDefaultGridLinePen(); | |
23324ae1 FM |
1638 | |
1639 | /** | |
caac7804 BP |
1640 | Returns the colour used for grid lines. |
1641 | ||
1642 | @see GetDefaultGridLinePen() | |
23324ae1 | 1643 | */ |
caac7804 | 1644 | wxColour GetGridLineColour() const; |
23324ae1 FM |
1645 | |
1646 | /** | |
caac7804 BP |
1647 | Returns the pen used for horizontal grid lines. |
1648 | ||
1649 | This virtual function may be overridden in derived classes in order to | |
1650 | change the appearance of individual grid line for the given @a row. | |
1651 | ||
1652 | Example: | |
1653 | @code | |
1654 | // in a grid displaying music notation, use a solid black pen between | |
1655 | // octaves (C0=row 127, C1=row 115 etc.) | |
1656 | wxPen MidiGrid::GetRowGridLinePen(int row) | |
1657 | { | |
1658 | if ( row % 12 == 7 ) | |
1659 | return wxPen(*wxBLACK, 1, wxSOLID); | |
1660 | else | |
1661 | return GetDefaultGridLinePen(); | |
1662 | } | |
1663 | @endcode | |
23324ae1 | 1664 | */ |
caac7804 | 1665 | virtual wxPen GetRowGridLinePen(int row); |
23324ae1 FM |
1666 | |
1667 | /** | |
caac7804 | 1668 | Returns @true if drawing of grid lines is turned on, @false otherwise. |
23324ae1 | 1669 | */ |
caac7804 | 1670 | bool GridLinesEnabled() const; |
23324ae1 FM |
1671 | |
1672 | /** | |
caac7804 | 1673 | Sets the colour used to draw grid lines. |
23324ae1 | 1674 | */ |
caac7804 BP |
1675 | void SetGridLineColour(const wxColour& colour); |
1676 | ||
1677 | //@} | |
1678 | ||
23324ae1 FM |
1679 | |
1680 | /** | |
caac7804 BP |
1681 | @name Label Values and Formatting |
1682 | */ | |
1683 | //@{ | |
23324ae1 FM |
1684 | |
1685 | /** | |
caac7804 BP |
1686 | Sets the arguments to the current column label alignment values. |
1687 | ||
1688 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE | |
1689 | or @c wxALIGN_RIGHT. | |
1690 | ||
1691 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1692 | @c wxALIGN_BOTTOM. | |
23324ae1 | 1693 | */ |
caac7804 | 1694 | void GetColLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
1695 | |
1696 | /** | |
caac7804 BP |
1697 | Returns the orientation of the column labels (either @c wxHORIZONTAL or |
1698 | @c wxVERTICAL). | |
23324ae1 | 1699 | */ |
caac7804 | 1700 | int GetColLabelTextOrientation() const; |
23324ae1 FM |
1701 | |
1702 | /** | |
caac7804 | 1703 | Returns the specified column label. |
7c913512 | 1704 | |
caac7804 BP |
1705 | The default grid table class provides column labels of the form |
1706 | A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can | |
1707 | override wxGridTableBase::GetColLabelValue() to provide your own | |
1708 | labels. | |
23324ae1 | 1709 | */ |
caac7804 | 1710 | wxString GetColLabelValue(int col) const; |
23324ae1 | 1711 | |
8b9ef005 | 1712 | /** |
caac7804 BP |
1713 | Returns the colour used for the background of row and column labels. |
1714 | */ | |
1715 | wxColour GetLabelBackgroundColour() const; | |
e54c96f1 | 1716 | |
caac7804 BP |
1717 | /** |
1718 | Returns the font used for row and column labels. | |
1719 | */ | |
1720 | wxFont GetLabelFont() const; | |
7c913512 | 1721 | |
caac7804 BP |
1722 | /** |
1723 | Returns the colour used for row and column label text. | |
8b9ef005 | 1724 | */ |
caac7804 | 1725 | wxColour GetLabelTextColour() const; |
7c913512 | 1726 | |
23324ae1 | 1727 | /** |
caac7804 | 1728 | Returns the alignment used for row labels. |
3c4f71cc | 1729 | |
caac7804 BP |
1730 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1731 | or @c wxALIGN_RIGHT. | |
1732 | ||
1733 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1734 | @c wxALIGN_BOTTOM. | |
23324ae1 | 1735 | */ |
caac7804 | 1736 | void GetRowLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
1737 | |
1738 | /** | |
caac7804 | 1739 | Returns the specified row label. |
23324ae1 | 1740 | |
caac7804 BP |
1741 | The default grid table class provides numeric row labels. If you are |
1742 | using a custom grid table you can override | |
1743 | wxGridTableBase::GetRowLabelValue() to provide your own labels. | |
23324ae1 | 1744 | */ |
caac7804 | 1745 | wxString GetRowLabelValue(int row) const; |
23324ae1 FM |
1746 | |
1747 | /** | |
caac7804 BP |
1748 | Hides the column labels by calling SetColLabelSize() with a size of 0. |
1749 | Show labels again by calling that method with a width greater than 0. | |
23324ae1 | 1750 | */ |
caac7804 | 1751 | void HideColLabels(); |
23324ae1 FM |
1752 | |
1753 | /** | |
caac7804 | 1754 | Hides the row labels by calling SetRowLabelSize() with a size of 0. |
23324ae1 | 1755 | |
caac7804 BP |
1756 | The labels can be shown again by calling SetRowLabelSize() with a width |
1757 | greater than 0. | |
23324ae1 | 1758 | */ |
caac7804 | 1759 | void HideRowLabels(); |
23324ae1 FM |
1760 | |
1761 | /** | |
caac7804 | 1762 | Sets the horizontal and vertical alignment of column label text. |
23324ae1 | 1763 | |
caac7804 BP |
1764 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
1765 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one | |
1766 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
23324ae1 | 1767 | */ |
caac7804 | 1768 | void SetColLabelAlignment(int horiz, int vert); |
23324ae1 FM |
1769 | |
1770 | /** | |
caac7804 BP |
1771 | Sets the orientation of the column labels (either @c wxHORIZONTAL or |
1772 | @c wxVERTICAL). | |
8b9ef005 | 1773 | */ |
caac7804 | 1774 | void SetColLabelTextOrientation(int textOrientation); |
7c913512 | 1775 | |
23324ae1 | 1776 | /** |
caac7804 | 1777 | Set the value for the given column label. |
8b9ef005 | 1778 | |
caac7804 BP |
1779 | If you are using a custom grid table you must override |
1780 | wxGridTableBase::SetColLabelValue() for this to have any effect. | |
23324ae1 | 1781 | */ |
caac7804 | 1782 | void SetColLabelValue(int col, const wxString& value); |
23324ae1 FM |
1783 | |
1784 | /** | |
caac7804 | 1785 | Sets the background colour for row and column labels. |
23324ae1 | 1786 | */ |
caac7804 | 1787 | void SetLabelBackgroundColour(const wxColour& colour); |
23324ae1 | 1788 | |
8b9ef005 | 1789 | /** |
caac7804 BP |
1790 | Sets the font for row and column labels. |
1791 | */ | |
1792 | void SetLabelFont(const wxFont& font); | |
55f0bf1f | 1793 | |
8b9ef005 | 1794 | /** |
caac7804 BP |
1795 | Sets the colour for row and column label text. |
1796 | */ | |
1797 | void SetLabelTextColour(const wxColour& colour); | |
55f0bf1f | 1798 | |
8b9ef005 | 1799 | /** |
caac7804 | 1800 | Sets the horizontal and vertical alignment of row label text. |
7c913512 | 1801 | |
caac7804 BP |
1802 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
1803 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one | |
1804 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
8b9ef005 | 1805 | */ |
caac7804 | 1806 | void SetRowLabelAlignment(int horiz, int vert); |
7c913512 | 1807 | |
23324ae1 | 1808 | /** |
caac7804 | 1809 | Sets the value for the given row label. |
55f0bf1f | 1810 | |
caac7804 BP |
1811 | If you are using a derived grid table you must override |
1812 | wxGridTableBase::SetRowLabelValue() for this to have any effect. | |
8b9ef005 | 1813 | */ |
caac7804 | 1814 | void SetRowLabelValue(int row, const wxString& value); |
55f0bf1f | 1815 | |
8b9ef005 | 1816 | /** |
caac7804 | 1817 | Call this in order to make the column labels use a native look by using |
03faec76 | 1818 | wxRendererNative::DrawHeaderButton() internally. |
55f0bf1f | 1819 | |
caac7804 BP |
1820 | There is no equivalent method for drawing row columns as there is not |
1821 | native look for that. This option is useful when using wxGrid for | |
1822 | displaying tables and not as a spread-sheet. | |
ad805b9e | 1823 | |
03faec76 | 1824 | @see UseNativeColHeader() |
8b9ef005 | 1825 | */ |
caac7804 | 1826 | void SetUseNativeColLabels(bool native = true); |
55f0bf1f | 1827 | |
ad805b9e VZ |
1828 | /** |
1829 | Enable the use of native header window for column labels. | |
1830 | ||
1831 | If this function is called with @true argument, a wxHeaderCtrl is used | |
1832 | instead to display the column labels instead of drawing them in wxGrid | |
1833 | code itself. This has the advantage of making the grid look and feel | |
1834 | perfectly the same as native applications (using SetUseNativeColLabels() | |
1835 | the grid can be made to look more natively but it still doesn't feel | |
1836 | natively, notably the column resizing and dragging still works slightly | |
1837 | differently as it is implemented in wxWidgets itself) but results in | |
1838 | different behaviour for column and row headers, for which there is no | |
1839 | equivalent function, and, most importantly, is unsuitable for grids | |
1840 | with huge numbers of columns as wxHeaderCtrl doesn't support virtual | |
1841 | mode. Because of this, by default the grid does not use the native | |
1842 | header control but you should call this function to enable it if you | |
1843 | are using the grid to display tabular data and don't have thousands of | |
1844 | columns in it. | |
1845 | ||
03faec76 FM |
1846 | Also note that currently @c wxEVT_GRID_LABEL_LEFT_DCLICK and |
1847 | @c wxEVT_GRID_LABEL_RIGHT_DCLICK events are not generated for the column | |
ad805b9e VZ |
1848 | labels if the native columns header is used (but this limitation could |
1849 | possibly be lifted in the future). | |
1850 | */ | |
1851 | void UseNativeColHeader(bool native = true); | |
1852 | ||
caac7804 | 1853 | //@} |
55f0bf1f | 1854 | |
55f0bf1f VZ |
1855 | |
1856 | /** | |
caac7804 | 1857 | @name Cell Formatting |
55f0bf1f | 1858 | |
caac7804 BP |
1859 | Note that wxGridCellAttr can be used alternatively to most of these |
1860 | methods. See the "Attributes Management" of wxGridTableBase. | |
1861 | */ | |
1862 | //@{ | |
23324ae1 FM |
1863 | |
1864 | /** | |
caac7804 BP |
1865 | Sets the arguments to the horizontal and vertical text alignment values |
1866 | for the grid cell at the specified location. | |
55f0bf1f | 1867 | |
caac7804 BP |
1868 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1869 | or @c wxALIGN_RIGHT. | |
1870 | ||
1871 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1872 | @c wxALIGN_BOTTOM. | |
8b9ef005 | 1873 | */ |
caac7804 | 1874 | void GetCellAlignment(int row, int col, int* horiz, int* vert) const; |
55f0bf1f VZ |
1875 | |
1876 | /** | |
caac7804 | 1877 | Returns the background colour of the cell at the specified location. |
23324ae1 | 1878 | */ |
caac7804 | 1879 | wxColour GetCellBackgroundColour(int row, int col) const; |
23324ae1 FM |
1880 | |
1881 | /** | |
caac7804 BP |
1882 | Returns the font for text in the grid cell at the specified location. |
1883 | */ | |
1884 | wxFont GetCellFont(int row, int col) const; | |
55f0bf1f | 1885 | |
caac7804 BP |
1886 | /** |
1887 | Returns the text colour for the grid cell at the specified location. | |
23324ae1 | 1888 | */ |
caac7804 | 1889 | wxColour GetCellTextColour(int row, int col) const; |
23324ae1 FM |
1890 | |
1891 | /** | |
caac7804 BP |
1892 | Returns the default cell alignment. |
1893 | ||
1894 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE | |
1895 | or @c wxALIGN_RIGHT. | |
55f0bf1f | 1896 | |
caac7804 BP |
1897 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or |
1898 | @c wxALIGN_BOTTOM. | |
1899 | ||
1900 | @see SetDefaultCellAlignment() | |
8b9ef005 | 1901 | */ |
caac7804 | 1902 | void GetDefaultCellAlignment(int* horiz, int* vert) const; |
55f0bf1f | 1903 | |
8b9ef005 | 1904 | /** |
caac7804 | 1905 | Returns the current default background colour for grid cells. |
23324ae1 | 1906 | */ |
caac7804 | 1907 | wxColour GetDefaultCellBackgroundColour() const; |
23324ae1 | 1908 | |
9f7aee01 | 1909 | /** |
caac7804 | 1910 | Returns the current default font for grid cell text. |
8b9ef005 | 1911 | */ |
caac7804 | 1912 | wxFont GetDefaultCellFont() const; |
9f7aee01 | 1913 | |
8b9ef005 | 1914 | /** |
caac7804 | 1915 | Returns the current default colour for grid cell text. |
8b9ef005 | 1916 | */ |
caac7804 | 1917 | wxColour GetDefaultCellTextColour() const; |
9f7aee01 | 1918 | |
8b9ef005 | 1919 | /** |
caac7804 BP |
1920 | Sets the horizontal and vertical alignment for grid cell text at the |
1921 | specified location. | |
9f7aee01 | 1922 | |
caac7804 BP |
1923 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
1924 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
1925 | ||
1926 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
1927 | or @c wxALIGN_BOTTOM. | |
1928 | */ | |
1929 | void SetCellAlignment(int row, int col, int horiz, int vert); | |
9f7aee01 | 1930 | /** |
caac7804 BP |
1931 | Sets the horizontal and vertical alignment for grid cell text at the |
1932 | specified location. | |
9f7aee01 | 1933 | |
caac7804 BP |
1934 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
1935 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
9f7aee01 | 1936 | |
caac7804 BP |
1937 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE |
1938 | or @c wxALIGN_BOTTOM. | |
8b9ef005 | 1939 | */ |
caac7804 | 1940 | void SetCellAlignment(int align, int row, int col); |
9f7aee01 | 1941 | |
23324ae1 | 1942 | /** |
caac7804 | 1943 | Set the background colour for the given cell or all cells by default. |
23324ae1 | 1944 | */ |
caac7804 | 1945 | void SetCellBackgroundColour(int row, int col, const wxColour& colour); |
23324ae1 FM |
1946 | |
1947 | /** | |
caac7804 BP |
1948 | Sets the font for text in the grid cell at the specified location. |
1949 | */ | |
1950 | void SetCellFont(int row, int col, const wxFont& font); | |
8b9ef005 | 1951 | |
caac7804 BP |
1952 | /** |
1953 | Sets the text colour for the given cell. | |
1954 | */ | |
1955 | void SetCellTextColour(int row, int col, const wxColour& colour); | |
1956 | /** | |
1957 | Sets the text colour for the given cell. | |
1958 | */ | |
1959 | void SetCellTextColour(const wxColour& val, int row, int col); | |
1960 | /** | |
1961 | Sets the text colour for all cells by default. | |
1962 | */ | |
1963 | void SetCellTextColour(const wxColour& colour); | |
8b9ef005 | 1964 | |
caac7804 BP |
1965 | /** |
1966 | Sets the default horizontal and vertical alignment for grid cell text. | |
1967 | ||
1968 | Horizontal alignment should be one of @c wxALIGN_LEFT, | |
1969 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one | |
1970 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
23324ae1 | 1971 | */ |
caac7804 | 1972 | void SetDefaultCellAlignment(int horiz, int vert); |
23324ae1 FM |
1973 | |
1974 | /** | |
caac7804 | 1975 | Sets the default background colour for grid cells. |
23324ae1 | 1976 | */ |
caac7804 | 1977 | void SetDefaultCellBackgroundColour(const wxColour& colour); |
23324ae1 FM |
1978 | |
1979 | /** | |
caac7804 BP |
1980 | Sets the default font to be used for grid cell text. |
1981 | */ | |
1982 | void SetDefaultCellFont(const wxFont& font); | |
8b9ef005 | 1983 | |
caac7804 BP |
1984 | /** |
1985 | Sets the current default colour for grid cell text. | |
23324ae1 | 1986 | */ |
caac7804 BP |
1987 | void SetDefaultCellTextColour(const wxColour& colour); |
1988 | ||
1989 | //@} | |
1990 | ||
1991 | ||
1992 | /** | |
1993 | @name Cell Values, Editors, and Renderers | |
1994 | ||
1995 | Note that wxGridCellAttr can be used alternatively to most of these | |
1996 | methods. See the "Attributes Management" of wxGridTableBase. | |
1997 | */ | |
1998 | //@{ | |
23324ae1 FM |
1999 | |
2000 | /** | |
caac7804 BP |
2001 | Returns @true if the in-place edit control for the current grid cell |
2002 | can be used and @false otherwise. | |
2003 | ||
2004 | This function always returns @false for the read-only cells. | |
23324ae1 | 2005 | */ |
caac7804 | 2006 | bool CanEnableCellControl() const; |
23324ae1 FM |
2007 | |
2008 | /** | |
caac7804 | 2009 | Disables in-place editing of grid cells. |
8b9ef005 | 2010 | |
caac7804 BP |
2011 | Equivalent to calling EnableCellEditControl(@false). |
2012 | */ | |
2013 | void DisableCellEditControl(); | |
8b9ef005 | 2014 | |
caac7804 BP |
2015 | /** |
2016 | Enables or disables in-place editing of grid cell data. | |
2017 | ||
2018 | The grid will issue either a @c wxEVT_GRID_EDITOR_SHOWN or | |
2019 | @c wxEVT_GRID_EDITOR_HIDDEN event. | |
23324ae1 | 2020 | */ |
caac7804 | 2021 | void EnableCellEditControl(bool enable = true); |
23324ae1 FM |
2022 | |
2023 | /** | |
caac7804 BP |
2024 | Makes the grid globally editable or read-only. |
2025 | ||
2026 | If the edit argument is @false this function sets the whole grid as | |
2027 | read-only. If the argument is @true the grid is set to the default | |
2028 | state where cells may be editable. In the default state you can set | |
2029 | single grid cells and whole rows and columns to be editable or | |
2030 | read-only via wxGridCellAttr::SetReadOnly(). For single cells you | |
2031 | can also use the shortcut function SetReadOnly(). | |
2032 | ||
2033 | For more information about controlling grid cell attributes see the | |
2034 | wxGridCellAttr class and the @ref overview_grid. | |
23324ae1 | 2035 | */ |
caac7804 | 2036 | void EnableEditing(bool edit); |
23324ae1 FM |
2037 | |
2038 | /** | |
8b9ef005 | 2039 | Returns a pointer to the editor for the cell at the specified location. |
3c4f71cc | 2040 | |
caac7804 BP |
2041 | See wxGridCellEditor and the @ref overview_grid for more information |
2042 | about cell editors and renderers. | |
3c4f71cc | 2043 | |
8b9ef005 | 2044 | The caller must call DecRef() on the returned pointer. |
23324ae1 | 2045 | */ |
8b9ef005 | 2046 | wxGridCellEditor* GetCellEditor(int row, int col) const; |
23324ae1 | 2047 | |
8b9ef005 BP |
2048 | /** |
2049 | Returns a pointer to the renderer for the grid cell at the specified | |
2050 | location. | |
08dd9b5a | 2051 | |
caac7804 BP |
2052 | See wxGridCellRenderer and the @ref overview_grid for more information |
2053 | about cell editors and renderers. | |
8b9ef005 BP |
2054 | |
2055 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 2056 | */ |
8b9ef005 | 2057 | wxGridCellRenderer* GetCellRenderer(int row, int col) const; |
23324ae1 FM |
2058 | |
2059 | /** | |
caac7804 | 2060 | Returns the string contained in the cell at the specified location. |
23324ae1 | 2061 | |
caac7804 BP |
2062 | For simple applications where a grid object automatically uses a |
2063 | default grid table of string values you use this function together with | |
2064 | SetCellValue() to access cell values. For more complex applications | |
2065 | where you have derived your own grid table class that contains various | |
2066 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2067 | you only use this function for those cells that contain string values. | |
2068 | ||
2069 | See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for | |
2070 | more information. | |
2071 | */ | |
2072 | wxString GetCellValue(int row, int col) const; | |
23324ae1 | 2073 | /** |
8b9ef005 | 2074 | Returns the string contained in the cell at the specified location. |
08dd9b5a | 2075 | |
8b9ef005 BP |
2076 | For simple applications where a grid object automatically uses a |
2077 | default grid table of string values you use this function together with | |
2078 | SetCellValue() to access cell values. For more complex applications | |
2079 | where you have derived your own grid table class that contains various | |
2080 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2081 | you only use this function for those cells that contain string values. | |
2082 | ||
caac7804 BP |
2083 | See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for |
2084 | more information. | |
23324ae1 | 2085 | */ |
882678eb | 2086 | wxString GetCellValue(const wxGridCellCoords& coords) const; |
23324ae1 FM |
2087 | |
2088 | /** | |
caac7804 BP |
2089 | Returns a pointer to the current default grid cell editor. |
2090 | ||
2091 | See wxGridCellEditor and the @ref overview_grid for more information | |
2092 | about cell editors and renderers. | |
23324ae1 | 2093 | */ |
caac7804 | 2094 | wxGridCellEditor* GetDefaultEditor() const; |
23324ae1 FM |
2095 | |
2096 | /** | |
caac7804 | 2097 | Returns the default editor for the specified cell. |
08dd9b5a | 2098 | |
caac7804 BP |
2099 | The base class version returns the editor appropriate for the current |
2100 | cell type but this method may be overridden in the derived classes to | |
2101 | use custom editors for some cells by default. | |
8b9ef005 | 2102 | |
caac7804 BP |
2103 | Notice that the same may be achieved in a usually simpler way by |
2104 | associating a custom editor with the given cell or cells. | |
23324ae1 | 2105 | |
caac7804 BP |
2106 | The caller must call DecRef() on the returned pointer. |
2107 | */ | |
2108 | virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; | |
23324ae1 | 2109 | /** |
caac7804 | 2110 | Returns the default editor for the specified cell. |
08dd9b5a | 2111 | |
caac7804 BP |
2112 | The base class version returns the editor appropriate for the current |
2113 | cell type but this method may be overridden in the derived classes to | |
2114 | use custom editors for some cells by default. | |
8b9ef005 | 2115 | |
caac7804 BP |
2116 | Notice that the same may be achieved in a usually simpler way by |
2117 | associating a custom editor with the given cell or cells. | |
23324ae1 | 2118 | |
caac7804 | 2119 | The caller must call DecRef() on the returned pointer. |
23324ae1 | 2120 | */ |
caac7804 | 2121 | wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const; |
23324ae1 FM |
2122 | |
2123 | /** | |
caac7804 BP |
2124 | Returns the default editor for the cells containing values of the given |
2125 | type. | |
55f0bf1f | 2126 | |
caac7804 BP |
2127 | The base class version returns the editor which was associated with the |
2128 | specified @a typeName when it was registered RegisterDataType() but | |
2129 | this function may be overridden to return something different. This | |
2130 | allows to override an editor used for one of the standard types. | |
2131 | ||
2132 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 2133 | */ |
caac7804 | 2134 | virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; |
23324ae1 FM |
2135 | |
2136 | /** | |
caac7804 | 2137 | Returns a pointer to the current default grid cell renderer. |
8b9ef005 | 2138 | |
caac7804 BP |
2139 | See wxGridCellRenderer and the @ref overview_grid for more information |
2140 | about cell editors and renderers. | |
2141 | ||
2142 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 2143 | */ |
caac7804 | 2144 | wxGridCellRenderer* GetDefaultRenderer() const; |
23324ae1 | 2145 | |
9f7aee01 | 2146 | /** |
caac7804 BP |
2147 | Returns the default renderer for the given cell. |
2148 | ||
2149 | The base class version returns the renderer appropriate for the current | |
2150 | cell type but this method may be overridden in the derived classes to | |
2151 | use custom renderers for some cells by default. | |
2152 | ||
2153 | The caller must call DecRef() on the returned pointer. | |
8b9ef005 | 2154 | */ |
caac7804 | 2155 | virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; |
9f7aee01 | 2156 | |
8b9ef005 | 2157 | /** |
caac7804 BP |
2158 | Returns the default renderer for the cell containing values of the |
2159 | given type. | |
9f7aee01 | 2160 | |
caac7804 | 2161 | @see GetDefaultEditorForType() |
8b9ef005 | 2162 | */ |
caac7804 | 2163 | virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; |
08dd9b5a | 2164 | |
8b9ef005 | 2165 | /** |
caac7804 | 2166 | Hides the in-place cell edit control. |
23324ae1 | 2167 | */ |
caac7804 | 2168 | void HideCellEditControl(); |
23324ae1 FM |
2169 | |
2170 | /** | |
caac7804 | 2171 | Returns @true if the in-place edit control is currently enabled. |
8b9ef005 | 2172 | */ |
caac7804 | 2173 | bool IsCellEditControlEnabled() const; |
3c4f71cc | 2174 | |
8b9ef005 | 2175 | /** |
caac7804 | 2176 | Returns @true if the current cell is read-only. |
3c4f71cc | 2177 | |
caac7804 | 2178 | @see SetReadOnly(), IsReadOnly() |
23324ae1 | 2179 | */ |
caac7804 | 2180 | bool IsCurrentCellReadOnly() const; |
23324ae1 FM |
2181 | |
2182 | /** | |
caac7804 BP |
2183 | Returns @false if the whole grid has been set as read-only or @true |
2184 | otherwise. | |
2185 | ||
2186 | See EnableEditing() for more information about controlling the editing | |
2187 | status of grid cells. | |
8b9ef005 | 2188 | */ |
caac7804 | 2189 | bool IsEditable() const; |
23324ae1 | 2190 | |
8b9ef005 | 2191 | /** |
caac7804 | 2192 | Returns @true if the cell at the specified location can't be edited. |
55f0bf1f | 2193 | |
caac7804 | 2194 | @see SetReadOnly(), IsCurrentCellReadOnly() |
23324ae1 | 2195 | */ |
caac7804 | 2196 | bool IsReadOnly(int row, int col) const; |
23324ae1 FM |
2197 | |
2198 | /** | |
caac7804 | 2199 | Register a new data type. |
08dd9b5a | 2200 | |
caac7804 BP |
2201 | The data types allow to naturally associate specific renderers and |
2202 | editors to the cells containing values of the given type. For example, | |
2203 | the grid automatically registers a data type with the name | |
2204 | @c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and | |
2205 | wxGridCellTextEditor as its renderer and editor respectively -- this is | |
2206 | the data type used by all the cells of the default wxGridStringTable, | |
2207 | so this renderer and editor are used by default for all grid cells. | |
8b9ef005 | 2208 | |
caac7804 BP |
2209 | However if a custom table returns @c wxGRID_VALUE_BOOL from its |
2210 | wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and | |
2211 | wxGridCellBoolEditor are used for it because the grid also registers a | |
2212 | boolean data type with this name. | |
8b9ef005 | 2213 | |
caac7804 BP |
2214 | And as this mechanism is completely generic, you may register your own |
2215 | data types using your own custom renderers and editors. Just remember | |
2216 | that the table must identify a cell as being of the given type for them | |
2217 | to be used for this cell. | |
2218 | ||
2219 | @param typeName | |
2220 | Name of the new type. May be any string, but if the type name is | |
2221 | the same as the name of an already registered type, including one | |
2222 | of the standard ones (which are @c wxGRID_VALUE_STRING, @c | |
2223 | wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT | |
2224 | and @c wxGRID_VALUE_CHOICE), then the new registration information | |
2225 | replaces the previously used renderer and editor. | |
2226 | @param renderer | |
2227 | The renderer to use for the cells of this type. Its ownership is | |
2228 | taken by the grid, i.e. it will call DecRef() on this pointer when | |
2229 | it doesn't need it any longer. | |
2230 | @param editor | |
2231 | The editor to use for the cells of this type. Its ownership is also | |
2232 | taken by the grid. | |
23324ae1 | 2233 | */ |
caac7804 BP |
2234 | void RegisterDataType(const wxString& typeName, |
2235 | wxGridCellRenderer* renderer, | |
2236 | wxGridCellEditor* editor); | |
23324ae1 FM |
2237 | |
2238 | /** | |
caac7804 BP |
2239 | Sets the value of the current grid cell to the current in-place edit |
2240 | control value. | |
55f0bf1f | 2241 | |
caac7804 BP |
2242 | This is called automatically when the grid cursor moves from the |
2243 | current cell to a new cell. It is also a good idea to call this | |
2244 | function when closing a grid since any edits to the final cell location | |
2245 | will not be saved otherwise. | |
23324ae1 | 2246 | */ |
caac7804 | 2247 | void SaveEditControlValue(); |
23324ae1 FM |
2248 | |
2249 | /** | |
caac7804 | 2250 | Sets the editor for the grid cell at the specified location. |
55f0bf1f | 2251 | |
caac7804 | 2252 | The grid will take ownership of the pointer. |
8b9ef005 | 2253 | |
caac7804 BP |
2254 | See wxGridCellEditor and the @ref overview_grid for more information |
2255 | about cell editors and renderers. | |
23324ae1 | 2256 | */ |
caac7804 | 2257 | void SetCellEditor(int row, int col, wxGridCellEditor* editor); |
23324ae1 FM |
2258 | |
2259 | /** | |
caac7804 | 2260 | Sets the renderer for the grid cell at the specified location. |
55f0bf1f | 2261 | |
caac7804 | 2262 | The grid will take ownership of the pointer. |
8b9ef005 | 2263 | |
caac7804 BP |
2264 | See wxGridCellRenderer and the @ref overview_grid for more information |
2265 | about cell editors and renderers. | |
23324ae1 | 2266 | */ |
caac7804 | 2267 | void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer); |
23324ae1 FM |
2268 | |
2269 | /** | |
caac7804 | 2270 | Sets the string value for the cell at the specified location. |
55f0bf1f | 2271 | |
caac7804 BP |
2272 | For simple applications where a grid object automatically uses a |
2273 | default grid table of string values you use this function together with | |
2274 | GetCellValue() to access cell values. For more complex applications | |
2275 | where you have derived your own grid table class that contains various | |
2276 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2277 | you only use this function for those cells that contain string values. | |
8b9ef005 | 2278 | |
caac7804 BP |
2279 | See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for |
2280 | more information. | |
23324ae1 | 2281 | */ |
caac7804 | 2282 | void SetCellValue(int row, int col, const wxString& s); |
23324ae1 | 2283 | /** |
caac7804 | 2284 | Sets the string value for the cell at the specified location. |
55f0bf1f | 2285 | |
caac7804 BP |
2286 | For simple applications where a grid object automatically uses a |
2287 | default grid table of string values you use this function together with | |
2288 | GetCellValue() to access cell values. For more complex applications | |
2289 | where you have derived your own grid table class that contains various | |
2290 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2291 | you only use this function for those cells that contain string values. | |
23324ae1 | 2292 | |
caac7804 BP |
2293 | See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for |
2294 | more information. | |
23324ae1 | 2295 | */ |
caac7804 | 2296 | void SetCellValue(const wxGridCellCoords& coords, const wxString& s); |
23324ae1 | 2297 | /** |
caac7804 BP |
2298 | @deprecated Please use SetCellValue(int,int,const wxString&) or |
2299 | SetCellValue(const wxGridCellCoords&,const wxString&) | |
2300 | instead. | |
23324ae1 | 2301 | |
caac7804 | 2302 | Sets the string value for the cell at the specified location. |
23324ae1 | 2303 | |
caac7804 BP |
2304 | For simple applications where a grid object automatically uses a |
2305 | default grid table of string values you use this function together with | |
2306 | GetCellValue() to access cell values. For more complex applications | |
2307 | where you have derived your own grid table class that contains various | |
2308 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2309 | you only use this function for those cells that contain string values. | |
2310 | ||
2311 | See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for | |
2312 | more information. | |
23324ae1 | 2313 | */ |
caac7804 | 2314 | void SetCellValue(const wxString& val, int row, int col); |
23324ae1 FM |
2315 | |
2316 | /** | |
caac7804 | 2317 | Sets the specified column to display boolean values. |
55f0bf1f | 2318 | |
caac7804 | 2319 | @see SetColFormatCustom() |
23324ae1 | 2320 | */ |
caac7804 | 2321 | void SetColFormatBool(int col); |
23324ae1 FM |
2322 | |
2323 | /** | |
caac7804 | 2324 | Sets the specified column to display data in a custom format. |
23324ae1 | 2325 | |
caac7804 BP |
2326 | This method provides an alternative to defining a custom grid table |
2327 | which would return @a typeName from its GetTypeName() method for the | |
2328 | cells in this column: while it doesn't really change the type of the | |
2329 | cells in this column, it does associate the renderer and editor used | |
2330 | for the cells of the specified type with them. | |
23324ae1 | 2331 | |
caac7804 BP |
2332 | See the @ref overview_grid for more information on working with custom |
2333 | data types. | |
23324ae1 | 2334 | */ |
caac7804 | 2335 | void SetColFormatCustom(int col, const wxString& typeName); |
23324ae1 FM |
2336 | |
2337 | /** | |
caac7804 BP |
2338 | Sets the specified column to display floating point values with the |
2339 | given width and precision. | |
55f0bf1f | 2340 | |
caac7804 | 2341 | @see SetColFormatCustom() |
23324ae1 | 2342 | */ |
caac7804 | 2343 | void SetColFormatFloat(int col, int width = -1, int precision = -1); |
23324ae1 FM |
2344 | |
2345 | /** | |
caac7804 | 2346 | Sets the specified column to display integer values. |
8b9ef005 | 2347 | |
caac7804 | 2348 | @see SetColFormatCustom() |
23324ae1 | 2349 | */ |
caac7804 | 2350 | void SetColFormatNumber(int col); |
23324ae1 FM |
2351 | |
2352 | /** | |
caac7804 | 2353 | Sets the default editor for grid cells. |
3c4f71cc | 2354 | |
caac7804 | 2355 | The grid will take ownership of the pointer. |
55f0bf1f | 2356 | |
caac7804 BP |
2357 | See wxGridCellEditor and the @ref overview_grid for more information |
2358 | about cell editors and renderers. | |
23324ae1 | 2359 | */ |
caac7804 | 2360 | void SetDefaultEditor(wxGridCellEditor* editor); |
23324ae1 FM |
2361 | |
2362 | /** | |
caac7804 | 2363 | Sets the default renderer for grid cells. |
8b9ef005 | 2364 | |
caac7804 | 2365 | The grid will take ownership of the pointer. |
8b9ef005 | 2366 | |
caac7804 BP |
2367 | See wxGridCellRenderer and the @ref overview_grid for more information |
2368 | about cell editors and renderers. | |
23324ae1 | 2369 | */ |
caac7804 | 2370 | void SetDefaultRenderer(wxGridCellRenderer* renderer); |
23324ae1 FM |
2371 | |
2372 | /** | |
caac7804 | 2373 | Makes the cell at the specified location read-only or editable. |
08dd9b5a | 2374 | |
caac7804 | 2375 | @see IsReadOnly() |
23324ae1 | 2376 | */ |
caac7804 | 2377 | void SetReadOnly(int row, int col, bool isReadOnly = true); |
23324ae1 FM |
2378 | |
2379 | /** | |
caac7804 | 2380 | Displays the in-place cell edit control for the current cell. |
23324ae1 | 2381 | */ |
caac7804 | 2382 | void ShowCellEditControl(); |
23324ae1 | 2383 | |
caac7804 | 2384 | //@} |
23324ae1 | 2385 | |
23324ae1 | 2386 | |
23324ae1 | 2387 | /** |
caac7804 | 2388 | @name Column and Row Sizes |
82edfbe7 | 2389 | |
32bcf974 | 2390 | @see @ref overview_grid_resizing |
caac7804 BP |
2391 | */ |
2392 | //@{ | |
08dd9b5a | 2393 | |
caac7804 BP |
2394 | /** |
2395 | Automatically sets the height and width of all rows and columns to fit | |
2396 | their contents. | |
23324ae1 | 2397 | */ |
caac7804 | 2398 | void AutoSize(); |
23324ae1 FM |
2399 | |
2400 | /** | |
caac7804 | 2401 | Automatically adjusts width of the column to fit its label. |
23324ae1 | 2402 | */ |
caac7804 | 2403 | void AutoSizeColLabelSize(int col); |
23324ae1 FM |
2404 | |
2405 | /** | |
caac7804 BP |
2406 | Automatically sizes the column to fit its contents. If @a setAsMin is |
2407 | @true the calculated width will also be set as the minimal width for | |
2408 | the column. | |
2409 | */ | |
2410 | void AutoSizeColumn(int col, bool setAsMin = true); | |
23324ae1 FM |
2411 | |
2412 | /** | |
caac7804 BP |
2413 | Automatically sizes all columns to fit their contents. If @a setAsMin |
2414 | is @true the calculated widths will also be set as the minimal widths | |
2415 | for the columns. | |
23324ae1 | 2416 | */ |
caac7804 | 2417 | void AutoSizeColumns(bool setAsMin = true); |
23324ae1 FM |
2418 | |
2419 | /** | |
caac7804 BP |
2420 | Automatically sizes the row to fit its contents. If @a setAsMin is |
2421 | @true the calculated height will also be set as the minimal height for | |
2422 | the row. | |
23324ae1 | 2423 | */ |
caac7804 | 2424 | void AutoSizeRow(int row, bool setAsMin = true); |
23324ae1 | 2425 | |
23324ae1 | 2426 | /** |
caac7804 | 2427 | Automatically adjusts height of the row to fit its label. |
23324ae1 | 2428 | */ |
caac7804 | 2429 | void AutoSizeRowLabelSize(int col); |
23324ae1 | 2430 | |
23324ae1 | 2431 | /** |
caac7804 BP |
2432 | Automatically sizes all rows to fit their contents. If @a setAsMin is |
2433 | @true the calculated heights will also be set as the minimal heights | |
2434 | for the rows. | |
23324ae1 | 2435 | */ |
caac7804 | 2436 | void AutoSizeRows(bool setAsMin = true); |
23324ae1 | 2437 | |
23324ae1 | 2438 | /** |
caac7804 | 2439 | Returns the current height of the column labels. |
23324ae1 | 2440 | */ |
caac7804 | 2441 | int GetColLabelSize() const; |
23324ae1 FM |
2442 | |
2443 | /** | |
caac7804 | 2444 | Returns the minimal width to which a column may be resized. |
08dd9b5a | 2445 | |
caac7804 BP |
2446 | Use SetColMinimalAcceptableWidth() to change this value globally or |
2447 | SetColMinimalWidth() to do it for individual columns. | |
08dd9b5a | 2448 | |
caac7804 | 2449 | @see GetRowMinimalAcceptableHeight() |
23324ae1 | 2450 | */ |
caac7804 | 2451 | int GetColMinimalAcceptableWidth() const; |
23324ae1 FM |
2452 | |
2453 | /** | |
caac7804 | 2454 | Returns the width of the specified column. |
23324ae1 | 2455 | */ |
caac7804 | 2456 | int GetColSize(int col) const; |
23324ae1 | 2457 | |
fe79f76b VZ |
2458 | /** |
2459 | Returns @true if the specified column is not currently hidden. | |
2460 | */ | |
2461 | bool IsColShown(int col) const; | |
2462 | ||
23324ae1 | 2463 | /** |
caac7804 | 2464 | Returns the default height for column labels. |
23324ae1 | 2465 | */ |
caac7804 | 2466 | int GetDefaultColLabelSize() const; |
23324ae1 FM |
2467 | |
2468 | /** | |
caac7804 | 2469 | Returns the current default width for grid columns. |
23324ae1 | 2470 | */ |
caac7804 | 2471 | int GetDefaultColSize() const; |
23324ae1 FM |
2472 | |
2473 | /** | |
caac7804 BP |
2474 | Returns the default width for the row labels. |
2475 | */ | |
2476 | int GetDefaultRowLabelSize() const; | |
08dd9b5a | 2477 | |
caac7804 BP |
2478 | /** |
2479 | Returns the current default height for grid rows. | |
23324ae1 | 2480 | */ |
caac7804 | 2481 | int GetDefaultRowSize() const; |
23324ae1 | 2482 | |
23324ae1 | 2483 | /** |
caac7804 | 2484 | Returns the minimal size to which rows can be resized. |
08dd9b5a | 2485 | |
caac7804 BP |
2486 | Use SetRowMinimalAcceptableHeight() to change this value globally or |
2487 | SetRowMinimalHeight() to do it for individual cells. | |
23324ae1 | 2488 | |
caac7804 | 2489 | @see GetColMinimalAcceptableWidth() |
23324ae1 | 2490 | */ |
caac7804 | 2491 | int GetRowMinimalAcceptableHeight() const; |
23324ae1 FM |
2492 | |
2493 | /** | |
caac7804 | 2494 | Returns the current width of the row labels. |
23324ae1 | 2495 | */ |
caac7804 | 2496 | int GetRowLabelSize() const; |
23324ae1 FM |
2497 | |
2498 | /** | |
caac7804 | 2499 | Returns the height of the specified row. |
8b9ef005 | 2500 | */ |
caac7804 | 2501 | int GetRowSize(int row) const; |
08dd9b5a | 2502 | |
fe79f76b VZ |
2503 | /** |
2504 | Returns @true if the specified row is not currently hidden. | |
2505 | */ | |
2506 | bool IsRowShown(int row) const; | |
2507 | ||
8b9ef005 | 2508 | /** |
caac7804 | 2509 | Sets the height of the column labels. |
08dd9b5a | 2510 | |
caac7804 BP |
2511 | If @a height equals to @c wxGRID_AUTOSIZE then height is calculated |
2512 | automatically so that no label is truncated. Note that this could be | |
2513 | slow for a large table. | |
23324ae1 | 2514 | */ |
caac7804 | 2515 | void SetColLabelSize(int height); |
23324ae1 FM |
2516 | |
2517 | /** | |
caac7804 | 2518 | Sets the minimal @a width to which the user can resize columns. |
08dd9b5a | 2519 | |
caac7804 | 2520 | @see GetColMinimalAcceptableWidth() |
23324ae1 | 2521 | */ |
caac7804 | 2522 | void SetColMinimalAcceptableWidth(int width); |
23324ae1 FM |
2523 | |
2524 | /** | |
caac7804 | 2525 | Sets the minimal @a width for the specified column @a col. |
3c4f71cc | 2526 | |
caac7804 BP |
2527 | It is usually best to call this method during grid creation as calling |
2528 | it later will not resize the column to the given minimal width even if | |
2529 | it is currently narrower than it. | |
23324ae1 | 2530 | |
caac7804 BP |
2531 | @a width must be greater than the minimal acceptable column width as |
2532 | returned by GetColMinimalAcceptableWidth(). | |
23324ae1 | 2533 | */ |
caac7804 | 2534 | void SetColMinimalWidth(int col, int width); |
23324ae1 FM |
2535 | |
2536 | /** | |
caac7804 BP |
2537 | Sets the width of the specified column. |
2538 | ||
caac7804 BP |
2539 | @param col |
2540 | The column index. | |
2541 | @param width | |
009c7216 VZ |
2542 | The new column width in pixels, 0 to hide the column or -1 to fit |
2543 | the column width to its label width. | |
23324ae1 | 2544 | */ |
caac7804 | 2545 | void SetColSize(int col, int width); |
23324ae1 | 2546 | |
009c7216 VZ |
2547 | /** |
2548 | Hides the specified column. | |
2549 | ||
2550 | To show the column later you need to call SetColSize() with non-0 | |
2551 | width or ShowCol(). | |
2552 | ||
2553 | @param col | |
2554 | The column index. | |
2555 | */ | |
2556 | void HideCol(int col); | |
2557 | ||
2558 | /** | |
2559 | Shows the previously hidden column by resizing it to non-0 size. | |
2560 | ||
2561 | @see HideCol(), SetColSize() | |
2562 | */ | |
2563 | void ShowCol(int col); | |
2564 | ||
2565 | ||
23324ae1 | 2566 | /** |
caac7804 | 2567 | Sets the default width for columns in the grid. |
23324ae1 | 2568 | |
caac7804 BP |
2569 | This will only affect columns subsequently added to the grid unless |
2570 | @a resizeExistingCols is @true. | |
2571 | ||
2572 | If @a width is less than GetColMinimalAcceptableWidth(), then the | |
2573 | minimal acceptable width is used instead of it. | |
23324ae1 | 2574 | */ |
caac7804 | 2575 | void SetDefaultColSize(int width, bool resizeExistingCols = false); |
23324ae1 FM |
2576 | |
2577 | /** | |
caac7804 | 2578 | Sets the default height for rows in the grid. |
3c4f71cc | 2579 | |
caac7804 BP |
2580 | This will only affect rows subsequently added to the grid unless |
2581 | @a resizeExistingRows is @true. | |
2582 | ||
2583 | If @a height is less than GetRowMinimalAcceptableHeight(), then the | |
2584 | minimal acceptable heihgt is used instead of it. | |
23324ae1 | 2585 | */ |
caac7804 | 2586 | void SetDefaultRowSize(int height, bool resizeExistingRows = false); |
23324ae1 FM |
2587 | |
2588 | /** | |
caac7804 BP |
2589 | Sets the width of the row labels. |
2590 | ||
2591 | If @a width equals @c wxGRID_AUTOSIZE then width is calculated | |
2592 | automatically so that no label is truncated. Note that this could be | |
2593 | slow for a large table. | |
23324ae1 | 2594 | */ |
caac7804 | 2595 | void SetRowLabelSize(int width); |
23324ae1 FM |
2596 | |
2597 | /** | |
caac7804 | 2598 | Sets the minimal row @a height used by default. |
8b9ef005 | 2599 | |
caac7804 | 2600 | See SetColMinimalAcceptableWidth() for more information. |
23324ae1 | 2601 | */ |
caac7804 | 2602 | void SetRowMinimalAcceptableHeight(int height); |
23324ae1 FM |
2603 | |
2604 | /** | |
caac7804 BP |
2605 | Sets the minimal @a height for the specified @a row. |
2606 | ||
2607 | See SetColMinimalWidth() for more information. | |
23324ae1 | 2608 | */ |
caac7804 | 2609 | void SetRowMinimalHeight(int row, int height); |
23324ae1 FM |
2610 | |
2611 | /** | |
caac7804 | 2612 | Sets the height of the specified row. |
08dd9b5a | 2613 | |
caac7804 | 2614 | See SetColSize() for more information. |
23324ae1 | 2615 | */ |
caac7804 BP |
2616 | void SetRowSize(int row, int height); |
2617 | ||
009c7216 VZ |
2618 | /** |
2619 | Hides the specified row. | |
2620 | ||
2621 | To show the row later you need to call SetRowSize() with non-0 | |
2622 | width or ShowRow(). | |
2623 | ||
2624 | @param col | |
2625 | The row index. | |
2626 | */ | |
2627 | void HideRow(int col); | |
2628 | ||
2629 | /** | |
2630 | Shows the previously hidden row by resizing it to non-0 size. | |
2631 | ||
2632 | @see HideRow(), SetRowSize() | |
2633 | */ | |
2634 | void ShowRow(int col); | |
2635 | ||
574e1c5a VZ |
2636 | /** |
2637 | Get size information for all columns at once. | |
2638 | ||
2639 | This method is useful when the information about all column widths | |
2640 | needs to be saved. The widths can be later restored using | |
2641 | SetColSizes(). | |
2642 | ||
2643 | @sa wxGridSizesInfo, GetRowSizes() | |
2644 | */ | |
2645 | wxGridSizesInfo GetColSizes() const; | |
2646 | ||
2647 | /** | |
2648 | Get size information for all row at once. | |
2649 | ||
2650 | @sa wxGridSizesInfo, GetColSizes() | |
2651 | */ | |
2652 | wxGridSizesInfo GetRowSizes() const; | |
2653 | ||
2654 | /** | |
2655 | Restore all columns sizes. | |
2656 | ||
2657 | This is usually called with wxGridSizesInfo object previously returned | |
2658 | by GetColSizes(). | |
2659 | ||
2660 | @sa SetRowSizes() | |
2661 | */ | |
2662 | void SetColSizes(const wxGridSizesInfo& sizeInfo); | |
2663 | ||
2664 | /** | |
2665 | Restore all rows sizes. | |
2666 | ||
2667 | @sa SetColSizes() | |
2668 | */ | |
2669 | void SetRowSizes(const wxGridSizesInfo& sizeInfo); | |
2670 | ||
ea99e8e3 VZ |
2671 | /** |
2672 | Set the size of the cell. | |
2673 | ||
2674 | Specifying a value of more than 1 in @a num_rows or @a num_cols will | |
2675 | make the cell at (@a row, @a col) span the block of the specified size, | |
2676 | covering the other cells which would be normally shown in it. Passing 1 | |
2677 | for both arguments resets the cell to normal appearance. | |
2678 | ||
2679 | @see GetCellSize() | |
2680 | ||
2681 | @param row | |
2682 | The row of the cell. | |
2683 | @param col | |
2684 | The column of the cell. | |
2685 | @param num_rows | |
2686 | Number of rows to be occupied by this cell, must be >= 1. | |
2687 | @param num_cols | |
2688 | Number of columns to be occupied by this cell, must be >= 1. | |
2689 | */ | |
2690 | void SetCellSize(int row, int col, int num_rows, int num_cols); | |
2691 | ||
2692 | /** | |
2693 | Get the size of the cell in number of cells covered by it. | |
2694 | ||
2695 | For normal cells, the function fills both @a num_rows and @a num_cols | |
2696 | with 1 and returns CellSpan_None. For cells which span multiple cells, i.e. | |
2697 | for which SetCellSize() had been called, the returned values are the | |
2698 | same ones as were passed to SetCellSize() call and the function return | |
2699 | value is CellSpan_Main. | |
2700 | ||
2701 | More unexpectedly, perhaps, the returned values may be @em negative for | |
2702 | the cells which are inside a span covered by a cell occupying multiple | |
2703 | rows or columns. They correspond to the offset of the main cell of the | |
2704 | span from the cell passed to this functions and the function returns | |
2705 | CellSpan_Inside value to indicate this. | |
2706 | ||
2707 | As an example, consider a 3*3 grid with the cell (1, 1) (the one in the | |
2708 | middle) having a span of 2 rows and 2 columns, i.e. the grid looks like | |
2709 | @code | |
2710 | +----+----+----+ | |
2711 | | | | | | |
2712 | +----+----+----+ | |
2713 | | | | | |
2714 | +----+ | | |
2715 | | | | | |
2716 | +----+----+----+ | |
2717 | @endcode | |
2718 | Then the function returns 2 and 2 in @a num_rows and @a num_cols for | |
2719 | the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1 | |
2720 | and 0 for the cell (2, 1). | |
2721 | ||
2722 | @param row | |
2723 | The row of the cell. | |
2724 | @param col | |
2725 | The column of the cell. | |
2726 | @param num_rows | |
2727 | Pointer to variable receiving the number of rows, must not be @NULL. | |
2728 | @param num_cols | |
2729 | Pointer to variable receiving the number of columns, must not be | |
2730 | @NULL. | |
2731 | @return | |
2732 | The kind of this cell span (the return value is new in wxWidgets | |
2733 | 2.9.1, this function was void in previous wxWidgets versions). | |
2734 | */ | |
2735 | CellSpan GetCellSize( int row, int col, int *num_rows, int *num_cols ) const; | |
2736 | ||
2737 | /** | |
2738 | Get the number of rows and columns allocated for this cell. | |
2739 | ||
2740 | This overload doesn't return a CellSpan value but the values returned | |
2741 | may still be negative, see GetCellSize(int, int, int *, int *) for | |
2742 | details. | |
2743 | */ | |
2744 | wxSize GetCellSize(const wxGridCellCoords& coords); | |
2745 | ||
8b9ef005 | 2746 | //@} |
23324ae1 | 2747 | |
caac7804 | 2748 | |
23324ae1 | 2749 | /** |
caac7804 | 2750 | @name User-Resizing and Dragging |
82edfbe7 VZ |
2751 | |
2752 | Functions controlling various interactive mouse operations. | |
2753 | ||
2754 | By default, columns and rows can be resized by dragging the edges of | |
2755 | their labels (this can be disabled using DisableDragColSize() and | |
2756 | DisableDragRowSize() methods). And if grid line dragging is enabled with | |
2757 | EnableDragGridSize() they can also be resized by dragging the right or | |
2758 | bottom edge of the grid cells. | |
2759 | ||
2760 | Columns can also be moved to interactively change their order but this | |
2761 | needs to be explicitly enabled with EnableDragColMove(). | |
caac7804 BP |
2762 | */ |
2763 | //@{ | |
08dd9b5a | 2764 | |
caac7804 BP |
2765 | /** |
2766 | Return @true if the dragging of cells is enabled or @false otherwise. | |
23324ae1 | 2767 | */ |
caac7804 | 2768 | bool CanDragCell() const; |
23324ae1 FM |
2769 | |
2770 | /** | |
caac7804 | 2771 | Returns @true if columns can be moved by dragging with the mouse. |
08dd9b5a | 2772 | |
caac7804 | 2773 | Columns can be moved by dragging on their labels. |
23324ae1 | 2774 | */ |
caac7804 | 2775 | bool CanDragColMove() const; |
23324ae1 FM |
2776 | |
2777 | /** | |
82edfbe7 VZ |
2778 | Returns @true if the given column can be resized by dragging with the |
2779 | mouse. | |
8b9ef005 | 2780 | |
82edfbe7 VZ |
2781 | This function returns @true if resizing the columns interactively is |
2782 | globally enabled, i.e. if DisableDragColSize() hadn't been called, and | |
2783 | if this column wasn't explicitly marked as non-resizable with | |
2784 | DisableColResize(). | |
23324ae1 | 2785 | */ |
82edfbe7 | 2786 | bool CanDragColSize(int col) const; |
23324ae1 FM |
2787 | |
2788 | /** | |
caac7804 BP |
2789 | Return @true if the dragging of grid lines to resize rows and columns |
2790 | is enabled or @false otherwise. | |
2791 | */ | |
2792 | bool CanDragGridSize() const; | |
2793 | ||
2794 | /** | |
82edfbe7 VZ |
2795 | Returns @true if the given row can be resized by dragging with the |
2796 | mouse. | |
caac7804 | 2797 | |
82edfbe7 | 2798 | This is the same as CanDragColSize() but for rows. |
caac7804 | 2799 | */ |
82edfbe7 VZ |
2800 | bool CanDragRowSize(int row) const; |
2801 | ||
2802 | /** | |
2803 | Disable interactive resizing of the specified column. | |
2804 | ||
2805 | This method allows to disable resizing of an individual column in a | |
2806 | grid where the columns are otherwise resizable (which is the case by | |
2807 | default). | |
2808 | ||
2809 | Notice that currently there is no way to make some columns resizable in | |
2810 | a grid where columns can't be resized by default as there doesn't seem | |
2811 | to be any need for this in practice. There is also no way to make the | |
2812 | column marked as fixed using this method resizeable again because it is | |
2813 | supposed that fixed columns are used for static parts of the grid and | |
2814 | so should remain fixed during the entire grid lifetime. | |
2815 | ||
2816 | Also notice that disabling interactive column resizing will not prevent | |
2817 | the program from changing the column size. | |
2818 | ||
2819 | @see EnableDragColSize() | |
2820 | */ | |
2821 | void DisableColResize(int col); | |
2822 | ||
2823 | /** | |
2824 | Disable interactive resizing of the specified row. | |
2825 | ||
2826 | This is the same as DisableColResize() but for rows. | |
2827 | ||
2828 | @see EnableDragRowSize() | |
2829 | */ | |
2830 | void DisableRowResize(int row); | |
caac7804 BP |
2831 | |
2832 | /** | |
2833 | Disables column moving by dragging with the mouse. | |
2834 | ||
2835 | Equivalent to passing @false to EnableDragColMove(). | |
2836 | */ | |
2837 | void DisableDragColMove(); | |
2838 | ||
2839 | /** | |
2840 | Disables column sizing by dragging with the mouse. | |
2841 | ||
2842 | Equivalent to passing @false to EnableDragColSize(). | |
2843 | */ | |
2844 | void DisableDragColSize(); | |
2845 | ||
2846 | /** | |
2847 | Disable mouse dragging of grid lines to resize rows and columns. | |
2848 | ||
2849 | Equivalent to passing @false to EnableDragGridSize() | |
2850 | */ | |
2851 | void DisableDragGridSize(); | |
2852 | ||
2853 | /** | |
2854 | Disables row sizing by dragging with the mouse. | |
2855 | ||
2856 | Equivalent to passing @false to EnableDragRowSize(). | |
2857 | */ | |
2858 | void DisableDragRowSize(); | |
2859 | ||
2860 | /** | |
2861 | Enables or disables cell dragging with the mouse. | |
2862 | */ | |
2863 | void EnableDragCell(bool enable = true); | |
2864 | ||
2865 | /** | |
2866 | Enables or disables column moving by dragging with the mouse. | |
2867 | */ | |
2868 | void EnableDragColMove(bool enable = true); | |
2869 | ||
2870 | /** | |
2871 | Enables or disables column sizing by dragging with the mouse. | |
82edfbe7 VZ |
2872 | |
2873 | @see DisableColResize() | |
caac7804 BP |
2874 | */ |
2875 | void EnableDragColSize(bool enable = true); | |
2876 | ||
2877 | /** | |
2878 | Enables or disables row and column resizing by dragging gridlines with | |
2879 | the mouse. | |
2880 | */ | |
2881 | void EnableDragGridSize(bool enable = true); | |
2882 | ||
2883 | /** | |
2884 | Enables or disables row sizing by dragging with the mouse. | |
82edfbe7 VZ |
2885 | |
2886 | @see DisableRowResize() | |
caac7804 BP |
2887 | */ |
2888 | void EnableDragRowSize(bool enable = true); | |
2889 | ||
2890 | /** | |
2891 | Returns the column ID of the specified column position. | |
2892 | */ | |
2893 | int GetColAt(int colPos) const; | |
2894 | ||
2895 | /** | |
2896 | Returns the position of the specified column. | |
2897 | */ | |
2898 | int GetColPos(int colID) const; | |
2899 | ||
2900 | /** | |
2901 | Sets the position of the specified column. | |
2902 | */ | |
2903 | void SetColPos(int colID, int newPos); | |
2904 | ||
31ec8b4e VZ |
2905 | /** |
2906 | Sets the positions of all columns at once. | |
2907 | ||
2908 | This method takes an array containing the indices of the columns in | |
2909 | their display order, i.e. uses the same convention as | |
2910 | wxHeaderCtrl::SetColumnsOrder(). | |
f8f31de6 | 2911 | */ |
31ec8b4e VZ |
2912 | void SetColumnsOrder(const wxArrayInt& order); |
2913 | ||
009c7216 VZ |
2914 | /** |
2915 | Resets the position of the columns to the default. | |
f8f31de6 | 2916 | */ |
009c7216 VZ |
2917 | void ResetColPos(); |
2918 | ||
caac7804 BP |
2919 | //@} |
2920 | ||
2921 | ||
2922 | /** | |
2923 | @name Cursor Movement | |
f8f31de6 | 2924 | */ |
caac7804 BP |
2925 | //@{ |
2926 | ||
2927 | /** | |
2928 | Returns the current grid cell column position. | |
2929 | */ | |
2930 | int GetGridCursorCol() const; | |
2931 | ||
2932 | /** | |
2933 | Returns the current grid cell row position. | |
2934 | */ | |
2935 | int GetGridCursorRow() const; | |
2936 | ||
2937 | /** | |
2938 | Make the given cell current and ensure it is visible. | |
2939 | ||
2940 | This method is equivalent to calling MakeCellVisible() and | |
2941 | SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL | |
2942 | event is generated by it and the selected cell doesn't change if the | |
2943 | event is vetoed. | |
2944 | */ | |
2945 | void GoToCell(int row, int col); | |
2946 | /** | |
2947 | Make the given cell current and ensure it is visible. | |
2948 | ||
2949 | This method is equivalent to calling MakeCellVisible() and | |
2950 | SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL | |
2951 | event is generated by it and the selected cell doesn't change if the | |
2952 | event is vetoed. | |
2953 | */ | |
2954 | void GoToCell(const wxGridCellCoords& coords); | |
2955 | ||
2956 | /** | |
2957 | Moves the grid cursor down by one row. | |
2958 | ||
2959 | If a block of cells was previously selected it will expand if the | |
2960 | argument is @true or be cleared if the argument is @false. | |
2961 | */ | |
2962 | bool MoveCursorDown(bool expandSelection); | |
2963 | ||
2964 | /** | |
2965 | Moves the grid cursor down in the current column such that it skips to | |
2966 | the beginning or end of a block of non-empty cells. | |
2967 | ||
2968 | If a block of cells was previously selected it will expand if the | |
2969 | argument is @true or be cleared if the argument is @false. | |
2970 | */ | |
2971 | bool MoveCursorDownBlock(bool expandSelection); | |
2972 | ||
2973 | /** | |
2974 | Moves the grid cursor left by one column. | |
08dd9b5a | 2975 | |
8b9ef005 BP |
2976 | If a block of cells was previously selected it will expand if the |
2977 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 2978 | */ |
8b9ef005 | 2979 | bool MoveCursorLeft(bool expandSelection); |
23324ae1 FM |
2980 | |
2981 | /** | |
8b9ef005 BP |
2982 | Moves the grid cursor left in the current row such that it skips to the |
2983 | beginning or end of a block of non-empty cells. | |
2984 | ||
2985 | If a block of cells was previously selected it will expand if the | |
2986 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 2987 | */ |
8b9ef005 | 2988 | bool MoveCursorLeftBlock(bool expandSelection); |
23324ae1 FM |
2989 | |
2990 | /** | |
8b9ef005 | 2991 | Moves the grid cursor right by one column. |
08dd9b5a | 2992 | |
8b9ef005 BP |
2993 | If a block of cells was previously selected it will expand if the |
2994 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 2995 | */ |
8b9ef005 | 2996 | bool MoveCursorRight(bool expandSelection); |
23324ae1 FM |
2997 | |
2998 | /** | |
8b9ef005 BP |
2999 | Moves the grid cursor right in the current row such that it skips to |
3000 | the beginning or end of a block of non-empty cells. | |
08dd9b5a | 3001 | |
8b9ef005 BP |
3002 | If a block of cells was previously selected it will expand if the |
3003 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3004 | */ |
8b9ef005 | 3005 | bool MoveCursorRightBlock(bool expandSelection); |
23324ae1 | 3006 | |
23324ae1 | 3007 | /** |
8b9ef005 BP |
3008 | Moves the grid cursor up by one row. |
3009 | ||
3010 | If a block of cells was previously selected it will expand if the | |
3011 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3012 | */ |
8b9ef005 | 3013 | bool MoveCursorUp(bool expandSelection); |
23324ae1 FM |
3014 | |
3015 | /** | |
8b9ef005 BP |
3016 | Moves the grid cursor up in the current column such that it skips to |
3017 | the beginning or end of a block of non-empty cells. | |
3c4f71cc | 3018 | |
8b9ef005 BP |
3019 | If a block of cells was previously selected it will expand if the |
3020 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3021 | */ |
8b9ef005 | 3022 | bool MoveCursorUpBlock(bool expandSelection); |
23324ae1 FM |
3023 | |
3024 | /** | |
8b9ef005 BP |
3025 | Moves the grid cursor down by some number of rows so that the previous |
3026 | bottom visible row becomes the top visible row. | |
3027 | */ | |
3028 | bool MovePageDown(); | |
3c4f71cc | 3029 | |
8b9ef005 BP |
3030 | /** |
3031 | Moves the grid cursor up by some number of rows so that the previous | |
3032 | top visible row becomes the bottom visible row. | |
23324ae1 | 3033 | */ |
8b9ef005 | 3034 | bool MovePageUp(); |
23324ae1 FM |
3035 | |
3036 | /** | |
caac7804 | 3037 | Set the grid cursor to the specified cell. |
08dd9b5a | 3038 | |
caac7804 BP |
3039 | The grid cursor indicates the current cell and can be moved by the user |
3040 | using the arrow keys or the mouse. | |
8b9ef005 | 3041 | |
caac7804 BP |
3042 | Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and |
3043 | if the event handler vetoes this event, the cursor is not moved. | |
8b9ef005 | 3044 | |
caac7804 BP |
3045 | This function doesn't make the target call visible, use GoToCell() to |
3046 | do this. | |
23324ae1 | 3047 | */ |
caac7804 | 3048 | void SetGridCursor(int row, int col); |
23324ae1 | 3049 | /** |
caac7804 | 3050 | Set the grid cursor to the specified cell. |
23324ae1 | 3051 | |
caac7804 BP |
3052 | The grid cursor indicates the current cell and can be moved by the user |
3053 | using the arrow keys or the mouse. | |
bb778cae | 3054 | |
caac7804 BP |
3055 | Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and |
3056 | if the event handler vetoes this event, the cursor is not moved. | |
8b9ef005 | 3057 | |
caac7804 BP |
3058 | This function doesn't make the target call visible, use GoToCell() to |
3059 | do this. | |
23324ae1 | 3060 | */ |
caac7804 BP |
3061 | void SetGridCursor(const wxGridCellCoords& coords); |
3062 | ||
8b9ef005 | 3063 | //@} |
23324ae1 | 3064 | |
8b9ef005 | 3065 | |
caac7804 BP |
3066 | /** |
3067 | @name User Selection | |
3068 | */ | |
3069 | //@{ | |
8b9ef005 | 3070 | |
caac7804 BP |
3071 | /** |
3072 | Deselects all cells that are currently selected. | |
23324ae1 | 3073 | */ |
caac7804 | 3074 | void ClearSelection(); |
23324ae1 FM |
3075 | |
3076 | /** | |
caac7804 | 3077 | Returns an array of individually selected cells. |
08dd9b5a | 3078 | |
caac7804 BP |
3079 | Notice that this array does @em not contain all the selected cells in |
3080 | general as it doesn't include the cells selected as part of column, row | |
3081 | or block selection. You must use this method, GetSelectedCols(), | |
3082 | GetSelectedRows() and GetSelectionBlockTopLeft() and | |
3083 | GetSelectionBlockBottomRight() methods to obtain the entire selection | |
3084 | in general. | |
08dd9b5a | 3085 | |
caac7804 BP |
3086 | Please notice this behaviour is by design and is needed in order to |
3087 | support grids of arbitrary size (when an entire column is selected in | |
3088 | a grid with a million of columns, we don't want to create an array with | |
3089 | a million of entries in this function, instead it returns an empty | |
3090 | array and GetSelectedCols() returns an array containing one element). | |
23324ae1 | 3091 | */ |
caac7804 | 3092 | wxGridCellCoordsArray GetSelectedCells() const; |
23324ae1 FM |
3093 | |
3094 | /** | |
caac7804 | 3095 | Returns an array of selected columns. |
08dd9b5a | 3096 | |
caac7804 BP |
3097 | Please notice that this method alone is not sufficient to find all the |
3098 | selected columns as it contains only the columns which were | |
3099 | individually selected but not those being part of the block selection | |
3100 | or being selected in virtue of all of their cells being selected | |
3101 | individually, please see GetSelectedCells() for more details. | |
23324ae1 | 3102 | */ |
caac7804 | 3103 | wxArrayInt GetSelectedCols() const; |
23324ae1 FM |
3104 | |
3105 | /** | |
caac7804 | 3106 | Returns an array of selected rows. |
23324ae1 | 3107 | |
caac7804 BP |
3108 | Please notice that this method alone is not sufficient to find all the |
3109 | selected rows as it contains only the rows which were individually | |
3110 | selected but not those being part of the block selection or being | |
3111 | selected in virtue of all of their cells being selected individually, | |
3112 | please see GetSelectedCells() for more details. | |
23324ae1 | 3113 | */ |
caac7804 | 3114 | wxArrayInt GetSelectedRows() const; |
23324ae1 FM |
3115 | |
3116 | /** | |
caac7804 | 3117 | Returns the colour used for drawing the selection background. |
23324ae1 | 3118 | */ |
caac7804 | 3119 | wxColour GetSelectionBackground() const; |
23324ae1 | 3120 | |
8a3e536c | 3121 | /** |
caac7804 BP |
3122 | Returns an array of the bottom right corners of blocks of selected |
3123 | cells. | |
8a3e536c | 3124 | |
caac7804 BP |
3125 | Please see GetSelectedCells() for more information about the selection |
3126 | representation in wxGrid. | |
23324ae1 | 3127 | |
caac7804 | 3128 | @see GetSelectionBlockTopLeft() |
23324ae1 | 3129 | */ |
caac7804 | 3130 | wxGridCellCoordsArray GetSelectionBlockBottomRight() const; |
8b9ef005 | 3131 | |
8b9ef005 | 3132 | /** |
caac7804 | 3133 | Returns an array of the top left corners of blocks of selected cells. |
8b9ef005 | 3134 | |
caac7804 BP |
3135 | Please see GetSelectedCells() for more information about the selection |
3136 | representation in wxGrid. | |
23324ae1 | 3137 | |
caac7804 | 3138 | @see GetSelectionBlockBottomRight() |
23324ae1 | 3139 | */ |
caac7804 | 3140 | wxGridCellCoordsArray GetSelectionBlockTopLeft() const; |
23324ae1 FM |
3141 | |
3142 | /** | |
caac7804 | 3143 | Returns the colour used for drawing the selection foreground. |
23324ae1 | 3144 | */ |
caac7804 | 3145 | wxColour GetSelectionForeground() const; |
23324ae1 FM |
3146 | |
3147 | /** | |
caac7804 | 3148 | Returns the current selection mode. |
23324ae1 | 3149 | |
caac7804 | 3150 | @see SetSelectionMode(). |
23324ae1 | 3151 | */ |
caac7804 | 3152 | wxGridSelectionModes GetSelectionMode() const; |
23324ae1 FM |
3153 | |
3154 | /** | |
caac7804 BP |
3155 | Returns @true if the given cell is selected. |
3156 | */ | |
3157 | bool IsInSelection(int row, int col) const; | |
3158 | /** | |
3159 | Returns @true if the given cell is selected. | |
3160 | */ | |
3161 | bool IsInSelection(const wxGridCellCoords& coords) const; | |
08dd9b5a | 3162 | |
caac7804 BP |
3163 | /** |
3164 | Returns @true if there are currently any selected cells, rows, columns | |
3165 | or blocks. | |
3166 | */ | |
3167 | bool IsSelection() const; | |
08dd9b5a | 3168 | |
caac7804 BP |
3169 | /** |
3170 | Selects all cells in the grid. | |
23324ae1 | 3171 | */ |
caac7804 | 3172 | void SelectAll(); |
23324ae1 FM |
3173 | |
3174 | /** | |
caac7804 | 3175 | Selects a rectangular block of cells. |
8b9ef005 | 3176 | |
caac7804 BP |
3177 | If @a addToSelected is @false then any existing selection will be |
3178 | deselected; if @true the column will be added to the existing | |
3179 | selection. | |
23324ae1 | 3180 | */ |
caac7804 BP |
3181 | void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, |
3182 | bool addToSelected = false); | |
23324ae1 | 3183 | /** |
caac7804 | 3184 | Selects a rectangular block of cells. |
08dd9b5a | 3185 | |
caac7804 BP |
3186 | If @a addToSelected is @false then any existing selection will be |
3187 | deselected; if @true the column will be added to the existing | |
3188 | selection. | |
23324ae1 | 3189 | */ |
caac7804 BP |
3190 | void SelectBlock(const wxGridCellCoords& topLeft, |
3191 | const wxGridCellCoords& bottomRight, | |
3192 | bool addToSelected = false); | |
23324ae1 FM |
3193 | |
3194 | /** | |
caac7804 | 3195 | Selects the specified column. |
08dd9b5a | 3196 | |
caac7804 BP |
3197 | If @a addToSelected is @false then any existing selection will be |
3198 | deselected; if @true the column will be added to the existing | |
3199 | selection. | |
3200 | ||
3201 | This method won't select anything if the current selection mode is | |
3202 | wxGridSelectRows. | |
23324ae1 | 3203 | */ |
caac7804 | 3204 | void SelectCol(int col, bool addToSelected = false); |
23324ae1 | 3205 | |
23324ae1 | 3206 | /** |
caac7804 | 3207 | Selects the specified row. |
8b9ef005 | 3208 | |
caac7804 BP |
3209 | If @a addToSelected is @false then any existing selection will be |
3210 | deselected; if @true the row will be added to the existing selection. | |
3211 | ||
3212 | This method won't select anything if the current selection mode is | |
3213 | wxGridSelectColumns. | |
23324ae1 | 3214 | */ |
caac7804 | 3215 | void SelectRow(int row, bool addToSelected = false); |
23324ae1 FM |
3216 | |
3217 | /** | |
caac7804 BP |
3218 | Set the colour to be used for drawing the selection background. |
3219 | */ | |
3220 | void SetSelectionBackground(const wxColour& c); | |
08dd9b5a | 3221 | |
caac7804 BP |
3222 | /** |
3223 | Set the colour to be used for drawing the selection foreground. | |
23324ae1 | 3224 | */ |
caac7804 | 3225 | void SetSelectionForeground(const wxColour& c); |
23324ae1 FM |
3226 | |
3227 | /** | |
caac7804 | 3228 | Set the selection behaviour of the grid. |
8b9ef005 | 3229 | |
caac7804 BP |
3230 | The existing selection is converted to conform to the new mode if |
3231 | possible and discarded otherwise (e.g. any individual selected cells | |
3232 | are deselected if the new mode allows only the selection of the entire | |
3233 | rows or columns). | |
23324ae1 | 3234 | */ |
caac7804 | 3235 | void SetSelectionMode(wxGridSelectionModes selmode); |
23324ae1 | 3236 | |
caac7804 | 3237 | //@} |
08dd9b5a | 3238 | |
8b9ef005 | 3239 | |
caac7804 BP |
3240 | /** |
3241 | @name Scrolling | |
3242 | */ | |
3243 | //@{ | |
23324ae1 | 3244 | |
23324ae1 | 3245 | /** |
caac7804 BP |
3246 | Returns the number of pixels per horizontal scroll increment. |
3247 | ||
3248 | The default is 15. | |
3249 | ||
3250 | @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY() | |
23324ae1 | 3251 | */ |
caac7804 | 3252 | int GetScrollLineX() const; |
23324ae1 FM |
3253 | |
3254 | /** | |
caac7804 | 3255 | Returns the number of pixels per vertical scroll increment. |
08dd9b5a | 3256 | |
caac7804 | 3257 | The default is 15. |
8b9ef005 | 3258 | |
caac7804 | 3259 | @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY() |
23324ae1 | 3260 | */ |
caac7804 | 3261 | int GetScrollLineY() const; |
23324ae1 FM |
3262 | |
3263 | /** | |
caac7804 BP |
3264 | Returns @true if a cell is either entirely or at least partially |
3265 | visible in the grid window. | |
08dd9b5a | 3266 | |
caac7804 BP |
3267 | By default, the cell must be entirely visible for this function to |
3268 | return @true but if @a wholeCellVisible is @false, the function returns | |
3269 | @true even if the cell is only partially visible. | |
23324ae1 | 3270 | */ |
caac7804 | 3271 | bool IsVisible(int row, int col, bool wholeCellVisible = true) const; |
23324ae1 | 3272 | /** |
caac7804 BP |
3273 | Returns @true if a cell is either entirely or at least partially |
3274 | visible in the grid window. | |
3275 | ||
3276 | By default, the cell must be entirely visible for this function to | |
3277 | return @true but if @a wholeCellVisible is @false, the function returns | |
3278 | @true even if the cell is only partially visible. | |
23324ae1 | 3279 | */ |
caac7804 BP |
3280 | bool IsVisible(const wxGridCellCoords& coords, |
3281 | bool wholeCellVisible = true) const; | |
23324ae1 FM |
3282 | |
3283 | /** | |
caac7804 BP |
3284 | Brings the specified cell into the visible grid cell area with minimal |
3285 | scrolling. | |
23324ae1 | 3286 | |
caac7804 BP |
3287 | Does nothing if the cell is already visible. |
3288 | */ | |
3289 | void MakeCellVisible(int row, int col); | |
23324ae1 | 3290 | /** |
caac7804 BP |
3291 | Brings the specified cell into the visible grid cell area with minimal |
3292 | scrolling. | |
3293 | ||
3294 | Does nothing if the cell is already visible. | |
23324ae1 | 3295 | */ |
caac7804 | 3296 | void MakeCellVisible(const wxGridCellCoords& coords); |
23324ae1 FM |
3297 | |
3298 | /** | |
caac7804 | 3299 | Sets the number of pixels per horizontal scroll increment. |
08dd9b5a | 3300 | |
caac7804 | 3301 | The default is 15. |
8b9ef005 | 3302 | |
caac7804 | 3303 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY() |
23324ae1 | 3304 | */ |
caac7804 | 3305 | void SetScrollLineX(int x); |
23324ae1 FM |
3306 | |
3307 | /** | |
caac7804 | 3308 | Sets the number of pixels per vertical scroll increment. |
08dd9b5a | 3309 | |
caac7804 | 3310 | The default is 15. |
8b9ef005 | 3311 | |
caac7804 | 3312 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX() |
23324ae1 | 3313 | */ |
caac7804 | 3314 | void SetScrollLineY(int y); |
23324ae1 | 3315 | |
caac7804 | 3316 | //@} |
08dd9b5a | 3317 | |
23324ae1 | 3318 | |
caac7804 BP |
3319 | /** |
3320 | @name Cell and Device Coordinate Translation | |
3321 | */ | |
3322 | //@{ | |
23324ae1 FM |
3323 | |
3324 | /** | |
caac7804 | 3325 | Convert grid cell coordinates to grid window pixel coordinates. |
8b9ef005 | 3326 | |
caac7804 BP |
3327 | This function returns the rectangle that encloses the block of cells |
3328 | limited by @a topLeft and @a bottomRight cell in device coords and | |
3329 | clipped to the client size of the grid window. | |
8b9ef005 | 3330 | |
caac7804 | 3331 | @see CellToRect() |
23324ae1 | 3332 | */ |
caac7804 BP |
3333 | wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft, |
3334 | const wxGridCellCoords& bottomRight) const; | |
23324ae1 FM |
3335 | |
3336 | /** | |
caac7804 BP |
3337 | Return the rectangle corresponding to the grid cell's size and position |
3338 | in logical coordinates. | |
08dd9b5a | 3339 | |
caac7804 BP |
3340 | @see BlockToDeviceRect() |
3341 | */ | |
3342 | wxRect CellToRect(int row, int col) const; | |
3343 | /** | |
3344 | Return the rectangle corresponding to the grid cell's size and position | |
3345 | in logical coordinates. | |
08dd9b5a | 3346 | |
caac7804 | 3347 | @see BlockToDeviceRect() |
23324ae1 | 3348 | */ |
882678eb | 3349 | wxRect CellToRect(const wxGridCellCoords& coords) const; |
23324ae1 | 3350 | |
23324ae1 | 3351 | /** |
caac7804 BP |
3352 | Returns the column at the given pixel position. |
3353 | ||
3354 | @param x | |
3355 | The x position to evaluate. | |
3356 | @param clipToMinMax | |
3357 | If @true, rather than returning @c wxNOT_FOUND, it returns either | |
3358 | the first or last column depending on whether @a x is too far to | |
3359 | the left or right respectively. | |
3360 | @return | |
3361 | The column index or @c wxNOT_FOUND. | |
23324ae1 | 3362 | */ |
caac7804 | 3363 | int XToCol(int x, bool clipToMinMax = false) const; |
23324ae1 FM |
3364 | |
3365 | /** | |
caac7804 BP |
3366 | Returns the column whose right hand edge is close to the given logical |
3367 | @a x position. | |
3368 | ||
3369 | If no column edge is near to this position @c wxNOT_FOUND is returned. | |
23324ae1 | 3370 | */ |
caac7804 | 3371 | int XToEdgeOfCol(int x) const; |
23324ae1 | 3372 | |
23324ae1 | 3373 | /** |
caac7804 BP |
3374 | Translates logical pixel coordinates to the grid cell coordinates. |
3375 | ||
3376 | Notice that this function expects logical coordinates on input so if | |
3377 | you use this function in a mouse event handler you need to translate | |
3378 | the mouse position, which is expressed in device coordinates, to | |
3379 | logical ones. | |
3380 | ||
3381 | @see XToCol(), YToRow() | |
3382 | */ | |
3383 | wxGridCellCoords XYToCell(int x, int y) const; | |
3384 | /** | |
3385 | Translates logical pixel coordinates to the grid cell coordinates. | |
3386 | ||
3387 | Notice that this function expects logical coordinates on input so if | |
3388 | you use this function in a mouse event handler you need to translate | |
3389 | the mouse position, which is expressed in device coordinates, to | |
3390 | logical ones. | |
3391 | ||
3392 | @see XToCol(), YToRow() | |
3393 | */ | |
3394 | wxGridCellCoords XYToCell(const wxPoint& pos) const; | |
3395 | // XYToCell(int, int, wxGridCellCoords&) overload is intentionally | |
3396 | // undocumented, using it is ugly and non-const reference parameters are | |
3397 | // not used in wxWidgets API | |
08dd9b5a | 3398 | |
8b9ef005 | 3399 | /** |
caac7804 BP |
3400 | Returns the row whose bottom edge is close to the given logical @a y |
3401 | position. | |
3402 | ||
3403 | If no row edge is near to this position @c wxNOT_FOUND is returned. | |
23324ae1 | 3404 | */ |
caac7804 | 3405 | int YToEdgeOfRow(int y) const; |
23324ae1 FM |
3406 | |
3407 | /** | |
caac7804 | 3408 | Returns the grid row that corresponds to the logical @a y coordinate. |
08dd9b5a | 3409 | |
caac7804 | 3410 | Returns @c wxNOT_FOUND if there is no row at the @a y position. |
8b9ef005 | 3411 | */ |
caac7804 BP |
3412 | int YToRow(int y, bool clipToMinMax = false) const; |
3413 | ||
3414 | //@} | |
3415 | ||
08dd9b5a | 3416 | |
8b9ef005 | 3417 | /** |
caac7804 BP |
3418 | @name Miscellaneous Functions |
3419 | */ | |
3420 | //@{ | |
8b9ef005 | 3421 | |
caac7804 BP |
3422 | /** |
3423 | Appends one or more new columns to the right of the grid. | |
3424 | ||
3425 | The @a updateLabels argument is not used at present. If you are using a | |
3426 | derived grid table class you will need to override | |
3427 | wxGridTableBase::AppendCols(). See InsertCols() for further | |
3428 | information. | |
3429 | ||
3430 | @return @true on success or @false if appending columns failed. | |
23324ae1 | 3431 | */ |
caac7804 | 3432 | bool AppendCols(int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
3433 | |
3434 | /** | |
caac7804 | 3435 | Appends one or more new rows to the bottom of the grid. |
08dd9b5a | 3436 | |
caac7804 BP |
3437 | The @a updateLabels argument is not used at present. If you are using a |
3438 | derived grid table class you will need to override | |
3439 | wxGridTableBase::AppendRows(). See InsertRows() for further | |
3440 | information. | |
23324ae1 | 3441 | |
caac7804 | 3442 | @return @true on success or @false if appending rows failed. |
23324ae1 | 3443 | */ |
caac7804 | 3444 | bool AppendRows(int numRows = 1, bool updateLabels = true); |
23324ae1 | 3445 | |
23324ae1 | 3446 | /** |
caac7804 BP |
3447 | Return @true if the horizontal grid lines stop at the last column |
3448 | boundary or @false if they continue to the end of the window. | |
3c4f71cc | 3449 | |
caac7804 BP |
3450 | The default is to clip grid lines. |
3451 | ||
3452 | @see ClipHorzGridLines(), AreVertGridLinesClipped() | |
3453 | */ | |
3454 | bool AreHorzGridLinesClipped() const; | |
23324ae1 FM |
3455 | |
3456 | /** | |
caac7804 BP |
3457 | Return @true if the vertical grid lines stop at the last row |
3458 | boundary or @false if they continue to the end of the window. | |
8b9ef005 | 3459 | |
caac7804 BP |
3460 | The default is to clip grid lines. |
3461 | ||
3462 | @see ClipVertGridLines(), AreHorzGridLinesClipped() | |
3463 | */ | |
3464 | bool AreVertGridLinesClipped() const; | |
23324ae1 FM |
3465 | |
3466 | /** | |
caac7804 | 3467 | Increments the grid's batch count. |
08dd9b5a | 3468 | |
caac7804 BP |
3469 | When the count is greater than zero repainting of the grid is |
3470 | suppressed. Each call to BeginBatch must be matched by a later call to | |
3471 | EndBatch(). Code that does a lot of grid modification can be enclosed | |
3472 | between BeginBatch() and EndBatch() calls to avoid screen flicker. The | |
3473 | final EndBatch() call will cause the grid to be repainted. | |
3474 | ||
3475 | Notice that you should use wxGridUpdateLocker which ensures that there | |
3476 | is always a matching EndBatch() call for this BeginBatch() if possible | |
3477 | instead of calling this method directly. | |
8b9ef005 | 3478 | */ |
caac7804 | 3479 | void BeginBatch(); |
08dd9b5a | 3480 | |
8b9ef005 | 3481 | /** |
caac7804 | 3482 | Clears all data in the underlying grid table and repaints the grid. |
8b9ef005 | 3483 | |
caac7804 BP |
3484 | The table is not deleted by this function. If you are using a derived |
3485 | table class then you need to override wxGridTableBase::Clear() for this | |
3486 | function to have any effect. | |
23324ae1 | 3487 | */ |
caac7804 | 3488 | void ClearGrid(); |
23324ae1 FM |
3489 | |
3490 | /** | |
caac7804 BP |
3491 | Change whether the horizontal grid lines are clipped by the end of the |
3492 | last column. | |
8b9ef005 | 3493 | |
caac7804 BP |
3494 | By default the grid lines are not drawn beyond the end of the last |
3495 | column but after calling this function with @a clip set to @false they | |
3496 | will be drawn across the entire grid window. | |
3497 | ||
3498 | @see AreHorzGridLinesClipped(), ClipVertGridLines() | |
3499 | */ | |
3500 | void ClipHorzGridLines(bool clip); | |
23324ae1 FM |
3501 | |
3502 | /** | |
caac7804 BP |
3503 | Change whether the vertical grid lines are clipped by the end of the |
3504 | last row. | |
08dd9b5a | 3505 | |
caac7804 BP |
3506 | By default the grid lines are not drawn beyond the end of the last |
3507 | row but after calling this function with @a clip set to @false they | |
3508 | will be drawn across the entire grid window. | |
3509 | ||
3510 | @see AreVertGridLinesClipped(), ClipHorzGridLines() | |
3511 | */ | |
3512 | void ClipVertGridLines(bool clip); | |
08dd9b5a | 3513 | |
8b9ef005 | 3514 | /** |
caac7804 BP |
3515 | Deletes one or more columns from a grid starting at the specified |
3516 | position. | |
8b9ef005 | 3517 | |
caac7804 BP |
3518 | The @a updateLabels argument is not used at present. If you are using a |
3519 | derived grid table class you will need to override | |
3520 | wxGridTableBase::DeleteCols(). See InsertCols() for further | |
3521 | information. | |
8b9ef005 | 3522 | |
caac7804 | 3523 | @return @true on success or @false if deleting columns failed. |
23324ae1 | 3524 | */ |
caac7804 | 3525 | bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 | 3526 | |
23324ae1 | 3527 | /** |
caac7804 BP |
3528 | Deletes one or more rows from a grid starting at the specified |
3529 | position. | |
8b9ef005 | 3530 | |
caac7804 BP |
3531 | The @a updateLabels argument is not used at present. If you are using a |
3532 | derived grid table class you will need to override | |
3533 | wxGridTableBase::DeleteRows(). See InsertRows() for further | |
3534 | information. | |
8b9ef005 | 3535 | |
caac7804 | 3536 | @return @true on success or @false if appending rows failed. |
23324ae1 | 3537 | */ |
caac7804 | 3538 | bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true); |
23324ae1 | 3539 | |
23324ae1 | 3540 | /** |
caac7804 BP |
3541 | Decrements the grid's batch count. |
3542 | ||
3543 | When the count is greater than zero repainting of the grid is | |
3544 | suppressed. Each previous call to BeginBatch() must be matched by a | |
3545 | later call to EndBatch(). Code that does a lot of grid modification can | |
3546 | be enclosed between BeginBatch() and EndBatch() calls to avoid screen | |
3547 | flicker. The final EndBatch() will cause the grid to be repainted. | |
3548 | ||
3549 | @see wxGridUpdateLocker | |
8b9ef005 | 3550 | */ |
caac7804 | 3551 | void EndBatch(); |
08dd9b5a | 3552 | |
8b9ef005 | 3553 | /** |
caac7804 | 3554 | Overridden wxWindow method. |
8b9ef005 | 3555 | */ |
caac7804 | 3556 | virtual void Fit(); |
08dd9b5a | 3557 | |
8b9ef005 | 3558 | /** |
caac7804 | 3559 | Causes immediate repainting of the grid. |
8b9ef005 | 3560 | |
caac7804 | 3561 | Use this instead of the usual wxWindow::Refresh(). |
23324ae1 | 3562 | */ |
caac7804 | 3563 | void ForceRefresh(); |
23324ae1 FM |
3564 | |
3565 | /** | |
caac7804 BP |
3566 | Returns the number of times that BeginBatch() has been called without |
3567 | (yet) matching calls to EndBatch(). While the grid's batch count is | |
3568 | greater than zero the display will not be updated. | |
3569 | */ | |
3570 | int GetBatchCount(); | |
08dd9b5a | 3571 | |
caac7804 BP |
3572 | /** |
3573 | Returns the total number of grid columns. | |
8b9ef005 | 3574 | |
caac7804 | 3575 | This is the same as the number of columns in the underlying grid table. |
23324ae1 | 3576 | */ |
caac7804 | 3577 | int GetNumberCols() const; |
23324ae1 FM |
3578 | |
3579 | /** | |
caac7804 | 3580 | Returns the total number of grid rows. |
08dd9b5a | 3581 | |
caac7804 | 3582 | This is the same as the number of rows in the underlying grid table. |
23324ae1 | 3583 | */ |
caac7804 | 3584 | int GetNumberRows() const; |
23324ae1 FM |
3585 | |
3586 | /** | |
caac7804 BP |
3587 | Returns the attribute for the given cell creating one if necessary. |
3588 | ||
3589 | If the cell already has an attribute, it is returned. Otherwise a new | |
3590 | attribute is created, associated with the cell and returned. In any | |
3591 | case the caller must call DecRef() on the returned pointer. | |
3592 | ||
3593 | This function may only be called if CanHaveAttributes() returns @true. | |
8b9ef005 | 3594 | */ |
caac7804 | 3595 | wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const; |
08dd9b5a | 3596 | |
8b9ef005 | 3597 | /** |
caac7804 | 3598 | Returns a base pointer to the current table object. |
08dd9b5a | 3599 | |
caac7804 | 3600 | The returned pointer is still owned by the grid. |
23324ae1 | 3601 | */ |
caac7804 | 3602 | wxGridTableBase *GetTable() const; |
23324ae1 FM |
3603 | |
3604 | /** | |
caac7804 BP |
3605 | Inserts one or more new columns into a grid with the first new column |
3606 | at the specified position. | |
08dd9b5a | 3607 | |
caac7804 BP |
3608 | Notice that inserting the columns in the grid requires grid table |
3609 | cooperation: when this method is called, grid object begins by | |
3610 | requesting the underlying grid table to insert new columns. If this is | |
3611 | successful the table notifies the grid and the grid updates the | |
3612 | display. For a default grid (one where you have called CreateGrid()) | |
3613 | this process is automatic. If you are using a custom grid table | |
3614 | (specified with SetTable()) then you must override | |
3615 | wxGridTableBase::InsertCols() in your derived table class. | |
3616 | ||
3617 | @param pos | |
3618 | The position which the first newly inserted column will have. | |
3619 | @param numCols | |
3620 | The number of columns to insert. | |
3621 | @param updateLabels | |
3622 | Currently not used. | |
3623 | @return | |
3624 | @true if the columns were successfully inserted, @false if an error | |
3625 | occurred (most likely the table couldn't be updated). | |
23324ae1 | 3626 | */ |
caac7804 | 3627 | bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
3628 | |
3629 | /** | |
caac7804 BP |
3630 | Inserts one or more new rows into a grid with the first new row at the |
3631 | specified position. | |
8b9ef005 | 3632 | |
caac7804 BP |
3633 | Notice that you must implement wxGridTableBase::InsertRows() if you use |
3634 | a grid with a custom table, please see InsertCols() for more | |
3635 | information. | |
8b9ef005 | 3636 | |
caac7804 BP |
3637 | @param pos |
3638 | The position which the first newly inserted row will have. | |
3639 | @param numRows | |
3640 | The number of rows to insert. | |
3641 | @param updateLabels | |
3642 | Currently not used. | |
3643 | @return | |
3644 | @true if the rows were successfully inserted, @false if an error | |
3645 | occurred (most likely the table couldn't be updated). | |
3646 | */ | |
3647 | bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true); | |
8b9ef005 | 3648 | |
caac7804 BP |
3649 | /** |
3650 | Sets the cell attributes for all cells in the specified column. | |
08dd9b5a | 3651 | |
caac7804 BP |
3652 | For more information about controlling grid cell attributes see the |
3653 | wxGridCellAttr cell attribute class and the @ref overview_grid. | |
3654 | */ | |
3655 | void SetColAttr(int col, wxGridCellAttr* attr); | |
23324ae1 FM |
3656 | |
3657 | /** | |
caac7804 | 3658 | Sets the extra margins used around the grid area. |
08dd9b5a | 3659 | |
caac7804 BP |
3660 | A grid may occupy more space than needed for its data display and |
3661 | this function allows to set how big this extra space is | |
23324ae1 | 3662 | */ |
caac7804 | 3663 | void SetMargins(int extraWidth, int extraHeight); |
23324ae1 FM |
3664 | |
3665 | /** | |
caac7804 | 3666 | Sets the cell attributes for all cells in the specified row. |
08dd9b5a | 3667 | |
caac7804 BP |
3668 | The grid takes ownership of the attribute pointer. |
3669 | ||
3670 | See the wxGridCellAttr class for more information about controlling | |
3671 | cell attributes. | |
23324ae1 | 3672 | */ |
caac7804 BP |
3673 | void SetRowAttr(int row, wxGridCellAttr* attr); |
3674 | ||
3675 | //@} | |
23324ae1 | 3676 | |
11393d29 VZ |
3677 | |
3678 | /** | |
3679 | @name Sorting support. | |
3680 | ||
3681 | wxGrid doesn't provide any support for sorting the data but it does | |
3682 | generate events allowing the user code to sort it and supports | |
3683 | displaying the sort indicator in the column used for sorting. | |
3684 | ||
3685 | To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT | |
3686 | event (and not veto it) and resort the data displayed in the grid. The | |
3687 | grid will automatically update the sorting indicator on the column | |
3688 | which was clicked. | |
3689 | ||
3690 | You can also call the functions in this section directly to update the | |
3691 | sorting indicator. Once again, they don't do anything with the grid | |
3692 | data, it remains your responsibility to actually sort it appropriately. | |
3693 | */ | |
3694 | //@{ | |
3695 | ||
3696 | /** | |
3697 | Return the column in which the sorting indicator is currently | |
3698 | displayed. | |
3699 | ||
3700 | Returns @c wxNOT_FOUND if sorting indicator is not currently displayed | |
3701 | at all. | |
3702 | ||
3703 | @see SetSortingColumn() | |
3704 | */ | |
3705 | int GetSortingColumn() const; | |
3706 | ||
3707 | /** | |
3708 | Return @true if this column is currently used for sorting. | |
3709 | ||
3710 | @see GetSortingColumn() | |
3711 | */ | |
3712 | bool IsSortingBy(int col) const; | |
3713 | ||
3714 | /** | |
3715 | Return @true if the current sorting order is ascending or @false if it | |
3716 | is descending. | |
3717 | ||
3718 | It only makes sense to call this function if GetSortingColumn() returns | |
3719 | a valid column index and not @c wxNOT_FOUND. | |
3720 | ||
3721 | @see SetSortingColumn() | |
3722 | */ | |
3723 | bool IsSortOrderAscending() const; | |
3724 | ||
3725 | /** | |
3726 | Set the column to display the sorting indicator in and its direction. | |
3727 | ||
3728 | @param col | |
3729 | The column to display the sorting indicator in or @c wxNOT_FOUND to | |
3730 | remove any currently displayed sorting indicator. | |
3731 | @param ascending | |
3732 | If @true, display the ascending sort indicator, otherwise display | |
3733 | the descending sort indicator. | |
3734 | ||
3735 | @see GetSortingColumn(), IsSortOrderAscending() | |
3736 | */ | |
3737 | void SetSortingColumn(int col, bool ascending = true); | |
3738 | ||
3739 | /** | |
3740 | Remove any currently shown sorting indicator. | |
3741 | ||
3742 | This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND | |
3743 | first argument. | |
3744 | */ | |
3745 | void UnsetSortingColumn(); | |
3746 | //@} | |
3039ade9 | 3747 | |
882678eb | 3748 | |
3039ade9 VZ |
3749 | /** |
3750 | @name Accessors for component windows. | |
3751 | ||
3752 | Return the various child windows of wxGrid. | |
3753 | ||
3754 | wxGrid is an empty parent window for 4 children representing the column | |
3755 | labels window (top), the row labels window (left), the corner window | |
3756 | (top left) and the main grid window. It may be necessary to use these | |
3757 | individual windows and not the wxGrid window itself if you need to | |
3758 | handle events for them (this can be done using wxEvtHandler::Connect() | |
3759 | or wxWindow::PushEventHandler()) or do something else requiring the use | |
3760 | of the correct window pointer. Notice that you should not, however, | |
3761 | change these windows (e.g. reposition them or draw over them) because | |
3762 | they are managed by wxGrid itself. | |
3763 | */ | |
3764 | //@{ | |
3765 | ||
3766 | /** | |
3767 | Return the main grid window containing the grid cells. | |
3768 | ||
3769 | This window is always shown. | |
3770 | */ | |
3771 | wxWindow *GetGridWindow() const; | |
3772 | ||
3773 | /** | |
3774 | Return the row labels window. | |
3775 | ||
3776 | This window is not shown if the row labels were hidden using | |
3777 | HideRowLabels(). | |
3778 | */ | |
3779 | wxWindow *GetGridRowLabelWindow() const; | |
3780 | ||
3781 | /** | |
3782 | Return the column labels window. | |
3783 | ||
3784 | This window is not shown if the columns labels were hidden using | |
3785 | HideColLabels(). | |
3786 | ||
3787 | Depending on whether UseNativeColHeader() was called or not this can be | |
3788 | either a wxHeaderCtrl or a plain wxWindow. This function returns a valid | |
3789 | window pointer in either case but in the former case you can also use | |
3790 | GetGridColHeader() to access it if you need wxHeaderCtrl-specific | |
3791 | functionality. | |
3792 | */ | |
600e986a | 3793 | wxWindow *GetGridColLabelWindow() const; |
3039ade9 VZ |
3794 | |
3795 | /** | |
3796 | Return the window in the top left grid corner. | |
3797 | ||
3798 | This window is shown only of both columns and row labels are shown and | |
3799 | normally doesn't contain anything. Clicking on it is handled by wxGrid | |
3800 | however and can be used to select the entire grid. | |
3801 | */ | |
3802 | wxWindow *GetGridCornerLabelWindow() const; | |
3803 | ||
3804 | /** | |
3805 | Return the header control used for column labels display. | |
3806 | ||
3807 | This function can only be called if UseNativeColHeader() had been | |
3808 | called. | |
3809 | */ | |
3810 | wxHeaderCtrl *GetGridColHeader() const; | |
3811 | ||
3812 | //@} | |
882678eb FM |
3813 | |
3814 | protected: | |
3815 | /** | |
3816 | Returns @true if this grid has support for cell attributes. | |
3817 | ||
3818 | The grid supports attributes if it has the associated table which, in | |
3819 | turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes() | |
3820 | returns @true. | |
3821 | */ | |
3822 | bool CanHaveAttributes() const; | |
3823 | ||
3824 | /** | |
3825 | Get the minimal width of the given column/row. | |
3826 | ||
3827 | The value returned by this function may be different than that returned | |
3828 | by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been | |
3829 | called for this column. | |
3830 | */ | |
3831 | int GetColMinimalWidth(int col) const; | |
3832 | ||
3833 | /** | |
3834 | Returns the coordinate of the right border specified column. | |
3835 | */ | |
3836 | int GetColRight(int col) const; | |
3837 | ||
3838 | /** | |
3839 | Returns the coordinate of the left border specified column. | |
3840 | */ | |
3841 | int GetColLeft(int col) const; | |
3842 | ||
3843 | /** | |
3844 | Returns the minimal size for the given column. | |
3845 | ||
3846 | The value returned by this function may be different than that returned | |
3847 | by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been | |
3848 | called for this row. | |
3849 | */ | |
3850 | int GetRowMinimalHeight(int col) const; | |
8b9ef005 | 3851 | }; |
23324ae1 | 3852 | |
08dd9b5a | 3853 | |
23324ae1 | 3854 | |
8b9ef005 BP |
3855 | /** |
3856 | @class wxGridUpdateLocker | |
23324ae1 | 3857 | |
8b9ef005 BP |
3858 | This small class can be used to prevent wxGrid from redrawing during its |
3859 | lifetime by calling wxGrid::BeginBatch() in its constructor and | |
3860 | wxGrid::EndBatch() in its destructor. It is typically used in a function | |
3861 | performing several operations with a grid which would otherwise result in | |
3862 | flicker. For example: | |
23324ae1 | 3863 | |
8b9ef005 BP |
3864 | @code |
3865 | void MyFrame::Foo() | |
3866 | { | |
3867 | m_grid = new wxGrid(this, ...); | |
23324ae1 | 3868 | |
8b9ef005 BP |
3869 | wxGridUpdateLocker noUpdates(m_grid); |
3870 | m_grid-AppendColumn(); | |
3871 | // ... many other operations with m_grid ... | |
3872 | m_grid-AppendRow(); | |
08dd9b5a | 3873 | |
8b9ef005 BP |
3874 | // destructor called, grid refreshed |
3875 | } | |
3876 | @endcode | |
08dd9b5a | 3877 | |
8b9ef005 BP |
3878 | Using this class is easier and safer than calling wxGrid::BeginBatch() and |
3879 | wxGrid::EndBatch() because you don't risk missing the call the latter (due | |
3880 | to an exception for example). | |
23324ae1 | 3881 | |
8b9ef005 BP |
3882 | @library{wxadv} |
3883 | @category{grid} | |
3884 | */ | |
3885 | class wxGridUpdateLocker | |
3886 | { | |
3887 | public: | |
23324ae1 | 3888 | /** |
8b9ef005 BP |
3889 | Creates an object preventing the updates of the specified @a grid. The |
3890 | parameter could be @NULL in which case nothing is done. If @a grid is | |
3891 | non-@NULL then the grid must exist for longer than this | |
3892 | wxGridUpdateLocker object itself. | |
08dd9b5a | 3893 | |
8b9ef005 BP |
3894 | The default constructor could be followed by a call to Create() to set |
3895 | the grid object later. | |
23324ae1 | 3896 | */ |
8b9ef005 | 3897 | wxGridUpdateLocker(wxGrid* grid = NULL); |
23324ae1 FM |
3898 | |
3899 | /** | |
8b9ef005 BP |
3900 | Destructor reenables updates for the grid this object is associated |
3901 | with. | |
23324ae1 | 3902 | */ |
8b9ef005 | 3903 | ~wxGridUpdateLocker(); |
23324ae1 FM |
3904 | |
3905 | /** | |
8b9ef005 BP |
3906 | This method can be called if the object had been constructed using the |
3907 | default constructor. It must not be called more than once. | |
3908 | */ | |
3909 | void Create(wxGrid* grid); | |
3910 | }; | |
08dd9b5a | 3911 | |
08dd9b5a | 3912 | |
23324ae1 | 3913 | |
8b9ef005 BP |
3914 | /** |
3915 | @class wxGridEvent | |
08dd9b5a | 3916 | |
8b9ef005 | 3917 | This event class contains information about various grid events. |
8a3e536c | 3918 | |
2b1f9fa0 VZ |
3919 | Notice that all grid event table macros are available in two versions: |
3920 | @c EVT_GRID_XXX and @c EVT_GRID_CMD_XXX. The only difference between the | |
3921 | two is that the former doesn't allow to specify the grid window identifier | |
3922 | and so takes a single parameter, the event handler, but is not suitable if | |
3923 | there is more than one grid control in the window where the event table is | |
3924 | used (as it would catch the events from all the grids). The version with @c | |
3925 | CMD takes the id as first argument and the event handler as the second one | |
3926 | and so can be used with multiple grids as well. Otherwise there are no | |
3927 | difference between the two and only the versions without the id are | |
3928 | documented below for brevity. | |
3929 | ||
8b9ef005 | 3930 | @beginEventTable{wxGridEvent} |
763163a8 VZ |
3931 | @event{EVT_GRID_CELL_CHANGING(func)} |
3932 | The user is about to change the data in a cell. The new cell value as | |
3933 | string is available from GetString() event object method. This event | |
f8f31de6 FM |
3934 | can be vetoed if the change is not allowed. |
3935 | Processes a @c wxEVT_GRID_CELL_CHANGING event type. | |
763163a8 VZ |
3936 | @event{EVT_GRID_CELL_CHANGED(func)} |
3937 | The user changed the data in a cell. The old cell value as string is | |
3938 | available from GetString() event object method. Notice that vetoing | |
3939 | this event still works for backwards compatibility reasons but any new | |
3940 | code should only veto EVT_GRID_CELL_CHANGING event and not this one. | |
3941 | Processes a @c wxEVT_GRID_CELL_CHANGED event type. | |
8b9ef005 BP |
3942 | @event{EVT_GRID_CELL_LEFT_CLICK(func)} |
3943 | The user clicked a cell with the left mouse button. Processes a | |
3944 | @c wxEVT_GRID_CELL_LEFT_CLICK event type. | |
3945 | @event{EVT_GRID_CELL_LEFT_DCLICK(func)} | |
3946 | The user double-clicked a cell with the left mouse button. Processes a | |
3947 | @c wxEVT_GRID_CELL_LEFT_DCLICK event type. | |
3948 | @event{EVT_GRID_CELL_RIGHT_CLICK(func)} | |
3949 | The user clicked a cell with the right mouse button. Processes a | |
3950 | @c wxEVT_GRID_CELL_RIGHT_CLICK event type. | |
3951 | @event{EVT_GRID_CELL_RIGHT_DCLICK(func)} | |
3952 | The user double-clicked a cell with the right mouse button. Processes a | |
3953 | @c wxEVT_GRID_CELL_RIGHT_DCLICK event type. | |
3954 | @event{EVT_GRID_EDITOR_HIDDEN(func)} | |
3955 | The editor for a cell was hidden. Processes a | |
3956 | @c wxEVT_GRID_EDITOR_HIDDEN event type. | |
3957 | @event{EVT_GRID_EDITOR_SHOWN(func)} | |
3958 | The editor for a cell was shown. Processes a | |
3959 | @c wxEVT_GRID_EDITOR_SHOWN event type. | |
3960 | @event{EVT_GRID_LABEL_LEFT_CLICK(func)} | |
3961 | The user clicked a label with the left mouse button. Processes a | |
3962 | @c wxEVT_GRID_LABEL_LEFT_CLICK event type. | |
3963 | @event{EVT_GRID_LABEL_LEFT_DCLICK(func)} | |
3964 | The user double-clicked a label with the left mouse button. Processes a | |
3965 | @c wxEVT_GRID_LABEL_LEFT_DCLICK event type. | |
3966 | @event{EVT_GRID_LABEL_RIGHT_CLICK(func)} | |
3967 | The user clicked a label with the right mouse button. Processes a | |
3968 | @c wxEVT_GRID_LABEL_RIGHT_CLICK event type. | |
3969 | @event{EVT_GRID_LABEL_RIGHT_DCLICK(func)} | |
3970 | The user double-clicked a label with the right mouse button. Processes | |
3971 | a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type. | |
3972 | @event{EVT_GRID_SELECT_CELL(func)} | |
c6cc8b15 VZ |
3973 | The given cell was made current, either by user or by the program via a |
3974 | call to SetGridCursor() or GoToCell(). Processes a | |
8b9ef005 | 3975 | @c wxEVT_GRID_SELECT_CELL event type. |
cd68daf5 VZ |
3976 | @event{EVT_GRID_COL_MOVE(func)} |
3977 | The user tries to change the order of the columns in the grid by | |
3978 | dragging the column specified by GetCol(). This event can be vetoed to | |
3979 | either prevent the user from reordering the column change completely | |
3980 | (but notice that if you don't want to allow it at all, you simply | |
3981 | shouldn't call wxGrid::EnableDragColMove() in the first place), vetoed | |
3982 | but handled in some way in the handler, e.g. by really moving the | |
3983 | column to the new position at the associated table level, or allowed to | |
3984 | proceed in which case wxGrid::SetColPos() is used to reorder the | |
3985 | columns display order without affecting the use of the column indices | |
3986 | otherwise. | |
3987 | This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type. | |
11393d29 VZ |
3988 | @event{EVT_GRID_COL_SORT(func)} |
3989 | This event is generated when a column is clicked by the user and its | |
3990 | name is explained by the fact that the custom reaction to a click on a | |
3991 | column is to sort the grid contents by this column. However the grid | |
3992 | itself has no special support for sorting and it's up to the handler of | |
3993 | this event to update the associated table. But if the event is handled | |
3994 | (and not vetoed) the grid supposes that the table was indeed resorted | |
3995 | and updates the column to indicate the new sort order and refreshes | |
3996 | itself. | |
11393d29 | 3997 | This event macro corresponds to @c wxEVT_GRID_COL_SORT event type. |
8b9ef005 | 3998 | @endEventTable |
8a3e536c | 3999 | |
8b9ef005 | 4000 | @library{wxadv} |
87638422 | 4001 | @category{grid,events} |
8b9ef005 BP |
4002 | */ |
4003 | class wxGridEvent : public wxNotifyEvent | |
4004 | { | |
4005 | public: | |
4006 | /** | |
4007 | Default constructor. | |
23324ae1 | 4008 | */ |
8b9ef005 | 4009 | wxGridEvent(); |
23324ae1 | 4010 | /** |
8b9ef005 | 4011 | Constructor for initializing all event attributes. |
23324ae1 | 4012 | */ |
8b9ef005 BP |
4013 | wxGridEvent(int id, wxEventType type, wxObject* obj, |
4014 | int row = -1, int col = -1, int x = -1, int y = -1, | |
ccf39540 | 4015 | bool sel = true, const wxKeyboardState& kbd = wxKeyboardState()); |
23324ae1 FM |
4016 | |
4017 | /** | |
8b9ef005 | 4018 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 4019 | */ |
8b9ef005 | 4020 | bool AltDown() const; |
23324ae1 FM |
4021 | |
4022 | /** | |
8b9ef005 | 4023 | Returns @true if the Control key was down at the time of the event. |
23324ae1 | 4024 | */ |
8b9ef005 | 4025 | bool ControlDown() const; |
23324ae1 FM |
4026 | |
4027 | /** | |
8b9ef005 | 4028 | Column at which the event occurred. |
23324ae1 | 4029 | */ |
8b9ef005 | 4030 | virtual int GetCol(); |
23324ae1 FM |
4031 | |
4032 | /** | |
8b9ef005 | 4033 | Position in pixels at which the event occurred. |
23324ae1 | 4034 | */ |
8b9ef005 | 4035 | wxPoint GetPosition(); |
23324ae1 FM |
4036 | |
4037 | /** | |
8b9ef005 | 4038 | Row at which the event occurred. |
23324ae1 | 4039 | */ |
8b9ef005 | 4040 | virtual int GetRow(); |
23324ae1 FM |
4041 | |
4042 | /** | |
8b9ef005 | 4043 | Returns @true if the Meta key was down at the time of the event. |
23324ae1 | 4044 | */ |
8b9ef005 | 4045 | bool MetaDown() const; |
23324ae1 FM |
4046 | |
4047 | /** | |
8b9ef005 BP |
4048 | Returns @true if the user is selecting grid cells, or @false if |
4049 | deselecting. | |
23324ae1 | 4050 | */ |
8b9ef005 | 4051 | bool Selecting(); |
23324ae1 FM |
4052 | |
4053 | /** | |
8b9ef005 | 4054 | Returns @true if the Shift key was down at the time of the event. |
23324ae1 | 4055 | */ |
8b9ef005 BP |
4056 | bool ShiftDown() const; |
4057 | }; | |
23324ae1 | 4058 | |
08dd9b5a | 4059 | |
8b9ef005 BP |
4060 | |
4061 | /** | |
4062 | @class wxGridSizeEvent | |
4063 | ||
4064 | This event class contains information about a row/column resize event. | |
4065 | ||
4066 | @beginEventTable{wxGridSizeEvent} | |
8b9ef005 | 4067 | @event{EVT_GRID_CMD_COL_SIZE(id, func)} |
27bb2c8c VZ |
4068 | The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event |
4069 | type. | |
8b9ef005 | 4070 | @event{EVT_GRID_CMD_ROW_SIZE(id, func)} |
27bb2c8c VZ |
4071 | The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event |
4072 | type. | |
4073 | @event{EVT_GRID_COL_SIZE(func)} | |
4074 | Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id. | |
4075 | @event{EVT_GRID_ROW_SIZE(func)} | |
4076 | Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id. | |
8b9ef005 BP |
4077 | @endEventTable |
4078 | ||
4079 | @library{wxadv} | |
87638422 | 4080 | @category{grid,events} |
8b9ef005 BP |
4081 | */ |
4082 | class wxGridSizeEvent : public wxNotifyEvent | |
4083 | { | |
4084 | public: | |
4085 | /** | |
4086 | Default constructor. | |
23324ae1 | 4087 | */ |
8b9ef005 | 4088 | wxGridSizeEvent(); |
23324ae1 | 4089 | /** |
8b9ef005 | 4090 | Constructor for initializing all event attributes. |
23324ae1 | 4091 | */ |
8b9ef005 BP |
4092 | wxGridSizeEvent(int id, wxEventType type, wxObject* obj, |
4093 | int rowOrCol = -1, int x = -1, int y = -1, | |
ccf39540 | 4094 | const wxKeyboardState& kbd = wxKeyboardState()); |
23324ae1 FM |
4095 | |
4096 | /** | |
8b9ef005 | 4097 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 4098 | */ |
8b9ef005 | 4099 | bool AltDown() const; |
23324ae1 FM |
4100 | |
4101 | /** | |
8b9ef005 | 4102 | Returns @true if the Control key was down at the time of the event. |
23324ae1 | 4103 | */ |
8b9ef005 | 4104 | bool ControlDown() const; |
23324ae1 FM |
4105 | |
4106 | /** | |
8b9ef005 | 4107 | Position in pixels at which the event occurred. |
23324ae1 | 4108 | */ |
8b9ef005 | 4109 | wxPoint GetPosition(); |
23324ae1 FM |
4110 | |
4111 | /** | |
8b9ef005 | 4112 | Row or column at that was resized. |
23324ae1 | 4113 | */ |
8b9ef005 | 4114 | int GetRowOrCol(); |
23324ae1 FM |
4115 | |
4116 | /** | |
8b9ef005 | 4117 | Returns @true if the Meta key was down at the time of the event. |
23324ae1 | 4118 | */ |
8b9ef005 | 4119 | bool MetaDown() const; |
23324ae1 FM |
4120 | |
4121 | /** | |
8b9ef005 | 4122 | Returns @true if the Shift key was down at the time of the event. |
23324ae1 | 4123 | */ |
8b9ef005 BP |
4124 | bool ShiftDown() const; |
4125 | }; | |
23324ae1 | 4126 | |
3c4f71cc | 4127 | |
23324ae1 | 4128 | |
8b9ef005 BP |
4129 | /** |
4130 | @class wxGridRangeSelectEvent | |
08dd9b5a | 4131 | |
8b9ef005 BP |
4132 | @beginEventTable{wxGridRangeSelectEvent} |
4133 | @event{EVT_GRID_RANGE_SELECT(func)} | |
4134 | The user selected a group of contiguous cells. Processes a | |
4135 | @c wxEVT_GRID_RANGE_SELECT event type. | |
4136 | @event{EVT_GRID_CMD_RANGE_SELECT(id, func)} | |
4137 | The user selected a group of contiguous cells; variant taking a window | |
4138 | identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type. | |
4139 | @endEventTable | |
08dd9b5a | 4140 | |
8b9ef005 | 4141 | @library{wxadv} |
87638422 | 4142 | @category{grid,events} |
8b9ef005 BP |
4143 | */ |
4144 | class wxGridRangeSelectEvent : public wxNotifyEvent | |
4145 | { | |
4146 | public: | |
4147 | /** | |
4148 | Default constructor. | |
23324ae1 | 4149 | */ |
8b9ef005 | 4150 | wxGridRangeSelectEvent(); |
23324ae1 | 4151 | /** |
8b9ef005 | 4152 | Constructor for initializing all event attributes. |
23324ae1 | 4153 | */ |
8b9ef005 BP |
4154 | wxGridRangeSelectEvent(int id, wxEventType type, |
4155 | wxObject* obj, | |
4156 | const wxGridCellCoords& topLeft, | |
4157 | const wxGridCellCoords& bottomRight, | |
ccf39540 | 4158 | bool sel = true, const wxKeyboardState& kbd = wxKeyboardState()); |
23324ae1 FM |
4159 | |
4160 | /** | |
8b9ef005 | 4161 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 4162 | */ |
8b9ef005 | 4163 | bool AltDown() const; |
23324ae1 FM |
4164 | |
4165 | /** | |
8b9ef005 | 4166 | Returns @true if the Control key was down at the time of the event. |
23324ae1 | 4167 | */ |
8b9ef005 | 4168 | bool ControlDown() const; |
23324ae1 FM |
4169 | |
4170 | /** | |
8b9ef005 | 4171 | Top left corner of the rectangular area that was (de)selected. |
23324ae1 | 4172 | */ |
8b9ef005 | 4173 | wxGridCellCoords GetBottomRightCoords(); |
23324ae1 | 4174 | |
8a3e536c | 4175 | /** |
8b9ef005 BP |
4176 | Bottom row of the rectangular area that was (de)selected. |
4177 | */ | |
4178 | int GetBottomRow(); | |
8a3e536c | 4179 | |
23324ae1 | 4180 | /** |
8b9ef005 | 4181 | Left column of the rectangular area that was (de)selected. |
23324ae1 | 4182 | */ |
8b9ef005 | 4183 | int GetLeftCol(); |
23324ae1 FM |
4184 | |
4185 | /** | |
8b9ef005 | 4186 | Right column of the rectangular area that was (de)selected. |
23324ae1 | 4187 | */ |
8b9ef005 | 4188 | int GetRightCol(); |
5e6e278d | 4189 | |
5e6e278d | 4190 | /** |
8b9ef005 | 4191 | Top left corner of the rectangular area that was (de)selected. |
5e6e278d | 4192 | */ |
8b9ef005 | 4193 | wxGridCellCoords GetTopLeftCoords(); |
5e6e278d FM |
4194 | |
4195 | /** | |
8b9ef005 | 4196 | Top row of the rectangular area that was (de)selected. |
5e6e278d | 4197 | */ |
8b9ef005 | 4198 | int GetTopRow(); |
5e6e278d FM |
4199 | |
4200 | /** | |
8b9ef005 | 4201 | Returns @true if the Meta key was down at the time of the event. |
5e6e278d | 4202 | */ |
8b9ef005 | 4203 | bool MetaDown() const; |
5e6e278d FM |
4204 | |
4205 | /** | |
8b9ef005 | 4206 | Returns @true if the area was selected, @false otherwise. |
5e6e278d | 4207 | */ |
8b9ef005 | 4208 | bool Selecting(); |
5e6e278d FM |
4209 | |
4210 | /** | |
8b9ef005 | 4211 | Returns @true if the Shift key was down at the time of the event. |
5e6e278d | 4212 | */ |
8b9ef005 | 4213 | bool ShiftDown() const; |
23324ae1 FM |
4214 | }; |
4215 | ||
4216 | ||
e54c96f1 | 4217 | |
23324ae1 | 4218 | /** |
8b9ef005 | 4219 | @class wxGridEditorCreatedEvent |
7c913512 | 4220 | |
8b9ef005 BP |
4221 | @beginEventTable{wxGridEditorCreatedEvent} |
4222 | @event{EVT_GRID_EDITOR_CREATED(func)} | |
4223 | The editor for a cell was created. Processes a | |
4224 | @c wxEVT_GRID_EDITOR_CREATED event type. | |
4225 | @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)} | |
4226 | The editor for a cell was created; variant taking a window identifier. | |
4227 | Processes a @c wxEVT_GRID_EDITOR_CREATED event type. | |
4228 | @endEventTable | |
7c913512 | 4229 | |
23324ae1 | 4230 | @library{wxadv} |
87638422 | 4231 | @category{grid,events} |
23324ae1 | 4232 | */ |
8b9ef005 | 4233 | class wxGridEditorCreatedEvent : public wxCommandEvent |
23324ae1 FM |
4234 | { |
4235 | public: | |
4236 | /** | |
4237 | Default constructor. | |
4238 | */ | |
8b9ef005 | 4239 | wxGridEditorCreatedEvent(); |
23324ae1 | 4240 | /** |
8b9ef005 | 4241 | Constructor for initializing all event attributes. |
23324ae1 | 4242 | */ |
8b9ef005 BP |
4243 | wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj, |
4244 | int row, int col, wxControl* ctrl); | |
23324ae1 FM |
4245 | |
4246 | /** | |
8b9ef005 | 4247 | Returns the column at which the event occurred. |
23324ae1 | 4248 | */ |
8b9ef005 | 4249 | int GetCol(); |
7c913512 | 4250 | |
8b9ef005 BP |
4251 | /** |
4252 | Returns the edit control. | |
4253 | */ | |
4254 | wxControl* GetControl(); | |
7c913512 | 4255 | |
8b9ef005 BP |
4256 | /** |
4257 | Returns the row at which the event occurred. | |
4258 | */ | |
4259 | int GetRow(); | |
7c913512 | 4260 | |
23324ae1 | 4261 | /** |
8b9ef005 | 4262 | Sets the column at which the event occurred. |
23324ae1 | 4263 | */ |
8b9ef005 | 4264 | void SetCol(int col); |
23324ae1 FM |
4265 | |
4266 | /** | |
8b9ef005 | 4267 | Sets the edit control. |
23324ae1 | 4268 | */ |
8b9ef005 | 4269 | void SetControl(wxControl* ctrl); |
23324ae1 FM |
4270 | |
4271 | /** | |
8b9ef005 | 4272 | Sets the row at which the event occurred. |
23324ae1 | 4273 | */ |
8b9ef005 | 4274 | void SetRow(int row); |
23324ae1 | 4275 | }; |
e54c96f1 | 4276 |