]>
Commit | Line | Data |
---|---|---|
1c4293cb | 1 | ///////////////////////////////////////////////////////////////////////////// |
80fdcdb9 | 2 | // Name: wx/propgrid/propgridiface.h |
1c4293cb VZ |
3 | // Purpose: wxPropertyGridInterface class |
4 | // Author: Jaakko Salli | |
5 | // Modified by: | |
6 | // Created: 2008-08-24 | |
ea5af9c5 | 7 | // RCS-ID: $Id$ |
1c4293cb | 8 | // Copyright: (c) Jaakko Salli |
526954c5 | 9 | // Licence: wxWindows licence |
1c4293cb VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef __WX_PROPGRID_PROPGRIDIFACE_H__ | |
13 | #define __WX_PROPGRID_PROPGRIDIFACE_H__ | |
14 | ||
6f631217 JS |
15 | #include "wx/defs.h" |
16 | ||
f4bc1aa2 JS |
17 | #if wxUSE_PROPGRID |
18 | ||
1c4293cb VZ |
19 | #include "wx/propgrid/property.h" |
20 | #include "wx/propgrid/propgridpagestate.h" | |
21 | ||
22 | // ----------------------------------------------------------------------- | |
23 | ||
1c4293cb VZ |
24 | /** @section wxPGPropArgCls |
25 | ||
26 | Most property grid functions have this type as their argument, as it can | |
27 | convey a property by either a pointer or name. | |
28 | */ | |
29 | class WXDLLIMPEXP_PROPGRID wxPGPropArgCls | |
30 | { | |
31 | public: | |
1c4293cb VZ |
32 | wxPGPropArgCls( const wxPGProperty* property ) |
33 | { | |
34 | m_ptr.property = (wxPGProperty*) property; | |
f3793429 | 35 | m_flags = IsProperty; |
1c4293cb VZ |
36 | } |
37 | wxPGPropArgCls( const wxString& str ) | |
38 | { | |
f3793429 JS |
39 | m_ptr.stringName = &str; |
40 | m_flags = IsWxString; | |
1c4293cb VZ |
41 | } |
42 | wxPGPropArgCls( const wxPGPropArgCls& id ) | |
43 | { | |
44 | m_ptr = id.m_ptr; | |
f3793429 | 45 | m_flags = id.m_flags; |
1c4293cb VZ |
46 | } |
47 | // This is only needed for wxPython bindings | |
48 | wxPGPropArgCls( wxString* str, bool WXUNUSED(deallocPtr) ) | |
49 | { | |
f3793429 JS |
50 | m_ptr.stringName = str; |
51 | m_flags = IsWxString | OwnsWxString; | |
1c4293cb VZ |
52 | } |
53 | ~wxPGPropArgCls() | |
54 | { | |
f3793429 JS |
55 | if ( m_flags & OwnsWxString ) |
56 | delete m_ptr.stringName; | |
1c4293cb VZ |
57 | } |
58 | wxPGProperty* GetPtr() const | |
59 | { | |
f3793429 | 60 | wxCHECK( m_flags == IsProperty, NULL ); |
1c4293cb VZ |
61 | return m_ptr.property; |
62 | } | |
f3793429 | 63 | wxPGPropArgCls( const char* str ) |
1c4293cb | 64 | { |
f3793429 JS |
65 | m_ptr.charName = str; |
66 | m_flags = IsCharPtr; | |
1c4293cb | 67 | } |
f3793429 JS |
68 | wxPGPropArgCls( const wchar_t* str ) |
69 | { | |
70 | m_ptr.wcharName = str; | |
71 | m_flags = IsWCharPtr; | |
72 | } | |
1c4293cb VZ |
73 | /** This constructor is required for NULL. */ |
74 | wxPGPropArgCls( int ) | |
75 | { | |
d3b9f782 | 76 | m_ptr.property = NULL; |
f3793429 | 77 | m_flags = IsProperty; |
1c4293cb | 78 | } |
f3793429 JS |
79 | wxPGProperty* GetPtr( wxPropertyGridInterface* iface ) const; |
80 | wxPGProperty* GetPtr( const wxPropertyGridInterface* iface ) const | |
1c4293cb | 81 | { |
f3793429 | 82 | return GetPtr((wxPropertyGridInterface*)iface); |
1c4293cb VZ |
83 | } |
84 | wxPGProperty* GetPtr0() const { return m_ptr.property; } | |
f3793429 JS |
85 | bool HasName() const { return (m_flags != IsProperty); } |
86 | const wxString& GetName() const { return *m_ptr.stringName; } | |
1c4293cb | 87 | private: |
f3793429 JS |
88 | |
89 | enum | |
90 | { | |
91 | IsProperty = 0x00, | |
92 | IsWxString = 0x01, | |
93 | IsCharPtr = 0x02, | |
94 | IsWCharPtr = 0x04, | |
35524f61 | 95 | OwnsWxString = 0x10 |
f3793429 JS |
96 | }; |
97 | ||
1c4293cb VZ |
98 | union |
99 | { | |
100 | wxPGProperty* property; | |
f3793429 | 101 | const char* charName; |
f3793429 | 102 | const wchar_t* wcharName; |
f3793429 | 103 | const wxString* stringName; |
1c4293cb | 104 | } m_ptr; |
f3793429 | 105 | unsigned char m_flags; |
1c4293cb VZ |
106 | }; |
107 | ||
1c4293cb VZ |
108 | typedef const wxPGPropArgCls& wxPGPropArg; |
109 | ||
110 | // ----------------------------------------------------------------------- | |
111 | ||
112 | WXDLLIMPEXP_PROPGRID | |
113 | void wxPGTypeOperationFailed( const wxPGProperty* p, | |
0372d42e JS |
114 | const wxString& typestr, |
115 | const wxString& op ); | |
1c4293cb | 116 | WXDLLIMPEXP_PROPGRID |
0372d42e | 117 | void wxPGGetFailed( const wxPGProperty* p, const wxString& typestr ); |
1c4293cb VZ |
118 | |
119 | // ----------------------------------------------------------------------- | |
120 | ||
121 | // Helper macro that does necessary preparations when calling | |
122 | // some wxPGProperty's member function. | |
123 | #define wxPG_PROP_ARG_CALL_PROLOG_0(PROPERTY) \ | |
124 | PROPERTY *p = (PROPERTY*)id.GetPtr(this); \ | |
125 | if ( !p ) return; | |
126 | ||
127 | #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(PROPERTY, RETVAL) \ | |
128 | PROPERTY *p = (PROPERTY*)id.GetPtr(this); \ | |
129 | if ( !p ) return RETVAL; | |
130 | ||
131 | #define wxPG_PROP_ARG_CALL_PROLOG() \ | |
132 | wxPG_PROP_ARG_CALL_PROLOG_0(wxPGProperty) | |
133 | ||
134 | #define wxPG_PROP_ARG_CALL_PROLOG_RETVAL(RVAL) \ | |
135 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(wxPGProperty, RVAL) | |
136 | ||
137 | #define wxPG_PROP_ID_CONST_CALL_PROLOG() \ | |
138 | wxPG_PROP_ARG_CALL_PROLOG_0(const wxPGProperty) | |
139 | ||
140 | #define wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(RVAL) \ | |
141 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL_0(const wxPGProperty, RVAL) | |
142 | ||
143 | // ----------------------------------------------------------------------- | |
144 | ||
145 | ||
146 | /** @class wxPropertyGridInterface | |
147 | ||
148 | Most of the shared property manipulation interface shared by wxPropertyGrid, | |
149 | wxPropertyGridPage, and wxPropertyGridManager is defined in this class. | |
150 | ||
151 | @remarks | |
152 | - In separate wxPropertyGrid component this class was known as | |
153 | wxPropertyContainerMethods. | |
154 | ||
155 | @library{wxpropgrid} | |
156 | @category{propgrid} | |
157 | */ | |
158 | class WXDLLIMPEXP_PROPGRID wxPropertyGridInterface | |
159 | { | |
160 | public: | |
161 | ||
162 | /** Destructor */ | |
163 | virtual ~wxPropertyGridInterface() { } | |
164 | ||
1c4293cb VZ |
165 | /** |
166 | Appends property to the list. | |
167 | ||
168 | wxPropertyGrid assumes ownership of the object. | |
169 | Becomes child of most recently added category. | |
170 | @remarks | |
171 | - wxPropertyGrid takes the ownership of the property pointer. | |
172 | - If appending a category with name identical to a category already in | |
173 | the wxPropertyGrid, then newly created category is deleted, and most | |
174 | recently added category (under which properties are appended) is set | |
175 | to the one with same name. This allows easier adding of items to same | |
176 | categories in multiple passes. | |
177 | - Does not automatically redraw the control, so you may need to call | |
178 | Refresh when calling this function after control has been shown for | |
179 | the first time. | |
180 | */ | |
181 | wxPGProperty* Append( wxPGProperty* property ); | |
182 | ||
183 | wxPGProperty* AppendIn( wxPGPropArg id, wxPGProperty* newproperty ); | |
184 | ||
185 | /** | |
186 | In order to add new items into a property with fixed children (for | |
187 | instance, wxFlagsProperty), you need to call this method. After | |
188 | populating has been finished, you need to call EndAddChildren. | |
189 | */ | |
190 | void BeginAddChildren( wxPGPropArg id ); | |
191 | ||
192 | /** Deletes all properties. | |
193 | */ | |
194 | virtual void Clear() = 0; | |
195 | ||
1621f192 JS |
196 | /** |
197 | Clears current selection, if any. | |
198 | ||
199 | @param validation | |
200 | If set to @false, deselecting the property will always work, | |
201 | even if its editor had invalid value in it. | |
202 | ||
203 | @return Returns @true if successful or if there was no selection. May | |
204 | fail if validation was enabled and active editor had invalid | |
205 | value. | |
01b5ad3b JS |
206 | |
207 | @remarks In wxPropertyGrid 1.4, this member function used to send | |
208 | wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer | |
209 | does that. | |
1621f192 | 210 | */ |
01b5ad3b | 211 | bool ClearSelection( bool validation = false ); |
1c4293cb VZ |
212 | |
213 | /** Resets modified status of all properties. | |
214 | */ | |
89b44158 | 215 | void ClearModifiedStatus(); |
1c4293cb VZ |
216 | |
217 | /** Collapses given category or property with children. | |
218 | Returns true if actually collapses. | |
219 | */ | |
220 | bool Collapse( wxPGPropArg id ); | |
221 | ||
222 | /** Collapses all items that can be collapsed. | |
223 | ||
224 | @return | |
225 | Return false if failed (may fail if editor value cannot be validated). | |
226 | */ | |
227 | bool CollapseAll() { return ExpandAll(false); } | |
228 | ||
229 | /** | |
230 | Changes value of a property, as if from an editor. | |
231 | Use this instead of SetPropertyValue() if you need the value to run | |
232 | through validation process, and also send the property change event. | |
233 | ||
234 | @return | |
235 | Returns true if value was successfully changed. | |
236 | */ | |
237 | bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue ); | |
238 | ||
1c4293cb | 239 | /** |
f231df8a JS |
240 | Removes and deletes a property and any children. |
241 | ||
242 | @param id | |
243 | Pointer or name of a property. | |
244 | ||
245 | @remarks If you delete a property in a wxPropertyGrid event | |
246 | handler, the actual deletion is postponed until the next | |
247 | idle event. | |
248 | ||
249 | This functions deselects selected property, if any. | |
250 | Validation failure option wxPG_VFB_STAY_IN_PROPERTY is not | |
251 | respected, ie. selection is cleared even if editor had | |
252 | invalid value. | |
253 | */ | |
1c4293cb VZ |
254 | void DeleteProperty( wxPGPropArg id ); |
255 | ||
f915d44b | 256 | /** |
f231df8a JS |
257 | Removes a property. Does not delete the property object, but |
258 | instead returns it. | |
f915d44b JS |
259 | |
260 | @param id | |
261 | Pointer or name of a property. | |
262 | ||
263 | @remarks Removed property cannot have any children. | |
f231df8a JS |
264 | |
265 | Also, if you remove property in a wxPropertyGrid event | |
266 | handler, the actual removal is postponed until the next | |
267 | idle event. | |
f915d44b JS |
268 | */ |
269 | wxPGProperty* RemoveProperty( wxPGPropArg id ); | |
270 | ||
9ceed261 JS |
271 | /** |
272 | Disables a property. | |
273 | ||
274 | @see EnableProperty(), wxPGProperty::Enable() | |
275 | */ | |
1c4293cb VZ |
276 | bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); } |
277 | ||
278 | /** | |
279 | Returns true if all property grid data changes have been committed. | |
280 | ||
281 | Usually only returns false if value in active editor has been | |
282 | invalidated by a wxValidator. | |
283 | */ | |
284 | bool EditorValidate(); | |
285 | ||
286 | /** | |
287 | Enables or disables property, depending on whether enable is true or | |
9ceed261 JS |
288 | false. Disabled property usually appears as having grey text. |
289 | ||
290 | @param id | |
291 | Name or pointer to a property. | |
292 | @param enable | |
293 | If @false, property is disabled instead. | |
294 | ||
295 | @see wxPGProperty::Enable() | |
1c4293cb VZ |
296 | */ |
297 | bool EnableProperty( wxPGPropArg id, bool enable = true ); | |
298 | ||
299 | /** Called after population of property with fixed children has finished. | |
300 | */ | |
301 | void EndAddChildren( wxPGPropArg id ); | |
302 | ||
303 | /** Expands given category or property with children. | |
304 | Returns true if actually expands. | |
305 | */ | |
306 | bool Expand( wxPGPropArg id ); | |
307 | ||
308 | /** Expands all items that can be expanded. | |
309 | */ | |
310 | bool ExpandAll( bool expand = true ); | |
311 | ||
1c4293cb VZ |
312 | /** Returns id of first child of given property. |
313 | @remarks | |
314 | Does not return sub-properties! | |
315 | */ | |
316 | wxPGProperty* GetFirstChild( wxPGPropArg id ) | |
317 | { | |
318 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty) | |
319 | ||
320 | if ( !p->GetChildCount() || p->HasFlag(wxPG_PROP_AGGREGATE) ) | |
321 | return wxNullProperty; | |
322 | ||
323 | return p->Item(0); | |
324 | } | |
325 | ||
326 | //@{ | |
327 | /** Returns iterator class instance. | |
328 | @param flags | |
329 | See @ref propgrid_iterator_flags. Value wxPG_ITERATE_DEFAULT causes | |
330 | iteration over everything except private child properties. | |
331 | @param firstProp | |
332 | Property to start iteration from. If NULL, then first child of root | |
333 | is used. | |
334 | @param startPos | |
335 | Either wxTOP or wxBOTTOM. wxTOP will indicate that iterations start | |
336 | from the first property from the top, and wxBOTTOM means that the | |
337 | iteration will instead begin from bottommost valid item. | |
338 | */ | |
339 | wxPropertyGridIterator GetIterator( int flags = wxPG_ITERATE_DEFAULT, | |
340 | wxPGProperty* firstProp = NULL ) | |
341 | { | |
342 | return wxPropertyGridIterator( m_pState, flags, firstProp ); | |
343 | } | |
344 | ||
345 | wxPropertyGridConstIterator | |
346 | GetIterator( int flags = wxPG_ITERATE_DEFAULT, | |
347 | wxPGProperty* firstProp = NULL ) const | |
348 | { | |
349 | return wxPropertyGridConstIterator( m_pState, flags, firstProp ); | |
350 | } | |
351 | ||
352 | wxPropertyGridIterator GetIterator( int flags, int startPos ) | |
353 | { | |
354 | return wxPropertyGridIterator( m_pState, flags, startPos ); | |
355 | } | |
356 | ||
357 | wxPropertyGridConstIterator GetIterator( int flags, int startPos ) const | |
358 | { | |
359 | return wxPropertyGridConstIterator( m_pState, flags, startPos ); | |
360 | } | |
361 | //@} | |
362 | ||
363 | /** Returns id of first item, whether it is a category or property. | |
364 | @param flags | |
365 | @link iteratorflags List of iterator flags@endlink | |
366 | */ | |
367 | wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ) | |
368 | { | |
369 | wxPropertyGridIterator it( m_pState, flags, wxNullProperty, 1 ); | |
370 | return *it; | |
371 | } | |
372 | ||
373 | const wxPGProperty* GetFirst( int flags = wxPG_ITERATE_ALL ) const | |
374 | { | |
375 | return ((wxPropertyGridInterface*)this)->GetFirst(flags); | |
376 | } | |
377 | ||
378 | /** | |
d85635c5 JS |
379 | Returns pointer to a property with given name (case-sensitive). |
380 | If there is no property with such name, @NULL pointer is returned. | |
1c4293cb | 381 | |
d85635c5 | 382 | @remarks Properties which have non-category, non-root parent |
4c51a665 | 383 | cannot be accessed globally by their name. Instead, use |
d85635c5 | 384 | "<property>.<subproperty>" instead of "<subproperty>". |
1c4293cb VZ |
385 | */ |
386 | wxPGProperty* GetProperty( const wxString& name ) const | |
387 | { | |
388 | return GetPropertyByName(name); | |
389 | } | |
390 | ||
391 | /** Returns map-like storage of property's attributes. | |
392 | @remarks | |
393 | Note that if extra style wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES is set, | |
394 | then builtin-attributes are not included in the storage. | |
395 | */ | |
396 | const wxPGAttributeStorage& GetPropertyAttributes( wxPGPropArg id ) const | |
397 | { | |
e9cc4973 JS |
398 | // If 'id' refers to invalid property, then we will return dummy |
399 | // attributes (ie. root property's attributes, which contents should | |
400 | // should always be empty and of no consequence). | |
401 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_pState->DoGetRoot()->GetAttributes()); | |
1c4293cb VZ |
402 | return p->GetAttributes(); |
403 | } | |
404 | ||
405 | /** Adds to 'targetArr' pointers to properties that have given | |
406 | flags 'flags' set. However, if 'inverse' is set to true, then | |
407 | only properties without given flags are stored. | |
408 | @param flags | |
409 | Property flags to use. | |
410 | @param iterFlags | |
411 | Iterator flags to use. Default is everything expect private children. | |
412 | */ | |
413 | void GetPropertiesWithFlag( wxArrayPGProperty* targetArr, | |
414 | wxPGProperty::FlagType flags, | |
415 | bool inverse = false, | |
416 | int iterFlags = wxPG_ITERATE_PROPERTIES | | |
417 | wxPG_ITERATE_HIDDEN | | |
418 | wxPG_ITERATE_CATEGORIES) const; | |
419 | ||
420 | /** Returns value of given attribute. If none found, returns NULL-variant. | |
421 | */ | |
422 | wxVariant GetPropertyAttribute( wxPGPropArg id, | |
423 | const wxString& attrName ) const | |
424 | { | |
425 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullVariant) | |
426 | return p->GetAttribute(attrName); | |
427 | } | |
428 | ||
429 | /** Returns pointer of property's nearest parent category. If no category | |
430 | found, returns NULL. | |
431 | */ | |
432 | wxPropertyCategory* GetPropertyCategory( wxPGPropArg id ) const | |
433 | { | |
434 | wxPG_PROP_ID_CONST_CALL_PROLOG_RETVAL(NULL) | |
435 | return m_pState->GetPropertyCategory(p); | |
436 | } | |
437 | ||
1c4293cb VZ |
438 | /** Returns client data (void*) of a property. */ |
439 | void* GetPropertyClientData( wxPGPropArg id ) const | |
440 | { | |
441 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL) | |
442 | return p->GetClientData(); | |
443 | } | |
1c4293cb VZ |
444 | |
445 | /** | |
446 | Returns first property which label matches given string. | |
447 | ||
448 | NULL if none found. Note that this operation is extremely slow when | |
449 | compared to GetPropertyByName(). | |
450 | */ | |
451 | wxPGProperty* GetPropertyByLabel( const wxString& label ) const; | |
452 | ||
453 | /** Returns property with given name. NULL if none found. | |
454 | */ | |
455 | wxPGProperty* GetPropertyByName( const wxString& name ) const; | |
456 | ||
457 | /** Returns child property 'subname' of property 'name'. Same as | |
458 | calling GetPropertyByName("name.subname"), albeit slightly faster. | |
459 | */ | |
460 | wxPGProperty* GetPropertyByName( const wxString& name, | |
461 | const wxString& subname ) const; | |
462 | ||
1c4293cb VZ |
463 | /** Returns property's editor. */ |
464 | const wxPGEditor* GetPropertyEditor( wxPGPropArg id ) const | |
465 | { | |
466 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL) | |
467 | return p->GetEditorClass(); | |
468 | } | |
469 | ||
470 | /** Returns help string associated with a property. */ | |
471 | wxString GetPropertyHelpString( wxPGPropArg id ) const | |
472 | { | |
473 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString) | |
474 | return p->GetHelpString(); | |
475 | } | |
476 | ||
477 | /** Returns property's custom value image (NULL of none). */ | |
478 | wxBitmap* GetPropertyImage( wxPGPropArg id ) const | |
479 | { | |
480 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL) | |
481 | return p->GetValueImage(); | |
482 | } | |
483 | ||
1c4293cb VZ |
484 | /** Returns label of a property. */ |
485 | const wxString& GetPropertyLabel( wxPGPropArg id ) | |
486 | { | |
487 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(m_emptyString) | |
488 | return p->GetLabel(); | |
489 | } | |
490 | ||
491 | /** Returns name of a property, by which it is globally accessible. */ | |
effb029c | 492 | wxString GetPropertyName( wxPGProperty* property ) |
1c4293cb | 493 | { |
effb029c | 494 | return property->GetName(); |
1c4293cb VZ |
495 | } |
496 | ||
497 | /** Returns parent item of a property. */ | |
498 | wxPGProperty* GetPropertyParent( wxPGPropArg id ) | |
499 | { | |
500 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty) | |
501 | return p->GetParent(); | |
502 | } | |
503 | ||
504 | #if wxUSE_VALIDATORS | |
505 | /** Returns validator of a property as a reference, which you | |
506 | can pass to any number of SetPropertyValidator. | |
507 | */ | |
508 | wxValidator* GetPropertyValidator( wxPGPropArg id ) | |
509 | { | |
510 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(NULL) | |
511 | return p->GetValidator(); | |
512 | } | |
513 | #endif | |
514 | ||
515 | /** Returns value as wxVariant. To get wxObject pointer from it, | |
516 | you will have to use WX_PG_VARIANT_TO_WXOBJECT(VARIANT,CLASSNAME) macro. | |
517 | ||
518 | If property value is unspecified, Null variant is returned. | |
519 | */ | |
520 | wxVariant GetPropertyValue( wxPGPropArg id ) | |
521 | { | |
522 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxVariant()) | |
523 | return p->GetValue(); | |
524 | } | |
525 | ||
526 | wxString GetPropertyValueAsString( wxPGPropArg id ) const; | |
527 | long GetPropertyValueAsLong( wxPGPropArg id ) const; | |
528 | unsigned long GetPropertyValueAsULong( wxPGPropArg id ) const | |
529 | { | |
530 | return (unsigned long) GetPropertyValueAsLong(id); | |
531 | } | |
1c4293cb VZ |
532 | int GetPropertyValueAsInt( wxPGPropArg id ) const |
533 | { return (int)GetPropertyValueAsLong(id); } | |
1c4293cb VZ |
534 | bool GetPropertyValueAsBool( wxPGPropArg id ) const; |
535 | double GetPropertyValueAsDouble( wxPGPropArg id ) const; | |
1c4293cb VZ |
536 | |
537 | #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL(TYPENAME, DEFVAL) \ | |
538 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \ | |
0372d42e JS |
539 | wxString typeName(wxS(TYPENAME)); \ |
540 | wxVariant value = p->GetValue(); \ | |
541 | if ( value.GetType() != typeName ) \ | |
1c4293cb | 542 | { \ |
0372d42e | 543 | wxPGGetFailed(p, typeName); \ |
1c4293cb VZ |
544 | return DEFVAL; \ |
545 | } | |
546 | ||
547 | #define wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL_WFALLBACK(TYPENAME, DEFVAL) \ | |
548 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(DEFVAL) \ | |
0372d42e JS |
549 | wxVariant value = p->GetValue(); \ |
550 | if ( value.GetType() != wxS(TYPENAME) ) \ | |
1c4293cb VZ |
551 | return DEFVAL; \ |
552 | ||
553 | wxArrayString GetPropertyValueAsArrayString( wxPGPropArg id ) const | |
554 | { | |
0372d42e | 555 | wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("arrstring", |
1c4293cb | 556 | wxArrayString()) |
0372d42e | 557 | return value.GetArrayString(); |
1c4293cb VZ |
558 | } |
559 | ||
4e00b908 | 560 | #ifdef wxLongLong_t |
1c4293cb VZ |
561 | wxLongLong_t GetPropertyValueAsLongLong( wxPGPropArg id ) const |
562 | { | |
4e00b908 JS |
563 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0) |
564 | return p->GetValue().GetLongLong().GetValue(); | |
1c4293cb VZ |
565 | } |
566 | ||
567 | wxULongLong_t GetPropertyValueAsULongLong( wxPGPropArg id ) const | |
568 | { | |
4e00b908 JS |
569 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(0) |
570 | return p->GetValue().GetULongLong().GetValue(); | |
1c4293cb | 571 | } |
0dc44cac | 572 | #endif |
1c4293cb VZ |
573 | |
574 | wxArrayInt GetPropertyValueAsArrayInt( wxPGPropArg id ) const | |
575 | { | |
0372d42e | 576 | wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("wxArrayInt", |
1c4293cb | 577 | wxArrayInt()) |
0372d42e JS |
578 | wxArrayInt arr; |
579 | arr << value; | |
1c4293cb VZ |
580 | return arr; |
581 | } | |
582 | ||
583 | #if wxUSE_DATETIME | |
584 | wxDateTime GetPropertyValueAsDateTime( wxPGPropArg id ) const | |
585 | { | |
0372d42e JS |
586 | wxPG_PROP_ID_GETPROPVAL_CALL_PROLOG_RETVAL("datetime", |
587 | wxDateTime()) | |
588 | return value.GetDateTime(); | |
1c4293cb VZ |
589 | } |
590 | #endif | |
591 | ||
1c4293cb VZ |
592 | /** Returns a wxVariant list containing wxVariant versions of all |
593 | property values. Order is not guaranteed. | |
594 | @param flags | |
595 | Use wxPG_KEEP_STRUCTURE to retain category structure; each sub | |
596 | category will be its own wxVariantList of wxVariant. | |
597 | Use wxPG_INC_ATTRIBUTES to include property attributes as well. | |
598 | Each attribute will be stored as list variant named | |
599 | "@@<propname>@@attr." | |
600 | @remarks | |
601 | */ | |
602 | wxVariant GetPropertyValues( const wxString& listname = wxEmptyString, | |
603 | wxPGProperty* baseparent = NULL, long flags = 0 ) const | |
604 | { | |
605 | return m_pState->DoGetPropertyValues(listname, baseparent, flags); | |
606 | } | |
1c4293cb | 607 | |
fc72fab6 JS |
608 | /** |
609 | Returns currently selected property. NULL if none. | |
610 | ||
611 | @remarks When wxPG_EX_MULTIPLE_SELECTION extra style is used, this | |
612 | member function returns the focused property, that is the | |
613 | one which can have active editor. | |
614 | */ | |
615 | wxPGProperty* GetSelection() const; | |
616 | ||
617 | /** | |
618 | Returns list of currently selected properties. | |
619 | ||
620 | @remarks wxArrayPGProperty should be compatible with std::vector API. | |
621 | */ | |
622 | const wxArrayPGProperty& GetSelectedProperties() const | |
1c4293cb | 623 | { |
fc72fab6 | 624 | return m_pState->m_selection; |
1c4293cb VZ |
625 | } |
626 | ||
1c4293cb | 627 | wxPropertyGridPageState* GetState() const { return m_pState; } |
1c4293cb VZ |
628 | |
629 | /** Similar to GetIterator(), but instead returns wxPGVIterator instance, | |
630 | which can be useful for forward-iterating through arbitrary property | |
631 | containers. | |
632 | ||
633 | @param flags | |
634 | See @ref propgrid_iterator_flags. | |
635 | */ | |
636 | virtual wxPGVIterator GetVIterator( int flags ) const; | |
637 | ||
638 | /** Hides or reveals a property. | |
639 | @param hide | |
640 | If true, hides property, otherwise reveals it. | |
641 | @param flags | |
642 | By default changes are applied recursively. Set this paramter | |
643 | wxPG_DONT_RECURSE to prevent this. | |
644 | */ | |
645 | bool HideProperty( wxPGPropArg id, | |
646 | bool hide = true, | |
647 | int flags = wxPG_RECURSE ); | |
648 | ||
649 | #if wxPG_INCLUDE_ADVPROPS | |
650 | /** Initializes *all* property types. Causes references to most object | |
651 | files in the library, so calling this may cause significant increase | |
652 | in executable size when linking with static library. | |
653 | */ | |
654 | static void InitAllTypeHandlers(); | |
655 | #else | |
656 | static void InitAllTypeHandlers() { } | |
657 | #endif | |
658 | ||
659 | //@{ | |
660 | /** Inserts property to the property container. | |
661 | ||
662 | @param priorThis | |
663 | New property is inserted just prior to this. Available only | |
664 | in the first variant. There are two versions of this function | |
665 | to allow this parameter to be either an id or name to | |
666 | a property. | |
667 | ||
668 | @param newproperty | |
669 | Pointer to the inserted property. wxPropertyGrid will take | |
670 | ownership of this object. | |
671 | ||
672 | @param parent | |
673 | New property is inserted under this category. Available only | |
674 | in the second variant. There are two versions of this function | |
675 | to allow this parameter to be either an id or name to | |
676 | a property. | |
677 | ||
678 | @param index | |
679 | Index under category. Available only in the second variant. | |
680 | If index is < 0, property is appended in category. | |
681 | ||
682 | @return | |
683 | Returns id for the property, | |
684 | ||
685 | @remarks | |
686 | ||
687 | - wxPropertyGrid takes the ownership of the property pointer. | |
688 | ||
689 | - While Append may be faster way to add items, make note that when | |
690 | both types of data storage (categoric and | |
691 | non-categoric) are active, Insert becomes even more slow. This is | |
692 | especially true if current mode is non-categoric. | |
693 | ||
694 | Example of use: | |
695 | ||
696 | @code | |
697 | ||
698 | // append category | |
699 | wxPGProperty* my_cat_id = propertygrid->Append( | |
700 | new wxPropertyCategory("My Category") ); | |
701 | ||
702 | ... | |
703 | ||
704 | // insert into category - using second variant | |
705 | wxPGProperty* my_item_id_1 = propertygrid->Insert( | |
706 | my_cat_id, 0, new wxStringProperty("My String 1") ); | |
707 | ||
708 | // insert before to first item - using first variant | |
709 | wxPGProperty* my_item_id_2 = propertygrid->Insert( | |
710 | my_item_id, new wxStringProperty("My String 2") ); | |
711 | ||
712 | @endcode | |
713 | ||
714 | */ | |
715 | wxPGProperty* Insert( wxPGPropArg priorThis, wxPGProperty* newproperty ); | |
716 | wxPGProperty* Insert( wxPGPropArg parent, | |
717 | int index, | |
718 | wxPGProperty* newproperty ); | |
719 | //@} | |
720 | ||
721 | /** Returns true if property is a category. */ | |
722 | bool IsPropertyCategory( wxPGPropArg id ) const | |
723 | { | |
724 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
725 | return p->IsCategory(); | |
726 | } | |
727 | ||
1c4293cb VZ |
728 | /** Returns true if property is enabled. */ |
729 | bool IsPropertyEnabled( wxPGPropArg id ) const | |
730 | { | |
731 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
732 | return (!(p->GetFlags() & wxPG_PROP_DISABLED))?true:false; | |
733 | } | |
734 | ||
735 | /** | |
736 | Returns true if given property is expanded. | |
737 | ||
738 | Naturally, always returns false for properties that cannot be expanded. | |
739 | */ | |
740 | bool IsPropertyExpanded( wxPGPropArg id ) const; | |
741 | ||
742 | /** | |
743 | Returns true if property has been modified after value set or modify | |
744 | flag clear by software. | |
745 | */ | |
746 | bool IsPropertyModified( wxPGPropArg id ) const | |
747 | { | |
748 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
749 | return ( (p->GetFlags() & wxPG_PROP_MODIFIED) ? true : false ); | |
750 | } | |
751 | ||
fc72fab6 JS |
752 | /** |
753 | Returns true if property is selected. | |
754 | */ | |
755 | bool IsPropertySelected( wxPGPropArg id ) const | |
756 | { | |
757 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
758 | return m_pState->DoIsPropertySelected(p); | |
759 | } | |
760 | ||
1c4293cb VZ |
761 | /** |
762 | Returns true if property is shown (ie hideproperty with true not | |
763 | called for it). | |
fc72fab6 | 764 | */ |
1c4293cb VZ |
765 | bool IsPropertyShown( wxPGPropArg id ) const |
766 | { | |
767 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
768 | return (!(p->GetFlags() & wxPG_PROP_HIDDEN))?true:false; | |
769 | } | |
770 | ||
771 | /** Returns true if property value is set to unspecified. | |
772 | */ | |
773 | bool IsPropertyValueUnspecified( wxPGPropArg id ) const | |
774 | { | |
775 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false) | |
776 | return p->IsValueUnspecified(); | |
777 | } | |
778 | ||
779 | /** | |
780 | Disables (limit = true) or enables (limit = false) wxTextCtrl editor of | |
781 | a property, if it is not the sole mean to edit the value. | |
782 | */ | |
783 | void LimitPropertyEditing( wxPGPropArg id, bool limit = true ); | |
784 | ||
785 | /** If state is shown in it's grid, refresh it now. | |
786 | */ | |
787 | virtual void RefreshGrid( wxPropertyGridPageState* state = NULL ); | |
788 | ||
789 | #if wxPG_INCLUDE_ADVPROPS | |
790 | /** | |
791 | Initializes additional property editors (SpinCtrl etc.). Causes | |
792 | references to most object files in the library, so calling this may | |
793 | cause significant increase in executable size when linking with static | |
794 | library. | |
795 | */ | |
796 | static void RegisterAdditionalEditors(); | |
797 | #else | |
798 | static void RegisterAdditionalEditors() { } | |
799 | #endif | |
800 | ||
801 | /** Replaces property with id with newly created property. For example, | |
802 | this code replaces existing property named "Flags" with one that | |
803 | will have different set of items: | |
804 | @code | |
805 | pg->ReplaceProperty("Flags", | |
806 | wxFlagsProperty("Flags", wxPG_LABEL, newItems)) | |
807 | @endcode | |
808 | For more info, see wxPropertyGrid::Insert. | |
809 | */ | |
810 | wxPGProperty* ReplaceProperty( wxPGPropArg id, wxPGProperty* property ); | |
811 | ||
812 | /** @anchor propgridinterface_editablestate_flags | |
813 | ||
814 | Flags for wxPropertyGridInterface::SaveEditableState() and | |
815 | wxPropertyGridInterface::RestoreEditableState(). | |
816 | */ | |
817 | enum EditableStateFlags | |
818 | { | |
819 | /** Include selected property. */ | |
820 | SelectionState = 0x01, | |
821 | /** Include expanded/collapsed property information. */ | |
822 | ExpandedState = 0x02, | |
823 | /** Include scrolled position. */ | |
824 | ScrollPosState = 0x04, | |
825 | /** Include selected page information. | |
826 | Only applies to wxPropertyGridManager. */ | |
827 | PageState = 0x08, | |
828 | /** Include splitter position. Stored for each page. */ | |
829 | SplitterPosState = 0x10, | |
62805170 JS |
830 | /** Include description box size. |
831 | Only applies to wxPropertyGridManager. */ | |
832 | DescBoxState = 0x20, | |
1c4293cb VZ |
833 | |
834 | /** | |
835 | Include all supported user editable state information. | |
836 | This is usually the default value. */ | |
837 | AllStates = SelectionState | | |
838 | ExpandedState | | |
839 | ScrollPosState | | |
840 | PageState | | |
62805170 JS |
841 | SplitterPosState | |
842 | DescBoxState | |
1c4293cb VZ |
843 | }; |
844 | ||
845 | /** | |
846 | Restores user-editable state. | |
847 | ||
848 | See also wxPropertyGridInterface::SaveEditableState(). | |
849 | ||
850 | @param src | |
851 | String generated by SaveEditableState. | |
852 | ||
853 | @param restoreStates | |
854 | Which parts to restore from source string. See @ref | |
855 | propgridinterface_editablestate_flags "list of editable state | |
856 | flags". | |
857 | ||
858 | @return | |
859 | False if there was problem reading the string. | |
860 | ||
861 | @remarks | |
862 | If some parts of state (such as scrolled or splitter position) fail to | |
863 | restore correctly, please make sure that you call this function after | |
864 | wxPropertyGrid size has been set (this may sometimes be tricky when | |
865 | sizers are used). | |
866 | */ | |
867 | bool RestoreEditableState( const wxString& src, | |
868 | int restoreStates = AllStates ); | |
869 | ||
870 | /** | |
871 | Used to acquire user-editable state (selected property, expanded | |
872 | properties, scrolled position, splitter positions). | |
873 | ||
874 | @param includedStates | |
875 | Which parts of state to include. See @ref | |
876 | propgridinterface_editablestate_flags "list of editable state flags". | |
877 | */ | |
878 | wxString SaveEditableState( int includedStates = AllStates ) const; | |
879 | ||
880 | /** | |
4c51a665 | 881 | Lets user set the strings listed in the choice dropdown of a |
1c4293cb VZ |
882 | wxBoolProperty. Defaults are "True" and "False", so changing them to, |
883 | say, "Yes" and "No" may be useful in some less technical applications. | |
884 | */ | |
885 | static void SetBoolChoices( const wxString& trueChoice, | |
886 | const wxString& falseChoice ); | |
887 | ||
fe01f16e JS |
888 | /** |
889 | Set proportion of a auto-stretchable column. wxPG_SPLITTER_AUTO_CENTER | |
890 | window style needs to be used to indicate that columns are auto- | |
d13b34d3 | 891 | resizable. |
fe01f16e JS |
892 | |
893 | @returns Returns @false on failure. | |
894 | ||
895 | @remarks You should call this for individual pages of | |
896 | wxPropertyGridManager (if used). | |
4279fdb4 JS |
897 | |
898 | @see GetColumnProportion() | |
fe01f16e JS |
899 | */ |
900 | bool SetColumnProportion( unsigned int column, int proportion ); | |
901 | ||
4279fdb4 JS |
902 | /** |
903 | Returns auto-resize proportion of the given column. | |
904 | ||
905 | @see SetColumnProportion() | |
906 | */ | |
907 | int GetColumnProportion( unsigned int column ) const | |
908 | { | |
909 | return m_pState->DoGetColumnProportion(column); | |
910 | } | |
911 | ||
1c4293cb VZ |
912 | /** Sets an attribute for this property. |
913 | @param name | |
914 | Text identifier of attribute. See @ref propgrid_property_attributes. | |
915 | @param value | |
916 | Value of attribute. | |
917 | @param argFlags | |
918 | Optional. Use wxPG_RECURSE to set the attribute to child properties | |
919 | recursively. | |
920 | */ | |
921 | void SetPropertyAttribute( wxPGPropArg id, | |
922 | const wxString& attrName, | |
923 | wxVariant value, | |
924 | long argFlags = 0 ) | |
925 | { | |
926 | DoSetPropertyAttribute(id,attrName,value,argFlags); | |
927 | } | |
928 | ||
3c26d11b JS |
929 | /** Sets property attribute for all applicapple properties. |
930 | Be sure to use this method only after all properties have been | |
931 | added to the grid. | |
932 | */ | |
933 | void SetPropertyAttributeAll( const wxString& attrName, wxVariant value ); | |
934 | ||
e2ca6599 JS |
935 | /** |
936 | Sets background colour of a property. | |
937 | ||
938 | @param id | |
939 | Property name or pointer. | |
940 | ||
941 | @param colour | |
942 | New background colour. | |
943 | ||
e607eac2 JS |
944 | @param flags |
945 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
946 | Omit this flag to only set colour for the property in question | |
947 | and not any of its children. | |
e2ca6599 JS |
948 | */ |
949 | void SetPropertyBackgroundColour( wxPGPropArg id, | |
950 | const wxColour& colour, | |
e607eac2 | 951 | int flags = wxPG_RECURSE ); |
e2ca6599 JS |
952 | |
953 | /** Resets text and background colours of given property. | |
954 | */ | |
955 | void SetPropertyColoursToDefault( wxPGPropArg id ); | |
956 | ||
957 | /** | |
958 | Sets text colour of a property. | |
959 | ||
960 | @param id | |
961 | Property name or pointer. | |
962 | ||
963 | @param colour | |
964 | New background colour. | |
965 | ||
e607eac2 JS |
966 | @param flags |
967 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
968 | Omit this flag to only set colour for the property in question | |
969 | and not any of its children. | |
e2ca6599 JS |
970 | */ |
971 | void SetPropertyTextColour( wxPGPropArg id, | |
972 | const wxColour& col, | |
e607eac2 | 973 | int flags = wxPG_RECURSE ); |
e2ca6599 JS |
974 | |
975 | /** | |
976 | Returns background colour of first cell of a property. | |
977 | */ | |
978 | wxColour GetPropertyBackgroundColour( wxPGPropArg id ) const | |
979 | { | |
980 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour()) | |
981 | return p->GetCell(0).GetBgCol(); | |
982 | } | |
983 | ||
984 | /** | |
985 | Returns text colour of first cell of a property. | |
986 | */ | |
987 | wxColour GetPropertyTextColour( wxPGPropArg id ) const | |
988 | { | |
989 | wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxColour()) | |
990 | return p->GetCell(0).GetFgCol(); | |
991 | } | |
992 | ||
1c4293cb VZ |
993 | /** Sets text, bitmap, and colours for given column's cell. |
994 | ||
995 | @remarks | |
996 | - You can set label cell by setting column to 0. | |
997 | - You can use wxPG_LABEL as text to use default text for column. | |
998 | */ | |
999 | void SetPropertyCell( wxPGPropArg id, | |
1000 | int column, | |
1001 | const wxString& text = wxEmptyString, | |
1002 | const wxBitmap& bitmap = wxNullBitmap, | |
1003 | const wxColour& fgCol = wxNullColour, | |
d7e2b522 | 1004 | const wxColour& bgCol = wxNullColour ); |
1c4293cb | 1005 | |
1c4293cb VZ |
1006 | /** Sets client data (void*) of a property. |
1007 | @remarks | |
1008 | This untyped client data has to be deleted manually. | |
1009 | */ | |
1010 | void SetPropertyClientData( wxPGPropArg id, void* clientData ) | |
1011 | { | |
1012 | wxPG_PROP_ARG_CALL_PROLOG() | |
1013 | p->SetClientData(clientData); | |
1014 | } | |
1015 | ||
1016 | /** Sets editor for a property. | |
1017 | ||
1018 | @param editor | |
1019 | For builtin editors, use wxPGEditor_X, where X is builtin editor's | |
1020 | name (TextCtrl, Choice, etc. see wxPGEditor documentation for full | |
1021 | list). | |
1022 | ||
1023 | For custom editors, use pointer you received from | |
1024 | wxPropertyGrid::RegisterEditorClass(). | |
1025 | */ | |
1026 | void SetPropertyEditor( wxPGPropArg id, const wxPGEditor* editor ) | |
1027 | { | |
1028 | wxPG_PROP_ARG_CALL_PROLOG() | |
1029 | wxCHECK_RET( editor, wxT("unknown/NULL editor") ); | |
1030 | p->SetEditor(editor); | |
1031 | RefreshProperty(p); | |
1032 | } | |
1c4293cb VZ |
1033 | |
1034 | /** Sets editor control of a property. As editor argument, use | |
1035 | editor name string, such as "TextCtrl" or "Choice". | |
1036 | */ | |
1037 | void SetPropertyEditor( wxPGPropArg id, const wxString& editorName ) | |
1038 | { | |
1039 | SetPropertyEditor(id,GetEditorByName(editorName)); | |
1040 | } | |
1041 | ||
1042 | /** Sets label of a property. | |
1c4293cb VZ |
1043 | */ |
1044 | void SetPropertyLabel( wxPGPropArg id, const wxString& newproplabel ); | |
1045 | ||
020b0041 JS |
1046 | /** |
1047 | Sets name of a property. | |
1048 | ||
1049 | @param id | |
1050 | Name or pointer of property which name to change. | |
1051 | ||
1052 | @param newName | |
1053 | New name for property. | |
1054 | */ | |
1055 | void SetPropertyName( wxPGPropArg id, const wxString& newName ) | |
1056 | { | |
1057 | wxPG_PROP_ARG_CALL_PROLOG() | |
1058 | m_pState->DoSetPropertyName( p, newName ); | |
1059 | } | |
1060 | ||
1c4293cb VZ |
1061 | /** |
1062 | Sets property (and, recursively, its children) to have read-only value. | |
1063 | In other words, user cannot change the value in the editor, but they | |
1064 | can still copy it. | |
1065 | @remarks | |
1066 | This is mainly for use with textctrl editor. Not all other editors fully | |
1067 | support it. | |
1068 | @param flags | |
1069 | By default changes are applied recursively. Set this paramter | |
1070 | wxPG_DONT_RECURSE to prevent this. | |
1071 | */ | |
1072 | void SetPropertyReadOnly( wxPGPropArg id, | |
1073 | bool set = true, | |
1074 | int flags = wxPG_RECURSE ) | |
1075 | { | |
1076 | wxPG_PROP_ARG_CALL_PROLOG() | |
1077 | if ( flags & wxPG_RECURSE ) | |
1078 | p->SetFlagRecursively(wxPG_PROP_READONLY, set); | |
1079 | else | |
d58526d5 | 1080 | p->ChangeFlag(wxPG_PROP_READONLY, set); |
1c4293cb VZ |
1081 | } |
1082 | ||
1083 | /** Sets property's value to unspecified. | |
1084 | If it has children (it may be category), then the same thing is done to | |
1085 | them. | |
1086 | */ | |
daeb4e4d JS |
1087 | void SetPropertyValueUnspecified( wxPGPropArg id ) |
1088 | { | |
1089 | wxPG_PROP_ARG_CALL_PROLOG() | |
269619bf | 1090 | p->SetValueToUnspecified(); |
daeb4e4d | 1091 | } |
1c4293cb | 1092 | |
c9cc9a2f JS |
1093 | /** |
1094 | Sets property values from a list of wxVariants. | |
1c4293cb VZ |
1095 | */ |
1096 | void SetPropertyValues( const wxVariantList& list, | |
1097 | wxPGPropArg defaultCategory = wxNullProperty ) | |
1098 | { | |
1099 | wxPGProperty *p; | |
1100 | if ( defaultCategory.HasName() ) p = defaultCategory.GetPtr(this); | |
1101 | else p = defaultCategory.GetPtr0(); | |
1102 | m_pState->DoSetPropertyValues(list, p); | |
1103 | } | |
1104 | ||
c9cc9a2f JS |
1105 | /** |
1106 | Sets property values from a list of wxVariants. | |
1107 | */ | |
1c4293cb VZ |
1108 | void SetPropertyValues( const wxVariant& list, |
1109 | wxPGPropArg defaultCategory = wxNullProperty ) | |
1110 | { | |
1111 | SetPropertyValues(list.GetList(),defaultCategory); | |
1112 | } | |
1c4293cb VZ |
1113 | |
1114 | /** Associates the help string with property. | |
1115 | @remarks | |
1116 | By default, text is shown either in the manager's "description" | |
1117 | text box or in the status bar. If extra window style | |
1118 | wxPG_EX_HELP_AS_TOOLTIPS is used, then the text will appear as a | |
1119 | tooltip. | |
1120 | */ | |
1121 | void SetPropertyHelpString( wxPGPropArg id, const wxString& helpString ) | |
1122 | { | |
1123 | wxPG_PROP_ARG_CALL_PROLOG() | |
1124 | p->SetHelpString(helpString); | |
1125 | } | |
1126 | ||
1127 | /** Set wxBitmap in front of the value. | |
1128 | @remarks | |
1129 | - Bitmap will be scaled to a size returned by | |
1130 | wxPropertyGrid::GetImageSize(); | |
1131 | */ | |
1132 | void SetPropertyImage( wxPGPropArg id, wxBitmap& bmp ) | |
1133 | { | |
1134 | wxPG_PROP_ARG_CALL_PROLOG() | |
1135 | p->SetValueImage(bmp); | |
1136 | RefreshProperty(p); | |
1137 | } | |
1138 | ||
1139 | /** Sets max length of property's text. | |
1140 | */ | |
1141 | bool SetPropertyMaxLength( wxPGPropArg id, int maxLen ); | |
1142 | ||
1143 | #if wxUSE_VALIDATORS | |
1144 | /** Sets validator of a property. | |
1145 | */ | |
1146 | void SetPropertyValidator( wxPGPropArg id, const wxValidator& validator ) | |
1147 | { | |
1148 | wxPG_PROP_ARG_CALL_PROLOG() | |
1149 | p->SetValidator(validator); | |
1150 | } | |
1151 | #endif | |
1152 | ||
1c4293cb VZ |
1153 | /** Sets value (long integer) of a property. |
1154 | */ | |
1155 | void SetPropertyValue( wxPGPropArg id, long value ) | |
1156 | { | |
1157 | wxVariant v(value); | |
1158 | SetPropVal( id, v ); | |
1159 | } | |
1160 | ||
1161 | /** Sets value (integer) of a property. | |
1162 | */ | |
1163 | void SetPropertyValue( wxPGPropArg id, int value ) | |
1164 | { | |
1165 | wxVariant v((long)value); | |
1166 | SetPropVal( id, v ); | |
1167 | } | |
1168 | /** Sets value (floating point) of a property. | |
1169 | */ | |
1170 | void SetPropertyValue( wxPGPropArg id, double value ) | |
1171 | { | |
1172 | wxVariant v(value); | |
1173 | SetPropVal( id, v ); | |
1174 | } | |
1175 | /** Sets value (bool) of a property. | |
1176 | */ | |
1177 | void SetPropertyValue( wxPGPropArg id, bool value ) | |
1178 | { | |
1179 | wxVariant v(value); | |
1180 | SetPropVal( id, v ); | |
1181 | } | |
a6f2417d JS |
1182 | void SetPropertyValue( wxPGPropArg id, const wchar_t* value ) |
1183 | { | |
1184 | SetPropertyValueString( id, wxString(value) ); | |
1185 | } | |
a6f2417d | 1186 | void SetPropertyValue( wxPGPropArg id, const char* value ) |
1c4293cb VZ |
1187 | { |
1188 | SetPropertyValueString( id, wxString(value) ); | |
1189 | } | |
1190 | void SetPropertyValue( wxPGPropArg id, const wxString& value ) | |
1191 | { | |
1192 | SetPropertyValueString( id, value ); | |
1193 | } | |
1194 | ||
1195 | /** Sets value (wxArrayString) of a property. | |
1196 | */ | |
1197 | void SetPropertyValue( wxPGPropArg id, const wxArrayString& value ) | |
1198 | { | |
1199 | wxVariant v(value); | |
1200 | SetPropVal( id, v ); | |
1201 | } | |
1202 | ||
1203 | #if wxUSE_DATETIME | |
1204 | void SetPropertyValue( wxPGPropArg id, const wxDateTime& value ) | |
1205 | { | |
1206 | wxVariant v(value); | |
1207 | SetPropVal( id, v ); | |
1208 | } | |
1209 | #endif | |
1210 | ||
1211 | /** Sets value (wxObject*) of a property. | |
1212 | */ | |
1213 | void SetPropertyValue( wxPGPropArg id, wxObject* value ) | |
1214 | { | |
1215 | wxVariant v(value); | |
1216 | SetPropVal( id, v ); | |
1217 | } | |
1218 | ||
1219 | void SetPropertyValue( wxPGPropArg id, wxObject& value ) | |
1220 | { | |
1221 | wxVariant v(&value); | |
1222 | SetPropVal( id, v ); | |
1223 | } | |
1224 | ||
4e00b908 | 1225 | #ifdef wxLongLong_t |
1c4293cb VZ |
1226 | /** Sets value (wxLongLong&) of a property. |
1227 | */ | |
1228 | void SetPropertyValue( wxPGPropArg id, wxLongLong_t value ) | |
1229 | { | |
1230 | wxVariant v = WXVARIANT(wxLongLong(value)); | |
1231 | SetPropVal( id, v ); | |
1232 | } | |
1233 | /** Sets value (wxULongLong&) of a property. | |
1234 | */ | |
1235 | void SetPropertyValue( wxPGPropArg id, wxULongLong_t value ) | |
1236 | { | |
1237 | wxVariant v = WXVARIANT(wxULongLong(value)); | |
1238 | SetPropVal( id, v ); | |
1239 | } | |
0dc44cac JS |
1240 | #endif |
1241 | ||
1c4293cb VZ |
1242 | /** Sets value (wxArrayInt&) of a property. |
1243 | */ | |
1244 | void SetPropertyValue( wxPGPropArg id, const wxArrayInt& value ) | |
1245 | { | |
1246 | wxVariant v = WXVARIANT(value); | |
1247 | SetPropVal( id, v ); | |
1248 | } | |
1c4293cb VZ |
1249 | |
1250 | /** Sets value (wxString) of a property. | |
1251 | ||
1252 | @remarks | |
1253 | This method uses wxPGProperty::SetValueFromString, which all properties | |
1254 | should implement. This means that there should not be a type error, | |
1255 | and instead the string is converted to property's actual value type. | |
1256 | */ | |
1257 | void SetPropertyValueString( wxPGPropArg id, const wxString& value ); | |
1258 | ||
1259 | /** Sets value (wxVariant&) of a property. | |
1260 | ||
1261 | @remarks | |
1262 | Use wxPropertyGrid::ChangePropertyValue() instead if you need to run | |
1263 | through validation process and send property change event. | |
1264 | */ | |
1265 | void SetPropertyValue( wxPGPropArg id, wxVariant value ) | |
1266 | { | |
1267 | SetPropVal( id, value ); | |
1268 | } | |
1269 | ||
1c4293cb VZ |
1270 | /** Sets value (wxVariant&) of a property. Same as SetPropertyValue, but |
1271 | accepts reference. */ | |
1272 | void SetPropVal( wxPGPropArg id, wxVariant& value ); | |
1c4293cb VZ |
1273 | |
1274 | /** Adjusts how wxPropertyGrid behaves when invalid value is entered | |
1275 | in a property. | |
1276 | @param vfbFlags | |
1277 | See @link vfbflags list of valid flags values@endlink | |
1278 | */ | |
1279 | void SetValidationFailureBehavior( int vfbFlags ); | |
1280 | ||
43396981 | 1281 | /** |
0eb877f2 JS |
1282 | Sorts all properties recursively. |
1283 | ||
1284 | @param flags | |
1285 | This can contain any of the following options: | |
1286 | wxPG_SORT_TOP_LEVEL_ONLY: Only sort categories and their | |
1287 | immediate children. Sorting done by wxPG_AUTO_SORT option | |
1288 | uses this. | |
43396981 JS |
1289 | |
1290 | @see SortChildren, wxPropertyGrid::SetSortFunction | |
1291 | */ | |
0eb877f2 | 1292 | void Sort( int flags = 0 ); |
43396981 JS |
1293 | |
1294 | /** | |
1295 | Sorts children of a property. | |
1296 | ||
1297 | @param id | |
1298 | Name or pointer to a property. | |
1299 | ||
0eb877f2 JS |
1300 | @param flags |
1301 | This can contain any of the following options: | |
1302 | wxPG_RECURSE: Sorts recursively. | |
43396981 JS |
1303 | |
1304 | @see Sort, wxPropertyGrid::SetSortFunction | |
1305 | */ | |
0eb877f2 | 1306 | void SortChildren( wxPGPropArg id, int flags = 0 ) |
43396981 JS |
1307 | { |
1308 | wxPG_PROP_ARG_CALL_PROLOG() | |
0eb877f2 | 1309 | m_pState->DoSortChildren(p, flags); |
43396981 JS |
1310 | } |
1311 | ||
1c4293cb VZ |
1312 | // GetPropertyByName With nice assertion error message. |
1313 | wxPGProperty* GetPropertyByNameA( const wxString& name ) const; | |
1314 | ||
1315 | static wxPGEditor* GetEditorByName( const wxString& editorName ); | |
1316 | ||
58935d4a JS |
1317 | // NOTE: This function reselects the property and may cause |
1318 | // excess flicker, so to just call Refresh() on a rect | |
1319 | // of single property, call DrawItem() instead. | |
1c4293cb VZ |
1320 | virtual void RefreshProperty( wxPGProperty* p ) = 0; |
1321 | ||
1322 | protected: | |
1323 | ||
fc72fab6 JS |
1324 | bool DoClearSelection( bool validation = false, |
1325 | int selFlags = 0 ); | |
1326 | ||
62805170 JS |
1327 | /** |
1328 | In derived class, implement to set editable state component with | |
1329 | given name to given value. | |
1330 | */ | |
1331 | virtual bool SetEditableStateItem( const wxString& name, wxVariant value ) | |
1332 | { | |
1333 | wxUnusedVar(name); | |
1334 | wxUnusedVar(value); | |
1335 | return false; | |
1336 | } | |
1337 | ||
1338 | /** | |
1339 | In derived class, implement to return editable state component with | |
1340 | given name. | |
1341 | */ | |
1342 | virtual wxVariant GetEditableStateItem( const wxString& name ) const | |
1343 | { | |
1344 | wxUnusedVar(name); | |
1345 | return wxNullVariant; | |
1346 | } | |
1347 | ||
1c4293cb VZ |
1348 | // Returns page state data for given (sub) page (-1 means current page). |
1349 | virtual wxPropertyGridPageState* GetPageState( int pageIndex ) const | |
1350 | { | |
1351 | if ( pageIndex <= 0 ) | |
1352 | return m_pState; | |
1353 | return NULL; | |
1354 | } | |
1355 | ||
1356 | virtual bool DoSelectPage( int WXUNUSED(index) ) { return true; } | |
1357 | ||
1358 | // Default call's m_pState's BaseGetPropertyByName | |
1359 | virtual wxPGProperty* DoGetPropertyByName( const wxString& name ) const; | |
1360 | ||
1c4293cb VZ |
1361 | // Deriving classes must set this (it must be only or current page). |
1362 | wxPropertyGridPageState* m_pState; | |
1363 | ||
1364 | // Intermediate version needed due to wxVariant copying inefficiency | |
1365 | void DoSetPropertyAttribute( wxPGPropArg id, | |
1366 | const wxString& name, | |
1367 | wxVariant& value, long argFlags ); | |
1368 | ||
1369 | // Empty string object to return from member functions returning const | |
1370 | // wxString&. | |
1371 | wxString m_emptyString; | |
1372 | ||
1373 | private: | |
1374 | // Cannot be GetGrid() due to ambiguity issues. | |
1375 | wxPropertyGrid* GetPropertyGrid() | |
1376 | { | |
9a30da4d JS |
1377 | if ( !m_pState ) |
1378 | return NULL; | |
1c4293cb VZ |
1379 | return m_pState->GetGrid(); |
1380 | } | |
1381 | ||
1382 | // Cannot be GetGrid() due to ambiguity issues. | |
1383 | const wxPropertyGrid* GetPropertyGrid() const | |
1384 | { | |
9a30da4d JS |
1385 | if ( !m_pState ) |
1386 | return NULL; | |
25859335 VZ |
1387 | |
1388 | return m_pState->GetGrid(); | |
1c4293cb | 1389 | } |
1c4293cb VZ |
1390 | |
1391 | friend class wxPropertyGrid; | |
1392 | friend class wxPropertyGridManager; | |
1393 | }; | |
1394 | ||
f4bc1aa2 JS |
1395 | #endif // wxUSE_PROPGRID |
1396 | ||
1c4293cb | 1397 | #endif // __WX_PROPGRID_PROPGRIDIFACE_H__ |