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