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