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