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