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