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