]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: property.h | |
3 | // Purpose: interface of wxPGProperty | |
4 | // Author: wxWidgets team | |
de003797 | 5 | // RCS-ID: $Id$ |
1c4293cb VZ |
6 | // Licence: wxWindows license |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | // ----------------------------------------------------------------------- | |
10 | ||
effb029c JS |
11 | /** |
12 | @class wxPropertyGridInterface | |
1c4293cb VZ |
13 | |
14 | Most of the shared property manipulation interface shared by wxPropertyGrid, | |
15 | wxPropertyGridPage, and wxPropertyGridManager is defined in this class. | |
16 | ||
17 | @remarks | |
effb029c JS |
18 | - In separate wxPropertyGrid component this class was known as |
19 | wxPropertyContainerMethods. | |
1c4293cb | 20 | |
bba3f9b5 JS |
21 | - wxPropertyGridInterface's property operation member functions all accept |
22 | a special wxPGPropArg id argument, using which you can refer to properties | |
23 | either by their pointer (for performance) or by their name (for conveniency). | |
24 | ||
1c4293cb VZ |
25 | @library{wxpropgrid} |
26 | @category{propgrid} | |
27 | */ | |
28 | class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface | |
29 | { | |
30 | public: | |
31 | ||
32 | /** Destructor */ | |
33 | virtual ~wxPropertyGridInterface() { } | |
34 | ||
effb029c JS |
35 | /** |
36 | Appends property to the list. wxPropertyGrid assumes ownership of the | |
37 | object. Becomes child of most recently added category. | |
38 | ||
1c4293cb VZ |
39 | @remarks |
40 | - wxPropertyGrid takes the ownership of the property pointer. | |
effb029c JS |
41 | - If appending a category with name identical to a category already in |
42 | the wxPropertyGrid, then newly created category is deleted, and most | |
43 | recently added category (under which properties are appended) is set | |
44 | to the one with same name. This allows easier adding of items to same | |
45 | categories in multiple passes. | |
46 | - Does not automatically redraw the control, so you may need to call | |
47 | Refresh() when calling this function after control has been shown for | |
48 | the first time. | |
1621f192 JS |
49 | - This functions deselects selected property, if any. Validation |
50 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
51 | selection is cleared even if editor had invalid value. | |
1c4293cb VZ |
52 | */ |
53 | wxPGProperty* Append( wxPGProperty* property ); | |
54 | ||
effb029c JS |
55 | /** |
56 | Same as Append(), but appends under given parent property. | |
57 | ||
58 | @param id | |
59 | Name or pointer to parent property. | |
60 | ||
61 | @param newProperty | |
62 | Property to be added. | |
63 | */ | |
64 | wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newProperty ); | |
65 | ||
66 | /** | |
67 | In order to add new items into a property with private children (for | |
0ad10f30 FM |
68 | instance, wxFlagsProperty), you need to call this method. |
69 | After populating has been finished, you need to call EndAddChildren(). | |
1c4293cb | 70 | |
effb029c | 71 | @see EndAddChildren() |
1c4293cb VZ |
72 | */ |
73 | void BeginAddChildren( wxPGPropArg id ); | |
74 | ||
effb029c JS |
75 | /** |
76 | Deletes all properties. | |
1621f192 JS |
77 | |
78 | @remarks This functions deselects selected property, if any. Validation | |
79 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
80 | selection is cleared even if editor had invalid value. | |
1c4293cb VZ |
81 | */ |
82 | virtual void Clear() = 0; | |
83 | ||
effb029c | 84 | /** |
1621f192 JS |
85 | Clears current selection, if any. |
86 | ||
87 | @param validation | |
88 | If set to @false, deselecting the property will always work, | |
89 | even if its editor had invalid value in it. | |
effb029c | 90 | |
1621f192 JS |
91 | @return Returns @true if successful or if there was no selection. May |
92 | fail if validation was enabled and active editor had invalid | |
93 | value. | |
01b5ad3b JS |
94 | |
95 | @remarks In wxPropertyGrid 1.4, this member function used to send | |
96 | wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer | |
97 | does that. | |
98 | ||
99 | @see wxPropertyGrid::SelectProperty() | |
effb029c | 100 | */ |
1621f192 | 101 | bool ClearSelection( bool validation = false); |
1c4293cb | 102 | |
effb029c JS |
103 | /** |
104 | Resets modified status of all properties. | |
1c4293cb | 105 | */ |
effb029c JS |
106 | void ClearModifiedStatus(); |
107 | ||
108 | /** | |
109 | Collapses given category or property with children. | |
1c4293cb | 110 | |
effb029c | 111 | @return Returns @true if actually collapsed. |
1621f192 JS |
112 | |
113 | @remarks This function may deselect selected property, if any. Validation | |
114 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
115 | selection is cleared even if editor had invalid value. | |
1c4293cb VZ |
116 | */ |
117 | bool Collapse( wxPGPropArg id ); | |
118 | ||
effb029c JS |
119 | /** |
120 | Collapses all items that can be collapsed. | |
1c4293cb | 121 | |
1621f192 JS |
122 | @remarks This functions clears selection. Validation failure option |
123 | wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. selection | |
124 | is cleared even if editor had invalid value. | |
1c4293cb | 125 | */ |
effb029c | 126 | bool CollapseAll(); |
1c4293cb | 127 | |
effb029c JS |
128 | /** |
129 | Changes value of a property, as if by user. Use this instead of | |
130 | SetPropertyValue() if you need the value to run through validation | |
131 | process, and also send the property change event. | |
1c4293cb | 132 | |
effb029c | 133 | @return Returns @true if value was successfully changed. |
1c4293cb VZ |
134 | */ |
135 | bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue ); | |
136 | ||
effb029c JS |
137 | /** |
138 | Deletes a property. | |
1621f192 JS |
139 | |
140 | @remarks This functions deselects selected property, if any. Validation | |
141 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
142 | selection is cleared even if editor had invalid value. | |
effb029c | 143 | */ |
1c4293cb VZ |
144 | void DeleteProperty( wxPGPropArg id ); |
145 | ||
effb029c JS |
146 | /** |
147 | Disables a property. | |
148 | */ | |
149 | bool DisableProperty( wxPGPropArg id ); | |
1c4293cb | 150 | |
effb029c | 151 | /** |
0ad10f30 FM |
152 | Returns @true if all property grid data changes have been committed. Usually |
153 | only returns @false if value in active editor has been invalidated by a | |
1c4293cb VZ |
154 | wxValidator. |
155 | */ | |
156 | bool EditorValidate(); | |
157 | ||
effb029c JS |
158 | /** |
159 | Enables or disables property. | |
160 | ||
161 | @param id | |
162 | Name or pointer to a property. | |
effb029c JS |
163 | @param enable |
164 | If @false, property is disabled instead. | |
165 | */ | |
1c4293cb VZ |
166 | bool EnableProperty( wxPGPropArg id, bool enable = true ); |
167 | ||
effb029c JS |
168 | /** |
169 | Called after population of property with fixed children has finished. | |
170 | ||
171 | @see BeginAddChildren() | |
1c4293cb VZ |
172 | */ |
173 | void EndAddChildren( wxPGPropArg id ); | |
174 | ||
effb029c JS |
175 | /** |
176 | Expands given category or property with children. | |
177 | ||
178 | @return Returns @true if actually expanded. | |
1621f192 JS |
179 | |
180 | @remarks This function may deselect selected property, if any. Validation | |
181 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
182 | selection is cleared even if editor had invalid value. | |
1c4293cb VZ |
183 | */ |
184 | bool Expand( wxPGPropArg id ); | |
185 | ||
effb029c JS |
186 | /** |
187 | Expands all items that can be expanded. | |
1621f192 JS |
188 | |
189 | @remarks This functions clears selection. Validation failure option | |
190 | wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. selection | |
191 | is cleared even if editor had invalid value. | |
1c4293cb VZ |
192 | */ |
193 | bool ExpandAll( bool expand = true ); | |
194 | ||
4279fdb4 JS |
195 | /** |
196 | Returns auto-resize proportion of the given column. | |
197 | ||
198 | @see SetColumnProportion() | |
199 | */ | |
200 | int GetColumnProportion( unsigned int column ) const; | |
201 | ||
effb029c JS |
202 | /** |
203 | Returns id of first child of given property. | |
1c4293cb | 204 | |
effb029c JS |
205 | @remarks Does not return private children! |
206 | */ | |
207 | wxPGProperty* GetFirstChild( wxPGPropArg id ); | |
1c4293cb VZ |
208 | |
209 | //@{ | |
0ad10f30 FM |
210 | /** |
211 | Returns iterator class instance. | |
bba3f9b5 | 212 | |
1c4293cb | 213 | @param flags |
bba3f9b5 JS |
214 | See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes |
215 | iteration over everything except private child properties. | |
1c4293cb | 216 | @param firstProp |
0ad10f30 | 217 | Property to start iteration from. If @NULL, then first child of root |
effb029c | 218 | is used. |
bba3f9b5 | 219 | |
0ad10f30 FM |
220 | @beginWxPythonOnly |
221 | <b>wxPython Note:</b> Instead of ++ operator, use Next() method, and | |
222 | instead of * operator, use GetProperty() method. | |
223 | @endWxPythonOnly | |
224 | */ | |
225 | wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, | |
226 | wxPGProperty* firstProp = NULL ); | |
227 | wxPropertyGridConstIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, | |
228 | wxPGProperty* firstProp = NULL ) const; | |
229 | //@} | |
230 | ||
231 | //@{ | |
232 | /** | |
233 | Returns iterator class instance. | |
234 | ||
235 | @param flags | |
236 | See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes | |
237 | iteration over everything except private child properties. | |
1c4293cb | 238 | @param startPos |
effb029c JS |
239 | Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start |
240 | from the first property from the top, and wxBOTTOM means that the | |
241 | iteration will instead begin from bottommost valid item. | |
242 | ||
0ad10f30 | 243 | @beginWxPythonOnly |
effb029c JS |
244 | <b>wxPython Note:</b> Instead of ++ operator, use Next() method, and |
245 | instead of * operator, use GetProperty() method. | |
0ad10f30 | 246 | @endWxPythonOnly |
effb029c | 247 | */ |
effb029c JS |
248 | wxPropertyGridIterator GetIterator( int flags, int startPos ); |
249 | wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const; | |
1c4293cb VZ |
250 | //@} |
251 | ||
effb029c JS |
252 | /** |
253 | Returns id of first item that matches given criteria. | |
254 | ||
1c4293cb | 255 | @param flags |
effb029c | 256 | See @ref propgrid_iterator_flags. |
1c4293cb | 257 | */ |
effb029c | 258 | wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ); |
1c4293cb | 259 | |
effb029c | 260 | /** |
d85635c5 JS |
261 | Returns pointer to a property with given name (case-sensitive). |
262 | If there is no property with such name, @NULL pointer is returned. | |
263 | ||
264 | @remarks Properties which have non-category, non-root parent | |
265 | can not be accessed globally by their name. Instead, use | |
266 | "<property>.<subproperty>" instead of "<subproperty>". | |
1c4293cb | 267 | */ |
0ad10f30 | 268 | wxPGProperty* GetProperty( const wxString& name ) const; |
1c4293cb | 269 | |
effb029c | 270 | /** |
0ad10f30 FM |
271 | Adds to 'targetArr' pointers to properties that have given flags 'flags' set. |
272 | However, if @a 'inverse' is set to @true, then only properties without | |
273 | given flags are stored. | |
effb029c | 274 | |
0ad10f30 FM |
275 | @param targetArr |
276 | @todo docme | |
1c4293cb | 277 | @param flags |
effb029c | 278 | Property flags to use. |
0ad10f30 FM |
279 | @param inverse |
280 | @todo docme | |
1c4293cb | 281 | @param iterFlags |
effb029c JS |
282 | Iterator flags to use. Default is everything expect private children. |
283 | See @ref propgrid_iterator_flags. | |
1c4293cb VZ |
284 | */ |
285 | void GetPropertiesWithFlag( wxArrayPGProperty* targetArr, | |
286 | wxPGProperty::FlagType flags, | |
287 | bool inverse = false, | |
288 | int iterFlags = (wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_HIDDEN|wxPG_ITERATE_CATEGORIES) ) const; | |
289 | ||
effb029c JS |
290 | /** |
291 | Returns value of given attribute. If none found, returns wxNullVariant. | |
1c4293cb | 292 | */ |
effb029c | 293 | wxVariant GetPropertyAttribute( wxPGPropArg id, const wxString& attrName ) const; |
1c4293cb | 294 | |
e2ca6599 JS |
295 | /** |
296 | Returns background colour of first cell of a property. | |
297 | */ | |
298 | wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const; | |
299 | ||
effb029c JS |
300 | /** |
301 | Returns pointer of property's nearest parent category. If no category | |
0ad10f30 | 302 | found, returns @NULL. |
1c4293cb | 303 | */ |
effb029c | 304 | wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const; |
1c4293cb VZ |
305 | |
306 | /** Returns client data (void*) of a property. */ | |
effb029c | 307 | void* GetPropertyClientData( wxPGPropArg id ) const; |
1c4293cb | 308 | |
effb029c | 309 | /** |
0ad10f30 | 310 | Returns first property which label matches given string. @NULL if none |
effb029c JS |
311 | found. Note that this operation is very slow when compared to |
312 | GetPropertyByName(). | |
1c4293cb VZ |
313 | */ |
314 | wxPGProperty* GetPropertyByLabel( const wxString& label ) const; | |
315 | ||
effb029c | 316 | /** |
d85635c5 JS |
317 | Returns pointer to a property with given name (case-sensitive). |
318 | If there is no property with such name, @NULL pointer is returned. | |
319 | ||
320 | @remarks Properties which have non-category, non-root parent | |
321 | can not be accessed globally by their name. Instead, use | |
322 | "<property>.<subproperty>" instead of "<subproperty>". | |
1c4293cb VZ |
323 | */ |
324 | wxPGProperty* GetPropertyByName( const wxString& name ) const; | |
325 | ||
effb029c JS |
326 | /** |
327 | Returns child property 'subname' of property 'name'. Same as | |
1c4293cb VZ |
328 | calling GetPropertyByName("name.subname"), albeit slightly faster. |
329 | */ | |
effb029c JS |
330 | wxPGProperty* GetPropertyByName( const wxString& name, |
331 | const wxString& subname ) const; | |
1c4293cb | 332 | |
effb029c JS |
333 | /** |
334 | Returns property's editor. | |
335 | */ | |
336 | const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const; | |
1c4293cb | 337 | |
effb029c JS |
338 | /** |
339 | Returns help string associated with a property. | |
340 | */ | |
341 | wxString GetPropertyHelpString( wxPGPropArg id ) const; | |
1c4293cb | 342 | |
effb029c | 343 | /** |
0ad10f30 | 344 | Returns property's custom value image (@NULL of none). |
effb029c JS |
345 | */ |
346 | wxBitmap* GetPropertyImage( wxPGPropArg id ) const; | |
1c4293cb VZ |
347 | |
348 | /** Returns label of a property. */ | |
effb029c | 349 | const wxString& GetPropertyLabel( wxPGPropArg id ); |
1c4293cb | 350 | |
effb029c JS |
351 | /** Returns property's name, by which it is globally accessible. */ |
352 | wxString GetPropertyName( wxPGProperty* property ); | |
1c4293cb | 353 | |
e2ca6599 JS |
354 | /** |
355 | Returns text colour of first cell of a property. | |
356 | */ | |
357 | wxColour GetPropertyTextColour( wxPGPropArg id ) const; | |
358 | ||
effb029c JS |
359 | /** |
360 | Returns validator of a property as a reference, which you | |
1c4293cb VZ |
361 | can pass to any number of SetPropertyValidator. |
362 | */ | |
effb029c | 363 | wxValidator* GetPropertyValidator( wxPGPropArg id ); |
1c4293cb | 364 | |
effb029c JS |
365 | /** |
366 | Returns property's value as wxVariant. | |
1c4293cb VZ |
367 | |
368 | If property value is unspecified, Null variant is returned. | |
369 | */ | |
effb029c | 370 | wxVariant GetPropertyValue( wxPGPropArg id ); |
1c4293cb | 371 | |
effb029c JS |
372 | /** Return's property's value as wxArrayInt. */ |
373 | wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const; | |
374 | ||
375 | /** Returns property's value as wxArrayString. */ | |
376 | wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const; | |
377 | ||
378 | /** Returns property's value as bool */ | |
1c4293cb | 379 | bool GetPropertyValueAsBool( wxPGPropArg id ) const; |
1c4293cb | 380 | |
effb029c JS |
381 | /** Return's property's value as wxDateTime. */ |
382 | wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const; | |
1c4293cb | 383 | |
effb029c JS |
384 | /** Returns property's value as double-precision floating point number. */ |
385 | double GetPropertyValueAsDouble( wxPGPropArg id ) const; | |
1c4293cb | 386 | |
effb029c JS |
387 | /** Returns property's value as integer */ |
388 | int GetPropertyValueAsInt( wxPGPropArg id ) const; | |
1c4293cb | 389 | |
effb029c JS |
390 | /** Returns property's value as integer */ |
391 | long GetPropertyValueAsLong( wxPGPropArg id ) const; | |
1c4293cb | 392 | |
effb029c JS |
393 | /** Returns property's value as native signed 64-bit integer. */ |
394 | wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const; | |
1c4293cb | 395 | |
effb029c JS |
396 | /** |
397 | Returns property's value as wxString. If property does not | |
398 | use string value type, then its value is converted using | |
399 | wxPGProperty::GetValueAsString(). | |
400 | */ | |
401 | wxString GetPropertyValueAsString( wxPGPropArg id ) const; | |
1c4293cb | 402 | |
effb029c JS |
403 | /** Returns property's value as unsigned integer */ |
404 | unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const; | |
1c4293cb | 405 | |
effb029c JS |
406 | /** Returns property's value as native unsigned 64-bit integer. */ |
407 | wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const; | |
408 | ||
409 | /** | |
410 | Returns a wxVariant list containing wxVariant versions of all | |
1c4293cb | 411 | property values. Order is not guaranteed. |
effb029c | 412 | |
0ad10f30 FM |
413 | @param listname |
414 | @todo docme | |
415 | @param baseparent | |
416 | @todo docme | |
1c4293cb | 417 | @param flags |
effb029c JS |
418 | Use wxPG_KEEP_STRUCTURE to retain category structure; each sub |
419 | category will be its own wxVariantList of wxVariant. | |
420 | ||
421 | Use wxPG_INC_ATTRIBUTES to include property attributes as well. | |
422 | Each attribute will be stored as list variant named | |
423 | "@@<propname>@@attr." | |
1c4293cb VZ |
424 | */ |
425 | wxVariant GetPropertyValues( const wxString& listname = wxEmptyString, | |
0ad10f30 | 426 | wxPGProperty* baseparent = NULL, long flags = 0 ) const; |
1c4293cb | 427 | |
fc72fab6 JS |
428 | /** |
429 | Returns list of currently selected properties. | |
430 | ||
431 | @remarks wxArrayPGProperty should be compatible with std::vector API. | |
432 | */ | |
433 | const wxArrayPGProperty& GetSelectedProperties() const; | |
434 | ||
435 | /** | |
436 | Returns currently selected property. NULL if none. | |
437 | ||
438 | @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this | |
439 | member function returns the focused property, that is the | |
440 | one which can have active editor. | |
441 | */ | |
effb029c | 442 | wxPGProperty* GetSelection() const; |
1c4293cb | 443 | |
effb029c JS |
444 | /** |
445 | Similar to GetIterator(), but instead returns wxPGVIterator instance, | |
1c4293cb VZ |
446 | which can be useful for forward-iterating through arbitrary property |
447 | containers. | |
448 | ||
449 | @param flags | |
bba3f9b5 JS |
450 | See @ref propgrid_iterator_flags. |
451 | ||
effb029c JS |
452 | <b>wxPython Note:</b> Instead of ++ operator, use Next() method, and |
453 | instead of * operator, use GetProperty() method. | |
1c4293cb VZ |
454 | */ |
455 | virtual wxPGVIterator GetVIterator( int flags ) const; | |
456 | ||
effb029c JS |
457 | /** |
458 | Hides or reveals a property. | |
459 | ||
0ad10f30 FM |
460 | @param id |
461 | @todo docme | |
1c4293cb | 462 | @param hide |
effb029c | 463 | If @true, hides property, otherwise reveals it. |
1c4293cb | 464 | @param flags |
effb029c JS |
465 | By default changes are applied recursively. Set this parameter |
466 | wxPG_DONT_RECURSE to prevent this. | |
1c4293cb VZ |
467 | */ |
468 | bool HideProperty( wxPGPropArg id, bool hide = true, int flags = wxPG_RECURSE ); | |
469 | ||
effb029c JS |
470 | /** |
471 | Initializes *all* property types. Causes references to most object | |
1c4293cb VZ |
472 | files in the library, so calling this may cause significant increase |
473 | in executable size when linking with static library. | |
474 | */ | |
475 | static void InitAllTypeHandlers(); | |
476 | ||
0ad10f30 FM |
477 | /** |
478 | Inserts property to the property container. | |
1c4293cb VZ |
479 | |
480 | @param priorThis | |
effb029c JS |
481 | New property is inserted just prior to this. Available only |
482 | in the first variant. There are two versions of this function | |
483 | to allow this parameter to be either an id or name to | |
484 | a property. | |
effb029c JS |
485 | @param newProperty |
486 | Pointer to the inserted property. wxPropertyGrid will take | |
487 | ownership of this object. | |
1c4293cb | 488 | |
effb029c | 489 | @return Returns newProperty. |
1c4293cb VZ |
490 | |
491 | @remarks | |
492 | ||
493 | - wxPropertyGrid takes the ownership of the property pointer. | |
494 | ||
495 | - While Append may be faster way to add items, make note that when | |
496 | both types of data storage (categoric and | |
497 | non-categoric) are active, Insert becomes even more slow. This is | |
498 | especially true if current mode is non-categoric. | |
499 | ||
1621f192 JS |
500 | - This functions deselects selected property, if any. Validation |
501 | failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie. | |
502 | selection is cleared even if editor had invalid value. | |
503 | ||
1c4293cb VZ |
504 | Example of use: |
505 | ||
506 | @code | |
507 | ||
508 | // append category | |
509 | wxPGProperty* my_cat_id = propertygrid->Append( new wxPropertyCategory("My Category") ); | |
510 | ||
511 | ... | |
512 | ||
513 | // insert into category - using second variant | |
514 | wxPGProperty* my_item_id_1 = propertygrid->Insert( my_cat_id, 0, new wxStringProperty("My String 1") ); | |
515 | ||
516 | // insert before to first item - using first variant | |
517 | wxPGProperty* my_item_id_2 = propertygrid->Insert( my_item_id, new wxStringProperty("My String 2") ); | |
518 | ||
519 | @endcode | |
1c4293cb | 520 | */ |
effb029c | 521 | wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newProperty ); |
0ad10f30 FM |
522 | |
523 | /** | |
524 | Inserts property to the property container. | |
525 | See the other overload for more details. | |
526 | ||
527 | @param parent | |
528 | New property is inserted under this category. Available only | |
529 | in the second variant. There are two versions of this function | |
530 | to allow this parameter to be either an id or name to | |
531 | a property. | |
532 | @param index | |
533 | Index under category. Available only in the second variant. | |
534 | If index is < 0, property is appended in category. | |
535 | @param newProperty | |
536 | Pointer to the inserted property. wxPropertyGrid will take | |
537 | ownership of this object. | |
538 | ||
539 | @return Returns newProperty. | |
540 | */ | |
effb029c | 541 | wxPGProperty* Insert( wxPGPropArg parent, int index, wxPGProperty* newProperty ); |
1c4293cb | 542 | |
effb029c JS |
543 | /** Returns @true if property is a category. */ |
544 | bool IsPropertyCategory( wxPGPropArg id ) const; | |
1c4293cb | 545 | |
effb029c JS |
546 | /** Returns @true if property is enabled. */ |
547 | bool IsPropertyEnabled( wxPGPropArg id ) const; | |
1c4293cb | 548 | |
effb029c | 549 | /** |
0ad10f30 | 550 | Returns @true if given property is expanded. Naturally, always returns |
effb029c | 551 | @false for properties that cannot be expanded. |
1c4293cb VZ |
552 | */ |
553 | bool IsPropertyExpanded( wxPGPropArg id ) const; | |
554 | ||
effb029c JS |
555 | /** |
556 | Returns @true if property has been modified after value set or modify | |
557 | flag clear by software. | |
1c4293cb | 558 | */ |
effb029c | 559 | bool IsPropertyModified( wxPGPropArg id ) const; |
1c4293cb | 560 | |
fc72fab6 JS |
561 | /** |
562 | Returns true if property is selected. | |
563 | */ | |
564 | virtual bool IsPropertySelected( wxPGPropArg id ) const; | |
565 | ||
effb029c | 566 | /** |
0ad10f30 | 567 | Returns @true if property is shown (ie. HideProperty() with @true not |
effb029c | 568 | called for it). |
1c4293cb | 569 | */ |
effb029c | 570 | bool IsPropertyShown( wxPGPropArg id ) const; |
1c4293cb | 571 | |
effb029c | 572 | /** |
0ad10f30 | 573 | Returns @true if property value is set to unspecified. |
1c4293cb | 574 | */ |
effb029c | 575 | bool IsPropertyValueUnspecified( wxPGPropArg id ) const; |
1c4293cb | 576 | |
effb029c JS |
577 | /** |
578 | Disables (limit = @true) or enables (limit = @false) wxTextCtrl editor | |
579 | of a property, if it is not the sole mean to edit the value. | |
1c4293cb | 580 | */ |
effb029c | 581 | void LimitPropertyEditing( wxPGPropArg id, bool limit = true ); |
1c4293cb | 582 | |
effb029c JS |
583 | /** |
584 | Initializes additional property editors (SpinCtrl etc.). Causes | |
585 | references to most object files in the library, so calling this may | |
586 | cause significant increase in executable size when linking with static | |
587 | library. | |
1c4293cb VZ |
588 | */ |
589 | static void RegisterAdditionalEditors(); | |
590 | ||
f915d44b JS |
591 | /** |
592 | Removes and returns a property. | |
593 | ||
594 | @param id | |
595 | Pointer or name of a property. | |
596 | ||
597 | @remarks Removed property cannot have any children. | |
598 | */ | |
599 | wxPGProperty* RemoveProperty( wxPGPropArg id ); | |
600 | ||
effb029c JS |
601 | /** |
602 | Replaces property with id with newly created one. For example, | |
1c4293cb VZ |
603 | this code replaces existing property named "Flags" with one that |
604 | will have different set of items: | |
effb029c | 605 | |
1c4293cb VZ |
606 | @code |
607 | pg->ReplaceProperty("Flags", | |
608 | wxFlagsProperty("Flags", wxPG_LABEL, newItems)) | |
609 | @endcode | |
effb029c JS |
610 | |
611 | @see Insert() | |
1c4293cb VZ |
612 | */ |
613 | wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property ); | |
614 | ||
effb029c JS |
615 | /** |
616 | @anchor propgridinterface_editablestate_flags | |
1c4293cb VZ |
617 | |
618 | Flags for wxPropertyGridInterface::SaveEditableState() and | |
619 | wxPropertyGridInterface::RestoreEditableState(). | |
620 | */ | |
621 | enum EditableStateFlags | |
622 | { | |
623 | /** Include selected property. */ | |
624 | SelectionState = 0x01, | |
625 | /** Include expanded/collapsed property information. */ | |
626 | ExpandedState = 0x02, | |
627 | /** Include scrolled position. */ | |
628 | ScrollPosState = 0x04, | |
effb029c JS |
629 | /** Include selected page information. Only applies to |
630 | wxPropertyGridManager. */ | |
1c4293cb VZ |
631 | PageState = 0x08, |
632 | /** Include splitter position. Stored for each page. */ | |
633 | SplitterPosState = 0x10, | |
62805170 JS |
634 | /** Include description box size. |
635 | Only applies to wxPropertyGridManager. */ | |
636 | DescBoxState = 0x20, | |
637 | ||
638 | /** | |
639 | Include all supported user editable state information. | |
640 | This is usually the default value. */ | |
641 | AllStates = SelectionState | | |
642 | ExpandedState | | |
643 | ScrollPosState | | |
644 | PageState | | |
645 | SplitterPosState | | |
646 | DescBoxState | |
1c4293cb VZ |
647 | }; |
648 | ||
effb029c JS |
649 | /** |
650 | Restores user-editable state. See also wxPropertyGridInterface::SaveEditableState(). | |
1c4293cb VZ |
651 | |
652 | @param src | |
653 | String generated by SaveEditableState. | |
654 | ||
655 | @param restoreStates | |
656 | Which parts to restore from source string. See @ref propgridinterface_editablestate_flags | |
657 | "list of editable state flags". | |
658 | ||
effb029c | 659 | @return Returns @false if there was problem reading the string. |
1c4293cb | 660 | |
effb029c JS |
661 | @remarks If some parts of state (such as scrolled or splitter position) |
662 | fail to restore correctly, please make sure that you call this | |
663 | function after wxPropertyGrid size has been set (this may | |
664 | sometimes be tricky when sizers are used). | |
1c4293cb VZ |
665 | */ |
666 | bool RestoreEditableState( const wxString& src, | |
667 | int restoreStates = AllStates ); | |
668 | ||
effb029c JS |
669 | /** |
670 | Used to acquire user-editable state (selected property, expanded | |
671 | properties, scrolled position, splitter positions). | |
1c4293cb VZ |
672 | |
673 | @param includedStates | |
674 | Which parts of state to include. See @ref propgridinterface_editablestate_flags | |
675 | "list of editable state flags". | |
676 | */ | |
677 | wxString SaveEditableState( int includedStates = AllStates ) const; | |
678 | ||
effb029c JS |
679 | /** |
680 | Sets strings listed in the choice dropdown of a wxBoolProperty. | |
681 | ||
682 | Defaults are "True" and "False", so changing them to, say, "Yes" and | |
683 | "No" may be useful in some less technical applications. | |
1c4293cb | 684 | */ |
effb029c JS |
685 | static void SetBoolChoices( const wxString& trueChoice, |
686 | const wxString& falseChoice ); | |
687 | ||
fe01f16e JS |
688 | /** |
689 | Set proportion of a auto-stretchable column. wxPG_SPLITTER_AUTO_CENTER | |
690 | window style needs to be used to indicate that columns are auto- | |
691 | resizeable. | |
692 | ||
693 | @returns Returns @false on failure. | |
694 | ||
695 | @remarks You should call this for individual pages of | |
696 | wxPropertyGridManager (if used). | |
4279fdb4 JS |
697 | |
698 | @see GetColumnProportion() | |
fe01f16e JS |
699 | */ |
700 | bool SetColumnProportion( unsigned int column, int proportion ); | |
701 | ||
effb029c JS |
702 | /** |
703 | Sets an attribute for this property. | |
704 | ||
0ad10f30 FM |
705 | @param id |
706 | @todo docme | |
707 | @param attrName | |
effb029c | 708 | Text identifier of attribute. See @ref propgrid_property_attributes. |
1c4293cb | 709 | @param value |
effb029c | 710 | Value of attribute. |
1c4293cb | 711 | @param argFlags |
0ad10f30 FM |
712 | Optional. |
713 | Use wxPG_RECURSE to set the attribute to child properties recursively. | |
1802a91d JS |
714 | |
715 | @remarks Setting attribute's value to Null variant will simply remove it | |
0ad10f30 | 716 | from property's set of attributes. |
1c4293cb | 717 | */ |
effb029c JS |
718 | void SetPropertyAttribute( wxPGPropArg id, const wxString& attrName, |
719 | wxVariant value, long argFlags = 0 ); | |
1c4293cb | 720 | |
effb029c JS |
721 | /** |
722 | Sets property attribute for all applicapple properties. | |
3c26d11b JS |
723 | Be sure to use this method only after all properties have been |
724 | added to the grid. | |
725 | */ | |
726 | void SetPropertyAttributeAll( const wxString& attrName, wxVariant value ); | |
727 | ||
e2ca6599 JS |
728 | /** |
729 | Sets background colour of a property. | |
730 | ||
731 | @param id | |
732 | Property name or pointer. | |
733 | ||
734 | @param colour | |
735 | New background colour. | |
736 | ||
e607eac2 JS |
737 | @param flags |
738 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
739 | Omit this flag to only set colour for the property in question | |
740 | and not any of its children. | |
e2ca6599 JS |
741 | */ |
742 | void SetPropertyBackgroundColour( wxPGPropArg id, | |
743 | const wxColour& colour, | |
e607eac2 | 744 | int flags = wxPG_RECURSE ); |
e2ca6599 | 745 | |
effb029c JS |
746 | /** |
747 | Sets text, bitmap, and colours for given column's cell. | |
1c4293cb VZ |
748 | |
749 | @remarks | |
effb029c | 750 | - You can set label cell by using column 0. |
1c4293cb VZ |
751 | - You can use wxPG_LABEL as text to use default text for column. |
752 | */ | |
753 | void SetPropertyCell( wxPGPropArg id, | |
754 | int column, | |
755 | const wxString& text = wxEmptyString, | |
756 | const wxBitmap& bitmap = wxNullBitmap, | |
757 | const wxColour& fgCol = wxNullColour, | |
effb029c JS |
758 | const wxColour& bgCol = wxNullColour ); |
759 | ||
760 | /** | |
761 | Sets client data (void*) of a property. | |
1c4293cb | 762 | |
1c4293cb VZ |
763 | @remarks |
764 | This untyped client data has to be deleted manually. | |
765 | */ | |
effb029c | 766 | void SetPropertyClientData( wxPGPropArg id, void* clientData ); |
1c4293cb | 767 | |
e2ca6599 JS |
768 | /** |
769 | Resets text and background colours of given property. | |
770 | */ | |
771 | void SetPropertyColoursToDefault( wxPGPropArg id ); | |
772 | ||
effb029c JS |
773 | /** |
774 | Sets editor for a property. | |
1c4293cb | 775 | |
0ad10f30 FM |
776 | @param id |
777 | @todo docme | |
1c4293cb | 778 | @param editor |
effb029c JS |
779 | For builtin editors, use wxPGEditor_X, where X is builtin editor's |
780 | name (TextCtrl, Choice, etc. see wxPGEditor documentation for full | |
781 | list). | |
1c4293cb VZ |
782 | |
783 | For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass(). | |
784 | */ | |
effb029c | 785 | void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor ); |
1c4293cb | 786 | |
effb029c JS |
787 | /** |
788 | Sets editor control of a property. As editor argument, use | |
1c4293cb VZ |
789 | editor name string, such as "TextCtrl" or "Choice". |
790 | */ | |
effb029c | 791 | void SetPropertyEditor( wxPGPropArg id, const wxString& editorName ); |
1c4293cb | 792 | |
effb029c JS |
793 | /** |
794 | Sets label of a property. | |
258ccb95 | 795 | |
1c4293cb | 796 | @remarks |
258ccb95 JS |
797 | - Properties under same parent may have same labels. However, |
798 | property names must still remain unique. | |
1c4293cb VZ |
799 | */ |
800 | void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel ); | |
801 | ||
020b0041 JS |
802 | /** |
803 | Sets name of a property. | |
804 | ||
805 | @param id | |
806 | Name or pointer of property which name to change. | |
807 | ||
808 | @param newName | |
809 | New name for property. | |
810 | */ | |
811 | void SetPropertyName( wxPGPropArg id, const wxString& newName ); | |
812 | ||
effb029c JS |
813 | /** |
814 | Sets property (and, recursively, its children) to have read-only value. | |
815 | In other words, user cannot change the value in the editor, but they can | |
816 | still copy it. | |
817 | ||
effb029c JS |
818 | @param id |
819 | Property name or pointer. | |
820 | ||
821 | @param set | |
822 | Use @true to enable read-only, @false to disable it. | |
1c4293cb | 823 | |
1c4293cb | 824 | @param flags |
effb029c JS |
825 | By default changes are applied recursively. Set this parameter |
826 | wxPG_DONT_RECURSE to prevent this. | |
c05fe841 JS |
827 | |
828 | @remarks This is mainly for use with textctrl editor. Only some other | |
829 | editors fully support it. | |
1c4293cb | 830 | */ |
effb029c JS |
831 | void SetPropertyReadOnly( wxPGPropArg id, bool set = true, |
832 | int flags = wxPG_RECURSE ); | |
1c4293cb | 833 | |
effb029c JS |
834 | /** |
835 | Sets property's value to unspecified. If it has children (it may be | |
836 | category), then the same thing is done to them. | |
1c4293cb VZ |
837 | */ |
838 | void SetPropertyValueUnspecified( wxPGPropArg id ); | |
839 | ||
effb029c | 840 | /** |
c9cc9a2f | 841 | Sets property values from a list of wxVariants. |
1c4293cb | 842 | */ |
effb029c JS |
843 | void SetPropertyValues( const wxVariantList& list, |
844 | wxPGPropArg defaultCategory = wxNullProperty ); | |
1c4293cb | 845 | |
c9cc9a2f JS |
846 | /** |
847 | Sets property values from a list of wxVariants. | |
848 | */ | |
effb029c JS |
849 | void SetPropertyValues( const wxVariant& list, |
850 | wxPGPropArg defaultCategory = wxNullProperty ); | |
1c4293cb | 851 | |
effb029c JS |
852 | /** |
853 | Associates the help string with property. | |
854 | ||
855 | @remarks By default, text is shown either in the manager's "description" | |
856 | text box or in the status bar. If extra window style | |
857 | wxPG_EX_HELP_AS_TOOLTIPS is used, then the text will appear as | |
858 | a tooltip. | |
1c4293cb | 859 | */ |
effb029c | 860 | void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString ); |
1c4293cb | 861 | |
effb029c JS |
862 | /** |
863 | Set wxBitmap in front of the value. | |
864 | ||
865 | @remarks Bitmap will be scaled to a size returned by | |
866 | wxPropertyGrid::GetImageSize(); | |
1c4293cb | 867 | */ |
effb029c | 868 | void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp ); |
1c4293cb | 869 | |
effb029c JS |
870 | /** |
871 | Sets max length of property's text. | |
1c4293cb VZ |
872 | */ |
873 | bool SetPropertyMaxLength( wxPGPropArg id, int maxLen ); | |
874 | ||
e2ca6599 JS |
875 | |
876 | /** | |
877 | Sets text colour of a property. | |
878 | ||
879 | @param id | |
880 | Property name or pointer. | |
881 | ||
882 | @param colour | |
883 | New background colour. | |
884 | ||
e607eac2 JS |
885 | @param flags |
886 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
887 | Omit this flag to only set colour for the property in question | |
888 | and not any of its children. | |
e2ca6599 JS |
889 | */ |
890 | void SetPropertyTextColour( wxPGPropArg id, | |
088441b5 | 891 | const wxColour& colour, |
e607eac2 | 892 | int flags = wxPG_RECURSE ); |
e2ca6599 | 893 | |
effb029c JS |
894 | /** |
895 | Sets validator of a property. | |
1c4293cb | 896 | */ |
effb029c | 897 | void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator ); |
1c4293cb | 898 | |
effb029c JS |
899 | /** Sets value (integer) of a property. */ |
900 | void SetPropertyValue( wxPGPropArg id, long value ); | |
1c4293cb | 901 | |
effb029c JS |
902 | /** Sets value (integer) of a property. */ |
903 | void SetPropertyValue( wxPGPropArg id, int value ); | |
1c4293cb | 904 | |
effb029c JS |
905 | /** Sets value (floating point) of a property. */ |
906 | void SetPropertyValue( wxPGPropArg id, double value ); | |
1c4293cb | 907 | |
effb029c JS |
908 | /** Sets value (bool) of a property. */ |
909 | void SetPropertyValue( wxPGPropArg id, bool value ); | |
1c4293cb | 910 | |
effb029c JS |
911 | /** Sets value (string) of a property. */ |
912 | void SetPropertyValue( wxPGPropArg id, const wxString& value ); | |
1c4293cb | 913 | |
effb029c JS |
914 | /** Sets value (wxArrayString) of a property. */ |
915 | void SetPropertyValue( wxPGPropArg id, const wxArrayString& value ); | |
1c4293cb | 916 | |
effb029c JS |
917 | /** Sets value (wxDateTime) of a property. */ |
918 | void SetPropertyValue( wxPGPropArg id, const wxDateTime& value ); | |
1c4293cb | 919 | |
effb029c JS |
920 | /** Sets value (wxObject*) of a property. */ |
921 | void SetPropertyValue( wxPGPropArg id, wxObject* value ); | |
1c4293cb | 922 | |
effb029c JS |
923 | /** Sets value (wxObject&) of a property. */ |
924 | void SetPropertyValue( wxPGPropArg id, wxObject& value ); | |
925 | ||
926 | /** Sets value (native 64-bit int) of a property. */ | |
927 | void SetPropertyValue( wxPGPropArg id, wxLongLong_t value ); | |
928 | ||
929 | /** Sets value (native 64-bit unsigned int) of a property. */ | |
930 | void SetPropertyValue( wxPGPropArg id, wxULongLong_t value ); | |
931 | ||
932 | /** Sets value (wxArrayInt&) of a property. */ | |
933 | void SetPropertyValue( wxPGPropArg id, const wxArrayInt& value ); | |
934 | ||
935 | /** | |
936 | Sets value (wxString) of a property. | |
937 | ||
938 | @remarks This method uses wxPGProperty::SetValueFromString(), which all | |
939 | properties should implement. This means that there should not be | |
940 | a type error, and instead the string is converted to property's | |
941 | actual value type. | |
1c4293cb VZ |
942 | */ |
943 | void SetPropertyValueString( wxPGPropArg id, const wxString& value ); | |
944 | ||
effb029c JS |
945 | /** |
946 | Sets value (wxVariant&) of a property. | |
bba3f9b5 | 947 | |
effb029c JS |
948 | @remarks Use wxPropertyGrid::ChangePropertyValue() instead if you need to |
949 | run through validation process and send property change event. | |
1c4293cb | 950 | */ |
effb029c | 951 | void SetPropertyValue( wxPGPropArg id, wxVariant value ); |
1c4293cb | 952 | |
effb029c JS |
953 | /** |
954 | Adjusts how wxPropertyGrid behaves when invalid value is entered | |
1c4293cb | 955 | in a property. |
effb029c | 956 | |
1c4293cb | 957 | @param vfbFlags |
effb029c | 958 | See @ref propgrid_vfbflags for possible values. |
1c4293cb VZ |
959 | */ |
960 | void SetValidationFailureBehavior( int vfbFlags ); | |
961 | ||
43396981 | 962 | /** |
0eb877f2 JS |
963 | Sorts all properties recursively. |
964 | ||
965 | @param flags | |
966 | This can contain any of the following options: | |
967 | wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their | |
968 | immediate children. Sorting done by wxPG_AUTO_SORT option | |
969 | uses this. | |
43396981 JS |
970 | |
971 | @see SortChildren, wxPropertyGrid::SetSortFunction | |
972 | */ | |
0eb877f2 | 973 | void Sort( int flags = 0 ); |
43396981 JS |
974 | |
975 | /** | |
976 | Sorts children of a property. | |
977 | ||
978 | @param id | |
979 | Name or pointer to a property. | |
980 | ||
0eb877f2 JS |
981 | @param flags |
982 | This can contain any of the following options: | |
983 | wxPG_RECURSE: Sorts recursively. | |
43396981 JS |
984 | |
985 | @see Sort, wxPropertyGrid::SetSortFunction | |
986 | */ | |
0eb877f2 | 987 | void SortChildren( wxPGPropArg id, int flags = 0 ); |
43396981 | 988 | |
effb029c JS |
989 | /** |
990 | Returns editor pointer of editor with given name; | |
991 | */ | |
1c4293cb | 992 | static wxPGEditor* GetEditorByName( const wxString& editorName ); |
1c4293cb VZ |
993 | }; |
994 |