]>
Commit | Line | Data |
---|---|---|
1c4293cb VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: property.h | |
3 | // Purpose: interface of wxPGProperty | |
4 | // Author: wxWidgets team | |
de003797 | 5 | // RCS-ID: $Id$ |
1c4293cb VZ |
6 | // Licence: wxWindows license |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | ||
10 | #define wxNullProperty ((wxPGProperty*)NULL) | |
11 | ||
12 | ||
0ad10f30 FM |
13 | /** |
14 | @section propgrid_property_attributes wxPropertyGrid Property Attribute Identifiers | |
1c4293cb | 15 | |
0ad10f30 FM |
16 | wxPGProperty::SetAttribute() and wxPropertyGridInterface::SetPropertyAttribute() |
17 | accept one of these as attribute name argument. | |
1c4293cb | 18 | |
0ad10f30 FM |
19 | You can use strings instead of constants. |
20 | However, some of these constants are redefined to use cached strings which | |
21 | may reduce your binary size by some amount. | |
1c4293cb VZ |
22 | |
23 | @{ | |
24 | */ | |
25 | ||
26 | /** Set default value for property. | |
27 | */ | |
28 | #define wxPG_ATTR_DEFAULT_VALUE wxS("DefaultValue") | |
29 | ||
30 | /** Universal, int or double. Minimum value for numeric properties. | |
31 | */ | |
32 | #define wxPG_ATTR_MIN wxS("Min") | |
33 | ||
34 | /** Universal, int or double. Maximum value for numeric properties. | |
35 | */ | |
36 | #define wxPG_ATTR_MAX wxS("Max") | |
37 | ||
38 | /** Universal, string. When set, will be shown as text after the displayed | |
39 | text value. Alternatively, if third column is enabled, text will be shown | |
40 | there (for any type of property). | |
41 | */ | |
42 | #define wxPG_ATTR_UNITS wxS("Units") | |
43 | ||
44 | /** Universal, string. When set, will be shown in property's value cell | |
45 | when displayed value string is empty, or value is unspecified. | |
46 | */ | |
47 | #define wxPG_ATTR_INLINE_HELP wxS("InlineHelp") | |
48 | ||
66fb9e12 JS |
49 | /** Universal, wxArrayString. Set to enable auto-completion in any |
50 | wxTextCtrl-based property editor. | |
51 | */ | |
52 | #define wxPG_ATTR_AUTOCOMPLETE wxS("AutoComplete") | |
53 | ||
16372f0d JS |
54 | /** wxBoolProperty and wxFlagsProperty specific. Value type is bool. |
55 | Default value is False. | |
56 | ||
57 | When set to True, bool property will use check box instead of a | |
58 | combo box as its editor control. If you set this attribute | |
59 | for a wxFlagsProperty, it is automatically applied to child | |
60 | bool properties. | |
1c4293cb VZ |
61 | */ |
62 | #define wxPG_BOOL_USE_CHECKBOX wxS("UseCheckbox") | |
63 | ||
16372f0d JS |
64 | /** wxBoolProperty and wxFlagsProperty specific. Value type is bool. |
65 | Default value is False. | |
66 | ||
67 | Set to True for the bool property to cycle value on double click | |
68 | (instead of showing the popup listbox). If you set this attribute | |
69 | for a wxFlagsProperty, it is automatically applied to child | |
70 | bool properties. | |
1c4293cb VZ |
71 | */ |
72 | #define wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING wxS("UseDClickCycling") | |
73 | ||
74 | /** wxFloatProperty (and similar) specific, int, default -1. Sets the (max) precision | |
75 | used when floating point value is rendered as text. The default -1 means infinite | |
76 | precision. | |
77 | */ | |
78 | #define wxPG_FLOAT_PRECISION wxS("Precision") | |
79 | ||
80 | /** The text will be echoed as asterisks (wxTE_PASSWORD will be passed to textctrl etc). | |
81 | */ | |
82 | #define wxPG_STRING_PASSWORD wxS("Password") | |
83 | ||
84 | /** Define base used by a wxUIntProperty. Valid constants are | |
85 | wxPG_BASE_OCT, wxPG_BASE_DEC, wxPG_BASE_HEX and wxPG_BASE_HEXL | |
86 | (lowercase characters). | |
87 | */ | |
88 | #define wxPG_UINT_BASE wxS("Base") | |
89 | ||
90 | /** Define prefix rendered to wxUIntProperty. Accepted constants | |
91 | wxPG_PREFIX_NONE, wxPG_PREFIX_0x, and wxPG_PREFIX_DOLLAR_SIGN. | |
92 | <b>Note:</b> Only wxPG_PREFIX_NONE works with Decimal and Octal | |
93 | numbers. | |
94 | */ | |
95 | #define wxPG_UINT_PREFIX wxS("Prefix") | |
96 | ||
97 | /** wxFileProperty/wxImageFileProperty specific, wxChar*, default is detected/varies. | |
98 | Sets the wildcard used in the triggered wxFileDialog. Format is the | |
99 | same. | |
100 | */ | |
101 | #define wxPG_FILE_WILDCARD wxS("Wildcard") | |
102 | ||
103 | /** wxFileProperty/wxImageFileProperty specific, int, default 1. | |
104 | When 0, only the file name is shown (i.e. drive and directory are hidden). | |
105 | */ | |
106 | #define wxPG_FILE_SHOW_FULL_PATH wxS("ShowFullPath") | |
107 | ||
108 | /** Specific to wxFileProperty and derived properties, wxString, default empty. | |
109 | If set, then the filename is shown relative to the given path string. | |
110 | */ | |
111 | #define wxPG_FILE_SHOW_RELATIVE_PATH wxS("ShowRelativePath") | |
112 | ||
113 | /** Specific to wxFileProperty and derived properties, wxString, default is empty. | |
114 | Sets the initial path of where to look for files. | |
115 | */ | |
116 | #define wxPG_FILE_INITIAL_PATH wxS("InitialPath") | |
117 | ||
118 | /** Specific to wxFileProperty and derivatives, wxString, default is empty. | |
119 | Sets a specific title for the dir dialog. | |
120 | */ | |
121 | #define wxPG_FILE_DIALOG_TITLE wxS("DialogTitle") | |
122 | ||
123 | /** Specific to wxDirProperty, wxString, default is empty. | |
124 | Sets a specific message for the dir dialog. | |
125 | */ | |
126 | #define wxPG_DIR_DIALOG_MESSAGE wxS("DialogMessage") | |
127 | ||
128 | /** Sets displayed date format for wxDateProperty. | |
129 | */ | |
130 | #define wxPG_DATE_FORMAT wxS("DateFormat") | |
131 | ||
132 | /** Sets wxDatePickerCtrl window style used with wxDateProperty. Default | |
b6fd0b42 JS |
133 | is wxDP_DEFAULT | wxDP_SHOWCENTURY. Using wxDP_ALLOWNONE will enable |
134 | better unspecified value support in the editor. | |
1c4293cb VZ |
135 | */ |
136 | #define wxPG_DATE_PICKER_STYLE wxS("PickerStyle") | |
137 | ||
138 | /** SpinCtrl editor, int or double. How much number changes when button is | |
139 | pressed (or up/down on keybard). | |
140 | */ | |
141 | #define wxPG_ATTR_SPINCTRL_STEP wxS("Step") | |
142 | ||
0ad10f30 | 143 | /** SpinCtrl editor, bool. If @true, value wraps at Min/Max. |
1c4293cb VZ |
144 | */ |
145 | #define wxPG_ATTR_SPINCTRL_WRAP wxS("Wrap") | |
146 | ||
18e046a7 JS |
147 | /** SpinCtrl editor, bool. If @true, value can also by changed by moving |
148 | mouse when left mouse button is being pressed. | |
149 | */ | |
150 | #define wxPG_ATTR_SPINCTRL_MOTIONSPIN wxS("MotionSpin") | |
151 | ||
1c4293cb VZ |
152 | /** wxMultiChoiceProperty, int. If 0, no user strings allowed. If 1, user strings |
153 | appear before list strings. If 2, user strings appear after list string. | |
154 | */ | |
155 | #define wxPG_ATTR_MULTICHOICE_USERSTRINGMODE wxS("UserStringMode") | |
156 | ||
157 | /** wxColourProperty and its kind, int, default 1. Setting this attribute to 0 hides custom | |
158 | colour from property's list of choices. | |
159 | */ | |
160 | #define wxPG_COLOUR_ALLOW_CUSTOM wxS("AllowCustom") | |
161 | ||
1c4293cb VZ |
162 | /** @} |
163 | */ | |
164 | ||
1c4293cb | 165 | |
0ad10f30 FM |
166 | |
167 | /** | |
168 | @class wxPGProperty | |
1c4293cb VZ |
169 | |
170 | wxPGProperty is base class for all wxPropertyGrid properties. In | |
171 | sections below we cover few related topics. | |
172 | ||
173 | @li @ref pgproperty_properties | |
174 | @li @ref pgproperty_creating | |
175 | ||
176 | @section pgproperty_properties Supplied Ready-to-use Property Classes | |
177 | ||
178 | Here is a list and short description of supplied fully-functional | |
179 | property classes. They are located in either props.h or advprops.h. | |
180 | ||
181 | @li @ref wxArrayStringProperty | |
182 | @li @ref wxBoolProperty | |
183 | @li @ref wxColourProperty | |
184 | @li @ref wxCursorProperty | |
185 | @li @ref wxDateProperty | |
186 | @li @ref wxDirProperty | |
187 | @li @ref wxEditEnumProperty | |
188 | @li @ref wxEnumProperty | |
189 | @li @ref wxFileProperty | |
190 | @li @ref wxFlagsProperty | |
191 | @li @ref wxFloatProperty | |
192 | @li @ref wxFontProperty | |
193 | @li @ref wxImageFileProperty | |
194 | @li @ref wxIntProperty | |
195 | @li @ref wxLongStringProperty | |
196 | @li @ref wxMultiChoiceProperty | |
197 | @li @ref wxPropertyCategory | |
198 | @li @ref wxStringProperty | |
199 | @li @ref wxSystemColourProperty | |
200 | @li @ref wxUIntProperty | |
201 | ||
202 | @subsection wxPropertyCategory | |
203 | ||
204 | Not an actual property per se, but a header for a group of properties. | |
205 | Regardless inherits from wxPGProperty. | |
206 | ||
207 | @subsection wxStringProperty | |
208 | ||
209 | Simple string property. wxPG_STRING_PASSWORD attribute may be used | |
210 | to echo value as asterisks and use wxTE_PASSWORD for wxTextCtrl. | |
66fb9e12 JS |
211 | wxPG_ATTR_AUTOCOMPLETE attribute may be used to enable auto-completion |
212 | (use a wxArrayString value), and is also supported by any property that | |
213 | happens to use a wxTextCtrl-based editor. | |
1c4293cb | 214 | |
bb6720bb JS |
215 | @remarks wxStringProperty has a special trait: if it has value of |
216 | "<composed>", and also has child properties, then its displayed | |
217 | value becomes composition of child property values, similar as | |
218 | with wxFontProperty, for instance. | |
1c4293cb VZ |
219 | |
220 | @subsection wxIntProperty | |
221 | ||
222 | Like wxStringProperty, but converts text to a signed long integer. | |
223 | wxIntProperty seamlessly supports 64-bit integers (ie. wxLongLong). | |
a6162a3e JS |
224 | To safely convert variant to integer, use code like this: |
225 | ||
226 | @code | |
227 | wxLongLong ll; | |
228 | ll << property->GetValue(); | |
229 | ||
230 | // or | |
231 | wxLongLong ll = propertyGrid->GetPropertyValueAsLong(property); | |
232 | @endcode | |
1c4293cb VZ |
233 | |
234 | @subsection wxUIntProperty | |
235 | ||
236 | Like wxIntProperty, but displays value as unsigned int. To set | |
237 | the prefix used globally, manipulate wxPG_UINT_PREFIX string attribute. | |
238 | To set the globally used base, manipulate wxPG_UINT_BASE int | |
239 | attribute. Regardless of current prefix, understands (hex) values starting | |
240 | with both "0x" and "$". | |
a6162a3e JS |
241 | Like wxIntProperty, wxUIntProperty seamlessly supports 64-bit unsigned |
242 | integers (ie. wxULongLong). Same wxVariant safety rules apply. | |
1c4293cb VZ |
243 | |
244 | @subsection wxFloatProperty | |
245 | ||
246 | Like wxStringProperty, but converts text to a double-precision floating point. | |
247 | Default float-to-text precision is 6 decimals, but this can be changed | |
248 | by modifying wxPG_FLOAT_PRECISION attribute. | |
249 | ||
250 | @subsection wxBoolProperty | |
251 | ||
252 | Represents a boolean value. wxChoice is used as editor control, by the | |
253 | default. wxPG_BOOL_USE_CHECKBOX attribute can be set to true inorder to use | |
254 | check box instead. | |
255 | ||
256 | @subsection wxLongStringProperty | |
257 | ||
258 | Like wxStringProperty, but has a button that triggers a small text editor | |
259 | dialog. Note that in long string values, tabs are represented by "\t" and | |
260 | line break by "\n". | |
261 | ||
3a89adc1 JS |
262 | To display custom dialog on button press, you can subclass |
263 | wxLongStringProperty and implement OnButtonClick, like this: | |
264 | ||
265 | @code | |
266 | virtual bool OnButtonClick( wxPropertyGrid* propGrid, wxString& value ) | |
267 | { | |
3a89adc1 JS |
268 | wxSize dialogSize(...size of your dialog...); |
269 | ||
270 | wxPoint dlgPos = propGrid->GetGoodEditorDialogPosition(this, | |
271 | dialogSize) | |
272 | ||
273 | // Create dialog dlg at dlgPos. Use value as initial string | |
274 | // value. | |
275 | ... | |
276 | ||
277 | if ( dlg.ShowModal() == wxID_OK ) | |
278 | { | |
279 | value = dlg.GetStringValue); | |
280 | return true; | |
281 | } | |
282 | return false; | |
283 | } | |
284 | @endcode | |
285 | ||
286 | Also, if you wish not to have line breaks and tabs translated to | |
287 | escape sequences, then do following in constructor of your subclass: | |
288 | ||
289 | @code | |
290 | m_flags |= wxPG_PROP_NO_ESCAPE; | |
291 | @endcode | |
292 | ||
1c4293cb VZ |
293 | @subsection wxDirProperty |
294 | ||
295 | Like wxLongStringProperty, but the button triggers dir selector instead. | |
296 | Supported properties (all with string value): wxPG_DIR_DIALOG_MESSAGE. | |
297 | ||
298 | @subsection wxFileProperty | |
299 | ||
300 | Like wxLongStringProperty, but the button triggers file selector instead. | |
301 | Default wildcard is "All files..." but this can be changed by setting | |
302 | wxPG_FILE_WILDCARD attribute (see wxFileDialog for format details). | |
0ad10f30 | 303 | Attribute wxPG_FILE_SHOW_FULL_PATH can be set to @false inorder to show |
1c4293cb VZ |
304 | only the filename, not the entire path. |
305 | ||
306 | @subsection wxEnumProperty | |
307 | ||
308 | Represents a single selection from a list of choices - | |
309 | wxOwnerDrawnComboBox is used to edit the value. | |
310 | ||
311 | @subsection wxFlagsProperty | |
312 | ||
16372f0d JS |
313 | Represents a bit set that fits in a long integer. wxBoolProperty sub- |
314 | properties are created for editing individual bits. Textctrl is created to | |
315 | manually edit the flags as a text; a continous sequence of spaces, commas | |
316 | and semicolons are considered as a flag id separator. | |
317 | ||
318 | <b>Note:</b> When changing "choices" (ie. flag labels) of wxFlagsProperty, | |
319 | you will need to use wxPGProperty::SetChoices() - otherwise they will not | |
320 | get updated properly. | |
321 | ||
322 | wxFlagsProperty supports the same attributes as wxBoolProperty. | |
1c4293cb VZ |
323 | |
324 | @subsection wxArrayStringProperty | |
325 | ||
326 | Allows editing of a list of strings in wxTextCtrl and in a separate dialog. | |
327 | ||
328 | @subsection wxDateProperty | |
329 | ||
330 | wxDateTime property. Default editor is DatePickerCtrl, altough TextCtrl | |
331 | should work as well. wxPG_DATE_FORMAT attribute can be used to change | |
332 | string wxDateTime::Format uses (altough default is recommended as it is | |
333 | locale-dependant), and wxPG_DATE_PICKER_STYLE allows changing window | |
334 | style given to DatePickerCtrl (default is wxDP_DEFAULT|wxDP_SHOWCENTURY). | |
b6fd0b42 | 335 | Using wxDP_ALLOWNONE will enable better unspecified value support. |
1c4293cb VZ |
336 | |
337 | @subsection wxEditEnumProperty | |
338 | ||
339 | Represents a string that can be freely edited or selected from list of choices - | |
340 | custom combobox control is used to edit the value. | |
341 | ||
342 | @subsection wxMultiChoiceProperty | |
343 | ||
344 | Allows editing a multiple selection from a list of strings. This is | |
345 | property is pretty much built around concept of wxMultiChoiceDialog. | |
346 | It uses wxArrayString value. | |
347 | ||
348 | @subsection wxImageFileProperty | |
349 | ||
350 | Like wxFileProperty, but has thumbnail of the image in front of | |
351 | the filename and autogenerates wildcard from available image handlers. | |
352 | ||
353 | @subsection wxColourProperty | |
354 | ||
355 | <b>Useful alternate editor:</b> Choice. | |
356 | ||
357 | Represents wxColour. wxButton is used to trigger a colour picker dialog. | |
d61d8cff JS |
358 | There are various sub-classing opportunities with this class. See |
359 | below in wxSystemColourProperty section for details. | |
1c4293cb VZ |
360 | |
361 | @subsection wxFontProperty | |
362 | ||
363 | Represents wxFont. Various sub-properties are used to edit individual | |
364 | subvalues. | |
365 | ||
366 | @subsection wxSystemColourProperty | |
367 | ||
368 | Represents wxColour and a system colour index. wxChoice is used to edit | |
369 | the value. Drop-down list has color images. Note that value type | |
d61d8cff JS |
370 | is wxColourPropertyValue instead of wxColour (which wxColourProperty |
371 | uses). | |
372 | ||
1c4293cb VZ |
373 | @code |
374 | class wxColourPropertyValue : public wxObject | |
375 | { | |
376 | public: | |
377 | // An integer value relating to the colour, and which exact | |
378 | // meaning depends on the property with which it is used. | |
379 | // | |
380 | // For wxSystemColourProperty: | |
381 | // Any of wxSYS_COLOUR_XXX, or any web-colour ( use wxPG_TO_WEB_COLOUR | |
382 | // macro - (currently unsupported) ), or wxPG_COLOUR_CUSTOM. | |
383 | wxUint32 m_type; | |
384 | ||
385 | // Resulting colour. Should be correct regardless of type. | |
386 | wxColour m_colour; | |
387 | }; | |
388 | @endcode | |
0ad10f30 | 389 | |
d61d8cff JS |
390 | in wxSystemColourProperty, and its derived class wxColourProperty, there |
391 | are various sub-classing features. To set basic list list of colour | |
392 | names, call wxPGProperty::SetChoices(). | |
393 | ||
394 | @code | |
395 | // Override in derived class to customize how colours are translated | |
396 | // to strings. | |
397 | virtual wxString ColourToString( const wxColour& col, int index ) const; | |
398 | ||
399 | // Returns index of entry that triggers colour picker dialog | |
400 | // (default is last). | |
401 | virtual int GetCustomColourIndex() const; | |
402 | ||
403 | // Helper function to show the colour dialog | |
404 | bool QueryColourFromUser( wxVariant& variant ) const; | |
405 | ||
406 | // Returns colour for given choice. | |
407 | // Default function returns wxSystemSettings::GetColour(index). | |
408 | virtual wxColour GetColour( int index ) const; | |
409 | @endcode | |
1c4293cb VZ |
410 | |
411 | @subsection wxCursorProperty | |
412 | ||
413 | Represents a wxCursor. wxChoice is used to edit the value. | |
414 | Drop-down list has cursor images under some (wxMSW) platforms. | |
415 | ||
416 | ||
417 | @section pgproperty_creating Creating Custom Properties | |
418 | ||
419 | New properties can be created by subclassing wxPGProperty or one | |
420 | of the provided property classes, and (re)implementing necessary | |
421 | member functions. Below, each virtual member function has ample | |
422 | documentation about its purpose and any odd details which to keep | |
423 | in mind. | |
424 | ||
425 | Here is a very simple 'template' code: | |
426 | ||
427 | @code | |
428 | class MyProperty : public wxPGProperty | |
429 | { | |
430 | public: | |
431 | // All arguments of ctor must have a default value - | |
432 | // use wxPG_LABEL for label and name | |
433 | MyProperty( const wxString& label = wxPG_LABEL, | |
434 | const wxString& name = wxPG_LABEL, | |
435 | const wxString& value = wxEmptyString ) | |
436 | { | |
437 | // m_value is wxVariant | |
438 | m_value = value; | |
439 | } | |
440 | ||
441 | virtual ~MyProperty() { } | |
442 | ||
443 | const wxPGEditor* DoGetEditorClass() const | |
444 | { | |
445 | // Determines editor used by property. | |
446 | // You can replace 'TextCtrl' below with any of these | |
447 | // builtin-in property editor identifiers: Choice, ComboBox, | |
448 | // TextCtrlAndButton, ChoiceAndButton, CheckBox, SpinCtrl, | |
449 | // DatePickerCtrl. | |
450 | return wxPGEditor_TextCtrl; | |
451 | } | |
452 | ||
1425eca5 JS |
453 | virtual wxString ValueToString( wxVariant& value, |
454 | int argFlags ) const | |
1c4293cb | 455 | { |
1425eca5 | 456 | // TODO: Convert given property value to a string |
1c4293cb VZ |
457 | } |
458 | ||
459 | virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags ) | |
460 | { | |
461 | // TODO: Adapt string to property value. | |
462 | } | |
463 | ||
464 | protected: | |
465 | }; | |
466 | @endcode | |
467 | ||
468 | Since wxPGProperty derives from wxObject, you can use standard | |
469 | DECLARE_DYNAMIC_CLASS and IMPLEMENT_DYNAMIC_CLASS macros. From the | |
470 | above example they were omitted for sake of simplicity, and besides, | |
471 | they are only really needed if you need to use wxRTTI with your | |
472 | property class. | |
473 | ||
0372d42e JS |
474 | You can change the 'value type' of a property by simply assigning different |
475 | type of variant with SetValue. <b>It is mandatory to implement | |
476 | wxVariantData class for all data types used as property values.</b> | |
477 | You can use macros declared in wxPropertyGrid headers. For instance: | |
1c4293cb VZ |
478 | |
479 | @code | |
480 | // In header file: | |
0372d42e JS |
481 | // (If you need to have export declaration, use version of macros |
482 | // with _EXPORTED postfix) | |
483 | WX_PG_DECLARE_VARIANT_DATA(MyDataClass) | |
1c4293cb VZ |
484 | |
485 | // In sources file: | |
0372d42e JS |
486 | WX_PG_IMPLEMENT_VARIANT_DATA(MyDataClass) |
487 | ||
488 | // Or, if you don't have valid == operator: | |
489 | WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(MyDataClass) | |
1c4293cb VZ |
490 | @endcode |
491 | ||
492 | @library{wxpropgrid} | |
493 | @category{propgrid} | |
494 | */ | |
495 | class wxPGProperty : public wxObject | |
496 | { | |
497 | public: | |
498 | typedef wxUint32 FlagType; | |
499 | ||
bb6720bb JS |
500 | /** |
501 | Default constructor. | |
1c4293cb VZ |
502 | */ |
503 | wxPGProperty(); | |
504 | ||
bb6720bb JS |
505 | /** |
506 | Constructor. | |
1c4293cb VZ |
507 | Non-abstract property classes should have constructor of this style: |
508 | ||
509 | @code | |
510 | ||
bb6720bb | 511 | MyProperty( const wxString& label, const wxString& name, const T& value ) |
1c4293cb VZ |
512 | : wxPGProperty() |
513 | { | |
514 | // Generally recommended way to set the initial value | |
515 | // (as it should work in pretty much 100% of cases). | |
516 | wxVariant variant; | |
517 | variant << value; | |
518 | SetValue(variant); | |
519 | ||
48a32cf6 JS |
520 | // If has private child properties then create them here. |
521 | // For example: | |
522 | // AddPrivateChild( new wxStringProperty("Subprop 1", | |
523 | // wxPG_LABEL, | |
524 | // value.GetSubProp1())); | |
1c4293cb VZ |
525 | } |
526 | ||
527 | @endcode | |
528 | */ | |
529 | wxPGProperty( const wxString& label, const wxString& name ); | |
530 | ||
bb6720bb JS |
531 | /** |
532 | Virtual destructor. It is customary for derived properties to implement this. | |
533 | */ | |
1c4293cb VZ |
534 | virtual ~wxPGProperty(); |
535 | ||
bb6720bb JS |
536 | /** |
537 | This virtual function is called after m_value has been set. | |
1c4293cb VZ |
538 | |
539 | @remarks | |
540 | - If m_value was set to Null variant (ie. unspecified value), OnSetValue() | |
541 | will not be called. | |
542 | - m_value may be of any variant type. Typically properties internally support only | |
543 | one variant type, and as such OnSetValue() provides a good opportunity to convert | |
544 | supported values into internal type. | |
545 | - Default implementation does nothing. | |
546 | */ | |
547 | virtual void OnSetValue(); | |
548 | ||
bb6720bb JS |
549 | /** |
550 | Override this to return something else than m_value as the value. | |
1c4293cb | 551 | */ |
0ad10f30 | 552 | virtual wxVariant DoGetValue() const; |
1c4293cb | 553 | |
bb6720bb JS |
554 | /** |
555 | Implement this function in derived class to check the value. | |
0ad10f30 | 556 | Return @true if it is ok. Returning @false prevents property change events |
1c4293cb VZ |
557 | from occurring. |
558 | ||
559 | @remarks | |
0ad10f30 | 560 | - Default implementation always returns @true. |
1c4293cb VZ |
561 | */ |
562 | virtual bool ValidateValue( wxVariant& value, wxPGValidationInfo& validationInfo ) const; | |
563 | ||
bb6720bb | 564 | /** |
9e6bebdc JS |
565 | Converts text into wxVariant value appropriate for this property. |
566 | ||
567 | @param variant | |
568 | On function entry this is the old value (should not be wxNullVariant | |
569 | in normal cases). Translated value must be assigned back to it. | |
570 | ||
571 | @param text | |
572 | Text to be translated into variant. | |
573 | ||
1c4293cb | 574 | @param argFlags |
9e6bebdc JS |
575 | If wxPG_FULL_VALUE is set, returns complete, storable value instead |
576 | of displayable one (they may be different). | |
577 | If wxPG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of | |
1425eca5 | 578 | composite property string value (as generated by ValueToString() |
9e6bebdc | 579 | called with this same flag). |
1c4293cb | 580 | |
9e6bebdc JS |
581 | @return Returns @true if resulting wxVariant value was different. |
582 | ||
583 | @remarks Default implementation converts semicolon delimited tokens into | |
584 | child values. Only works for properties with children. | |
585 | ||
586 | You might want to take into account that m_value is Null variant | |
587 | if property value is unspecified (which is usually only case if | |
588 | you explicitly enabled that sort behavior). | |
1c4293cb VZ |
589 | */ |
590 | virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const; | |
591 | ||
bb6720bb | 592 | /** |
9e6bebdc JS |
593 | Converts integer (possibly a choice selection) into wxVariant value |
594 | appropriate for this property. | |
595 | ||
596 | @param variant | |
597 | On function entry this is the old value (should not be wxNullVariant | |
598 | in normal cases). Translated value must be assigned back to it. | |
9e6bebdc JS |
599 | @param number |
600 | Integer to be translated into variant. | |
1c4293cb | 601 | @param argFlags |
9e6bebdc JS |
602 | If wxPG_FULL_VALUE is set, returns complete, storable value instead |
603 | of displayable one. | |
604 | ||
605 | @return Returns @true if resulting wxVariant value was different. | |
1c4293cb VZ |
606 | |
607 | @remarks | |
608 | - If property is not supposed to use choice or spinctrl or other editor | |
609 | with int-based value, it is not necessary to implement this method. | |
610 | - Default implementation simply assign given int to m_value. | |
9e6bebdc JS |
611 | - If property uses choice control, and displays a dialog on some choice |
612 | items, then it is preferred to display that dialog in IntToValue | |
613 | instead of OnEvent. | |
0ad10f30 | 614 | - You might want to take into account that m_value is Mull variant if |
9e6bebdc JS |
615 | property value is unspecified (which is usually only case if you |
616 | explicitly enabled that sort behavior). | |
1c4293cb | 617 | */ |
0ad10f30 | 618 | virtual bool IntToValue( wxVariant& variant, int number, int argFlags = 0 ) const; |
1c4293cb | 619 | |
bb6720bb | 620 | /** |
1425eca5 | 621 | Converts property value into a text representation. |
1c4293cb | 622 | |
1425eca5 JS |
623 | @param value |
624 | Value to be converted. | |
1425eca5 JS |
625 | @param argFlags |
626 | If 0 (default value), then displayed string is returned. | |
627 | If wxPG_FULL_VALUE is set, returns complete, storable string value | |
628 | instead of displayable. If wxPG_EDITABLE_VALUE is set, returns | |
0ad10f30 FM |
629 | string value that must be editable in textctrl. |
630 | If wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to | |
631 | display as a part of string property's composite text representation. | |
1425eca5 JS |
632 | |
633 | @remarks Default implementation calls GenerateComposedValue(). | |
1c4293cb | 634 | */ |
1425eca5 | 635 | virtual wxString ValueToString( wxVariant& value, int argFlags = 0 ) const; |
1c4293cb | 636 | |
bb6720bb JS |
637 | /** |
638 | Converts string to a value, and if successful, calls SetValue() on it. | |
1c4293cb | 639 | Default behavior is to do nothing. |
0ad10f30 | 640 | |
1c4293cb | 641 | @param text |
0ad10f30 FM |
642 | String to get the value from. |
643 | @param flags | |
644 | @todo docme | |
645 | ||
646 | @return @true if value was changed. | |
1c4293cb VZ |
647 | */ |
648 | bool SetValueFromString( const wxString& text, int flags = 0 ); | |
649 | ||
bb6720bb JS |
650 | /** |
651 | Converts integer to a value, and if succesful, calls SetValue() on it. | |
1c4293cb | 652 | Default behavior is to do nothing. |
0ad10f30 | 653 | |
1c4293cb | 654 | @param value |
0ad10f30 | 655 | Int to get the value from. |
1c4293cb | 656 | @param flags |
0ad10f30 FM |
657 | If has wxPG_FULL_VALUE, then the value given is a actual value and not an index. |
658 | ||
659 | @return @true if value was changed. | |
1c4293cb VZ |
660 | */ |
661 | bool SetValueFromInt( long value, int flags = 0 ); | |
662 | ||
bb6720bb JS |
663 | /** |
664 | Returns size of the custom painted image in front of property. This method | |
1c4293cb VZ |
665 | must be overridden to return non-default value if OnCustomPaint is to be |
666 | called. | |
0ad10f30 | 667 | |
1c4293cb | 668 | @param item |
0ad10f30 FM |
669 | Normally -1, but can be an index to the property's list of items. |
670 | ||
1c4293cb VZ |
671 | @remarks |
672 | - Default behavior is to return wxSize(0,0), which means no image. | |
673 | - Default image width or height is indicated with dimension -1. | |
674 | - You can also return wxPG_DEFAULT_IMAGE_SIZE which equals wxSize(-1, -1). | |
675 | */ | |
676 | virtual wxSize OnMeasureImage( int item = -1 ) const; | |
677 | ||
bb6720bb JS |
678 | /** |
679 | Events received by editor widgets are processed here. Note that editor class | |
1c4293cb VZ |
680 | usually processes most events. Some, such as button press events of |
681 | TextCtrlAndButton class, can be handled here. Also, if custom handling | |
682 | for regular events is desired, then that can also be done (for example, | |
683 | wxSystemColourProperty custom handles wxEVT_COMMAND_CHOICE_SELECTED | |
684 | to display colour picker dialog when 'custom' selection is made). | |
685 | ||
0ad10f30 FM |
686 | If the event causes value to be changed, SetValueInEvent() should be called |
687 | to set the new value. | |
688 | ||
689 | The parameter @a event is the associated wxEvent. | |
1c4293cb | 690 | |
1c4293cb | 691 | @retval |
0ad10f30 FM |
692 | Should return @true if any changes in value should be reported. |
693 | ||
1c4293cb VZ |
694 | @remarks |
695 | - If property uses choice control, and displays a dialog on some choice items, | |
696 | then it is preferred to display that dialog in IntToValue instead of OnEvent. | |
697 | */ | |
698 | virtual bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event ); | |
699 | ||
bb6720bb | 700 | /** |
b8b1ff48 JS |
701 | Called after value of a child property has been altered. Must return |
702 | new value of the whole property (after any alterations warrented by | |
703 | child's new value). | |
704 | ||
705 | Note that this function is usually called at the time that value of | |
706 | this property, or given child property, is still pending for change, | |
707 | and as such, result of GetValue() or m_value should not be relied | |
708 | on. | |
1c4293cb VZ |
709 | |
710 | Sample pseudo-code implementation: | |
711 | ||
712 | @code | |
b8b1ff48 JS |
713 | wxVariant MyProperty::ChildChanged( wxVariant& thisValue, |
714 | int childIndex, | |
715 | wxVariant& childValue ) const | |
1c4293cb VZ |
716 | { |
717 | // Acquire reference to actual type of data stored in variant | |
b8b1ff48 JS |
718 | // (TFromVariant only exists if wxPropertyGrid's wxVariant-macros |
719 | // were used to create the variant class). | |
1c4293cb VZ |
720 | T& data = TFromVariant(thisValue); |
721 | ||
722 | // Copy childValue into data. | |
723 | switch ( childIndex ) | |
724 | { | |
725 | case 0: | |
726 | data.SetSubProp1( childvalue.GetLong() ); | |
727 | break; | |
728 | case 1: | |
729 | data.SetSubProp2( childvalue.GetString() ); | |
730 | break; | |
731 | ... | |
732 | } | |
b8b1ff48 JS |
733 | |
734 | // Return altered data | |
735 | return data; | |
1c4293cb VZ |
736 | } |
737 | @endcode | |
738 | ||
739 | @param thisValue | |
b8b1ff48 JS |
740 | Value of this property. Changed value should be returned (in |
741 | previous versions of wxPropertyGrid it was only necessary to | |
742 | write value back to this argument). | |
1c4293cb | 743 | @param childIndex |
b8b1ff48 JS |
744 | Index of child changed (you can use Item(childIndex) to get |
745 | child property). | |
1c4293cb | 746 | @param childValue |
b8b1ff48 JS |
747 | (Pending) value of the child property. |
748 | ||
749 | @return | |
750 | Modified value of the whole property. | |
1c4293cb | 751 | */ |
b8b1ff48 JS |
752 | virtual wxVariant ChildChanged( wxVariant& thisValue, |
753 | int childIndex, | |
754 | wxVariant& childValue ) const; | |
1c4293cb | 755 | |
bb6720bb JS |
756 | /** |
757 | Returns pointer to an instance of used editor. | |
1c4293cb VZ |
758 | */ |
759 | virtual const wxPGEditor* DoGetEditorClass() const; | |
760 | ||
bb6720bb JS |
761 | /** |
762 | Returns pointer to the wxValidator that should be used | |
0ad10f30 | 763 | with the editor of this property (@NULL for no validator). |
1c4293cb VZ |
764 | Setting validator explicitly via SetPropertyValidator |
765 | will override this. | |
766 | ||
767 | In most situations, code like this should work well | |
768 | (macros are used to maintain one actual validator instance, | |
769 | so on the second call the function exits within the first | |
770 | macro): | |
771 | ||
772 | @code | |
773 | ||
774 | wxValidator* wxMyPropertyClass::DoGetValidator () const | |
775 | { | |
776 | WX_PG_DOGETVALIDATOR_ENTRY() | |
777 | ||
778 | wxMyValidator* validator = new wxMyValidator(...); | |
779 | ||
780 | ... prepare validator... | |
781 | ||
782 | WX_PG_DOGETVALIDATOR_EXIT(validator) | |
783 | } | |
784 | ||
785 | @endcode | |
786 | ||
787 | @remarks | |
788 | You can get common filename validator by returning | |
789 | wxFileProperty::GetClassValidator(). wxDirProperty, | |
790 | for example, uses it. | |
791 | */ | |
792 | virtual wxValidator* DoGetValidator () const; | |
793 | ||
bb6720bb JS |
794 | /** |
795 | Override to paint an image in front of the property value text or drop-down | |
1c4293cb VZ |
796 | list item (but only if wxPGProperty::OnMeasureImage is overridden as well). |
797 | ||
798 | If property's OnMeasureImage() returns size that has height != 0 but less than | |
799 | row height ( < 0 has special meanings), wxPropertyGrid calls this method to | |
800 | draw a custom image in a limited area in front of the editor control or | |
801 | value text/graphics, and if control has drop-down list, then the image is | |
802 | drawn there as well (even in the case OnMeasureImage() returned higher height | |
803 | than row height). | |
804 | ||
805 | NOTE: Following applies when OnMeasureImage() returns a "flexible" height ( | |
806 | using wxPG_FLEXIBLE_SIZE(W,H) macro), which implies variable height items: | |
807 | If rect.x is < 0, then this is a measure item call, which means that | |
808 | dc is invalid and only thing that should be done is to set paintdata.m_drawnHeight | |
809 | to the height of the image of item at index paintdata.m_choiceItem. This call | |
810 | may be done even as often as once every drop-down popup show. | |
811 | ||
812 | @param dc | |
813 | wxDC to paint on. | |
814 | @param rect | |
815 | Box reserved for custom graphics. Includes surrounding rectangle, if any. | |
816 | If x is < 0, then this is a measure item call (see above). | |
817 | @param paintdata | |
e342075f JS |
818 | wxPGPaintData structure with much useful data about painted item. |
819 | @code | |
820 | struct wxPGPaintData | |
821 | { | |
822 | // wxPropertyGrid. | |
823 | const wxPropertyGrid* m_parent; | |
824 | ||
825 | // Normally -1, otherwise index to drop-down list item that has to be drawn. | |
826 | int m_choiceItem; | |
827 | ||
828 | // Set to drawn width in OnCustomPaint (optional). | |
829 | int m_drawnWidth; | |
830 | ||
831 | // In a measure item call, set this to the height of item at m_choiceItem index | |
939d9364 | 832 | int m_drawnHeight; |
e342075f JS |
833 | }; |
834 | @endcode | |
1c4293cb VZ |
835 | |
836 | @remarks | |
837 | - You can actually exceed rect width, but if you do so then paintdata.m_drawnWidth | |
838 | must be set to the full width drawn in pixels. | |
839 | - Due to technical reasons, rect's height will be default even if custom height | |
840 | was reported during measure call. | |
841 | - Brush is guaranteed to be default background colour. It has been already used to | |
842 | clear the background of area being painted. It can be modified. | |
843 | - Pen is guaranteed to be 1-wide 'black' (or whatever is the proper colour) pen for | |
844 | drawing framing rectangle. It can be changed as well. | |
845 | ||
1425eca5 | 846 | @see ValueToString() |
1c4293cb VZ |
847 | */ |
848 | virtual void OnCustomPaint( wxDC& dc, const wxRect& rect, wxPGPaintData& paintdata ); | |
849 | ||
bb6720bb JS |
850 | /** |
851 | Returns used wxPGCellRenderer instance for given property column (label=0, value=1). | |
1c4293cb VZ |
852 | |
853 | Default implementation returns editor's renderer for all columns. | |
854 | */ | |
855 | virtual wxPGCellRenderer* GetCellRenderer( int column ) const; | |
856 | ||
bb6720bb JS |
857 | /** |
858 | Returns which choice is currently selected. Only applies to properties | |
939d9364 JS |
859 | which have choices. |
860 | ||
861 | Needs to reimplemented in derived class if property value does not | |
862 | map directly to a choice. Integer as index, bool, and string usually do. | |
863 | */ | |
864 | virtual int GetChoiceSelection() const; | |
865 | ||
bb6720bb JS |
866 | /** |
867 | Refresh values of child properties. Automatically called after value is set. | |
1c4293cb VZ |
868 | */ |
869 | virtual void RefreshChildren(); | |
870 | ||
bb6720bb JS |
871 | /** |
872 | Special handling for attributes of this property. | |
1c4293cb | 873 | |
0ad10f30 | 874 | If returns @false, then the attribute will be automatically stored in |
1c4293cb VZ |
875 | m_attributes. |
876 | ||
0ad10f30 | 877 | Default implementation simply returns @false. |
1c4293cb VZ |
878 | */ |
879 | virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); | |
880 | ||
bb6720bb JS |
881 | /** |
882 | Returns value of an attribute. | |
1c4293cb VZ |
883 | |
884 | Override if custom handling of attributes is needed. | |
885 | ||
0ad10f30 | 886 | Default implementation simply return @NULL variant. |
1c4293cb VZ |
887 | */ |
888 | virtual wxVariant DoGetAttribute( const wxString& name ) const; | |
889 | ||
bb6720bb JS |
890 | /** |
891 | Returns instance of a new wxPGEditorDialogAdapter instance, which is | |
1c4293cb VZ |
892 | used when user presses the (optional) button next to the editor control; |
893 | ||
0ad10f30 | 894 | Default implementation returns @NULL (ie. no action is generated when |
1c4293cb VZ |
895 | button is pressed). |
896 | */ | |
897 | virtual wxPGEditorDialogAdapter* GetEditorDialog() const; | |
898 | ||
d8812c6e JS |
899 | /** |
900 | Called whenever validation has failed with given pending value. | |
901 | ||
902 | @remarks If you implement this in your custom property class, please | |
903 | remember to call the baser implementation as well, since they | |
904 | may use it to revert property into pre-change state. | |
905 | */ | |
906 | virtual void OnValidationFailure( wxVariant& pendingValue ); | |
907 | ||
bb6720bb JS |
908 | /** |
909 | Append a new choice to property's list of choices. | |
939d9364 JS |
910 | |
911 | @param label | |
912 | Label for added choice. | |
913 | ||
914 | @param value | |
915 | Value for new choice. Do not specify if you wish this | |
916 | to equal choice index. | |
917 | ||
918 | @return | |
919 | Index to added choice. | |
920 | */ | |
921 | int AddChoice( const wxString& label, int value = wxPG_INVALID_VALUE ); | |
922 | ||
bb6720bb | 923 | /** |
48a32cf6 | 924 | Adds a private child property. |
2fd4a524 | 925 | |
48a32cf6 JS |
926 | @deprecated Use AddPrivateChild() instead. |
927 | ||
928 | @see AddPrivateChild() | |
929 | */ | |
930 | wxDEPRECATED( void AddChild( wxPGProperty* prop ) ); | |
931 | ||
932 | /** | |
933 | Adds a private child property. If you use this instead of | |
934 | wxPropertyGridInterface::Insert() or | |
935 | wxPropertyGridInterface::AppendIn(), then property's parental | |
936 | type will automatically be set up to wxPG_PROP_AGGREGATE. In other | |
937 | words, all properties of this property will become private. | |
bb6720bb | 938 | */ |
48a32cf6 | 939 | void AddPrivateChild( wxPGProperty* prop ); |
bb6720bb JS |
940 | |
941 | /** | |
942 | Adapts list variant into proper value using consecutive | |
943 | ChildChanged() calls. | |
944 | */ | |
945 | void AdaptListToValue( wxVariant& list, wxVariant* value ) const; | |
946 | ||
48a32cf6 JS |
947 | /** |
948 | Use this member function to add independent (ie. regular) children to | |
949 | a property. | |
950 | ||
951 | @return Appended childProperty. | |
952 | ||
953 | @remarks wxPropertyGrid is not automatically refreshed by this | |
954 | function. | |
955 | ||
956 | @see InsertChild(), AddPrivateChild() | |
957 | */ | |
958 | wxPGProperty* AppendChild( wxPGProperty* childProperty ); | |
959 | ||
bb6720bb JS |
960 | /** |
961 | Determines, recursively, if all children are not unspecified. | |
962 | ||
963 | @param pendingList | |
964 | Assumes members in this wxVariant list as pending | |
965 | replacement values. | |
966 | */ | |
967 | bool AreAllChildrenSpecified( wxVariant* pendingList = NULL ) const; | |
968 | ||
969 | /** | |
0ad10f30 | 970 | Returns @true if children of this property are component values (for instance, |
1c4293cb VZ |
971 | points size, face name, and is_underlined are component values of a font). |
972 | */ | |
0ad10f30 | 973 | bool AreChildrenComponents() const; |
1c4293cb | 974 | |
91c818f8 JS |
975 | /** |
976 | Deletes children of the property. | |
977 | */ | |
978 | void DeleteChildren(); | |
979 | ||
bb6720bb JS |
980 | /** |
981 | Removes entry from property's wxPGChoices and editor control (if it is active). | |
1c4293cb VZ |
982 | |
983 | If selected item is deleted, then the value is set to unspecified. | |
984 | */ | |
985 | void DeleteChoice( int index ); | |
986 | ||
bb6720bb JS |
987 | /** Deletes all child properties. */ |
988 | void Empty(); | |
989 | ||
1425eca5 | 990 | /** |
c82a80e8 | 991 | Composes text from values of child properties. |
1425eca5 | 992 | */ |
c82a80e8 | 993 | wxString GenerateComposedValue() const; |
1c4293cb | 994 | |
bb6720bb JS |
995 | /** |
996 | Returns property attribute value, null variant if not found. | |
997 | */ | |
998 | wxVariant GetAttribute( const wxString& name ) const; | |
1c4293cb | 999 | |
bb6720bb JS |
1000 | /** Returns named attribute, as string, if found. Otherwise defVal is returned. |
1001 | */ | |
1002 | wxString GetAttribute( const wxString& name, const wxString& defVal ) const; | |
1c4293cb | 1003 | |
bb6720bb | 1004 | /** Returns named attribute, as long, if found. Otherwise defVal is returned. |
939d9364 | 1005 | */ |
bb6720bb | 1006 | long GetAttributeAsLong( const wxString& name, long defVal ) const; |
1c4293cb | 1007 | |
bb6720bb | 1008 | /** Returns named attribute, as double, if found. Otherwise defVal is returned. |
1c4293cb | 1009 | */ |
bb6720bb | 1010 | double GetAttributeAsDouble( const wxString& name, double defVal ) const; |
1c4293cb | 1011 | |
bb6720bb JS |
1012 | /** |
1013 | Returns attributes as list wxVariant. | |
1014 | */ | |
1015 | wxVariant GetAttributesAsList() const; | |
1c4293cb | 1016 | |
bb6720bb | 1017 | /** |
0ad10f30 | 1018 | Returns editor used for given column. @NULL for no editor. |
1c4293cb | 1019 | */ |
0ad10f30 | 1020 | const wxPGEditor* GetColumnEditor( int column ) const; |
1c4293cb | 1021 | |
bb6720bb | 1022 | /** Returns property's base name (ie. parent's name is not added in any case) */ |
0ad10f30 | 1023 | const wxString& GetBaseName() const; |
1c4293cb | 1024 | |
bb6720bb | 1025 | /** |
d7e2b522 | 1026 | Returns wxPGCell of given column. |
1c4293cb | 1027 | */ |
d7e2b522 | 1028 | const wxPGCell& GetCell( unsigned int column ) const; |
1c4293cb | 1029 | |
bb6720bb JS |
1030 | /** |
1031 | Returns number of child properties. | |
1032 | */ | |
1033 | unsigned int GetChildCount() const; | |
1034 | ||
1035 | /** | |
1036 | Returns height of children, recursively, and | |
1037 | by taking expanded/collapsed status into account. | |
1038 | ||
1039 | @param lh | |
1040 | Line height. Pass result of GetGrid()->GetRowHeight() here. | |
1041 | ||
1042 | @param iMax | |
1043 | Only used (internally) when finding property y-positions. | |
1044 | */ | |
1045 | int GetChildrenHeight( int lh, int iMax = -1 ) const; | |
1046 | ||
1047 | /** | |
1048 | Returns read-only reference to property's list of choices. | |
1049 | */ | |
1050 | const wxPGChoices& GetChoices() const; | |
1051 | ||
1052 | /** | |
1053 | Returns client data (void*) of a property. | |
1054 | */ | |
1055 | void* GetClientData() const; | |
1056 | ||
1057 | /** Sets managed client object of a property. | |
1058 | */ | |
1059 | wxClientData *GetClientObject() const; | |
1060 | ||
1061 | /** | |
1062 | Returns property's default value. If property's value type is not | |
1063 | a built-in one, and "DefaultValue" attribute is not defined, then | |
1064 | this function usually returns Null variant. | |
1065 | */ | |
1066 | wxVariant GetDefaultValue() const; | |
1067 | ||
40924780 | 1068 | /** Returns property's displayed text. |
bb6720bb | 1069 | */ |
0ad10f30 | 1070 | wxString GetDisplayedString() const; |
1c4293cb | 1071 | |
bb6720bb JS |
1072 | /** |
1073 | Returns wxPGEditor that will be used and created when | |
1074 | property becomes selected. Returns more accurate value | |
1075 | than DoGetEditorClass(). | |
1076 | */ | |
1077 | const wxPGEditor* GetEditorClass() const; | |
1078 | ||
1c4293cb VZ |
1079 | /** Returns property grid where property lies. */ |
1080 | wxPropertyGrid* GetGrid() const; | |
1081 | ||
bb6720bb JS |
1082 | /** |
1083 | Returns owner wxPropertyGrid, but only if one is currently on a page | |
1084 | displaying this property. | |
1085 | */ | |
1c4293cb VZ |
1086 | wxPropertyGrid* GetGridIfDisplayed() const; |
1087 | ||
bb6720bb JS |
1088 | /** |
1089 | Returns property's help or description text. | |
1090 | ||
1091 | @see SetHelpString() | |
1c4293cb | 1092 | */ |
bb6720bb | 1093 | const wxString& GetHelpString() const; |
1c4293cb | 1094 | |
bb6720bb JS |
1095 | /** |
1096 | Returns position in parent's array. | |
1097 | */ | |
1098 | unsigned int GetIndexInParent() const; | |
1c4293cb | 1099 | |
bb6720bb | 1100 | /** Returns property's label. */ |
0ad10f30 | 1101 | const wxString& GetLabel() const; |
1c4293cb | 1102 | |
bb6720bb JS |
1103 | /** |
1104 | Returns last visible child property, recursively. | |
1c4293cb | 1105 | */ |
bb6720bb | 1106 | const wxPGProperty* GetLastVisibleSubItem() const; |
1c4293cb | 1107 | |
bb6720bb JS |
1108 | /** |
1109 | Returns highest level non-category, non-root parent. Useful when you | |
17e3ad2a | 1110 | have nested properties with children. |
1c4293cb | 1111 | |
bb6720bb JS |
1112 | @remarks If immediate parent is root or category, this will return the |
1113 | property itself. | |
1114 | */ | |
1115 | wxPGProperty* GetMainParent() const; | |
1c4293cb | 1116 | |
bb6720bb | 1117 | /** Returns maximum allowed length of property's text value. |
1c4293cb | 1118 | */ |
0ad10f30 | 1119 | int GetMaxLength() const; |
1c4293cb | 1120 | |
bb6720bb JS |
1121 | /** Returns property's name with all (non-category, non-root) parents. */ |
1122 | wxString GetName() const; | |
1123 | ||
1124 | /** Return parent of property */ | |
0ad10f30 | 1125 | wxPGProperty* GetParent() const; |
bb6720bb JS |
1126 | |
1127 | /** | |
0ad10f30 | 1128 | Returns (direct) child property with given name (or @NULL if not found). |
1c4293cb | 1129 | */ |
bb6720bb JS |
1130 | wxPGProperty* GetPropertyByName( const wxString& name ) const; |
1131 | ||
1132 | /** Gets assignable version of property's validator. */ | |
1133 | wxValidator* GetValidator() const; | |
1c4293cb | 1134 | |
bb6720bb JS |
1135 | /** |
1136 | Returns property's value. | |
1137 | */ | |
0ad10f30 | 1138 | wxVariant GetValue() const; |
1c4293cb | 1139 | |
bb6720bb | 1140 | /** |
0ad10f30 | 1141 | Returns bitmap that appears next to value text. Only returns non-@NULL |
bb6720bb JS |
1142 | bitmap if one was set with SetValueImage(). |
1143 | */ | |
1144 | wxBitmap* GetValueImage() const; | |
1c4293cb | 1145 | |
1425eca5 JS |
1146 | /** Returns text representation of property's value. |
1147 | ||
1148 | @param argFlags | |
1149 | If 0 (default value), then displayed string is returned. | |
1150 | If wxPG_FULL_VALUE is set, returns complete, storable string value | |
1151 | instead of displayable. If wxPG_EDITABLE_VALUE is set, returns | |
1152 | string value that must be editable in textctrl. If | |
1153 | wxPG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to | |
1154 | display as a part of string property's composite text | |
1155 | representation. | |
1156 | ||
1157 | @remarks In older versions, this function used to be overridden to convert | |
1158 | property's value into a string representation. This function is | |
1159 | now handled by ValueToString(), and overriding this function now | |
1160 | will result in run-time assertion failure. | |
1161 | */ | |
1162 | virtual wxString GetValueAsString( int argFlags = 0 ) const; | |
1163 | ||
1164 | /** Synonymous to GetValueAsString(). | |
1165 | ||
1166 | @deprecated Use GetValueAsString() instead. | |
bb6720bb JS |
1167 | |
1168 | @see GetValueAsString() | |
1169 | */ | |
1425eca5 | 1170 | wxDEPRECATED( wxString GetValueString( int argFlags = 0 ) const ); |
bb6720bb JS |
1171 | |
1172 | /** | |
1173 | Returns value type used by this property. | |
1174 | */ | |
0ad10f30 | 1175 | wxString GetValueType() const; |
1c4293cb | 1176 | |
bb6720bb JS |
1177 | /** |
1178 | Returns coordinate to the top y of the property. Note that the | |
1179 | position of scrollbars is not taken into account. | |
1c4293cb | 1180 | */ |
bb6720bb | 1181 | int GetY() const; |
1c4293cb | 1182 | |
bb6720bb | 1183 | /** |
0ad10f30 | 1184 | Returns @true if property has even one visible child. |
1c4293cb VZ |
1185 | */ |
1186 | bool HasVisibleChildren() const; | |
1187 | ||
bb6720bb JS |
1188 | /** |
1189 | Hides or reveals the property. | |
1190 | ||
1191 | @param hide | |
1192 | @true for hide, @false for reveal. | |
1193 | ||
1194 | @param flags | |
1195 | By default changes are applied recursively. Set this parameter wxPG_DONT_RECURSE to prevent this. | |
1196 | */ | |
1197 | bool Hide( bool hide, int flags = wxPG_RECURSE ); | |
1198 | ||
1199 | /** | |
1200 | Returns index of given child property. wxNOT_FOUND if | |
1201 | given property is not child of this. | |
1202 | */ | |
1203 | int Index( const wxPGProperty* p ) const; | |
1204 | ||
48a32cf6 JS |
1205 | /** |
1206 | Use this member function to add independent (ie. regular) children to | |
1207 | a property. | |
1208 | ||
1209 | @return Inserted childProperty. | |
1210 | ||
1211 | @remarks wxPropertyGrid is not automatically refreshed by this | |
1212 | function. | |
1213 | ||
1214 | @see AppendChild(), AddPrivateChild() | |
1215 | */ | |
1216 | wxPGProperty* InsertChild( int index, wxPGProperty* childProperty ); | |
1217 | ||
bb6720bb JS |
1218 | /** |
1219 | Inserts a new choice to property's list of choices. | |
939d9364 JS |
1220 | |
1221 | @param label | |
1222 | Text for new choice | |
1223 | ||
1224 | @param index | |
1225 | Insertion position. Use wxNOT_FOUND to append. | |
1226 | ||
1227 | @param value | |
1228 | Value for new choice. Do not specify if you wish this | |
1229 | to equal choice index. | |
1c4293cb VZ |
1230 | */ |
1231 | int InsertChoice( const wxString& label, int index, int value = wxPG_INVALID_VALUE ); | |
1232 | ||
bb6720bb JS |
1233 | /** |
1234 | Returns @true if this property is actually a wxPropertyCategory. | |
1c4293cb | 1235 | */ |
bb6720bb | 1236 | bool IsCategory() const; |
1c4293cb | 1237 | |
bb6720bb JS |
1238 | /** |
1239 | Returns @true if property is enabled. | |
1c4293cb | 1240 | */ |
bb6720bb | 1241 | bool IsEnabled() const; |
1c4293cb | 1242 | |
bb6720bb JS |
1243 | /** |
1244 | Returns @true if property has visible children. | |
1c4293cb | 1245 | */ |
bb6720bb | 1246 | bool IsExpanded() const; |
1c4293cb | 1247 | |
bb6720bb JS |
1248 | /** |
1249 | Returns @true if this property is actually a wxRootProperty. | |
1c4293cb | 1250 | */ |
0ad10f30 | 1251 | bool IsRoot() const; |
1c4293cb | 1252 | |
bb6720bb JS |
1253 | /** |
1254 | Returns @true if candidateParent is some parent of this property. | |
1c4293cb | 1255 | */ |
bb6720bb | 1256 | bool IsSomeParent( wxPGProperty* candidateParent ) const; |
1c4293cb | 1257 | |
bb6720bb JS |
1258 | /** |
1259 | Returns true if property has editable wxTextCtrl when selected. | |
1c4293cb | 1260 | |
bb6720bb JS |
1261 | @remarks Altough disabled properties do not displayed editor, they still |
1262 | return @true here as being disabled is considered a temporary | |
1263 | condition (unlike being read-only or having limited editing enabled). | |
1c4293cb | 1264 | */ |
bb6720bb | 1265 | bool IsTextEditable() const; |
1c4293cb | 1266 | |
bb6720bb JS |
1267 | /** |
1268 | Returns @true if property's value is considered unspecified. This | |
1269 | usually means that value is Null variant. | |
1c4293cb | 1270 | */ |
bb6720bb | 1271 | bool IsValueUnspecified() const; |
1c4293cb | 1272 | |
bb6720bb JS |
1273 | /** |
1274 | Returns true if all parents expanded. | |
1c4293cb | 1275 | */ |
bb6720bb | 1276 | bool IsVisible() const; |
1c4293cb | 1277 | |
bb6720bb JS |
1278 | /** |
1279 | Returns child property at index i. | |
1c4293cb | 1280 | */ |
68bcfd2c | 1281 | wxPGProperty* Item( unsigned int i ) const; |
1c4293cb | 1282 | |
bb6720bb JS |
1283 | /** |
1284 | If property's editor is active, then update it's value. | |
1c4293cb VZ |
1285 | */ |
1286 | void RefreshEditor(); | |
1287 | ||
bb6720bb JS |
1288 | /** |
1289 | Sets an attribute for this property. | |
1290 | ||
1c4293cb | 1291 | @param name |
bb6720bb JS |
1292 | Text identifier of attribute. See @ref propgrid_property_attributes. |
1293 | ||
1c4293cb | 1294 | @param value |
bb6720bb | 1295 | Value of attribute. |
1802a91d JS |
1296 | |
1297 | @remarks Setting attribute's value to Null variant will simply remove it | |
1298 | from property's set of attributes. | |
1c4293cb VZ |
1299 | */ |
1300 | void SetAttribute( const wxString& name, wxVariant value ); | |
1301 | ||
d7e2b522 JS |
1302 | /** |
1303 | Sets property's background colour. | |
1304 | ||
1305 | @param colour | |
1306 | Background colour to use. | |
1307 | ||
1308 | @param recursively | |
1309 | If @true, children are affected recursively, and any categories | |
1310 | are not. | |
1311 | */ | |
1312 | void SetBackgroundColour( const wxColour& colour, | |
1313 | bool recursively = false ); | |
1314 | ||
bb6720bb JS |
1315 | /** |
1316 | Sets editor for a property. | |
1c4293cb VZ |
1317 | |
1318 | @param editor | |
bb6720bb JS |
1319 | For builtin editors, use wxPGEditor_X, where X is builtin editor's |
1320 | name (TextCtrl, Choice, etc. see wxPGEditor documentation for full list). | |
1c4293cb VZ |
1321 | |
1322 | For custom editors, use pointer you received from wxPropertyGrid::RegisterEditorClass(). | |
1323 | */ | |
bb6720bb | 1324 | void SetEditor( const wxPGEditor* editor ); |
1c4293cb | 1325 | |
bb6720bb JS |
1326 | /** |
1327 | Sets editor for a property, by editor name. | |
1c4293cb | 1328 | */ |
bb6720bb | 1329 | void SetEditor( const wxString& editorName ); |
1c4293cb | 1330 | |
bb6720bb JS |
1331 | /** |
1332 | Sets cell information for given column. | |
1c4293cb | 1333 | */ |
d7e2b522 | 1334 | void SetCell( int column, const wxPGCell& cell ); |
1c4293cb | 1335 | |
bb6720bb JS |
1336 | /** |
1337 | Sets new set of choices for property. | |
1c4293cb | 1338 | |
bb6720bb | 1339 | @remarks This operation clears the property value. |
1c4293cb | 1340 | */ |
bb6720bb | 1341 | bool SetChoices( wxPGChoices& choices ); |
1c4293cb | 1342 | |
bb6720bb JS |
1343 | /** |
1344 | Sets client data (void*) of a property. | |
1c4293cb | 1345 | |
bb6720bb | 1346 | @remarks This untyped client data has to be deleted manually. |
1c4293cb | 1347 | */ |
bb6720bb | 1348 | void SetClientData( void* clientData ); |
1c4293cb | 1349 | |
bb6720bb JS |
1350 | /** Returns client object of a property. |
1351 | */ | |
1352 | void SetClientObject(wxClientData* clientObject); | |
1c4293cb | 1353 | |
bb6720bb JS |
1354 | /** |
1355 | Sets selected choice and changes property value. | |
1c4293cb | 1356 | |
bb6720bb JS |
1357 | Tries to retain value type, although currently if it is not string, |
1358 | then it is forced to integer. | |
1c4293cb | 1359 | */ |
bb6720bb | 1360 | void SetChoiceSelection( int newValue ); |
1c4293cb | 1361 | |
0ce8e27f JS |
1362 | /** Set default value of a property. Synonymous to |
1363 | ||
1364 | @code | |
1365 | SetAttribute("DefaultValue", value); | |
1366 | @endcode | |
1367 | */ | |
1368 | void SetDefaultValue( wxVariant& value ); | |
1369 | ||
bb6720bb JS |
1370 | /** |
1371 | Sets property's help string, which is shown, for example, in | |
1372 | wxPropertyGridManager's description text box. | |
1c4293cb | 1373 | */ |
bb6720bb | 1374 | void SetHelpString( const wxString& helpString ); |
1c4293cb | 1375 | |
bb6720bb JS |
1376 | /** |
1377 | Sets property's label. | |
1c4293cb | 1378 | |
bb6720bb JS |
1379 | @remarks Properties under same parent may have same labels. However, |
1380 | property names must still remain unique. | |
258ccb95 | 1381 | */ |
0ad10f30 | 1382 | void SetLabel( const wxString& label ); |
1c4293cb | 1383 | |
bb6720bb JS |
1384 | /** |
1385 | Set max length of text in text editor. | |
1c4293cb | 1386 | */ |
bb6720bb | 1387 | bool SetMaxLength( int maxLen ); |
1c4293cb | 1388 | |
bb6720bb JS |
1389 | /** |
1390 | Sets property's "is it modified?" flag. Affects children recursively. | |
1c4293cb | 1391 | */ |
bb6720bb | 1392 | void SetModifiedStatus( bool modified ); |
1c4293cb | 1393 | |
bb6720bb JS |
1394 | /** |
1395 | Sets new (base) name for property. | |
1c4293cb | 1396 | */ |
bb6720bb | 1397 | void SetName( const wxString& newName ); |
1c4293cb | 1398 | |
2fd4a524 JS |
1399 | /** |
1400 | Changes what sort of parent this property is for its children. | |
1401 | ||
1402 | @param flag | |
1403 | Use one of the following values: wxPG_PROP_MISC_PARENT (for generic | |
1404 | parents), wxPG_PROP_CATEGORY (for categories), or | |
1405 | wxPG_PROP_AGGREGATE (for derived property classes with private | |
1406 | children). | |
1407 | ||
48a32cf6 | 1408 | @remarks You generally do not need to call this function. |
2fd4a524 JS |
1409 | */ |
1410 | void SetParentalType( int flag ); | |
1411 | ||
d7e2b522 JS |
1412 | /** |
1413 | Sets property's text colour. | |
1414 | ||
1415 | @param colour | |
1416 | Text colour to use. | |
1417 | ||
1418 | @param recursively | |
1419 | If @true, children are affected recursively, and any categories | |
1420 | are not. | |
1421 | */ | |
1422 | void SetTextColour( const wxColour& colour, | |
1423 | bool recursively = false ); | |
1424 | ||
bb6720bb JS |
1425 | /** Sets wxValidator for a property */ |
1426 | void SetValidator( const wxValidator& validator ); | |
1c4293cb | 1427 | |
bb6720bb JS |
1428 | /** |
1429 | Call this to set value of the property. Unlike methods in wxPropertyGrid, | |
1430 | this does not automatically update the display. | |
1c4293cb VZ |
1431 | |
1432 | @remarks | |
bb6720bb JS |
1433 | Use wxPropertyGrid::ChangePropertyValue() instead if you need to run through |
1434 | validation process and send property change event. | |
1c4293cb | 1435 | |
bb6720bb JS |
1436 | If you need to change property value in event, based on user input, use |
1437 | SetValueInEvent() instead. | |
1c4293cb | 1438 | |
0ad10f30 FM |
1439 | @param value |
1440 | The value to set. | |
bb6720bb JS |
1441 | @param pList |
1442 | Pointer to list variant that contains child values. Used to indicate | |
0ad10f30 | 1443 | which children should be marked as modified. Usually you just use @NULL. |
bb6720bb | 1444 | @param flags |
e777bd14 JS |
1445 | wxPG_SETVAL_REFRESH_EDITOR is set by default, to refresh editor |
1446 | and redraw properties. | |
1c4293cb | 1447 | */ |
e777bd14 JS |
1448 | void SetValue( wxVariant value, wxVariant* pList = NULL, |
1449 | int flags = wxPG_SETVAL_REFRESH_EDITOR ); | |
1c4293cb | 1450 | |
bb6720bb JS |
1451 | /** |
1452 | Set wxBitmap in front of the value. This bitmap may be ignored | |
1453 | by custom cell renderers. | |
1c4293cb | 1454 | */ |
bb6720bb | 1455 | void SetValueImage( wxBitmap& bmp ); |
1c4293cb | 1456 | |
bb6720bb JS |
1457 | /** |
1458 | Call this function in OnEvent(), OnButtonClick() etc. to change the | |
1459 | property value based on user input. | |
939d9364 | 1460 | |
bb6720bb JS |
1461 | @remarks This method is const since it doesn't actually modify value, but posts |
1462 | given variant as pending value, stored in wxPropertyGrid. | |
1c4293cb | 1463 | */ |
bb6720bb | 1464 | void SetValueInEvent( wxVariant value ) const; |
1c4293cb | 1465 | |
bb6720bb JS |
1466 | /** |
1467 | Sets property's value to unspecified (ie. Null variant). | |
1c4293cb | 1468 | */ |
bb6720bb | 1469 | void SetValueToUnspecified(); |
1c4293cb | 1470 | |
bb6720bb JS |
1471 | /** |
1472 | Call with @false in OnSetValue() to cancel value changes after all | |
1473 | (ie. cancel @true returned by StringToValue() or IntToValue()). | |
1474 | */ | |
1475 | void SetWasModified( bool set = true ); | |
1c4293cb | 1476 | |
bb6720bb JS |
1477 | /** |
1478 | Updates composed values of parent non-category properties, recursively. | |
1479 | Returns topmost property updated. | |
1480 | */ | |
1481 | wxPGProperty* UpdateParentValues(); | |
1c4293cb | 1482 | |
bb6720bb | 1483 | /** |
0ad10f30 | 1484 | Returns @true if containing grid uses wxPG_EX_AUTO_UNSPECIFIED_VALUES. |
1c4293cb | 1485 | */ |
bb6720bb | 1486 | bool UsesAutoUnspecified() const; |
1c4293cb VZ |
1487 | }; |
1488 | ||
1489 | ||
0ad10f30 FM |
1490 | /** |
1491 | @class wxPGChoices | |
1c4293cb VZ |
1492 | |
1493 | Helper class for managing choices of wxPropertyGrid properties. | |
e1ef506e JS |
1494 | Each entry can have label, value, bitmap, text colour, and background |
1495 | colour. | |
16372f0d | 1496 | |
e1ef506e JS |
1497 | wxPGChoices uses reference counting, similar to other wxWidgets classes. |
1498 | This means that assignment operator and copy constructor only copy the | |
1499 | reference and not the actual data. Use Copy() member function to create a | |
1500 | real copy. | |
1501 | ||
1502 | @remarks If you do not specify value for entry, index is used. | |
1c4293cb VZ |
1503 | |
1504 | @library{wxpropgrid} | |
1505 | @category{propgrid} | |
1506 | */ | |
1507 | class WXDLLIMPEXP_PROPGRID wxPGChoices | |
1508 | { | |
1509 | public: | |
1510 | typedef long ValArrItem; | |
1511 | ||
bb6720bb JS |
1512 | /** |
1513 | Default constructor. | |
1514 | */ | |
1515 | wxPGChoices(); | |
1c4293cb | 1516 | |
e1ef506e JS |
1517 | /** |
1518 | Copy constructor, uses reference counting. To create a real copy, | |
1519 | use Copy() member function instead. | |
1520 | */ | |
bb6720bb | 1521 | wxPGChoices( const wxPGChoices& a ); |
1c4293cb VZ |
1522 | |
1523 | /** Constructor. */ | |
bb6720bb | 1524 | wxPGChoices( const wxChar** labels, const long* values = NULL ); |
1c4293cb VZ |
1525 | |
1526 | /** Constructor. */ | |
bb6720bb | 1527 | wxPGChoices( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() ); |
1c4293cb | 1528 | |
bb6720bb JS |
1529 | /** Constructor. */ |
1530 | wxPGChoices( wxPGChoicesData* data ); | |
1c4293cb VZ |
1531 | |
1532 | /** Destructor. */ | |
bb6720bb | 1533 | ~wxPGChoices(); |
1c4293cb | 1534 | |
bb6720bb JS |
1535 | /** |
1536 | Adds to current. If did not have own copies, creates them now. If was empty, | |
1c4293cb VZ |
1537 | identical to set except that creates copies. |
1538 | */ | |
1539 | void Add( const wxChar** labels, const ValArrItem* values = NULL ); | |
1540 | ||
1541 | /** Version that works with wxArrayString. */ | |
1542 | void Add( const wxArrayString& arr, const ValArrItem* values = NULL ); | |
1543 | ||
1544 | /** Version that works with wxArrayString and wxArrayInt. */ | |
1545 | void Add( const wxArrayString& arr, const wxArrayInt& arrint ); | |
1546 | ||
1547 | /** Adds single item. */ | |
1548 | wxPGChoiceEntry& Add( const wxString& label, int value = wxPG_INVALID_VALUE ); | |
1549 | ||
1550 | /** Adds a single item, with bitmap. */ | |
bb6720bb JS |
1551 | wxPGChoiceEntry& Add( const wxString& label, const wxBitmap& bitmap, |
1552 | int value = wxPG_INVALID_VALUE ); | |
1c4293cb VZ |
1553 | |
1554 | /** Adds a single item with full entry information. */ | |
0ad10f30 | 1555 | wxPGChoiceEntry& Add( const wxPGChoiceEntry& entry ); |
1c4293cb | 1556 | |
bb6720bb | 1557 | /** Adds single item, sorted. */ |
1c4293cb VZ |
1558 | wxPGChoiceEntry& AddAsSorted( const wxString& label, int value = wxPG_INVALID_VALUE ); |
1559 | ||
bb6720bb | 1560 | /** |
e1ef506e JS |
1561 | Assigns choices data, using reference counting. To create a real copy, |
1562 | use Copy() member function instead. | |
bb6720bb | 1563 | */ |
0ad10f30 | 1564 | void Assign( const wxPGChoices& a ); |
1c4293cb | 1565 | |
bb6720bb JS |
1566 | /** |
1567 | Assigns data from another set of choices. | |
1568 | */ | |
1c4293cb VZ |
1569 | void AssignData( wxPGChoicesData* data ); |
1570 | ||
bb6720bb JS |
1571 | /** |
1572 | Deletes all items. | |
1573 | */ | |
0ad10f30 | 1574 | void Clear(); |
1c4293cb | 1575 | |
e1ef506e JS |
1576 | /** |
1577 | Returns a real copy of the choices. | |
1578 | */ | |
1579 | wxPGChoices Copy() const; | |
1580 | ||
bb6720bb JS |
1581 | /** |
1582 | Returns labe of item. | |
1583 | */ | |
68bcfd2c | 1584 | const wxString& GetLabel( unsigned int ind ) const; |
1c4293cb | 1585 | |
bb6720bb JS |
1586 | /** |
1587 | Returns number of items. | |
1588 | */ | |
68bcfd2c | 1589 | unsigned int GetCount() const; |
1c4293cb | 1590 | |
bb6720bb JS |
1591 | /** |
1592 | Returns value of item; | |
1593 | */ | |
68bcfd2c | 1594 | int GetValue( unsigned int ind ) const; |
1c4293cb | 1595 | |
bb6720bb JS |
1596 | /** |
1597 | Returns array of values matching the given strings. Unmatching strings | |
1c4293cb VZ |
1598 | result in wxPG_INVALID_VALUE entry in array. |
1599 | */ | |
1600 | wxArrayInt GetValuesForStrings( const wxArrayString& strings ) const; | |
1601 | ||
bb6720bb JS |
1602 | /** |
1603 | Returns array of indices matching given strings. Unmatching strings | |
0ad10f30 | 1604 | are added to 'unmatched', if not @NULL. |
1c4293cb | 1605 | */ |
bb6720bb JS |
1606 | wxArrayInt GetIndicesForStrings( const wxArrayString& strings, |
1607 | wxArrayString* unmatched = NULL ) const; | |
1c4293cb | 1608 | |
14bac4b5 JS |
1609 | /** Returns property at given virtual y coordinate. |
1610 | */ | |
1611 | wxPGProperty* GetItemAtY( unsigned int y ) const; | |
1612 | ||
bb6720bb JS |
1613 | /** |
1614 | Returns @true if item at given index has a valid value; | |
1c4293cb | 1615 | */ |
bb6720bb | 1616 | bool HasValue( unsigned int i ) const; |
1c4293cb | 1617 | |
bb6720bb JS |
1618 | /** |
1619 | Returns index of item with given label. | |
1620 | */ | |
1621 | int Index( const wxString& label ) const; | |
1c4293cb | 1622 | |
bb6720bb JS |
1623 | /** |
1624 | Returns index of item with given value. | |
1625 | */ | |
1c4293cb VZ |
1626 | int Index( int val ) const; |
1627 | ||
bb6720bb JS |
1628 | /** |
1629 | Inserts single item. | |
1630 | */ | |
1c4293cb VZ |
1631 | wxPGChoiceEntry& Insert( const wxString& label, int index, int value = wxPG_INVALID_VALUE ); |
1632 | ||
bb6720bb JS |
1633 | /** |
1634 | Inserts a single item with full entry information. | |
1635 | */ | |
1c4293cb VZ |
1636 | wxPGChoiceEntry& Insert( const wxPGChoiceEntry& entry, int index ); |
1637 | ||
bb6720bb | 1638 | /** |
0ad10f30 | 1639 | Returns @false if this is a constant empty set of choices, |
1c4293cb VZ |
1640 | which should not be modified. |
1641 | */ | |
0ad10f30 | 1642 | bool IsOk() const; |
1c4293cb | 1643 | |
bb6720bb JS |
1644 | /** |
1645 | Returns item at given index. | |
1646 | */ | |
0ad10f30 | 1647 | const wxPGChoiceEntry& Item( unsigned int i ) const; |
1c4293cb | 1648 | |
bb6720bb JS |
1649 | /** |
1650 | Returns item at given index. | |
1651 | */ | |
0ad10f30 | 1652 | wxPGChoiceEntry& Item( unsigned int i ); |
1c4293cb | 1653 | |
bb6720bb JS |
1654 | /** |
1655 | Removes count items starting at position nIndex. | |
1656 | */ | |
1c4293cb VZ |
1657 | void RemoveAt(size_t nIndex, size_t count = 1); |
1658 | ||
bb6720bb JS |
1659 | /** |
1660 | Sets contents from lists of strings and values. | |
1c4293cb | 1661 | */ |
bb6720bb | 1662 | void Set( const wxChar** labels, const long* values = NULL ); |
1c4293cb | 1663 | |
bb6720bb JS |
1664 | /** |
1665 | Sets contents from lists of strings and values. | |
1666 | */ | |
1667 | void Set( const wxArrayString& labels, const wxArrayInt& values = wxArrayInt() ); | |
1c4293cb | 1668 | |
bb6720bb JS |
1669 | /** |
1670 | Creates exclusive copy of current choices. | |
1671 | */ | |
2728c3bf | 1672 | void AllocExclusive(); |
1c4293cb | 1673 | |
bb6720bb JS |
1674 | /** |
1675 | Returns array of choice labels. | |
1676 | */ | |
1c4293cb VZ |
1677 | wxArrayString GetLabels() const; |
1678 | ||
0ad10f30 | 1679 | void operator= (const wxPGChoices& a); |
1c4293cb | 1680 | |
0ad10f30 FM |
1681 | wxPGChoiceEntry& operator[](unsigned int i); |
1682 | const wxPGChoiceEntry& operator[](unsigned int i) const; | |
1c4293cb VZ |
1683 | }; |
1684 | ||
1685 | // ----------------------------------------------------------------------- |