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