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