]>
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 | ||
db890987 VZ |
21 | @see wxGridCellAutoWrapStringRenderer, wxGridCellBoolRenderer, |
22 | wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, | |
23 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
24 | wxGridCellStringRenderer | |
8b9ef005 BP |
25 | */ |
26 | class wxGridCellRenderer | |
27 | { | |
28 | public: | |
29 | /** | |
30 | This function must be implemented in derived classes to return a copy | |
31 | of itself. | |
32 | */ | |
33 | virtual wxGridCellRenderer* Clone() const = 0; | |
34 | ||
35 | /** | |
36 | Draw the given cell on the provided DC inside the given rectangle using | |
37 | the style specified by the attribute and the default or selected state | |
38 | corresponding to the isSelected value. | |
39 | ||
40 | This pure virtual function has a default implementation which will | |
41 | prepare the DC using the given attribute: it will draw the rectangle | |
42 | with the background colour from attr and set the text colour and font. | |
43 | */ | |
44 | virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
45 | const wxRect& rect, int row, int col, | |
46 | bool isSelected) = 0; | |
47 | ||
48 | /** | |
49 | Get the preferred size of the cell for its contents. | |
50 | */ | |
51 | virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, | |
52 | int row, int col) = 0; | |
53 | }; | |
54 | ||
db890987 VZ |
55 | /** |
56 | @class wxGridCellAutoWrapStringRenderer | |
57 | ||
58 | This class may be used to format string data in a cell. The too | |
59 | long lines are wrapped to be shown entirely at word boundaries. | |
60 | ||
61 | @library{wxadv} | |
62 | @category{grid} | |
63 | ||
64 | @see wxGridCellRenderer, wxGridCellBoolRenderer, | |
65 | wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, | |
66 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
67 | wxGridCellStringRenderer | |
68 | */ | |
69 | ||
70 | class wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer | |
71 | { | |
72 | public: | |
73 | /** | |
74 | Default constructor. | |
75 | */ | |
76 | wxGridCellAutoWrapStringRenderer(); | |
77 | }; | |
78 | ||
79 | ||
8b9ef005 BP |
80 | /** |
81 | @class wxGridCellBoolRenderer | |
82 | ||
83 | This class may be used to format boolean data in a cell. | |
84 | ||
85 | @library{wxadv} | |
86 | @category{grid} | |
87 | ||
db890987 VZ |
88 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, |
89 | wxGridCellDateTimeRenderer, wxGridCellEnumRenderer, | |
90 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
8b9ef005 BP |
91 | wxGridCellStringRenderer |
92 | */ | |
93 | class wxGridCellBoolRenderer : public wxGridCellRenderer | |
94 | { | |
95 | public: | |
96 | /** | |
97 | Default constructor. | |
98 | */ | |
99 | wxGridCellBoolRenderer(); | |
100 | }; | |
101 | ||
db890987 VZ |
102 | /** |
103 | @class wxGridCellDateTimeRenderer | |
104 | ||
105 | This class may be used to format a date/time data in a cell. | |
106 | The class wxDateTime is used internally to display the local date/time | |
107 | or to parse the string date entered in the cell thanks to the defined format. | |
108 | ||
109 | @library{wxadv} | |
110 | @category{grid} | |
111 | ||
112 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, | |
113 | wxGridCellBoolRenderer, wxGridCellEnumRenderer, | |
114 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
115 | wxGridCellStringRenderer | |
116 | */ | |
117 | class wxGridCellDateTimeRenderer : public wxGridCellStringRenderer | |
118 | { | |
119 | public: | |
120 | /** | |
121 | Date/time renderer constructor. | |
122 | ||
123 | @param outformat | |
124 | strptime()-like format string used the parse the output date/time. | |
125 | @param informat | |
126 | strptime()-like format string used to parse the string entered in the cell. | |
127 | */ | |
128 | wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat, | |
129 | const wxString& informat = wxDefaultDateTimeFormat); | |
130 | ||
131 | ||
132 | /** | |
133 | Sets the strptime()-like format string which will be used to parse | |
134 | the date/time. | |
135 | ||
136 | @param params | |
137 | strptime()-like format string used to parse the date/time. | |
138 | */ | |
139 | virtual void SetParameters(const wxString& params); | |
140 | }; | |
141 | ||
142 | /** | |
143 | @class wxGridCellEnumRenderer | |
144 | ||
145 | This class may be used to render in a cell a number as a textual | |
146 | equivalent. | |
147 | ||
148 | The corresponding text strings are specified as comma-separated items in | |
149 | the string passed to this renderer ctor or SetParameters() method. For | |
150 | example, if this string is @c "John,Fred,Bob" the cell will be rendered as | |
151 | "John", "Fred" or "Bob" if its contents is 0, 1 or 2 respectively. | |
152 | ||
153 | @library{wxadv} | |
154 | @category{grid} | |
155 | ||
156 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, | |
157 | wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, | |
158 | wxGridCellFloatRenderer, wxGridCellNumberRenderer, | |
159 | wxGridCellStringRenderer | |
160 | */ | |
161 | class wxGridCellEnumRenderer : public wxGridCellStringRenderer | |
162 | { | |
163 | public: | |
164 | /** | |
165 | Enum renderer ctor. | |
166 | ||
167 | @param choices | |
168 | Comma separated string parameters "item1[,item2[...,itemN]]". | |
169 | */ | |
170 | wxGridCellEnumRenderer( const wxString& choices = wxEmptyString ); | |
171 | ||
172 | /** | |
173 | Sets the comma separated string content of the enum. | |
174 | ||
175 | @param params | |
176 | Comma separated string parameters "item1[,item2[...,itemN]]". | |
177 | */ | |
178 | virtual void SetParameters(const wxString& params); | |
179 | }; | |
180 | ||
23324ae1 FM |
181 | /** |
182 | @class wxGridCellFloatRenderer | |
7c913512 | 183 | |
23324ae1 | 184 | This class may be used to format floating point data in a cell. |
7c913512 | 185 | |
23324ae1 | 186 | @library{wxadv} |
42b5841f | 187 | @category{grid} |
7c913512 | 188 | |
db890987 VZ |
189 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, |
190 | wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, | |
191 | wxGridCellEnumRenderer, wxGridCellNumberRenderer, | |
afe0e400 | 192 | wxGridCellStringRenderer |
23324ae1 FM |
193 | */ |
194 | class wxGridCellFloatRenderer : public wxGridCellStringRenderer | |
195 | { | |
196 | public: | |
197 | /** | |
db890987 VZ |
198 | Float cell renderer ctor. |
199 | ||
7c913512 | 200 | @param width |
4cc4bfaf | 201 | Minimum number of characters to be shown. |
7c913512 | 202 | @param precision |
4cc4bfaf | 203 | Number of digits after the decimal dot. |
23324ae1 FM |
204 | */ |
205 | wxGridCellFloatRenderer(int width = -1, int precision = -1); | |
206 | ||
207 | /** | |
42b5841f | 208 | Returns the precision. |
23324ae1 | 209 | */ |
328f5751 | 210 | int GetPrecision() const; |
23324ae1 FM |
211 | |
212 | /** | |
42b5841f | 213 | Returns the width. |
23324ae1 | 214 | */ |
328f5751 | 215 | int GetWidth() const; |
23324ae1 FM |
216 | |
217 | /** | |
218 | Parameters string format is "width[,precision]". | |
219 | */ | |
adaaa686 | 220 | virtual void SetParameters(const wxString& params); |
23324ae1 FM |
221 | |
222 | /** | |
42b5841f | 223 | Sets the precision. |
23324ae1 FM |
224 | */ |
225 | void SetPrecision(int precision); | |
226 | ||
227 | /** | |
42b5841f | 228 | Sets the width. |
23324ae1 FM |
229 | */ |
230 | void SetWidth(int width); | |
231 | }; | |
232 | ||
23324ae1 | 233 | /** |
8b9ef005 | 234 | @class wxGridCellNumberRenderer |
7c913512 | 235 | |
8b9ef005 | 236 | This class may be used to format integer data in a cell. |
5039f140 | 237 | |
8b9ef005 BP |
238 | @library{wxadv} |
239 | @category{grid} | |
5039f140 | 240 | |
db890987 VZ |
241 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, |
242 | wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, | |
243 | wxGridCellEnumRenderer, wxGridCellFloatRenderer, | |
8b9ef005 BP |
244 | wxGridCellStringRenderer |
245 | */ | |
246 | class wxGridCellNumberRenderer : public wxGridCellStringRenderer | |
247 | { | |
248 | public: | |
249 | /** | |
250 | Default constructor. | |
251 | */ | |
252 | wxGridCellNumberRenderer(); | |
253 | }; | |
5039f140 | 254 | |
8b9ef005 BP |
255 | /** |
256 | @class wxGridCellStringRenderer | |
257 | ||
258 | This class may be used to format string data in a cell; it is the default | |
259 | for string cells. | |
7c913512 | 260 | |
23324ae1 | 261 | @library{wxadv} |
42b5841f | 262 | @category{grid} |
8b9ef005 | 263 | |
db890987 VZ |
264 | @see wxGridCellRenderer, wxGridCellAutoWrapStringRenderer, |
265 | wxGridCellBoolRenderer, wxGridCellDateTimeRenderer, | |
266 | wxGridCellEnumRenderer, wxGridCellFloatRenderer, | |
8b9ef005 | 267 | wxGridCellNumberRenderer |
23324ae1 | 268 | */ |
8b9ef005 | 269 | class wxGridCellStringRenderer : public wxGridCellRenderer |
23324ae1 FM |
270 | { |
271 | public: | |
afe0e400 BP |
272 | /** |
273 | Default constructor. | |
8b9ef005 BP |
274 | */ |
275 | wxGridCellStringRenderer(); | |
276 | }; | |
23324ae1 | 277 | |
3c4f71cc | 278 | |
8b9ef005 BP |
279 | /** |
280 | @class wxGridCellEditor | |
23324ae1 | 281 | |
8b9ef005 BP |
282 | This class is responsible for providing and manipulating the in-place edit |
283 | controls for the grid. Instances of wxGridCellEditor (actually, instances | |
284 | of derived classes since it is an abstract class) can be associated with | |
285 | the cell attributes for individual cells, rows, columns, or even for the | |
286 | entire grid. | |
77d2c45c | 287 | |
8b9ef005 BP |
288 | @library{wxadv} |
289 | @category{grid} | |
3c4f71cc | 290 | |
db890987 VZ |
291 | @see wxGridCellAutoWrapStringEditor, wxGridCellBoolEditor, |
292 | wxGridCellChoiceEditor, wxGridCellEnumEditor, | |
293 | wxGridCellFloatEditor, wxGridCellNumberEditor, | |
294 | wxGridCellTextEditor | |
8b9ef005 BP |
295 | */ |
296 | class wxGridCellEditor | |
297 | { | |
298 | public: | |
77d2c45c | 299 | /** |
8b9ef005 BP |
300 | Default constructor. |
301 | */ | |
302 | wxGridCellEditor(); | |
77d2c45c VZ |
303 | |
304 | /** | |
8b9ef005 | 305 | Fetch the value from the table and prepare the edit control to begin |
763163a8 VZ |
306 | editing. |
307 | ||
308 | This function should save the original value of the grid cell at the | |
309 | given @a row and @a col and show the control allowing the user to | |
310 | change it. | |
311 | ||
312 | @see EndEdit() | |
8b9ef005 BP |
313 | */ |
314 | virtual void BeginEdit(int row, int col, wxGrid* grid) = 0; | |
77d2c45c | 315 | |
8b9ef005 BP |
316 | /** |
317 | Create a new object which is the copy of this one. | |
318 | */ | |
319 | virtual wxGridCellEditor* Clone() const = 0; | |
23324ae1 FM |
320 | |
321 | /** | |
8b9ef005 BP |
322 | Creates the actual edit control. |
323 | */ | |
324 | virtual void Create(wxWindow* parent, wxWindowID id, | |
325 | wxEvtHandler* evtHandler) = 0; | |
3c4f71cc | 326 | |
afe0e400 | 327 | /** |
8b9ef005 BP |
328 | Final cleanup. |
329 | */ | |
330 | virtual void Destroy(); | |
23324ae1 | 331 | |
10a4531d | 332 | /** |
763163a8 | 333 | End editing the cell. |
10a4531d | 334 | |
763163a8 VZ |
335 | This function must check if the current value of the editing control is |
336 | valid and different from the original value (available as @a oldval in | |
337 | its string form and possibly saved internally using its real type by | |
78e78812 VZ |
338 | BeginEdit()). If it isn't, it just returns @false, otherwise it must do |
339 | the following: | |
340 | # Save the new value internally so that ApplyEdit() could apply it. | |
341 | # Fill @a newval (which is never @NULL) with the string | |
342 | representation of the new value. | |
343 | # Return @true | |
344 | ||
345 | Notice that it must @em not modify the grid as the change could still | |
346 | be vetoed. | |
763163a8 VZ |
347 | |
348 | If the user-defined wxEVT_GRID_CELL_CHANGING event handler doesn't veto | |
349 | this change, ApplyEdit() will be called next. | |
8b9ef005 | 350 | */ |
78e78812 VZ |
351 | virtual bool EndEdit(int row, int col, const wxGrid* grid, |
352 | const wxString& oldval, wxString* newval) = 0; | |
10a4531d | 353 | |
763163a8 VZ |
354 | /** |
355 | Effectively save the changes in the grid. | |
356 | ||
357 | This function should save the value of the control in the grid. It is | |
358 | called only after EndEdit() returns @true. | |
359 | */ | |
360 | virtual void ApplyEdit(int row, int col, wxGrid* grid) = 0; | |
361 | ||
afe0e400 | 362 | /** |
8b9ef005 BP |
363 | Some types of controls on some platforms may need some help with the |
364 | Return key. | |
365 | */ | |
366 | virtual void HandleReturn(wxKeyEvent& event); | |
3c4f71cc | 367 | |
afe0e400 | 368 | /** |
8b9ef005 BP |
369 | Returns @true if the edit control has been created. |
370 | */ | |
371 | bool IsCreated(); | |
23324ae1 FM |
372 | |
373 | /** | |
8b9ef005 BP |
374 | Draws the part of the cell not occupied by the control: the base class |
375 | version just fills it with background colour from the attribute. | |
376 | */ | |
377 | virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr* attr); | |
23324ae1 FM |
378 | |
379 | /** | |
8b9ef005 BP |
380 | Reset the value in the control back to its starting value. |
381 | */ | |
382 | virtual void Reset() = 0; | |
3c4f71cc | 383 | |
8b9ef005 BP |
384 | /** |
385 | Size and position the edit control. | |
386 | */ | |
387 | virtual void SetSize(const wxRect& rect); | |
23324ae1 FM |
388 | |
389 | /** | |
8b9ef005 BP |
390 | Show or hide the edit control, use the specified attributes to set |
391 | colours/fonts for it. | |
392 | */ | |
393 | virtual void Show(bool show, wxGridCellAttr* attr = NULL); | |
3c4f71cc | 394 | |
8b9ef005 BP |
395 | /** |
396 | If the editor is enabled by clicking on the cell, this method will be | |
397 | called. | |
398 | */ | |
399 | virtual void StartingClick(); | |
23324ae1 FM |
400 | |
401 | /** | |
8b9ef005 BP |
402 | If the editor is enabled by pressing keys on the grid, this will be |
403 | called to let the editor do something about that first key if desired. | |
404 | */ | |
405 | virtual void StartingKey(wxKeyEvent& event); | |
3c4f71cc | 406 | |
8b9ef005 | 407 | protected: |
23324ae1 FM |
408 | |
409 | /** | |
8b9ef005 BP |
410 | The destructor is private because only DecRef() can delete us. |
411 | */ | |
412 | virtual ~wxGridCellEditor(); | |
413 | }; | |
3c4f71cc | 414 | |
db890987 VZ |
415 | /** |
416 | @class wxGridCellAutoWrapStringEditor | |
417 | ||
418 | Grid cell editor for wrappable string/text data. | |
419 | ||
420 | @library{wxadv} | |
421 | @category{grid} | |
422 | ||
423 | @see wxGridCellEditor, wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
424 | wxGridCellEnumEditor, wxGridCellFloatEditor, | |
425 | wxGridCellNumberEditor, wxGridCellTextEditor | |
426 | */ | |
427 | class wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor | |
428 | { | |
429 | public: | |
430 | wxGridCellAutoWrapStringEditor(); | |
431 | }; | |
432 | ||
8b9ef005 BP |
433 | /** |
434 | @class wxGridCellBoolEditor | |
23324ae1 | 435 | |
8b9ef005 | 436 | Grid cell editor for boolean data. |
23324ae1 | 437 | |
8b9ef005 BP |
438 | @library{wxadv} |
439 | @category{grid} | |
23324ae1 | 440 | |
db890987 VZ |
441 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
442 | wxGridCellChoiceEditor, wxGridCellEnumEditor, | |
443 | wxGridCellFloatEditor, wxGridCellNumberEditor, | |
444 | wxGridCellTextEditor | |
8b9ef005 BP |
445 | */ |
446 | class wxGridCellBoolEditor : public wxGridCellEditor | |
447 | { | |
448 | public: | |
23324ae1 | 449 | /** |
8b9ef005 BP |
450 | Default constructor. |
451 | */ | |
452 | wxGridCellBoolEditor(); | |
5039f140 | 453 | |
8b9ef005 BP |
454 | /** |
455 | Returns @true if the given @a value is equal to the string | |
456 | representation of the truth value we currently use (see | |
457 | UseStringValues()). | |
458 | */ | |
459 | static bool IsTrueValue(const wxString& value); | |
3c4f71cc | 460 | |
23324ae1 | 461 | /** |
8b9ef005 BP |
462 | This method allows you to customize the values returned by GetValue() |
463 | for the cell using this editor. By default, the default values of the | |
464 | arguments are used, i.e. @c "1" is returned if the cell is checked and | |
465 | an empty string otherwise. | |
466 | */ | |
467 | static void UseStringValues(const wxString& valueTrue = "1", | |
57bf907d | 468 | const wxString& valueFalse = wxEmptyString); |
8b9ef005 | 469 | }; |
3c4f71cc | 470 | |
8b9ef005 BP |
471 | /** |
472 | @class wxGridCellChoiceEditor | |
23324ae1 | 473 | |
8b9ef005 BP |
474 | Grid cell editor for string data providing the user a choice from a list of |
475 | strings. | |
5039f140 | 476 | |
8b9ef005 BP |
477 | @library{wxadv} |
478 | @category{grid} | |
23324ae1 | 479 | |
db890987 VZ |
480 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
481 | wxGridCellBoolEditor, wxGridCellEnumEditor, | |
482 | wxGridCellFloatEditor, wxGridCellNumberEditor, | |
483 | wxGridCellTextEditor | |
8b9ef005 BP |
484 | */ |
485 | class wxGridCellChoiceEditor : public wxGridCellEditor | |
486 | { | |
487 | public: | |
23324ae1 | 488 | /** |
db890987 VZ |
489 | Choice cell renderer ctor. |
490 | ||
8b9ef005 BP |
491 | @param count |
492 | Number of strings from which the user can choose. | |
493 | @param choices | |
494 | An array of strings from which the user can choose. | |
495 | @param allowOthers | |
496 | If allowOthers is @true, the user can type a string not in choices | |
497 | array. | |
498 | */ | |
499 | wxGridCellChoiceEditor(size_t count = 0, | |
500 | const wxString choices[] = NULL, | |
501 | bool allowOthers = false); | |
001f1f56 FM |
502 | |
503 | /** | |
504 | Choice cell renderer ctor. | |
505 | ||
506 | @param choices | |
507 | An array of strings from which the user can choose. | |
508 | @param allowOthers | |
509 | If allowOthers is @true, the user can type a string not in choices | |
510 | array. | |
511 | */ | |
8b9ef005 BP |
512 | wxGridCellChoiceEditor(const wxArrayString& choices, |
513 | bool allowOthers = false); | |
23324ae1 FM |
514 | |
515 | /** | |
8b9ef005 BP |
516 | Parameters string format is "item1[,item2[...,itemN]]" |
517 | */ | |
518 | virtual void SetParameters(const wxString& params); | |
519 | }; | |
23324ae1 | 520 | |
db890987 VZ |
521 | /** |
522 | @class wxGridCellEnumEditor | |
523 | ||
524 | Grid cell editor which displays an enum number as a textual equivalent | |
525 | (eg. data in cell is 0,1,2 ... n the cell could be displayed as | |
526 | "John","Fred"..."Bob" in the combo choice box). | |
527 | ||
528 | @library{wxadv} | |
529 | @category{grid} | |
530 | ||
531 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, | |
532 | wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
533 | wxGridCellTextEditor, wxGridCellFloatEditor, | |
534 | wxGridCellNumberEditor | |
535 | */ | |
536 | class wxGridCellEnumEditor : public wxGridCellChoiceEditor | |
537 | { | |
538 | public: | |
539 | /** | |
540 | Enum cell editor ctor. | |
541 | ||
542 | @param choices | |
543 | Comma separated choice parameters "item1[,item2[...,itemN]]". | |
544 | */ | |
545 | wxGridCellEnumEditor( const wxString& choices = wxEmptyString ); | |
546 | }; | |
547 | ||
8b9ef005 BP |
548 | /** |
549 | @class wxGridCellTextEditor | |
3c4f71cc | 550 | |
8b9ef005 | 551 | Grid cell editor for string/text data. |
23324ae1 | 552 | |
8b9ef005 BP |
553 | @library{wxadv} |
554 | @category{grid} | |
afe0e400 | 555 | |
db890987 VZ |
556 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
557 | wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
558 | wxGridCellEnumEditor, wxGridCellFloatEditor, | |
559 | wxGridCellNumberEditor | |
8b9ef005 BP |
560 | */ |
561 | class wxGridCellTextEditor : public wxGridCellEditor | |
562 | { | |
563 | public: | |
23324ae1 | 564 | /** |
8b9ef005 BP |
565 | Default constructor. |
566 | */ | |
567 | wxGridCellTextEditor(); | |
23324ae1 FM |
568 | |
569 | /** | |
8b9ef005 BP |
570 | The parameters string format is "n" where n is a number representing |
571 | the maximum width. | |
572 | */ | |
573 | virtual void SetParameters(const wxString& params); | |
574 | }; | |
5039f140 | 575 | |
8b9ef005 BP |
576 | /** |
577 | @class wxGridCellFloatEditor | |
23324ae1 | 578 | |
8b9ef005 | 579 | The editor for floating point numbers data. |
3c4f71cc | 580 | |
8b9ef005 BP |
581 | @library{wxadv} |
582 | @category{grid} | |
23324ae1 | 583 | |
db890987 VZ |
584 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
585 | wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
586 | wxGridCellEnumEditor, wxGridCellNumberEditor, | |
587 | wxGridCellTextEditor | |
8b9ef005 BP |
588 | */ |
589 | class wxGridCellFloatEditor : public wxGridCellTextEditor | |
590 | { | |
591 | public: | |
23324ae1 | 592 | /** |
db890987 VZ |
593 | Float cell editor ctor. |
594 | ||
8b9ef005 BP |
595 | @param width |
596 | Minimum number of characters to be shown. | |
597 | @param precision | |
598 | Number of digits after the decimal dot. | |
599 | */ | |
600 | wxGridCellFloatEditor(int width = -1, int precision = -1); | |
23324ae1 FM |
601 | |
602 | /** | |
8b9ef005 BP |
603 | Parameters string format is "width,precision" |
604 | */ | |
605 | virtual void SetParameters(const wxString& params); | |
606 | }; | |
23324ae1 | 607 | |
8b9ef005 BP |
608 | /** |
609 | @class wxGridCellNumberEditor | |
3c4f71cc | 610 | |
8b9ef005 | 611 | Grid cell editor for numeric integer data. |
5039f140 | 612 | |
8b9ef005 BP |
613 | @library{wxadv} |
614 | @category{grid} | |
23324ae1 | 615 | |
db890987 VZ |
616 | @see wxGridCellEditor, wxGridCellAutoWrapStringEditor, |
617 | wxGridCellBoolEditor, wxGridCellChoiceEditor, | |
618 | wxGridCellEnumEditor, wxGridCellFloatEditor, | |
619 | wxGridCellTextEditor | |
8b9ef005 BP |
620 | */ |
621 | class wxGridCellNumberEditor : public wxGridCellTextEditor | |
622 | { | |
623 | public: | |
23324ae1 | 624 | /** |
8b9ef005 BP |
625 | Allows you to specify the range for acceptable data. Values equal to |
626 | -1 for both @a min and @a max indicate that no range checking should be | |
627 | done. | |
628 | */ | |
629 | wxGridCellNumberEditor(int min = -1, int max = -1); | |
3c4f71cc | 630 | |
23324ae1 | 631 | |
afe0e400 | 632 | /** |
8b9ef005 BP |
633 | Parameters string format is "min,max". |
634 | */ | |
635 | virtual void SetParameters(const wxString& params); | |
636 | ||
637 | protected: | |
3c4f71cc | 638 | |
afe0e400 | 639 | /** |
8b9ef005 BP |
640 | If the return value is @true, the editor uses a wxSpinCtrl to get user |
641 | input, otherwise it uses a wxTextCtrl. | |
642 | */ | |
643 | bool HasRange() const; | |
23324ae1 | 644 | |
afe0e400 | 645 | /** |
8b9ef005 BP |
646 | String representation of the value. |
647 | */ | |
648 | wxString GetString() const; | |
649 | }; | |
23324ae1 | 650 | |
23324ae1 | 651 | |
3c4f71cc | 652 | |
8b9ef005 BP |
653 | /** |
654 | @class wxGridCellAttr | |
23324ae1 | 655 | |
8b9ef005 BP |
656 | This class can be used to alter the cells' appearance in the grid by |
657 | changing their attributes from the defaults. An object of this class may be | |
658 | returned by wxGridTableBase::GetAttr(). | |
5039f140 | 659 | |
8b9ef005 BP |
660 | @library{wxadv} |
661 | @category{grid} | |
662 | */ | |
663 | class wxGridCellAttr | |
664 | { | |
665 | public: | |
62960a2c VZ |
666 | /** |
667 | Kind of the attribute to retrieve. | |
668 | ||
669 | @see wxGridCellAttrProvider::GetAttr(), wxGridTableBase::GetAttr() | |
670 | */ | |
671 | enum wxAttrKind | |
672 | { | |
673 | /// Return the combined effective attribute for the cell. | |
674 | Any, | |
675 | ||
676 | /// Return the attribute explicitly set for this cell. | |
677 | Cell, | |
678 | ||
679 | /// Return the attribute set for this cells row. | |
680 | Row, | |
681 | ||
682 | /// Return the attribute set for this cells column. | |
683 | Col | |
684 | }; | |
685 | ||
afe0e400 | 686 | /** |
8b9ef005 BP |
687 | Default constructor. |
688 | */ | |
ccf39540 | 689 | wxGridCellAttr(wxGridCellAttr* attrDefault = NULL); |
23324ae1 | 690 | /** |
8b9ef005 BP |
691 | Constructor specifying some of the often used attributes. |
692 | */ | |
693 | wxGridCellAttr(const wxColour& colText, const wxColour& colBack, | |
694 | const wxFont& font, int hAlign, int vAlign); | |
5039f140 | 695 | |
afe0e400 | 696 | /** |
8b9ef005 BP |
697 | Creates a new copy of this object. |
698 | */ | |
699 | wxGridCellAttr* Clone() const; | |
23324ae1 FM |
700 | |
701 | /** | |
8b9ef005 BP |
702 | This class is reference counted: it is created with ref count of 1, so |
703 | calling DecRef() once will delete it. Calling IncRef() allows to lock | |
704 | it until the matching DecRef() is called. | |
705 | */ | |
706 | void DecRef(); | |
23324ae1 FM |
707 | |
708 | /** | |
cfbc15ee VZ |
709 | Get the alignment to use for the cell with the given attribute. |
710 | ||
711 | If this attribute doesn't specify any alignment, the default attribute | |
712 | alignment is used (which can be changed using | |
713 | wxGrid::SetDefaultCellAlignment() but is left and top by default). | |
714 | ||
715 | Notice that @a hAlign and @a vAlign values are always overwritten by | |
716 | this function, use GetNonDefaultAlignment() if this is not desirable. | |
717 | ||
718 | @param hAlign | |
719 | Horizontal alignment is returned here if this argument is non-@NULL. | |
720 | It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. | |
721 | @param vAlign | |
722 | Vertical alignment is returned here if this argument is non-@NULL. | |
723 | It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM. | |
8b9ef005 BP |
724 | */ |
725 | void GetAlignment(int* hAlign, int* vAlign) const; | |
23324ae1 FM |
726 | |
727 | /** | |
8b9ef005 BP |
728 | Returns the background colour. |
729 | */ | |
730 | const wxColour& GetBackgroundColour() const; | |
23324ae1 | 731 | |
23324ae1 | 732 | /** |
8b9ef005 BP |
733 | Returns the cell editor. |
734 | */ | |
735 | wxGridCellEditor* GetEditor(const wxGrid* grid, int row, int col) const; | |
23324ae1 FM |
736 | |
737 | /** | |
8b9ef005 BP |
738 | Returns the font. |
739 | */ | |
740 | const wxFont& GetFont() const; | |
23324ae1 | 741 | |
cfbc15ee VZ |
742 | /** |
743 | Get the alignment defined by this attribute. | |
744 | ||
745 | Unlike GetAlignment() this function only modifies @a hAlign and @a | |
746 | vAlign if this attribute does define a non-default alignment. This | |
747 | means that they must be initialized before calling this function and | |
748 | that their values will be preserved unchanged if they are different | |
749 | from wxALIGN_INVALID. | |
750 | ||
751 | For example, the following fragment can be used to use the cell | |
752 | alignment if one is defined but right-align its contents by default | |
753 | (instead of left-aligning it by default) while still using the default | |
754 | vertical alignment: | |
755 | @code | |
756 | int hAlign = wxALIGN_RIGHT, | |
757 | vAlign = wxALIGN_INVALID; | |
758 | attr.GetNonDefaultAlignment(&hAlign, &vAlign); | |
759 | @endcode | |
760 | ||
761 | @since 2.9.1 | |
762 | */ | |
763 | void GetNonDefaultAlignment(int *hAlign, int *vAlign) const; | |
764 | ||
23324ae1 | 765 | /** |
8b9ef005 BP |
766 | Returns the cell renderer. |
767 | */ | |
768 | wxGridCellRenderer* GetRenderer(const wxGrid* grid, int row, int col) const; | |
23324ae1 FM |
769 | |
770 | /** | |
8b9ef005 BP |
771 | Returns the text colour. |
772 | */ | |
773 | const wxColour& GetTextColour() const; | |
5e6e278d FM |
774 | |
775 | /** | |
8b9ef005 BP |
776 | Returns @true if this attribute has a valid alignment set. |
777 | */ | |
778 | bool HasAlignment() const; | |
7c913512 | 779 | |
23324ae1 | 780 | /** |
8b9ef005 | 781 | Returns @true if this attribute has a valid background colour set. |
23324ae1 | 782 | */ |
8b9ef005 | 783 | bool HasBackgroundColour() const; |
23324ae1 | 784 | |
23324ae1 | 785 | /** |
8b9ef005 | 786 | Returns @true if this attribute has a valid cell editor set. |
23324ae1 | 787 | */ |
8b9ef005 | 788 | bool HasEditor() const; |
23324ae1 FM |
789 | |
790 | /** | |
8b9ef005 | 791 | Returns @true if this attribute has a valid font set. |
23324ae1 | 792 | */ |
8b9ef005 | 793 | bool HasFont() const; |
23324ae1 FM |
794 | |
795 | /** | |
8b9ef005 | 796 | Returns @true if this attribute has a valid cell renderer set. |
23324ae1 | 797 | */ |
8b9ef005 | 798 | bool HasRenderer() const; |
23324ae1 FM |
799 | |
800 | /** | |
8b9ef005 | 801 | Returns @true if this attribute has a valid text colour set. |
23324ae1 | 802 | */ |
8b9ef005 | 803 | bool HasTextColour() const; |
23324ae1 FM |
804 | |
805 | /** | |
8b9ef005 BP |
806 | This class is reference counted: it is created with ref count of 1, so |
807 | calling DecRef() once will delete it. Calling IncRef() allows to lock | |
808 | it until the matching DecRef() is called. | |
23324ae1 | 809 | */ |
8b9ef005 | 810 | void IncRef(); |
23324ae1 FM |
811 | |
812 | /** | |
8b9ef005 | 813 | Returns @true if this cell is set as read-only. |
23324ae1 | 814 | */ |
8b9ef005 | 815 | bool IsReadOnly() const; |
23324ae1 FM |
816 | |
817 | /** | |
8b9ef005 BP |
818 | Sets the alignment. @a hAlign can be one of @c wxALIGN_LEFT, |
819 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT and @a vAlign can be one of | |
820 | @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
23324ae1 | 821 | */ |
8b9ef005 | 822 | void SetAlignment(int hAlign, int vAlign); |
23324ae1 FM |
823 | |
824 | /** | |
8b9ef005 | 825 | Sets the background colour. |
23324ae1 | 826 | */ |
8b9ef005 | 827 | void SetBackgroundColour(const wxColour& colBack); |
23324ae1 FM |
828 | |
829 | /** | |
8b9ef005 | 830 | @todo Needs documentation. |
23324ae1 | 831 | */ |
8b9ef005 | 832 | void SetDefAttr(wxGridCellAttr* defAttr); |
23324ae1 FM |
833 | |
834 | /** | |
8b9ef005 | 835 | Sets the editor to be used with the cells with this attribute. |
23324ae1 | 836 | */ |
8b9ef005 | 837 | void SetEditor(wxGridCellEditor* editor); |
23324ae1 FM |
838 | |
839 | /** | |
8b9ef005 | 840 | Sets the font. |
23324ae1 | 841 | */ |
8b9ef005 | 842 | void SetFont(const wxFont& font); |
23324ae1 FM |
843 | |
844 | /** | |
8b9ef005 | 845 | Sets the cell as read-only. |
23324ae1 | 846 | */ |
8b9ef005 | 847 | void SetReadOnly(bool isReadOnly = true); |
23324ae1 FM |
848 | |
849 | /** | |
8b9ef005 BP |
850 | Sets the renderer to be used for cells with this attribute. Takes |
851 | ownership of the pointer. | |
23324ae1 | 852 | */ |
8b9ef005 | 853 | void SetRenderer(wxGridCellRenderer* renderer); |
5e6e278d FM |
854 | |
855 | /** | |
8b9ef005 | 856 | Sets the text colour. |
5e6e278d | 857 | */ |
8b9ef005 | 858 | void SetTextColour(const wxColour& colText); |
23324ae1 FM |
859 | }; |
860 | ||
ba9574c3 VZ |
861 | /** |
862 | Base class for corner window renderer. | |
863 | ||
864 | This is the simplest of all header renderers and only has a single | |
865 | function. | |
866 | ||
867 | @see wxGridCellAttrProvider::GetCornerRenderer() | |
868 | ||
869 | @since 2.9.1 | |
870 | */ | |
871 | class wxGridCornerHeaderRenderer | |
872 | { | |
873 | public: | |
874 | /** | |
875 | Called by the grid to draw the corner window border. | |
876 | ||
877 | This method is responsible for drawing the border inside the given @a | |
878 | rect and adjusting the rectangle size to correspond to the area inside | |
879 | the border, i.e. usually call wxRect::Deflate() to account for the | |
880 | border width. | |
881 | ||
882 | @param grid | |
883 | The grid whose corner window is being drawn. | |
884 | @param dc | |
885 | The device context to use for drawing. | |
886 | @param rect | |
887 | Input/output parameter which contains the border rectangle on input | |
888 | and should be updated to contain the area inside the border on | |
889 | function return. | |
890 | */ | |
891 | virtual void DrawBorder(const wxGrid& grid, | |
892 | wxDC& dc, | |
893 | wxRect& rect) const = 0; | |
894 | }; | |
895 | /** | |
896 | Common base class for row and column headers renderers. | |
897 | ||
898 | @see wxGridColumnHeaderRenderer, wxGridRowHeaderRenderer | |
899 | ||
900 | @since 2.9.1 | |
901 | */ | |
902 | class wxGridHeaderLabelsRenderer : public wxGridCornerHeaderRenderer | |
903 | { | |
904 | public: | |
905 | /** | |
906 | Called by the grid to draw the specified label. | |
907 | ||
908 | Notice that the base class DrawBorder() method is called before this | |
909 | one. | |
910 | ||
911 | The default implementation uses wxGrid::GetLabelTextColour() and | |
912 | wxGrid::GetLabelFont() to draw the label. | |
913 | */ | |
914 | virtual void DrawLabel(const wxGrid& grid, | |
915 | wxDC& dc, | |
916 | const wxString& value, | |
917 | const wxRect& rect, | |
918 | int horizAlign, | |
919 | int vertAlign, | |
920 | int textOrientation) const; | |
921 | }; | |
922 | ||
923 | /** | |
924 | Base class for row headers renderer. | |
925 | ||
926 | This is the same as wxGridHeaderLabelsRenderer currently but we still use a | |
927 | separate class for it to distinguish it from wxGridColumnHeaderRenderer. | |
928 | ||
929 | @see wxGridRowHeaderRendererDefault | |
930 | ||
931 | @see wxGridCellAttrProvider::GetRowHeaderRenderer() | |
932 | ||
933 | @since 2.9.1 | |
934 | */ | |
935 | class wxGridRowHeaderRenderer : public wxGridHeaderLabelsRenderer | |
936 | { | |
937 | }; | |
938 | ||
939 | /** | |
940 | Base class for column headers renderer. | |
941 | ||
942 | This is the same as wxGridHeaderLabelsRenderer currently but we still use a | |
943 | separate class for it to distinguish it from wxGridRowHeaderRenderer. | |
944 | ||
945 | @see wxGridColumnHeaderRendererDefault | |
946 | ||
947 | @see wxGridCellAttrProvider::GetColumnHeaderRenderer() | |
948 | ||
949 | @since 2.9.1 | |
950 | */ | |
951 | class wxGridColumnHeaderRenderer : public wxGridHeaderLabelsRenderer | |
952 | { | |
953 | }; | |
954 | ||
955 | /** | |
956 | Default row header renderer. | |
957 | ||
958 | You may derive from this class if you need to only override one of its | |
959 | methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the | |
960 | default implementation for the other one. | |
961 | ||
962 | @see wxGridColumnHeaderRendererDefault | |
963 | ||
964 | @since 2.9.1 | |
965 | */ | |
163bd4f7 | 966 | class wxGridRowHeaderRendererDefault : public wxGridRowHeaderRenderer |
ba9574c3 VZ |
967 | { |
968 | public: | |
969 | /// Implement border drawing for the row labels. | |
970 | virtual void DrawBorder(const wxGrid& grid, | |
971 | wxDC& dc, | |
972 | wxRect& rect) const; | |
973 | }; | |
974 | ||
975 | /** | |
976 | Default column header renderer. | |
977 | ||
978 | @see wxGridRowHeaderRendererDefault | |
979 | ||
980 | @since 2.9.1 | |
981 | */ | |
982 | class wxGridColumnHeaderRendererDefault : public wxGridColumnHeaderRenderer | |
983 | { | |
984 | public: | |
985 | /// Implement border drawing for the column labels. | |
986 | virtual void DrawBorder(const wxGrid& grid, | |
987 | wxDC& dc, | |
988 | wxRect& rect) const; | |
989 | }; | |
990 | ||
991 | /** | |
992 | Default corner window renderer. | |
993 | ||
994 | @see wxGridColumnHeaderRendererDefault, wxGridRowHeaderRendererDefault | |
995 | ||
996 | @since 2.9.1 | |
997 | */ | |
998 | class wxGridCornerHeaderRendererDefault : public wxGridCornerHeaderRenderer | |
999 | { | |
1000 | public: | |
1001 | /// Implement border drawing for the corner window. | |
1002 | virtual void DrawBorder(const wxGrid& grid, | |
1003 | wxDC& dc, | |
1004 | wxRect& rect) const; | |
1005 | }; | |
1006 | ||
62960a2c VZ |
1007 | /** |
1008 | Class providing attributes to be used for the grid cells. | |
1009 | ||
1010 | This class both defines an interface which grid cell attributes providers | |
1011 | should implement -- and which can be implemented differently in derived | |
1012 | classes -- and a default implementation of this interface which is often | |
1013 | good enough to be used without modification, especially with not very large | |
1014 | grids for which the efficiency of attributes storage hardly matters (see | |
1015 | the discussion below). | |
1016 | ||
1017 | An object of this class can be associated with a wxGrid using | |
1018 | wxGridTableBase::SetAttrProvider() but it's not necessary to call it if you | |
1019 | intend to use the default provider as it is used by wxGridTableBase by | |
1020 | default anyhow. | |
1021 | ||
1022 | Notice that while attributes provided by this class can be set for | |
1023 | individual cells using SetAttr() or the entire rows or columns using | |
1024 | SetRowAttr() and SetColAttr() they are always retrieved using GetAttr() | |
1025 | function. | |
1026 | ||
1027 | ||
1028 | The default implementation of this class stores the attributes passed to | |
1029 | its SetAttr(), SetRowAttr() and SetColAttr() in a straightforward way. A | |
1030 | derived class may use its knowledge about how the attributes are used in | |
1031 | your program to implement it much more efficiently: for example, using a | |
1032 | special background colour for all even-numbered rows can be implemented by | |
1033 | simply returning the same attribute from GetAttr() if the row number is | |
1034 | even instead of having to store N/2 row attributes where N is the total | |
1035 | number of rows in the grid. | |
1036 | ||
1037 | Notice that objects of this class can't be copied. | |
1038 | */ | |
1039 | class wxGridCellAttrProvider : public wxClientDataContainer | |
1040 | { | |
1041 | public: | |
1042 | /// Trivial default constructor. | |
1043 | wxGridCellAttrProvider(); | |
1044 | ||
1045 | /// Destructor releases any attributes held by this class. | |
1046 | virtual ~wxGridCellAttrProvider(); | |
1047 | ||
1048 | /** | |
1049 | Get the attribute to use for the specified cell. | |
1050 | ||
1051 | If wxGridCellAttr::Any is used as @a kind value, this function combines | |
1052 | the attributes set for this cell using SetAttr() and those for its row | |
1053 | or column (set with SetRowAttr() or SetColAttr() respectively), with | |
1054 | the cell attribute having the highest precedence. | |
1055 | ||
1056 | Notice that the caller must call DecRef() on the returned pointer if it | |
1057 | is non-@NULL. | |
1058 | ||
1059 | @param row | |
1060 | The row of the cell. | |
1061 | @param col | |
1062 | The column of the cell. | |
1063 | @param kind | |
1064 | The kind of the attribute to return. | |
1065 | @return | |
1066 | The attribute to use which should be DecRef()'d by caller or @NULL | |
1067 | if no attributes are defined for this cell. | |
1068 | */ | |
1069 | virtual wxGridCellAttr *GetAttr(int row, int col, | |
1070 | wxGridCellAttr::wxAttrKind kind) const; | |
1071 | ||
1072 | /** | |
1073 | Setting attributes. | |
1074 | ||
1075 | All these functions take ownership of the attribute passed to them, | |
1076 | i.e. will call DecRef() on it themselves later and so it should not be | |
1077 | destroyed by the caller. And the attribute can be @NULL to reset a | |
1078 | previously set value. | |
1079 | */ | |
1080 | //@{ | |
1081 | ||
1082 | /// Set attribute for the specified cell. | |
1083 | virtual void SetAttr(wxGridCellAttr *attr, int row, int col); | |
1084 | ||
1085 | /// Set attribute for the specified row. | |
1086 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); | |
1087 | ||
1088 | /// Set attribute for the specified column. | |
1089 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
1090 | ||
1091 | //@} | |
ba9574c3 VZ |
1092 | |
1093 | /** | |
1094 | Getting header renderers. | |
1095 | ||
1096 | These functions return the renderers for the given row or column header | |
1097 | label and the corner window. Unlike cell attributes, these objects are | |
1098 | not reference counted and are never @NULL so they are returned by | |
1099 | reference and not pointer and DecRef() shouldn't (and can't) be called | |
1100 | for them. | |
1101 | ||
1102 | All these functions were added in wxWidgets 2.9.1. | |
1103 | */ | |
1104 | //@{ | |
1105 | ||
1106 | /** | |
1107 | Return the renderer used for drawing column headers. | |
1108 | ||
1109 | By default wxGridColumnHeaderRendererDefault is returned. | |
1110 | ||
1111 | @see wxGrid::SetUseNativeColLabels(), wxGrid::UseNativeColHeader() | |
1112 | ||
1113 | @since 2.9.1 | |
1114 | */ | |
1115 | virtual const wxGridColumnHeaderRenderer& GetColumnHeaderRenderer(int col); | |
1116 | ||
1117 | /** | |
1118 | Return the renderer used for drawing row headers. | |
1119 | ||
1120 | By default wxGridRowHeaderRendererDefault is returned. | |
1121 | ||
1122 | @since 2.9.1 | |
1123 | */ | |
1124 | virtual const wxGridRowHeaderRenderer& GetRowHeaderRenderer(int row); | |
1125 | ||
1126 | /** | |
1127 | Return the renderer used for drawing the corner window. | |
1128 | ||
1129 | By default wxGridCornerHeaderRendererDefault is returned. | |
1130 | ||
1131 | @since 2.9.1 | |
1132 | */ | |
1133 | virtual const wxGridCornerHeaderRenderer& GetCornerRenderer(); | |
1134 | ||
1135 | //@} | |
62960a2c | 1136 | }; |
23324ae1 | 1137 | |
e54c96f1 | 1138 | |
23324ae1 | 1139 | /** |
8b9ef005 | 1140 | @class wxGridTableBase |
7c913512 | 1141 | |
8b9ef005 BP |
1142 | The almost abstract base class for grid tables. |
1143 | ||
1144 | A grid table is responsible for storing the grid data and, indirectly, grid | |
1145 | cell attributes. The data can be stored in the way most convenient for the | |
1146 | application but has to be provided in string form to wxGrid. It is also | |
1147 | possible to provide cells values in other formats if appropriate, e.g. as | |
1148 | numbers. | |
1149 | ||
1150 | This base class is not quite abstract as it implements a trivial strategy | |
1151 | for storing the attributes by forwarding it to wxGridCellAttrProvider and | |
1152 | also provides stubs for some other functions. However it does have a number | |
1153 | of pure virtual methods which must be implemented in the derived classes. | |
1154 | ||
1155 | @see wxGridStringTable | |
7c913512 | 1156 | |
23324ae1 | 1157 | @library{wxadv} |
42b5841f | 1158 | @category{grid} |
23324ae1 | 1159 | */ |
8b9ef005 | 1160 | class wxGridTableBase : public wxObject |
23324ae1 FM |
1161 | { |
1162 | public: | |
1163 | /** | |
1164 | Default constructor. | |
8b9ef005 BP |
1165 | */ |
1166 | wxGridTableBase(); | |
23324ae1 FM |
1167 | |
1168 | /** | |
8b9ef005 BP |
1169 | Destructor frees the attribute provider if it was created. |
1170 | */ | |
1171 | virtual ~wxGridTableBase(); | |
23324ae1 | 1172 | |
8b9ef005 BP |
1173 | /** |
1174 | Must be overridden to return the number of rows in the table. | |
e54c96f1 | 1175 | |
8b9ef005 BP |
1176 | For backwards compatibility reasons, this method is not const. |
1177 | Use GetRowsCount() instead of it in const methods of derived table | |
1178 | classes. | |
1179 | */ | |
1180 | virtual int GetNumberRows() = 0; | |
7c913512 | 1181 | |
8b9ef005 BP |
1182 | /** |
1183 | Must be overridden to return the number of columns in the table. | |
7c913512 | 1184 | |
8b9ef005 BP |
1185 | For backwards compatibility reasons, this method is not const. |
1186 | Use GetColsCount() instead of it in const methods of derived table | |
1187 | classes, | |
1188 | */ | |
1189 | virtual int GetNumberCols() = 0; | |
7c913512 | 1190 | |
23324ae1 | 1191 | /** |
8b9ef005 | 1192 | Return the number of rows in the table. |
23324ae1 | 1193 | |
8b9ef005 BP |
1194 | This method is not virtual and is only provided as a convenience for |
1195 | the derived classes which can't call GetNumberRows() without a | |
1196 | @c const_cast from their const methods. | |
1197 | */ | |
1198 | int GetRowsCount() const; | |
23324ae1 | 1199 | |
8b9ef005 BP |
1200 | /** |
1201 | Return the number of columns in the table. | |
e54c96f1 | 1202 | |
8b9ef005 BP |
1203 | This method is not virtual and is only provided as a convenience for |
1204 | the derived classes which can't call GetNumberCols() without a | |
1205 | @c const_cast from their const methods. | |
1206 | */ | |
1207 | int GetColsCount() const; | |
7c913512 | 1208 | |
7c913512 | 1209 | |
23324ae1 | 1210 | /** |
8b9ef005 BP |
1211 | @name Table Cell Accessors |
1212 | */ | |
1213 | //@{ | |
23324ae1 FM |
1214 | |
1215 | /** | |
8acad210 VZ |
1216 | May be overridden to implement testing for empty cells. |
1217 | ||
1218 | This method is used by the grid to test if the given cell is not used | |
1219 | and so whether a neighbouring cell may overflow into it. By default it | |
1220 | only returns true if the value of the given cell, as returned by | |
1221 | GetValue(), is empty. | |
8b9ef005 | 1222 | */ |
8acad210 | 1223 | virtual bool IsEmptyCell(int row, int col); |
e54c96f1 | 1224 | |
8b9ef005 BP |
1225 | /** |
1226 | Same as IsEmptyCell() but taking wxGridCellCoords. | |
7c913512 | 1227 | |
8b9ef005 BP |
1228 | Notice that this method is not virtual, only IsEmptyCell() should be |
1229 | overridden. | |
1230 | */ | |
1231 | bool IsEmpty(const wxGridCellCoords& coords); | |
7c913512 | 1232 | |
afe0e400 | 1233 | /** |
8b9ef005 BP |
1234 | Must be overridden to implement accessing the table values as text. |
1235 | */ | |
1236 | virtual wxString GetValue(int row, int col) = 0; | |
23324ae1 FM |
1237 | |
1238 | /** | |
8b9ef005 BP |
1239 | Must be overridden to implement setting the table values as text. |
1240 | */ | |
1241 | virtual void SetValue(int row, int col, const wxString& value) = 0; | |
23324ae1 FM |
1242 | |
1243 | /** | |
8b9ef005 | 1244 | Returns the type of the value in the given cell. |
23324ae1 | 1245 | |
8b9ef005 BP |
1246 | By default all cells are strings and this method returns |
1247 | @c wxGRID_VALUE_STRING. | |
1248 | */ | |
1249 | virtual wxString GetTypeName(int row, int col); | |
23324ae1 FM |
1250 | |
1251 | /** | |
8b9ef005 BP |
1252 | Returns true if the value of the given cell can be accessed as if it |
1253 | were of the specified type. | |
23324ae1 | 1254 | |
8b9ef005 BP |
1255 | By default the cells can only be accessed as strings. Note that a cell |
1256 | could be accessible in different ways, e.g. a numeric cell may return | |
1257 | @true for @c wxGRID_VALUE_NUMBER but also for @c wxGRID_VALUE_STRING | |
1258 | indicating that the value can be coerced to a string form. | |
1259 | */ | |
1260 | virtual bool CanGetValueAs(int row, int col, const wxString& typeName); | |
23324ae1 FM |
1261 | |
1262 | /** | |
8b9ef005 BP |
1263 | Returns true if the value of the given cell can be set as if it were of |
1264 | the specified type. | |
23324ae1 | 1265 | |
8b9ef005 BP |
1266 | @see CanGetValueAs() |
1267 | */ | |
1268 | virtual bool CanSetValueAs(int row, int col, const wxString& typeName); | |
e54c96f1 | 1269 | |
8b9ef005 BP |
1270 | /** |
1271 | Returns the value of the given cell as a long. | |
7c913512 | 1272 | |
8b9ef005 BP |
1273 | This should only be called if CanGetValueAs() returns @true when called |
1274 | with @c wxGRID_VALUE_NUMBER argument. Default implementation always | |
1275 | return 0. | |
1276 | */ | |
1277 | virtual long GetValueAsLong(int row, int col); | |
7c913512 | 1278 | |
afe0e400 | 1279 | /** |
8b9ef005 | 1280 | Returns the value of the given cell as a double. |
23324ae1 | 1281 | |
8b9ef005 BP |
1282 | This should only be called if CanGetValueAs() returns @true when called |
1283 | with @c wxGRID_VALUE_FLOAT argument. Default implementation always | |
1284 | return 0.0. | |
1285 | */ | |
1286 | virtual double GetValueAsDouble(int row, int col); | |
23324ae1 FM |
1287 | |
1288 | /** | |
8b9ef005 | 1289 | Returns the value of the given cell as a boolean. |
23324ae1 | 1290 | |
8b9ef005 BP |
1291 | This should only be called if CanGetValueAs() returns @true when called |
1292 | with @c wxGRID_VALUE_BOOL argument. Default implementation always | |
1293 | return false. | |
1294 | */ | |
1295 | virtual bool GetValueAsBool(int row, int col); | |
23324ae1 FM |
1296 | |
1297 | /** | |
8b9ef005 BP |
1298 | Returns the value of the given cell as a user-defined type. |
1299 | ||
1300 | This should only be called if CanGetValueAs() returns @true when called | |
1301 | with @a typeName. Default implementation always return @NULL. | |
1302 | */ | |
1303 | virtual void *GetValueAsCustom(int row, int col, const wxString& typeName); | |
23324ae1 FM |
1304 | |
1305 | /** | |
8b9ef005 BP |
1306 | Sets the value of the given cell as a long. |
1307 | ||
1308 | This should only be called if CanSetValueAs() returns @true when called | |
1309 | with @c wxGRID_VALUE_NUMBER argument. Default implementation doesn't do | |
1310 | anything. | |
1311 | */ | |
1312 | virtual void SetValueAsLong(int row, int col, long value); | |
23324ae1 FM |
1313 | |
1314 | /** | |
8b9ef005 BP |
1315 | Sets the value of the given cell as a double. |
1316 | ||
1317 | This should only be called if CanSetValueAs() returns @true when called | |
1318 | with @c wxGRID_VALUE_FLOAT argument. Default implementation doesn't do | |
1319 | anything. | |
1320 | */ | |
1321 | virtual void SetValueAsDouble(int row, int col, double value); | |
23324ae1 FM |
1322 | |
1323 | /** | |
8b9ef005 BP |
1324 | Sets the value of the given cell as a boolean. |
1325 | ||
1326 | This should only be called if CanSetValueAs() returns @true when called | |
1327 | with @c wxGRID_VALUE_BOOL argument. Default implementation doesn't do | |
1328 | anything. | |
1329 | */ | |
1330 | virtual void SetValueAsBool( int row, int col, bool value ); | |
23324ae1 FM |
1331 | |
1332 | /** | |
8b9ef005 BP |
1333 | Sets the value of the given cell as a user-defined type. |
1334 | ||
1335 | This should only be called if CanSetValueAs() returns @true when called | |
1336 | with @a typeName. Default implementation doesn't do anything. | |
1337 | */ | |
1338 | virtual void SetValueAsCustom(int row, int col, const wxString& typeName, | |
1339 | void *value); | |
1340 | ||
1341 | //@} | |
1342 | ||
23324ae1 FM |
1343 | |
1344 | /** | |
8b9ef005 BP |
1345 | Called by the grid when the table is associated with it. |
1346 | ||
1347 | The default implementation stores the pointer and returns it from its | |
1348 | GetView() and so only makes sense if the table cannot be associated | |
1349 | with more than one grid at a time. | |
1350 | */ | |
1351 | virtual void SetView(wxGrid *grid); | |
23324ae1 FM |
1352 | |
1353 | /** | |
8b9ef005 BP |
1354 | Returns the last grid passed to SetView(). |
1355 | */ | |
1356 | virtual wxGrid *GetView() const; | |
1357 | ||
23324ae1 FM |
1358 | |
1359 | /** | |
8b9ef005 | 1360 | @name Table Structure Modifiers |
23324ae1 | 1361 | |
8b9ef005 BP |
1362 | Notice that none of these functions are pure virtual as they don't have |
1363 | to be implemented if the table structure is never modified after | |
1364 | creation, i.e. neither rows nor columns are never added or deleted but | |
1365 | that you do need to implement them if they are called, i.e. if your | |
1366 | code either calls them directly or uses the matching wxGrid methods, as | |
1367 | by default they simply do nothing which is definitely inappropriate. | |
1368 | */ | |
1369 | //@{ | |
23324ae1 | 1370 | |
8b9ef005 BP |
1371 | /** |
1372 | Clear the table contents. | |
e54c96f1 | 1373 | |
8b9ef005 BP |
1374 | This method is used by wxGrid::ClearGrid(). |
1375 | */ | |
1376 | virtual void Clear(); | |
7c913512 | 1377 | |
8b9ef005 BP |
1378 | /** |
1379 | Insert additional rows into the table. | |
7c913512 | 1380 | |
8b9ef005 BP |
1381 | @param pos |
1382 | The position of the first new row. | |
1383 | @param numRows | |
1384 | The number of rows to insert. | |
1385 | */ | |
1386 | virtual bool InsertRows(size_t pos = 0, size_t numRows = 1); | |
7c913512 | 1387 | |
23324ae1 | 1388 | /** |
8b9ef005 BP |
1389 | Append additional rows at the end of the table. |
1390 | ||
1391 | This method is provided in addition to InsertRows() as some data models | |
1392 | may only support appending rows to them but not inserting them at | |
1393 | arbitrary locations. In such case you may implement this method only | |
1394 | and leave InsertRows() unimplemented. | |
1395 | ||
1396 | @param numRows | |
1397 | The number of rows to add. | |
1398 | */ | |
1399 | virtual bool AppendRows(size_t numRows = 1); | |
23324ae1 FM |
1400 | |
1401 | /** | |
8b9ef005 | 1402 | Delete rows from the table. |
afe0e400 | 1403 | |
8b9ef005 BP |
1404 | @param pos |
1405 | The first row to delete. | |
1406 | @param numRows | |
1407 | The number of rows to delete. | |
1408 | */ | |
1409 | virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1); | |
1410 | ||
1411 | /** | |
1412 | Exactly the same as InsertRows() but for columns. | |
1413 | */ | |
1414 | virtual bool InsertCols(size_t pos = 0, size_t numCols = 1); | |
23324ae1 FM |
1415 | |
1416 | /** | |
8b9ef005 BP |
1417 | Exactly the same as AppendRows() but for columns. |
1418 | */ | |
1419 | virtual bool AppendCols(size_t numCols = 1); | |
23324ae1 | 1420 | |
8b9ef005 BP |
1421 | /** |
1422 | Exactly the same as DeleteRows() but for columns. | |
1423 | */ | |
1424 | virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1); | |
e54c96f1 | 1425 | |
8b9ef005 | 1426 | //@} |
7c913512 | 1427 | |
8b9ef005 BP |
1428 | /** |
1429 | @name Table Row and Column Labels | |
7c913512 | 1430 | |
8b9ef005 BP |
1431 | By default the numbers are used for labeling rows and Latin letters for |
1432 | labeling columns. If the table has more than 26 columns, the pairs of | |
1433 | letters are used starting from the 27-th one and so on, i.e. the | |
1434 | sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ, | |
1435 | AAA, ... | |
1436 | */ | |
1437 | //@{ | |
7c913512 | 1438 | |
23324ae1 | 1439 | /** |
8b9ef005 BP |
1440 | Return the label of the specified row. |
1441 | */ | |
1442 | virtual wxString GetRowLabelValue(int row); | |
23324ae1 | 1443 | |
8b9ef005 BP |
1444 | /** |
1445 | Return the label of the specified column. | |
1446 | */ | |
1447 | virtual wxString GetColLabelValue(int col); | |
5e6e278d | 1448 | |
23324ae1 | 1449 | /** |
8b9ef005 | 1450 | Set the given label for the specified row. |
5e6e278d | 1451 | |
8b9ef005 BP |
1452 | The default version does nothing, i.e. the label is not stored. You |
1453 | must override this method in your derived class if you wish | |
1454 | wxGrid::SetRowLabelValue() to work. | |
1455 | */ | |
1456 | virtual void SetRowLabelValue(int row, const wxString& label); | |
23324ae1 FM |
1457 | |
1458 | /** | |
8b9ef005 BP |
1459 | Exactly the same as SetRowLabelValue() but for columns. |
1460 | */ | |
1461 | virtual void SetColLabelValue(int col, const wxString& label); | |
23324ae1 | 1462 | |
8b9ef005 | 1463 | //@} |
23324ae1 FM |
1464 | |
1465 | ||
8b9ef005 BP |
1466 | /** |
1467 | @name Attributes Management | |
e54c96f1 | 1468 | |
8b9ef005 BP |
1469 | By default the attributes management is delegated to |
1470 | wxGridCellAttrProvider class. You may override the methods in this | |
1471 | section to handle the attributes directly if, for example, they can be | |
1472 | computed from the cell values. | |
1473 | */ | |
1474 | //@{ | |
7c913512 | 1475 | |
8b9ef005 BP |
1476 | /** |
1477 | Associate this attributes provider with the table. | |
7c913512 | 1478 | |
8b9ef005 BP |
1479 | The table takes ownership of @a attrProvider pointer and will delete it |
1480 | when it doesn't need it any more. The pointer can be @NULL, however | |
1481 | this won't disable attributes management in the table but will just | |
1482 | result in a default attributes being recreated the next time any of the | |
1483 | other functions in this section is called. To completely disable the | |
1484 | attributes support, should this be needed, you need to override | |
1485 | CanHaveAttributes() to return @false. | |
1486 | */ | |
1487 | void SetAttrProvider(wxGridCellAttrProvider *attrProvider); | |
afe0e400 | 1488 | |
23324ae1 | 1489 | /** |
8b9ef005 | 1490 | Returns the attribute provider currently being used. |
23324ae1 | 1491 | |
8b9ef005 BP |
1492 | This function may return @NULL if the attribute provider hasn't been |
1493 | neither associated with this table by SetAttrProvider() nor created on | |
1494 | demand by any other methods. | |
1495 | */ | |
1496 | wxGridCellAttrProvider *GetAttrProvider() const; | |
23324ae1 FM |
1497 | |
1498 | /** | |
8b9ef005 | 1499 | Return the attribute for the given cell. |
23324ae1 | 1500 | |
8b9ef005 BP |
1501 | By default this function is simply forwarded to |
1502 | wxGridCellAttrProvider::GetAttr() but it may be overridden to handle | |
1503 | attributes directly in the table. | |
1504 | */ | |
1505 | virtual wxGridCellAttr *GetAttr(int row, int col, | |
1506 | wxGridCellAttr::wxAttrKind kind); | |
23324ae1 FM |
1507 | |
1508 | /** | |
8b9ef005 | 1509 | Set attribute of the specified cell. |
23324ae1 | 1510 | |
8b9ef005 BP |
1511 | By default this function is simply forwarded to |
1512 | wxGridCellAttrProvider::SetAttr(). | |
1513 | ||
1514 | The table takes ownership of @a attr, i.e. will call DecRef() on it. | |
1515 | */ | |
1516 | virtual void SetAttr(wxGridCellAttr* attr, int row, int col); | |
23324ae1 FM |
1517 | |
1518 | /** | |
8b9ef005 | 1519 | Set attribute of the specified row. |
23324ae1 | 1520 | |
8b9ef005 BP |
1521 | By default this function is simply forwarded to |
1522 | wxGridCellAttrProvider::SetRowAttr(). | |
23324ae1 | 1523 | |
8b9ef005 BP |
1524 | The table takes ownership of @a attr, i.e. will call DecRef() on it. |
1525 | */ | |
1526 | virtual void SetRowAttr(wxGridCellAttr *attr, int row); | |
e54c96f1 | 1527 | |
8b9ef005 BP |
1528 | /** |
1529 | Set attribute of the specified column. | |
7c913512 | 1530 | |
8b9ef005 BP |
1531 | By default this function is simply forwarded to |
1532 | wxGridCellAttrProvider::SetColAttr(). | |
7c913512 | 1533 | |
8b9ef005 BP |
1534 | The table takes ownership of @a attr, i.e. will call DecRef() on it. |
1535 | */ | |
1536 | virtual void SetColAttr(wxGridCellAttr *attr, int col); | |
1537 | ||
1538 | //@} | |
7c913512 | 1539 | |
23324ae1 | 1540 | /** |
8b9ef005 BP |
1541 | Returns true if this table supports attributes or false otherwise. |
1542 | ||
1543 | By default, the table automatically creates a wxGridCellAttrProvider | |
1544 | when this function is called if it had no attribute provider before and | |
1545 | returns @true. | |
1546 | */ | |
1547 | virtual bool CanHaveAttributes(); | |
23324ae1 FM |
1548 | }; |
1549 | ||
574e1c5a VZ |
1550 | /** |
1551 | @class wxGridSizesInfo | |
1552 | ||
1553 | wxGridSizesInfo stores information about sizes of all wxGrid rows or | |
d455444a | 1554 | columns. |
574e1c5a VZ |
1555 | |
1556 | It assumes that most of the rows or columns (which are both called elements | |
1557 | here as the difference between them doesn't matter at this class level) | |
1558 | have the default size and so stores it separately. And it uses a wxHashMap | |
1559 | to store the sizes of all elements which have the non-default size. | |
1560 | ||
1561 | This structure is particularly useful for serializing the sizes of all | |
1562 | wxGrid elements at once. | |
1563 | ||
1564 | @library{wxadv} | |
1565 | @category{grid} | |
1566 | */ | |
1567 | struct wxGridSizesInfo | |
1568 | { | |
1569 | /** | |
1570 | Default constructor. | |
1571 | ||
1572 | m_sizeDefault and m_customSizes must be initialized later. | |
1573 | */ | |
1574 | wxGridSizesInfo(); | |
1575 | ||
1576 | /** | |
1577 | Constructor. | |
1578 | ||
1579 | This constructor is used by wxGrid::GetRowSizes() and GetColSizes() | |
1580 | methods. User code will usually use the default constructor instead. | |
1581 | ||
1582 | @param defSize | |
1583 | The default element size. | |
d455444a | 1584 | @param allSizes |
574e1c5a VZ |
1585 | Array containing the sizes of @em all elements, including those |
1586 | which have the default size. | |
1587 | */ | |
1588 | wxGridSizesInfo(int defSize, const wxArrayInt& allSizes); | |
1589 | ||
1590 | /** | |
1591 | Get the element size. | |
1592 | ||
1593 | @param pos | |
1594 | The index of the element. | |
1595 | @return | |
1596 | The size for this element, using m_customSizes if @a pos is in it | |
1597 | or m_sizeDefault otherwise. | |
1598 | */ | |
1599 | int GetSize(unsigned pos) const; | |
1600 | ||
1601 | ||
1602 | /// Default size | |
1603 | int m_sizeDefault; | |
1604 | ||
1605 | /** | |
1606 | Map with element indices as keys and their sizes as values. | |
1607 | ||
1608 | This map only contains the elements with non-default size. | |
1609 | */ | |
1610 | wxUnsignedToIntHashMap m_customSizes; | |
1611 | }; | |
23324ae1 | 1612 | |
e54c96f1 | 1613 | |
23324ae1 | 1614 | /** |
8b9ef005 | 1615 | @class wxGrid |
7c913512 | 1616 | |
8b9ef005 | 1617 | wxGrid and its related classes are used for displaying and editing tabular |
caac7804 BP |
1618 | data. They provide a rich set of features for display, editing, and |
1619 | interacting with a variety of data sources. For simple applications, and to | |
1620 | help you get started, wxGrid is the only class you need to refer to | |
1621 | directly. It will set up default instances of the other classes and manage | |
1622 | them for you. For more complex applications you can derive your own classes | |
1623 | for custom grid views, grid data tables, cell editors and renderers. The | |
1624 | @ref overview_grid has examples of simple and more complex applications, | |
8b9ef005 BP |
1625 | explains the relationship between the various grid classes and has a |
1626 | summary of the keyboard shortcuts and mouse functions provided by wxGrid. | |
7c913512 | 1627 | |
8b9ef005 BP |
1628 | A wxGridTableBase class holds the actual data to be displayed by a wxGrid |
1629 | class. One or more wxGrid classes may act as a view for one table class. | |
1630 | The default table class is called wxGridStringTable and holds an array of | |
caac7804 | 1631 | strings. An instance of such a class is created by CreateGrid(). |
23324ae1 | 1632 | |
8b9ef005 BP |
1633 | wxGridCellRenderer is the abstract base class for rendereing contents in a |
1634 | cell. The following renderers are predefined: | |
caac7804 BP |
1635 | |
1636 | - wxGridCellBoolRenderer | |
1637 | - wxGridCellFloatRenderer | |
1638 | - wxGridCellNumberRenderer | |
1639 | - wxGridCellStringRenderer | |
1640 | ||
8b9ef005 | 1641 | The look of a cell can be further defined using wxGridCellAttr. An object |
caac7804 | 1642 | of this type may be returned by wxGridTableBase::GetAttr(). |
3c4f71cc | 1643 | |
8b9ef005 BP |
1644 | wxGridCellEditor is the abstract base class for editing the value of a |
1645 | cell. The following editors are predefined: | |
caac7804 BP |
1646 | |
1647 | - wxGridCellBoolEditor | |
1648 | - wxGridCellChoiceEditor | |
1649 | - wxGridCellFloatEditor | |
1650 | - wxGridCellNumberEditor | |
1651 | - wxGridCellTextEditor | |
f8f31de6 | 1652 | |
caac7804 BP |
1653 | Please see wxGridEvent, wxGridSizeEvent, wxGridRangeSelectEvent, and |
1654 | wxGridEditorCreatedEvent for the documentation of all event types you can | |
1655 | use with wxGrid. | |
8b9ef005 BP |
1656 | |
1657 | @library{wxadv} | |
1658 | @category{grid} | |
23324ae1 | 1659 | |
caac7804 | 1660 | @see @ref overview_grid, wxGridUpdateLocker |
8b9ef005 BP |
1661 | */ |
1662 | class wxGrid : public wxScrolledWindow | |
1663 | { | |
1664 | public: | |
caac7804 | 1665 | |
23324ae1 | 1666 | /** |
8b9ef005 BP |
1667 | Different selection modes supported by the grid. |
1668 | */ | |
1669 | enum wxGridSelectionModes | |
1670 | { | |
1671 | /** | |
1672 | The default selection mode allowing selection of the individual | |
1673 | cells as well as of the entire rows and columns. | |
1674 | */ | |
1675 | wxGridSelectCells, | |
23324ae1 | 1676 | |
8b9ef005 BP |
1677 | /** |
1678 | The selection mode allowing the selection of the entire rows only. | |
3c4f71cc | 1679 | |
8b9ef005 BP |
1680 | The user won't be able to select any cells or columns in this mode. |
1681 | */ | |
1682 | wxGridSelectRows, | |
23324ae1 | 1683 | |
8b9ef005 BP |
1684 | /** |
1685 | The selection mode allowing the selection of the entire columns only. | |
3c4f71cc | 1686 | |
8b9ef005 BP |
1687 | The user won't be able to select any cells or rows in this mode. |
1688 | */ | |
1689 | wxGridSelectColumns | |
1690 | }; | |
23324ae1 | 1691 | |
ea99e8e3 VZ |
1692 | /** |
1693 | Return values for GetCellSize(). | |
1694 | ||
1695 | @since 2.9.1 | |
1696 | */ | |
1697 | enum CellSpan | |
1698 | { | |
1699 | /// This cell is inside a span covered by another cell. | |
1700 | CellSpan_Inside = -1, | |
1701 | ||
1702 | /// This is a normal, non-spanning cell. | |
1703 | CellSpan_None = 0, | |
1704 | ||
1705 | /// This cell spans several physical wxGrid cells. | |
1706 | CellSpan_Main | |
1707 | }; | |
caac7804 BP |
1708 | |
1709 | /** | |
1710 | @name Constructors and Initialization | |
1711 | */ | |
1712 | //@{ | |
1713 | ||
23324ae1 | 1714 | /** |
8b9ef005 | 1715 | Default constructor. |
3c4f71cc | 1716 | |
8b9ef005 BP |
1717 | You must call Create() to really create the grid window and also call |
1718 | CreateGrid() or SetTable() to initialize the grid contents. | |
1719 | */ | |
1720 | wxGrid(); | |
23324ae1 | 1721 | /** |
8b9ef005 | 1722 | Constructor creating the grid window. |
3c4f71cc | 1723 | |
8b9ef005 BP |
1724 | You must call either CreateGrid() or SetTable() to initialize the grid |
1725 | contents before using it. | |
23324ae1 | 1726 | */ |
caac7804 | 1727 | wxGrid(wxWindow* parent, wxWindowID id, |
8b9ef005 BP |
1728 | const wxPoint& pos = wxDefaultPosition, |
1729 | const wxSize& size = wxDefaultSize, | |
1730 | long style = wxWANTS_CHARS, | |
1731 | const wxString& name = wxGridNameStr); | |
23324ae1 | 1732 | |
caac7804 BP |
1733 | /** |
1734 | Destructor. | |
1735 | ||
1736 | This will also destroy the associated grid table unless you passed a | |
1737 | table object to the grid and specified that the grid should not take | |
1738 | ownership of the table (see SetTable()). | |
1739 | */ | |
1740 | virtual ~wxGrid(); | |
1741 | ||
23324ae1 | 1742 | /** |
8b9ef005 BP |
1743 | Creates the grid window for an object initialized using the default |
1744 | constructor. | |
3c4f71cc | 1745 | |
8b9ef005 BP |
1746 | You must call either CreateGrid() or SetTable() to initialize the grid |
1747 | contents before using it. | |
1748 | */ | |
caac7804 | 1749 | bool Create(wxWindow* parent, wxWindowID id, |
8b9ef005 BP |
1750 | const wxPoint& pos = wxDefaultPosition, |
1751 | const wxSize& size = wxDefaultSize, | |
1752 | long style = wxWANTS_CHARS, | |
1753 | const wxString& name = wxGridNameStr); | |
23324ae1 FM |
1754 | |
1755 | /** | |
caac7804 | 1756 | Creates a grid with the specified initial number of rows and columns. |
3c4f71cc | 1757 | |
caac7804 BP |
1758 | Call this directly after the grid constructor. When you use this |
1759 | function wxGrid will create and manage a simple table of string values | |
1760 | for you. All of the grid data will be stored in memory. | |
1761 | ||
1762 | For applications with more complex data types or relationships, or for | |
1763 | dealing with very large datasets, you should derive your own grid table | |
1764 | class and pass a table object to the grid with SetTable(). | |
23324ae1 | 1765 | */ |
caac7804 BP |
1766 | bool CreateGrid(int numRows, int numCols, |
1767 | wxGridSelectionModes selmode = wxGridSelectCells); | |
23324ae1 FM |
1768 | |
1769 | /** | |
caac7804 | 1770 | Passes a pointer to a custom grid table to be used by the grid. |
3c4f71cc | 1771 | |
caac7804 BP |
1772 | This should be called after the grid constructor and before using the |
1773 | grid object. If @a takeOwnership is set to @true then the table will be | |
1774 | deleted by the wxGrid destructor. | |
3c4f71cc | 1775 | |
caac7804 BP |
1776 | Use this function instead of CreateGrid() when your application |
1777 | involves complex or non-string data or data sets that are too large to | |
1778 | fit wholly in memory. | |
23324ae1 | 1779 | */ |
caac7804 BP |
1780 | bool SetTable(wxGridTableBase* table, bool takeOwnership = false, |
1781 | wxGridSelectionModes selmode = wxGridSelectCells); | |
23324ae1 | 1782 | |
caac7804 | 1783 | //@} |
8b9ef005 | 1784 | |
3c4f71cc | 1785 | |
caac7804 BP |
1786 | /** |
1787 | @name Grid Line Formatting | |
1788 | */ | |
1789 | //@{ | |
1790 | ||
1791 | /** | |
1792 | Turns the drawing of grid lines on or off. | |
23324ae1 | 1793 | */ |
caac7804 | 1794 | void EnableGridLines(bool enable = true); |
23324ae1 FM |
1795 | |
1796 | /** | |
caac7804 | 1797 | Returns the pen used for vertical grid lines. |
3c4f71cc | 1798 | |
caac7804 BP |
1799 | This virtual function may be overridden in derived classes in order to |
1800 | change the appearance of individual grid lines for the given column | |
1801 | @a col. | |
23324ae1 | 1802 | |
caac7804 BP |
1803 | See GetRowGridLinePen() for an example. |
1804 | */ | |
1805 | virtual wxPen GetColGridLinePen(int col); | |
23324ae1 FM |
1806 | |
1807 | /** | |
caac7804 | 1808 | Returns the pen used for grid lines. |
23324ae1 | 1809 | |
caac7804 BP |
1810 | This virtual function may be overridden in derived classes in order to |
1811 | change the appearance of grid lines. Note that currently the pen width | |
1812 | must be 1. | |
3c4f71cc | 1813 | |
caac7804 BP |
1814 | @see GetColGridLinePen(), GetRowGridLinePen() |
1815 | */ | |
1816 | virtual wxPen GetDefaultGridLinePen(); | |
23324ae1 FM |
1817 | |
1818 | /** | |
caac7804 BP |
1819 | Returns the colour used for grid lines. |
1820 | ||
1821 | @see GetDefaultGridLinePen() | |
23324ae1 | 1822 | */ |
caac7804 | 1823 | wxColour GetGridLineColour() const; |
23324ae1 FM |
1824 | |
1825 | /** | |
caac7804 BP |
1826 | Returns the pen used for horizontal grid lines. |
1827 | ||
1828 | This virtual function may be overridden in derived classes in order to | |
1829 | change the appearance of individual grid line for the given @a row. | |
1830 | ||
1831 | Example: | |
1832 | @code | |
1833 | // in a grid displaying music notation, use a solid black pen between | |
1834 | // octaves (C0=row 127, C1=row 115 etc.) | |
1835 | wxPen MidiGrid::GetRowGridLinePen(int row) | |
1836 | { | |
1837 | if ( row % 12 == 7 ) | |
1838 | return wxPen(*wxBLACK, 1, wxSOLID); | |
1839 | else | |
1840 | return GetDefaultGridLinePen(); | |
1841 | } | |
1842 | @endcode | |
23324ae1 | 1843 | */ |
caac7804 | 1844 | virtual wxPen GetRowGridLinePen(int row); |
23324ae1 FM |
1845 | |
1846 | /** | |
caac7804 | 1847 | Returns @true if drawing of grid lines is turned on, @false otherwise. |
23324ae1 | 1848 | */ |
caac7804 | 1849 | bool GridLinesEnabled() const; |
23324ae1 FM |
1850 | |
1851 | /** | |
caac7804 | 1852 | Sets the colour used to draw grid lines. |
23324ae1 | 1853 | */ |
caac7804 BP |
1854 | void SetGridLineColour(const wxColour& colour); |
1855 | ||
1856 | //@} | |
1857 | ||
23324ae1 FM |
1858 | |
1859 | /** | |
caac7804 BP |
1860 | @name Label Values and Formatting |
1861 | */ | |
1862 | //@{ | |
23324ae1 FM |
1863 | |
1864 | /** | |
caac7804 BP |
1865 | Sets the arguments to the current column label alignment values. |
1866 | ||
1867 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE | |
1868 | or @c wxALIGN_RIGHT. | |
1869 | ||
1870 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1871 | @c wxALIGN_BOTTOM. | |
23324ae1 | 1872 | */ |
caac7804 | 1873 | void GetColLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
1874 | |
1875 | /** | |
caac7804 BP |
1876 | Returns the orientation of the column labels (either @c wxHORIZONTAL or |
1877 | @c wxVERTICAL). | |
23324ae1 | 1878 | */ |
caac7804 | 1879 | int GetColLabelTextOrientation() const; |
23324ae1 FM |
1880 | |
1881 | /** | |
caac7804 | 1882 | Returns the specified column label. |
7c913512 | 1883 | |
caac7804 BP |
1884 | The default grid table class provides column labels of the form |
1885 | A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can | |
1886 | override wxGridTableBase::GetColLabelValue() to provide your own | |
1887 | labels. | |
23324ae1 | 1888 | */ |
caac7804 | 1889 | wxString GetColLabelValue(int col) const; |
23324ae1 | 1890 | |
8b9ef005 | 1891 | /** |
caac7804 BP |
1892 | Returns the colour used for the background of row and column labels. |
1893 | */ | |
1894 | wxColour GetLabelBackgroundColour() const; | |
e54c96f1 | 1895 | |
caac7804 BP |
1896 | /** |
1897 | Returns the font used for row and column labels. | |
1898 | */ | |
1899 | wxFont GetLabelFont() const; | |
7c913512 | 1900 | |
caac7804 BP |
1901 | /** |
1902 | Returns the colour used for row and column label text. | |
8b9ef005 | 1903 | */ |
caac7804 | 1904 | wxColour GetLabelTextColour() const; |
7c913512 | 1905 | |
23324ae1 | 1906 | /** |
caac7804 | 1907 | Returns the alignment used for row labels. |
3c4f71cc | 1908 | |
caac7804 BP |
1909 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
1910 | or @c wxALIGN_RIGHT. | |
1911 | ||
1912 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
1913 | @c wxALIGN_BOTTOM. | |
23324ae1 | 1914 | */ |
caac7804 | 1915 | void GetRowLabelAlignment(int* horiz, int* vert) const; |
23324ae1 FM |
1916 | |
1917 | /** | |
caac7804 | 1918 | Returns the specified row label. |
23324ae1 | 1919 | |
caac7804 BP |
1920 | The default grid table class provides numeric row labels. If you are |
1921 | using a custom grid table you can override | |
1922 | wxGridTableBase::GetRowLabelValue() to provide your own labels. | |
23324ae1 | 1923 | */ |
caac7804 | 1924 | wxString GetRowLabelValue(int row) const; |
23324ae1 FM |
1925 | |
1926 | /** | |
caac7804 BP |
1927 | Hides the column labels by calling SetColLabelSize() with a size of 0. |
1928 | Show labels again by calling that method with a width greater than 0. | |
23324ae1 | 1929 | */ |
caac7804 | 1930 | void HideColLabels(); |
23324ae1 FM |
1931 | |
1932 | /** | |
caac7804 | 1933 | Hides the row labels by calling SetRowLabelSize() with a size of 0. |
23324ae1 | 1934 | |
caac7804 BP |
1935 | The labels can be shown again by calling SetRowLabelSize() with a width |
1936 | greater than 0. | |
23324ae1 | 1937 | */ |
caac7804 | 1938 | void HideRowLabels(); |
23324ae1 FM |
1939 | |
1940 | /** | |
caac7804 | 1941 | Sets the horizontal and vertical alignment of column label text. |
23324ae1 | 1942 | |
caac7804 BP |
1943 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
1944 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one | |
1945 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
23324ae1 | 1946 | */ |
caac7804 | 1947 | void SetColLabelAlignment(int horiz, int vert); |
23324ae1 FM |
1948 | |
1949 | /** | |
caac7804 BP |
1950 | Sets the orientation of the column labels (either @c wxHORIZONTAL or |
1951 | @c wxVERTICAL). | |
8b9ef005 | 1952 | */ |
caac7804 | 1953 | void SetColLabelTextOrientation(int textOrientation); |
7c913512 | 1954 | |
23324ae1 | 1955 | /** |
caac7804 | 1956 | Set the value for the given column label. |
8b9ef005 | 1957 | |
caac7804 BP |
1958 | If you are using a custom grid table you must override |
1959 | wxGridTableBase::SetColLabelValue() for this to have any effect. | |
23324ae1 | 1960 | */ |
caac7804 | 1961 | void SetColLabelValue(int col, const wxString& value); |
23324ae1 FM |
1962 | |
1963 | /** | |
caac7804 | 1964 | Sets the background colour for row and column labels. |
23324ae1 | 1965 | */ |
caac7804 | 1966 | void SetLabelBackgroundColour(const wxColour& colour); |
23324ae1 | 1967 | |
8b9ef005 | 1968 | /** |
caac7804 BP |
1969 | Sets the font for row and column labels. |
1970 | */ | |
1971 | void SetLabelFont(const wxFont& font); | |
55f0bf1f | 1972 | |
8b9ef005 | 1973 | /** |
caac7804 BP |
1974 | Sets the colour for row and column label text. |
1975 | */ | |
1976 | void SetLabelTextColour(const wxColour& colour); | |
55f0bf1f | 1977 | |
8b9ef005 | 1978 | /** |
caac7804 | 1979 | Sets the horizontal and vertical alignment of row label text. |
7c913512 | 1980 | |
caac7804 BP |
1981 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
1982 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one | |
1983 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
8b9ef005 | 1984 | */ |
caac7804 | 1985 | void SetRowLabelAlignment(int horiz, int vert); |
7c913512 | 1986 | |
23324ae1 | 1987 | /** |
caac7804 | 1988 | Sets the value for the given row label. |
55f0bf1f | 1989 | |
caac7804 BP |
1990 | If you are using a derived grid table you must override |
1991 | wxGridTableBase::SetRowLabelValue() for this to have any effect. | |
8b9ef005 | 1992 | */ |
caac7804 | 1993 | void SetRowLabelValue(int row, const wxString& value); |
55f0bf1f | 1994 | |
8b9ef005 | 1995 | /** |
caac7804 | 1996 | Call this in order to make the column labels use a native look by using |
03faec76 | 1997 | wxRendererNative::DrawHeaderButton() internally. |
55f0bf1f | 1998 | |
caac7804 BP |
1999 | There is no equivalent method for drawing row columns as there is not |
2000 | native look for that. This option is useful when using wxGrid for | |
2001 | displaying tables and not as a spread-sheet. | |
ad805b9e | 2002 | |
03faec76 | 2003 | @see UseNativeColHeader() |
8b9ef005 | 2004 | */ |
caac7804 | 2005 | void SetUseNativeColLabels(bool native = true); |
55f0bf1f | 2006 | |
ad805b9e VZ |
2007 | /** |
2008 | Enable the use of native header window for column labels. | |
2009 | ||
2010 | If this function is called with @true argument, a wxHeaderCtrl is used | |
2011 | instead to display the column labels instead of drawing them in wxGrid | |
2012 | code itself. This has the advantage of making the grid look and feel | |
2013 | perfectly the same as native applications (using SetUseNativeColLabels() | |
2014 | the grid can be made to look more natively but it still doesn't feel | |
2015 | natively, notably the column resizing and dragging still works slightly | |
2016 | differently as it is implemented in wxWidgets itself) but results in | |
2017 | different behaviour for column and row headers, for which there is no | |
2018 | equivalent function, and, most importantly, is unsuitable for grids | |
2019 | with huge numbers of columns as wxHeaderCtrl doesn't support virtual | |
2020 | mode. Because of this, by default the grid does not use the native | |
2021 | header control but you should call this function to enable it if you | |
2022 | are using the grid to display tabular data and don't have thousands of | |
2023 | columns in it. | |
2024 | ||
03faec76 FM |
2025 | Also note that currently @c wxEVT_GRID_LABEL_LEFT_DCLICK and |
2026 | @c wxEVT_GRID_LABEL_RIGHT_DCLICK events are not generated for the column | |
ad805b9e VZ |
2027 | labels if the native columns header is used (but this limitation could |
2028 | possibly be lifted in the future). | |
2029 | */ | |
2030 | void UseNativeColHeader(bool native = true); | |
2031 | ||
caac7804 | 2032 | //@} |
55f0bf1f | 2033 | |
55f0bf1f VZ |
2034 | |
2035 | /** | |
caac7804 | 2036 | @name Cell Formatting |
55f0bf1f | 2037 | |
caac7804 BP |
2038 | Note that wxGridCellAttr can be used alternatively to most of these |
2039 | methods. See the "Attributes Management" of wxGridTableBase. | |
2040 | */ | |
2041 | //@{ | |
23324ae1 FM |
2042 | |
2043 | /** | |
caac7804 BP |
2044 | Sets the arguments to the horizontal and vertical text alignment values |
2045 | for the grid cell at the specified location. | |
55f0bf1f | 2046 | |
caac7804 BP |
2047 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE |
2048 | or @c wxALIGN_RIGHT. | |
2049 | ||
2050 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or | |
2051 | @c wxALIGN_BOTTOM. | |
8b9ef005 | 2052 | */ |
caac7804 | 2053 | void GetCellAlignment(int row, int col, int* horiz, int* vert) const; |
55f0bf1f VZ |
2054 | |
2055 | /** | |
caac7804 | 2056 | Returns the background colour of the cell at the specified location. |
23324ae1 | 2057 | */ |
caac7804 | 2058 | wxColour GetCellBackgroundColour(int row, int col) const; |
23324ae1 FM |
2059 | |
2060 | /** | |
caac7804 BP |
2061 | Returns the font for text in the grid cell at the specified location. |
2062 | */ | |
2063 | wxFont GetCellFont(int row, int col) const; | |
55f0bf1f | 2064 | |
caac7804 BP |
2065 | /** |
2066 | Returns the text colour for the grid cell at the specified location. | |
23324ae1 | 2067 | */ |
caac7804 | 2068 | wxColour GetCellTextColour(int row, int col) const; |
23324ae1 FM |
2069 | |
2070 | /** | |
caac7804 BP |
2071 | Returns the default cell alignment. |
2072 | ||
2073 | Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE | |
2074 | or @c wxALIGN_RIGHT. | |
55f0bf1f | 2075 | |
caac7804 BP |
2076 | Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or |
2077 | @c wxALIGN_BOTTOM. | |
2078 | ||
2079 | @see SetDefaultCellAlignment() | |
8b9ef005 | 2080 | */ |
caac7804 | 2081 | void GetDefaultCellAlignment(int* horiz, int* vert) const; |
55f0bf1f | 2082 | |
8b9ef005 | 2083 | /** |
caac7804 | 2084 | Returns the current default background colour for grid cells. |
23324ae1 | 2085 | */ |
caac7804 | 2086 | wxColour GetDefaultCellBackgroundColour() const; |
23324ae1 | 2087 | |
9f7aee01 | 2088 | /** |
caac7804 | 2089 | Returns the current default font for grid cell text. |
8b9ef005 | 2090 | */ |
caac7804 | 2091 | wxFont GetDefaultCellFont() const; |
9f7aee01 | 2092 | |
8b9ef005 | 2093 | /** |
caac7804 | 2094 | Returns the current default colour for grid cell text. |
8b9ef005 | 2095 | */ |
caac7804 | 2096 | wxColour GetDefaultCellTextColour() const; |
9f7aee01 | 2097 | |
8b9ef005 | 2098 | /** |
caac7804 BP |
2099 | Sets the horizontal and vertical alignment for grid cell text at the |
2100 | specified location. | |
9f7aee01 | 2101 | |
caac7804 BP |
2102 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
2103 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
2104 | ||
2105 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE | |
2106 | or @c wxALIGN_BOTTOM. | |
2107 | */ | |
2108 | void SetCellAlignment(int row, int col, int horiz, int vert); | |
9f7aee01 | 2109 | /** |
caac7804 BP |
2110 | Sets the horizontal and vertical alignment for grid cell text at the |
2111 | specified location. | |
9f7aee01 | 2112 | |
caac7804 BP |
2113 | Horizontal alignment should be one of @c wxALIGN_LEFT, |
2114 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. | |
9f7aee01 | 2115 | |
caac7804 BP |
2116 | Vertical alignment should be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE |
2117 | or @c wxALIGN_BOTTOM. | |
8b9ef005 | 2118 | */ |
caac7804 | 2119 | void SetCellAlignment(int align, int row, int col); |
9f7aee01 | 2120 | |
23324ae1 | 2121 | /** |
caac7804 | 2122 | Set the background colour for the given cell or all cells by default. |
23324ae1 | 2123 | */ |
caac7804 | 2124 | void SetCellBackgroundColour(int row, int col, const wxColour& colour); |
23324ae1 FM |
2125 | |
2126 | /** | |
caac7804 BP |
2127 | Sets the font for text in the grid cell at the specified location. |
2128 | */ | |
2129 | void SetCellFont(int row, int col, const wxFont& font); | |
8b9ef005 | 2130 | |
caac7804 BP |
2131 | /** |
2132 | Sets the text colour for the given cell. | |
2133 | */ | |
2134 | void SetCellTextColour(int row, int col, const wxColour& colour); | |
2135 | /** | |
2136 | Sets the text colour for the given cell. | |
2137 | */ | |
2138 | void SetCellTextColour(const wxColour& val, int row, int col); | |
2139 | /** | |
2140 | Sets the text colour for all cells by default. | |
2141 | */ | |
2142 | void SetCellTextColour(const wxColour& colour); | |
8b9ef005 | 2143 | |
caac7804 BP |
2144 | /** |
2145 | Sets the default horizontal and vertical alignment for grid cell text. | |
2146 | ||
2147 | Horizontal alignment should be one of @c wxALIGN_LEFT, | |
2148 | @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one | |
2149 | of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. | |
23324ae1 | 2150 | */ |
caac7804 | 2151 | void SetDefaultCellAlignment(int horiz, int vert); |
23324ae1 FM |
2152 | |
2153 | /** | |
caac7804 | 2154 | Sets the default background colour for grid cells. |
23324ae1 | 2155 | */ |
caac7804 | 2156 | void SetDefaultCellBackgroundColour(const wxColour& colour); |
23324ae1 FM |
2157 | |
2158 | /** | |
caac7804 BP |
2159 | Sets the default font to be used for grid cell text. |
2160 | */ | |
2161 | void SetDefaultCellFont(const wxFont& font); | |
8b9ef005 | 2162 | |
caac7804 BP |
2163 | /** |
2164 | Sets the current default colour for grid cell text. | |
23324ae1 | 2165 | */ |
caac7804 BP |
2166 | void SetDefaultCellTextColour(const wxColour& colour); |
2167 | ||
2168 | //@} | |
2169 | ||
2170 | ||
2171 | /** | |
2172 | @name Cell Values, Editors, and Renderers | |
2173 | ||
2174 | Note that wxGridCellAttr can be used alternatively to most of these | |
2175 | methods. See the "Attributes Management" of wxGridTableBase. | |
2176 | */ | |
2177 | //@{ | |
23324ae1 FM |
2178 | |
2179 | /** | |
caac7804 BP |
2180 | Returns @true if the in-place edit control for the current grid cell |
2181 | can be used and @false otherwise. | |
2182 | ||
2183 | This function always returns @false for the read-only cells. | |
23324ae1 | 2184 | */ |
caac7804 | 2185 | bool CanEnableCellControl() const; |
23324ae1 FM |
2186 | |
2187 | /** | |
caac7804 | 2188 | Disables in-place editing of grid cells. |
8b9ef005 | 2189 | |
caac7804 BP |
2190 | Equivalent to calling EnableCellEditControl(@false). |
2191 | */ | |
2192 | void DisableCellEditControl(); | |
8b9ef005 | 2193 | |
caac7804 BP |
2194 | /** |
2195 | Enables or disables in-place editing of grid cell data. | |
2196 | ||
2197 | The grid will issue either a @c wxEVT_GRID_EDITOR_SHOWN or | |
2198 | @c wxEVT_GRID_EDITOR_HIDDEN event. | |
23324ae1 | 2199 | */ |
caac7804 | 2200 | void EnableCellEditControl(bool enable = true); |
23324ae1 FM |
2201 | |
2202 | /** | |
caac7804 BP |
2203 | Makes the grid globally editable or read-only. |
2204 | ||
2205 | If the edit argument is @false this function sets the whole grid as | |
2206 | read-only. If the argument is @true the grid is set to the default | |
2207 | state where cells may be editable. In the default state you can set | |
2208 | single grid cells and whole rows and columns to be editable or | |
2209 | read-only via wxGridCellAttr::SetReadOnly(). For single cells you | |
2210 | can also use the shortcut function SetReadOnly(). | |
2211 | ||
2212 | For more information about controlling grid cell attributes see the | |
2213 | wxGridCellAttr class and the @ref overview_grid. | |
23324ae1 | 2214 | */ |
caac7804 | 2215 | void EnableEditing(bool edit); |
23324ae1 FM |
2216 | |
2217 | /** | |
8b9ef005 | 2218 | Returns a pointer to the editor for the cell at the specified location. |
3c4f71cc | 2219 | |
caac7804 BP |
2220 | See wxGridCellEditor and the @ref overview_grid for more information |
2221 | about cell editors and renderers. | |
3c4f71cc | 2222 | |
8b9ef005 | 2223 | The caller must call DecRef() on the returned pointer. |
23324ae1 | 2224 | */ |
8b9ef005 | 2225 | wxGridCellEditor* GetCellEditor(int row, int col) const; |
23324ae1 | 2226 | |
8b9ef005 BP |
2227 | /** |
2228 | Returns a pointer to the renderer for the grid cell at the specified | |
2229 | location. | |
08dd9b5a | 2230 | |
caac7804 BP |
2231 | See wxGridCellRenderer and the @ref overview_grid for more information |
2232 | about cell editors and renderers. | |
8b9ef005 BP |
2233 | |
2234 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 2235 | */ |
8b9ef005 | 2236 | wxGridCellRenderer* GetCellRenderer(int row, int col) const; |
23324ae1 FM |
2237 | |
2238 | /** | |
caac7804 | 2239 | Returns the string contained in the cell at the specified location. |
23324ae1 | 2240 | |
caac7804 BP |
2241 | For simple applications where a grid object automatically uses a |
2242 | default grid table of string values you use this function together with | |
2243 | SetCellValue() to access cell values. For more complex applications | |
2244 | where you have derived your own grid table class that contains various | |
2245 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2246 | you only use this function for those cells that contain string values. | |
2247 | ||
2248 | See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for | |
2249 | more information. | |
2250 | */ | |
2251 | wxString GetCellValue(int row, int col) const; | |
23324ae1 | 2252 | /** |
8b9ef005 | 2253 | Returns the string contained in the cell at the specified location. |
08dd9b5a | 2254 | |
8b9ef005 BP |
2255 | For simple applications where a grid object automatically uses a |
2256 | default grid table of string values you use this function together with | |
2257 | SetCellValue() to access cell values. For more complex applications | |
2258 | where you have derived your own grid table class that contains various | |
2259 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2260 | you only use this function for those cells that contain string values. | |
2261 | ||
caac7804 BP |
2262 | See wxGridTableBase::CanGetValueAs() and the @ref overview_grid for |
2263 | more information. | |
23324ae1 | 2264 | */ |
882678eb | 2265 | wxString GetCellValue(const wxGridCellCoords& coords) const; |
23324ae1 FM |
2266 | |
2267 | /** | |
caac7804 BP |
2268 | Returns a pointer to the current default grid cell editor. |
2269 | ||
2270 | See wxGridCellEditor and the @ref overview_grid for more information | |
2271 | about cell editors and renderers. | |
23324ae1 | 2272 | */ |
caac7804 | 2273 | wxGridCellEditor* GetDefaultEditor() const; |
23324ae1 FM |
2274 | |
2275 | /** | |
caac7804 | 2276 | Returns the default editor for the specified cell. |
08dd9b5a | 2277 | |
caac7804 BP |
2278 | The base class version returns the editor appropriate for the current |
2279 | cell type but this method may be overridden in the derived classes to | |
2280 | use custom editors for some cells by default. | |
8b9ef005 | 2281 | |
caac7804 BP |
2282 | Notice that the same may be achieved in a usually simpler way by |
2283 | associating a custom editor with the given cell or cells. | |
23324ae1 | 2284 | |
caac7804 BP |
2285 | The caller must call DecRef() on the returned pointer. |
2286 | */ | |
2287 | virtual wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; | |
23324ae1 | 2288 | /** |
caac7804 | 2289 | Returns the default editor for the specified cell. |
08dd9b5a | 2290 | |
caac7804 BP |
2291 | The base class version returns the editor appropriate for the current |
2292 | cell type but this method may be overridden in the derived classes to | |
2293 | use custom editors for some cells by default. | |
8b9ef005 | 2294 | |
caac7804 BP |
2295 | Notice that the same may be achieved in a usually simpler way by |
2296 | associating a custom editor with the given cell or cells. | |
23324ae1 | 2297 | |
caac7804 | 2298 | The caller must call DecRef() on the returned pointer. |
23324ae1 | 2299 | */ |
caac7804 | 2300 | wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const; |
23324ae1 FM |
2301 | |
2302 | /** | |
caac7804 BP |
2303 | Returns the default editor for the cells containing values of the given |
2304 | type. | |
55f0bf1f | 2305 | |
caac7804 BP |
2306 | The base class version returns the editor which was associated with the |
2307 | specified @a typeName when it was registered RegisterDataType() but | |
2308 | this function may be overridden to return something different. This | |
2309 | allows to override an editor used for one of the standard types. | |
2310 | ||
2311 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 2312 | */ |
caac7804 | 2313 | virtual wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; |
23324ae1 FM |
2314 | |
2315 | /** | |
caac7804 | 2316 | Returns a pointer to the current default grid cell renderer. |
8b9ef005 | 2317 | |
caac7804 BP |
2318 | See wxGridCellRenderer and the @ref overview_grid for more information |
2319 | about cell editors and renderers. | |
2320 | ||
2321 | The caller must call DecRef() on the returned pointer. | |
23324ae1 | 2322 | */ |
caac7804 | 2323 | wxGridCellRenderer* GetDefaultRenderer() const; |
23324ae1 | 2324 | |
9f7aee01 | 2325 | /** |
caac7804 BP |
2326 | Returns the default renderer for the given cell. |
2327 | ||
2328 | The base class version returns the renderer appropriate for the current | |
2329 | cell type but this method may be overridden in the derived classes to | |
2330 | use custom renderers for some cells by default. | |
2331 | ||
2332 | The caller must call DecRef() on the returned pointer. | |
8b9ef005 | 2333 | */ |
caac7804 | 2334 | virtual wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; |
9f7aee01 | 2335 | |
8b9ef005 | 2336 | /** |
caac7804 BP |
2337 | Returns the default renderer for the cell containing values of the |
2338 | given type. | |
9f7aee01 | 2339 | |
caac7804 | 2340 | @see GetDefaultEditorForType() |
8b9ef005 | 2341 | */ |
caac7804 | 2342 | virtual wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; |
08dd9b5a | 2343 | |
8b9ef005 | 2344 | /** |
caac7804 | 2345 | Hides the in-place cell edit control. |
23324ae1 | 2346 | */ |
caac7804 | 2347 | void HideCellEditControl(); |
23324ae1 FM |
2348 | |
2349 | /** | |
caac7804 | 2350 | Returns @true if the in-place edit control is currently enabled. |
8b9ef005 | 2351 | */ |
caac7804 | 2352 | bool IsCellEditControlEnabled() const; |
3c4f71cc | 2353 | |
8b9ef005 | 2354 | /** |
caac7804 | 2355 | Returns @true if the current cell is read-only. |
3c4f71cc | 2356 | |
caac7804 | 2357 | @see SetReadOnly(), IsReadOnly() |
23324ae1 | 2358 | */ |
caac7804 | 2359 | bool IsCurrentCellReadOnly() const; |
23324ae1 FM |
2360 | |
2361 | /** | |
caac7804 BP |
2362 | Returns @false if the whole grid has been set as read-only or @true |
2363 | otherwise. | |
2364 | ||
2365 | See EnableEditing() for more information about controlling the editing | |
2366 | status of grid cells. | |
8b9ef005 | 2367 | */ |
caac7804 | 2368 | bool IsEditable() const; |
23324ae1 | 2369 | |
8b9ef005 | 2370 | /** |
caac7804 | 2371 | Returns @true if the cell at the specified location can't be edited. |
55f0bf1f | 2372 | |
caac7804 | 2373 | @see SetReadOnly(), IsCurrentCellReadOnly() |
23324ae1 | 2374 | */ |
caac7804 | 2375 | bool IsReadOnly(int row, int col) const; |
23324ae1 FM |
2376 | |
2377 | /** | |
caac7804 | 2378 | Register a new data type. |
08dd9b5a | 2379 | |
caac7804 BP |
2380 | The data types allow to naturally associate specific renderers and |
2381 | editors to the cells containing values of the given type. For example, | |
2382 | the grid automatically registers a data type with the name | |
2383 | @c wxGRID_VALUE_STRING which uses wxGridCellStringRenderer and | |
2384 | wxGridCellTextEditor as its renderer and editor respectively -- this is | |
2385 | the data type used by all the cells of the default wxGridStringTable, | |
2386 | so this renderer and editor are used by default for all grid cells. | |
8b9ef005 | 2387 | |
caac7804 BP |
2388 | However if a custom table returns @c wxGRID_VALUE_BOOL from its |
2389 | wxGridTableBase::GetTypeName() method, then wxGridCellBoolRenderer and | |
2390 | wxGridCellBoolEditor are used for it because the grid also registers a | |
2391 | boolean data type with this name. | |
8b9ef005 | 2392 | |
caac7804 BP |
2393 | And as this mechanism is completely generic, you may register your own |
2394 | data types using your own custom renderers and editors. Just remember | |
2395 | that the table must identify a cell as being of the given type for them | |
2396 | to be used for this cell. | |
2397 | ||
2398 | @param typeName | |
2399 | Name of the new type. May be any string, but if the type name is | |
2400 | the same as the name of an already registered type, including one | |
2401 | of the standard ones (which are @c wxGRID_VALUE_STRING, @c | |
2402 | wxGRID_VALUE_BOOL, @c wxGRID_VALUE_NUMBER, @c wxGRID_VALUE_FLOAT | |
2403 | and @c wxGRID_VALUE_CHOICE), then the new registration information | |
2404 | replaces the previously used renderer and editor. | |
2405 | @param renderer | |
2406 | The renderer to use for the cells of this type. Its ownership is | |
2407 | taken by the grid, i.e. it will call DecRef() on this pointer when | |
2408 | it doesn't need it any longer. | |
2409 | @param editor | |
2410 | The editor to use for the cells of this type. Its ownership is also | |
2411 | taken by the grid. | |
23324ae1 | 2412 | */ |
caac7804 BP |
2413 | void RegisterDataType(const wxString& typeName, |
2414 | wxGridCellRenderer* renderer, | |
2415 | wxGridCellEditor* editor); | |
23324ae1 FM |
2416 | |
2417 | /** | |
caac7804 BP |
2418 | Sets the value of the current grid cell to the current in-place edit |
2419 | control value. | |
55f0bf1f | 2420 | |
caac7804 BP |
2421 | This is called automatically when the grid cursor moves from the |
2422 | current cell to a new cell. It is also a good idea to call this | |
2423 | function when closing a grid since any edits to the final cell location | |
2424 | will not be saved otherwise. | |
23324ae1 | 2425 | */ |
caac7804 | 2426 | void SaveEditControlValue(); |
23324ae1 FM |
2427 | |
2428 | /** | |
caac7804 | 2429 | Sets the editor for the grid cell at the specified location. |
55f0bf1f | 2430 | |
caac7804 | 2431 | The grid will take ownership of the pointer. |
8b9ef005 | 2432 | |
caac7804 BP |
2433 | See wxGridCellEditor and the @ref overview_grid for more information |
2434 | about cell editors and renderers. | |
23324ae1 | 2435 | */ |
caac7804 | 2436 | void SetCellEditor(int row, int col, wxGridCellEditor* editor); |
23324ae1 FM |
2437 | |
2438 | /** | |
caac7804 | 2439 | Sets the renderer for the grid cell at the specified location. |
55f0bf1f | 2440 | |
caac7804 | 2441 | The grid will take ownership of the pointer. |
8b9ef005 | 2442 | |
caac7804 BP |
2443 | See wxGridCellRenderer and the @ref overview_grid for more information |
2444 | about cell editors and renderers. | |
23324ae1 | 2445 | */ |
caac7804 | 2446 | void SetCellRenderer(int row, int col, wxGridCellRenderer* renderer); |
23324ae1 FM |
2447 | |
2448 | /** | |
caac7804 | 2449 | Sets the string value for the cell at the specified location. |
55f0bf1f | 2450 | |
caac7804 BP |
2451 | For simple applications where a grid object automatically uses a |
2452 | default grid table of string values you use this function together with | |
2453 | GetCellValue() to access cell values. For more complex applications | |
2454 | where you have derived your own grid table class that contains various | |
2455 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2456 | you only use this function for those cells that contain string values. | |
8b9ef005 | 2457 | |
caac7804 BP |
2458 | See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for |
2459 | more information. | |
23324ae1 | 2460 | */ |
caac7804 | 2461 | void SetCellValue(int row, int col, const wxString& s); |
23324ae1 | 2462 | /** |
caac7804 | 2463 | Sets the string value for the cell at the specified location. |
55f0bf1f | 2464 | |
caac7804 BP |
2465 | For simple applications where a grid object automatically uses a |
2466 | default grid table of string values you use this function together with | |
2467 | GetCellValue() to access cell values. For more complex applications | |
2468 | where you have derived your own grid table class that contains various | |
2469 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2470 | you only use this function for those cells that contain string values. | |
23324ae1 | 2471 | |
caac7804 BP |
2472 | See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for |
2473 | more information. | |
23324ae1 | 2474 | */ |
caac7804 | 2475 | void SetCellValue(const wxGridCellCoords& coords, const wxString& s); |
23324ae1 | 2476 | /** |
caac7804 BP |
2477 | @deprecated Please use SetCellValue(int,int,const wxString&) or |
2478 | SetCellValue(const wxGridCellCoords&,const wxString&) | |
2479 | instead. | |
23324ae1 | 2480 | |
caac7804 | 2481 | Sets the string value for the cell at the specified location. |
23324ae1 | 2482 | |
caac7804 BP |
2483 | For simple applications where a grid object automatically uses a |
2484 | default grid table of string values you use this function together with | |
2485 | GetCellValue() to access cell values. For more complex applications | |
2486 | where you have derived your own grid table class that contains various | |
2487 | data types (e.g. numeric, boolean or user-defined custom types) then | |
2488 | you only use this function for those cells that contain string values. | |
2489 | ||
2490 | See wxGridTableBase::CanSetValueAs() and the @ref overview_grid for | |
2491 | more information. | |
23324ae1 | 2492 | */ |
caac7804 | 2493 | void SetCellValue(const wxString& val, int row, int col); |
23324ae1 FM |
2494 | |
2495 | /** | |
caac7804 | 2496 | Sets the specified column to display boolean values. |
55f0bf1f | 2497 | |
caac7804 | 2498 | @see SetColFormatCustom() |
23324ae1 | 2499 | */ |
caac7804 | 2500 | void SetColFormatBool(int col); |
23324ae1 FM |
2501 | |
2502 | /** | |
caac7804 | 2503 | Sets the specified column to display data in a custom format. |
23324ae1 | 2504 | |
caac7804 BP |
2505 | This method provides an alternative to defining a custom grid table |
2506 | which would return @a typeName from its GetTypeName() method for the | |
2507 | cells in this column: while it doesn't really change the type of the | |
2508 | cells in this column, it does associate the renderer and editor used | |
2509 | for the cells of the specified type with them. | |
23324ae1 | 2510 | |
caac7804 BP |
2511 | See the @ref overview_grid for more information on working with custom |
2512 | data types. | |
23324ae1 | 2513 | */ |
caac7804 | 2514 | void SetColFormatCustom(int col, const wxString& typeName); |
23324ae1 FM |
2515 | |
2516 | /** | |
caac7804 BP |
2517 | Sets the specified column to display floating point values with the |
2518 | given width and precision. | |
55f0bf1f | 2519 | |
caac7804 | 2520 | @see SetColFormatCustom() |
23324ae1 | 2521 | */ |
caac7804 | 2522 | void SetColFormatFloat(int col, int width = -1, int precision = -1); |
23324ae1 FM |
2523 | |
2524 | /** | |
caac7804 | 2525 | Sets the specified column to display integer values. |
8b9ef005 | 2526 | |
caac7804 | 2527 | @see SetColFormatCustom() |
23324ae1 | 2528 | */ |
caac7804 | 2529 | void SetColFormatNumber(int col); |
23324ae1 FM |
2530 | |
2531 | /** | |
caac7804 | 2532 | Sets the default editor for grid cells. |
3c4f71cc | 2533 | |
caac7804 | 2534 | The grid will take ownership of the pointer. |
55f0bf1f | 2535 | |
caac7804 BP |
2536 | See wxGridCellEditor and the @ref overview_grid for more information |
2537 | about cell editors and renderers. | |
23324ae1 | 2538 | */ |
caac7804 | 2539 | void SetDefaultEditor(wxGridCellEditor* editor); |
23324ae1 FM |
2540 | |
2541 | /** | |
caac7804 | 2542 | Sets the default renderer for grid cells. |
8b9ef005 | 2543 | |
caac7804 | 2544 | The grid will take ownership of the pointer. |
8b9ef005 | 2545 | |
caac7804 BP |
2546 | See wxGridCellRenderer and the @ref overview_grid for more information |
2547 | about cell editors and renderers. | |
23324ae1 | 2548 | */ |
caac7804 | 2549 | void SetDefaultRenderer(wxGridCellRenderer* renderer); |
23324ae1 FM |
2550 | |
2551 | /** | |
caac7804 | 2552 | Makes the cell at the specified location read-only or editable. |
08dd9b5a | 2553 | |
caac7804 | 2554 | @see IsReadOnly() |
23324ae1 | 2555 | */ |
caac7804 | 2556 | void SetReadOnly(int row, int col, bool isReadOnly = true); |
23324ae1 FM |
2557 | |
2558 | /** | |
caac7804 | 2559 | Displays the in-place cell edit control for the current cell. |
23324ae1 | 2560 | */ |
caac7804 | 2561 | void ShowCellEditControl(); |
23324ae1 | 2562 | |
caac7804 | 2563 | //@} |
23324ae1 | 2564 | |
23324ae1 | 2565 | |
23324ae1 | 2566 | /** |
caac7804 | 2567 | @name Column and Row Sizes |
82edfbe7 | 2568 | |
32bcf974 | 2569 | @see @ref overview_grid_resizing |
caac7804 BP |
2570 | */ |
2571 | //@{ | |
08dd9b5a | 2572 | |
caac7804 BP |
2573 | /** |
2574 | Automatically sets the height and width of all rows and columns to fit | |
2575 | their contents. | |
23324ae1 | 2576 | */ |
caac7804 | 2577 | void AutoSize(); |
23324ae1 FM |
2578 | |
2579 | /** | |
caac7804 | 2580 | Automatically adjusts width of the column to fit its label. |
23324ae1 | 2581 | */ |
caac7804 | 2582 | void AutoSizeColLabelSize(int col); |
23324ae1 FM |
2583 | |
2584 | /** | |
caac7804 BP |
2585 | Automatically sizes the column to fit its contents. If @a setAsMin is |
2586 | @true the calculated width will also be set as the minimal width for | |
2587 | the column. | |
2588 | */ | |
2589 | void AutoSizeColumn(int col, bool setAsMin = true); | |
23324ae1 FM |
2590 | |
2591 | /** | |
caac7804 BP |
2592 | Automatically sizes all columns to fit their contents. If @a setAsMin |
2593 | is @true the calculated widths will also be set as the minimal widths | |
2594 | for the columns. | |
23324ae1 | 2595 | */ |
caac7804 | 2596 | void AutoSizeColumns(bool setAsMin = true); |
23324ae1 FM |
2597 | |
2598 | /** | |
caac7804 BP |
2599 | Automatically sizes the row to fit its contents. If @a setAsMin is |
2600 | @true the calculated height will also be set as the minimal height for | |
2601 | the row. | |
23324ae1 | 2602 | */ |
caac7804 | 2603 | void AutoSizeRow(int row, bool setAsMin = true); |
23324ae1 | 2604 | |
23324ae1 | 2605 | /** |
caac7804 | 2606 | Automatically adjusts height of the row to fit its label. |
23324ae1 | 2607 | */ |
caac7804 | 2608 | void AutoSizeRowLabelSize(int col); |
23324ae1 | 2609 | |
23324ae1 | 2610 | /** |
caac7804 BP |
2611 | Automatically sizes all rows to fit their contents. If @a setAsMin is |
2612 | @true the calculated heights will also be set as the minimal heights | |
2613 | for the rows. | |
23324ae1 | 2614 | */ |
caac7804 | 2615 | void AutoSizeRows(bool setAsMin = true); |
23324ae1 | 2616 | |
23324ae1 | 2617 | /** |
caac7804 | 2618 | Returns the current height of the column labels. |
23324ae1 | 2619 | */ |
caac7804 | 2620 | int GetColLabelSize() const; |
23324ae1 FM |
2621 | |
2622 | /** | |
caac7804 | 2623 | Returns the minimal width to which a column may be resized. |
08dd9b5a | 2624 | |
caac7804 BP |
2625 | Use SetColMinimalAcceptableWidth() to change this value globally or |
2626 | SetColMinimalWidth() to do it for individual columns. | |
08dd9b5a | 2627 | |
caac7804 | 2628 | @see GetRowMinimalAcceptableHeight() |
23324ae1 | 2629 | */ |
caac7804 | 2630 | int GetColMinimalAcceptableWidth() const; |
23324ae1 FM |
2631 | |
2632 | /** | |
caac7804 | 2633 | Returns the width of the specified column. |
23324ae1 | 2634 | */ |
caac7804 | 2635 | int GetColSize(int col) const; |
23324ae1 | 2636 | |
fe79f76b VZ |
2637 | /** |
2638 | Returns @true if the specified column is not currently hidden. | |
2639 | */ | |
2640 | bool IsColShown(int col) const; | |
2641 | ||
23324ae1 | 2642 | /** |
caac7804 | 2643 | Returns the default height for column labels. |
23324ae1 | 2644 | */ |
caac7804 | 2645 | int GetDefaultColLabelSize() const; |
23324ae1 FM |
2646 | |
2647 | /** | |
caac7804 | 2648 | Returns the current default width for grid columns. |
23324ae1 | 2649 | */ |
caac7804 | 2650 | int GetDefaultColSize() const; |
23324ae1 FM |
2651 | |
2652 | /** | |
caac7804 BP |
2653 | Returns the default width for the row labels. |
2654 | */ | |
2655 | int GetDefaultRowLabelSize() const; | |
08dd9b5a | 2656 | |
caac7804 BP |
2657 | /** |
2658 | Returns the current default height for grid rows. | |
23324ae1 | 2659 | */ |
caac7804 | 2660 | int GetDefaultRowSize() const; |
23324ae1 | 2661 | |
23324ae1 | 2662 | /** |
caac7804 | 2663 | Returns the minimal size to which rows can be resized. |
08dd9b5a | 2664 | |
caac7804 BP |
2665 | Use SetRowMinimalAcceptableHeight() to change this value globally or |
2666 | SetRowMinimalHeight() to do it for individual cells. | |
23324ae1 | 2667 | |
caac7804 | 2668 | @see GetColMinimalAcceptableWidth() |
23324ae1 | 2669 | */ |
caac7804 | 2670 | int GetRowMinimalAcceptableHeight() const; |
23324ae1 FM |
2671 | |
2672 | /** | |
caac7804 | 2673 | Returns the current width of the row labels. |
23324ae1 | 2674 | */ |
caac7804 | 2675 | int GetRowLabelSize() const; |
23324ae1 FM |
2676 | |
2677 | /** | |
caac7804 | 2678 | Returns the height of the specified row. |
8b9ef005 | 2679 | */ |
caac7804 | 2680 | int GetRowSize(int row) const; |
08dd9b5a | 2681 | |
fe79f76b VZ |
2682 | /** |
2683 | Returns @true if the specified row is not currently hidden. | |
2684 | */ | |
2685 | bool IsRowShown(int row) const; | |
2686 | ||
8b9ef005 | 2687 | /** |
caac7804 | 2688 | Sets the height of the column labels. |
08dd9b5a | 2689 | |
caac7804 BP |
2690 | If @a height equals to @c wxGRID_AUTOSIZE then height is calculated |
2691 | automatically so that no label is truncated. Note that this could be | |
2692 | slow for a large table. | |
23324ae1 | 2693 | */ |
caac7804 | 2694 | void SetColLabelSize(int height); |
23324ae1 FM |
2695 | |
2696 | /** | |
caac7804 | 2697 | Sets the minimal @a width to which the user can resize columns. |
08dd9b5a | 2698 | |
caac7804 | 2699 | @see GetColMinimalAcceptableWidth() |
23324ae1 | 2700 | */ |
caac7804 | 2701 | void SetColMinimalAcceptableWidth(int width); |
23324ae1 FM |
2702 | |
2703 | /** | |
caac7804 | 2704 | Sets the minimal @a width for the specified column @a col. |
3c4f71cc | 2705 | |
caac7804 BP |
2706 | It is usually best to call this method during grid creation as calling |
2707 | it later will not resize the column to the given minimal width even if | |
2708 | it is currently narrower than it. | |
23324ae1 | 2709 | |
caac7804 BP |
2710 | @a width must be greater than the minimal acceptable column width as |
2711 | returned by GetColMinimalAcceptableWidth(). | |
23324ae1 | 2712 | */ |
caac7804 | 2713 | void SetColMinimalWidth(int col, int width); |
23324ae1 FM |
2714 | |
2715 | /** | |
caac7804 BP |
2716 | Sets the width of the specified column. |
2717 | ||
caac7804 BP |
2718 | @param col |
2719 | The column index. | |
2720 | @param width | |
009c7216 VZ |
2721 | The new column width in pixels, 0 to hide the column or -1 to fit |
2722 | the column width to its label width. | |
23324ae1 | 2723 | */ |
caac7804 | 2724 | void SetColSize(int col, int width); |
23324ae1 | 2725 | |
009c7216 VZ |
2726 | /** |
2727 | Hides the specified column. | |
2728 | ||
2729 | To show the column later you need to call SetColSize() with non-0 | |
2730 | width or ShowCol(). | |
2731 | ||
2732 | @param col | |
2733 | The column index. | |
2734 | */ | |
2735 | void HideCol(int col); | |
2736 | ||
2737 | /** | |
2738 | Shows the previously hidden column by resizing it to non-0 size. | |
2739 | ||
2740 | @see HideCol(), SetColSize() | |
2741 | */ | |
2742 | void ShowCol(int col); | |
2743 | ||
2744 | ||
23324ae1 | 2745 | /** |
caac7804 | 2746 | Sets the default width for columns in the grid. |
23324ae1 | 2747 | |
caac7804 BP |
2748 | This will only affect columns subsequently added to the grid unless |
2749 | @a resizeExistingCols is @true. | |
2750 | ||
2751 | If @a width is less than GetColMinimalAcceptableWidth(), then the | |
2752 | minimal acceptable width is used instead of it. | |
23324ae1 | 2753 | */ |
caac7804 | 2754 | void SetDefaultColSize(int width, bool resizeExistingCols = false); |
23324ae1 FM |
2755 | |
2756 | /** | |
caac7804 | 2757 | Sets the default height for rows in the grid. |
3c4f71cc | 2758 | |
caac7804 BP |
2759 | This will only affect rows subsequently added to the grid unless |
2760 | @a resizeExistingRows is @true. | |
2761 | ||
2762 | If @a height is less than GetRowMinimalAcceptableHeight(), then the | |
2763 | minimal acceptable heihgt is used instead of it. | |
23324ae1 | 2764 | */ |
caac7804 | 2765 | void SetDefaultRowSize(int height, bool resizeExistingRows = false); |
23324ae1 FM |
2766 | |
2767 | /** | |
caac7804 BP |
2768 | Sets the width of the row labels. |
2769 | ||
2770 | If @a width equals @c wxGRID_AUTOSIZE then width is calculated | |
2771 | automatically so that no label is truncated. Note that this could be | |
2772 | slow for a large table. | |
23324ae1 | 2773 | */ |
caac7804 | 2774 | void SetRowLabelSize(int width); |
23324ae1 FM |
2775 | |
2776 | /** | |
caac7804 | 2777 | Sets the minimal row @a height used by default. |
8b9ef005 | 2778 | |
caac7804 | 2779 | See SetColMinimalAcceptableWidth() for more information. |
23324ae1 | 2780 | */ |
caac7804 | 2781 | void SetRowMinimalAcceptableHeight(int height); |
23324ae1 FM |
2782 | |
2783 | /** | |
caac7804 BP |
2784 | Sets the minimal @a height for the specified @a row. |
2785 | ||
2786 | See SetColMinimalWidth() for more information. | |
23324ae1 | 2787 | */ |
caac7804 | 2788 | void SetRowMinimalHeight(int row, int height); |
23324ae1 FM |
2789 | |
2790 | /** | |
caac7804 | 2791 | Sets the height of the specified row. |
08dd9b5a | 2792 | |
caac7804 | 2793 | See SetColSize() for more information. |
23324ae1 | 2794 | */ |
caac7804 BP |
2795 | void SetRowSize(int row, int height); |
2796 | ||
009c7216 VZ |
2797 | /** |
2798 | Hides the specified row. | |
2799 | ||
2800 | To show the row later you need to call SetRowSize() with non-0 | |
2801 | width or ShowRow(). | |
2802 | ||
2803 | @param col | |
2804 | The row index. | |
2805 | */ | |
2806 | void HideRow(int col); | |
2807 | ||
2808 | /** | |
2809 | Shows the previously hidden row by resizing it to non-0 size. | |
2810 | ||
2811 | @see HideRow(), SetRowSize() | |
2812 | */ | |
2813 | void ShowRow(int col); | |
2814 | ||
574e1c5a VZ |
2815 | /** |
2816 | Get size information for all columns at once. | |
2817 | ||
2818 | This method is useful when the information about all column widths | |
2819 | needs to be saved. The widths can be later restored using | |
2820 | SetColSizes(). | |
2821 | ||
2822 | @sa wxGridSizesInfo, GetRowSizes() | |
2823 | */ | |
2824 | wxGridSizesInfo GetColSizes() const; | |
2825 | ||
2826 | /** | |
2827 | Get size information for all row at once. | |
2828 | ||
2829 | @sa wxGridSizesInfo, GetColSizes() | |
2830 | */ | |
2831 | wxGridSizesInfo GetRowSizes() const; | |
2832 | ||
2833 | /** | |
2834 | Restore all columns sizes. | |
2835 | ||
2836 | This is usually called with wxGridSizesInfo object previously returned | |
2837 | by GetColSizes(). | |
2838 | ||
2839 | @sa SetRowSizes() | |
2840 | */ | |
2841 | void SetColSizes(const wxGridSizesInfo& sizeInfo); | |
2842 | ||
2843 | /** | |
2844 | Restore all rows sizes. | |
2845 | ||
2846 | @sa SetColSizes() | |
2847 | */ | |
2848 | void SetRowSizes(const wxGridSizesInfo& sizeInfo); | |
2849 | ||
ea99e8e3 VZ |
2850 | /** |
2851 | Set the size of the cell. | |
2852 | ||
2853 | Specifying a value of more than 1 in @a num_rows or @a num_cols will | |
2854 | make the cell at (@a row, @a col) span the block of the specified size, | |
2855 | covering the other cells which would be normally shown in it. Passing 1 | |
2856 | for both arguments resets the cell to normal appearance. | |
2857 | ||
2858 | @see GetCellSize() | |
2859 | ||
2860 | @param row | |
2861 | The row of the cell. | |
2862 | @param col | |
2863 | The column of the cell. | |
2864 | @param num_rows | |
2865 | Number of rows to be occupied by this cell, must be >= 1. | |
2866 | @param num_cols | |
2867 | Number of columns to be occupied by this cell, must be >= 1. | |
2868 | */ | |
2869 | void SetCellSize(int row, int col, int num_rows, int num_cols); | |
2870 | ||
2871 | /** | |
2872 | Get the size of the cell in number of cells covered by it. | |
2873 | ||
2874 | For normal cells, the function fills both @a num_rows and @a num_cols | |
2875 | with 1 and returns CellSpan_None. For cells which span multiple cells, i.e. | |
2876 | for which SetCellSize() had been called, the returned values are the | |
2877 | same ones as were passed to SetCellSize() call and the function return | |
2878 | value is CellSpan_Main. | |
2879 | ||
2880 | More unexpectedly, perhaps, the returned values may be @em negative for | |
2881 | the cells which are inside a span covered by a cell occupying multiple | |
2882 | rows or columns. They correspond to the offset of the main cell of the | |
2883 | span from the cell passed to this functions and the function returns | |
2884 | CellSpan_Inside value to indicate this. | |
2885 | ||
2886 | As an example, consider a 3*3 grid with the cell (1, 1) (the one in the | |
2887 | middle) having a span of 2 rows and 2 columns, i.e. the grid looks like | |
2888 | @code | |
2889 | +----+----+----+ | |
2890 | | | | | | |
2891 | +----+----+----+ | |
2892 | | | | | |
2893 | +----+ | | |
2894 | | | | | |
2895 | +----+----+----+ | |
2896 | @endcode | |
2897 | Then the function returns 2 and 2 in @a num_rows and @a num_cols for | |
2898 | the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1 | |
2899 | and 0 for the cell (2, 1). | |
2900 | ||
2901 | @param row | |
2902 | The row of the cell. | |
2903 | @param col | |
2904 | The column of the cell. | |
2905 | @param num_rows | |
2906 | Pointer to variable receiving the number of rows, must not be @NULL. | |
2907 | @param num_cols | |
2908 | Pointer to variable receiving the number of columns, must not be | |
2909 | @NULL. | |
2910 | @return | |
2911 | The kind of this cell span (the return value is new in wxWidgets | |
2912 | 2.9.1, this function was void in previous wxWidgets versions). | |
2913 | */ | |
2914 | CellSpan GetCellSize( int row, int col, int *num_rows, int *num_cols ) const; | |
2915 | ||
2916 | /** | |
2917 | Get the number of rows and columns allocated for this cell. | |
2918 | ||
2919 | This overload doesn't return a CellSpan value but the values returned | |
2920 | may still be negative, see GetCellSize(int, int, int *, int *) for | |
2921 | details. | |
2922 | */ | |
2923 | wxSize GetCellSize(const wxGridCellCoords& coords); | |
2924 | ||
8b9ef005 | 2925 | //@} |
23324ae1 | 2926 | |
caac7804 | 2927 | |
23324ae1 | 2928 | /** |
caac7804 | 2929 | @name User-Resizing and Dragging |
82edfbe7 VZ |
2930 | |
2931 | Functions controlling various interactive mouse operations. | |
2932 | ||
2933 | By default, columns and rows can be resized by dragging the edges of | |
2934 | their labels (this can be disabled using DisableDragColSize() and | |
2935 | DisableDragRowSize() methods). And if grid line dragging is enabled with | |
2936 | EnableDragGridSize() they can also be resized by dragging the right or | |
2937 | bottom edge of the grid cells. | |
2938 | ||
2939 | Columns can also be moved to interactively change their order but this | |
2940 | needs to be explicitly enabled with EnableDragColMove(). | |
caac7804 BP |
2941 | */ |
2942 | //@{ | |
08dd9b5a | 2943 | |
caac7804 BP |
2944 | /** |
2945 | Return @true if the dragging of cells is enabled or @false otherwise. | |
23324ae1 | 2946 | */ |
caac7804 | 2947 | bool CanDragCell() const; |
23324ae1 FM |
2948 | |
2949 | /** | |
caac7804 | 2950 | Returns @true if columns can be moved by dragging with the mouse. |
08dd9b5a | 2951 | |
caac7804 | 2952 | Columns can be moved by dragging on their labels. |
23324ae1 | 2953 | */ |
caac7804 | 2954 | bool CanDragColMove() const; |
23324ae1 FM |
2955 | |
2956 | /** | |
82edfbe7 VZ |
2957 | Returns @true if the given column can be resized by dragging with the |
2958 | mouse. | |
8b9ef005 | 2959 | |
82edfbe7 VZ |
2960 | This function returns @true if resizing the columns interactively is |
2961 | globally enabled, i.e. if DisableDragColSize() hadn't been called, and | |
2962 | if this column wasn't explicitly marked as non-resizable with | |
2963 | DisableColResize(). | |
23324ae1 | 2964 | */ |
82edfbe7 | 2965 | bool CanDragColSize(int col) const; |
23324ae1 FM |
2966 | |
2967 | /** | |
caac7804 BP |
2968 | Return @true if the dragging of grid lines to resize rows and columns |
2969 | is enabled or @false otherwise. | |
2970 | */ | |
2971 | bool CanDragGridSize() const; | |
2972 | ||
2973 | /** | |
82edfbe7 VZ |
2974 | Returns @true if the given row can be resized by dragging with the |
2975 | mouse. | |
caac7804 | 2976 | |
82edfbe7 | 2977 | This is the same as CanDragColSize() but for rows. |
caac7804 | 2978 | */ |
82edfbe7 VZ |
2979 | bool CanDragRowSize(int row) const; |
2980 | ||
2981 | /** | |
2982 | Disable interactive resizing of the specified column. | |
2983 | ||
2984 | This method allows to disable resizing of an individual column in a | |
2985 | grid where the columns are otherwise resizable (which is the case by | |
2986 | default). | |
2987 | ||
2988 | Notice that currently there is no way to make some columns resizable in | |
2989 | a grid where columns can't be resized by default as there doesn't seem | |
2990 | to be any need for this in practice. There is also no way to make the | |
2991 | column marked as fixed using this method resizeable again because it is | |
2992 | supposed that fixed columns are used for static parts of the grid and | |
2993 | so should remain fixed during the entire grid lifetime. | |
2994 | ||
2995 | Also notice that disabling interactive column resizing will not prevent | |
2996 | the program from changing the column size. | |
2997 | ||
2998 | @see EnableDragColSize() | |
2999 | */ | |
3000 | void DisableColResize(int col); | |
3001 | ||
3002 | /** | |
3003 | Disable interactive resizing of the specified row. | |
3004 | ||
3005 | This is the same as DisableColResize() but for rows. | |
3006 | ||
3007 | @see EnableDragRowSize() | |
3008 | */ | |
3009 | void DisableRowResize(int row); | |
caac7804 BP |
3010 | |
3011 | /** | |
3012 | Disables column moving by dragging with the mouse. | |
3013 | ||
3014 | Equivalent to passing @false to EnableDragColMove(). | |
3015 | */ | |
3016 | void DisableDragColMove(); | |
3017 | ||
3018 | /** | |
3019 | Disables column sizing by dragging with the mouse. | |
3020 | ||
3021 | Equivalent to passing @false to EnableDragColSize(). | |
3022 | */ | |
3023 | void DisableDragColSize(); | |
3024 | ||
3025 | /** | |
3026 | Disable mouse dragging of grid lines to resize rows and columns. | |
3027 | ||
3028 | Equivalent to passing @false to EnableDragGridSize() | |
3029 | */ | |
3030 | void DisableDragGridSize(); | |
3031 | ||
3032 | /** | |
3033 | Disables row sizing by dragging with the mouse. | |
3034 | ||
3035 | Equivalent to passing @false to EnableDragRowSize(). | |
3036 | */ | |
3037 | void DisableDragRowSize(); | |
3038 | ||
3039 | /** | |
3040 | Enables or disables cell dragging with the mouse. | |
3041 | */ | |
3042 | void EnableDragCell(bool enable = true); | |
3043 | ||
3044 | /** | |
3045 | Enables or disables column moving by dragging with the mouse. | |
3046 | */ | |
3047 | void EnableDragColMove(bool enable = true); | |
3048 | ||
3049 | /** | |
3050 | Enables or disables column sizing by dragging with the mouse. | |
82edfbe7 VZ |
3051 | |
3052 | @see DisableColResize() | |
caac7804 BP |
3053 | */ |
3054 | void EnableDragColSize(bool enable = true); | |
3055 | ||
3056 | /** | |
3057 | Enables or disables row and column resizing by dragging gridlines with | |
3058 | the mouse. | |
3059 | */ | |
3060 | void EnableDragGridSize(bool enable = true); | |
3061 | ||
3062 | /** | |
3063 | Enables or disables row sizing by dragging with the mouse. | |
82edfbe7 VZ |
3064 | |
3065 | @see DisableRowResize() | |
caac7804 BP |
3066 | */ |
3067 | void EnableDragRowSize(bool enable = true); | |
3068 | ||
3069 | /** | |
3070 | Returns the column ID of the specified column position. | |
3071 | */ | |
3072 | int GetColAt(int colPos) const; | |
3073 | ||
3074 | /** | |
3075 | Returns the position of the specified column. | |
3076 | */ | |
3077 | int GetColPos(int colID) const; | |
3078 | ||
3079 | /** | |
3080 | Sets the position of the specified column. | |
3081 | */ | |
3082 | void SetColPos(int colID, int newPos); | |
3083 | ||
31ec8b4e VZ |
3084 | /** |
3085 | Sets the positions of all columns at once. | |
3086 | ||
3087 | This method takes an array containing the indices of the columns in | |
3088 | their display order, i.e. uses the same convention as | |
3089 | wxHeaderCtrl::SetColumnsOrder(). | |
f8f31de6 | 3090 | */ |
31ec8b4e VZ |
3091 | void SetColumnsOrder(const wxArrayInt& order); |
3092 | ||
009c7216 VZ |
3093 | /** |
3094 | Resets the position of the columns to the default. | |
f8f31de6 | 3095 | */ |
009c7216 VZ |
3096 | void ResetColPos(); |
3097 | ||
caac7804 BP |
3098 | //@} |
3099 | ||
3100 | ||
3101 | /** | |
3102 | @name Cursor Movement | |
f8f31de6 | 3103 | */ |
caac7804 BP |
3104 | //@{ |
3105 | ||
3106 | /** | |
3107 | Returns the current grid cell column position. | |
3108 | */ | |
3109 | int GetGridCursorCol() const; | |
3110 | ||
3111 | /** | |
3112 | Returns the current grid cell row position. | |
3113 | */ | |
3114 | int GetGridCursorRow() const; | |
3115 | ||
3116 | /** | |
3117 | Make the given cell current and ensure it is visible. | |
3118 | ||
3119 | This method is equivalent to calling MakeCellVisible() and | |
3120 | SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL | |
3121 | event is generated by it and the selected cell doesn't change if the | |
3122 | event is vetoed. | |
3123 | */ | |
3124 | void GoToCell(int row, int col); | |
3125 | /** | |
3126 | Make the given cell current and ensure it is visible. | |
3127 | ||
3128 | This method is equivalent to calling MakeCellVisible() and | |
3129 | SetGridCursor() and so, as with the latter, a @c wxEVT_GRID_SELECT_CELL | |
3130 | event is generated by it and the selected cell doesn't change if the | |
3131 | event is vetoed. | |
3132 | */ | |
3133 | void GoToCell(const wxGridCellCoords& coords); | |
3134 | ||
3135 | /** | |
3136 | Moves the grid cursor down by one row. | |
3137 | ||
3138 | If a block of cells was previously selected it will expand if the | |
3139 | argument is @true or be cleared if the argument is @false. | |
3140 | */ | |
3141 | bool MoveCursorDown(bool expandSelection); | |
3142 | ||
3143 | /** | |
3144 | Moves the grid cursor down in the current column such that it skips to | |
3145 | the beginning or end of a block of non-empty cells. | |
3146 | ||
3147 | If a block of cells was previously selected it will expand if the | |
3148 | argument is @true or be cleared if the argument is @false. | |
3149 | */ | |
3150 | bool MoveCursorDownBlock(bool expandSelection); | |
3151 | ||
3152 | /** | |
3153 | Moves the grid cursor left by one column. | |
08dd9b5a | 3154 | |
8b9ef005 BP |
3155 | If a block of cells was previously selected it will expand if the |
3156 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3157 | */ |
8b9ef005 | 3158 | bool MoveCursorLeft(bool expandSelection); |
23324ae1 FM |
3159 | |
3160 | /** | |
8b9ef005 BP |
3161 | Moves the grid cursor left in the current row such that it skips to the |
3162 | beginning or end of a block of non-empty cells. | |
3163 | ||
3164 | If a block of cells was previously selected it will expand if the | |
3165 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3166 | */ |
8b9ef005 | 3167 | bool MoveCursorLeftBlock(bool expandSelection); |
23324ae1 FM |
3168 | |
3169 | /** | |
8b9ef005 | 3170 | Moves the grid cursor right by one column. |
08dd9b5a | 3171 | |
8b9ef005 BP |
3172 | If a block of cells was previously selected it will expand if the |
3173 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3174 | */ |
8b9ef005 | 3175 | bool MoveCursorRight(bool expandSelection); |
23324ae1 FM |
3176 | |
3177 | /** | |
8b9ef005 BP |
3178 | Moves the grid cursor right in the current row such that it skips to |
3179 | the beginning or end of a block of non-empty cells. | |
08dd9b5a | 3180 | |
8b9ef005 BP |
3181 | If a block of cells was previously selected it will expand if the |
3182 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3183 | */ |
8b9ef005 | 3184 | bool MoveCursorRightBlock(bool expandSelection); |
23324ae1 | 3185 | |
23324ae1 | 3186 | /** |
8b9ef005 BP |
3187 | Moves the grid cursor up by one row. |
3188 | ||
3189 | If a block of cells was previously selected it will expand if the | |
3190 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3191 | */ |
8b9ef005 | 3192 | bool MoveCursorUp(bool expandSelection); |
23324ae1 FM |
3193 | |
3194 | /** | |
8b9ef005 BP |
3195 | Moves the grid cursor up in the current column such that it skips to |
3196 | the beginning or end of a block of non-empty cells. | |
3c4f71cc | 3197 | |
8b9ef005 BP |
3198 | If a block of cells was previously selected it will expand if the |
3199 | argument is @true or be cleared if the argument is @false. | |
23324ae1 | 3200 | */ |
8b9ef005 | 3201 | bool MoveCursorUpBlock(bool expandSelection); |
23324ae1 FM |
3202 | |
3203 | /** | |
8b9ef005 BP |
3204 | Moves the grid cursor down by some number of rows so that the previous |
3205 | bottom visible row becomes the top visible row. | |
3206 | */ | |
3207 | bool MovePageDown(); | |
3c4f71cc | 3208 | |
8b9ef005 BP |
3209 | /** |
3210 | Moves the grid cursor up by some number of rows so that the previous | |
3211 | top visible row becomes the bottom visible row. | |
23324ae1 | 3212 | */ |
8b9ef005 | 3213 | bool MovePageUp(); |
23324ae1 FM |
3214 | |
3215 | /** | |
caac7804 | 3216 | Set the grid cursor to the specified cell. |
08dd9b5a | 3217 | |
caac7804 BP |
3218 | The grid cursor indicates the current cell and can be moved by the user |
3219 | using the arrow keys or the mouse. | |
8b9ef005 | 3220 | |
caac7804 BP |
3221 | Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and |
3222 | if the event handler vetoes this event, the cursor is not moved. | |
8b9ef005 | 3223 | |
caac7804 BP |
3224 | This function doesn't make the target call visible, use GoToCell() to |
3225 | do this. | |
23324ae1 | 3226 | */ |
caac7804 | 3227 | void SetGridCursor(int row, int col); |
23324ae1 | 3228 | /** |
caac7804 | 3229 | Set the grid cursor to the specified cell. |
23324ae1 | 3230 | |
caac7804 BP |
3231 | The grid cursor indicates the current cell and can be moved by the user |
3232 | using the arrow keys or the mouse. | |
bb778cae | 3233 | |
caac7804 BP |
3234 | Calling this function generates a @c wxEVT_GRID_SELECT_CELL event and |
3235 | if the event handler vetoes this event, the cursor is not moved. | |
8b9ef005 | 3236 | |
caac7804 BP |
3237 | This function doesn't make the target call visible, use GoToCell() to |
3238 | do this. | |
23324ae1 | 3239 | */ |
caac7804 BP |
3240 | void SetGridCursor(const wxGridCellCoords& coords); |
3241 | ||
8b9ef005 | 3242 | //@} |
23324ae1 | 3243 | |
8b9ef005 | 3244 | |
caac7804 BP |
3245 | /** |
3246 | @name User Selection | |
3247 | */ | |
3248 | //@{ | |
8b9ef005 | 3249 | |
caac7804 BP |
3250 | /** |
3251 | Deselects all cells that are currently selected. | |
23324ae1 | 3252 | */ |
caac7804 | 3253 | void ClearSelection(); |
23324ae1 FM |
3254 | |
3255 | /** | |
caac7804 | 3256 | Returns an array of individually selected cells. |
08dd9b5a | 3257 | |
caac7804 BP |
3258 | Notice that this array does @em not contain all the selected cells in |
3259 | general as it doesn't include the cells selected as part of column, row | |
3260 | or block selection. You must use this method, GetSelectedCols(), | |
3261 | GetSelectedRows() and GetSelectionBlockTopLeft() and | |
3262 | GetSelectionBlockBottomRight() methods to obtain the entire selection | |
3263 | in general. | |
08dd9b5a | 3264 | |
caac7804 BP |
3265 | Please notice this behaviour is by design and is needed in order to |
3266 | support grids of arbitrary size (when an entire column is selected in | |
3267 | a grid with a million of columns, we don't want to create an array with | |
3268 | a million of entries in this function, instead it returns an empty | |
3269 | array and GetSelectedCols() returns an array containing one element). | |
23324ae1 | 3270 | */ |
caac7804 | 3271 | wxGridCellCoordsArray GetSelectedCells() const; |
23324ae1 FM |
3272 | |
3273 | /** | |
caac7804 | 3274 | Returns an array of selected columns. |
08dd9b5a | 3275 | |
caac7804 BP |
3276 | Please notice that this method alone is not sufficient to find all the |
3277 | selected columns as it contains only the columns which were | |
3278 | individually selected but not those being part of the block selection | |
3279 | or being selected in virtue of all of their cells being selected | |
3280 | individually, please see GetSelectedCells() for more details. | |
23324ae1 | 3281 | */ |
caac7804 | 3282 | wxArrayInt GetSelectedCols() const; |
23324ae1 FM |
3283 | |
3284 | /** | |
caac7804 | 3285 | Returns an array of selected rows. |
23324ae1 | 3286 | |
caac7804 BP |
3287 | Please notice that this method alone is not sufficient to find all the |
3288 | selected rows as it contains only the rows which were individually | |
3289 | selected but not those being part of the block selection or being | |
3290 | selected in virtue of all of their cells being selected individually, | |
3291 | please see GetSelectedCells() for more details. | |
23324ae1 | 3292 | */ |
caac7804 | 3293 | wxArrayInt GetSelectedRows() const; |
23324ae1 FM |
3294 | |
3295 | /** | |
caac7804 | 3296 | Returns the colour used for drawing the selection background. |
23324ae1 | 3297 | */ |
caac7804 | 3298 | wxColour GetSelectionBackground() const; |
23324ae1 | 3299 | |
8a3e536c | 3300 | /** |
caac7804 BP |
3301 | Returns an array of the bottom right corners of blocks of selected |
3302 | cells. | |
8a3e536c | 3303 | |
caac7804 BP |
3304 | Please see GetSelectedCells() for more information about the selection |
3305 | representation in wxGrid. | |
23324ae1 | 3306 | |
caac7804 | 3307 | @see GetSelectionBlockTopLeft() |
23324ae1 | 3308 | */ |
caac7804 | 3309 | wxGridCellCoordsArray GetSelectionBlockBottomRight() const; |
8b9ef005 | 3310 | |
8b9ef005 | 3311 | /** |
caac7804 | 3312 | Returns an array of the top left corners of blocks of selected cells. |
8b9ef005 | 3313 | |
caac7804 BP |
3314 | Please see GetSelectedCells() for more information about the selection |
3315 | representation in wxGrid. | |
23324ae1 | 3316 | |
caac7804 | 3317 | @see GetSelectionBlockBottomRight() |
23324ae1 | 3318 | */ |
caac7804 | 3319 | wxGridCellCoordsArray GetSelectionBlockTopLeft() const; |
23324ae1 FM |
3320 | |
3321 | /** | |
caac7804 | 3322 | Returns the colour used for drawing the selection foreground. |
23324ae1 | 3323 | */ |
caac7804 | 3324 | wxColour GetSelectionForeground() const; |
23324ae1 FM |
3325 | |
3326 | /** | |
caac7804 | 3327 | Returns the current selection mode. |
23324ae1 | 3328 | |
caac7804 | 3329 | @see SetSelectionMode(). |
23324ae1 | 3330 | */ |
caac7804 | 3331 | wxGridSelectionModes GetSelectionMode() const; |
23324ae1 FM |
3332 | |
3333 | /** | |
caac7804 BP |
3334 | Returns @true if the given cell is selected. |
3335 | */ | |
3336 | bool IsInSelection(int row, int col) const; | |
3337 | /** | |
3338 | Returns @true if the given cell is selected. | |
3339 | */ | |
3340 | bool IsInSelection(const wxGridCellCoords& coords) const; | |
08dd9b5a | 3341 | |
caac7804 BP |
3342 | /** |
3343 | Returns @true if there are currently any selected cells, rows, columns | |
3344 | or blocks. | |
3345 | */ | |
3346 | bool IsSelection() const; | |
08dd9b5a | 3347 | |
caac7804 BP |
3348 | /** |
3349 | Selects all cells in the grid. | |
23324ae1 | 3350 | */ |
caac7804 | 3351 | void SelectAll(); |
23324ae1 FM |
3352 | |
3353 | /** | |
caac7804 | 3354 | Selects a rectangular block of cells. |
8b9ef005 | 3355 | |
caac7804 BP |
3356 | If @a addToSelected is @false then any existing selection will be |
3357 | deselected; if @true the column will be added to the existing | |
3358 | selection. | |
23324ae1 | 3359 | */ |
caac7804 BP |
3360 | void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, |
3361 | bool addToSelected = false); | |
23324ae1 | 3362 | /** |
caac7804 | 3363 | Selects a rectangular block of cells. |
08dd9b5a | 3364 | |
caac7804 BP |
3365 | If @a addToSelected is @false then any existing selection will be |
3366 | deselected; if @true the column will be added to the existing | |
3367 | selection. | |
23324ae1 | 3368 | */ |
caac7804 BP |
3369 | void SelectBlock(const wxGridCellCoords& topLeft, |
3370 | const wxGridCellCoords& bottomRight, | |
3371 | bool addToSelected = false); | |
23324ae1 FM |
3372 | |
3373 | /** | |
caac7804 | 3374 | Selects the specified column. |
08dd9b5a | 3375 | |
caac7804 BP |
3376 | If @a addToSelected is @false then any existing selection will be |
3377 | deselected; if @true the column will be added to the existing | |
3378 | selection. | |
3379 | ||
3380 | This method won't select anything if the current selection mode is | |
3381 | wxGridSelectRows. | |
23324ae1 | 3382 | */ |
caac7804 | 3383 | void SelectCol(int col, bool addToSelected = false); |
23324ae1 | 3384 | |
23324ae1 | 3385 | /** |
caac7804 | 3386 | Selects the specified row. |
8b9ef005 | 3387 | |
caac7804 BP |
3388 | If @a addToSelected is @false then any existing selection will be |
3389 | deselected; if @true the row will be added to the existing selection. | |
3390 | ||
3391 | This method won't select anything if the current selection mode is | |
3392 | wxGridSelectColumns. | |
23324ae1 | 3393 | */ |
caac7804 | 3394 | void SelectRow(int row, bool addToSelected = false); |
23324ae1 FM |
3395 | |
3396 | /** | |
caac7804 BP |
3397 | Set the colour to be used for drawing the selection background. |
3398 | */ | |
3399 | void SetSelectionBackground(const wxColour& c); | |
08dd9b5a | 3400 | |
caac7804 BP |
3401 | /** |
3402 | Set the colour to be used for drawing the selection foreground. | |
23324ae1 | 3403 | */ |
caac7804 | 3404 | void SetSelectionForeground(const wxColour& c); |
23324ae1 FM |
3405 | |
3406 | /** | |
caac7804 | 3407 | Set the selection behaviour of the grid. |
8b9ef005 | 3408 | |
caac7804 BP |
3409 | The existing selection is converted to conform to the new mode if |
3410 | possible and discarded otherwise (e.g. any individual selected cells | |
3411 | are deselected if the new mode allows only the selection of the entire | |
3412 | rows or columns). | |
23324ae1 | 3413 | */ |
caac7804 | 3414 | void SetSelectionMode(wxGridSelectionModes selmode); |
23324ae1 | 3415 | |
caac7804 | 3416 | //@} |
08dd9b5a | 3417 | |
8b9ef005 | 3418 | |
caac7804 BP |
3419 | /** |
3420 | @name Scrolling | |
3421 | */ | |
3422 | //@{ | |
23324ae1 | 3423 | |
23324ae1 | 3424 | /** |
caac7804 BP |
3425 | Returns the number of pixels per horizontal scroll increment. |
3426 | ||
3427 | The default is 15. | |
3428 | ||
3429 | @see GetScrollLineY(), SetScrollLineX(), SetScrollLineY() | |
23324ae1 | 3430 | */ |
caac7804 | 3431 | int GetScrollLineX() const; |
23324ae1 FM |
3432 | |
3433 | /** | |
caac7804 | 3434 | Returns the number of pixels per vertical scroll increment. |
08dd9b5a | 3435 | |
caac7804 | 3436 | The default is 15. |
8b9ef005 | 3437 | |
caac7804 | 3438 | @see GetScrollLineX(), SetScrollLineX(), SetScrollLineY() |
23324ae1 | 3439 | */ |
caac7804 | 3440 | int GetScrollLineY() const; |
23324ae1 FM |
3441 | |
3442 | /** | |
caac7804 BP |
3443 | Returns @true if a cell is either entirely or at least partially |
3444 | visible in the grid window. | |
08dd9b5a | 3445 | |
caac7804 BP |
3446 | By default, the cell must be entirely visible for this function to |
3447 | return @true but if @a wholeCellVisible is @false, the function returns | |
3448 | @true even if the cell is only partially visible. | |
23324ae1 | 3449 | */ |
caac7804 | 3450 | bool IsVisible(int row, int col, bool wholeCellVisible = true) const; |
23324ae1 | 3451 | /** |
caac7804 BP |
3452 | Returns @true if a cell is either entirely or at least partially |
3453 | visible in the grid window. | |
3454 | ||
3455 | By default, the cell must be entirely visible for this function to | |
3456 | return @true but if @a wholeCellVisible is @false, the function returns | |
3457 | @true even if the cell is only partially visible. | |
23324ae1 | 3458 | */ |
caac7804 BP |
3459 | bool IsVisible(const wxGridCellCoords& coords, |
3460 | bool wholeCellVisible = true) const; | |
23324ae1 FM |
3461 | |
3462 | /** | |
caac7804 BP |
3463 | Brings the specified cell into the visible grid cell area with minimal |
3464 | scrolling. | |
23324ae1 | 3465 | |
caac7804 BP |
3466 | Does nothing if the cell is already visible. |
3467 | */ | |
3468 | void MakeCellVisible(int row, int col); | |
23324ae1 | 3469 | /** |
caac7804 BP |
3470 | Brings the specified cell into the visible grid cell area with minimal |
3471 | scrolling. | |
3472 | ||
3473 | Does nothing if the cell is already visible. | |
23324ae1 | 3474 | */ |
caac7804 | 3475 | void MakeCellVisible(const wxGridCellCoords& coords); |
23324ae1 FM |
3476 | |
3477 | /** | |
caac7804 | 3478 | Sets the number of pixels per horizontal scroll increment. |
08dd9b5a | 3479 | |
caac7804 | 3480 | The default is 15. |
8b9ef005 | 3481 | |
caac7804 | 3482 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineY() |
23324ae1 | 3483 | */ |
caac7804 | 3484 | void SetScrollLineX(int x); |
23324ae1 FM |
3485 | |
3486 | /** | |
caac7804 | 3487 | Sets the number of pixels per vertical scroll increment. |
08dd9b5a | 3488 | |
caac7804 | 3489 | The default is 15. |
8b9ef005 | 3490 | |
caac7804 | 3491 | @see GetScrollLineX(), GetScrollLineY(), SetScrollLineX() |
23324ae1 | 3492 | */ |
caac7804 | 3493 | void SetScrollLineY(int y); |
23324ae1 | 3494 | |
caac7804 | 3495 | //@} |
08dd9b5a | 3496 | |
23324ae1 | 3497 | |
caac7804 BP |
3498 | /** |
3499 | @name Cell and Device Coordinate Translation | |
3500 | */ | |
3501 | //@{ | |
23324ae1 FM |
3502 | |
3503 | /** | |
caac7804 | 3504 | Convert grid cell coordinates to grid window pixel coordinates. |
8b9ef005 | 3505 | |
caac7804 BP |
3506 | This function returns the rectangle that encloses the block of cells |
3507 | limited by @a topLeft and @a bottomRight cell in device coords and | |
3508 | clipped to the client size of the grid window. | |
8b9ef005 | 3509 | |
caac7804 | 3510 | @see CellToRect() |
23324ae1 | 3511 | */ |
caac7804 BP |
3512 | wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft, |
3513 | const wxGridCellCoords& bottomRight) const; | |
23324ae1 FM |
3514 | |
3515 | /** | |
caac7804 BP |
3516 | Return the rectangle corresponding to the grid cell's size and position |
3517 | in logical coordinates. | |
08dd9b5a | 3518 | |
caac7804 BP |
3519 | @see BlockToDeviceRect() |
3520 | */ | |
3521 | wxRect CellToRect(int row, int col) const; | |
3522 | /** | |
3523 | Return the rectangle corresponding to the grid cell's size and position | |
3524 | in logical coordinates. | |
08dd9b5a | 3525 | |
caac7804 | 3526 | @see BlockToDeviceRect() |
23324ae1 | 3527 | */ |
882678eb | 3528 | wxRect CellToRect(const wxGridCellCoords& coords) const; |
23324ae1 | 3529 | |
23324ae1 | 3530 | /** |
caac7804 BP |
3531 | Returns the column at the given pixel position. |
3532 | ||
3533 | @param x | |
3534 | The x position to evaluate. | |
3535 | @param clipToMinMax | |
3536 | If @true, rather than returning @c wxNOT_FOUND, it returns either | |
3537 | the first or last column depending on whether @a x is too far to | |
3538 | the left or right respectively. | |
3539 | @return | |
3540 | The column index or @c wxNOT_FOUND. | |
23324ae1 | 3541 | */ |
caac7804 | 3542 | int XToCol(int x, bool clipToMinMax = false) const; |
23324ae1 FM |
3543 | |
3544 | /** | |
caac7804 BP |
3545 | Returns the column whose right hand edge is close to the given logical |
3546 | @a x position. | |
3547 | ||
3548 | If no column edge is near to this position @c wxNOT_FOUND is returned. | |
23324ae1 | 3549 | */ |
caac7804 | 3550 | int XToEdgeOfCol(int x) const; |
23324ae1 | 3551 | |
23324ae1 | 3552 | /** |
caac7804 BP |
3553 | Translates logical pixel coordinates to the grid cell coordinates. |
3554 | ||
3555 | Notice that this function expects logical coordinates on input so if | |
3556 | you use this function in a mouse event handler you need to translate | |
3557 | the mouse position, which is expressed in device coordinates, to | |
3558 | logical ones. | |
3559 | ||
3560 | @see XToCol(), YToRow() | |
3561 | */ | |
3562 | wxGridCellCoords XYToCell(int x, int y) const; | |
3563 | /** | |
3564 | Translates logical pixel coordinates to the grid cell coordinates. | |
3565 | ||
3566 | Notice that this function expects logical coordinates on input so if | |
3567 | you use this function in a mouse event handler you need to translate | |
3568 | the mouse position, which is expressed in device coordinates, to | |
3569 | logical ones. | |
3570 | ||
3571 | @see XToCol(), YToRow() | |
3572 | */ | |
3573 | wxGridCellCoords XYToCell(const wxPoint& pos) const; | |
3574 | // XYToCell(int, int, wxGridCellCoords&) overload is intentionally | |
3575 | // undocumented, using it is ugly and non-const reference parameters are | |
3576 | // not used in wxWidgets API | |
08dd9b5a | 3577 | |
8b9ef005 | 3578 | /** |
caac7804 BP |
3579 | Returns the row whose bottom edge is close to the given logical @a y |
3580 | position. | |
3581 | ||
3582 | If no row edge is near to this position @c wxNOT_FOUND is returned. | |
23324ae1 | 3583 | */ |
caac7804 | 3584 | int YToEdgeOfRow(int y) const; |
23324ae1 FM |
3585 | |
3586 | /** | |
caac7804 | 3587 | Returns the grid row that corresponds to the logical @a y coordinate. |
08dd9b5a | 3588 | |
caac7804 | 3589 | Returns @c wxNOT_FOUND if there is no row at the @a y position. |
8b9ef005 | 3590 | */ |
caac7804 BP |
3591 | int YToRow(int y, bool clipToMinMax = false) const; |
3592 | ||
3593 | //@} | |
3594 | ||
08dd9b5a | 3595 | |
8b9ef005 | 3596 | /** |
caac7804 BP |
3597 | @name Miscellaneous Functions |
3598 | */ | |
3599 | //@{ | |
8b9ef005 | 3600 | |
caac7804 BP |
3601 | /** |
3602 | Appends one or more new columns to the right of the grid. | |
3603 | ||
3604 | The @a updateLabels argument is not used at present. If you are using a | |
3605 | derived grid table class you will need to override | |
3606 | wxGridTableBase::AppendCols(). See InsertCols() for further | |
3607 | information. | |
3608 | ||
3609 | @return @true on success or @false if appending columns failed. | |
23324ae1 | 3610 | */ |
caac7804 | 3611 | bool AppendCols(int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
3612 | |
3613 | /** | |
caac7804 | 3614 | Appends one or more new rows to the bottom of the grid. |
08dd9b5a | 3615 | |
caac7804 BP |
3616 | The @a updateLabels argument is not used at present. If you are using a |
3617 | derived grid table class you will need to override | |
3618 | wxGridTableBase::AppendRows(). See InsertRows() for further | |
3619 | information. | |
23324ae1 | 3620 | |
caac7804 | 3621 | @return @true on success or @false if appending rows failed. |
23324ae1 | 3622 | */ |
caac7804 | 3623 | bool AppendRows(int numRows = 1, bool updateLabels = true); |
23324ae1 | 3624 | |
23324ae1 | 3625 | /** |
caac7804 BP |
3626 | Return @true if the horizontal grid lines stop at the last column |
3627 | boundary or @false if they continue to the end of the window. | |
3c4f71cc | 3628 | |
caac7804 BP |
3629 | The default is to clip grid lines. |
3630 | ||
3631 | @see ClipHorzGridLines(), AreVertGridLinesClipped() | |
3632 | */ | |
3633 | bool AreHorzGridLinesClipped() const; | |
23324ae1 FM |
3634 | |
3635 | /** | |
caac7804 BP |
3636 | Return @true if the vertical grid lines stop at the last row |
3637 | boundary or @false if they continue to the end of the window. | |
8b9ef005 | 3638 | |
caac7804 BP |
3639 | The default is to clip grid lines. |
3640 | ||
3641 | @see ClipVertGridLines(), AreHorzGridLinesClipped() | |
3642 | */ | |
3643 | bool AreVertGridLinesClipped() const; | |
23324ae1 FM |
3644 | |
3645 | /** | |
caac7804 | 3646 | Increments the grid's batch count. |
08dd9b5a | 3647 | |
caac7804 BP |
3648 | When the count is greater than zero repainting of the grid is |
3649 | suppressed. Each call to BeginBatch must be matched by a later call to | |
3650 | EndBatch(). Code that does a lot of grid modification can be enclosed | |
3651 | between BeginBatch() and EndBatch() calls to avoid screen flicker. The | |
3652 | final EndBatch() call will cause the grid to be repainted. | |
3653 | ||
3654 | Notice that you should use wxGridUpdateLocker which ensures that there | |
3655 | is always a matching EndBatch() call for this BeginBatch() if possible | |
3656 | instead of calling this method directly. | |
8b9ef005 | 3657 | */ |
caac7804 | 3658 | void BeginBatch(); |
08dd9b5a | 3659 | |
8b9ef005 | 3660 | /** |
caac7804 | 3661 | Clears all data in the underlying grid table and repaints the grid. |
8b9ef005 | 3662 | |
caac7804 BP |
3663 | The table is not deleted by this function. If you are using a derived |
3664 | table class then you need to override wxGridTableBase::Clear() for this | |
3665 | function to have any effect. | |
23324ae1 | 3666 | */ |
caac7804 | 3667 | void ClearGrid(); |
23324ae1 FM |
3668 | |
3669 | /** | |
caac7804 BP |
3670 | Change whether the horizontal grid lines are clipped by the end of the |
3671 | last column. | |
8b9ef005 | 3672 | |
caac7804 BP |
3673 | By default the grid lines are not drawn beyond the end of the last |
3674 | column but after calling this function with @a clip set to @false they | |
3675 | will be drawn across the entire grid window. | |
3676 | ||
3677 | @see AreHorzGridLinesClipped(), ClipVertGridLines() | |
3678 | */ | |
3679 | void ClipHorzGridLines(bool clip); | |
23324ae1 FM |
3680 | |
3681 | /** | |
caac7804 BP |
3682 | Change whether the vertical grid lines are clipped by the end of the |
3683 | last row. | |
08dd9b5a | 3684 | |
caac7804 BP |
3685 | By default the grid lines are not drawn beyond the end of the last |
3686 | row but after calling this function with @a clip set to @false they | |
3687 | will be drawn across the entire grid window. | |
3688 | ||
3689 | @see AreVertGridLinesClipped(), ClipHorzGridLines() | |
3690 | */ | |
3691 | void ClipVertGridLines(bool clip); | |
08dd9b5a | 3692 | |
8b9ef005 | 3693 | /** |
caac7804 BP |
3694 | Deletes one or more columns from a grid starting at the specified |
3695 | position. | |
8b9ef005 | 3696 | |
caac7804 BP |
3697 | The @a updateLabels argument is not used at present. If you are using a |
3698 | derived grid table class you will need to override | |
3699 | wxGridTableBase::DeleteCols(). See InsertCols() for further | |
3700 | information. | |
8b9ef005 | 3701 | |
caac7804 | 3702 | @return @true on success or @false if deleting columns failed. |
23324ae1 | 3703 | */ |
caac7804 | 3704 | bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 | 3705 | |
23324ae1 | 3706 | /** |
caac7804 BP |
3707 | Deletes one or more rows from a grid starting at the specified |
3708 | position. | |
8b9ef005 | 3709 | |
caac7804 BP |
3710 | The @a updateLabels argument is not used at present. If you are using a |
3711 | derived grid table class you will need to override | |
3712 | wxGridTableBase::DeleteRows(). See InsertRows() for further | |
3713 | information. | |
8b9ef005 | 3714 | |
caac7804 | 3715 | @return @true on success or @false if appending rows failed. |
23324ae1 | 3716 | */ |
caac7804 | 3717 | bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true); |
23324ae1 | 3718 | |
23324ae1 | 3719 | /** |
caac7804 BP |
3720 | Decrements the grid's batch count. |
3721 | ||
3722 | When the count is greater than zero repainting of the grid is | |
3723 | suppressed. Each previous call to BeginBatch() must be matched by a | |
3724 | later call to EndBatch(). Code that does a lot of grid modification can | |
3725 | be enclosed between BeginBatch() and EndBatch() calls to avoid screen | |
3726 | flicker. The final EndBatch() will cause the grid to be repainted. | |
3727 | ||
3728 | @see wxGridUpdateLocker | |
8b9ef005 | 3729 | */ |
caac7804 | 3730 | void EndBatch(); |
08dd9b5a | 3731 | |
8b9ef005 | 3732 | /** |
caac7804 | 3733 | Overridden wxWindow method. |
8b9ef005 | 3734 | */ |
caac7804 | 3735 | virtual void Fit(); |
08dd9b5a | 3736 | |
8b9ef005 | 3737 | /** |
caac7804 | 3738 | Causes immediate repainting of the grid. |
8b9ef005 | 3739 | |
caac7804 | 3740 | Use this instead of the usual wxWindow::Refresh(). |
23324ae1 | 3741 | */ |
caac7804 | 3742 | void ForceRefresh(); |
23324ae1 FM |
3743 | |
3744 | /** | |
caac7804 BP |
3745 | Returns the number of times that BeginBatch() has been called without |
3746 | (yet) matching calls to EndBatch(). While the grid's batch count is | |
3747 | greater than zero the display will not be updated. | |
3748 | */ | |
3749 | int GetBatchCount(); | |
08dd9b5a | 3750 | |
caac7804 BP |
3751 | /** |
3752 | Returns the total number of grid columns. | |
8b9ef005 | 3753 | |
caac7804 | 3754 | This is the same as the number of columns in the underlying grid table. |
23324ae1 | 3755 | */ |
caac7804 | 3756 | int GetNumberCols() const; |
23324ae1 FM |
3757 | |
3758 | /** | |
caac7804 | 3759 | Returns the total number of grid rows. |
08dd9b5a | 3760 | |
caac7804 | 3761 | This is the same as the number of rows in the underlying grid table. |
23324ae1 | 3762 | */ |
caac7804 | 3763 | int GetNumberRows() const; |
23324ae1 FM |
3764 | |
3765 | /** | |
caac7804 BP |
3766 | Returns the attribute for the given cell creating one if necessary. |
3767 | ||
3768 | If the cell already has an attribute, it is returned. Otherwise a new | |
3769 | attribute is created, associated with the cell and returned. In any | |
3770 | case the caller must call DecRef() on the returned pointer. | |
3771 | ||
3772 | This function may only be called if CanHaveAttributes() returns @true. | |
8b9ef005 | 3773 | */ |
caac7804 | 3774 | wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const; |
08dd9b5a | 3775 | |
8b9ef005 | 3776 | /** |
caac7804 | 3777 | Returns a base pointer to the current table object. |
08dd9b5a | 3778 | |
caac7804 | 3779 | The returned pointer is still owned by the grid. |
23324ae1 | 3780 | */ |
caac7804 | 3781 | wxGridTableBase *GetTable() const; |
23324ae1 FM |
3782 | |
3783 | /** | |
caac7804 BP |
3784 | Inserts one or more new columns into a grid with the first new column |
3785 | at the specified position. | |
08dd9b5a | 3786 | |
caac7804 BP |
3787 | Notice that inserting the columns in the grid requires grid table |
3788 | cooperation: when this method is called, grid object begins by | |
3789 | requesting the underlying grid table to insert new columns. If this is | |
3790 | successful the table notifies the grid and the grid updates the | |
3791 | display. For a default grid (one where you have called CreateGrid()) | |
3792 | this process is automatic. If you are using a custom grid table | |
3793 | (specified with SetTable()) then you must override | |
3794 | wxGridTableBase::InsertCols() in your derived table class. | |
3795 | ||
3796 | @param pos | |
3797 | The position which the first newly inserted column will have. | |
3798 | @param numCols | |
3799 | The number of columns to insert. | |
3800 | @param updateLabels | |
3801 | Currently not used. | |
3802 | @return | |
3803 | @true if the columns were successfully inserted, @false if an error | |
3804 | occurred (most likely the table couldn't be updated). | |
23324ae1 | 3805 | */ |
caac7804 | 3806 | bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true); |
23324ae1 FM |
3807 | |
3808 | /** | |
caac7804 BP |
3809 | Inserts one or more new rows into a grid with the first new row at the |
3810 | specified position. | |
8b9ef005 | 3811 | |
caac7804 BP |
3812 | Notice that you must implement wxGridTableBase::InsertRows() if you use |
3813 | a grid with a custom table, please see InsertCols() for more | |
3814 | information. | |
8b9ef005 | 3815 | |
caac7804 BP |
3816 | @param pos |
3817 | The position which the first newly inserted row will have. | |
3818 | @param numRows | |
3819 | The number of rows to insert. | |
3820 | @param updateLabels | |
3821 | Currently not used. | |
3822 | @return | |
3823 | @true if the rows were successfully inserted, @false if an error | |
3824 | occurred (most likely the table couldn't be updated). | |
3825 | */ | |
3826 | bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true); | |
8b9ef005 | 3827 | |
caac7804 BP |
3828 | /** |
3829 | Sets the cell attributes for all cells in the specified column. | |
08dd9b5a | 3830 | |
caac7804 BP |
3831 | For more information about controlling grid cell attributes see the |
3832 | wxGridCellAttr cell attribute class and the @ref overview_grid. | |
3833 | */ | |
3834 | void SetColAttr(int col, wxGridCellAttr* attr); | |
23324ae1 FM |
3835 | |
3836 | /** | |
caac7804 | 3837 | Sets the extra margins used around the grid area. |
08dd9b5a | 3838 | |
caac7804 BP |
3839 | A grid may occupy more space than needed for its data display and |
3840 | this function allows to set how big this extra space is | |
23324ae1 | 3841 | */ |
caac7804 | 3842 | void SetMargins(int extraWidth, int extraHeight); |
23324ae1 FM |
3843 | |
3844 | /** | |
caac7804 | 3845 | Sets the cell attributes for all cells in the specified row. |
08dd9b5a | 3846 | |
caac7804 BP |
3847 | The grid takes ownership of the attribute pointer. |
3848 | ||
3849 | See the wxGridCellAttr class for more information about controlling | |
3850 | cell attributes. | |
23324ae1 | 3851 | */ |
caac7804 BP |
3852 | void SetRowAttr(int row, wxGridCellAttr* attr); |
3853 | ||
3854 | //@} | |
23324ae1 | 3855 | |
11393d29 VZ |
3856 | |
3857 | /** | |
3858 | @name Sorting support. | |
3859 | ||
3860 | wxGrid doesn't provide any support for sorting the data but it does | |
3861 | generate events allowing the user code to sort it and supports | |
3862 | displaying the sort indicator in the column used for sorting. | |
3863 | ||
3864 | To use wxGrid sorting support you need to handle wxEVT_GRID_COL_SORT | |
3865 | event (and not veto it) and resort the data displayed in the grid. The | |
3866 | grid will automatically update the sorting indicator on the column | |
3867 | which was clicked. | |
3868 | ||
3869 | You can also call the functions in this section directly to update the | |
3870 | sorting indicator. Once again, they don't do anything with the grid | |
3871 | data, it remains your responsibility to actually sort it appropriately. | |
3872 | */ | |
3873 | //@{ | |
3874 | ||
3875 | /** | |
3876 | Return the column in which the sorting indicator is currently | |
3877 | displayed. | |
3878 | ||
3879 | Returns @c wxNOT_FOUND if sorting indicator is not currently displayed | |
3880 | at all. | |
3881 | ||
3882 | @see SetSortingColumn() | |
3883 | */ | |
3884 | int GetSortingColumn() const; | |
3885 | ||
3886 | /** | |
3887 | Return @true if this column is currently used for sorting. | |
3888 | ||
3889 | @see GetSortingColumn() | |
3890 | */ | |
3891 | bool IsSortingBy(int col) const; | |
3892 | ||
3893 | /** | |
3894 | Return @true if the current sorting order is ascending or @false if it | |
3895 | is descending. | |
3896 | ||
3897 | It only makes sense to call this function if GetSortingColumn() returns | |
3898 | a valid column index and not @c wxNOT_FOUND. | |
3899 | ||
3900 | @see SetSortingColumn() | |
3901 | */ | |
3902 | bool IsSortOrderAscending() const; | |
3903 | ||
3904 | /** | |
3905 | Set the column to display the sorting indicator in and its direction. | |
3906 | ||
3907 | @param col | |
3908 | The column to display the sorting indicator in or @c wxNOT_FOUND to | |
3909 | remove any currently displayed sorting indicator. | |
3910 | @param ascending | |
3911 | If @true, display the ascending sort indicator, otherwise display | |
3912 | the descending sort indicator. | |
3913 | ||
3914 | @see GetSortingColumn(), IsSortOrderAscending() | |
3915 | */ | |
3916 | void SetSortingColumn(int col, bool ascending = true); | |
3917 | ||
3918 | /** | |
3919 | Remove any currently shown sorting indicator. | |
3920 | ||
3921 | This is equivalent to calling SetSortingColumn() with @c wxNOT_FOUND | |
3922 | first argument. | |
3923 | */ | |
3924 | void UnsetSortingColumn(); | |
3925 | //@} | |
3039ade9 | 3926 | |
882678eb | 3927 | |
3039ade9 VZ |
3928 | /** |
3929 | @name Accessors for component windows. | |
3930 | ||
3931 | Return the various child windows of wxGrid. | |
3932 | ||
3933 | wxGrid is an empty parent window for 4 children representing the column | |
3934 | labels window (top), the row labels window (left), the corner window | |
3935 | (top left) and the main grid window. It may be necessary to use these | |
3936 | individual windows and not the wxGrid window itself if you need to | |
3937 | handle events for them (this can be done using wxEvtHandler::Connect() | |
3938 | or wxWindow::PushEventHandler()) or do something else requiring the use | |
3939 | of the correct window pointer. Notice that you should not, however, | |
3940 | change these windows (e.g. reposition them or draw over them) because | |
3941 | they are managed by wxGrid itself. | |
3942 | */ | |
3943 | //@{ | |
3944 | ||
3945 | /** | |
3946 | Return the main grid window containing the grid cells. | |
3947 | ||
3948 | This window is always shown. | |
3949 | */ | |
3950 | wxWindow *GetGridWindow() const; | |
3951 | ||
3952 | /** | |
3953 | Return the row labels window. | |
3954 | ||
3955 | This window is not shown if the row labels were hidden using | |
3956 | HideRowLabels(). | |
3957 | */ | |
3958 | wxWindow *GetGridRowLabelWindow() const; | |
3959 | ||
3960 | /** | |
3961 | Return the column labels window. | |
3962 | ||
3963 | This window is not shown if the columns labels were hidden using | |
3964 | HideColLabels(). | |
3965 | ||
3966 | Depending on whether UseNativeColHeader() was called or not this can be | |
3967 | either a wxHeaderCtrl or a plain wxWindow. This function returns a valid | |
3968 | window pointer in either case but in the former case you can also use | |
3969 | GetGridColHeader() to access it if you need wxHeaderCtrl-specific | |
3970 | functionality. | |
3971 | */ | |
600e986a | 3972 | wxWindow *GetGridColLabelWindow() const; |
3039ade9 VZ |
3973 | |
3974 | /** | |
3975 | Return the window in the top left grid corner. | |
3976 | ||
3977 | This window is shown only of both columns and row labels are shown and | |
3978 | normally doesn't contain anything. Clicking on it is handled by wxGrid | |
3979 | however and can be used to select the entire grid. | |
3980 | */ | |
3981 | wxWindow *GetGridCornerLabelWindow() const; | |
3982 | ||
3983 | /** | |
3984 | Return the header control used for column labels display. | |
3985 | ||
3986 | This function can only be called if UseNativeColHeader() had been | |
3987 | called. | |
3988 | */ | |
3989 | wxHeaderCtrl *GetGridColHeader() const; | |
3990 | ||
3991 | //@} | |
882678eb FM |
3992 | |
3993 | protected: | |
3994 | /** | |
3995 | Returns @true if this grid has support for cell attributes. | |
3996 | ||
3997 | The grid supports attributes if it has the associated table which, in | |
3998 | turn, has attributes support, i.e. wxGridTableBase::CanHaveAttributes() | |
3999 | returns @true. | |
4000 | */ | |
4001 | bool CanHaveAttributes() const; | |
4002 | ||
4003 | /** | |
4004 | Get the minimal width of the given column/row. | |
4005 | ||
4006 | The value returned by this function may be different than that returned | |
4007 | by GetColMinimalAcceptableWidth() if SetColMinimalWidth() had been | |
4008 | called for this column. | |
4009 | */ | |
4010 | int GetColMinimalWidth(int col) const; | |
4011 | ||
4012 | /** | |
4013 | Returns the coordinate of the right border specified column. | |
4014 | */ | |
4015 | int GetColRight(int col) const; | |
4016 | ||
4017 | /** | |
4018 | Returns the coordinate of the left border specified column. | |
4019 | */ | |
4020 | int GetColLeft(int col) const; | |
4021 | ||
4022 | /** | |
4023 | Returns the minimal size for the given column. | |
4024 | ||
4025 | The value returned by this function may be different than that returned | |
4026 | by GetRowMinimalAcceptableHeight() if SetRowMinimalHeight() had been | |
4027 | called for this row. | |
4028 | */ | |
4029 | int GetRowMinimalHeight(int col) const; | |
8b9ef005 | 4030 | }; |
23324ae1 | 4031 | |
08dd9b5a | 4032 | |
23324ae1 | 4033 | |
8b9ef005 BP |
4034 | /** |
4035 | @class wxGridUpdateLocker | |
23324ae1 | 4036 | |
8b9ef005 BP |
4037 | This small class can be used to prevent wxGrid from redrawing during its |
4038 | lifetime by calling wxGrid::BeginBatch() in its constructor and | |
4039 | wxGrid::EndBatch() in its destructor. It is typically used in a function | |
4040 | performing several operations with a grid which would otherwise result in | |
4041 | flicker. For example: | |
23324ae1 | 4042 | |
8b9ef005 BP |
4043 | @code |
4044 | void MyFrame::Foo() | |
4045 | { | |
4046 | m_grid = new wxGrid(this, ...); | |
23324ae1 | 4047 | |
8b9ef005 BP |
4048 | wxGridUpdateLocker noUpdates(m_grid); |
4049 | m_grid-AppendColumn(); | |
4050 | // ... many other operations with m_grid ... | |
4051 | m_grid-AppendRow(); | |
08dd9b5a | 4052 | |
8b9ef005 BP |
4053 | // destructor called, grid refreshed |
4054 | } | |
4055 | @endcode | |
08dd9b5a | 4056 | |
8b9ef005 BP |
4057 | Using this class is easier and safer than calling wxGrid::BeginBatch() and |
4058 | wxGrid::EndBatch() because you don't risk missing the call the latter (due | |
4059 | to an exception for example). | |
23324ae1 | 4060 | |
8b9ef005 BP |
4061 | @library{wxadv} |
4062 | @category{grid} | |
4063 | */ | |
4064 | class wxGridUpdateLocker | |
4065 | { | |
4066 | public: | |
23324ae1 | 4067 | /** |
8b9ef005 BP |
4068 | Creates an object preventing the updates of the specified @a grid. The |
4069 | parameter could be @NULL in which case nothing is done. If @a grid is | |
4070 | non-@NULL then the grid must exist for longer than this | |
4071 | wxGridUpdateLocker object itself. | |
08dd9b5a | 4072 | |
8b9ef005 BP |
4073 | The default constructor could be followed by a call to Create() to set |
4074 | the grid object later. | |
23324ae1 | 4075 | */ |
8b9ef005 | 4076 | wxGridUpdateLocker(wxGrid* grid = NULL); |
23324ae1 FM |
4077 | |
4078 | /** | |
8b9ef005 BP |
4079 | Destructor reenables updates for the grid this object is associated |
4080 | with. | |
23324ae1 | 4081 | */ |
8b9ef005 | 4082 | ~wxGridUpdateLocker(); |
23324ae1 FM |
4083 | |
4084 | /** | |
8b9ef005 BP |
4085 | This method can be called if the object had been constructed using the |
4086 | default constructor. It must not be called more than once. | |
4087 | */ | |
4088 | void Create(wxGrid* grid); | |
4089 | }; | |
08dd9b5a | 4090 | |
08dd9b5a | 4091 | |
23324ae1 | 4092 | |
8b9ef005 BP |
4093 | /** |
4094 | @class wxGridEvent | |
08dd9b5a | 4095 | |
8b9ef005 | 4096 | This event class contains information about various grid events. |
8a3e536c | 4097 | |
2b1f9fa0 VZ |
4098 | Notice that all grid event table macros are available in two versions: |
4099 | @c EVT_GRID_XXX and @c EVT_GRID_CMD_XXX. The only difference between the | |
4100 | two is that the former doesn't allow to specify the grid window identifier | |
4101 | and so takes a single parameter, the event handler, but is not suitable if | |
4102 | there is more than one grid control in the window where the event table is | |
4103 | used (as it would catch the events from all the grids). The version with @c | |
4104 | CMD takes the id as first argument and the event handler as the second one | |
4105 | and so can be used with multiple grids as well. Otherwise there are no | |
4106 | difference between the two and only the versions without the id are | |
4107 | documented below for brevity. | |
4108 | ||
8b9ef005 | 4109 | @beginEventTable{wxGridEvent} |
763163a8 VZ |
4110 | @event{EVT_GRID_CELL_CHANGING(func)} |
4111 | The user is about to change the data in a cell. The new cell value as | |
4112 | string is available from GetString() event object method. This event | |
f8f31de6 FM |
4113 | can be vetoed if the change is not allowed. |
4114 | Processes a @c wxEVT_GRID_CELL_CHANGING event type. | |
763163a8 VZ |
4115 | @event{EVT_GRID_CELL_CHANGED(func)} |
4116 | The user changed the data in a cell. The old cell value as string is | |
4117 | available from GetString() event object method. Notice that vetoing | |
4118 | this event still works for backwards compatibility reasons but any new | |
4119 | code should only veto EVT_GRID_CELL_CHANGING event and not this one. | |
4120 | Processes a @c wxEVT_GRID_CELL_CHANGED event type. | |
8b9ef005 BP |
4121 | @event{EVT_GRID_CELL_LEFT_CLICK(func)} |
4122 | The user clicked a cell with the left mouse button. Processes a | |
4123 | @c wxEVT_GRID_CELL_LEFT_CLICK event type. | |
4124 | @event{EVT_GRID_CELL_LEFT_DCLICK(func)} | |
4125 | The user double-clicked a cell with the left mouse button. Processes a | |
4126 | @c wxEVT_GRID_CELL_LEFT_DCLICK event type. | |
4127 | @event{EVT_GRID_CELL_RIGHT_CLICK(func)} | |
4128 | The user clicked a cell with the right mouse button. Processes a | |
4129 | @c wxEVT_GRID_CELL_RIGHT_CLICK event type. | |
4130 | @event{EVT_GRID_CELL_RIGHT_DCLICK(func)} | |
4131 | The user double-clicked a cell with the right mouse button. Processes a | |
4132 | @c wxEVT_GRID_CELL_RIGHT_DCLICK event type. | |
4133 | @event{EVT_GRID_EDITOR_HIDDEN(func)} | |
4134 | The editor for a cell was hidden. Processes a | |
4135 | @c wxEVT_GRID_EDITOR_HIDDEN event type. | |
4136 | @event{EVT_GRID_EDITOR_SHOWN(func)} | |
4137 | The editor for a cell was shown. Processes a | |
4138 | @c wxEVT_GRID_EDITOR_SHOWN event type. | |
4139 | @event{EVT_GRID_LABEL_LEFT_CLICK(func)} | |
4140 | The user clicked a label with the left mouse button. Processes a | |
4141 | @c wxEVT_GRID_LABEL_LEFT_CLICK event type. | |
4142 | @event{EVT_GRID_LABEL_LEFT_DCLICK(func)} | |
4143 | The user double-clicked a label with the left mouse button. Processes a | |
4144 | @c wxEVT_GRID_LABEL_LEFT_DCLICK event type. | |
4145 | @event{EVT_GRID_LABEL_RIGHT_CLICK(func)} | |
4146 | The user clicked a label with the right mouse button. Processes a | |
4147 | @c wxEVT_GRID_LABEL_RIGHT_CLICK event type. | |
4148 | @event{EVT_GRID_LABEL_RIGHT_DCLICK(func)} | |
4149 | The user double-clicked a label with the right mouse button. Processes | |
4150 | a @c wxEVT_GRID_LABEL_RIGHT_DCLICK event type. | |
4151 | @event{EVT_GRID_SELECT_CELL(func)} | |
c6cc8b15 VZ |
4152 | The given cell was made current, either by user or by the program via a |
4153 | call to SetGridCursor() or GoToCell(). Processes a | |
8b9ef005 | 4154 | @c wxEVT_GRID_SELECT_CELL event type. |
cd68daf5 VZ |
4155 | @event{EVT_GRID_COL_MOVE(func)} |
4156 | The user tries to change the order of the columns in the grid by | |
4157 | dragging the column specified by GetCol(). This event can be vetoed to | |
4158 | either prevent the user from reordering the column change completely | |
4159 | (but notice that if you don't want to allow it at all, you simply | |
4160 | shouldn't call wxGrid::EnableDragColMove() in the first place), vetoed | |
4161 | but handled in some way in the handler, e.g. by really moving the | |
4162 | column to the new position at the associated table level, or allowed to | |
4163 | proceed in which case wxGrid::SetColPos() is used to reorder the | |
4164 | columns display order without affecting the use of the column indices | |
4165 | otherwise. | |
4166 | This event macro corresponds to @c wxEVT_GRID_COL_MOVE event type. | |
11393d29 VZ |
4167 | @event{EVT_GRID_COL_SORT(func)} |
4168 | This event is generated when a column is clicked by the user and its | |
4169 | name is explained by the fact that the custom reaction to a click on a | |
4170 | column is to sort the grid contents by this column. However the grid | |
4171 | itself has no special support for sorting and it's up to the handler of | |
4172 | this event to update the associated table. But if the event is handled | |
4173 | (and not vetoed) the grid supposes that the table was indeed resorted | |
4174 | and updates the column to indicate the new sort order and refreshes | |
4175 | itself. | |
11393d29 | 4176 | This event macro corresponds to @c wxEVT_GRID_COL_SORT event type. |
8b9ef005 | 4177 | @endEventTable |
8a3e536c | 4178 | |
8b9ef005 | 4179 | @library{wxadv} |
87638422 | 4180 | @category{grid,events} |
8b9ef005 BP |
4181 | */ |
4182 | class wxGridEvent : public wxNotifyEvent | |
4183 | { | |
4184 | public: | |
4185 | /** | |
4186 | Default constructor. | |
23324ae1 | 4187 | */ |
8b9ef005 | 4188 | wxGridEvent(); |
23324ae1 | 4189 | /** |
8b9ef005 | 4190 | Constructor for initializing all event attributes. |
23324ae1 | 4191 | */ |
8b9ef005 BP |
4192 | wxGridEvent(int id, wxEventType type, wxObject* obj, |
4193 | int row = -1, int col = -1, int x = -1, int y = -1, | |
ccf39540 | 4194 | bool sel = true, const wxKeyboardState& kbd = wxKeyboardState()); |
23324ae1 FM |
4195 | |
4196 | /** | |
8b9ef005 | 4197 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 4198 | */ |
8b9ef005 | 4199 | bool AltDown() const; |
23324ae1 FM |
4200 | |
4201 | /** | |
8b9ef005 | 4202 | Returns @true if the Control key was down at the time of the event. |
23324ae1 | 4203 | */ |
8b9ef005 | 4204 | bool ControlDown() const; |
23324ae1 FM |
4205 | |
4206 | /** | |
8b9ef005 | 4207 | Column at which the event occurred. |
23324ae1 | 4208 | */ |
8b9ef005 | 4209 | virtual int GetCol(); |
23324ae1 FM |
4210 | |
4211 | /** | |
8b9ef005 | 4212 | Position in pixels at which the event occurred. |
23324ae1 | 4213 | */ |
8b9ef005 | 4214 | wxPoint GetPosition(); |
23324ae1 FM |
4215 | |
4216 | /** | |
8b9ef005 | 4217 | Row at which the event occurred. |
23324ae1 | 4218 | */ |
8b9ef005 | 4219 | virtual int GetRow(); |
23324ae1 FM |
4220 | |
4221 | /** | |
8b9ef005 | 4222 | Returns @true if the Meta key was down at the time of the event. |
23324ae1 | 4223 | */ |
8b9ef005 | 4224 | bool MetaDown() const; |
23324ae1 FM |
4225 | |
4226 | /** | |
8b9ef005 BP |
4227 | Returns @true if the user is selecting grid cells, or @false if |
4228 | deselecting. | |
23324ae1 | 4229 | */ |
8b9ef005 | 4230 | bool Selecting(); |
23324ae1 FM |
4231 | |
4232 | /** | |
8b9ef005 | 4233 | Returns @true if the Shift key was down at the time of the event. |
23324ae1 | 4234 | */ |
8b9ef005 BP |
4235 | bool ShiftDown() const; |
4236 | }; | |
23324ae1 | 4237 | |
08dd9b5a | 4238 | |
8b9ef005 BP |
4239 | |
4240 | /** | |
4241 | @class wxGridSizeEvent | |
4242 | ||
4243 | This event class contains information about a row/column resize event. | |
4244 | ||
4245 | @beginEventTable{wxGridSizeEvent} | |
8b9ef005 | 4246 | @event{EVT_GRID_CMD_COL_SIZE(id, func)} |
27bb2c8c VZ |
4247 | The user resized a column, corresponds to @c wxEVT_GRID_COL_SIZE event |
4248 | type. | |
8b9ef005 | 4249 | @event{EVT_GRID_CMD_ROW_SIZE(id, func)} |
27bb2c8c VZ |
4250 | The user resized a row, corresponds to @c wxEVT_GRID_ROW_SIZE event |
4251 | type. | |
4252 | @event{EVT_GRID_COL_SIZE(func)} | |
4253 | Same as EVT_GRID_CMD_COL_SIZE() but uses `wxID_ANY` id. | |
4254 | @event{EVT_GRID_ROW_SIZE(func)} | |
4255 | Same as EVT_GRID_CMD_ROW_SIZE() but uses `wxID_ANY` id. | |
8b9ef005 BP |
4256 | @endEventTable |
4257 | ||
4258 | @library{wxadv} | |
87638422 | 4259 | @category{grid,events} |
8b9ef005 BP |
4260 | */ |
4261 | class wxGridSizeEvent : public wxNotifyEvent | |
4262 | { | |
4263 | public: | |
4264 | /** | |
4265 | Default constructor. | |
23324ae1 | 4266 | */ |
8b9ef005 | 4267 | wxGridSizeEvent(); |
23324ae1 | 4268 | /** |
8b9ef005 | 4269 | Constructor for initializing all event attributes. |
23324ae1 | 4270 | */ |
8b9ef005 BP |
4271 | wxGridSizeEvent(int id, wxEventType type, wxObject* obj, |
4272 | int rowOrCol = -1, int x = -1, int y = -1, | |
ccf39540 | 4273 | const wxKeyboardState& kbd = wxKeyboardState()); |
23324ae1 FM |
4274 | |
4275 | /** | |
8b9ef005 | 4276 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 4277 | */ |
8b9ef005 | 4278 | bool AltDown() const; |
23324ae1 FM |
4279 | |
4280 | /** | |
8b9ef005 | 4281 | Returns @true if the Control key was down at the time of the event. |
23324ae1 | 4282 | */ |
8b9ef005 | 4283 | bool ControlDown() const; |
23324ae1 FM |
4284 | |
4285 | /** | |
8b9ef005 | 4286 | Position in pixels at which the event occurred. |
23324ae1 | 4287 | */ |
8b9ef005 | 4288 | wxPoint GetPosition(); |
23324ae1 FM |
4289 | |
4290 | /** | |
8b9ef005 | 4291 | Row or column at that was resized. |
23324ae1 | 4292 | */ |
8b9ef005 | 4293 | int GetRowOrCol(); |
23324ae1 FM |
4294 | |
4295 | /** | |
8b9ef005 | 4296 | Returns @true if the Meta key was down at the time of the event. |
23324ae1 | 4297 | */ |
8b9ef005 | 4298 | bool MetaDown() const; |
23324ae1 FM |
4299 | |
4300 | /** | |
8b9ef005 | 4301 | Returns @true if the Shift key was down at the time of the event. |
23324ae1 | 4302 | */ |
8b9ef005 BP |
4303 | bool ShiftDown() const; |
4304 | }; | |
23324ae1 | 4305 | |
3c4f71cc | 4306 | |
23324ae1 | 4307 | |
8b9ef005 BP |
4308 | /** |
4309 | @class wxGridRangeSelectEvent | |
08dd9b5a | 4310 | |
8b9ef005 BP |
4311 | @beginEventTable{wxGridRangeSelectEvent} |
4312 | @event{EVT_GRID_RANGE_SELECT(func)} | |
4313 | The user selected a group of contiguous cells. Processes a | |
4314 | @c wxEVT_GRID_RANGE_SELECT event type. | |
4315 | @event{EVT_GRID_CMD_RANGE_SELECT(id, func)} | |
4316 | The user selected a group of contiguous cells; variant taking a window | |
4317 | identifier. Processes a @c wxEVT_GRID_RANGE_SELECT event type. | |
4318 | @endEventTable | |
08dd9b5a | 4319 | |
8b9ef005 | 4320 | @library{wxadv} |
87638422 | 4321 | @category{grid,events} |
8b9ef005 BP |
4322 | */ |
4323 | class wxGridRangeSelectEvent : public wxNotifyEvent | |
4324 | { | |
4325 | public: | |
4326 | /** | |
4327 | Default constructor. | |
23324ae1 | 4328 | */ |
8b9ef005 | 4329 | wxGridRangeSelectEvent(); |
23324ae1 | 4330 | /** |
8b9ef005 | 4331 | Constructor for initializing all event attributes. |
23324ae1 | 4332 | */ |
8b9ef005 BP |
4333 | wxGridRangeSelectEvent(int id, wxEventType type, |
4334 | wxObject* obj, | |
4335 | const wxGridCellCoords& topLeft, | |
4336 | const wxGridCellCoords& bottomRight, | |
ccf39540 | 4337 | bool sel = true, const wxKeyboardState& kbd = wxKeyboardState()); |
23324ae1 FM |
4338 | |
4339 | /** | |
8b9ef005 | 4340 | Returns @true if the Alt key was down at the time of the event. |
23324ae1 | 4341 | */ |
8b9ef005 | 4342 | bool AltDown() const; |
23324ae1 FM |
4343 | |
4344 | /** | |
8b9ef005 | 4345 | Returns @true if the Control key was down at the time of the event. |
23324ae1 | 4346 | */ |
8b9ef005 | 4347 | bool ControlDown() const; |
23324ae1 FM |
4348 | |
4349 | /** | |
8b9ef005 | 4350 | Top left corner of the rectangular area that was (de)selected. |
23324ae1 | 4351 | */ |
8b9ef005 | 4352 | wxGridCellCoords GetBottomRightCoords(); |
23324ae1 | 4353 | |
8a3e536c | 4354 | /** |
8b9ef005 BP |
4355 | Bottom row of the rectangular area that was (de)selected. |
4356 | */ | |
4357 | int GetBottomRow(); | |
8a3e536c | 4358 | |
23324ae1 | 4359 | /** |
8b9ef005 | 4360 | Left column of the rectangular area that was (de)selected. |
23324ae1 | 4361 | */ |
8b9ef005 | 4362 | int GetLeftCol(); |
23324ae1 FM |
4363 | |
4364 | /** | |
8b9ef005 | 4365 | Right column of the rectangular area that was (de)selected. |
23324ae1 | 4366 | */ |
8b9ef005 | 4367 | int GetRightCol(); |
5e6e278d | 4368 | |
5e6e278d | 4369 | /** |
8b9ef005 | 4370 | Top left corner of the rectangular area that was (de)selected. |
5e6e278d | 4371 | */ |
8b9ef005 | 4372 | wxGridCellCoords GetTopLeftCoords(); |
5e6e278d FM |
4373 | |
4374 | /** | |
8b9ef005 | 4375 | Top row of the rectangular area that was (de)selected. |
5e6e278d | 4376 | */ |
8b9ef005 | 4377 | int GetTopRow(); |
5e6e278d FM |
4378 | |
4379 | /** | |
8b9ef005 | 4380 | Returns @true if the Meta key was down at the time of the event. |
5e6e278d | 4381 | */ |
8b9ef005 | 4382 | bool MetaDown() const; |
5e6e278d FM |
4383 | |
4384 | /** | |
8b9ef005 | 4385 | Returns @true if the area was selected, @false otherwise. |
5e6e278d | 4386 | */ |
8b9ef005 | 4387 | bool Selecting(); |
5e6e278d FM |
4388 | |
4389 | /** | |
8b9ef005 | 4390 | Returns @true if the Shift key was down at the time of the event. |
5e6e278d | 4391 | */ |
8b9ef005 | 4392 | bool ShiftDown() const; |
23324ae1 FM |
4393 | }; |
4394 | ||
4395 | ||
e54c96f1 | 4396 | |
23324ae1 | 4397 | /** |
8b9ef005 | 4398 | @class wxGridEditorCreatedEvent |
7c913512 | 4399 | |
8b9ef005 BP |
4400 | @beginEventTable{wxGridEditorCreatedEvent} |
4401 | @event{EVT_GRID_EDITOR_CREATED(func)} | |
4402 | The editor for a cell was created. Processes a | |
4403 | @c wxEVT_GRID_EDITOR_CREATED event type. | |
4404 | @event{EVT_GRID_CMD_EDITOR_CREATED(id, func)} | |
4405 | The editor for a cell was created; variant taking a window identifier. | |
4406 | Processes a @c wxEVT_GRID_EDITOR_CREATED event type. | |
4407 | @endEventTable | |
7c913512 | 4408 | |
23324ae1 | 4409 | @library{wxadv} |
87638422 | 4410 | @category{grid,events} |
23324ae1 | 4411 | */ |
8b9ef005 | 4412 | class wxGridEditorCreatedEvent : public wxCommandEvent |
23324ae1 FM |
4413 | { |
4414 | public: | |
4415 | /** | |
4416 | Default constructor. | |
4417 | */ | |
8b9ef005 | 4418 | wxGridEditorCreatedEvent(); |
23324ae1 | 4419 | /** |
8b9ef005 | 4420 | Constructor for initializing all event attributes. |
23324ae1 | 4421 | */ |
8b9ef005 BP |
4422 | wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj, |
4423 | int row, int col, wxControl* ctrl); | |
23324ae1 FM |
4424 | |
4425 | /** | |
8b9ef005 | 4426 | Returns the column at which the event occurred. |
23324ae1 | 4427 | */ |
8b9ef005 | 4428 | int GetCol(); |
7c913512 | 4429 | |
8b9ef005 BP |
4430 | /** |
4431 | Returns the edit control. | |
4432 | */ | |
4433 | wxControl* GetControl(); | |
7c913512 | 4434 | |
8b9ef005 BP |
4435 | /** |
4436 | Returns the row at which the event occurred. | |
4437 | */ | |
4438 | int GetRow(); | |
7c913512 | 4439 | |
23324ae1 | 4440 | /** |
8b9ef005 | 4441 | Sets the column at which the event occurred. |
23324ae1 | 4442 | */ |
8b9ef005 | 4443 | void SetCol(int col); |
23324ae1 FM |
4444 | |
4445 | /** | |
8b9ef005 | 4446 | Sets the edit control. |
23324ae1 | 4447 | */ |
8b9ef005 | 4448 | void SetControl(wxControl* ctrl); |
23324ae1 FM |
4449 | |
4450 | /** | |
8b9ef005 | 4451 | Sets the row at which the event occurred. |
23324ae1 | 4452 | */ |
8b9ef005 | 4453 | void SetRow(int row); |
23324ae1 | 4454 | }; |
e54c96f1 | 4455 |