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