]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: grid.h | |
e54c96f1 | 3 | // Purpose: interface of wxGridCellFloatRenderer |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxGridCellFloatRenderer | |
7c913512 | 11 | |
23324ae1 | 12 | This class may be used to format floating point data in a cell. |
7c913512 | 13 | |
23324ae1 | 14 | @library{wxadv} |
42b5841f | 15 | @category{grid} |
7c913512 | 16 | |
e54c96f1 | 17 | @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellStringRenderer, |
23324ae1 FM |
18 | wxGridCellBoolRenderer |
19 | */ | |
20 | class wxGridCellFloatRenderer : public wxGridCellStringRenderer | |
21 | { | |
22 | public: | |
23 | /** | |
7c913512 | 24 | @param width |
4cc4bfaf | 25 | Minimum number of characters to be shown. |
7c913512 | 26 | @param precision |
4cc4bfaf | 27 | Number of digits after the decimal dot. |
23324ae1 FM |
28 | */ |
29 | wxGridCellFloatRenderer(int width = -1, int precision = -1); | |
30 | ||
31 | /** | |
42b5841f | 32 | Returns the precision. |
23324ae1 | 33 | */ |
328f5751 | 34 | int GetPrecision() const; |
23324ae1 FM |
35 | |
36 | /** | |
42b5841f | 37 | Returns the width. |
23324ae1 | 38 | */ |
328f5751 | 39 | int GetWidth() const; |
23324ae1 FM |
40 | |
41 | /** | |
42 | Parameters string format is "width[,precision]". | |
43 | */ | |
44 | void SetParameters(const wxString& params); | |
45 | ||
46 | /** | |
42b5841f | 47 | Sets the precision. |
23324ae1 FM |
48 | */ |
49 | void SetPrecision(int precision); | |
50 | ||
51 | /** | |
42b5841f | 52 | Sets the width. |
23324ae1 FM |
53 | */ |
54 | void SetWidth(int width); | |
55 | }; | |
56 | ||
57 | ||
e54c96f1 | 58 | |
23324ae1 FM |
59 | /** |
60 | @class wxGridTableBase | |
7c913512 | 61 | |
23324ae1 | 62 | Grid table classes. |
7c913512 | 63 | |
23324ae1 | 64 | @library{wxadv} |
42b5841f | 65 | @category{grid} |
23324ae1 FM |
66 | */ |
67 | class wxGridTableBase : public wxObject | |
68 | { | |
69 | public: | |
70 | /** | |
3c4f71cc | 71 | |
23324ae1 FM |
72 | */ |
73 | wxGridTableBase(); | |
74 | ||
75 | /** | |
3c4f71cc | 76 | |
23324ae1 FM |
77 | */ |
78 | ~wxGridTableBase(); | |
79 | ||
80 | /** | |
3c4f71cc | 81 | |
23324ae1 FM |
82 | */ |
83 | bool AppendCols(size_t numCols = 1); | |
84 | ||
85 | /** | |
3c4f71cc | 86 | |
23324ae1 FM |
87 | */ |
88 | bool AppendRows(size_t numRows = 1); | |
89 | ||
90 | /** | |
3c4f71cc | 91 | |
23324ae1 FM |
92 | */ |
93 | bool CanGetValueAs(int row, int col, const wxString& typeName); | |
94 | ||
95 | /** | |
96 | Does this table allow attributes? Default implementation creates | |
97 | a wxGridCellAttrProvider if necessary. | |
98 | */ | |
99 | bool CanHaveAttributes(); | |
100 | ||
101 | /** | |
3c4f71cc | 102 | |
23324ae1 FM |
103 | */ |
104 | bool CanSetValueAs(int row, int col, const wxString& typeName); | |
105 | ||
106 | /** | |
3c4f71cc | 107 | |
23324ae1 FM |
108 | */ |
109 | void Clear(); | |
110 | ||
111 | /** | |
3c4f71cc | 112 | |
23324ae1 FM |
113 | */ |
114 | bool DeleteCols(size_t pos = 0, size_t numCols = 1); | |
115 | ||
116 | /** | |
3c4f71cc | 117 | |
23324ae1 FM |
118 | */ |
119 | bool DeleteRows(size_t pos = 0, size_t numRows = 1); | |
120 | ||
121 | /** | |
122 | by default forwarded to wxGridCellAttrProvider if any. May be | |
123 | overridden to handle attributes directly in the table. | |
124 | */ | |
125 | wxGridCellAttr* GetAttr(int row, int col); | |
126 | ||
127 | /** | |
128 | get the currently used attr provider (may be @NULL) | |
129 | */ | |
328f5751 | 130 | wxGridCellAttrProvider* GetAttrProvider() const; |
23324ae1 FM |
131 | |
132 | /** | |
3c4f71cc | 133 | |
23324ae1 FM |
134 | */ |
135 | wxString GetColLabelValue(int col); | |
136 | ||
137 | /** | |
3c4f71cc | 138 | |
23324ae1 FM |
139 | */ |
140 | int GetNumberCols(); | |
141 | ||
142 | /** | |
143 | You must override these functions in a derived table class. | |
144 | */ | |
145 | int GetNumberRows(); | |
146 | ||
147 | /** | |
3c4f71cc | 148 | |
23324ae1 FM |
149 | */ |
150 | wxString GetRowLabelValue(int row); | |
151 | ||
152 | /** | |
153 | Data type determination and value access. | |
154 | */ | |
155 | wxString GetTypeName(int row, int col); | |
156 | ||
157 | /** | |
3c4f71cc | 158 | |
23324ae1 FM |
159 | */ |
160 | wxString GetValue(int row, int col); | |
161 | ||
162 | /** | |
3c4f71cc | 163 | |
23324ae1 FM |
164 | */ |
165 | bool GetValueAsBool(int row, int col); | |
166 | ||
167 | /** | |
168 | For user defined types | |
169 | */ | |
170 | void* GetValueAsCustom(int row, int col, | |
171 | const wxString& typeName); | |
172 | ||
173 | /** | |
3c4f71cc | 174 | |
23324ae1 FM |
175 | */ |
176 | double GetValueAsDouble(int row, int col); | |
177 | ||
178 | /** | |
3c4f71cc | 179 | |
23324ae1 FM |
180 | */ |
181 | long GetValueAsLong(int row, int col); | |
182 | ||
183 | /** | |
3c4f71cc | 184 | |
23324ae1 | 185 | */ |
328f5751 | 186 | wxGrid* GetView() const; |
23324ae1 FM |
187 | |
188 | /** | |
3c4f71cc | 189 | |
23324ae1 FM |
190 | */ |
191 | bool InsertCols(size_t pos = 0, size_t numCols = 1); | |
192 | ||
193 | /** | |
3c4f71cc | 194 | |
23324ae1 FM |
195 | */ |
196 | bool InsertRows(size_t pos = 0, size_t numRows = 1); | |
197 | ||
198 | /** | |
3c4f71cc | 199 | |
23324ae1 FM |
200 | */ |
201 | bool IsEmptyCell(int row, int col); | |
202 | ||
203 | /** | |
204 | these functions take ownership of the pointer | |
205 | */ | |
206 | void SetAttr(wxGridCellAttr* attr, int row, int col); | |
207 | ||
208 | /** | |
209 | Attribute handling | |
210 | give us the attr provider to use - we take ownership of the pointer | |
211 | */ | |
212 | void SetAttrProvider(wxGridCellAttrProvider* attrProvider); | |
213 | ||
214 | /** | |
3c4f71cc | 215 | |
23324ae1 FM |
216 | */ |
217 | void SetColAttr(wxGridCellAttr* attr, int col); | |
218 | ||
219 | /** | |
328f5751 | 220 | , @e wxString) |
23324ae1 | 221 | */ |
328f5751 | 222 | void SetColLabelValue() const; |
23324ae1 FM |
223 | |
224 | /** | |
3c4f71cc | 225 | |
23324ae1 FM |
226 | */ |
227 | void SetRowAttr(wxGridCellAttr* attr, int row); | |
228 | ||
229 | /** | |
328f5751 | 230 | , @e wxString) |
23324ae1 | 231 | */ |
328f5751 | 232 | void SetRowLabelValue() const; |
23324ae1 FM |
233 | |
234 | /** | |
3c4f71cc | 235 | |
23324ae1 FM |
236 | */ |
237 | void SetValue(int row, int col, const wxString& value); | |
238 | ||
239 | /** | |
3c4f71cc | 240 | |
23324ae1 FM |
241 | */ |
242 | void SetValueAsBool(int row, int col, bool value); | |
243 | ||
244 | /** | |
3c4f71cc | 245 | |
23324ae1 FM |
246 | */ |
247 | void SetValueAsCustom(int row, int col, const wxString& typeName, | |
248 | void* value); | |
249 | ||
250 | /** | |
3c4f71cc | 251 | |
23324ae1 FM |
252 | */ |
253 | void SetValueAsDouble(int row, int col, double value); | |
254 | ||
255 | /** | |
3c4f71cc | 256 | |
23324ae1 FM |
257 | */ |
258 | void SetValueAsLong(int row, int col, long value); | |
259 | ||
260 | /** | |
261 | Overriding these is optional | |
262 | */ | |
263 | void SetView(wxGrid* grid); | |
264 | ||
265 | /** | |
3c4f71cc | 266 | |
23324ae1 FM |
267 | */ |
268 | void UpdateAttrCols(size_t pos, int numCols); | |
269 | ||
270 | /** | |
271 | change row/col number in attribute if needed | |
272 | */ | |
273 | void UpdateAttrRows(size_t pos, int numRows); | |
274 | }; | |
275 | ||
276 | ||
e54c96f1 | 277 | |
23324ae1 FM |
278 | /** |
279 | @class wxGridCellEditor | |
7c913512 | 280 | |
23324ae1 FM |
281 | This class is responsible for providing and manipulating |
282 | the in-place edit controls for the grid. Instances of wxGridCellEditor | |
283 | (actually, instances of derived classes since it is an abstract class) can be | |
284 | associated with the cell attributes for individual cells, rows, columns, or | |
285 | even for the entire grid. | |
7c913512 | 286 | |
23324ae1 | 287 | @library{wxadv} |
42b5841f | 288 | @category{grid} |
7c913512 | 289 | |
e54c96f1 | 290 | @see wxGridCellTextEditor, wxGridCellFloatEditor, wxGridCellBoolEditor, |
23324ae1 FM |
291 | wxGridCellNumberEditor, wxGridCellChoiceEditor |
292 | */ | |
7c913512 | 293 | class wxGridCellEditor |
23324ae1 FM |
294 | { |
295 | public: | |
296 | /** | |
3c4f71cc | 297 | |
23324ae1 FM |
298 | */ |
299 | wxGridCellEditor(); | |
300 | ||
301 | /** | |
302 | The dtor is private because only DecRef() can delete us. | |
303 | */ | |
304 | ~wxGridCellEditor(); | |
305 | ||
306 | /** | |
307 | Fetch the value from the table and prepare the edit control | |
308 | to begin editing. Set the focus to the edit control. | |
309 | */ | |
310 | void BeginEdit(int row, int col, wxGrid* grid); | |
311 | ||
312 | /** | |
313 | Create a new object which is the copy of this one. | |
314 | */ | |
328f5751 | 315 | wxGridCellEditor* Clone() const; |
23324ae1 FM |
316 | |
317 | /** | |
318 | Creates the actual edit control. | |
319 | */ | |
320 | void Create(wxWindow* parent, wxWindowID id, | |
321 | wxEvtHandler* evtHandler); | |
322 | ||
323 | /** | |
324 | Final cleanup. | |
325 | */ | |
326 | void Destroy(); | |
327 | ||
328 | /** | |
329 | Complete the editing of the current cell. Returns @true if the value has | |
330 | changed. If necessary, the control may be destroyed. | |
331 | */ | |
332 | bool EndEdit(int row, int col, wxGrid* grid); | |
333 | ||
334 | /** | |
335 | Some types of controls on some platforms may need some help | |
336 | with the Return key. | |
337 | */ | |
338 | void HandleReturn(wxKeyEvent& event); | |
339 | ||
340 | /** | |
3c4f71cc | 341 | |
23324ae1 FM |
342 | */ |
343 | bool IsCreated(); | |
344 | ||
345 | /** | |
346 | Draws the part of the cell not occupied by the control: the base class | |
347 | version just fills it with background colour from the attribute. | |
348 | */ | |
349 | void PaintBackground(const wxRect& rectCell, | |
350 | wxGridCellAttr* attr); | |
351 | ||
352 | /** | |
353 | Reset the value in the control back to its starting value. | |
354 | */ | |
355 | void Reset(); | |
356 | ||
357 | /** | |
358 | Size and position the edit control. | |
359 | */ | |
360 | void SetSize(const wxRect& rect); | |
361 | ||
362 | /** | |
363 | Show or hide the edit control, use the specified attributes to set | |
364 | colours/fonts for it. | |
365 | */ | |
4cc4bfaf | 366 | void Show(bool show, wxGridCellAttr* attr = NULL); |
23324ae1 FM |
367 | |
368 | /** | |
369 | If the editor is enabled by clicking on the cell, this method will be | |
370 | called. | |
371 | */ | |
372 | void StartingClick(); | |
373 | ||
374 | /** | |
375 | If the editor is enabled by pressing keys on the grid, | |
376 | this will be called to let the editor do something about | |
377 | that first key if desired. | |
378 | */ | |
379 | void StartingKey(wxKeyEvent& event); | |
380 | }; | |
381 | ||
382 | ||
e54c96f1 | 383 | |
23324ae1 FM |
384 | /** |
385 | @class wxGridCellTextEditor | |
7c913512 | 386 | |
23324ae1 | 387 | The editor for string/text data. |
7c913512 | 388 | |
23324ae1 | 389 | @library{wxadv} |
42b5841f | 390 | @category{grid} |
7c913512 | 391 | |
e54c96f1 | 392 | @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor, |
23324ae1 FM |
393 | wxGridCellNumberEditor, wxGridCellChoiceEditor |
394 | */ | |
395 | class wxGridCellTextEditor : public wxGridCellEditor | |
396 | { | |
397 | public: | |
398 | /** | |
399 | Default constructor. | |
400 | */ | |
401 | wxGridCellTextEditor(); | |
402 | ||
403 | /** | |
404 | The parameters string format is "n" where n is a number representing the | |
405 | maximum width. | |
406 | */ | |
407 | void SetParameters(const wxString& params); | |
408 | }; | |
409 | ||
410 | ||
e54c96f1 | 411 | |
23324ae1 FM |
412 | /** |
413 | @class wxGridCellStringRenderer | |
7c913512 | 414 | |
23324ae1 FM |
415 | This class may be used to format string data in a cell; it is the default |
416 | for string cells. | |
7c913512 | 417 | |
23324ae1 | 418 | @library{wxadv} |
42b5841f | 419 | @category{grid} |
7c913512 | 420 | |
e54c96f1 | 421 | @see wxGridCellRenderer, wxGridCellNumberRenderer, wxGridCellFloatRenderer, |
23324ae1 FM |
422 | wxGridCellBoolRenderer |
423 | */ | |
424 | class wxGridCellStringRenderer : public wxGridCellRenderer | |
425 | { | |
426 | public: | |
427 | /** | |
428 | Default constructor | |
429 | */ | |
430 | wxGridCellStringRenderer(); | |
431 | }; | |
432 | ||
433 | ||
e54c96f1 | 434 | |
23324ae1 FM |
435 | /** |
436 | @class wxGridCellChoiceEditor | |
7c913512 | 437 | |
23324ae1 | 438 | The editor for string data allowing to choose from a list of strings. |
7c913512 | 439 | |
23324ae1 | 440 | @library{wxadv} |
42b5841f | 441 | @category{grid} |
7c913512 | 442 | |
e54c96f1 | 443 | @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor, |
23324ae1 FM |
444 | wxGridCellTextEditor, wxGridCellNumberEditor |
445 | */ | |
446 | class wxGridCellChoiceEditor : public wxGridCellEditor | |
447 | { | |
448 | public: | |
449 | //@{ | |
450 | /** | |
7c913512 | 451 | @param count |
4cc4bfaf | 452 | Number of strings from which the user can choose. |
7c913512 | 453 | @param choices |
4cc4bfaf | 454 | An array of strings from which the user can choose. |
7c913512 | 455 | @param allowOthers |
4cc4bfaf | 456 | If allowOthers is @true, the user can type a string not in choices array. |
23324ae1 FM |
457 | */ |
458 | wxGridCellChoiceEditor(size_t count = 0, | |
4cc4bfaf FM |
459 | const wxString choices[] = NULL, |
460 | bool allowOthers = false); | |
7c913512 | 461 | wxGridCellChoiceEditor(const wxArrayString& choices, |
4cc4bfaf | 462 | bool allowOthers = false); |
23324ae1 FM |
463 | //@} |
464 | ||
465 | /** | |
466 | Parameters string format is "item1[,item2[...,itemN]]" | |
467 | */ | |
468 | void SetParameters(const wxString& params); | |
469 | }; | |
470 | ||
471 | ||
e54c96f1 | 472 | |
23324ae1 FM |
473 | /** |
474 | @class wxGridEditorCreatedEvent | |
7c913512 FM |
475 | |
476 | ||
23324ae1 | 477 | @library{wxadv} |
42b5841f | 478 | @category{grid} |
23324ae1 FM |
479 | */ |
480 | class wxGridEditorCreatedEvent : public wxCommandEvent | |
481 | { | |
482 | public: | |
483 | //@{ | |
484 | /** | |
3c4f71cc | 485 | |
23324ae1 FM |
486 | */ |
487 | wxGridEditorCreatedEvent(); | |
7c913512 FM |
488 | wxGridEditorCreatedEvent(int id, wxEventType type, |
489 | wxObject* obj, | |
490 | int row, | |
491 | int col, | |
492 | wxControl* ctrl); | |
23324ae1 FM |
493 | //@} |
494 | ||
495 | /** | |
496 | Returns the column at which the event occurred. | |
497 | */ | |
498 | int GetCol(); | |
499 | ||
500 | /** | |
501 | Returns the edit control. | |
502 | */ | |
503 | wxControl* GetControl(); | |
504 | ||
505 | /** | |
506 | Returns the row at which the event occurred. | |
507 | */ | |
508 | int GetRow(); | |
509 | ||
510 | /** | |
511 | Sets the column at which the event occurred. | |
512 | */ | |
513 | void SetCol(int col); | |
514 | ||
515 | /** | |
516 | Sets the edit control. | |
517 | */ | |
518 | void SetControl(wxControl* ctrl); | |
519 | ||
520 | /** | |
521 | Sets the row at which the event occurred. | |
522 | */ | |
523 | void SetRow(int row); | |
524 | }; | |
525 | ||
526 | ||
e54c96f1 | 527 | |
23324ae1 FM |
528 | /** |
529 | @class wxGridRangeSelectEvent | |
7c913512 FM |
530 | |
531 | ||
23324ae1 | 532 | @library{wxadv} |
42b5841f | 533 | @category{grid} |
23324ae1 FM |
534 | */ |
535 | class wxGridRangeSelectEvent : public wxNotifyEvent | |
536 | { | |
537 | public: | |
538 | //@{ | |
539 | /** | |
3c4f71cc | 540 | |
23324ae1 FM |
541 | */ |
542 | wxGridRangeSelectEvent(); | |
7c913512 FM |
543 | wxGridRangeSelectEvent(int id, wxEventType type, |
544 | wxObject* obj, | |
545 | const wxGridCellCoords& topLeft, | |
546 | const wxGridCellCoords& bottomRight, | |
4cc4bfaf FM |
547 | bool sel = true, |
548 | bool control = false, | |
549 | bool shift = false, | |
550 | bool alt = false, | |
551 | bool meta = false); | |
23324ae1 FM |
552 | //@} |
553 | ||
554 | /** | |
555 | Returns @true if the Alt key was down at the time of the event. | |
556 | */ | |
557 | bool AltDown(); | |
558 | ||
559 | /** | |
560 | Returns @true if the Control key was down at the time of the event. | |
561 | */ | |
562 | bool ControlDown(); | |
563 | ||
564 | /** | |
565 | Top left corner of the rectangular area that was (de)selected. | |
566 | */ | |
567 | wxGridCellCoords GetBottomRightCoords(); | |
568 | ||
569 | /** | |
570 | Bottom row of the rectangular area that was (de)selected. | |
571 | */ | |
572 | int GetBottomRow(); | |
573 | ||
574 | /** | |
575 | Left column of the rectangular area that was (de)selected. | |
576 | */ | |
577 | int GetLeftCol(); | |
578 | ||
579 | /** | |
580 | Right column of the rectangular area that was (de)selected. | |
581 | */ | |
582 | int GetRightCol(); | |
583 | ||
584 | /** | |
585 | Top left corner of the rectangular area that was (de)selected. | |
586 | */ | |
587 | wxGridCellCoords GetTopLeftCoords(); | |
588 | ||
589 | /** | |
590 | Top row of the rectangular area that was (de)selected. | |
591 | */ | |
592 | int GetTopRow(); | |
593 | ||
594 | /** | |
595 | Returns @true if the Meta key was down at the time of the event. | |
596 | */ | |
597 | bool MetaDown(); | |
598 | ||
599 | /** | |
600 | Returns @true if the area was selected, @false otherwise. | |
601 | */ | |
602 | bool Selecting(); | |
603 | ||
604 | /** | |
605 | Returns @true if the Shift key was down at the time of the event. | |
606 | */ | |
607 | bool ShiftDown(); | |
608 | }; | |
609 | ||
610 | ||
e54c96f1 | 611 | |
23324ae1 FM |
612 | /** |
613 | @class wxGridCellRenderer | |
7c913512 | 614 | |
23324ae1 FM |
615 | This class is responsible for actually drawing the cell |
616 | in the grid. You may pass it to the wxGridCellAttr (below) to change the | |
617 | format of one given cell or to wxGrid::SetDefaultRenderer() to change the | |
618 | view of all cells. This is an abstract class, and you will normally use one of | |
619 | the | |
620 | predefined derived classes or derive your own class from it. | |
7c913512 | 621 | |
23324ae1 | 622 | @library{wxadv} |
42b5841f | 623 | @category{grid} |
7c913512 | 624 | |
e54c96f1 FM |
625 | @see wxGridCellStringRenderer, wxGridCellNumberRenderer, |
626 | wxGridCellFloatRenderer, wxGridCellBoolRenderer | |
23324ae1 | 627 | */ |
7c913512 | 628 | class wxGridCellRenderer |
23324ae1 FM |
629 | { |
630 | public: | |
631 | /** | |
3c4f71cc | 632 | |
23324ae1 | 633 | */ |
328f5751 | 634 | wxGridCellRenderer* Clone() const; |
23324ae1 FM |
635 | |
636 | /** | |
637 | Draw the given cell on the provided DC inside the given rectangle | |
638 | using the style specified by the attribute and the default or selected | |
639 | state corresponding to the isSelected value. | |
23324ae1 FM |
640 | This pure virtual function has a default implementation which will |
641 | prepare the DC using the given attribute: it will draw the rectangle | |
642 | with the background colour from attr and set the text colour and font. | |
643 | */ | |
644 | void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
645 | const wxRect& rect, int row, int col, | |
646 | bool isSelected); | |
647 | ||
648 | /** | |
649 | Get the preferred size of the cell for its contents. | |
650 | */ | |
651 | wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
652 | int row, int col); | |
653 | }; | |
654 | ||
655 | ||
e54c96f1 | 656 | |
23324ae1 FM |
657 | /** |
658 | @class wxGridCellNumberEditor | |
7c913512 | 659 | |
23324ae1 | 660 | The editor for numeric integer data. |
7c913512 | 661 | |
23324ae1 | 662 | @library{wxadv} |
42b5841f | 663 | @category{grid} |
7c913512 | 664 | |
e54c96f1 | 665 | @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellBoolEditor, |
23324ae1 FM |
666 | wxGridCellTextEditor, wxGridCellChoiceEditor |
667 | */ | |
668 | class wxGridCellNumberEditor : public wxGridCellTextEditor | |
669 | { | |
670 | public: | |
671 | /** | |
672 | Allows to specify the range for acceptable data; | |
673 | if min == max == -1, no range checking is done | |
674 | */ | |
675 | wxGridCellNumberEditor(int min = -1, int max = -1); | |
676 | ||
677 | /** | |
678 | String representation of the value. | |
679 | */ | |
328f5751 | 680 | wxString GetString() const; |
23324ae1 FM |
681 | |
682 | /** | |
683 | If the return value is @true, the editor uses a wxSpinCtrl to get user input, | |
684 | otherwise it uses a wxTextCtrl. | |
685 | */ | |
328f5751 | 686 | bool HasRange() const; |
23324ae1 FM |
687 | |
688 | /** | |
689 | Parameters string format is "min,max". | |
690 | */ | |
691 | void SetParameters(const wxString& params); | |
692 | }; | |
693 | ||
694 | ||
e54c96f1 | 695 | |
23324ae1 FM |
696 | /** |
697 | @class wxGridSizeEvent | |
7c913512 | 698 | |
23324ae1 | 699 | This event class contains information about a row/column resize event. |
7c913512 | 700 | |
23324ae1 | 701 | @library{wxadv} |
42b5841f | 702 | @category{grid} |
23324ae1 FM |
703 | */ |
704 | class wxGridSizeEvent : public wxNotifyEvent | |
705 | { | |
706 | public: | |
707 | //@{ | |
708 | /** | |
3c4f71cc | 709 | |
23324ae1 FM |
710 | */ |
711 | wxGridSizeEvent(); | |
7c913512 FM |
712 | wxGridSizeEvent(int id, wxEventType type, wxObject* obj, |
713 | int rowOrCol = -1, | |
714 | int x = -1, | |
715 | int y = -1, | |
4cc4bfaf FM |
716 | bool control = false, |
717 | bool shift = false, | |
718 | bool alt = false, | |
719 | bool meta = false); | |
23324ae1 FM |
720 | //@} |
721 | ||
722 | /** | |
723 | Returns @true if the Alt key was down at the time of the event. | |
724 | */ | |
725 | bool AltDown(); | |
726 | ||
727 | /** | |
728 | Returns @true if the Control key was down at the time of the event. | |
729 | */ | |
730 | bool ControlDown(); | |
731 | ||
732 | /** | |
733 | Position in pixels at which the event occurred. | |
734 | */ | |
735 | wxPoint GetPosition(); | |
736 | ||
737 | /** | |
738 | Row or column at that was resized. | |
739 | */ | |
740 | int GetRowOrCol(); | |
741 | ||
742 | /** | |
743 | Returns @true if the Meta key was down at the time of the event. | |
744 | */ | |
745 | bool MetaDown(); | |
746 | ||
747 | /** | |
748 | Returns @true if the Shift key was down at the time of the event. | |
749 | */ | |
750 | bool ShiftDown(); | |
751 | }; | |
752 | ||
753 | ||
e54c96f1 | 754 | |
23324ae1 FM |
755 | /** |
756 | @class wxGridCellNumberRenderer | |
7c913512 | 757 | |
23324ae1 | 758 | This class may be used to format integer data in a cell. |
7c913512 | 759 | |
23324ae1 | 760 | @library{wxadv} |
42b5841f | 761 | @category{grid} |
7c913512 | 762 | |
e54c96f1 | 763 | @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer, |
23324ae1 FM |
764 | wxGridCellBoolRenderer |
765 | */ | |
766 | class wxGridCellNumberRenderer : public wxGridCellStringRenderer | |
767 | { | |
768 | public: | |
769 | /** | |
770 | Default constructor | |
771 | */ | |
772 | wxGridCellNumberRenderer(); | |
773 | }; | |
774 | ||
775 | ||
e54c96f1 | 776 | |
23324ae1 FM |
777 | /** |
778 | @class wxGridCellAttr | |
7c913512 | 779 | |
23324ae1 FM |
780 | This class can be used to alter the cells' appearance in |
781 | the grid by changing their colour/font/... from default. An object of this | |
782 | class may be returned by wxGridTableBase::GetAttr. | |
7c913512 | 783 | |
23324ae1 | 784 | @library{wxadv} |
42b5841f | 785 | @category{grid} |
23324ae1 | 786 | */ |
7c913512 | 787 | class wxGridCellAttr |
23324ae1 FM |
788 | { |
789 | public: | |
790 | //@{ | |
791 | /** | |
792 | Constructor specifying some of the often used attributes. | |
793 | */ | |
794 | wxGridCellAttr(); | |
7c913512 FM |
795 | wxGridCellAttr(const wxColour& colText, |
796 | const wxColour& colBack, | |
797 | const wxFont& font, | |
798 | int hAlign, int vAlign); | |
23324ae1 FM |
799 | //@} |
800 | ||
801 | /** | |
802 | Creates a new copy of this object. | |
803 | */ | |
328f5751 | 804 | wxGridCellAttr* Clone() const; |
23324ae1 FM |
805 | |
806 | /** | |
3c4f71cc | 807 | |
23324ae1 FM |
808 | */ |
809 | void DecRef(); | |
810 | ||
811 | /** | |
812 | See SetAlignment() for the returned values. | |
813 | */ | |
328f5751 | 814 | void GetAlignment(int* hAlign, int* vAlign) const; |
23324ae1 FM |
815 | |
816 | /** | |
3c4f71cc | 817 | |
23324ae1 | 818 | */ |
328f5751 | 819 | const wxColour GetBackgroundColour() const; |
23324ae1 FM |
820 | |
821 | /** | |
3c4f71cc | 822 | |
23324ae1 | 823 | */ |
328f5751 | 824 | wxGridCellEditor* GetEditor(wxGrid* grid, int row, int col) const; |
23324ae1 FM |
825 | |
826 | /** | |
3c4f71cc | 827 | |
23324ae1 | 828 | */ |
328f5751 | 829 | const wxFont GetFont() const; |
23324ae1 FM |
830 | |
831 | /** | |
3c4f71cc | 832 | |
23324ae1 | 833 | */ |
328f5751 | 834 | wxGridCellRenderer* GetRenderer(wxGrid* grid, int row, int col) const; |
23324ae1 FM |
835 | |
836 | /** | |
3c4f71cc | 837 | |
23324ae1 | 838 | */ |
328f5751 | 839 | const wxColour GetTextColour() const; |
23324ae1 FM |
840 | |
841 | /** | |
3c4f71cc | 842 | |
23324ae1 | 843 | */ |
328f5751 | 844 | bool HasAlignment() const; |
23324ae1 FM |
845 | |
846 | /** | |
3c4f71cc | 847 | |
23324ae1 | 848 | */ |
328f5751 | 849 | bool HasBackgroundColour() const; |
23324ae1 FM |
850 | |
851 | /** | |
3c4f71cc | 852 | |
23324ae1 | 853 | */ |
328f5751 | 854 | bool HasEditor() const; |
23324ae1 FM |
855 | |
856 | /** | |
3c4f71cc | 857 | |
23324ae1 | 858 | */ |
328f5751 | 859 | bool HasFont() const; |
23324ae1 FM |
860 | |
861 | /** | |
3c4f71cc | 862 | |
23324ae1 | 863 | */ |
328f5751 | 864 | bool HasRenderer() const; |
23324ae1 FM |
865 | |
866 | /** | |
867 | accessors | |
868 | */ | |
328f5751 | 869 | bool HasTextColour() const; |
23324ae1 FM |
870 | |
871 | /** | |
872 | This class is ref counted: it is created with ref count of 1, so | |
873 | calling DecRef() once will delete it. Calling IncRef() allows to lock | |
874 | it until the matching DecRef() is called | |
875 | */ | |
876 | void IncRef(); | |
877 | ||
878 | /** | |
3c4f71cc | 879 | |
23324ae1 | 880 | */ |
328f5751 | 881 | bool IsReadOnly() const; |
23324ae1 FM |
882 | |
883 | /** | |
4cc4bfaf FM |
884 | Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT, |
885 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one | |
23324ae1 FM |
886 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. |
887 | */ | |
888 | void SetAlignment(int hAlign, int vAlign); | |
889 | ||
890 | /** | |
891 | Sets the background colour. | |
892 | */ | |
893 | void SetBackgroundColour(const wxColour& colBack); | |
894 | ||
895 | /** | |
3c4f71cc | 896 | |
23324ae1 FM |
897 | */ |
898 | void SetDefAttr(wxGridCellAttr* defAttr); | |
899 | ||
900 | /** | |
3c4f71cc | 901 | |
23324ae1 FM |
902 | */ |
903 | void SetEditor(wxGridCellEditor* editor); | |
904 | ||
905 | /** | |
906 | Sets the font. | |
907 | */ | |
908 | void SetFont(const wxFont& font); | |
909 | ||
910 | /** | |
3c4f71cc | 911 | |
23324ae1 | 912 | */ |
4cc4bfaf | 913 | void SetReadOnly(bool isReadOnly = true); |
23324ae1 FM |
914 | |
915 | /** | |
916 | takes ownership of the pointer | |
917 | */ | |
918 | void SetRenderer(wxGridCellRenderer* renderer); | |
919 | ||
920 | /** | |
921 | Sets the text colour. | |
922 | */ | |
923 | void SetTextColour(const wxColour& colText); | |
924 | }; | |
925 | ||
926 | ||
e54c96f1 | 927 | |
23324ae1 FM |
928 | /** |
929 | @class wxGridCellBoolRenderer | |
7c913512 | 930 | |
23324ae1 FM |
931 | This class may be used to format boolean data in a cell. |
932 | for string cells. | |
7c913512 | 933 | |
23324ae1 | 934 | @library{wxadv} |
42b5841f | 935 | @category{grid} |
7c913512 | 936 | |
e54c96f1 | 937 | @see wxGridCellRenderer, wxGridCellStringRenderer, wxGridCellFloatRenderer, |
23324ae1 FM |
938 | wxGridCellNumberRenderer |
939 | */ | |
940 | class wxGridCellBoolRenderer : public wxGridCellRenderer | |
941 | { | |
942 | public: | |
943 | /** | |
944 | Default constructor | |
945 | */ | |
946 | wxGridCellBoolRenderer(); | |
947 | }; | |
948 | ||
949 | ||
e54c96f1 | 950 | |
23324ae1 FM |
951 | /** |
952 | @class wxGridEvent | |
7c913512 | 953 | |
23324ae1 | 954 | This event class contains information about various grid events. |
7c913512 | 955 | |
23324ae1 | 956 | @library{wxadv} |
42b5841f | 957 | @category{grid} |
23324ae1 FM |
958 | */ |
959 | class wxGridEvent : public wxNotifyEvent | |
960 | { | |
961 | public: | |
962 | //@{ | |
963 | /** | |
3c4f71cc | 964 | |
23324ae1 FM |
965 | */ |
966 | wxGridEvent(); | |
7c913512 FM |
967 | wxGridEvent(int id, wxEventType type, wxObject* obj, |
968 | int row = -1, int col = -1, | |
969 | int x = -1, int y = -1, | |
4cc4bfaf FM |
970 | bool sel = true, |
971 | bool control = false, | |
972 | bool shift = false, | |
973 | bool alt = false, | |
974 | bool meta = false); | |
23324ae1 FM |
975 | //@} |
976 | ||
977 | /** | |
978 | Returns @true if the Alt key was down at the time of the event. | |
979 | */ | |
980 | bool AltDown(); | |
981 | ||
982 | /** | |
983 | Returns @true if the Control key was down at the time of the event. | |
984 | */ | |
985 | bool ControlDown(); | |
986 | ||
987 | /** | |
988 | Column at which the event occurred. | |
989 | */ | |
990 | int GetCol(); | |
991 | ||
992 | /** | |
993 | Position in pixels at which the event occurred. | |
994 | */ | |
995 | wxPoint GetPosition(); | |
996 | ||
997 | /** | |
998 | Row at which the event occurred. | |
999 | */ | |
1000 | int GetRow(); | |
1001 | ||
1002 | /** | |
1003 | Returns @true if the Meta key was down at the time of the event. | |
1004 | */ | |
1005 | bool MetaDown(); | |
1006 | ||
1007 | /** | |
1008 | Returns @true if the user is selecting grid cells, @false -- if | |
1009 | deselecting. | |
1010 | */ | |
1011 | bool Selecting(); | |
1012 | ||
1013 | /** | |
1014 | Returns @true if the Shift key was down at the time of the event. | |
1015 | */ | |
1016 | bool ShiftDown(); | |
1017 | }; | |
1018 | ||
1019 | ||
e54c96f1 | 1020 | |
23324ae1 FM |
1021 | /** |
1022 | @class wxGridCellFloatEditor | |
7c913512 | 1023 | |
23324ae1 | 1024 | The editor for floating point numbers data. |
7c913512 | 1025 | |
23324ae1 | 1026 | @library{wxadv} |
42b5841f | 1027 | @category{grid} |
7c913512 | 1028 | |
e54c96f1 | 1029 | @see wxGridCellEditor, wxGridCellNumberEditor, wxGridCellBoolEditor, |
23324ae1 FM |
1030 | wxGridCellTextEditor, wxGridCellChoiceEditor |
1031 | */ | |
1032 | class wxGridCellFloatEditor : public wxGridCellTextEditor | |
1033 | { | |
1034 | public: | |
1035 | /** | |
7c913512 | 1036 | @param width |
4cc4bfaf | 1037 | Minimum number of characters to be shown. |
7c913512 | 1038 | @param precision |
4cc4bfaf | 1039 | Number of digits after the decimal dot. |
23324ae1 FM |
1040 | */ |
1041 | wxGridCellFloatEditor(int width = -1, int precision = -1); | |
1042 | ||
1043 | /** | |
1044 | Parameters string format is "width,precision" | |
1045 | */ | |
1046 | void SetParameters(const wxString& params); | |
1047 | }; | |
1048 | ||
1049 | ||
e54c96f1 | 1050 | |
23324ae1 FM |
1051 | /** |
1052 | @class wxGrid | |
7c913512 | 1053 | |
23324ae1 | 1054 | wxGrid and its related classes are used for displaying and editing tabular |
55f0bf1f VZ |
1055 | data. |
1056 | They provide a rich set of features for display, editing, and interacting | |
1057 | with a variety of data sources. For simple applications, and to help you | |
1058 | get started, wxGrid is the only class you need to refer to directly. It | |
1059 | will set up default instances of the other classes and manage them for you. | |
1060 | For more complex applications you can derive your own classes for custom | |
1061 | grid views, grid data tables, cell editors and renderers. The @ref | |
1062 | overview_gridoverview has examples of simple and more complex applications, | |
1063 | explains the relationship between the various grid classes and has a | |
1064 | summary of the keyboard shortcuts and mouse functions provided by wxGrid. | |
1065 | ||
1066 | wxGrid has been greatly expanded and redesigned for wxWidgets 2.2 onwards. | |
1067 | The new grid classes are reasonably backward-compatible but there are some | |
1068 | exceptions. There are also easier ways of doing many things compared to the | |
1069 | previous implementation. | |
1070 | ||
1071 | A wxGridTableBase class holds the actual data to be displayed by a wxGrid | |
1072 | class. One or more wxGrid classes may act as a view for one table class. | |
1073 | The default table class is called wxGridStringTable and holds an array of | |
1074 | strings. An instance of such a class is created by wxGrid::CreateGrid. | |
1075 | ||
1076 | wxGridCellRenderer is the abstract base class for rendereing contents in a | |
1077 | cell. The following renderers are predefined: | |
1078 | - wxGridCellStringRenderer, | |
1079 | - wxGridCellBoolRenderer, | |
1080 | - wxGridCellFloatRenderer, | |
1081 | - wxGridCellNumberRenderer. | |
1082 | The look of a cell can be further defined using wxGridCellAttr. An object | |
1083 | of this type may be returned by wxGridTableBase::GetAttr. | |
1084 | ||
1085 | wxGridCellEditor is the abstract base class for editing the value of a | |
1086 | cell. The following editors are predefined: | |
1087 | - wxGridCellTextEditor | |
1088 | - wxGridCellBoolEditor | |
1089 | - wxGridCellChoiceEditor | |
1090 | - wxGridCellNumberEditor. | |
7c913512 | 1091 | |
23324ae1 | 1092 | @library{wxadv} |
55f0bf1f | 1093 | @category{grid} |
7c913512 | 1094 | |
e54c96f1 | 1095 | @see @ref overview_gridoverview "wxGrid overview" |
23324ae1 FM |
1096 | */ |
1097 | class wxGrid : public wxScrolledWindow | |
1098 | { | |
1099 | public: | |
23324ae1 | 1100 | /** |
55f0bf1f VZ |
1101 | Different selection modes supported by the grid. |
1102 | */ | |
1103 | enum wxGridSelectionModes | |
1104 | { | |
1105 | /** | |
1106 | The default selection mode allowing selection of the individual | |
1107 | cells as well as of the entire rows and columns. | |
1108 | */ | |
1109 | wxGridSelectCells, | |
1110 | ||
1111 | /** | |
1112 | The selection mode allowing the selection of the entire rows only. | |
1113 | ||
1114 | The user won't be able to select any cells or columns in this mode. | |
1115 | */ | |
1116 | wxGridSelectRows, | |
1117 | ||
1118 | /** | |
1119 | The selection mode allowing the selection of the entire columns only. | |
1120 | ||
1121 | The user won't be able to select any cells or rows in this mode. | |
1122 | */ | |
1123 | wxGridSelectColumns | |
1124 | }; | |
1125 | ||
1126 | /** | |
1127 | Default constructor. | |
1128 | ||
1129 | You must call Create() to really create the grid window and also call | |
1130 | CreateGrid() or SetTable() to initialize the grid contents. | |
1131 | */ | |
23324ae1 | 1132 | wxGrid(); |
55f0bf1f VZ |
1133 | |
1134 | /** | |
1135 | Constructor creating the grid window. | |
1136 | ||
1137 | You must call either CreateGrid() or SetTable() to initialize the grid | |
1138 | contents before using it. | |
1139 | */ | |
1140 | wxGrid(wxWindow* parent, | |
1141 | wxWindowID id, | |
7c913512 FM |
1142 | const wxPoint& pos = wxDefaultPosition, |
1143 | const wxSize& size = wxDefaultSize, | |
1144 | long style = wxWANTS_CHARS, | |
55f0bf1f | 1145 | const wxString& name = wxGridNameStr); |
23324ae1 FM |
1146 | |
1147 | /** | |
55f0bf1f VZ |
1148 | Creates the grid window for an object initialized using the default |
1149 | constructor. | |
1150 | ||
1151 | You must call either CreateGrid() or SetTable() to initialize the grid | |
1152 | contents before using it. | |
1153 | */ | |
1154 | bool Create(wxWindow* parent, | |
1155 | wxWindowID id, | |
1156 | const wxPoint& pos = wxDefaultPosition, | |
1157 | const wxSize& size = wxDefaultSize, | |
1158 | long style = wxWANTS_CHARS, | |
1159 | const wxString& name = wxGridNameStr); | |
1160 | ||
1161 | /** | |
1162 | Destructor. | |
1163 | ||
1164 | This will also destroy the associated grid table unless you passed a | |
1165 | table object to the grid and specified that the grid should not take | |
1166 | ownership of the table (see wxGrid::SetTable). | |
23324ae1 | 1167 | */ |
55f0bf1f | 1168 | virtual ~wxGrid(); |
23324ae1 FM |
1169 | |
1170 | /** | |
55f0bf1f VZ |
1171 | Appends one or more new columns to the right of the grid. |
1172 | ||
1173 | The @a updateLabels argument is not used at present. If you are using a | |
1174 | derived grid table class you will need to override | |
1175 | wxGridTableBase::AppendCols. See InsertCols() for further information. | |
1176 | ||
1177 | @return @true on success or @false if appending columns failed. | |
23324ae1 | 1178 | */ |
4cc4bfaf | 1179 | bool AppendCols(int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
1180 | |
1181 | /** | |
55f0bf1f VZ |
1182 | Appends one or more new rows to the bottom of the grid. |
1183 | ||
1184 | The @a updateLabels argument is not used at present. If you are using a | |
1185 | derived grid table class you will need to override | |
1186 | wxGridTableBase::AppendRows. See InsertRows() for further information. | |
1187 | ||
1188 | @return @true on success or @false if appending rows failed. | |
23324ae1 | 1189 | */ |
4cc4bfaf | 1190 | bool AppendRows(int numRows = 1, bool updateLabels = true); |
23324ae1 FM |
1191 | |
1192 | /** | |
1193 | Automatically sets the height and width of all rows and columns to fit their | |
1194 | contents. | |
1195 | */ | |
1196 | void AutoSize(); | |
1197 | ||
1198 | /** | |
1199 | Automatically adjusts width of the column to fit its label. | |
1200 | */ | |
1201 | void AutoSizeColLabelSize(int col); | |
1202 | ||
1203 | /** | |
1204 | Automatically sizes the column to fit its contents. If setAsMin is @true the | |
1205 | calculated width will | |
1206 | also be set as the minimal width for the column. | |
1207 | */ | |
4cc4bfaf | 1208 | void AutoSizeColumn(int col, bool setAsMin = true); |
23324ae1 FM |
1209 | |
1210 | /** | |
1211 | Automatically sizes all columns to fit their contents. If setAsMin is @true the | |
1212 | calculated widths will | |
1213 | also be set as the minimal widths for the columns. | |
1214 | */ | |
4cc4bfaf | 1215 | void AutoSizeColumns(bool setAsMin = true); |
23324ae1 FM |
1216 | |
1217 | /** | |
1218 | Automatically sizes the row to fit its contents. If setAsMin is @true the | |
1219 | calculated height will | |
1220 | also be set as the minimal height for the row. | |
1221 | */ | |
4cc4bfaf | 1222 | void AutoSizeRow(int row, bool setAsMin = true); |
23324ae1 FM |
1223 | |
1224 | /** | |
1225 | Automatically adjusts height of the row to fit its label. | |
1226 | */ | |
1227 | void AutoSizeRowLabelSize(int col); | |
1228 | ||
1229 | /** | |
1230 | Automatically sizes all rows to fit their contents. If setAsMin is @true the | |
1231 | calculated heights will | |
1232 | also be set as the minimal heights for the rows. | |
1233 | */ | |
4cc4bfaf | 1234 | void AutoSizeRows(bool setAsMin = true); |
23324ae1 FM |
1235 | |
1236 | /** | |
55f0bf1f | 1237 | Increments the grid's batch count. |
3c4f71cc | 1238 | |
55f0bf1f VZ |
1239 | When the count is greater than zero repainting of the grid is |
1240 | suppressed. Each call to BeginBatch must be matched by a later call to | |
1241 | EndBatch(). Code that does a lot of grid modification can be enclosed | |
1242 | between BeginBatch and EndBatch calls to avoid screen flicker. The | |
1243 | final EndBatch will cause the grid to be repainted. | |
3c4f71cc | 1244 | |
55f0bf1f VZ |
1245 | Notice that you should use wxGridUpdateLocker which ensures that there |
1246 | is always a matching EndBatch() call for this BeginBatch() if possible | |
1247 | instead of calling this method directly. | |
23324ae1 FM |
1248 | */ |
1249 | void BeginBatch(); | |
1250 | ||
1251 | /** | |
08dd9b5a VZ |
1252 | Convert grid cell coordinates to grid window pixel coordinates. |
1253 | ||
23324ae1 | 1254 | This function returns the rectangle that encloses the block of cells |
08dd9b5a VZ |
1255 | limited by @a topLeft and @a bottomRight cell in device coords and |
1256 | clipped to the client size of the grid window. | |
1257 | ||
1258 | @see CellToRect() | |
23324ae1 | 1259 | */ |
4cc4bfaf | 1260 | wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft, |
328f5751 | 1261 | const wxGridCellCoords& bottomRight) const; |
23324ae1 FM |
1262 | |
1263 | /** | |
55f0bf1f VZ |
1264 | Returns @true if columns can be moved by dragging with the mouse. |
1265 | ||
1266 | Columns can be moved by dragging on their labels. | |
23324ae1 | 1267 | */ |
328f5751 | 1268 | bool CanDragColMove() const; |
23324ae1 FM |
1269 | |
1270 | /** | |
55f0bf1f | 1271 | Returns @true if columns can be resized by dragging with the mouse. |
08dd9b5a | 1272 | |
55f0bf1f VZ |
1273 | Columns can be resized by dragging the edges of their labels. If grid |
1274 | line dragging is enabled they can also be resized by dragging the right | |
1275 | edge of the column in the grid cell area (see | |
1276 | wxGrid::EnableDragGridSize). | |
23324ae1 | 1277 | */ |
328f5751 | 1278 | bool CanDragColSize() const; |
23324ae1 FM |
1279 | |
1280 | /** | |
08dd9b5a VZ |
1281 | Return @true if the dragging of grid lines to resize rows and columns |
1282 | is enabled or @false otherwise. | |
23324ae1 | 1283 | */ |
328f5751 | 1284 | bool CanDragGridSize() const; |
23324ae1 FM |
1285 | |
1286 | /** | |
55f0bf1f | 1287 | Returns @true if rows can be resized by dragging with the mouse. |
08dd9b5a | 1288 | |
55f0bf1f VZ |
1289 | Rows can be resized by dragging the edges of their labels. If grid line |
1290 | dragging is enabled they can also be resized by dragging the lower edge | |
1291 | of the row in the grid cell area (see wxGrid::EnableDragGridSize). | |
23324ae1 | 1292 | */ |
328f5751 | 1293 | bool CanDragRowSize() const; |
23324ae1 FM |
1294 | |
1295 | /** | |
08dd9b5a VZ |
1296 | Returns @true if the in-place edit control for the current grid cell |
1297 | can be used and @false otherwise. | |
1298 | ||
1299 | This function always returns @false for the read-only cells. | |
23324ae1 | 1300 | */ |
328f5751 | 1301 | bool CanEnableCellControl() const; |
23324ae1 FM |
1302 | |
1303 | /** | |
08dd9b5a VZ |
1304 | Returns @true if this grid has support for cell attributes. |
1305 | ||
1306 | The grid supports attributes if it has the associated table which, in | |
1307 | turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes() | |
1308 | returns @true. | |
23324ae1 | 1309 | */ |
328f5751 | 1310 | bool CanHaveAttributes() const; |
23324ae1 | 1311 | |
23324ae1 FM |
1312 | //@{ |
1313 | /** | |
08dd9b5a VZ |
1314 | Return the rectangle corresponding to the grid cell's size and position |
1315 | in logical coordinates. | |
1316 | ||
1317 | @see BlockToDeviceRect() | |
23324ae1 | 1318 | */ |
328f5751 | 1319 | wxRect CellToRect(int row, int col) const; |
08dd9b5a VZ |
1320 | const wxRect CellToRect(const wxGridCellCoords& coords) const; |
1321 | ||
23324ae1 FM |
1322 | //@} |
1323 | ||
1324 | /** | |
55f0bf1f VZ |
1325 | Clears all data in the underlying grid table and repaints the grid. |
1326 | ||
1327 | The table is not deleted by this function. If you are using a derived | |
1328 | table class then you need to override wxGridTableBase::Clear() for this | |
1329 | function to have any effect. | |
23324ae1 FM |
1330 | */ |
1331 | void ClearGrid(); | |
1332 | ||
1333 | /** | |
1334 | Deselects all cells that are currently selected. | |
1335 | */ | |
1336 | void ClearSelection(); | |
1337 | ||
23324ae1 FM |
1338 | /** |
1339 | Creates a grid with the specified initial number of rows and columns. | |
08dd9b5a | 1340 | |
23324ae1 FM |
1341 | Call this directly after the grid constructor. When you use this |
1342 | function wxGrid will create and manage a simple table of string values | |
1343 | for you. All of the grid data will be stored in memory. | |
23324ae1 FM |
1344 | For applications with more complex data types or relationships, or for |
1345 | dealing with very large datasets, you should derive your own grid table | |
1346 | class and pass a table object to the grid with SetTable(). | |
1347 | */ | |
1348 | bool CreateGrid(int numRows, int numCols, | |
55f0bf1f | 1349 | wxGridSelectionModes selmode = wxGridSelectCells); |
23324ae1 FM |
1350 | |
1351 | /** | |
55f0bf1f VZ |
1352 | Deletes one or more columns from a grid starting at the specified |
1353 | position. | |
3c4f71cc | 1354 | |
55f0bf1f VZ |
1355 | The @a updateLabels argument is not used at present. If you are using a |
1356 | derived grid table class you will need to override | |
1357 | wxGridTableBase::DeleteCols. See InsertCols() for further information. | |
3c4f71cc | 1358 | |
55f0bf1f | 1359 | @return @true on success or @false if deleting columns failed. |
23324ae1 | 1360 | */ |
55f0bf1f | 1361 | bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
1362 | |
1363 | /** | |
55f0bf1f | 1364 | Deletes one or more rows from a grid starting at the specified position. |
23324ae1 | 1365 | |
55f0bf1f VZ |
1366 | The @a updateLabels argument is not used at present. If you are using a |
1367 | derived grid table class you will need to override | |
1368 | wxGridTableBase::DeleteRows. See InsertRows() for further information. | |
1369 | ||
1370 | @return @true on success or @false if appending rows failed. | |
23324ae1 | 1371 | */ |
55f0bf1f | 1372 | bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true); |
23324ae1 FM |
1373 | |
1374 | /** | |
1375 | Disables in-place editing of grid cells. | |
08dd9b5a | 1376 | |
23324ae1 FM |
1377 | Equivalent to calling EnableCellEditControl(@false). |
1378 | */ | |
1379 | void DisableCellEditControl(); | |
1380 | ||
1381 | /** | |
55f0bf1f VZ |
1382 | Disables column moving by dragging with the mouse. |
1383 | ||
1384 | Equivalent to passing @false to EnableDragColMove(). | |
23324ae1 FM |
1385 | */ |
1386 | void DisableDragColMove(); | |
1387 | ||
1388 | /** | |
55f0bf1f VZ |
1389 | Disables column sizing by dragging with the mouse. |
1390 | ||
1391 | Equivalent to passing @false to EnableDragColSize(). | |
23324ae1 FM |
1392 | */ |
1393 | void DisableDragColSize(); | |
1394 | ||
1395 | /** | |
55f0bf1f VZ |
1396 | Disable mouse dragging of grid lines to resize rows and columns. |
1397 | ||
1398 | Equivalent to passing @false to EnableDragGridSize() | |
23324ae1 FM |
1399 | */ |
1400 | void DisableDragGridSize(); | |
1401 | ||
1402 | /** | |
55f0bf1f VZ |
1403 | Disables row sizing by dragging with the mouse. |
1404 | ||
1405 | Equivalent to passing @false to EnableDragRowSize(). | |
23324ae1 FM |
1406 | */ |
1407 | void DisableDragRowSize(); | |
1408 | ||
1409 | /** | |
55f0bf1f VZ |
1410 | Enables or disables in-place editing of grid cell data. |
1411 | ||
1412 | The grid will issue either a wxEVT_GRID_EDITOR_SHOWN or | |
1413 | wxEVT_GRID_EDITOR_HIDDEN event. | |
23324ae1 | 1414 | */ |
4cc4bfaf | 1415 | void EnableCellEditControl(bool enable = true); |
23324ae1 FM |
1416 | |
1417 | /** | |
1418 | Enables or disables column moving by dragging with the mouse. | |
1419 | */ | |
4cc4bfaf | 1420 | void EnableDragColMove(bool enable = true); |
23324ae1 FM |
1421 | |
1422 | /** | |
1423 | Enables or disables column sizing by dragging with the mouse. | |
1424 | */ | |
4cc4bfaf | 1425 | void EnableDragColSize(bool enable = true); |
23324ae1 FM |
1426 | |
1427 | /** | |
1428 | Enables or disables row and column resizing by dragging gridlines with the | |
1429 | mouse. | |
1430 | */ | |
4cc4bfaf | 1431 | void EnableDragGridSize(bool enable = true); |
23324ae1 FM |
1432 | |
1433 | /** | |
1434 | Enables or disables row sizing by dragging with the mouse. | |
1435 | */ | |
4cc4bfaf | 1436 | void EnableDragRowSize(bool enable = true); |
23324ae1 FM |
1437 | |
1438 | /** | |
55f0bf1f VZ |
1439 | Makes the grid globally editable or read-only. |
1440 | ||
1441 | If the edit argument is @false this function sets the whole grid as | |
1442 | read-only. If the argument is @true the grid is set to the default | |
1443 | state where cells may be editable. In the default state you can set | |
1444 | single grid cells and whole rows and columns to be editable or | |
1445 | read-only via wxGridCellAttribute::SetReadOnly. For single cells you | |
1446 | can also use the shortcut function SetReadOnly(). | |
1447 | ||
23324ae1 FM |
1448 | For more information about controlling grid cell attributes see the |
1449 | wxGridCellAttr cell attribute class and the | |
4cc4bfaf | 1450 | @ref overview_gridoverview. |
23324ae1 FM |
1451 | */ |
1452 | void EnableEditing(bool edit); | |
1453 | ||
1454 | /** | |
1455 | Turns the drawing of grid lines on or off. | |
1456 | */ | |
4cc4bfaf | 1457 | void EnableGridLines(bool enable = true); |
23324ae1 FM |
1458 | |
1459 | /** | |
55f0bf1f VZ |
1460 | Decrements the grid's batch count. |
1461 | ||
1462 | When the count is greater than zero repainting of the grid is | |
1463 | suppressed. Each previous call to BeginBatch() must be matched by a | |
1464 | later call to EndBatch. Code that does a lot of grid modification can | |
1465 | be enclosed between BeginBatch and EndBatch calls to avoid screen | |
1466 | flicker. The final EndBatch will cause the grid to be repainted. | |
3c4f71cc | 1467 | |
4cc4bfaf | 1468 | @see wxGridUpdateLocker |
23324ae1 FM |
1469 | */ |
1470 | void EndBatch(); | |
1471 | ||
1472 | /** | |
1473 | Overridden wxWindow method. | |
1474 | */ | |
4cc4bfaf | 1475 | void Fit(); |
23324ae1 FM |
1476 | |
1477 | /** | |
55f0bf1f VZ |
1478 | Causes immediate repainting of the grid. |
1479 | ||
1480 | Use this instead of the usual wxWindow::Refresh. | |
23324ae1 FM |
1481 | */ |
1482 | void ForceRefresh(); | |
1483 | ||
1484 | /** | |
1485 | Returns the number of times that BeginBatch() has been called | |
1486 | without (yet) matching calls to EndBatch(). While | |
1487 | the grid's batch count is greater than zero the display will not be updated. | |
1488 | */ | |
328f5751 | 1489 | int GetBatchCount() const; |
23324ae1 FM |
1490 | |
1491 | /** | |
55f0bf1f VZ |
1492 | Sets the arguments to the horizontal and vertical text alignment values |
1493 | for the grid cell at the specified location. | |
3c4f71cc | 1494 | |
55f0bf1f VZ |
1495 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1496 | or @c wxALIGN_RIGHT. | |
1497 | ||
1498 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1499 | @c wxALIGN_BOTTOM. | |
23324ae1 | 1500 | */ |
328f5751 | 1501 | void GetCellAlignment(int row, int col, int* horiz, int* vert) const; |
23324ae1 FM |
1502 | |
1503 | /** | |
1504 | Returns the background colour of the cell at the specified location. | |
1505 | */ | |
328f5751 | 1506 | wxColour GetCellBackgroundColour(int row, int col) const; |
23324ae1 FM |
1507 | |
1508 | /** | |
1509 | Returns a pointer to the editor for the cell at the specified location. | |
08dd9b5a VZ |
1510 | |
1511 | See wxGridCellEditor and the @ref overview_gridoverview "wxGrid | |
1512 | overview" for more information about cell editors and renderers. | |
1513 | ||
1514 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1515 | */ |
328f5751 | 1516 | wxGridCellEditor* GetCellEditor(int row, int col) const; |
23324ae1 FM |
1517 | |
1518 | /** | |
1519 | Returns the font for text in the grid cell at the specified location. | |
1520 | */ | |
328f5751 | 1521 | wxFont GetCellFont(int row, int col) const; |
23324ae1 FM |
1522 | |
1523 | /** | |
08dd9b5a VZ |
1524 | Returns a pointer to the renderer for the grid cell at the specified |
1525 | location. | |
1526 | ||
1527 | See wxGridCellRenderer and the @ref overview_gridoverview "wxGrid | |
1528 | overview" for more information about cell editors and renderers. | |
1529 | ||
1530 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1531 | */ |
328f5751 | 1532 | wxGridCellRenderer* GetCellRenderer(int row, int col) const; |
23324ae1 FM |
1533 | |
1534 | /** | |
1535 | Returns the text colour for the grid cell at the specified location. | |
1536 | */ | |
328f5751 | 1537 | wxColour GetCellTextColour(int row, int col) const; |
23324ae1 FM |
1538 | |
1539 | //@{ | |
1540 | /** | |
08dd9b5a VZ |
1541 | Returns the string contained in the cell at the specified location. |
1542 | ||
1543 | For simple applications where a grid object automatically uses a | |
1544 | default grid table of string values you use this function together with | |
1545 | SetCellValue() to access cell values. For more complex applications | |
1546 | where you have derived your own grid table class that contains various | |
1547 | data types (e.g. numeric, boolean or user-defined custom types) then | |
1548 | you only use this function for those cells that contain string values. | |
1549 | ||
1550 | See wxGridTableBase::CanGetValueAs and the @ref overview_gridoverview | |
1551 | "wxGrid overview" for more information. | |
23324ae1 | 1552 | */ |
328f5751 FM |
1553 | wxString GetCellValue(int row, int col) const; |
1554 | const wxString GetCellValue(const wxGridCellCoords& coords) const; | |
23324ae1 FM |
1555 | //@} |
1556 | ||
1557 | /** | |
1558 | Returns the column ID of the specified column position. | |
1559 | */ | |
328f5751 | 1560 | int GetColAt(int colPos) const; |
23324ae1 FM |
1561 | |
1562 | /** | |
08dd9b5a VZ |
1563 | Returns the pen used for vertical grid lines. |
1564 | ||
1565 | This virtual function may be overridden in derived classes in order to | |
1566 | change the appearance of individual grid lines for the given column @e | |
1567 | col. | |
1568 | ||
23324ae1 FM |
1569 | See GetRowGridLinePen() for an example. |
1570 | */ | |
1571 | wxPen GetColGridLinePen(int col); | |
1572 | ||
1573 | /** | |
1574 | Sets the arguments to the current column label alignment values. | |
3c4f71cc | 1575 | |
55f0bf1f VZ |
1576 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1577 | or @c wxALIGN_RIGHT. | |
1578 | ||
1579 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1580 | @c wxALIGN_BOTTOM. | |
23324ae1 | 1581 | */ |
328f5751 | 1582 | void GetColLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
1583 | |
1584 | /** | |
1585 | Returns the current height of the column labels. | |
1586 | */ | |
328f5751 | 1587 | int GetColLabelSize() const; |
23324ae1 FM |
1588 | |
1589 | /** | |
55f0bf1f VZ |
1590 | Returns the specified column label. |
1591 | ||
1592 | The default grid table class provides column labels of the form | |
1593 | A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can | |
1594 | override wxGridTableBase::GetColLabelValue to provide your own labels. | |
23324ae1 | 1595 | */ |
328f5751 | 1596 | wxString GetColLabelValue(int col) const; |
23324ae1 FM |
1597 | |
1598 | /** | |
55f0bf1f | 1599 | Returns the coordinate of the left border specified column. |
23324ae1 | 1600 | */ |
328f5751 | 1601 | int GetColLeft(int col) const; |
23324ae1 FM |
1602 | |
1603 | /** | |
08dd9b5a VZ |
1604 | Returns the minimal width to which a column may be resized. |
1605 | ||
1606 | Use SetColMinimalAcceptableWidth() to change this value globally or | |
1607 | SetColMinimalWidth() to do it for individual columns. | |
23324ae1 | 1608 | */ |
328f5751 | 1609 | int GetColMinimalAcceptableWidth() const; |
23324ae1 FM |
1610 | |
1611 | /** | |
1612 | Get the minimal width of the given column/row. | |
08dd9b5a VZ |
1613 | |
1614 | The value returned by this function may be different than that returned | |
1615 | by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been | |
1616 | called for this column. | |
23324ae1 | 1617 | */ |
328f5751 | 1618 | int GetColMinimalWidth(int col) const; |
23324ae1 FM |
1619 | |
1620 | /** | |
1621 | Returns the position of the specified column. | |
1622 | */ | |
328f5751 | 1623 | int GetColPos(int colID) const; |
23324ae1 FM |
1624 | |
1625 | /** | |
55f0bf1f | 1626 | Returns the coordinate of the right border specified column. |
23324ae1 | 1627 | */ |
328f5751 | 1628 | int GetColRight(int col) const; |
23324ae1 FM |
1629 | |
1630 | /** | |
1631 | Returns the width of the specified column. | |
1632 | */ | |
328f5751 | 1633 | int GetColSize(int col) const; |
23324ae1 FM |
1634 | |
1635 | /** | |
08dd9b5a | 1636 | Returns the default cell alignment. |
3c4f71cc | 1637 | |
08dd9b5a VZ |
1638 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1639 | or @c wxALIGN_RIGHT. | |
1640 | ||
1641 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1642 | @c wxALIGN_BOTTOM. | |
1643 | ||
1644 | @see SetDefaultCellAlignment() | |
23324ae1 | 1645 | */ |
328f5751 | 1646 | void GetDefaultCellAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
1647 | |
1648 | /** | |
1649 | Returns the current default background colour for grid cells. | |
1650 | */ | |
328f5751 | 1651 | wxColour GetDefaultCellBackgroundColour() const; |
23324ae1 FM |
1652 | |
1653 | /** | |
1654 | Returns the current default font for grid cell text. | |
1655 | */ | |
328f5751 | 1656 | wxFont GetDefaultCellFont() const; |
23324ae1 FM |
1657 | |
1658 | /** | |
1659 | Returns the current default colour for grid cell text. | |
1660 | */ | |
328f5751 | 1661 | wxColour GetDefaultCellTextColour() const; |
23324ae1 FM |
1662 | |
1663 | /** | |
1664 | Returns the default height for column labels. | |
1665 | */ | |
328f5751 | 1666 | int GetDefaultColLabelSize() const; |
23324ae1 FM |
1667 | |
1668 | /** | |
1669 | Returns the current default width for grid columns. | |
1670 | */ | |
328f5751 | 1671 | int GetDefaultColSize() const; |
23324ae1 FM |
1672 | |
1673 | /** | |
1674 | Returns a pointer to the current default grid cell editor. | |
08dd9b5a VZ |
1675 | |
1676 | See wxGridCellEditor and the @ref overview_gridoverview "wxGrid | |
1677 | overview" for more information about cell editors and renderers. | |
23324ae1 | 1678 | */ |
328f5751 | 1679 | wxGridCellEditor* GetDefaultEditor() const; |
23324ae1 FM |
1680 | |
1681 | //@{ | |
1682 | /** | |
08dd9b5a VZ |
1683 | Returns the default editor for the specified cell. |
1684 | ||
1685 | The base class version returns the editor appropriate for the current | |
1686 | cell type but this method may be overridden in the derived classes to | |
1687 | use custom editors for some cells by default. | |
3c4f71cc | 1688 | |
08dd9b5a VZ |
1689 | Notice that the same may be usually achieved in simpler way by |
1690 | associating a custom editor with the given cell or cells. | |
1691 | ||
1692 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1693 | */ |
08dd9b5a VZ |
1694 | virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; |
1695 | wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const; | |
23324ae1 FM |
1696 | //@} |
1697 | ||
1698 | /** | |
08dd9b5a VZ |
1699 | Returns the default editor for the cells containing values of the given |
1700 | type. | |
1701 | ||
1702 | The base class version returns the editor which was associated with the | |
1703 | specified @a typeName when it was registered RegisterDataType() but | |
1704 | this function may be overridden to return something different. This | |
1705 | allows to override an editor used for one of the standard types. | |
3c4f71cc | 1706 | |
08dd9b5a | 1707 | The caller must call DecRef() on the returned pointer. |
23324ae1 | 1708 | */ |
08dd9b5a VZ |
1709 | virtual wxGridCellEditor * |
1710 | GetDefaultEditorForType(const wxString& typeName) const; | |
23324ae1 FM |
1711 | |
1712 | /** | |
08dd9b5a VZ |
1713 | Returns the pen used for grid lines. |
1714 | ||
1715 | This virtual function may be overridden in derived classes in order to | |
1716 | change the appearance of grid lines. Note that currently the pen width | |
1717 | must be 1. | |
3c4f71cc | 1718 | |
4cc4bfaf | 1719 | @see GetColGridLinePen(), GetRowGridLinePen() |
23324ae1 FM |
1720 | */ |
1721 | wxPen GetDefaultGridLinePen(); | |
1722 | ||
1723 | /** | |
1724 | Returns a pointer to the current default grid cell renderer. | |
08dd9b5a VZ |
1725 | |
1726 | See wxGridCellRenderer and the @ref overview_gridoverview "wxGrid | |
1727 | overview" for more information about cell editors and renderers. | |
1728 | ||
1729 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1730 | */ |
328f5751 | 1731 | wxGridCellRenderer* GetDefaultRenderer() const; |
23324ae1 FM |
1732 | |
1733 | /** | |
08dd9b5a | 1734 | Returns the default renderer for the given cell. |
3c4f71cc | 1735 | |
08dd9b5a VZ |
1736 | The base class version returns the renderer appropriate for the current |
1737 | cell type but this method may be overridden in the derived classes to | |
1738 | use custom renderers for some cells by default. | |
1739 | ||
1740 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 1741 | */ |
08dd9b5a | 1742 | virtual wxGridCellRenderer *GetDefaultRendererForCell(int row, int col) const; |
23324ae1 FM |
1743 | |
1744 | /** | |
08dd9b5a VZ |
1745 | Returns the default renderer for the cell containing values of the |
1746 | given type. | |
3c4f71cc | 1747 | |
08dd9b5a | 1748 | @see GetDefaultEditorForType() |
23324ae1 | 1749 | */ |
08dd9b5a VZ |
1750 | virtual wxGridCellRenderer * |
1751 | GetDefaultRendererForType(const wxString& typeName) const; | |
23324ae1 FM |
1752 | |
1753 | /** | |
1754 | Returns the default width for the row labels. | |
1755 | */ | |
328f5751 | 1756 | int GetDefaultRowLabelSize() const; |
23324ae1 FM |
1757 | |
1758 | /** | |
1759 | Returns the current default height for grid rows. | |
1760 | */ | |
328f5751 | 1761 | int GetDefaultRowSize() const; |
23324ae1 FM |
1762 | |
1763 | /** | |
1764 | Returns the current grid cell column position. | |
1765 | */ | |
328f5751 | 1766 | int GetGridCursorCol() const; |
23324ae1 FM |
1767 | |
1768 | /** | |
1769 | Returns the current grid cell row position. | |
1770 | */ | |
328f5751 | 1771 | int GetGridCursorRow() const; |
23324ae1 FM |
1772 | |
1773 | /** | |
1774 | Returns the colour used for grid lines. | |
3c4f71cc | 1775 | |
4cc4bfaf | 1776 | @see GetDefaultGridLinePen() |
23324ae1 | 1777 | */ |
328f5751 | 1778 | wxColour GetGridLineColour() const; |
23324ae1 FM |
1779 | |
1780 | /** | |
1781 | Returns the colour used for the background of row and column labels. | |
1782 | */ | |
328f5751 | 1783 | wxColour GetLabelBackgroundColour() const; |
23324ae1 FM |
1784 | |
1785 | /** | |
1786 | Returns the font used for row and column labels. | |
1787 | */ | |
328f5751 | 1788 | wxFont GetLabelFont() const; |
23324ae1 FM |
1789 | |
1790 | /** | |
1791 | Returns the colour used for row and column label text. | |
1792 | */ | |
328f5751 | 1793 | wxColour GetLabelTextColour() const; |
23324ae1 FM |
1794 | |
1795 | /** | |
08dd9b5a VZ |
1796 | Returns the total number of grid columns. |
1797 | ||
1798 | This is the same as the number of columns in the underlying grid | |
1799 | table. | |
23324ae1 | 1800 | */ |
328f5751 | 1801 | int GetNumberCols() const; |
23324ae1 FM |
1802 | |
1803 | /** | |
08dd9b5a VZ |
1804 | Returns the total number of grid rows. |
1805 | ||
1806 | This is the same as the number of rows in the underlying grid table. | |
23324ae1 | 1807 | */ |
328f5751 | 1808 | int GetNumberRows() const; |
23324ae1 FM |
1809 | |
1810 | /** | |
08dd9b5a | 1811 | Returns the attribute for the given cell creating one if necessary. |
3c4f71cc | 1812 | |
08dd9b5a VZ |
1813 | If the cell already has an attribute, it is returned. Otherwise a new |
1814 | attribute is created, associated with the cell and returned. In any | |
1815 | case the caller must call DecRef() on the returned pointer. | |
1816 | ||
1817 | This function may only be called if CanHaveAttributes() returns @true. | |
23324ae1 | 1818 | */ |
08dd9b5a | 1819 | wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const; |
23324ae1 FM |
1820 | |
1821 | /** | |
08dd9b5a VZ |
1822 | Returns the pen used for horizontal grid lines. |
1823 | ||
1824 | This virtual function may be overridden in derived classes in order to | |
1825 | change the appearance of individual grid line for the given row @e row. | |
1826 | ||
23324ae1 | 1827 | Example: |
08dd9b5a VZ |
1828 | @code |
1829 | // in a grid displaying music notation, use a solid black pen between | |
1830 | // octaves (C0=row 127, C1=row 115 etc.) | |
1831 | wxPen MidiGrid::GetRowGridLinePen(int row) | |
1832 | { | |
1833 | if ( row % 12 == 7 ) | |
1834 | return wxPen(*wxBLACK, 1, wxSOLID); | |
1835 | else | |
1836 | return GetDefaultGridLinePen(); | |
1837 | } | |
1838 | @endcode | |
23324ae1 FM |
1839 | */ |
1840 | wxPen GetRowGridLinePen(int row); | |
1841 | ||
1842 | /** | |
08dd9b5a | 1843 | Returns the alignment used for row labels. |
3c4f71cc | 1844 | |
08dd9b5a VZ |
1845 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1846 | or @c wxALIGN_RIGHT. | |
1847 | ||
1848 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1849 | @c wxALIGN_BOTTOM. | |
23324ae1 | 1850 | */ |
328f5751 | 1851 | void GetRowLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
1852 | |
1853 | /** | |
1854 | Returns the current width of the row labels. | |
1855 | */ | |
328f5751 | 1856 | int GetRowLabelSize() const; |
23324ae1 FM |
1857 | |
1858 | /** | |
08dd9b5a VZ |
1859 | Returns the specified row label. |
1860 | ||
1861 | The default grid table class provides numeric row labels. If you are | |
1862 | using a custom grid table you can override | |
1863 | wxGridTableBase::GetRowLabelValue to provide your own labels. | |
23324ae1 | 1864 | */ |
328f5751 | 1865 | wxString GetRowLabelValue(int row) const; |
23324ae1 FM |
1866 | |
1867 | /** | |
08dd9b5a VZ |
1868 | Returns the minimal size to which rows can be resized. |
1869 | ||
1870 | Use SetRowMinimalAcceptableHeight() to change this value globally or | |
1871 | SetRowMinimalHeight() to do it for individual cells. | |
1872 | ||
1873 | @see GetColMinimalAcceptableWidth() | |
23324ae1 | 1874 | */ |
328f5751 | 1875 | int GetRowMinimalAcceptableHeight() const; |
23324ae1 FM |
1876 | |
1877 | /** | |
08dd9b5a | 1878 | Returns the minimal size for the given column. |
3c4f71cc | 1879 | |
08dd9b5a VZ |
1880 | The value returned by this function may be different than that returned |
1881 | by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been | |
1882 | called for this row. | |
23324ae1 | 1883 | */ |
328f5751 | 1884 | int GetRowMinimalHeight(int col) const; |
23324ae1 FM |
1885 | |
1886 | /** | |
1887 | Returns the height of the specified row. | |
1888 | */ | |
328f5751 | 1889 | int GetRowSize(int row) const; |
23324ae1 FM |
1890 | |
1891 | /** | |
08dd9b5a VZ |
1892 | Returns the number of pixels per horizontal scroll increment. |
1893 | ||
1894 | The default is 15. | |
3c4f71cc | 1895 | |
4cc4bfaf | 1896 | @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY() |
23324ae1 | 1897 | */ |
328f5751 | 1898 | int GetScrollLineX() const; |
23324ae1 FM |
1899 | |
1900 | /** | |
08dd9b5a VZ |
1901 | Returns the number of pixels per vertical scroll increment. |
1902 | ||
1903 | The default is 15. | |
3c4f71cc | 1904 | |
4cc4bfaf | 1905 | @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY() |
23324ae1 | 1906 | */ |
328f5751 | 1907 | int GetScrollLineY() const; |
23324ae1 FM |
1908 | |
1909 | /** | |
08dd9b5a VZ |
1910 | Returns an array of individually selected cells. |
1911 | ||
1912 | Notice that this array does @em not contain all the selected cells in | |
1913 | general as it doesn't include the cells selected as part of column, row | |
1914 | or block selection. You must use this method, GetSelectedCols(), | |
1915 | GetSelectedRows() and GetSelectionBlockTopLeft() and | |
1916 | GetSelectionBlockBottomRight() methods to obtain the entire selection | |
1917 | in general. | |
1918 | ||
1919 | Please notice this behaviour is by design and is needed in order to | |
1920 | support grids of arbitrary size (when an entire column is selected in | |
1921 | a grid with a million of columns, we don't want to create an array with | |
1922 | a million of entries in this function, instead it returns an empty | |
1923 | array and GetSelectedCols() returns an array containing one element). | |
23324ae1 | 1924 | */ |
328f5751 | 1925 | wxGridCellCoordsArray GetSelectedCells() const; |
23324ae1 FM |
1926 | |
1927 | /** | |
08dd9b5a | 1928 | Returns an array of selected columns. |
bb778cae VZ |
1929 | |
1930 | Please notice that this method alone is not sufficient to find all the | |
08dd9b5a VZ |
1931 | selected columns as it contains only the columns which were |
1932 | individually selected but not those being part of the block selection | |
1933 | or being selected in virtue of all of their cells being selected | |
1934 | individually, please see GetSelectedCells() for more details. | |
23324ae1 | 1935 | */ |
328f5751 | 1936 | wxArrayInt GetSelectedCols() const; |
23324ae1 FM |
1937 | |
1938 | /** | |
1939 | Returns an array of selected rows. | |
bb778cae | 1940 | |
08dd9b5a VZ |
1941 | Please notice that this method alone is not sufficient to find all the |
1942 | selected rows as it contains only the rows which were individually | |
1943 | selected but not those being part of the block selection or being | |
1944 | selected in virtue of all of their cells being selected individually, | |
1945 | please see GetSelectedCells() for more details. | |
23324ae1 | 1946 | */ |
328f5751 | 1947 | wxArrayInt GetSelectedRows() const; |
23324ae1 FM |
1948 | |
1949 | /** | |
1950 | Access or update the selection fore/back colours | |
1951 | */ | |
328f5751 | 1952 | wxColour GetSelectionBackground() const; |
23324ae1 FM |
1953 | |
1954 | /** | |
08dd9b5a VZ |
1955 | Returns an array of the bottom right corners of blocks of selected |
1956 | cells. | |
1957 | ||
1958 | Please see GetSelectedCells() for more information about the selection | |
1959 | representation in wxGrid. | |
1960 | ||
1961 | @see GetSelectionBlockTopLeft() | |
23324ae1 | 1962 | */ |
328f5751 | 1963 | wxGridCellCoordsArray GetSelectionBlockBottomRight() const; |
23324ae1 FM |
1964 | |
1965 | /** | |
08dd9b5a VZ |
1966 | Returns an array of the top left corners of blocks of selected cells. |
1967 | ||
1968 | Please see GetSelectedCells() for more information about the selection | |
1969 | representation in wxGrid. | |
1970 | ||
1971 | @see GetSelectionBlockBottomRight() | |
23324ae1 | 1972 | */ |
328f5751 | 1973 | wxGridCellCoordsArray GetSelectionBlockTopLeft() const; |
23324ae1 FM |
1974 | |
1975 | /** | |
08dd9b5a | 1976 | Returns the colour used for drawing the selection foreground. |
23324ae1 | 1977 | */ |
328f5751 | 1978 | wxColour GetSelectionForeground() const; |
23324ae1 FM |
1979 | |
1980 | /** | |
08dd9b5a VZ |
1981 | Returns the current selection mode. |
1982 | ||
1983 | @see SetSelectionMode(). | |
23324ae1 | 1984 | */ |
55f0bf1f | 1985 | wxGridSelectionModes GetSelectionMode() const; |
23324ae1 FM |
1986 | |
1987 | /** | |
1988 | Returns a base pointer to the current table object. | |
3c4f71cc | 1989 | |
08dd9b5a | 1990 | The returned pointer is still owned by the grid. |
23324ae1 | 1991 | */ |
08dd9b5a | 1992 | wxGridTableBase *GetTable() const; |
23324ae1 FM |
1993 | |
1994 | /** | |
1995 | Returns @true if drawing of grid lines is turned on, @false otherwise. | |
1996 | */ | |
328f5751 | 1997 | bool GridLinesEnabled() const; |
23324ae1 FM |
1998 | |
1999 | /** | |
2000 | Hides the in-place cell edit control. | |
2001 | */ | |
2002 | void HideCellEditControl(); | |
2003 | ||
2004 | /** | |
2005 | Hides the column labels by calling SetColLabelSize() | |
2006 | with a size of 0. Show labels again by calling that method with | |
2007 | a width greater than 0. | |
2008 | */ | |
2009 | void HideColLabels(); | |
2010 | ||
2011 | /** | |
08dd9b5a VZ |
2012 | Hides the row labels by calling SetRowLabelSize() with a size of 0. |
2013 | ||
2014 | The labels can be shown again by calling SetRowLabelSize() with a width | |
2015 | greater than 0. | |
23324ae1 FM |
2016 | */ |
2017 | void HideRowLabels(); | |
2018 | ||
2019 | /** | |
08dd9b5a VZ |
2020 | Inserts one or more new columns into a grid with the first new column |
2021 | at the specified position. | |
23324ae1 | 2022 | |
08dd9b5a VZ |
2023 | Notice that inserting the columns in the grid requires grid table |
2024 | cooperation: when this method is called, grid object begins by | |
2025 | requesting the underlying grid table to insert new columns. If this is | |
2026 | successful the table notifies the grid and the grid updates the | |
2027 | display. For a default grid (one where you have called | |
2028 | wxGrid::CreateGrid) this process is automatic. If you are using a | |
2029 | custom grid table (specified with wxGrid::SetTable) then you must | |
2030 | override wxGridTableBase::InsertCols() in your derived table class. | |
23324ae1 | 2031 | |
08dd9b5a VZ |
2032 | @param pos |
2033 | The position which the first newly inserted column will have. | |
2034 | @param numCols | |
2035 | The number of columns to insert. | |
2036 | @param updateLabels | |
2037 | Currently not used. | |
2038 | @return | |
2039 | @true if the columns were successfully inserted, @false if an error | |
2040 | occurred (most likely the table couldn't be updated). | |
23324ae1 | 2041 | */ |
08dd9b5a | 2042 | bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
2043 | |
2044 | /** | |
08dd9b5a VZ |
2045 | Inserts one or more new rows into a grid with the first new row at the |
2046 | specified position. | |
2047 | ||
2048 | Notice that you must implement wxGridTableBase::InsertRows() if you use | |
2049 | a grid with a custom table, please see InsertCols() for more | |
2050 | information. | |
2051 | ||
2052 | @param pos | |
2053 | The position which the first newly inserted row will have. | |
2054 | @param numRows | |
2055 | The number of rows to insert. | |
2056 | @param updateLabels | |
2057 | Currently not used. | |
2058 | @return | |
2059 | @true if the rows were successfully inserted, @false if an error | |
2060 | occurred (most likely the table couldn't be updated). | |
23324ae1 | 2061 | */ |
08dd9b5a | 2062 | bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true); |
23324ae1 FM |
2063 | |
2064 | /** | |
2065 | Returns @true if the in-place edit control is currently enabled. | |
2066 | */ | |
328f5751 | 2067 | bool IsCellEditControlEnabled() const; |
23324ae1 FM |
2068 | |
2069 | /** | |
08dd9b5a VZ |
2070 | Returns @true if the current cell is read-only. |
2071 | ||
2072 | @see SetReadOnly(), IsReadOnly() | |
23324ae1 | 2073 | */ |
328f5751 | 2074 | bool IsCurrentCellReadOnly() const; |
23324ae1 FM |
2075 | |
2076 | /** | |
08dd9b5a VZ |
2077 | Returns @false if the whole grid has been set as read-only or @true |
2078 | otherwise. | |
2079 | ||
2080 | See EnableEditing() for more information about controlling the editing | |
2081 | status of grid cells. | |
23324ae1 | 2082 | */ |
328f5751 | 2083 | bool IsEditable() const; |
23324ae1 FM |
2084 | |
2085 | //@{ | |
2086 | /** | |
08dd9b5a | 2087 | Is this cell currently selected? |
23324ae1 | 2088 | */ |
328f5751 | 2089 | bool IsInSelection(int row, int col) const; |
08dd9b5a | 2090 | bool IsInSelection(const wxGridCellCoords& coords) const; |
23324ae1 FM |
2091 | //@} |
2092 | ||
2093 | /** | |
2094 | Returns @true if the cell at the specified location can't be edited. | |
08dd9b5a VZ |
2095 | |
2096 | @see SetReadOnly(), IsCurrentCellReadOnly() | |
23324ae1 | 2097 | */ |
328f5751 | 2098 | bool IsReadOnly(int row, int col) const; |
23324ae1 FM |
2099 | |
2100 | /** | |
08dd9b5a VZ |
2101 | Returns @true if there are currently any selected cells, rows, columns |
2102 | or blocks. | |
23324ae1 | 2103 | */ |
328f5751 | 2104 | bool IsSelection() const; |
23324ae1 FM |
2105 | |
2106 | //@{ | |
2107 | /** | |
08dd9b5a VZ |
2108 | Returns @true if a cell is either wholly or at least partially visible |
2109 | in the grid window. | |
2110 | ||
2111 | By default, the cell must be entirely visible for this function to | |
2112 | return true but if @a wholeCellVisible is @false, the function returns | |
2113 | @true even if the cell is only partially visible. | |
23324ae1 | 2114 | */ |
328f5751 FM |
2115 | bool IsVisible(int row, int col, bool wholeCellVisible = true) const; |
2116 | const bool IsVisible(const wxGridCellCoords& coords, | |
2117 | bool wholeCellVisible = true) const; | |
23324ae1 FM |
2118 | //@} |
2119 | ||
2120 | //@{ | |
2121 | /** | |
2122 | Brings the specified cell into the visible grid cell area with minimal | |
08dd9b5a VZ |
2123 | scrolling. |
2124 | ||
2125 | Does nothing if the cell is already visible. | |
23324ae1 FM |
2126 | */ |
2127 | void MakeCellVisible(int row, int col); | |
7c913512 | 2128 | void MakeCellVisible(const wxGridCellCoords& coords); |
23324ae1 FM |
2129 | //@} |
2130 | ||
2131 | /** | |
08dd9b5a VZ |
2132 | Moves the grid cursor down by one row. |
2133 | ||
2134 | If a block of cells was previously selected it will expand if the | |
2135 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2136 | */ |
2137 | bool MoveCursorDown(bool expandSelection); | |
2138 | ||
2139 | /** | |
08dd9b5a VZ |
2140 | Moves the grid cursor down in the current column such that it skips to |
2141 | the beginning or end of a block of non-empty cells. | |
2142 | ||
2143 | If a block of cells was previously selected it will expand if the | |
2144 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2145 | */ |
2146 | bool MoveCursorDownBlock(bool expandSelection); | |
2147 | ||
2148 | /** | |
08dd9b5a VZ |
2149 | Moves the grid cursor left by one column. |
2150 | ||
2151 | If a block of cells was previously selected it will expand if the | |
2152 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2153 | */ |
2154 | bool MoveCursorLeft(bool expandSelection); | |
2155 | ||
2156 | /** | |
2157 | Moves the grid cursor left in the current row such that it skips to the | |
08dd9b5a VZ |
2158 | beginning or end of a block of non-empty cells. |
2159 | ||
2160 | If a block of cells was previously selected it will expand if the | |
2161 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2162 | */ |
2163 | bool MoveCursorLeftBlock(bool expandSelection); | |
2164 | ||
2165 | /** | |
08dd9b5a VZ |
2166 | Moves the grid cursor right by one column. |
2167 | ||
2168 | If a block of cells was previously selected it will expand if the | |
2169 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2170 | */ |
2171 | bool MoveCursorRight(bool expandSelection); | |
2172 | ||
2173 | /** | |
08dd9b5a VZ |
2174 | Moves the grid cursor right in the current row such that it skips to |
2175 | the beginning or end of a block of non-empty cells. | |
2176 | ||
2177 | If a block of cells was previously selected it will expand if the | |
2178 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2179 | */ |
2180 | bool MoveCursorRightBlock(bool expandSelection); | |
2181 | ||
2182 | /** | |
08dd9b5a VZ |
2183 | Moves the grid cursor up by one row. |
2184 | ||
2185 | If a block of cells was previously selected it will expand if the | |
2186 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2187 | */ |
2188 | bool MoveCursorUp(bool expandSelection); | |
2189 | ||
2190 | /** | |
08dd9b5a VZ |
2191 | Moves the grid cursor up in the current column such that it skips to |
2192 | the beginning or end of a block of non-empty cells. | |
2193 | ||
2194 | If a block of cells was previously selected it will expand if the | |
2195 | argument is @true or be cleared if the argument is @false. | |
23324ae1 FM |
2196 | */ |
2197 | bool MoveCursorUpBlock(bool expandSelection); | |
2198 | ||
2199 | /** | |
08dd9b5a VZ |
2200 | Moves the grid cursor down by some number of rows so that the previous |
2201 | bottom visible row becomes the top visible row. | |
23324ae1 FM |
2202 | */ |
2203 | bool MovePageDown(); | |
2204 | ||
2205 | /** | |
08dd9b5a VZ |
2206 | Moves the grid cursor up by some number of rows so that the previous |
2207 | top visible row becomes the bottom visible row. | |
23324ae1 FM |
2208 | */ |
2209 | bool MovePageUp(); | |
2210 | ||
2211 | /** | |
08dd9b5a VZ |
2212 | Register a new data type. |
2213 | ||
2214 | The data types allow to naturally associate specific renderers and | |
2215 | editors to the cells containing values of the given type. For example, | |
2216 | the grid automatically registers a data type with the name @c | |
2217 | wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and | |
2218 | wxGridCellTextEditor as its renderer and editor respectively -- this is | |
2219 | the data type used by all the cells of the default wxGridStringTable, | |
2220 | so this renderer and editor are used by default for all grid cells. | |
2221 | ||
2222 | However if a custom table returns @c wxGRID_VALUE_BOOL from its | |
2223 | wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and | |
2224 | wxGridCellBoolEditor are used for it because the grid also registers a | |
2225 | boolean data type with this name. | |
2226 | ||
2227 | And as this mechanism is completely generic, you may register your own | |
2228 | data types using your own custom renderers and editors. Just remember | |
2229 | that the table must identify a cell as being of the given type for them | |
2230 | to be used for this cell. | |
2231 | ||
2232 | @param typeName | |
2233 | Name of the new type. May be any string, but if the type name is | |
2234 | the same as the name of an already registered type, including one | |
2235 | of the standard ones (which are @c wxGRID_VALUE_STRING, @c | |
2236 | wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT | |
2237 | and @c wxGRID_VALUE_CHOICE), then the new registration information | |
2238 | replaces the previously used renderer and editor. | |
2239 | @param renderer | |
2240 | The renderer to use for the cells of this type. Its ownership is | |
2241 | taken by the grid, i.e. it will call DecRef() on this pointer when | |
2242 | it doesn't need it any longer. | |
2243 | @param editor | |
2244 | The editor to use for the cells of this type. Its ownership is also | |
2245 | taken by the grid. | |
23324ae1 FM |
2246 | */ |
2247 | void RegisterDataType(const wxString& typeName, | |
2248 | wxGridCellRenderer* renderer, | |
2249 | wxGridCellEditor* editor); | |
2250 | ||
23324ae1 | 2251 | /** |
08dd9b5a VZ |
2252 | Sets the value of the current grid cell to the current in-place edit |
2253 | control value. | |
2254 | ||
2255 | This is called automatically when the grid cursor moves from the | |
2256 | current cell to a new cell. It is also a good idea to call this | |
2257 | function when closing a grid since any edits to the final cell location | |
2258 | will not be saved otherwise. | |
23324ae1 FM |
2259 | */ |
2260 | void SaveEditControlValue(); | |
2261 | ||
2262 | /** | |
2263 | Selects all cells in the grid. | |
2264 | */ | |
2265 | void SelectAll(); | |
2266 | ||
2267 | //@{ | |
2268 | /** | |
08dd9b5a VZ |
2269 | Selects a rectangular block of cells. |
2270 | ||
2271 | If @a addToSelected is @false then any existing selection will be | |
2272 | deselected; if @true the column will be added to the existing | |
2273 | selection. | |
23324ae1 | 2274 | */ |
08dd9b5a | 2275 | void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, |
4cc4bfaf | 2276 | bool addToSelected = false); |
7c913512 FM |
2277 | void SelectBlock(const wxGridCellCoords& topLeft, |
2278 | const wxGridCellCoords& bottomRight, | |
4cc4bfaf | 2279 | bool addToSelected = false); |
23324ae1 FM |
2280 | //@} |
2281 | ||
2282 | /** | |
08dd9b5a VZ |
2283 | Selects the specified column. |
2284 | ||
2285 | If @a addToSelected is @false then any existing selection will be | |
2286 | deselected; if @true the column will be added to the existing | |
2287 | selection. | |
2288 | ||
2289 | This method won't select anything if the current selection mode is | |
2290 | wxGridSelectRows. | |
23324ae1 | 2291 | */ |
4cc4bfaf | 2292 | void SelectCol(int col, bool addToSelected = false); |
23324ae1 FM |
2293 | |
2294 | /** | |
08dd9b5a VZ |
2295 | Selects the specified row. |
2296 | ||
2297 | If @a addToSelected is @false then any existing selection will be | |
23324ae1 | 2298 | deselected; if @true the row will be added to the existing selection. |
23324ae1 | 2299 | |
08dd9b5a VZ |
2300 | This method won't select anything if the current selection mode is |
2301 | wxGridSelectColumns. | |
23324ae1 | 2302 | */ |
08dd9b5a | 2303 | void SelectRow(int row, bool addToSelected = false); |
23324ae1 FM |
2304 | |
2305 | //@{ | |
2306 | /** | |
08dd9b5a VZ |
2307 | Sets the horizontal and vertical alignment for grid cell text at the |
2308 | specified location. | |
3c4f71cc | 2309 | |
08dd9b5a VZ |
2310 | Horizontal alignment should be one of @c wxALIGN_LEFT, @c |
2311 | wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2312 | ||
2313 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2314 | or @c wxALIGN_BOTTOM. | |
23324ae1 FM |
2315 | */ |
2316 | void SetCellAlignment(int row, int col, int horiz, int vert); | |
7c913512 | 2317 | void SetCellAlignment(int align, int row, int col); |
23324ae1 FM |
2318 | //@} |
2319 | ||
08dd9b5a | 2320 | //@{ |
23324ae1 | 2321 | /** |
08dd9b5a | 2322 | Set the background colour for the given cell or all cells by default. |
23324ae1 | 2323 | */ |
08dd9b5a VZ |
2324 | void SetCellBackgroundColour(int row, int col, const wxColour& colour); |
2325 | //@} | |
23324ae1 FM |
2326 | |
2327 | /** | |
2328 | Sets the editor for the grid cell at the specified location. | |
08dd9b5a | 2329 | |
23324ae1 | 2330 | The grid will take ownership of the pointer. |
08dd9b5a VZ |
2331 | |
2332 | See wxGridCellEditor and the @ref overview_gridoverview "wxGrid | |
2333 | overview" for more information about cell editors and renderers. | |
23324ae1 FM |
2334 | */ |
2335 | void SetCellEditor(int row, int col, wxGridCellEditor* editor); | |
2336 | ||
2337 | /** | |
2338 | Sets the font for text in the grid cell at the specified location. | |
2339 | */ | |
2340 | void SetCellFont(int row, int col, const wxFont& font); | |
2341 | ||
2342 | /** | |
2343 | Sets the renderer for the grid cell at the specified location. | |
08dd9b5a | 2344 | |
23324ae1 | 2345 | The grid will take ownership of the pointer. |
08dd9b5a VZ |
2346 | |
2347 | See wxGridCellRenderer and the @ref overview_gridoverview "wxGrid | |
2348 | overview" for more information about cell editors and renderers. | |
23324ae1 | 2349 | */ |
08dd9b5a | 2350 | void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer); |
23324ae1 FM |
2351 | |
2352 | //@{ | |
2353 | /** | |
08dd9b5a | 2354 | Sets the text colour for the given cell or all cells by default. |
23324ae1 FM |
2355 | */ |
2356 | void SetCellTextColour(int row, int col, const wxColour& colour); | |
7c913512 FM |
2357 | void SetCellTextColour(const wxColour& val, int row, int col); |
2358 | void SetCellTextColour(const wxColour& colour); | |
23324ae1 FM |
2359 | //@} |
2360 | ||
2361 | //@{ | |
2362 | /** | |
08dd9b5a VZ |
2363 | Sets the string value for the cell at the specified location. |
2364 | ||
2365 | For simple applications where a grid object automatically uses a | |
2366 | default grid table of string values you use this function together with | |
2367 | GetCellValue() to access cell values. For more complex applications | |
2368 | where you have derived your own grid table class that contains various | |
2369 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2370 | you only use this function for those cells that contain string values. | |
23324ae1 | 2371 | The last form is for backward compatibility only. |
08dd9b5a VZ |
2372 | |
2373 | See wxGridTableBase::CanSetValueAs and the @ref overview_gridoverview | |
2374 | "wxGrid overview" for more information. | |
23324ae1 FM |
2375 | */ |
2376 | void SetCellValue(int row, int col, const wxString& s); | |
08dd9b5a | 2377 | void SetCellValue(const wxGridCellCoords& coords, const wxString& s); |
7c913512 | 2378 | void SetCellValue(const wxString& val, int row, int col); |
23324ae1 FM |
2379 | //@} |
2380 | ||
2381 | /** | |
2382 | Sets the cell attributes for all cells in the specified column. | |
08dd9b5a | 2383 | |
23324ae1 | 2384 | For more information about controlling grid cell attributes see the |
08dd9b5a | 2385 | wxGridCellAttr cell attribute class and the @ref overview_gridoverview. |
23324ae1 FM |
2386 | */ |
2387 | void SetColAttr(int col, wxGridCellAttr* attr); | |
2388 | ||
2389 | /** | |
08dd9b5a VZ |
2390 | Sets the specified column to display boolean values. |
2391 | ||
2392 | @see SetColFormatCustom() | |
23324ae1 FM |
2393 | */ |
2394 | void SetColFormatBool(int col); | |
2395 | ||
2396 | /** | |
2397 | Sets the specified column to display data in a custom format. | |
08dd9b5a VZ |
2398 | |
2399 | This method provides an alternative to defining a custom grid table | |
2400 | which would return @a typeName from its GetTypeName() method for the | |
2401 | cells in this column: while it doesn't really change the type of the | |
2402 | cells in this column, it does associate the renderer and editor used | |
2403 | for the cells of the specified type with them. | |
2404 | ||
2405 | See the @ref overview_gridoverview "wxGrid overview" for more | |
2406 | information on working with custom data types. | |
23324ae1 FM |
2407 | */ |
2408 | void SetColFormatCustom(int col, const wxString& typeName); | |
2409 | ||
2410 | /** | |
08dd9b5a VZ |
2411 | Sets the specified column to display floating point values with the |
2412 | given width and precision. | |
2413 | ||
2414 | @see SetColFormatCustom() | |
23324ae1 | 2415 | */ |
08dd9b5a | 2416 | void SetColFormatFloat(int col, int width = -1, int precision = -1); |
23324ae1 FM |
2417 | |
2418 | /** | |
2419 | Sets the specified column to display integer values. | |
08dd9b5a VZ |
2420 | |
2421 | @see SetColFormatCustom() | |
23324ae1 FM |
2422 | */ |
2423 | void SetColFormatNumber(int col); | |
2424 | ||
2425 | /** | |
2426 | Sets the horizontal and vertical alignment of column label text. | |
08dd9b5a VZ |
2427 | |
2428 | Horizontal alignment should be one of @c wxALIGN_LEFT, @c | |
2429 | wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2430 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2431 | or @c wxALIGN_BOTTOM. | |
23324ae1 FM |
2432 | */ |
2433 | void SetColLabelAlignment(int horiz, int vert); | |
2434 | ||
2435 | /** | |
2436 | Sets the height of the column labels. | |
08dd9b5a | 2437 | |
4cc4bfaf | 2438 | If @a height equals to @c wxGRID_AUTOSIZE then height is calculated |
08dd9b5a VZ |
2439 | automatically so that no label is truncated. Note that this could be |
2440 | slow for a large table. | |
23324ae1 FM |
2441 | */ |
2442 | void SetColLabelSize(int height); | |
2443 | ||
2444 | /** | |
08dd9b5a VZ |
2445 | Set the value for the given column label. |
2446 | ||
2447 | If you are using a custom grid table you must override | |
2448 | wxGridTableBase::SetColLabelValue for this to have any effect. | |
23324ae1 FM |
2449 | */ |
2450 | void SetColLabelValue(int col, const wxString& value); | |
2451 | ||
2452 | /** | |
08dd9b5a VZ |
2453 | Sets the minimal width to which the user can resize columns. |
2454 | ||
2455 | @see GetColMinimalAcceptableWidth() | |
23324ae1 FM |
2456 | */ |
2457 | void SetColMinimalAcceptableWidth(int width); | |
2458 | ||
2459 | /** | |
08dd9b5a VZ |
2460 | Sets the minimal width for the specified column. |
2461 | ||
2462 | It is usually best to call this method during grid creation as calling | |
2463 | it later will not resize the column to the given minimal width even if | |
2464 | it is currently narrower than it. | |
2465 | ||
2466 | @a width must be greater than the minimal acceptable column width as | |
2467 | returned by GetColMinimalAcceptableWidth(). | |
23324ae1 FM |
2468 | */ |
2469 | void SetColMinimalWidth(int col, int width); | |
2470 | ||
2471 | /** | |
2472 | Sets the position of the specified column. | |
2473 | */ | |
2474 | void SetColPos(int colID, int newPos); | |
2475 | ||
2476 | /** | |
2477 | Sets the width of the specified column. | |
08dd9b5a VZ |
2478 | |
2479 | Notice that this function does not refresh the grid, you need to call | |
2480 | ForceRefresh() to make the changes take effect immediately. | |
2481 | ||
2482 | @param col | |
2483 | The column index. | |
2484 | @param width | |
2485 | The new column width in pixels or a negative value to fit the | |
2486 | column width to its label width. | |
23324ae1 FM |
2487 | */ |
2488 | void SetColSize(int col, int width); | |
2489 | ||
2490 | /** | |
2491 | Sets the default horizontal and vertical alignment for grid cell text. | |
08dd9b5a VZ |
2492 | |
2493 | Horizontal alignment should be one of @c wxALIGN_LEFT, @c | |
2494 | wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2495 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2496 | or @c wxALIGN_BOTTOM. | |
23324ae1 FM |
2497 | */ |
2498 | void SetDefaultCellAlignment(int horiz, int vert); | |
2499 | ||
2500 | /** | |
2501 | Sets the default background colour for grid cells. | |
2502 | */ | |
2503 | void SetDefaultCellBackgroundColour(const wxColour& colour); | |
2504 | ||
2505 | /** | |
2506 | Sets the default font to be used for grid cell text. | |
2507 | */ | |
2508 | void SetDefaultCellFont(const wxFont& font); | |
2509 | ||
2510 | /** | |
2511 | Sets the current default colour for grid cell text. | |
2512 | */ | |
2513 | void SetDefaultCellTextColour(const wxColour& colour); | |
2514 | ||
2515 | /** | |
08dd9b5a VZ |
2516 | Sets the default width for columns in the grid. |
2517 | ||
2518 | This will only affect columns subsequently added to the grid unless | |
2519 | @a resizeExistingCols is @true. | |
2520 | ||
2521 | If @a width is less than GetColMinimalAcceptableWidth(), then the | |
2522 | minimal acceptable width is used instead of it. | |
23324ae1 | 2523 | */ |
08dd9b5a | 2524 | void SetDefaultColSize(int width, bool resizeExistingCols = false); |
23324ae1 FM |
2525 | |
2526 | /** | |
08dd9b5a VZ |
2527 | Sets the default editor for grid cells. |
2528 | ||
2529 | The grid will take ownership of the pointer. | |
2530 | ||
2531 | See wxGridCellEditor and the @ref overview_gridoverview "wxGrid | |
2532 | overview" for more information about cell editors and renderers. | |
23324ae1 FM |
2533 | */ |
2534 | void SetDefaultEditor(wxGridCellEditor* editor); | |
2535 | ||
2536 | /** | |
08dd9b5a VZ |
2537 | Sets the default renderer for grid cells. |
2538 | ||
2539 | The grid will take ownership of the pointer. | |
2540 | ||
2541 | See wxGridCellRenderer and the @ref overview_gridoverview "wxGrid | |
2542 | overview" for more information about cell editors and renderers. | |
23324ae1 FM |
2543 | */ |
2544 | void SetDefaultRenderer(wxGridCellRenderer* renderer); | |
2545 | ||
2546 | /** | |
08dd9b5a VZ |
2547 | Sets the default height for rows in the grid. |
2548 | ||
2549 | This will only affect rows subsequently added to the grid unless | |
2550 | @a resizeExistingRows is @true. | |
2551 | ||
2552 | If @a height is less than GetRowMinimalAcceptableHeight(), then the | |
2553 | minimal acceptable heihgt is used instead of it. | |
23324ae1 | 2554 | */ |
08dd9b5a | 2555 | void SetDefaultRowSize(int height, bool resizeExistingRows = false); |
23324ae1 FM |
2556 | |
2557 | /** | |
2558 | Set the grid cursor to the specified cell. | |
08dd9b5a | 2559 | |
23324ae1 FM |
2560 | This function calls MakeCellVisible(). |
2561 | */ | |
2562 | void SetGridCursor(int row, int col); | |
2563 | ||
2564 | /** | |
2565 | Sets the colour used to draw grid lines. | |
2566 | */ | |
2567 | void SetGridLineColour(const wxColour& colour); | |
2568 | ||
2569 | /** | |
2570 | Sets the background colour for row and column labels. | |
2571 | */ | |
2572 | void SetLabelBackgroundColour(const wxColour& colour); | |
2573 | ||
2574 | /** | |
2575 | Sets the font for row and column labels. | |
2576 | */ | |
2577 | void SetLabelFont(const wxFont& font); | |
2578 | ||
2579 | /** | |
2580 | Sets the colour for row and column label text. | |
2581 | */ | |
2582 | void SetLabelTextColour(const wxColour& colour); | |
2583 | ||
2584 | /** | |
08dd9b5a | 2585 | Sets the extra margins used around the grid area. |
23324ae1 | 2586 | |
08dd9b5a VZ |
2587 | A grid may occupy more space than needed for its data display and |
2588 | this function allows to set how big this extra space is | |
23324ae1 | 2589 | */ |
08dd9b5a | 2590 | void SetMargins(int extraWidth, int extraHeight); |
23324ae1 FM |
2591 | |
2592 | /** | |
2593 | Makes the cell at the specified location read-only or editable. | |
08dd9b5a VZ |
2594 | |
2595 | @see IsReadOnly() | |
23324ae1 | 2596 | */ |
4cc4bfaf | 2597 | void SetReadOnly(int row, int col, bool isReadOnly = true); |
23324ae1 FM |
2598 | |
2599 | /** | |
2600 | Sets the cell attributes for all cells in the specified row. | |
08dd9b5a VZ |
2601 | |
2602 | The grid takes ownership of the attribute pointer. | |
2603 | ||
2604 | See the wxGridCellAttr class for more information about controlling | |
2605 | cell attributes. | |
23324ae1 FM |
2606 | */ |
2607 | void SetRowAttr(int row, wxGridCellAttr* attr); | |
2608 | ||
2609 | /** | |
2610 | Sets the horizontal and vertical alignment of row label text. | |
08dd9b5a VZ |
2611 | |
2612 | Horizontal alignment should be one of @c wxALIGN_LEFT, @c | |
2613 | wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2614 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2615 | or @c wxALIGN_BOTTOM. | |
23324ae1 FM |
2616 | */ |
2617 | void SetRowLabelAlignment(int horiz, int vert); | |
2618 | ||
2619 | /** | |
2620 | Sets the width of the row labels. | |
08dd9b5a VZ |
2621 | |
2622 | If @a width equals @c wxGRID_AUTOSIZE then width is calculated | |
2623 | automatically so that no label is truncated. Note that this could be | |
2624 | slow for a large table. | |
23324ae1 FM |
2625 | */ |
2626 | void SetRowLabelSize(int width); | |
2627 | ||
2628 | /** | |
08dd9b5a VZ |
2629 | Sets the value for the given row label. |
2630 | ||
2631 | If you are using a derived grid table you must override | |
2632 | wxGridTableBase::SetRowLabelValue for this to have any effect. | |
23324ae1 FM |
2633 | */ |
2634 | void SetRowLabelValue(int row, const wxString& value); | |
2635 | ||
2636 | /** | |
08dd9b5a VZ |
2637 | Sets the minimal row height used by default. |
2638 | ||
2639 | See SetColMinimalAcceptableWidth() for more information. | |
23324ae1 FM |
2640 | */ |
2641 | void SetRowMinimalAcceptableHeight(int height); | |
2642 | ||
2643 | /** | |
08dd9b5a VZ |
2644 | Sets the minimal height for the specified row. |
2645 | ||
2646 | See SetColMinimalWidth() for more information. | |
23324ae1 FM |
2647 | */ |
2648 | void SetRowMinimalHeight(int row, int height); | |
2649 | ||
2650 | /** | |
2651 | Sets the height of the specified row. | |
08dd9b5a VZ |
2652 | |
2653 | See SetColSize() for more information. | |
23324ae1 FM |
2654 | */ |
2655 | void SetRowSize(int row, int height); | |
2656 | ||
2657 | /** | |
08dd9b5a VZ |
2658 | Sets the number of pixels per horizontal scroll increment. |
2659 | ||
2660 | The default is 15. | |
3c4f71cc | 2661 | |
4cc4bfaf | 2662 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY() |
23324ae1 FM |
2663 | */ |
2664 | void SetScrollLineX(int x); | |
2665 | ||
2666 | /** | |
08dd9b5a VZ |
2667 | Sets the number of pixels per vertical scroll increment. |
2668 | ||
2669 | The default is 15. | |
3c4f71cc | 2670 | |
4cc4bfaf | 2671 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX() |
23324ae1 FM |
2672 | */ |
2673 | void SetScrollLineY(int y); | |
2674 | ||
2675 | /** | |
08dd9b5a | 2676 | Set the colour to be used for drawing the selection background. |
23324ae1 FM |
2677 | */ |
2678 | void SetSelectionBackground(const wxColour& c); | |
2679 | ||
2680 | /** | |
08dd9b5a | 2681 | Set the colour to be used for drawing the selection foreground. |
23324ae1 FM |
2682 | */ |
2683 | void SetSelectionForeground(const wxColour& c); | |
2684 | ||
2685 | /** | |
2686 | Set the selection behaviour of the grid. | |
3c4f71cc | 2687 | |
55f0bf1f VZ |
2688 | The existing selection is converted to conform to the new mode if |
2689 | possible and discarded otherwise (e.g. any individual selected cells | |
2690 | are deselected if the new mode allows only the selection of the entire | |
2691 | rows or columns). | |
23324ae1 | 2692 | */ |
55f0bf1f | 2693 | void SetSelectionMode(wxGridSelectionModes selmode); |
23324ae1 FM |
2694 | |
2695 | /** | |
08dd9b5a VZ |
2696 | Passes a pointer to a custom grid table to be used by the grid. |
2697 | ||
2698 | This should be called after the grid constructor and before using the | |
2699 | grid object. If @a takeOwnership is set to @true then the table will be | |
2700 | deleted by the wxGrid destructor. | |
2701 | ||
2702 | Use this function instead of CreateGrid() when your application | |
2703 | involves complex or non-string data or data sets that are too large to | |
2704 | fit wholly in memory. | |
23324ae1 | 2705 | */ |
55f0bf1f VZ |
2706 | bool SetTable(wxGridTableBase* table, |
2707 | bool takeOwnership = false, | |
2708 | wxGridSelectionModes selmode = wxGridSelectCells); | |
23324ae1 FM |
2709 | |
2710 | /** | |
2711 | Call this in order to make the column labels use a native look by using | |
55f0bf1f VZ |
2712 | wxRenderer::DrawHeaderButton internally. |
2713 | ||
2714 | There is no equivalent method for drawing row columns as there is not | |
2715 | native look for that. This option is useful when using wxGrid for | |
2716 | displaying tables and not as a spread-sheet. | |
23324ae1 | 2717 | */ |
4cc4bfaf | 2718 | void SetUseNativeColLabels(bool native = true); |
23324ae1 FM |
2719 | |
2720 | /** | |
2721 | Displays the in-place cell edit control for the current cell. | |
2722 | */ | |
2723 | void ShowCellEditControl(); | |
2724 | ||
2725 | /** | |
08dd9b5a VZ |
2726 | Returns the column at the given pixel position. |
2727 | ||
7c913512 | 2728 | @param x |
4cc4bfaf | 2729 | The x position to evaluate. |
7c913512 | 2730 | @param clipToMinMax |
08dd9b5a VZ |
2731 | If @true, rather than returning wxNOT_FOUND, it returns either the |
2732 | first or last column depending on whether x is too far to the left | |
2733 | or right respectively. | |
2734 | @return | |
2735 | The column index or wxNOT_FOUND. | |
23324ae1 | 2736 | */ |
328f5751 | 2737 | int XToCol(int x, bool clipToMinMax = false) const; |
23324ae1 FM |
2738 | |
2739 | /** | |
08dd9b5a VZ |
2740 | Returns the column whose right hand edge is close to the given logical |
2741 | x position. | |
2742 | ||
23324ae1 FM |
2743 | If no column edge is near to this position @c wxNOT_FOUND is returned. |
2744 | */ | |
328f5751 | 2745 | int XToEdgeOfCol(int x) const; |
23324ae1 FM |
2746 | |
2747 | /** | |
08dd9b5a VZ |
2748 | Returns the row whose bottom edge is close to the given logical y |
2749 | position. | |
2750 | ||
23324ae1 FM |
2751 | If no row edge is near to this position @c wxNOT_FOUND is returned. |
2752 | */ | |
328f5751 | 2753 | int YToEdgeOfRow(int y) const; |
23324ae1 FM |
2754 | |
2755 | /** | |
08dd9b5a VZ |
2756 | Returns the grid row that corresponds to the logical y coordinate. |
2757 | ||
2758 | Returns @c wxNOT_FOUND if there is no row at the y position. | |
23324ae1 | 2759 | */ |
328f5751 | 2760 | int YToRow(int y) const; |
23324ae1 FM |
2761 | }; |
2762 | ||
2763 | ||
e54c96f1 | 2764 | |
23324ae1 FM |
2765 | /** |
2766 | @class wxGridCellBoolEditor | |
7c913512 | 2767 | |
23324ae1 | 2768 | The editor for boolean data. |
7c913512 | 2769 | |
23324ae1 | 2770 | @library{wxadv} |
42b5841f | 2771 | @category{grid} |
7c913512 | 2772 | |
e54c96f1 | 2773 | @see wxGridCellEditor, wxGridCellFloatEditor, wxGridCellNumberEditor, |
23324ae1 FM |
2774 | wxGridCellTextEditor, wxGridCellChoiceEditor |
2775 | */ | |
2776 | class wxGridCellBoolEditor : public wxGridCellEditor | |
2777 | { | |
2778 | public: | |
2779 | /** | |
2780 | Default constructor. | |
2781 | */ | |
2782 | wxGridCellBoolEditor(); | |
2783 | ||
2784 | /** | |
4cc4bfaf | 2785 | Returns @true if the given @a value is equal to the string representation of |
7c913512 | 2786 | the truth value we currently use (see |
23324ae1 FM |
2787 | wxGridCellBoolEditor::UseStringValues). |
2788 | */ | |
2789 | static bool IsTrueValue(const wxString& value); | |
2790 | ||
2791 | /** | |
328f5751 | 2792 | , wxString&@e valueFalse = _T("")) |
23324ae1 FM |
2793 | This method allows to customize the values returned by GetValue() method for |
2794 | the cell using this editor. By default, the default values of the arguments are | |
2795 | used, i.e. @c "1" is returned if the cell is checked and an empty string | |
2796 | otherwise, using this method allows to change this. | |
2797 | */ | |
328f5751 | 2798 | static void UseStringValues() const; |
23324ae1 FM |
2799 | }; |
2800 | ||
2801 | ||
e54c96f1 | 2802 | |
23324ae1 FM |
2803 | /** |
2804 | @class wxGridUpdateLocker | |
7c913512 | 2805 | |
23324ae1 FM |
2806 | This small class can be used to prevent wxGrid from redrawing |
2807 | during its lifetime by calling wxGrid::BeginBatch | |
2808 | in its constructor and wxGrid::EndBatch in its | |
2809 | destructor. It is typically used in a function performing several operations | |
2810 | with a grid which would otherwise result in flicker. For example: | |
7c913512 | 2811 | |
23324ae1 FM |
2812 | @code |
2813 | void MyFrame::Foo() | |
2814 | { | |
2815 | m_grid = new wxGrid(this, ...); | |
7c913512 | 2816 | |
23324ae1 FM |
2817 | wxGridUpdateLocker noUpdates(m_grid); |
2818 | m_grid-AppendColumn(); | |
2819 | ... many other operations with m_grid... | |
2820 | m_grid-AppendRow(); | |
7c913512 | 2821 | |
23324ae1 FM |
2822 | // destructor called, grid refreshed |
2823 | } | |
2824 | @endcode | |
7c913512 FM |
2825 | |
2826 | Using this class is easier and safer than calling | |
23324ae1 FM |
2827 | wxGrid::BeginBatch and wxGrid::EndBatch |
2828 | because you don't risk not to call the latter (due to an exception for example). | |
7c913512 | 2829 | |
23324ae1 | 2830 | @library{wxadv} |
42b5841f | 2831 | @category{grid} |
23324ae1 | 2832 | */ |
7c913512 | 2833 | class wxGridUpdateLocker |
23324ae1 FM |
2834 | { |
2835 | public: | |
2836 | /** | |
2837 | Creates an object preventing the updates of the specified @e grid. The | |
4cc4bfaf | 2838 | parameter could be @NULL in which case nothing is done. If @a grid is |
23324ae1 FM |
2839 | non-@NULL then the grid must exist for longer than wxGridUpdateLocker object |
2840 | itself. | |
7c913512 | 2841 | The default constructor could be followed by a call to |
23324ae1 FM |
2842 | Create() to set the |
2843 | grid object later. | |
2844 | */ | |
4cc4bfaf | 2845 | wxGridUpdateLocker(wxGrid* grid = NULL); |
23324ae1 FM |
2846 | |
2847 | /** | |
2848 | Destructor reenables updates for the grid this object is associated with. | |
2849 | */ | |
2850 | ~wxGridUpdateLocker(); | |
2851 | ||
2852 | /** | |
2853 | This method can be called if the object had been constructed using the default | |
2854 | constructor. It must not be called more than once. | |
2855 | */ | |
2856 | void Create(wxGrid* grid); | |
2857 | }; | |
e54c96f1 | 2858 |