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