]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/propgrid/property.h | |
3 | // Purpose: wxPGProperty and related support classes | |
4 | // Author: Jaakko Salli | |
5 | // Modified by: | |
6 | // Created: 2008-08-23 | |
1c4293cb | 7 | // Copyright: (c) Jaakko Salli |
526954c5 | 8 | // Licence: wxWindows licence |
1c4293cb VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifndef _WX_PROPGRID_PROPERTY_H_ | |
12 | #define _WX_PROPGRID_PROPERTY_H_ | |
13 | ||
6f631217 JS |
14 | #include "wx/defs.h" |
15 | ||
f4bc1aa2 JS |
16 | #if wxUSE_PROPGRID |
17 | ||
1c4293cb VZ |
18 | #include "wx/propgrid/propgriddefs.h" |
19 | ||
20 | // ----------------------------------------------------------------------- | |
21 | ||
22 | #define wxNullProperty ((wxPGProperty*)NULL) | |
23 | ||
24 | ||
25 | /** @class wxPGPaintData | |
26 | ||
27 | Contains information relayed to property's OnCustomPaint. | |
28 | */ | |
29 | struct wxPGPaintData | |
30 | { | |
31 | /** wxPropertyGrid. */ | |
32 | const wxPropertyGrid* m_parent; | |
33 | ||
34 | /** | |
35 | Normally -1, otherwise index to drop-down list item that has to be | |
36 | drawn. | |
37 | */ | |
38 | int m_choiceItem; | |
39 | ||
40 | /** Set to drawn width in OnCustomPaint (optional). */ | |
41 | int m_drawnWidth; | |
42 | ||
43 | /** | |
44 | In a measure item call, set this to the height of item at m_choiceItem | |
45 | index. | |
46 | */ | |
47 | int m_drawnHeight; | |
48 | }; | |
49 | ||
50 | ||
1c4293cb VZ |
51 | // space between vertical sides of a custom image |
52 | #define wxPG_CUSTOM_IMAGE_SPACINGY 1 | |
53 | ||
54 | // space between caption and selection rectangle, | |
55 | #define wxPG_CAPRECTXMARGIN 2 | |
56 | ||
57 | // horizontally and vertically | |
58 | #define wxPG_CAPRECTYMARGIN 1 | |
59 | ||
60 | ||
61 | /** @class wxPGCellRenderer | |
62 | ||
63 | Base class for wxPropertyGrid cell renderers. | |
64 | */ | |
92ffc98a | 65 | class WXDLLIMPEXP_PROPGRID wxPGCellRenderer : public wxObjectRefData |
1c4293cb VZ |
66 | { |
67 | public: | |
68 | ||
bd035313 JS |
69 | wxPGCellRenderer() |
70 | : wxObjectRefData() { } | |
1c4293cb VZ |
71 | virtual ~wxPGCellRenderer() { } |
72 | ||
73 | // Render flags | |
74 | enum | |
75 | { | |
d7e2b522 | 76 | // We are painting selected item |
1c4293cb | 77 | Selected = 0x00010000, |
d7e2b522 JS |
78 | |
79 | // We are painting item in choice popup | |
80 | ChoicePopup = 0x00020000, | |
81 | ||
82 | // We are rendering wxOwnerDrawnComboBox control | |
83 | // (or other owner drawn control, but that is only | |
84 | // officially supported one ATM). | |
85 | Control = 0x00040000, | |
86 | ||
87 | // We are painting a disable property | |
88 | Disabled = 0x00080000, | |
89 | ||
90 | // We are painting selected, disabled, or similar | |
91 | // item that dictates fore- and background colours, | |
92 | // overriding any cell values. | |
93 | DontUseCellFgCol = 0x00100000, | |
94 | DontUseCellBgCol = 0x00200000, | |
95 | DontUseCellColours = DontUseCellFgCol | | |
96 | DontUseCellBgCol | |
1c4293cb VZ |
97 | }; |
98 | ||
e16bff8e JS |
99 | /** |
100 | Returns @true if rendered something in the foreground (text or | |
101 | bitmap. | |
102 | */ | |
103 | virtual bool Render( wxDC& dc, | |
1c4293cb VZ |
104 | const wxRect& rect, |
105 | const wxPropertyGrid* propertyGrid, | |
106 | wxPGProperty* property, | |
107 | int column, | |
108 | int item, | |
109 | int flags ) const = 0; | |
110 | ||
111 | /** Returns size of the image in front of the editable area. | |
112 | @remarks | |
113 | If property is NULL, then this call is for a custom value. In that case | |
114 | the item is index to wxPropertyGrid's custom values. | |
115 | */ | |
116 | virtual wxSize GetImageSize( const wxPGProperty* property, | |
117 | int column, | |
118 | int item ) const; | |
119 | ||
120 | /** Paints property category selection rectangle. | |
121 | */ | |
122 | virtual void DrawCaptionSelectionRect( wxDC& dc, | |
123 | int x, int y, | |
124 | int w, int h ) const; | |
125 | ||
126 | /** Utility to draw vertically centered text. | |
127 | */ | |
128 | void DrawText( wxDC& dc, | |
129 | const wxRect& rect, | |
130 | int imageWidth, | |
131 | const wxString& text ) const; | |
132 | ||
133 | /** | |
134 | Utility to draw editor's value, or vertically aligned text if editor is | |
135 | NULL. | |
136 | */ | |
137 | void DrawEditorValue( wxDC& dc, const wxRect& rect, | |
138 | int xOffset, const wxString& text, | |
139 | wxPGProperty* property, | |
140 | const wxPGEditor* editor ) const; | |
141 | ||
aaf5f986 JS |
142 | /** Utility to render cell bitmap and set text colour plus bg brush |
143 | colour. | |
1c4293cb | 144 | |
aaf5f986 JS |
145 | @return Returns image width, which, for instance, can be passed to |
146 | DrawText. | |
1c4293cb VZ |
147 | */ |
148 | int PreDrawCell( wxDC& dc, | |
149 | const wxRect& rect, | |
150 | const wxPGCell& cell, | |
151 | int flags ) const; | |
aaf5f986 JS |
152 | |
153 | /** | |
154 | Utility to be called after drawing is done, to revert whatever | |
155 | changes PreDrawCell() did. | |
156 | ||
157 | @param flags | |
158 | Same as those passed to PreDrawCell(). | |
159 | */ | |
160 | void PostDrawCell( wxDC& dc, | |
161 | const wxPropertyGrid* propGrid, | |
162 | const wxPGCell& cell, | |
163 | int flags ) const; | |
1c4293cb VZ |
164 | }; |
165 | ||
166 | ||
b4a72504 JS |
167 | /** |
168 | @class wxPGDefaultRenderer | |
169 | ||
170 | Default cell renderer, that can handles the common | |
171 | scenarios. | |
172 | */ | |
173 | class WXDLLIMPEXP_PROPGRID wxPGDefaultRenderer : public wxPGCellRenderer | |
174 | { | |
175 | public: | |
e16bff8e | 176 | virtual bool Render( wxDC& dc, |
b4a72504 JS |
177 | const wxRect& rect, |
178 | const wxPropertyGrid* propertyGrid, | |
179 | wxPGProperty* property, | |
180 | int column, | |
181 | int item, | |
182 | int flags ) const; | |
183 | ||
184 | virtual wxSize GetImageSize( const wxPGProperty* property, | |
185 | int column, | |
186 | int item ) const; | |
187 | ||
188 | protected: | |
189 | }; | |
190 | ||
191 | ||
d7e2b522 JS |
192 | class WXDLLIMPEXP_PROPGRID wxPGCellData : public wxObjectRefData |
193 | { | |
194 | friend class wxPGCell; | |
195 | public: | |
196 | wxPGCellData(); | |
197 | ||
198 | void SetText( const wxString& text ) | |
199 | { | |
200 | m_text = text; | |
201 | m_hasValidText = true; | |
202 | } | |
203 | void SetBitmap( const wxBitmap& bitmap ) { m_bitmap = bitmap; } | |
204 | void SetFgCol( const wxColour& col ) { m_fgCol = col; } | |
205 | void SetBgCol( const wxColour& col ) { m_bgCol = col; } | |
aaf5f986 | 206 | void SetFont( const wxFont& font ) { m_font = font; } |
d7e2b522 JS |
207 | |
208 | protected: | |
209 | virtual ~wxPGCellData() { } | |
210 | ||
211 | wxString m_text; | |
212 | wxBitmap m_bitmap; | |
213 | wxColour m_fgCol; | |
214 | wxColour m_bgCol; | |
aaf5f986 | 215 | wxFont m_font; |
d7e2b522 JS |
216 | |
217 | // True if m_text is valid and specified | |
218 | bool m_hasValidText; | |
219 | }; | |
220 | ||
b4a72504 | 221 | |
aaf5f986 JS |
222 | /** |
223 | @class wxPGCell | |
1c4293cb | 224 | |
aaf5f986 | 225 | Base class for wxPropertyGrid cell information. |
1c4293cb | 226 | */ |
d7e2b522 | 227 | class WXDLLIMPEXP_PROPGRID wxPGCell : public wxObject |
1c4293cb VZ |
228 | { |
229 | public: | |
230 | wxPGCell(); | |
18415eb5 VZ |
231 | wxPGCell(const wxPGCell& other) |
232 | : wxObject(other) | |
d7e2b522 | 233 | { |
d7e2b522 JS |
234 | } |
235 | ||
1c4293cb VZ |
236 | wxPGCell( const wxString& text, |
237 | const wxBitmap& bitmap = wxNullBitmap, | |
238 | const wxColour& fgCol = wxNullColour, | |
239 | const wxColour& bgCol = wxNullColour ); | |
240 | ||
241 | virtual ~wxPGCell() { } | |
242 | ||
d7e2b522 JS |
243 | wxPGCellData* GetData() |
244 | { | |
245 | return (wxPGCellData*) m_refData; | |
246 | } | |
247 | ||
248 | const wxPGCellData* GetData() const | |
249 | { | |
250 | return (const wxPGCellData*) m_refData; | |
251 | } | |
252 | ||
253 | bool HasText() const | |
254 | { | |
255 | return (m_refData && GetData()->m_hasValidText); | |
256 | } | |
1c4293cb | 257 | |
3e6d8c31 JS |
258 | /** |
259 | Sets empty but valid data to this cell object. | |
260 | */ | |
261 | void SetEmptyData(); | |
262 | ||
d7e2b522 JS |
263 | /** |
264 | Merges valid data from srcCell into this. | |
265 | */ | |
266 | void MergeFrom( const wxPGCell& srcCell ); | |
267 | ||
268 | void SetText( const wxString& text ); | |
269 | void SetBitmap( const wxBitmap& bitmap ); | |
270 | void SetFgCol( const wxColour& col ); | |
aaf5f986 JS |
271 | |
272 | /** | |
273 | Sets font of the cell. | |
274 | ||
275 | @remarks Because wxPropertyGrid does not support rows of | |
276 | different height, it makes little sense to change | |
277 | size of the font. Therefore it is recommended | |
278 | to use return value of wxPropertyGrid::GetFont() | |
279 | or wxPropertyGrid::GetCaptionFont() as a basis | |
280 | for the font that, after modifications, is passed | |
281 | to this member function. | |
282 | */ | |
283 | void SetFont( const wxFont& font ); | |
284 | ||
d7e2b522 JS |
285 | void SetBgCol( const wxColour& col ); |
286 | ||
287 | const wxString& GetText() const { return GetData()->m_text; } | |
288 | const wxBitmap& GetBitmap() const { return GetData()->m_bitmap; } | |
289 | const wxColour& GetFgCol() const { return GetData()->m_fgCol; } | |
aaf5f986 JS |
290 | |
291 | /** | |
292 | Returns font of the cell. If no specific font is set for this | |
293 | cell, then the font will be invalid. | |
294 | */ | |
295 | const wxFont& GetFont() const { return GetData()->m_font; } | |
296 | ||
d7e2b522 JS |
297 | const wxColour& GetBgCol() const { return GetData()->m_bgCol; } |
298 | ||
299 | wxPGCell& operator=( const wxPGCell& other ) | |
300 | { | |
301 | if ( this != &other ) | |
302 | { | |
303 | Ref(other); | |
304 | } | |
305 | return *this; | |
306 | } | |
1c4293cb | 307 | |
ed8b46bb JS |
308 | // Used mostly internally to figure out if this cell is supposed |
309 | // to have default values when attached to a grid. | |
310 | bool IsInvalid() const | |
311 | { | |
312 | return ( m_refData == NULL ); | |
313 | } | |
314 | ||
b4a72504 | 315 | private: |
d7e2b522 JS |
316 | virtual wxObjectRefData *CreateRefData() const |
317 | { return new wxPGCellData(); } | |
318 | ||
319 | virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; | |
1c4293cb VZ |
320 | }; |
321 | ||
1c4293cb VZ |
322 | // ----------------------------------------------------------------------- |
323 | ||
324 | /** @class wxPGAttributeStorage | |
325 | ||
326 | wxPGAttributeStorage is somewhat optimized storage for | |
327 | key=variant pairs (ie. a map). | |
328 | */ | |
329 | class WXDLLIMPEXP_PROPGRID wxPGAttributeStorage | |
330 | { | |
331 | public: | |
332 | wxPGAttributeStorage(); | |
333 | ~wxPGAttributeStorage(); | |
334 | ||
335 | void Set( const wxString& name, const wxVariant& value ); | |
68bcfd2c | 336 | unsigned int GetCount() const { return (unsigned int) m_map.size(); } |
1c4293cb VZ |
337 | wxVariant FindValue( const wxString& name ) const |
338 | { | |
339 | wxPGHashMapS2P::const_iterator it = m_map.find(name); | |
340 | if ( it != m_map.end() ) | |
341 | { | |
342 | wxVariantData* data = (wxVariantData*) it->second; | |
343 | data->IncRef(); | |
344 | return wxVariant(data, it->first); | |
345 | } | |
346 | return wxVariant(); | |
347 | } | |
348 | ||
349 | typedef wxPGHashMapS2P::const_iterator const_iterator; | |
350 | const_iterator StartIteration() const | |
351 | { | |
352 | return m_map.begin(); | |
353 | } | |
354 | bool GetNext( const_iterator& it, wxVariant& variant ) const | |
355 | { | |
356 | if ( it == m_map.end() ) | |
357 | return false; | |
358 | ||
359 | wxVariantData* data = (wxVariantData*) it->second; | |
360 | data->IncRef(); | |
361 | variant.SetData(data); | |
362 | variant.SetName(it->first); | |
a09307ab | 363 | ++it; |
1c4293cb VZ |
364 | return true; |
365 | } | |
366 | ||
367 | protected: | |
368 | wxPGHashMapS2P m_map; | |
369 | }; | |
370 | ||
1c4293cb VZ |
371 | |
372 | // ----------------------------------------------------------------------- | |
373 | ||
374 | /** @section propgrid_propflags wxPGProperty Flags | |
375 | @{ | |
376 | */ | |
377 | ||
6cf5edea | 378 | enum wxPGPropertyFlags |
1c4293cb VZ |
379 | { |
380 | ||
381 | /** Indicates bold font. | |
382 | */ | |
383 | wxPG_PROP_MODIFIED = 0x0001, | |
384 | ||
385 | /** Disables ('greyed' text and editor does not activate) property. | |
386 | */ | |
387 | wxPG_PROP_DISABLED = 0x0002, | |
388 | ||
389 | /** Hider button will hide this property. | |
390 | */ | |
391 | wxPG_PROP_HIDDEN = 0x0004, | |
392 | ||
393 | /** This property has custom paint image just in front of its value. | |
394 | If property only draws custom images into a popup list, then this | |
395 | flag should not be set. | |
396 | */ | |
397 | wxPG_PROP_CUSTOMIMAGE = 0x0008, | |
398 | ||
399 | /** Do not create text based editor for this property (but button-triggered | |
400 | dialog and choice are ok). | |
401 | */ | |
402 | wxPG_PROP_NOEDITOR = 0x0010, | |
403 | ||
404 | /** Property is collapsed, ie. it's children are hidden. | |
405 | */ | |
406 | wxPG_PROP_COLLAPSED = 0x0020, | |
407 | ||
408 | /** | |
409 | If property is selected, then indicates that validation failed for pending | |
410 | value. | |
411 | ||
4c51a665 DS |
412 | If property is not selected, that indicates that the actual property |
413 | value has failed validation (NB: this behaviour is not currently supported, | |
1c4293cb VZ |
414 | but may be used in future). |
415 | */ | |
416 | wxPG_PROP_INVALID_VALUE = 0x0040, | |
417 | ||
418 | // 0x0080, | |
419 | ||
420 | /** Switched via SetWasModified(). Temporary flag - only used when | |
421 | setting/changing property value. | |
422 | */ | |
423 | wxPG_PROP_WAS_MODIFIED = 0x0200, | |
424 | ||
425 | /** | |
426 | If set, then child properties (if any) are private, and should be | |
427 | "invisible" to the application. | |
428 | */ | |
429 | wxPG_PROP_AGGREGATE = 0x0400, | |
430 | ||
431 | /** If set, then child properties (if any) are copies and should not | |
432 | be deleted in dtor. | |
433 | */ | |
434 | wxPG_PROP_CHILDREN_ARE_COPIES = 0x0800, | |
435 | ||
436 | /** | |
437 | Classifies this item as a non-category. | |
438 | ||
439 | Used for faster item type identification. | |
440 | */ | |
441 | wxPG_PROP_PROPERTY = 0x1000, | |
442 | ||
443 | /** | |
444 | Classifies this item as a category. | |
445 | ||
446 | Used for faster item type identification. | |
447 | */ | |
448 | wxPG_PROP_CATEGORY = 0x2000, | |
449 | ||
450 | /** Classifies this item as a property that has children, but is not aggregate | |
451 | (ie children are not private). | |
452 | */ | |
453 | wxPG_PROP_MISC_PARENT = 0x4000, | |
454 | ||
c05fe841 JS |
455 | /** Property is read-only. Editor is still created for wxTextCtrl-based |
456 | property editors. For others, editor is not usually created because | |
457 | they do implement wxTE_READONLY style or equivalent. | |
1c4293cb VZ |
458 | */ |
459 | wxPG_PROP_READONLY = 0x8000, | |
460 | ||
461 | // | |
462 | // NB: FLAGS ABOVE 0x8000 CANNOT BE USED WITH PROPERTY ITERATORS | |
463 | // | |
464 | ||
465 | /** Property's value is composed from values of child properties. | |
466 | @remarks | |
467 | This flag cannot be used with property iterators. | |
468 | */ | |
469 | wxPG_PROP_COMPOSED_VALUE = 0x00010000, | |
470 | ||
471 | /** Common value of property is selectable in editor. | |
472 | @remarks | |
473 | This flag cannot be used with property iterators. | |
474 | */ | |
475 | wxPG_PROP_USES_COMMON_VALUE = 0x00020000, | |
476 | ||
477 | /** Property can be set to unspecified value via editor. | |
478 | Currently, this applies to following properties: | |
479 | - wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty: | |
480 | Clear the text field | |
481 | ||
482 | @remarks | |
483 | This flag cannot be used with property iterators. | |
6c78066f JS |
484 | |
485 | @see wxPGProperty::SetAutoUnspecified() | |
1c4293cb VZ |
486 | */ |
487 | wxPG_PROP_AUTO_UNSPECIFIED = 0x00040000, | |
488 | ||
489 | /** Indicates the bit useable by derived properties. | |
490 | */ | |
491 | wxPG_PROP_CLASS_SPECIFIC_1 = 0x00080000, | |
492 | ||
493 | /** Indicates the bit useable by derived properties. | |
494 | */ | |
fc72fab6 JS |
495 | wxPG_PROP_CLASS_SPECIFIC_2 = 0x00100000, |
496 | ||
497 | /** Indicates that the property is being deleted and should be ignored. | |
498 | */ | |
499 | wxPG_PROP_BEING_DELETED = 0x00200000 | |
1c4293cb VZ |
500 | |
501 | }; | |
502 | ||
503 | /** Topmost flag. | |
504 | */ | |
505 | #define wxPG_PROP_MAX wxPG_PROP_AUTO_UNSPECIFIED | |
506 | ||
507 | /** Property with children must have one of these set, otherwise iterators | |
508 | will not work correctly. | |
509 | Code should automatically take care of this, however. | |
510 | */ | |
511 | #define wxPG_PROP_PARENTAL_FLAGS \ | |
6cf5edea JS |
512 | ((wxPGPropertyFlags)(wxPG_PROP_AGGREGATE | \ |
513 | wxPG_PROP_CATEGORY | \ | |
514 | wxPG_PROP_MISC_PARENT)) | |
1c4293cb VZ |
515 | |
516 | /** @} | |
517 | */ | |
518 | ||
1c4293cb VZ |
519 | // Combination of flags that can be stored by GetFlagsAsString |
520 | #define wxPG_STRING_STORED_FLAGS \ | |
521 | (wxPG_PROP_DISABLED|wxPG_PROP_HIDDEN|wxPG_PROP_NOEDITOR|wxPG_PROP_COLLAPSED) | |
522 | ||
523 | // ----------------------------------------------------------------------- | |
524 | ||
1c4293cb VZ |
525 | /** |
526 | @section propgrid_property_attributes wxPropertyGrid Property Attribute | |
527 | Identifiers. | |
528 | ||
529 | wxPGProperty::SetAttribute() and | |
15cbcd00 | 530 | wxPropertyGridInterface::SetPropertyAttribute() accept one of these as |
1c4293cb VZ |
531 | attribute name argument. |
532 | ||
533 | You can use strings instead of constants. However, some of these | |
534 | constants are redefined to use cached strings which may reduce | |
535 | your binary size by some amount. | |
536 | ||
537 | @{ | |
538 | */ | |
539 | ||
540 | /** Set default value for property. | |
541 | */ | |
542 | #define wxPG_ATTR_DEFAULT_VALUE wxS("DefaultValue") | |
543 | ||
544 | /** Universal, int or double. Minimum value for numeric properties. | |
545 | */ | |
546 | #define wxPG_ATTR_MIN wxS("Min") | |
547 | ||
548 | /** Universal, int or double. Maximum value for numeric properties. | |
549 | */ | |
550 | #define wxPG_ATTR_MAX wxS("Max") | |
551 | ||
552 | /** Universal, string. When set, will be shown as text after the displayed | |
553 | text value. Alternatively, if third column is enabled, text will be shown | |
554 | there (for any type of property). | |
555 | */ | |
556 | #define wxPG_ATTR_UNITS wxS("Units") | |
557 | ||
534090e3 JS |
558 | /** When set, will be shown as 'greyed' text in property's value cell when |
559 | the actual displayed value is blank. | |
560 | */ | |
561 | #define wxPG_ATTR_HINT wxS("Hint") | |
562 | ||
563 | #if wxPG_COMPATIBILITY_1_4 | |
564 | /** | |
4fe6eca4 | 565 | @deprecated Use "Hint" (wxPG_ATTR_HINT) instead. |
1c4293cb VZ |
566 | */ |
567 | #define wxPG_ATTR_INLINE_HELP wxS("InlineHelp") | |
534090e3 | 568 | #endif |
1c4293cb | 569 | |
66fb9e12 JS |
570 | /** Universal, wxArrayString. Set to enable auto-completion in any |
571 | wxTextCtrl-based property editor. | |
572 | */ | |
573 | #define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete") | |
574 | ||
16372f0d JS |
575 | /** wxBoolProperty and wxFlagsProperty specific. Value type is bool. |
576 | Default value is False. | |
577 | ||
578 | When set to True, bool property will use check box instead of a | |
579 | combo box as its editor control. If you set this attribute | |
580 | for a wxFlagsProperty, it is automatically applied to child | |
581 | bool properties. | |
1c4293cb VZ |
582 | */ |
583 | #define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox") | |
584 | ||
16372f0d JS |
585 | /** wxBoolProperty and wxFlagsProperty specific. Value type is bool. |
586 | Default value is False. | |
587 | ||
588 | Set to True for the bool property to cycle value on double click | |
589 | (instead of showing the popup listbox). If you set this attribute | |
590 | for a wxFlagsProperty, it is automatically applied to child | |
591 | bool properties. | |
1c4293cb VZ |
592 | */ |
593 | #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling") | |
594 | ||
595 | /** | |
596 | wxFloatProperty (and similar) specific, int, default -1. | |
597 | ||
598 | Sets the (max) precision used when floating point value is rendered as | |
599 | text. The default -1 means infinite precision. | |
600 | */ | |
601 | #define wxPG_FLOAT_PRECISION wxS("Precision") | |
602 | ||
603 | /** | |
604 | The text will be echoed as asterisks (wxTE_PASSWORD will be passed to | |
605 | textctrl etc). | |
606 | */ | |
607 | #define wxPG_STRING_PASSWORD wxS("Password") | |
608 | ||
609 | /** Define base used by a wxUIntProperty. Valid constants are | |
610 | wxPG_BASE_OCT, wxPG_BASE_DEC, wxPG_BASE_HEX and wxPG_BASE_HEXL | |
611 | (lowercase characters). | |
612 | */ | |
613 | #define wxPG_UINT_BASE wxS("Base") | |
614 | ||
615 | /** Define prefix rendered to wxUIntProperty. Accepted constants | |
616 | wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and wxPG_PREFIX_DOLLAR_SIGN. | |
617 | <b>Note:</b> Only wxPG_PREFIX_NONE works with Decimal and Octal | |
618 | numbers. | |
619 | */ | |
620 | #define wxPG_UINT_PREFIX wxS("Prefix") | |
621 | ||
622 | /** | |
623 | wxFileProperty/wxImageFileProperty specific, wxChar*, default is | |
624 | detected/varies. | |
625 | Sets the wildcard used in the triggered wxFileDialog. Format is the same. | |
626 | */ | |
627 | #define wxPG_FILE_WILDCARD wxS("Wildcard") | |
628 | ||
629 | /** wxFileProperty/wxImageFileProperty specific, int, default 1. | |
630 | When 0, only the file name is shown (i.e. drive and directory are hidden). | |
631 | */ | |
632 | #define wxPG_FILE_SHOW_FULL_PATH wxS("ShowFullPath") | |
633 | ||
634 | /** Specific to wxFileProperty and derived properties, wxString, default empty. | |
635 | If set, then the filename is shown relative to the given path string. | |
636 | */ | |
637 | #define wxPG_FILE_SHOW_RELATIVE_PATH wxS("ShowRelativePath") | |
638 | ||
639 | /** | |
640 | Specific to wxFileProperty and derived properties, wxString, default is | |
641 | empty. | |
642 | ||
643 | Sets the initial path of where to look for files. | |
644 | */ | |
645 | #define wxPG_FILE_INITIAL_PATH wxS("InitialPath") | |
646 | ||
647 | /** Specific to wxFileProperty and derivatives, wxString, default is empty. | |
648 | Sets a specific title for the dir dialog. | |
649 | */ | |
650 | #define wxPG_FILE_DIALOG_TITLE wxS("DialogTitle") | |
651 | ||
2d5409f9 VZ |
652 | /** Specific to wxFileProperty and derivatives, long, default is 0. |
653 | Sets a specific wxFileDialog style for the file dialog. | |
654 | */ | |
655 | #define wxPG_FILE_DIALOG_STYLE wxS("DialogStyle") | |
656 | ||
1c4293cb VZ |
657 | /** Specific to wxDirProperty, wxString, default is empty. |
658 | Sets a specific message for the dir dialog. | |
659 | */ | |
660 | #define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage") | |
661 | ||
525b2912 | 662 | /** |
4c51a665 | 663 | wxArrayStringProperty's string delimiter character. If this is a quotation |
525b2912 JS |
664 | mark or hyphen, then strings will be quoted instead (with given |
665 | character). | |
666 | ||
667 | Default delimiter is quotation mark. | |
668 | */ | |
669 | #define wxPG_ARRAY_DELIMITER wxS("Delimiter") | |
670 | ||
1c4293cb VZ |
671 | /** Sets displayed date format for wxDateProperty. |
672 | */ | |
673 | #define wxPG_DATE_FORMAT wxS("DateFormat") | |
674 | ||
675 | /** Sets wxDatePickerCtrl window style used with wxDateProperty. Default | |
676 | is wxDP_DEFAULT | wxDP_SHOWCENTURY. | |
677 | */ | |
678 | #define wxPG_DATE_PICKER_STYLE wxS("PickerStyle") | |
679 | ||
680 | /** SpinCtrl editor, int or double. How much number changes when button is | |
4c51a665 | 681 | pressed (or up/down on keyboard). |
1c4293cb VZ |
682 | */ |
683 | #define wxPG_ATTR_SPINCTRL_STEP wxS("Step") | |
684 | ||
685 | /** SpinCtrl editor, bool. If true, value wraps at Min/Max. | |
686 | */ | |
687 | #define wxPG_ATTR_SPINCTRL_WRAP wxS("Wrap") | |
688 | ||
689 | /** | |
690 | wxMultiChoiceProperty, int. | |
691 | If 0, no user strings allowed. If 1, user strings appear before list | |
692 | strings. If 2, user strings appear after list string. | |
693 | */ | |
694 | #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode") | |
695 | ||
696 | /** | |
697 | wxColourProperty and its kind, int, default 1. | |
698 | ||
699 | Setting this attribute to 0 hides custom colour from property's list of | |
700 | choices. | |
701 | */ | |
702 | #define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom") | |
703 | ||
6f3f3898 JS |
704 | /** |
705 | wxColourProperty and its kind: Set to True in order to support editing | |
706 | alpha colour component. | |
707 | */ | |
708 | #define wxPG_COLOUR_HAS_ALPHA wxS("HasAlpha") | |
709 | ||
1c4293cb VZ |
710 | /** @} |
711 | */ | |
712 | ||
1c4293cb | 713 | // Redefine attribute macros to use cached strings |
0ce8e27f JS |
714 | #undef wxPG_ATTR_DEFAULT_VALUE |
715 | #define wxPG_ATTR_DEFAULT_VALUE wxPGGlobalVars->m_strDefaultValue | |
1c4293cb VZ |
716 | #undef wxPG_ATTR_MIN |
717 | #define wxPG_ATTR_MIN wxPGGlobalVars->m_strMin | |
718 | #undef wxPG_ATTR_MAX | |
719 | #define wxPG_ATTR_MAX wxPGGlobalVars->m_strMax | |
720 | #undef wxPG_ATTR_UNITS | |
721 | #define wxPG_ATTR_UNITS wxPGGlobalVars->m_strUnits | |
534090e3 JS |
722 | #undef wxPG_ATTR_HINT |
723 | #define wxPG_ATTR_HINT wxPGGlobalVars->m_strHint | |
724 | #if wxPG_COMPATIBILITY_1_4 | |
1c4293cb VZ |
725 | #undef wxPG_ATTR_INLINE_HELP |
726 | #define wxPG_ATTR_INLINE_HELP wxPGGlobalVars->m_strInlineHelp | |
534090e3 | 727 | #endif |
1c4293cb | 728 | |
1c4293cb VZ |
729 | // ----------------------------------------------------------------------- |
730 | ||
939d9364 JS |
731 | /** @class wxPGChoiceEntry |
732 | Data of a single wxPGChoices choice. | |
1c4293cb | 733 | */ |
939d9364 | 734 | class WXDLLIMPEXP_PROPGRID wxPGChoiceEntry : public wxPGCell |
1c4293cb | 735 | { |
1c4293cb | 736 | public: |
939d9364 | 737 | wxPGChoiceEntry(); |
d7e2b522 | 738 | wxPGChoiceEntry(const wxPGChoiceEntry& other) |
18415eb5 | 739 | : wxPGCell(other) |
d7e2b522 | 740 | { |
d7e2b522 JS |
741 | m_value = other.m_value; |
742 | } | |
939d9364 JS |
743 | wxPGChoiceEntry( const wxString& label, |
744 | int value = wxPG_INVALID_VALUE ) | |
745 | : wxPGCell(), m_value(value) | |
746 | { | |
d7e2b522 | 747 | SetText(label); |
939d9364 | 748 | } |
1c4293cb | 749 | |
d7e2b522 | 750 | virtual ~wxPGChoiceEntry() { } |
1c4293cb | 751 | |
939d9364 | 752 | void SetValue( int value ) { m_value = value; } |
939d9364 | 753 | int GetValue() const { return m_value; } |
1c4293cb | 754 | |
d7e2b522 JS |
755 | wxPGChoiceEntry& operator=( const wxPGChoiceEntry& other ) |
756 | { | |
757 | if ( this != &other ) | |
758 | { | |
759 | Ref(other); | |
760 | } | |
761 | m_value = other.m_value; | |
762 | return *this; | |
763 | } | |
764 | ||
939d9364 JS |
765 | protected: |
766 | int m_value; | |
767 | }; | |
1c4293cb | 768 | |
1c4293cb | 769 | |
939d9364 | 770 | typedef void* wxPGChoicesId; |
1c4293cb | 771 | |
92ffc98a | 772 | class WXDLLIMPEXP_PROPGRID wxPGChoicesData : public wxObjectRefData |
939d9364 JS |
773 | { |
774 | friend class wxPGChoices; | |
775 | public: | |
776 | // Constructor sets m_refCount to 1. | |
777 | wxPGChoicesData(); | |
1c4293cb | 778 | |
939d9364 | 779 | void CopyDataFrom( wxPGChoicesData* data ); |
1c4293cb | 780 | |
d7e2b522 | 781 | wxPGChoiceEntry& Insert( int index, const wxPGChoiceEntry& item ); |
1c4293cb | 782 | |
939d9364 JS |
783 | // Delete all entries |
784 | void Clear(); | |
1c4293cb | 785 | |
68bcfd2c JS |
786 | unsigned int GetCount() const |
787 | { | |
788 | return (unsigned int) m_items.size(); | |
789 | } | |
1c4293cb | 790 | |
d7e2b522 | 791 | const wxPGChoiceEntry& Item( unsigned int i ) const |
939d9364 | 792 | { |
d7e2b522 JS |
793 | wxASSERT_MSG( i < GetCount(), "invalid index" ); |
794 | return m_items[i]; | |
795 | } | |
1c4293cb | 796 | |
d7e2b522 JS |
797 | wxPGChoiceEntry& Item( unsigned int i ) |
798 | { | |
799 | wxASSERT_MSG( i < GetCount(), "invalid index" ); | |
f7a094e1 | 800 | return m_items[i]; |
939d9364 | 801 | } |
1c4293cb | 802 | |
939d9364 | 803 | private: |
d7e2b522 | 804 | wxVector<wxPGChoiceEntry> m_items; |
1c4293cb | 805 | |
939d9364 JS |
806 | virtual ~wxPGChoicesData(); |
807 | }; | |
1c4293cb | 808 | |
939d9364 | 809 | #define wxPGChoicesEmptyData ((wxPGChoicesData*)NULL) |
1c4293cb | 810 | |
1c4293cb | 811 | |
939d9364 | 812 | /** @class wxPGChoices |
1c4293cb | 813 | |
939d9364 JS |
814 | Helper class for managing choices of wxPropertyGrid properties. |
815 | Each entry can have label, value, bitmap, text colour, and background | |
816 | colour. | |
03647350 | 817 | |
e1ef506e JS |
818 | wxPGChoices uses reference counting, similar to other wxWidgets classes. |
819 | This means that assignment operator and copy constructor only copy the | |
820 | reference and not the actual data. Use Copy() member function to create a | |
821 | real copy. | |
1c4293cb | 822 | |
98c04633 JS |
823 | @remarks If you do not specify value for entry, index is used. |
824 | ||
939d9364 JS |
825 | @library{wxpropgrid} |
826 | @category{propgrid} | |
827 | */ | |
828 | class WXDLLIMPEXP_PROPGRID wxPGChoices | |
829 | { | |
830 | public: | |
831 | typedef long ValArrItem; | |
1c4293cb | 832 | |
939d9364 JS |
833 | /** Default constructor. */ |
834 | wxPGChoices() | |
835 | { | |
836 | Init(); | |
837 | } | |
1c4293cb | 838 | |
e1ef506e JS |
839 | /** |
840 | Copy constructor, uses reference counting. To create a real copy, | |
841 | use Copy() member function instead. | |
842 | */ | |
939d9364 JS |
843 | wxPGChoices( const wxPGChoices& a ) |
844 | { | |
845 | if ( a.m_data != wxPGChoicesEmptyData ) | |
846 | { | |
847 | m_data = a.m_data; | |
92ffc98a | 848 | m_data->IncRef(); |
939d9364 JS |
849 | } |
850 | } | |
1c4293cb | 851 | |
98c04633 JS |
852 | /** |
853 | Constructor. | |
854 | ||
855 | @param labels | |
856 | Labels for choices | |
857 | ||
858 | @param values | |
859 | Values for choices. If NULL, indexes are used. | |
860 | */ | |
a243da29 | 861 | wxPGChoices( const wxChar* const* labels, const long* values = NULL ) |
939d9364 JS |
862 | { |
863 | Init(); | |
864 | Set(labels,values); | |
865 | } | |
1c4293cb | 866 | |
98c04633 JS |
867 | /** |
868 | Constructor. | |
869 | ||
870 | @param labels | |
871 | Labels for choices | |
872 | ||
873 | @param values | |
874 | Values for choices. If empty, indexes are used. | |
875 | */ | |
939d9364 JS |
876 | wxPGChoices( const wxArrayString& labels, |
877 | const wxArrayInt& values = wxArrayInt() ) | |
878 | { | |
879 | Init(); | |
880 | Set(labels,values); | |
881 | } | |
1c4293cb | 882 | |
939d9364 JS |
883 | /** Simple interface constructor. */ |
884 | wxPGChoices( wxPGChoicesData* data ) | |
885 | { | |
886 | wxASSERT(data); | |
887 | m_data = data; | |
92ffc98a | 888 | data->IncRef(); |
939d9364 | 889 | } |
1c4293cb | 890 | |
939d9364 JS |
891 | /** Destructor. */ |
892 | ~wxPGChoices() | |
893 | { | |
894 | Free(); | |
895 | } | |
1c4293cb | 896 | |
939d9364 JS |
897 | /** |
898 | Adds to current. | |
1c4293cb | 899 | |
939d9364 JS |
900 | If did not have own copies, creates them now. If was empty, identical |
901 | to set except that creates copies. | |
98c04633 JS |
902 | |
903 | @param labels | |
904 | Labels for added choices. | |
905 | ||
906 | @param values | |
907 | Values for added choices. If empty, relevant entry indexes are used. | |
1c4293cb | 908 | */ |
a243da29 | 909 | void Add( const wxChar* const* labels, const ValArrItem* values = NULL ); |
1c4293cb | 910 | |
939d9364 | 911 | /** Version that works with wxArrayString and wxArrayInt. */ |
d7e2b522 | 912 | void Add( const wxArrayString& arr, const wxArrayInt& arrint = wxArrayInt() ); |
1c4293cb | 913 | |
98c04633 JS |
914 | /** |
915 | Adds a single choice. | |
916 | ||
917 | @param label | |
918 | Label for added choice. | |
919 | ||
920 | @param value | |
921 | Value for added choice. If unspecified, index is used. | |
922 | */ | |
939d9364 JS |
923 | wxPGChoiceEntry& Add( const wxString& label, |
924 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb | 925 | |
939d9364 JS |
926 | /** Adds a single item, with bitmap. */ |
927 | wxPGChoiceEntry& Add( const wxString& label, | |
928 | const wxBitmap& bitmap, | |
929 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb | 930 | |
939d9364 JS |
931 | /** Adds a single item with full entry information. */ |
932 | wxPGChoiceEntry& Add( const wxPGChoiceEntry& entry ) | |
933 | { | |
934 | return Insert(entry, -1); | |
935 | } | |
1c4293cb | 936 | |
939d9364 JS |
937 | /** Adds single item. */ |
938 | wxPGChoiceEntry& AddAsSorted( const wxString& label, | |
939 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb | 940 | |
e1ef506e JS |
941 | /** |
942 | Assigns choices data, using reference counting. To create a real copy, | |
943 | use Copy() member function instead. | |
944 | */ | |
939d9364 JS |
945 | void Assign( const wxPGChoices& a ) |
946 | { | |
947 | AssignData(a.m_data); | |
948 | } | |
1c4293cb | 949 | |
939d9364 | 950 | void AssignData( wxPGChoicesData* data ); |
1c4293cb | 951 | |
939d9364 | 952 | /** Delete all choices. */ |
2728c3bf | 953 | void Clear(); |
1c4293cb | 954 | |
e1ef506e JS |
955 | /** |
956 | Returns a real copy of the choices. | |
957 | */ | |
958 | wxPGChoices Copy() const | |
959 | { | |
960 | wxPGChoices dst; | |
961 | dst.EnsureData(); | |
962 | dst.m_data->CopyDataFrom(m_data); | |
963 | return dst; | |
964 | } | |
965 | ||
939d9364 JS |
966 | void EnsureData() |
967 | { | |
968 | if ( m_data == wxPGChoicesEmptyData ) | |
969 | m_data = new wxPGChoicesData(); | |
970 | } | |
1c4293cb | 971 | |
939d9364 | 972 | /** Gets a unsigned number identifying this list. */ |
6dd0883d | 973 | wxPGChoicesId GetId() const { return (wxPGChoicesId) m_data; } |
1c4293cb | 974 | |
68bcfd2c | 975 | const wxString& GetLabel( unsigned int ind ) const |
939d9364 JS |
976 | { |
977 | return Item(ind).GetText(); | |
978 | } | |
1c4293cb | 979 | |
68bcfd2c | 980 | unsigned int GetCount () const |
939d9364 JS |
981 | { |
982 | if ( !m_data ) | |
983 | return 0; | |
1c4293cb | 984 | |
939d9364 JS |
985 | return m_data->GetCount(); |
986 | } | |
1c4293cb | 987 | |
68bcfd2c | 988 | int GetValue( unsigned int ind ) const { return Item(ind).GetValue(); } |
1c4293cb | 989 | |
939d9364 JS |
990 | /** Returns array of values matching the given strings. Unmatching strings |
991 | result in wxPG_INVALID_VALUE entry in array. | |
1c4293cb | 992 | */ |
939d9364 | 993 | wxArrayInt GetValuesForStrings( const wxArrayString& strings ) const; |
1c4293cb | 994 | |
939d9364 JS |
995 | /** Returns array of indices matching given strings. Unmatching strings |
996 | are added to 'unmatched', if not NULL. | |
997 | */ | |
998 | wxArrayInt GetIndicesForStrings( const wxArrayString& strings, | |
999 | wxArrayString* unmatched = NULL ) const; | |
1c4293cb | 1000 | |
939d9364 JS |
1001 | int Index( const wxString& str ) const; |
1002 | int Index( int val ) const; | |
1c4293cb | 1003 | |
939d9364 JS |
1004 | /** Inserts single item. */ |
1005 | wxPGChoiceEntry& Insert( const wxString& label, | |
1006 | int index, | |
1007 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb | 1008 | |
939d9364 JS |
1009 | /** Inserts a single item with full entry information. */ |
1010 | wxPGChoiceEntry& Insert( const wxPGChoiceEntry& entry, int index ); | |
1c4293cb | 1011 | |
939d9364 JS |
1012 | /** Returns false if this is a constant empty set of choices, |
1013 | which should not be modified. | |
1c4293cb | 1014 | */ |
939d9364 JS |
1015 | bool IsOk() const |
1016 | { | |
1017 | return ( m_data != wxPGChoicesEmptyData ); | |
1018 | } | |
1c4293cb | 1019 | |
939d9364 JS |
1020 | const wxPGChoiceEntry& Item( unsigned int i ) const |
1021 | { | |
1022 | wxASSERT( IsOk() ); | |
d7e2b522 | 1023 | return m_data->Item(i); |
939d9364 | 1024 | } |
1c4293cb | 1025 | |
939d9364 JS |
1026 | wxPGChoiceEntry& Item( unsigned int i ) |
1027 | { | |
1028 | wxASSERT( IsOk() ); | |
d7e2b522 | 1029 | return m_data->Item(i); |
939d9364 | 1030 | } |
1c4293cb | 1031 | |
939d9364 JS |
1032 | /** Removes count items starting at position nIndex. */ |
1033 | void RemoveAt(size_t nIndex, size_t count = 1); | |
1c4293cb | 1034 | |
ec3cce5a JS |
1035 | /** Does not create copies for itself. |
1036 | TODO: Deprecate. | |
1037 | */ | |
a243da29 | 1038 | void Set( const wxChar* const* labels, const long* values = NULL ) |
939d9364 JS |
1039 | { |
1040 | Free(); | |
1041 | Add(labels,values); | |
1042 | } | |
939d9364 JS |
1043 | |
1044 | /** Version that works with wxArrayString and wxArrayInt. */ | |
1045 | void Set( const wxArrayString& labels, | |
1046 | const wxArrayInt& values = wxArrayInt() ) | |
1047 | { | |
1048 | Free(); | |
1049 | if ( &values ) | |
1050 | Add(labels,values); | |
1051 | else | |
1052 | Add(labels); | |
1053 | } | |
1054 | ||
1055 | // Creates exclusive copy of current choices | |
2728c3bf | 1056 | void AllocExclusive(); |
939d9364 JS |
1057 | |
1058 | // Returns data, increases refcount. | |
1059 | wxPGChoicesData* GetData() | |
1060 | { | |
92ffc98a VZ |
1061 | wxASSERT( m_data->GetRefCount() != -1 ); |
1062 | m_data->IncRef(); | |
939d9364 JS |
1063 | return m_data; |
1064 | } | |
1c4293cb | 1065 | |
939d9364 JS |
1066 | // Returns plain data ptr - no refcounting stuff is done. |
1067 | wxPGChoicesData* GetDataPtr() const { return m_data; } | |
1c4293cb | 1068 | |
939d9364 JS |
1069 | // Changes ownership of data to you. |
1070 | wxPGChoicesData* ExtractData() | |
1c4293cb | 1071 | { |
939d9364 JS |
1072 | wxPGChoicesData* data = m_data; |
1073 | m_data = wxPGChoicesEmptyData; | |
1074 | return data; | |
1c4293cb VZ |
1075 | } |
1076 | ||
939d9364 | 1077 | wxArrayString GetLabels() const; |
1c4293cb | 1078 | |
939d9364 JS |
1079 | void operator= (const wxPGChoices& a) |
1080 | { | |
a09307ab PC |
1081 | if (this != &a) |
1082 | AssignData(a.m_data); | |
1c4293cb VZ |
1083 | } |
1084 | ||
939d9364 | 1085 | wxPGChoiceEntry& operator[](unsigned int i) |
1c4293cb | 1086 | { |
939d9364 | 1087 | return Item(i); |
1c4293cb VZ |
1088 | } |
1089 | ||
939d9364 | 1090 | const wxPGChoiceEntry& operator[](unsigned int i) const |
1c4293cb | 1091 | { |
939d9364 | 1092 | return Item(i); |
1c4293cb VZ |
1093 | } |
1094 | ||
939d9364 JS |
1095 | protected: |
1096 | wxPGChoicesData* m_data; | |
1c4293cb | 1097 | |
939d9364 JS |
1098 | void Init(); |
1099 | void Free(); | |
939d9364 | 1100 | }; |
1c4293cb | 1101 | |
939d9364 | 1102 | // ----------------------------------------------------------------------- |
1c4293cb | 1103 | |
939d9364 | 1104 | /** @class wxPGProperty |
1c4293cb | 1105 | |
939d9364 | 1106 | wxPGProperty is base class for all wxPropertyGrid properties. |
1c4293cb | 1107 | |
939d9364 JS |
1108 | NB: Full class overview is now only present in |
1109 | interface/wx/propgrid/property.h. | |
1c4293cb | 1110 | |
939d9364 JS |
1111 | @library{wxpropgrid} |
1112 | @category{propgrid} | |
1113 | */ | |
1114 | class WXDLLIMPEXP_PROPGRID wxPGProperty : public wxObject | |
1115 | { | |
1116 | friend class wxPropertyGrid; | |
1117 | friend class wxPropertyGridInterface; | |
1118 | friend class wxPropertyGridPageState; | |
1119 | friend class wxPropertyGridPopulator; | |
1120 | friend class wxStringProperty; // Proper "<composed>" support requires this | |
14bac4b5 | 1121 | |
939d9364 | 1122 | DECLARE_ABSTRACT_CLASS(wxPGProperty) |
939d9364 JS |
1123 | public: |
1124 | typedef wxUint32 FlagType; | |
1c4293cb | 1125 | |
a6ca568c JS |
1126 | /** |
1127 | Default constructor. | |
1c4293cb | 1128 | */ |
939d9364 | 1129 | wxPGProperty(); |
1c4293cb | 1130 | |
a6ca568c JS |
1131 | /** |
1132 | Constructor. | |
1c4293cb | 1133 | |
a6ca568c JS |
1134 | All non-abstract property classes should have a constructor with |
1135 | the same first two arguments as this one. | |
939d9364 JS |
1136 | */ |
1137 | wxPGProperty( const wxString& label, const wxString& name ); | |
1c4293cb | 1138 | |
939d9364 JS |
1139 | /** |
1140 | Virtual destructor. | |
1141 | It is customary for derived properties to implement this. | |
1c4293cb | 1142 | */ |
939d9364 | 1143 | virtual ~wxPGProperty(); |
1c4293cb | 1144 | |
939d9364 | 1145 | /** This virtual function is called after m_value has been set. |
1c4293cb | 1146 | |
939d9364 JS |
1147 | @remarks |
1148 | - If m_value was set to Null variant (ie. unspecified value), | |
1149 | OnSetValue() will not be called. | |
1150 | - m_value may be of any variant type. Typically properties internally | |
1151 | support only one variant type, and as such OnSetValue() provides a | |
1152 | good opportunity to convert | |
1153 | supported values into internal type. | |
1154 | - Default implementation does nothing. | |
1155 | */ | |
1156 | virtual void OnSetValue(); | |
1c4293cb | 1157 | |
939d9364 JS |
1158 | /** Override this to return something else than m_value as the value. |
1159 | */ | |
1160 | virtual wxVariant DoGetValue() const { return m_value; } | |
1161 | ||
939d9364 JS |
1162 | /** Implement this function in derived class to check the value. |
1163 | Return true if it is ok. Returning false prevents property change events | |
1164 | from occurring. | |
1c4293cb | 1165 | |
1c4293cb | 1166 | @remarks |
939d9364 | 1167 | - Default implementation always returns true. |
1c4293cb | 1168 | */ |
939d9364 JS |
1169 | virtual bool ValidateValue( wxVariant& value, |
1170 | wxPGValidationInfo& validationInfo ) const; | |
1c4293cb | 1171 | |
939d9364 | 1172 | /** |
9e6bebdc JS |
1173 | Converts text into wxVariant value appropriate for this property. |
1174 | ||
1175 | @param variant | |
1176 | On function entry this is the old value (should not be wxNullVariant | |
1177 | in normal cases). Translated value must be assigned back to it. | |
1178 | ||
1179 | @param text | |
1180 | Text to be translated into variant. | |
1181 | ||
939d9364 JS |
1182 | @param argFlags |
1183 | If wxPG_FULL_VALUE is set, returns complete, storable value instead | |
1184 | of displayable one (they may be different). | |
1185 | If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of | |
1425eca5 | 1186 | composite property string value (as generated by ValueToString() |
939d9364 | 1187 | called with this same flag). |
1c4293cb | 1188 | |
9e6bebdc JS |
1189 | @return Returns @true if resulting wxVariant value was different. |
1190 | ||
1191 | @remarks Default implementation converts semicolon delimited tokens into | |
1192 | child values. Only works for properties with children. | |
1193 | ||
1194 | You might want to take into account that m_value is Null variant | |
1195 | if property value is unspecified (which is usually only case if | |
4c51a665 | 1196 | you explicitly enabled that sort behaviour). |
1c4293cb | 1197 | */ |
939d9364 JS |
1198 | virtual bool StringToValue( wxVariant& variant, |
1199 | const wxString& text, | |
1200 | int argFlags = 0 ) const; | |
1c4293cb | 1201 | |
939d9364 | 1202 | /** |
9e6bebdc JS |
1203 | Converts integer (possibly a choice selection) into wxVariant value |
1204 | appropriate for this property. | |
1c4293cb | 1205 | |
9e6bebdc JS |
1206 | @param variant |
1207 | On function entry this is the old value (should not be wxNullVariant | |
1208 | in normal cases). Translated value must be assigned back to it. | |
1209 | ||
1210 | @param number | |
1211 | Integer to be translated into variant. | |
1c4293cb | 1212 | |
939d9364 JS |
1213 | @param argFlags |
1214 | If wxPG_FULL_VALUE is set, returns complete, storable value instead | |
1215 | of displayable one. | |
1c4293cb | 1216 | |
9e6bebdc JS |
1217 | @return Returns @true if resulting wxVariant value was different. |
1218 | ||
939d9364 JS |
1219 | @remarks |
1220 | - If property is not supposed to use choice or spinctrl or other editor | |
1221 | with int-based value, it is not necessary to implement this method. | |
1222 | - Default implementation simply assign given int to m_value. | |
1223 | - If property uses choice control, and displays a dialog on some choice | |
1224 | items, then it is preferred to display that dialog in IntToValue | |
1225 | instead of OnEvent. | |
9e6bebdc JS |
1226 | - You might want to take into account that m_value is Null variant if |
1227 | property value is unspecified (which is usually only case if you | |
4c51a665 | 1228 | explicitly enabled that sort behaviour). |
1c4293cb | 1229 | */ |
939d9364 JS |
1230 | virtual bool IntToValue( wxVariant& value, |
1231 | int number, | |
1232 | int argFlags = 0 ) const; | |
ec3cce5a | 1233 | |
1425eca5 JS |
1234 | /** |
1235 | Converts property value into a text representation. | |
1c4293cb | 1236 | |
1425eca5 JS |
1237 | @param value |
1238 | Value to be converted. | |
1c4293cb | 1239 | |
939d9364 | 1240 | @param argFlags |
1425eca5 | 1241 | If 0 (default value), then displayed string is returned. |
939d9364 JS |
1242 | If wxPG_FULL_VALUE is set, returns complete, storable string value |
1243 | instead of displayable. If wxPG_EDITABLE_VALUE is set, returns | |
1244 | string value that must be editable in textctrl. If | |
1245 | wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to | |
1425eca5 JS |
1246 | display as a part of string property's composite text |
1247 | representation. | |
1c4293cb | 1248 | |
1425eca5 | 1249 | @remarks Default implementation calls GenerateComposedValue(). |
1c4293cb | 1250 | */ |
1425eca5 | 1251 | virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const; |
1c4293cb | 1252 | |
939d9364 | 1253 | /** Converts string to a value, and if successful, calls SetValue() on it. |
4c51a665 | 1254 | Default behaviour is to do nothing. |
939d9364 JS |
1255 | @param text |
1256 | String to get the value from. | |
1257 | @return | |
1258 | true if value was changed. | |
1c4293cb | 1259 | */ |
f275b5db | 1260 | bool SetValueFromString( const wxString& text, int flags = wxPG_PROGRAMMATIC_VALUE ); |
1c4293cb | 1261 | |
4c51a665 DS |
1262 | /** Converts integer to a value, and if successful, calls SetValue() on it. |
1263 | Default behaviour is to do nothing. | |
939d9364 JS |
1264 | @param value |
1265 | Int to get the value from. | |
1266 | @param flags | |
1267 | If has wxPG_FULL_VALUE, then the value given is a actual value and | |
1268 | not an index. | |
1269 | @return | |
1270 | True if value was changed. | |
1c4293cb | 1271 | */ |
939d9364 | 1272 | bool SetValueFromInt( long value, int flags = 0 ); |
1c4293cb VZ |
1273 | |
1274 | /** | |
939d9364 | 1275 | Returns size of the custom painted image in front of property. |
1c4293cb | 1276 | |
939d9364 JS |
1277 | This method must be overridden to return non-default value if |
1278 | OnCustomPaint is to be called. | |
1279 | @param item | |
1280 | Normally -1, but can be an index to the property's list of items. | |
1281 | @remarks | |
4c51a665 | 1282 | - Default behaviour is to return wxSize(0,0), which means no image. |
939d9364 JS |
1283 | - Default image width or height is indicated with dimension -1. |
1284 | - You can also return wxPG_DEFAULT_IMAGE_SIZE, i.e. wxSize(-1, -1). | |
1c4293cb | 1285 | */ |
939d9364 | 1286 | virtual wxSize OnMeasureImage( int item = -1 ) const; |
1c4293cb VZ |
1287 | |
1288 | /** | |
939d9364 | 1289 | Events received by editor widgets are processed here. |
1c4293cb | 1290 | |
939d9364 JS |
1291 | Note that editor class usually processes most events. Some, such as |
1292 | button press events of TextCtrlAndButton class, can be handled here. | |
1293 | Also, if custom handling for regular events is desired, then that can | |
1294 | also be done (for example, wxSystemColourProperty custom handles | |
ce7fe42e | 1295 | wxEVT_CHOICE to display colour picker dialog when |
939d9364 | 1296 | 'custom' selection is made). |
1c4293cb | 1297 | |
939d9364 JS |
1298 | If the event causes value to be changed, SetValueInEvent() |
1299 | should be called to set the new value. | |
1c4293cb | 1300 | |
939d9364 JS |
1301 | @param event |
1302 | Associated wxEvent. | |
1303 | @return | |
1304 | Should return true if any changes in value should be reported. | |
1305 | @remarks | |
1306 | If property uses choice control, and displays a dialog on some choice | |
1307 | items, then it is preferred to display that dialog in IntToValue | |
1308 | instead of OnEvent. | |
1c4293cb | 1309 | */ |
939d9364 JS |
1310 | virtual bool OnEvent( wxPropertyGrid* propgrid, |
1311 | wxWindow* wnd_primary, | |
1312 | wxEvent& event ); | |
1c4293cb | 1313 | |
939d9364 | 1314 | /** |
b8b1ff48 | 1315 | Called after value of a child property has been altered. Must return |
4c51a665 | 1316 | new value of the whole property (after any alterations warranted by |
b8b1ff48 | 1317 | child's new value). |
1c4293cb | 1318 | |
939d9364 | 1319 | Note that this function is usually called at the time that value of |
b8b1ff48 JS |
1320 | this property, or given child property, is still pending for change, |
1321 | and as such, result of GetValue() or m_value should not be relied | |
1322 | on. | |
1c4293cb | 1323 | |
939d9364 | 1324 | Sample pseudo-code implementation: |
1c4293cb | 1325 | |
939d9364 | 1326 | @code |
b8b1ff48 JS |
1327 | wxVariant MyProperty::ChildChanged( wxVariant& thisValue, |
1328 | int childIndex, | |
1329 | wxVariant& childValue ) const | |
939d9364 JS |
1330 | { |
1331 | // Acquire reference to actual type of data stored in variant | |
1332 | // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros | |
1333 | // were used to create the variant class). | |
1334 | T& data = TFromVariant(thisValue); | |
1c4293cb | 1335 | |
939d9364 JS |
1336 | // Copy childValue into data. |
1337 | switch ( childIndex ) | |
1338 | { | |
1339 | case 0: | |
1340 | data.SetSubProp1( childvalue.GetLong() ); | |
1341 | break; | |
1342 | case 1: | |
1343 | data.SetSubProp2( childvalue.GetString() ); | |
1344 | break; | |
1345 | ... | |
1346 | } | |
b8b1ff48 JS |
1347 | |
1348 | // Return altered data | |
1349 | return data; | |
939d9364 JS |
1350 | } |
1351 | @endcode | |
1c4293cb | 1352 | |
939d9364 | 1353 | @param thisValue |
b8b1ff48 JS |
1354 | Value of this property. Changed value should be returned (in |
1355 | previous versions of wxPropertyGrid it was only necessary to | |
1356 | write value back to this argument). | |
939d9364 | 1357 | @param childIndex |
b8b1ff48 JS |
1358 | Index of child changed (you can use Item(childIndex) to get |
1359 | child property). | |
939d9364 | 1360 | @param childValue |
b8b1ff48 JS |
1361 | (Pending) value of the child property. |
1362 | ||
1363 | @return | |
1364 | Modified value of the whole property. | |
1c4293cb | 1365 | */ |
b8b1ff48 JS |
1366 | virtual wxVariant ChildChanged( wxVariant& thisValue, |
1367 | int childIndex, | |
1368 | wxVariant& childValue ) const; | |
1c4293cb | 1369 | |
939d9364 | 1370 | /** Returns pointer to an instance of used editor. |
1c4293cb | 1371 | */ |
939d9364 | 1372 | virtual const wxPGEditor* DoGetEditorClass() const; |
1c4293cb | 1373 | |
939d9364 JS |
1374 | /** Returns pointer to the wxValidator that should be used |
1375 | with the editor of this property (NULL for no validator). | |
1376 | Setting validator explicitly via SetPropertyValidator | |
1377 | will override this. | |
1c4293cb | 1378 | |
939d9364 JS |
1379 | In most situations, code like this should work well |
1380 | (macros are used to maintain one actual validator instance, | |
1381 | so on the second call the function exits within the first | |
1382 | macro): | |
1c4293cb | 1383 | |
939d9364 | 1384 | @code |
1c4293cb | 1385 | |
939d9364 JS |
1386 | wxValidator* wxMyPropertyClass::DoGetValidator () const |
1387 | { | |
1388 | WX_PG_DOGETVALIDATOR_ENTRY() | |
1c4293cb | 1389 | |
939d9364 | 1390 | wxMyValidator* validator = new wxMyValidator(...); |
1c4293cb | 1391 | |
939d9364 | 1392 | ... prepare validator... |
1c4293cb | 1393 | |
939d9364 JS |
1394 | WX_PG_DOGETVALIDATOR_EXIT(validator) |
1395 | } | |
1c4293cb | 1396 | |
939d9364 JS |
1397 | @endcode |
1398 | ||
1399 | @remarks | |
1400 | You can get common filename validator by returning | |
1401 | wxFileProperty::GetClassValidator(). wxDirProperty, | |
1402 | for example, uses it. | |
1c4293cb | 1403 | */ |
939d9364 | 1404 | virtual wxValidator* DoGetValidator () const; |
1c4293cb | 1405 | |
939d9364 JS |
1406 | /** |
1407 | Override to paint an image in front of the property value text or | |
1408 | drop-down list item (but only if wxPGProperty::OnMeasureImage is | |
1409 | overridden as well). | |
1c4293cb | 1410 | |
939d9364 JS |
1411 | If property's OnMeasureImage() returns size that has height != 0 but |
1412 | less than row height ( < 0 has special meanings), wxPropertyGrid calls | |
1413 | this method to draw a custom image in a limited area in front of the | |
1414 | editor control or value text/graphics, and if control has drop-down | |
1415 | list, then the image is drawn there as well (even in the case | |
1416 | OnMeasureImage() returned higher height than row height). | |
1c4293cb | 1417 | |
939d9364 JS |
1418 | NOTE: Following applies when OnMeasureImage() returns a "flexible" |
1419 | height ( using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable | |
1420 | height items: If rect.x is < 0, then this is a measure item call, which | |
1421 | means that dc is invalid and only thing that should be done is to set | |
1422 | paintdata.m_drawnHeight to the height of the image of item at index | |
1423 | paintdata.m_choiceItem. This call may be done even as often as once | |
1424 | every drop-down popup show. | |
1c4293cb | 1425 | |
939d9364 JS |
1426 | @param dc |
1427 | wxDC to paint on. | |
1428 | @param rect | |
1429 | Box reserved for custom graphics. Includes surrounding rectangle, | |
1430 | if any. If x is < 0, then this is a measure item call (see above). | |
1431 | @param paintdata | |
1432 | wxPGPaintData structure with much useful data. | |
1c4293cb | 1433 | |
939d9364 JS |
1434 | @remarks |
1435 | - You can actually exceed rect width, but if you do so then | |
1436 | paintdata.m_drawnWidth must be set to the full width drawn in | |
1437 | pixels. | |
1438 | - Due to technical reasons, rect's height will be default even if | |
1439 | custom height was reported during measure call. | |
1440 | - Brush is guaranteed to be default background colour. It has been | |
1441 | already used to clear the background of area being painted. It | |
1442 | can be modified. | |
1443 | - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper | |
1444 | colour) pen for drawing framing rectangle. It can be changed as | |
1445 | well. | |
1446 | ||
1425eca5 | 1447 | @see ValueToString() |
1c4293cb | 1448 | */ |
939d9364 JS |
1449 | virtual void OnCustomPaint( wxDC& dc, |
1450 | const wxRect& rect, | |
1451 | wxPGPaintData& paintdata ); | |
1c4293cb | 1452 | |
939d9364 JS |
1453 | /** |
1454 | Returns used wxPGCellRenderer instance for given property column | |
1455 | (label=0, value=1). | |
1c4293cb | 1456 | |
939d9364 | 1457 | Default implementation returns editor's renderer for all columns. |
1c4293cb | 1458 | */ |
939d9364 | 1459 | virtual wxPGCellRenderer* GetCellRenderer( int column ) const; |
1c4293cb | 1460 | |
939d9364 JS |
1461 | /** Returns which choice is currently selected. Only applies to properties |
1462 | which have choices. | |
1c4293cb | 1463 | |
939d9364 JS |
1464 | Needs to reimplemented in derived class if property value does not |
1465 | map directly to a choice. Integer as index, bool, and string usually do. | |
1c4293cb | 1466 | */ |
939d9364 | 1467 | virtual int GetChoiceSelection() const; |
1c4293cb | 1468 | |
939d9364 JS |
1469 | /** |
1470 | Refresh values of child properties. | |
1c4293cb | 1471 | |
939d9364 | 1472 | Automatically called after value is set. |
1c4293cb | 1473 | */ |
939d9364 | 1474 | virtual void RefreshChildren(); |
1c4293cb | 1475 | |
14946ce1 JS |
1476 | /** |
1477 | Reimplement this member function to add special handling for | |
1478 | attributes of this property. | |
1c4293cb | 1479 | |
14946ce1 JS |
1480 | @return Return @false to have the attribute automatically stored in |
1481 | m_attributes. Default implementation simply does that and | |
1482 | nothing else. | |
1c4293cb | 1483 | |
14946ce1 JS |
1484 | @remarks To actually set property attribute values from the |
1485 | application, use wxPGProperty::SetAttribute() instead. | |
1c4293cb | 1486 | */ |
939d9364 | 1487 | virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); |
1c4293cb | 1488 | |
939d9364 | 1489 | /** Returns value of an attribute. |
1c4293cb | 1490 | |
939d9364 | 1491 | Override if custom handling of attributes is needed. |
1c4293cb | 1492 | |
939d9364 | 1493 | Default implementation simply return NULL variant. |
1c4293cb | 1494 | */ |
939d9364 | 1495 | virtual wxVariant DoGetAttribute( const wxString& name ) const; |
1c4293cb | 1496 | |
939d9364 JS |
1497 | /** Returns instance of a new wxPGEditorDialogAdapter instance, which is |
1498 | used when user presses the (optional) button next to the editor control; | |
1c4293cb | 1499 | |
939d9364 JS |
1500 | Default implementation returns NULL (ie. no action is generated when |
1501 | button is pressed). | |
1c4293cb | 1502 | */ |
939d9364 JS |
1503 | virtual wxPGEditorDialogAdapter* GetEditorDialog() const; |
1504 | ||
d8812c6e JS |
1505 | /** |
1506 | Called whenever validation has failed with given pending value. | |
1507 | ||
1508 | @remarks If you implement this in your custom property class, please | |
1509 | remember to call the baser implementation as well, since they | |
1510 | may use it to revert property into pre-change state. | |
1511 | */ | |
1512 | virtual void OnValidationFailure( wxVariant& pendingValue ); | |
1513 | ||
939d9364 | 1514 | /** Append a new choice to property's list of choices. |
1c4293cb | 1515 | */ |
939d9364 JS |
1516 | int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE ) |
1517 | { | |
1518 | return InsertChoice(label, wxNOT_FOUND, value); | |
1519 | } | |
1c4293cb | 1520 | |
939d9364 JS |
1521 | /** |
1522 | Returns true if children of this property are component values (for | |
1523 | instance, points size, face name, and is_underlined are component | |
1524 | values of a font). | |
1c4293cb | 1525 | */ |
939d9364 | 1526 | bool AreChildrenComponents() const |
1c4293cb | 1527 | { |
939d9364 JS |
1528 | if ( m_flags & (wxPG_PROP_COMPOSED_VALUE|wxPG_PROP_AGGREGATE) ) |
1529 | return true; | |
1530 | ||
1531 | return false; | |
1c4293cb VZ |
1532 | } |
1533 | ||
91c818f8 JS |
1534 | /** |
1535 | Deletes children of the property. | |
1536 | */ | |
1537 | void DeleteChildren(); | |
1538 | ||
939d9364 JS |
1539 | /** |
1540 | Removes entry from property's wxPGChoices and editor control (if it is | |
1541 | active). | |
1c4293cb | 1542 | |
939d9364 | 1543 | If selected item is deleted, then the value is set to unspecified. |
1c4293cb | 1544 | */ |
939d9364 | 1545 | void DeleteChoice( int index ); |
1c4293cb | 1546 | |
9ceed261 JS |
1547 | /** |
1548 | Enables or disables the property. Disabled property usually appears | |
1549 | as having grey text. | |
1550 | ||
1551 | @param enable | |
1552 | If @false, property is disabled instead. | |
1553 | ||
1554 | @see wxPropertyGridInterface::EnableProperty() | |
1555 | */ | |
1556 | void Enable( bool enable = true ); | |
1557 | ||
1c4293cb | 1558 | /** |
939d9364 JS |
1559 | Call to enable or disable usage of common value (integer value that can |
1560 | be selected for properties instead of their normal values) for this | |
1561 | property. | |
1c4293cb | 1562 | |
939d9364 JS |
1563 | Common values are disabled by the default for all properties. |
1564 | */ | |
1565 | void EnableCommonValue( bool enable = true ) | |
1566 | { | |
1567 | if ( enable ) SetFlag( wxPG_PROP_USES_COMMON_VALUE ); | |
1568 | else ClearFlag( wxPG_PROP_USES_COMMON_VALUE ); | |
1569 | } | |
1c4293cb | 1570 | |
1425eca5 | 1571 | /** |
c82a80e8 | 1572 | Composes text from values of child properties. |
1425eca5 | 1573 | */ |
c82a80e8 JS |
1574 | wxString GenerateComposedValue() const |
1575 | { | |
1576 | wxString s; | |
1577 | DoGenerateComposedValue(s); | |
1578 | return s; | |
1579 | } | |
1c4293cb | 1580 | |
939d9364 JS |
1581 | /** Returns property's label. */ |
1582 | const wxString& GetLabel() const { return m_label; } | |
1c4293cb | 1583 | |
939d9364 JS |
1584 | /** Returns property's name with all (non-category, non-root) parents. */ |
1585 | wxString GetName() const; | |
1c4293cb | 1586 | |
939d9364 JS |
1587 | /** |
1588 | Returns property's base name (ie parent's name is not added in any | |
1589 | case) | |
1590 | */ | |
1591 | const wxString& GetBaseName() const { return m_name; } | |
1592 | ||
1593 | /** Returns read-only reference to property's list of choices. | |
1c4293cb | 1594 | */ |
939d9364 JS |
1595 | const wxPGChoices& GetChoices() const |
1596 | { | |
1597 | return m_choices; | |
1598 | } | |
1c4293cb | 1599 | |
939d9364 JS |
1600 | /** Returns coordinate to the top y of the property. Note that the |
1601 | position of scrollbars is not taken into account. | |
1c4293cb | 1602 | */ |
939d9364 | 1603 | int GetY() const; |
1c4293cb | 1604 | |
939d9364 | 1605 | wxVariant GetValue() const |
1c4293cb | 1606 | { |
939d9364 | 1607 | return DoGetValue(); |
1c4293cb VZ |
1608 | } |
1609 | ||
939d9364 JS |
1610 | /** Returns reference to the internal stored value. GetValue is preferred |
1611 | way to get the actual value, since GetValueRef ignores DoGetValue, | |
1612 | which may override stored value. | |
1613 | */ | |
1614 | wxVariant& GetValueRef() | |
1615 | { | |
1616 | return m_value; | |
1617 | } | |
1c4293cb | 1618 | |
939d9364 | 1619 | const wxVariant& GetValueRef() const |
1c4293cb | 1620 | { |
939d9364 | 1621 | return m_value; |
1c4293cb | 1622 | } |
ac1013c0 JS |
1623 | |
1624 | // Helper function (for wxPython bindings and such) for settings protected | |
1625 | // m_value. | |
1626 | wxVariant GetValuePlain() const | |
1627 | { | |
1628 | return m_value; | |
1629 | } | |
1c4293cb | 1630 | |
1425eca5 JS |
1631 | /** Returns text representation of property's value. |
1632 | ||
1633 | @param argFlags | |
1634 | If 0 (default value), then displayed string is returned. | |
1635 | If wxPG_FULL_VALUE is set, returns complete, storable string value | |
1636 | instead of displayable. If wxPG_EDITABLE_VALUE is set, returns | |
1637 | string value that must be editable in textctrl. If | |
1638 | wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to | |
1639 | display as a part of string property's composite text | |
1640 | representation. | |
1641 | ||
1642 | @remarks In older versions, this function used to be overridden to convert | |
1643 | property's value into a string representation. This function is | |
1644 | now handled by ValueToString(), and overriding this function now | |
1645 | will result in run-time assertion failure. | |
1646 | */ | |
1647 | virtual wxString GetValueAsString( int argFlags = 0 ) const; | |
1648 | ||
1649 | /** Synonymous to GetValueAsString(). | |
1650 | ||
1651 | @deprecated Use GetValueAsString() instead. | |
1652 | ||
1653 | @see GetValueAsString() | |
939d9364 | 1654 | */ |
1425eca5 | 1655 | wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const ); |
1c4293cb | 1656 | |
d7e2b522 JS |
1657 | /** |
1658 | Returns wxPGCell of given column. | |
58935d4a JS |
1659 | |
1660 | @remarks const version of this member function returns 'default' | |
1661 | wxPGCell object if the property itself didn't hold | |
1662 | cell data. | |
939d9364 | 1663 | */ |
d7e2b522 | 1664 | const wxPGCell& GetCell( unsigned int column ) const; |
1c4293cb | 1665 | |
58935d4a JS |
1666 | /** |
1667 | Returns wxPGCell of given column, creating one if necessary. | |
1668 | */ | |
1669 | wxPGCell& GetCell( unsigned int column ) | |
1670 | { | |
1671 | return GetOrCreateCell(column); | |
1672 | } | |
1673 | ||
1674 | /** | |
1675 | Returns wxPGCell of given column, creating one if necessary. | |
1676 | */ | |
1677 | wxPGCell& GetOrCreateCell( unsigned int column ); | |
1c4293cb | 1678 | |
939d9364 JS |
1679 | /** Return number of displayed common values for this property. |
1680 | */ | |
1681 | int GetDisplayedCommonValueCount() const; | |
1682 | ||
1683 | wxString GetDisplayedString() const | |
1c4293cb | 1684 | { |
1425eca5 | 1685 | return GetValueAsString(0); |
1c4293cb | 1686 | } |
1c4293cb | 1687 | |
534090e3 JS |
1688 | /** |
1689 | Returns property's hint text (shown in empty value cell). | |
1690 | */ | |
1691 | inline wxString GetHintText() const; | |
1692 | ||
939d9364 JS |
1693 | /** Returns property grid where property lies. */ |
1694 | wxPropertyGrid* GetGrid() const; | |
1695 | ||
1696 | /** Returns owner wxPropertyGrid, but only if one is currently on a page | |
1697 | displaying this property. */ | |
1698 | wxPropertyGrid* GetGridIfDisplayed() const; | |
1699 | ||
1700 | /** Returns highest level non-category, non-root parent. Useful when you | |
1701 | have nested wxCustomProperties/wxParentProperties. | |
1c4293cb | 1702 | @remarks |
939d9364 JS |
1703 | Thus, if immediate parent is root or category, this will return the |
1704 | property itself. | |
1c4293cb | 1705 | */ |
939d9364 | 1706 | wxPGProperty* GetMainParent() const; |
1c4293cb | 1707 | |
939d9364 JS |
1708 | /** Return parent of property */ |
1709 | wxPGProperty* GetParent() const { return m_parent; } | |
1710 | ||
1711 | /** Returns true if property has editable wxTextCtrl when selected. | |
1712 | ||
1713 | @remarks | |
4c51a665 | 1714 | Although disabled properties do not displayed editor, they still |
939d9364 JS |
1715 | return True here as being disabled is considered a temporary |
1716 | condition (unlike being read-only or having limited editing enabled). | |
1c4293cb | 1717 | */ |
939d9364 JS |
1718 | bool IsTextEditable() const; |
1719 | ||
1720 | bool IsValueUnspecified() const | |
1c4293cb | 1721 | { |
939d9364 | 1722 | return m_value.IsNull(); |
1c4293cb VZ |
1723 | } |
1724 | ||
6cf5edea JS |
1725 | /** |
1726 | Returns non-zero if property has given flag set. | |
1727 | ||
1728 | @see propgrid_propflags | |
1729 | */ | |
1730 | FlagType HasFlag( wxPGPropertyFlags flag ) const | |
1c4293cb | 1731 | { |
939d9364 | 1732 | return ( m_flags & flag ); |
1c4293cb VZ |
1733 | } |
1734 | ||
939d9364 | 1735 | /** Returns comma-delimited string of property attributes. |
1c4293cb | 1736 | */ |
939d9364 | 1737 | const wxPGAttributeStorage& GetAttributes() const |
1c4293cb | 1738 | { |
939d9364 | 1739 | return m_attributes; |
1c4293cb VZ |
1740 | } |
1741 | ||
939d9364 | 1742 | /** Returns m_attributes as list wxVariant. |
1c4293cb | 1743 | */ |
939d9364 | 1744 | wxVariant GetAttributesAsList() const; |
1c4293cb | 1745 | |
6cf5edea JS |
1746 | /** |
1747 | Returns property flags. | |
1748 | */ | |
939d9364 JS |
1749 | FlagType GetFlags() const |
1750 | { | |
1751 | return m_flags; | |
1752 | } | |
1c4293cb | 1753 | |
939d9364 | 1754 | const wxPGEditor* GetEditorClass() const; |
1c4293cb | 1755 | |
939d9364 JS |
1756 | wxString GetValueType() const |
1757 | { | |
1758 | return m_value.GetType(); | |
1759 | } | |
1c4293cb | 1760 | |
939d9364 | 1761 | /** Returns editor used for given column. NULL for no editor. |
1c4293cb | 1762 | */ |
939d9364 | 1763 | const wxPGEditor* GetColumnEditor( int column ) const |
1c4293cb | 1764 | { |
939d9364 JS |
1765 | if ( column == 1 ) |
1766 | return GetEditorClass(); | |
1767 | ||
1768 | return NULL; | |
1c4293cb VZ |
1769 | } |
1770 | ||
939d9364 JS |
1771 | /** Returns common value selected for this property. -1 for none. |
1772 | */ | |
1773 | int GetCommonValue() const | |
1c4293cb | 1774 | { |
939d9364 | 1775 | return m_commonValue; |
1c4293cb VZ |
1776 | } |
1777 | ||
939d9364 JS |
1778 | /** Returns true if property has even one visible child. |
1779 | */ | |
1780 | bool HasVisibleChildren() const; | |
1c4293cb | 1781 | |
48a32cf6 JS |
1782 | /** |
1783 | Use this member function to add independent (ie. regular) children to | |
1784 | a property. | |
1785 | ||
1786 | @return Inserted childProperty. | |
1787 | ||
1788 | @remarks wxPropertyGrid is not automatically refreshed by this | |
1789 | function. | |
1790 | ||
1791 | @see AddPrivateChild() | |
1792 | */ | |
1793 | wxPGProperty* InsertChild( int index, wxPGProperty* childProperty ); | |
1794 | ||
939d9364 JS |
1795 | /** Inserts a new choice to property's list of choices. |
1796 | */ | |
1797 | int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE ); | |
1c4293cb VZ |
1798 | |
1799 | /** | |
939d9364 | 1800 | Returns true if this property is actually a wxPropertyCategory. |
1c4293cb | 1801 | */ |
939d9364 | 1802 | bool IsCategory() const { return HasFlag(wxPG_PROP_CATEGORY)?true:false; } |
1c4293cb | 1803 | |
939d9364 | 1804 | /** Returns true if this property is actually a wxRootProperty. |
1c4293cb | 1805 | */ |
939d9364 | 1806 | bool IsRoot() const { return (m_parent == NULL); } |
1c4293cb | 1807 | |
939d9364 JS |
1808 | /** Returns true if this is a sub-property. */ |
1809 | bool IsSubProperty() const | |
1810 | { | |
1811 | wxPGProperty* parent = (wxPGProperty*)m_parent; | |
1812 | if ( parent && !parent->IsCategory() ) | |
1813 | return true; | |
1814 | return false; | |
1815 | } | |
1c4293cb | 1816 | |
939d9364 | 1817 | /** Returns last visible sub-property, recursively. |
1c4293cb | 1818 | */ |
939d9364 | 1819 | const wxPGProperty* GetLastVisibleSubItem() const; |
1c4293cb | 1820 | |
939d9364 | 1821 | wxVariant GetDefaultValue() const; |
1c4293cb | 1822 | |
939d9364 JS |
1823 | int GetMaxLength() const |
1824 | { | |
1825 | return (int) m_maxLen; | |
1826 | } | |
1c4293cb | 1827 | |
939d9364 JS |
1828 | /** |
1829 | Determines, recursively, if all children are not unspecified. | |
1c4293cb | 1830 | |
bb6720bb JS |
1831 | @param pendingList |
1832 | Assumes members in this wxVariant list as pending | |
1833 | replacement values. | |
939d9364 JS |
1834 | */ |
1835 | bool AreAllChildrenSpecified( wxVariant* pendingList = NULL ) const; | |
1c4293cb | 1836 | |
939d9364 JS |
1837 | /** Updates composed values of parent non-category properties, recursively. |
1838 | Returns topmost property updated. | |
1c4293cb | 1839 | |
939d9364 JS |
1840 | @remarks |
1841 | - Must not call SetValue() (as can be called in it). | |
1c4293cb | 1842 | */ |
939d9364 | 1843 | wxPGProperty* UpdateParentValues(); |
1c4293cb | 1844 | |
939d9364 JS |
1845 | /** Returns true if containing grid uses wxPG_EX_AUTO_UNSPECIFIED_VALUES. |
1846 | */ | |
bb6720bb | 1847 | bool UsesAutoUnspecified() const |
939d9364 | 1848 | { |
bb6720bb | 1849 | return HasFlag(wxPG_PROP_AUTO_UNSPECIFIED)?true:false; |
1c4293cb | 1850 | } |
939d9364 JS |
1851 | |
1852 | wxBitmap* GetValueImage() const | |
1853 | { | |
1854 | return m_valueBitmap; | |
1c4293cb | 1855 | } |
1c4293cb | 1856 | |
939d9364 | 1857 | wxVariant GetAttribute( const wxString& name ) const; |
1c4293cb | 1858 | |
939d9364 JS |
1859 | /** |
1860 | Returns named attribute, as string, if found. | |
1c4293cb | 1861 | |
939d9364 | 1862 | Otherwise defVal is returned. |
1c4293cb | 1863 | */ |
939d9364 | 1864 | wxString GetAttribute( const wxString& name, const wxString& defVal ) const; |
1c4293cb | 1865 | |
939d9364 JS |
1866 | /** |
1867 | Returns named attribute, as long, if found. | |
1c4293cb | 1868 | |
939d9364 JS |
1869 | Otherwise defVal is returned. |
1870 | */ | |
1871 | long GetAttributeAsLong( const wxString& name, long defVal ) const; | |
1c4293cb | 1872 | |
939d9364 JS |
1873 | /** |
1874 | Returns named attribute, as double, if found. | |
1c4293cb | 1875 | |
939d9364 | 1876 | Otherwise defVal is returned. |
1c4293cb | 1877 | */ |
939d9364 | 1878 | double GetAttributeAsDouble( const wxString& name, double defVal ) const; |
1c4293cb | 1879 | |
939d9364 | 1880 | unsigned int GetDepth() const { return (unsigned int)m_depth; } |
1c4293cb | 1881 | |
939d9364 JS |
1882 | /** Gets flags as a'|' delimited string. Note that flag names are not |
1883 | prepended with 'wxPG_PROP_'. | |
1884 | @param flagsMask | |
1885 | String will only be made to include flags combined by this parameter. | |
1886 | */ | |
1887 | wxString GetFlagsAsString( FlagType flagsMask ) const; | |
1c4293cb | 1888 | |
939d9364 JS |
1889 | /** Returns position in parent's array. */ |
1890 | unsigned int GetIndexInParent() const | |
1c4293cb | 1891 | { |
939d9364 | 1892 | return (unsigned int)m_arrIndex; |
1c4293cb VZ |
1893 | } |
1894 | ||
939d9364 JS |
1895 | /** Hides or reveals the property. |
1896 | @param hide | |
1897 | true for hide, false for reveal. | |
1898 | @param flags | |
1899 | By default changes are applied recursively. Set this paramter | |
1900 | wxPG_DONT_RECURSE to prevent this. | |
1901 | */ | |
3ded4b22 | 1902 | bool Hide( bool hide, int flags = wxPG_RECURSE ); |
1c4293cb | 1903 | |
939d9364 JS |
1904 | bool IsExpanded() const |
1905 | { return (!(m_flags & wxPG_PROP_COLLAPSED) && GetChildCount()); } | |
1c4293cb | 1906 | |
939d9364 JS |
1907 | /** Returns true if all parents expanded. |
1908 | */ | |
1909 | bool IsVisible() const; | |
1c4293cb | 1910 | |
939d9364 | 1911 | bool IsEnabled() const { return !(m_flags & wxPG_PROP_DISABLED); } |
1c4293cb | 1912 | |
939d9364 JS |
1913 | /** If property's editor is created this forces its recreation. |
1914 | Useful in SetAttribute etc. Returns true if actually did anything. | |
1915 | */ | |
1916 | bool RecreateEditor(); | |
1c4293cb | 1917 | |
939d9364 JS |
1918 | /** If property's editor is active, then update it's value. |
1919 | */ | |
1920 | void RefreshEditor(); | |
1c4293cb | 1921 | |
939d9364 JS |
1922 | /** Sets an attribute for this property. |
1923 | @param name | |
1924 | Text identifier of attribute. See @ref propgrid_property_attributes. | |
1925 | @param value | |
1926 | Value of attribute. | |
1927 | */ | |
1928 | void SetAttribute( const wxString& name, wxVariant value ); | |
1c4293cb | 1929 | |
939d9364 | 1930 | void SetAttributes( const wxPGAttributeStorage& attributes ); |
1c4293cb | 1931 | |
6c78066f JS |
1932 | /** |
1933 | Set if user can change the property's value to unspecified by | |
1934 | modifying the value of the editor control (usually by clearing | |
1935 | it). Currently, this can work with following properties: | |
1936 | wxIntProperty, wxUIntProperty, wxFloatProperty, wxEditEnumProperty. | |
ce00f59b | 1937 | |
6c78066f | 1938 | @param enable |
4c51a665 | 1939 | Whether to enable or disable this behaviour (it is disabled by |
6c78066f JS |
1940 | default). |
1941 | */ | |
1942 | void SetAutoUnspecified( bool enable = true ) | |
1943 | { | |
1944 | ChangeFlag(wxPG_PROP_AUTO_UNSPECIFIED, enable); | |
1945 | } | |
1946 | ||
d7e2b522 JS |
1947 | /** |
1948 | Sets property's background colour. | |
1949 | ||
1950 | @param colour | |
1951 | Background colour to use. | |
1952 | ||
e607eac2 JS |
1953 | @param flags |
1954 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
1955 | Omit this flag to only set colour for the property in question | |
1956 | and not any of its children. | |
d7e2b522 JS |
1957 | */ |
1958 | void SetBackgroundColour( const wxColour& colour, | |
e607eac2 | 1959 | int flags = wxPG_RECURSE ); |
d7e2b522 JS |
1960 | |
1961 | /** | |
1962 | Sets property's text colour. | |
1963 | ||
1964 | @param colour | |
1965 | Text colour to use. | |
1966 | ||
e607eac2 JS |
1967 | @param flags |
1968 | Default is wxPG_RECURSE which causes colour to be set recursively. | |
1969 | Omit this flag to only set colour for the property in question | |
1970 | and not any of its children. | |
d7e2b522 JS |
1971 | */ |
1972 | void SetTextColour( const wxColour& colour, | |
e607eac2 | 1973 | int flags = wxPG_RECURSE ); |
d7e2b522 | 1974 | |
0ce8e27f JS |
1975 | /** Set default value of a property. Synonymous to |
1976 | ||
1977 | @code | |
1978 | SetAttribute("DefaultValue", value); | |
1979 | @endcode | |
1980 | */ | |
1981 | void SetDefaultValue( wxVariant& value ); | |
1982 | ||
939d9364 | 1983 | /** Sets editor for a property. |
1c4293cb | 1984 | |
939d9364 JS |
1985 | @param editor |
1986 | For builtin editors, use wxPGEditor_X, where X is builtin editor's | |
1987 | name (TextCtrl, Choice, etc. see wxPGEditor documentation for full | |
1988 | list). | |
1c4293cb | 1989 | |
939d9364 JS |
1990 | For custom editors, use pointer you received from |
1991 | wxPropertyGrid::RegisterEditorClass(). | |
1992 | */ | |
1993 | void SetEditor( const wxPGEditor* editor ) | |
1994 | { | |
1995 | m_customEditor = editor; | |
1996 | } | |
1c4293cb | 1997 | |
939d9364 JS |
1998 | /** Sets editor for a property. |
1999 | */ | |
2000 | inline void SetEditor( const wxString& editorName ); | |
1c4293cb | 2001 | |
d7e2b522 JS |
2002 | /** |
2003 | Sets cell information for given column. | |
939d9364 | 2004 | */ |
d7e2b522 | 2005 | void SetCell( int column, const wxPGCell& cell ); |
1c4293cb | 2006 | |
939d9364 JS |
2007 | /** Sets common value selected for this property. -1 for none. |
2008 | */ | |
2009 | void SetCommonValue( int commonValue ) | |
2010 | { | |
2011 | m_commonValue = commonValue; | |
2012 | } | |
1c4293cb | 2013 | |
939d9364 JS |
2014 | /** Sets flags from a '|' delimited string. Note that flag names are not |
2015 | prepended with 'wxPG_PROP_'. | |
2016 | */ | |
2017 | void SetFlagsFromString( const wxString& str ); | |
1c4293cb | 2018 | |
939d9364 JS |
2019 | /** Sets property's "is it modified?" flag. Affects children recursively. |
2020 | */ | |
2021 | void SetModifiedStatus( bool modified ) | |
2022 | { | |
2023 | SetFlagRecursively(wxPG_PROP_MODIFIED, modified); | |
2024 | } | |
1c4293cb | 2025 | |
939d9364 JS |
2026 | /** Call in OnEvent(), OnButtonClick() etc. to change the property value |
2027 | based on user input. | |
1c4293cb | 2028 | |
939d9364 JS |
2029 | @remarks |
2030 | This method is const since it doesn't actually modify value, but posts | |
2031 | given variant as pending value, stored in wxPropertyGrid. | |
2032 | */ | |
2033 | void SetValueInEvent( wxVariant value ) const; | |
1c4293cb | 2034 | |
939d9364 JS |
2035 | /** |
2036 | Call this to set value of the property. | |
1c4293cb | 2037 | |
939d9364 JS |
2038 | Unlike methods in wxPropertyGrid, this does not automatically update |
2039 | the display. | |
1c4293cb | 2040 | |
939d9364 JS |
2041 | @remarks |
2042 | Use wxPropertyGrid::ChangePropertyValue() instead if you need to run | |
2043 | through validation process and send property change event. | |
1c4293cb | 2044 | |
939d9364 JS |
2045 | If you need to change property value in event, based on user input, use |
2046 | SetValueInEvent() instead. | |
1c4293cb | 2047 | |
939d9364 | 2048 | @param pList |
e777bd14 JS |
2049 | Pointer to list variant that contains child values. Used to |
2050 | indicate which children should be marked as modified. | |
2051 | ||
939d9364 | 2052 | @param flags |
e777bd14 JS |
2053 | Various flags (for instance, wxPG_SETVAL_REFRESH_EDITOR, which is |
2054 | enabled by default). | |
939d9364 | 2055 | */ |
e777bd14 JS |
2056 | void SetValue( wxVariant value, wxVariant* pList = NULL, |
2057 | int flags = wxPG_SETVAL_REFRESH_EDITOR ); | |
1c4293cb | 2058 | |
939d9364 JS |
2059 | /** Set wxBitmap in front of the value. This bitmap may be ignored |
2060 | by custom cell renderers. | |
2061 | */ | |
2062 | void SetValueImage( wxBitmap& bmp ); | |
1c4293cb | 2063 | |
939d9364 | 2064 | /** Sets selected choice and changes property value. |
1c4293cb | 2065 | |
939d9364 JS |
2066 | Tries to retain value type, although currently if it is not string, |
2067 | then it is forced to integer. | |
2068 | */ | |
2069 | void SetChoiceSelection( int newValue ); | |
1c4293cb | 2070 | |
939d9364 JS |
2071 | void SetExpanded( bool expanded ) |
2072 | { | |
2073 | if ( !expanded ) m_flags |= wxPG_PROP_COLLAPSED; | |
2074 | else m_flags &= ~wxPG_PROP_COLLAPSED; | |
2075 | } | |
1c4293cb | 2076 | |
d58526d5 | 2077 | /** |
6c78066f | 2078 | Sets or clears given property flag. Mainly for internal use. |
1c4293cb | 2079 | |
6c78066f JS |
2080 | @remarks Setting a property flag never has any side-effect, and is |
2081 | intended almost exclusively for internal use. So, for | |
2082 | example, if you want to disable a property, call | |
2083 | Enable(false) instead of setting wxPG_PROP_DISABLED flag. | |
6cf5edea | 2084 | |
6c78066f | 2085 | @see HasFlag(), GetFlags() |
d58526d5 | 2086 | */ |
6cf5edea | 2087 | void ChangeFlag( wxPGPropertyFlags flag, bool set ) |
d58526d5 JS |
2088 | { |
2089 | if ( set ) | |
2090 | m_flags |= flag; | |
2091 | else | |
2092 | m_flags &= ~flag; | |
2093 | } | |
2094 | ||
6cf5edea | 2095 | /** |
6c78066f JS |
2096 | Sets or clears given property flag, recursively. This function is |
2097 | primarily intended for internal use. | |
6cf5edea | 2098 | |
6c78066f | 2099 | @see ChangeFlag() |
6cf5edea JS |
2100 | */ |
2101 | void SetFlagRecursively( wxPGPropertyFlags flag, bool set ); | |
1c4293cb | 2102 | |
939d9364 JS |
2103 | void SetHelpString( const wxString& helpString ) |
2104 | { | |
2105 | m_helpString = helpString; | |
2106 | } | |
1c4293cb | 2107 | |
939d9364 | 2108 | void SetLabel( const wxString& label ) { m_label = label; } |
1c4293cb | 2109 | |
5fdb6350 | 2110 | void SetName( const wxString& newName ); |
1c4293cb | 2111 | |
2fd4a524 JS |
2112 | /** |
2113 | Changes what sort of parent this property is for its children. | |
2114 | ||
2115 | @param flag | |
48a32cf6 JS |
2116 | Use one of the following values: wxPG_PROP_MISC_PARENT (for |
2117 | generic parents), wxPG_PROP_CATEGORY (for categories), or | |
2fd4a524 JS |
2118 | wxPG_PROP_AGGREGATE (for derived property classes with private |
2119 | children). | |
2120 | ||
48a32cf6 | 2121 | @remarks You generally do not need to call this function. |
2fd4a524 JS |
2122 | */ |
2123 | void SetParentalType( int flag ) | |
2124 | { | |
2125 | m_flags &= ~(wxPG_PROP_PROPERTY|wxPG_PROP_PARENTAL_FLAGS); | |
2126 | m_flags |= flag; | |
2127 | } | |
2128 | ||
939d9364 JS |
2129 | void SetValueToUnspecified() |
2130 | { | |
2131 | wxVariant val; // Create NULL variant | |
269619bf | 2132 | SetValue(val, NULL, wxPG_SETVAL_REFRESH_EDITOR); |
939d9364 | 2133 | } |
1c4293cb | 2134 | |
ac1013c0 JS |
2135 | // Helper function (for wxPython bindings and such) for settings protected |
2136 | // m_value. | |
2137 | void SetValuePlain( wxVariant value ) | |
2138 | { | |
2139 | m_value = value; | |
2140 | } | |
2141 | ||
939d9364 JS |
2142 | #if wxUSE_VALIDATORS |
2143 | /** Sets wxValidator for a property*/ | |
2144 | void SetValidator( const wxValidator& validator ) | |
2145 | { | |
2146 | m_validator = wxDynamicCast(validator.Clone(),wxValidator); | |
2147 | } | |
1c4293cb | 2148 | |
939d9364 JS |
2149 | /** Gets assignable version of property's validator. */ |
2150 | wxValidator* GetValidator() const | |
2151 | { | |
2152 | if ( m_validator ) | |
2153 | return m_validator; | |
2154 | return DoGetValidator(); | |
2155 | } | |
a243da29 | 2156 | #endif // wxUSE_VALIDATORS |
1c4293cb | 2157 | |
939d9364 JS |
2158 | /** Returns client data (void*) of a property. |
2159 | */ | |
2160 | void* GetClientData() const | |
1c4293cb | 2161 | { |
939d9364 | 2162 | return m_clientData; |
1c4293cb VZ |
2163 | } |
2164 | ||
939d9364 JS |
2165 | /** Sets client data (void*) of a property. |
2166 | @remarks | |
2167 | This untyped client data has to be deleted manually. | |
2168 | */ | |
2169 | void SetClientData( void* clientData ) | |
1c4293cb | 2170 | { |
939d9364 | 2171 | m_clientData = clientData; |
1c4293cb VZ |
2172 | } |
2173 | ||
939d9364 JS |
2174 | /** Returns client object of a property. |
2175 | */ | |
2176 | void SetClientObject(wxClientData* clientObject) | |
1c4293cb | 2177 | { |
939d9364 JS |
2178 | delete m_clientObject; |
2179 | m_clientObject = clientObject; | |
1c4293cb VZ |
2180 | } |
2181 | ||
939d9364 JS |
2182 | /** Sets managed client object of a property. |
2183 | */ | |
2184 | wxClientData *GetClientObject() const { return m_clientObject; } | |
1c4293cb | 2185 | |
26b22ae3 JS |
2186 | /** |
2187 | Sets new set of choices for the property. | |
1c4293cb | 2188 | |
26b22ae3 JS |
2189 | @remarks This operation deselects the property and clears its |
2190 | value. | |
939d9364 | 2191 | */ |
75ac0891 | 2192 | bool SetChoices( const wxPGChoices& choices ); |
1c4293cb | 2193 | |
939d9364 JS |
2194 | /** Set max length of text in text editor. |
2195 | */ | |
2196 | inline bool SetMaxLength( int maxLen ); | |
1c4293cb | 2197 | |
939d9364 JS |
2198 | /** Call with 'false' in OnSetValue to cancel value changes after all |
2199 | (ie. cancel 'true' returned by StringToValue() or IntToValue()). | |
2200 | */ | |
2201 | void SetWasModified( bool set = true ) | |
1c4293cb | 2202 | { |
939d9364 JS |
2203 | if ( set ) m_flags |= wxPG_PROP_WAS_MODIFIED; |
2204 | else m_flags &= ~wxPG_PROP_WAS_MODIFIED; | |
2205 | } | |
1c4293cb | 2206 | |
939d9364 JS |
2207 | const wxString& GetHelpString() const |
2208 | { | |
2209 | return m_helpString; | |
1c4293cb VZ |
2210 | } |
2211 | ||
939d9364 JS |
2212 | // Use, for example, to detect if item is inside collapsed section. |
2213 | bool IsSomeParent( wxPGProperty* candidate_parent ) const; | |
1c4293cb | 2214 | |
939d9364 JS |
2215 | /** |
2216 | Adapts list variant into proper value using consecutive | |
2217 | ChildChanged-calls. | |
2218 | */ | |
2219 | void AdaptListToValue( wxVariant& list, wxVariant* value ) const; | |
99774d58 | 2220 | |
48a32cf6 JS |
2221 | #if wxPG_COMPATIBILITY_1_4 |
2222 | /** | |
2223 | Adds a private child property. | |
2224 | ||
2225 | @deprecated Use AddPrivateChild() instead. | |
2226 | ||
2227 | @see AddPrivateChild() | |
2228 | */ | |
2229 | wxDEPRECATED( void AddChild( wxPGProperty* prop ) ); | |
2230 | #endif | |
2231 | ||
2fd4a524 | 2232 | /** |
48a32cf6 | 2233 | Adds a private child property. If you use this instead of |
2fd4a524 | 2234 | wxPropertyGridInterface::Insert() or |
48a32cf6 JS |
2235 | wxPropertyGridInterface::AppendIn(), then property's parental |
2236 | type will automatically be set up to wxPG_PROP_AGGREGATE. In other | |
2237 | words, all properties of this property will become private. | |
2238 | */ | |
2239 | void AddPrivateChild( wxPGProperty* prop ); | |
2fd4a524 | 2240 | |
48a32cf6 JS |
2241 | /** |
2242 | Appends a new child property. | |
2fd4a524 | 2243 | */ |
48a32cf6 JS |
2244 | wxPGProperty* AppendChild( wxPGProperty* prop ) |
2245 | { | |
2246 | return InsertChild(-1, prop); | |
2247 | } | |
1c4293cb | 2248 | |
939d9364 JS |
2249 | /** Returns height of children, recursively, and |
2250 | by taking expanded/collapsed status into account. | |
1c4293cb | 2251 | |
939d9364 JS |
2252 | iMax is used when finding property y-positions. |
2253 | */ | |
2254 | int GetChildrenHeight( int lh, int iMax = -1 ) const; | |
1c4293cb | 2255 | |
939d9364 | 2256 | /** Returns number of child properties */ |
68bcfd2c JS |
2257 | unsigned int GetChildCount() const |
2258 | { | |
2259 | return (unsigned int) m_children.size(); | |
2260 | } | |
1c4293cb | 2261 | |
939d9364 | 2262 | /** Returns sub-property at index i. */ |
68bcfd2c | 2263 | wxPGProperty* Item( unsigned int i ) const |
f7a094e1 | 2264 | { return m_children[i]; } |
1c4293cb | 2265 | |
939d9364 JS |
2266 | /** Returns last sub-property. |
2267 | */ | |
f7a094e1 | 2268 | wxPGProperty* Last() const { return m_children.back(); } |
1c4293cb | 2269 | |
f7a094e1 JS |
2270 | /** Returns index of given child property. */ |
2271 | int Index( const wxPGProperty* p ) const; | |
1c4293cb | 2272 | |
939d9364 | 2273 | // Puts correct indexes to children |
1b895132 | 2274 | void FixIndicesOfChildren( unsigned int starthere = 0 ); |
1c4293cb | 2275 | |
4aee8334 JS |
2276 | /** |
2277 | Converts image width into full image offset, with margins. | |
2278 | */ | |
2279 | int GetImageOffset( int imageWidth ) const; | |
2280 | ||
939d9364 JS |
2281 | // Returns wxPropertyGridPageState in which this property resides. |
2282 | wxPropertyGridPageState* GetParentState() const { return m_parentState; } | |
1c4293cb | 2283 | |
939d9364 JS |
2284 | wxPGProperty* GetItemAtY( unsigned int y, |
2285 | unsigned int lh, | |
2286 | unsigned int* nextItemY ) const; | |
14bac4b5 JS |
2287 | |
2288 | /** Returns property at given virtual y coordinate. | |
2289 | */ | |
2290 | wxPGProperty* GetItemAtY( unsigned int y ) const; | |
1c4293cb | 2291 | |
939d9364 JS |
2292 | /** Returns (direct) child property with given name (or NULL if not found). |
2293 | */ | |
2294 | wxPGProperty* GetPropertyByName( const wxString& name ) const; | |
1c4293cb | 2295 | |
d7e2b522 JS |
2296 | // Returns various display-related information for given column |
2297 | void GetDisplayInfo( unsigned int column, | |
2298 | int choiceIndex, | |
2299 | int flags, | |
2300 | wxString* pString, | |
2301 | const wxPGCell** pCell ); | |
2302 | ||
939d9364 | 2303 | static wxString* sm_wxPG_LABEL; |
1c4293cb | 2304 | |
939d9364 JS |
2305 | /** This member is public so scripting language bindings |
2306 | wrapper code can access it freely. | |
2307 | */ | |
2308 | void* m_clientData; | |
1c4293cb | 2309 | |
939d9364 | 2310 | protected: |
d7e2b522 JS |
2311 | |
2312 | /** | |
2313 | Sets property cell in fashion that reduces number of exclusive | |
2314 | copies of cell data. Used when setting, for instance, same | |
2315 | background colour for a number of properties. | |
2316 | ||
2317 | @param firstCol | |
2318 | First column to affect. | |
2319 | ||
2320 | @param lastCol | |
2321 | Last column to affect. | |
2322 | ||
2323 | @param preparedCell | |
2324 | Pre-prepared cell that is used for those which cell data | |
2325 | before this matched unmodCellData. | |
2326 | ||
2327 | @param srcData | |
2328 | If unmodCellData did not match, valid cell data from this | |
2329 | is merged into cell (usually generating new exclusive copy | |
2330 | of cell's data). | |
2331 | ||
2332 | @param unmodCellData | |
2333 | If cell's cell data matches this, its cell is now set to | |
2334 | preparedCell. | |
2335 | ||
2336 | @param ignoreWithFlags | |
2337 | Properties with any one of these flags are skipped. | |
2338 | ||
2339 | @param recursively | |
2340 | If @true, apply this operation recursively in child properties. | |
1c4293cb | 2341 | */ |
d7e2b522 JS |
2342 | void AdaptiveSetCell( unsigned int firstCol, |
2343 | unsigned int lastCol, | |
2344 | const wxPGCell& preparedCell, | |
2345 | const wxPGCell& srcData, | |
2346 | wxPGCellData* unmodCellData, | |
2347 | FlagType ignoreWithFlags, | |
2348 | bool recursively ); | |
2349 | ||
2350 | /** | |
2351 | Makes sure m_cells has size of column+1 (or more). | |
2352 | */ | |
2353 | void EnsureCells( unsigned int column ); | |
1c4293cb | 2354 | |
939d9364 JS |
2355 | /** Returns (direct) child property with given name (or NULL if not found), |
2356 | with hint index. | |
1c4293cb | 2357 | |
939d9364 JS |
2358 | @param hintIndex |
2359 | Start looking for the child at this index. | |
1c4293cb | 2360 | |
939d9364 JS |
2361 | @remarks |
2362 | Does not support scope (ie. Parent.Child notation). | |
2363 | */ | |
2364 | wxPGProperty* GetPropertyByNameWH( const wxString& name, | |
2365 | unsigned int hintIndex ) const; | |
1c4293cb | 2366 | |
939d9364 | 2367 | /** This is used by Insert etc. */ |
48a32cf6 JS |
2368 | void DoAddChild( wxPGProperty* prop, |
2369 | int index = -1, | |
2370 | bool correct_mode = true ); | |
1c4293cb | 2371 | |
c82a80e8 JS |
2372 | void DoGenerateComposedValue( wxString& text, |
2373 | int argFlags = wxPG_VALUE_IS_CURRENT, | |
2374 | const wxVariantList* valueOverrides = NULL, | |
2375 | wxPGHashMapS2S* childResults = NULL ) const; | |
2376 | ||
3ded4b22 JS |
2377 | bool DoHide( bool hide, int flags ); |
2378 | ||
939d9364 JS |
2379 | void DoSetName(const wxString& str) { m_name = str; } |
2380 | ||
91c818f8 JS |
2381 | /** Deletes all sub-properties. */ |
2382 | void Empty(); | |
2383 | ||
58935d4a JS |
2384 | bool HasCell( unsigned int column ) const |
2385 | { | |
2386 | if ( m_cells.size() > column ) | |
2387 | return true; | |
2388 | return false; | |
2389 | } | |
2390 | ||
2fd4a524 JS |
2391 | void InitAfterAdded( wxPropertyGridPageState* pageState, |
2392 | wxPropertyGrid* propgrid ); | |
939d9364 | 2393 | |
a6ca624a JS |
2394 | /** |
2395 | Returns true if child property is selected. | |
2396 | */ | |
1d8340b9 | 2397 | bool IsChildSelected( bool recursive = false ) const; |
a6ca624a | 2398 | |
d8c74d04 JS |
2399 | // Removes child property with given pointer. Does not delete it. |
2400 | void RemoveChild( wxPGProperty* p ); | |
2401 | ||
9ceed261 JS |
2402 | void DoEnable( bool enable ); |
2403 | ||
48a32cf6 JS |
2404 | void DoPreAddChild( int index, wxPGProperty* prop ); |
2405 | ||
939d9364 JS |
2406 | void SetParentState( wxPropertyGridPageState* pstate ) |
2407 | { m_parentState = pstate; } | |
2408 | ||
6c78066f JS |
2409 | void SetFlag( wxPGPropertyFlags flag ) |
2410 | { | |
2411 | // | |
2412 | // NB: While using wxPGPropertyFlags here makes it difficult to | |
2413 | // combine different flags, it usefully prevents user from | |
2414 | // using incorrect flags (say, wxWindow styles). | |
2415 | m_flags |= flag; | |
2416 | } | |
2417 | ||
2418 | void ClearFlag( FlagType flag ) { m_flags &= ~(flag); } | |
2419 | ||
ed8b46bb JS |
2420 | // Called when the property is being removed from the grid and/or |
2421 | // page state (but *not* when it is also deleted). | |
2422 | void OnDetached(wxPropertyGridPageState* state, | |
2423 | wxPropertyGrid* propgrid); | |
2424 | ||
939d9364 JS |
2425 | // Call after fixed sub-properties added/removed after creation. |
2426 | // if oldSelInd >= 0 and < new max items, then selection is | |
2427 | // moved to it. | |
2428 | void SubPropsChanged( int oldSelInd = -1 ); | |
1c4293cb | 2429 | |
939d9364 | 2430 | int GetY2( int lh ) const; |
1c4293cb | 2431 | |
939d9364 JS |
2432 | wxString m_label; |
2433 | wxString m_name; | |
2434 | wxPGProperty* m_parent; | |
d7e2b522 | 2435 | wxPropertyGridPageState* m_parentState; |
1c4293cb | 2436 | |
939d9364 | 2437 | wxClientData* m_clientObject; |
1c4293cb | 2438 | |
939d9364 JS |
2439 | // Overrides editor returned by property class |
2440 | const wxPGEditor* m_customEditor; | |
2441 | #if wxUSE_VALIDATORS | |
2442 | // Editor is going to get this validator | |
2443 | wxValidator* m_validator; | |
2444 | #endif | |
2445 | // Show this in front of the value | |
2446 | // | |
2447 | // TODO: Can bitmap be implemented with wxPGCell? | |
2448 | wxBitmap* m_valueBitmap; | |
1c4293cb | 2449 | |
939d9364 JS |
2450 | wxVariant m_value; |
2451 | wxPGAttributeStorage m_attributes; | |
f7a094e1 | 2452 | wxArrayPGProperty m_children; |
1c4293cb | 2453 | |
939d9364 | 2454 | // Extended cell information |
d7e2b522 | 2455 | wxVector<wxPGCell> m_cells; |
1c4293cb | 2456 | |
939d9364 JS |
2457 | // Choices shown in drop-down list of editor control. |
2458 | wxPGChoices m_choices; | |
1c4293cb | 2459 | |
939d9364 JS |
2460 | // Help shown in statusbar or help box. |
2461 | wxString m_helpString; | |
1c4293cb | 2462 | |
939d9364 JS |
2463 | // Index in parent's property array. |
2464 | unsigned int m_arrIndex; | |
1c4293cb | 2465 | |
939d9364 JS |
2466 | // If not -1, then overrides m_value |
2467 | int m_commonValue; | |
1c4293cb | 2468 | |
939d9364 | 2469 | FlagType m_flags; |
1c4293cb | 2470 | |
939d9364 JS |
2471 | // Maximum length (mainly for string properties). Could be in some sort of |
2472 | // wxBaseStringProperty, but currently, for maximum flexibility and | |
2473 | // compatibility, we'll stick it here. Anyway, we had 3 excess bytes to use | |
2474 | // so short int will fit in just fine. | |
2475 | short m_maxLen; | |
1c4293cb | 2476 | |
939d9364 JS |
2477 | // Root has 0, categories etc. at that level 1, etc. |
2478 | unsigned char m_depth; | |
1c4293cb | 2479 | |
939d9364 JS |
2480 | // m_depthBgCol indicates width of background colour between margin and item |
2481 | // (essentially this is category's depth, if none then equals m_depth). | |
2482 | unsigned char m_depthBgCol; | |
1c4293cb | 2483 | |
939d9364 JS |
2484 | private: |
2485 | // Called in constructors. | |
2486 | void Init(); | |
2487 | void Init( const wxString& label, const wxString& name ); | |
939d9364 | 2488 | }; |
1c4293cb | 2489 | |
939d9364 | 2490 | // ----------------------------------------------------------------------- |
1c4293cb | 2491 | |
939d9364 JS |
2492 | // |
2493 | // Property class declaration helper macros | |
2494 | // (wxPGRootPropertyClass and wxPropertyCategory require this). | |
2495 | // | |
1c4293cb | 2496 | |
939d9364 JS |
2497 | #define WX_PG_DECLARE_DOGETEDITORCLASS \ |
2498 | virtual const wxPGEditor* DoGetEditorClass() const; | |
1c4293cb | 2499 | |
ec3cce5a | 2500 | #ifndef WX_PG_DECLARE_PROPERTY_CLASS |
939d9364 JS |
2501 | #define WX_PG_DECLARE_PROPERTY_CLASS(CLASSNAME) \ |
2502 | public: \ | |
2503 | DECLARE_DYNAMIC_CLASS(CLASSNAME) \ | |
2504 | WX_PG_DECLARE_DOGETEDITORCLASS \ | |
2505 | private: | |
939d9364 | 2506 | #endif |
1c4293cb | 2507 | |
939d9364 JS |
2508 | // Implements sans constructor function. Also, first arg is class name, not |
2509 | // property name. | |
2510 | #define WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(PROPNAME,T,EDITOR) \ | |
2511 | const wxPGEditor* PROPNAME::DoGetEditorClass() const \ | |
2512 | { \ | |
2513 | return wxPGEditor_##EDITOR; \ | |
2514 | } | |
1c4293cb | 2515 | |
939d9364 | 2516 | // ----------------------------------------------------------------------- |
1c4293cb | 2517 | |
939d9364 JS |
2518 | /** @class wxPGRootProperty |
2519 | @ingroup classes | |
2520 | Root parent property. | |
2521 | */ | |
2522 | class WXDLLIMPEXP_PROPGRID wxPGRootProperty : public wxPGProperty | |
2523 | { | |
2524 | public: | |
2525 | WX_PG_DECLARE_PROPERTY_CLASS(wxPGRootProperty) | |
2526 | public: | |
1c4293cb | 2527 | |
939d9364 | 2528 | /** Constructor. */ |
94b8ecf1 | 2529 | wxPGRootProperty( const wxString& name = wxS("<Root>") ); |
939d9364 | 2530 | virtual ~wxPGRootProperty(); |
1c4293cb | 2531 | |
939d9364 | 2532 | virtual bool StringToValue( wxVariant&, const wxString&, int ) const |
1c4293cb | 2533 | { |
939d9364 | 2534 | return false; |
1c4293cb VZ |
2535 | } |
2536 | ||
939d9364 JS |
2537 | protected: |
2538 | }; | |
1c4293cb | 2539 | |
939d9364 | 2540 | // ----------------------------------------------------------------------- |
1c4293cb | 2541 | |
939d9364 JS |
2542 | /** @class wxPropertyCategory |
2543 | @ingroup classes | |
2544 | Category (caption) property. | |
2545 | */ | |
2546 | class WXDLLIMPEXP_PROPGRID wxPropertyCategory : public wxPGProperty | |
2547 | { | |
2548 | friend class wxPropertyGrid; | |
2549 | friend class wxPropertyGridPageState; | |
2550 | WX_PG_DECLARE_PROPERTY_CLASS(wxPropertyCategory) | |
2551 | public: | |
1c4293cb | 2552 | |
939d9364 JS |
2553 | /** Default constructor is only used in special cases. */ |
2554 | wxPropertyCategory(); | |
2555 | ||
2556 | wxPropertyCategory( const wxString& label, | |
2557 | const wxString& name = wxPG_LABEL ); | |
2558 | ~wxPropertyCategory(); | |
2559 | ||
2560 | int GetTextExtent( const wxWindow* wnd, const wxFont& font ) const; | |
1c4293cb | 2561 | |
1425eca5 | 2562 | virtual wxString ValueToString( wxVariant& value, int argFlags ) const; |
e16bff8e | 2563 | virtual wxString GetValueAsString( int argFlags = 0 ) const; |
1c4293cb | 2564 | |
a09307ab | 2565 | protected: |
939d9364 JS |
2566 | void SetTextColIndex( unsigned int colInd ) |
2567 | { m_capFgColIndex = (wxByte) colInd; } | |
2568 | unsigned int GetTextColIndex() const | |
2569 | { return (unsigned int) m_capFgColIndex; } | |
2570 | ||
2571 | void CalculateTextExtent( wxWindow* wnd, const wxFont& font ); | |
2572 | ||
2573 | int m_textExtent; // pre-calculated length of text | |
2574 | wxByte m_capFgColIndex; // caption text colour index | |
2575 | ||
2576 | private: | |
1c4293cb | 2577 | void Init(); |
1c4293cb VZ |
2578 | }; |
2579 | ||
1c4293cb VZ |
2580 | // ----------------------------------------------------------------------- |
2581 | ||
f4bc1aa2 JS |
2582 | #endif // wxUSE_PROPGRID |
2583 | ||
1c4293cb | 2584 | #endif // _WX_PROPGRID_PROPERTY_H_ |