]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/propgrid/propgrid.h
Removed some old code that generated warnings on some compilers
[wxWidgets.git] / interface / wx / propgrid / propgrid.h
CommitLineData
1c4293cb
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: propgrid.h
3// Purpose: interface of wxPropertyGrid
4// Author: wxWidgets team
de003797 5// RCS-ID: $Id$
1c4293cb
VZ
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9
6b03a638
JS
10/**
11 @section propgrid_window_styles wxPropertyGrid Window Styles
1c4293cb
VZ
12
13 SetWindowStyleFlag method can be used to modify some of these at run-time.
14 @{
15*/
16enum wxPG_WINDOW_STYLES
17{
18
6b03a638
JS
19/**
20 This will cause Sort() automatically after an item is added.
1c4293cb
VZ
21 When inserting a lot of items in this mode, it may make sense to
22 use Freeze() before operations and Thaw() afterwards to increase
23 performance.
24*/
25wxPG_AUTO_SORT = 0x00000010,
26
6b03a638
JS
27/**
28 Categories are not initially shown (even if added).
1c4293cb
VZ
29 IMPORTANT NOTE: If you do not plan to use categories, then this
30 style will waste resources.
31 This flag can also be changed using wxPropertyGrid::EnableCategories method.
32*/
33wxPG_HIDE_CATEGORIES = 0x00000020,
34
0ad10f30 35/**
6b03a638 36 This style combines non-categoric mode and automatic sorting.
1c4293cb
VZ
37*/
38wxPG_ALPHABETIC_MODE = (wxPG_HIDE_CATEGORIES|wxPG_AUTO_SORT),
39
6b03a638
JS
40/**
41 Modified values are shown in bold font. Changing this requires Refresh()
1c4293cb
VZ
42 to show changes.
43*/
44wxPG_BOLD_MODIFIED = 0x00000040,
45
6b03a638
JS
46/**
47 When wxPropertyGrid is resized, splitter moves to the center. This
1c4293cb
VZ
48 behavior stops once the user manually moves the splitter.
49*/
50wxPG_SPLITTER_AUTO_CENTER = 0x00000080,
51
6b03a638
JS
52/**
53 Display tool tips for cell text that cannot be shown completely. If
1c4293cb
VZ
54 wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
55*/
56wxPG_TOOLTIPS = 0x00000100,
57
6b03a638
JS
58/**
59 Disables margin and hides all expand/collapse buttons that would appear
1c4293cb
VZ
60 outside the margin (for sub-properties). Toggling this style automatically
61 expands all collapsed items.
62*/
63wxPG_HIDE_MARGIN = 0x00000200,
64
6b03a638
JS
65/**
66 This style prevents user from moving the splitter.
1c4293cb
VZ
67*/
68wxPG_STATIC_SPLITTER = 0x00000400,
69
6b03a638
JS
70/**
71 Combination of other styles that make it impossible for user to modify
1c4293cb
VZ
72 the layout.
73*/
74wxPG_STATIC_LAYOUT = (wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER),
75
6b03a638
JS
76/**
77 Disables wxTextCtrl based editors for properties which
78 can be edited in another way. Equals calling
79 wxPropertyGrid::LimitPropertyEditing() for all added properties.
1c4293cb
VZ
80*/
81wxPG_LIMITED_EDITING = 0x00000800,
82
6b03a638
JS
83/**
84 wxPropertyGridManager only: Show tool bar for mode and page selection.
85*/
1c4293cb
VZ
86wxPG_TOOLBAR = 0x00001000,
87
6b03a638
JS
88/**
89 wxPropertyGridManager only: Show adjustable text box showing description
1c4293cb
VZ
90 or help text, if available, for currently selected property.
91*/
92wxPG_DESCRIPTION = 0x00002000
93
94};
95
96enum wxPG_EX_WINDOW_STYLES
97{
98
99/**
100 NOTE: wxPG_EX_xxx are extra window styles and must be set using SetExtraStyle()
101 member function.
102
6b03a638
JS
103 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
104 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is not
105 activated, and switching the mode first time becomes somewhat slower.
106 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
1c4293cb 107
6b03a638
JS
108 NOTE: If you do plan not switching to non-categoric mode, or if
109 you don't plan to use categories at all, then using this style will result
110 in waste of resources.
1c4293cb
VZ
111*/
112wxPG_EX_INIT_NOCAT = 0x00001000,
113
6b03a638
JS
114/**
115 Extended window style that sets wxPropertyGridManager tool bar to not
1c4293cb
VZ
116 use flat style.
117*/
118wxPG_EX_NO_FLAT_TOOLBAR = 0x00002000,
119
6b03a638
JS
120/**
121 Shows alphabetic/categoric mode buttons from tool bar.
1c4293cb
VZ
122*/
123wxPG_EX_MODE_BUTTONS = 0x00008000,
124
6b03a638
JS
125/**
126 Show property help strings as tool tips instead as text on the status bar.
1c4293cb
VZ
127 You can set the help strings using SetPropertyHelpString member function.
128*/
129wxPG_EX_HELP_AS_TOOLTIPS = 0x00010000,
130
6b03a638
JS
131/**
132 Allows relying on native double-buffering.
1c4293cb
VZ
133*/
134wxPG_EX_NATIVE_DOUBLE_BUFFERING = 0x00080000,
135
6b03a638
JS
136/**
137 Set this style to let user have ability to set values of properties to
1c4293cb
VZ
138 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
139 all properties.
140*/
141wxPG_EX_AUTO_UNSPECIFIED_VALUES = 0x00200000,
142
6b03a638
JS
143/**
144 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION and
145 wxPG_STRING_PASSWORD) are not stored into property's attribute storage (thus
146 they are not readable).
1c4293cb
VZ
147
148 Note that this option is global, and applies to all wxPG property containers.
149*/
150wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES = 0x00400000,
151
6b03a638
JS
152/**
153 Hides page selection buttons from tool bar.
1c4293cb 154*/
fc72fab6
JS
155wxPG_EX_HIDE_PAGE_BUTTONS = 0x01000000,
156
157/** Allows multiple properties to be selected by user (by pressing SHIFT
158 when clicking on a property, or by dragging with left mouse button
159 down).
160
161 You can get array of selected properties with
162 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
163 mode wxPropertyGridInterface::GetSelection() returns
164 property which has editor active (usually the first one
165 selected). Other useful member functions are ClearSelection(),
166 AddToSelection() and RemoveFromSelection().
167*/
08c1613f
JS
168wxPG_EX_MULTIPLE_SELECTION = 0x02000000,
169
170/**
171 This enables top-level window tracking which allows wxPropertyGrid to
172 notify the application of last-minute property value changes by user.
173
174 This style is not enabled by default because it may cause crashes when
175 wxPropertyGrid is used in with wxAUI or similar system.
176
177 @remarks If you are not in fact using any system that may change
178 wxPropertyGrid's top-level parent window on its own, then you
179 are recommended to enable this style.
180*/
181wxPG_EX_ENABLE_TLP_TRACKING = 0x04000000
1c4293cb
VZ
182
183};
184
185/** Combines various styles.
186*/
08c1613f 187#define wxPG_DEFAULT_STYLE (0)
1c4293cb
VZ
188
189/** Combines various styles.
190*/
08c1613f 191#define wxPGMAN_DEFAULT_STYLE (0)
1c4293cb
VZ
192
193/** @}
194*/
195
196// -----------------------------------------------------------------------
197
6b03a638
JS
198/**
199 @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
1c4293cb
VZ
200 @{
201*/
202
203enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
204{
205
6b03a638
JS
206/**
207 Prevents user from leaving property unless value is valid. If this
1c4293cb
VZ
208 behavior flag is not used, then value change is instead cancelled.
209*/
210wxPG_VFB_STAY_IN_PROPERTY = 0x01,
211
6b03a638
JS
212/**
213 Calls wxBell() on validation failure.
1c4293cb
VZ
214*/
215wxPG_VFB_BEEP = 0x02,
216
6b03a638
JS
217/**
218 Cell with invalid value will be marked (with red colour).
1c4293cb
VZ
219*/
220wxPG_VFB_MARK_CELL = 0x04,
221
6b03a638
JS
222/**
223 Display customizable text message explaining the situation.
1c4293cb
VZ
224*/
225wxPG_VFB_SHOW_MESSAGE = 0x08,
226
6b03a638
JS
227/**
228 Defaults.
229*/
1c4293cb 230wxPG_VFB_DEFAULT = wxPG_VFB_STAY_IN_PROPERTY|wxPG_VFB_BEEP,
1c4293cb
VZ
231};
232
233/** @}
234*/
235
236typedef wxByte wxPGVFBFlags;
237
2a8312bc
JS
238/**
239 wxPGValidationInfo
240
241 Used to convey validation information to and from functions that
0ad10f30 242 actually perform validation. Mostly used in custom property classes.
2a8312bc
JS
243*/
244class wxPGValidationInfo
245{
246public:
247 /**
248 @return Returns failure behavior which is a combination of
0ad10f30 249 @ref propgrid_vfbflags.
2a8312bc
JS
250 */
251 wxPGVFBFlags GetFailureBehavior();
252
253 /**
254 Returns current failure message.
255 */
256 const wxString& GetFailureMessage() const;
257
258 /**
259 Returns reference to pending value.
260 */
261 const wxVariant& GetValue() const;
262
263 /** Set validation failure behavior
264
265 @param failureBehavior
266 Mixture of @ref propgrid_vfbflags.
267 */
268 void SetFailureBehavior(wxPGVFBFlags failureBehavior);
269
270 /**
271 Set current failure message.
272 */
273 void SetFailureMessage(const wxString& message);
274};
275
1c4293cb
VZ
276// -----------------------------------------------------------------------
277
6b03a638
JS
278/**
279 @section propgrid_keyboard_actions wxPropertyGrid Action Identifiers
0ad10f30 280
6b03a638
JS
281 These are used with wxPropertyGrid::AddActionTrigger() and
282 wxPropertyGrid::ClearActionTriggers().
1c4293cb
VZ
283 @{
284*/
285
286enum wxPG_KEYBOARD_ACTIONS
287{
288 wxPG_ACTION_INVALID = 0,
289 wxPG_ACTION_NEXT_PROPERTY,
290 wxPG_ACTION_PREV_PROPERTY,
291 wxPG_ACTION_EXPAND_PROPERTY,
292 wxPG_ACTION_COLLAPSE_PROPERTY,
293 wxPG_ACTION_CANCEL_EDIT,
1c4293cb
VZ
294 wxPG_ACTION_MAX
295};
296
297/** @}
298*/
299
43396981
JS
300/** This callback function is used for sorting properties.
301
302 Call wxPropertyGrid::SetSortFunction() to set it.
303
304 Sort function should return a value greater than 0 if position of p1 is
305 after p2. So, for instance, when comparing property names, you can use
306 following implementation:
307
308 @code
309 int MyPropertySortFunction(wxPropertyGrid* propGrid,
310 wxPGProperty* p1,
311 wxPGProperty* p2)
312 {
313 return p1->GetBaseName().compare( p2->GetBaseName() );
314 }
315 @endcode
316*/
317typedef int (*wxPGSortCallback)(wxPropertyGrid* propGrid,
318 wxPGProperty* p1,
319 wxPGProperty* p2);
320
1c4293cb
VZ
321// -----------------------------------------------------------------------
322
0ad10f30
FM
323/**
324 @class wxPropertyGrid
1c4293cb 325
0ad10f30 326 wxPropertyGrid is a specialized grid for editing properties - in other
bba3f9b5 327 words name = value pairs. List of ready-to-use property classes include
6b03a638 328 strings, numbers, flag sets, fonts, colours and many others. It is possible,
bba3f9b5
JS
329 for example, to categorize properties, set up a complete tree-hierarchy,
330 add more than two columns, and set arbitrary per-property attributes.
1c4293cb 331
6b03a638
JS
332 Please note that most member functions are inherited and as such not
333 documented on this page. This means you will probably also want to read
334 wxPropertyGridInterface class reference.
1c4293cb
VZ
335
336 See also @ref overview_propgrid.
337
338 @section propgrid_window_styles_ Window Styles
339
340 See @ref propgrid_window_styles.
341
342 @section propgrid_event_handling Event Handling
343
6b03a638
JS
344 To process input from a property grid control, use these event handler macros
345 to direct input to member functions that take a wxPropertyGridEvent argument.
1c4293cb 346
3051a44a 347 @beginEventEmissionTable{wxPropertyGridEvent}
1c4293cb 348 @event{EVT_PG_SELECTED (id, func)}
01b5ad3b
JS
349 Respond to wxEVT_PG_SELECTED event, generated when a property selection
350 has been changed, either by user action or by indirect program
351 function. For instance, collapsing a parent property programmatically
352 causes any selected child property to become unselected, and may
353 therefore cause this event to be generated.
1c4293cb
VZ
354 @event{EVT_PG_CHANGING(id, func)}
355 Respond to wxEVT_PG_CHANGING event, generated when property value
356 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
357 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
358 to prevent change from taking place, if necessary.
359 @event{EVT_PG_HIGHLIGHTED(id, func)}
360 Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
361 moves over a property. Event's property is NULL if hovered area does
362 not belong to any property.
363 @event{EVT_PG_RIGHT_CLICK(id, func)}
364 Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
365 clicked on with right mouse button.
366 @event{EVT_PG_DOUBLE_CLICK(id, func)}
367 Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
6b03a638 368 double-clicked on with left mouse button.
1c4293cb
VZ
369 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
370 Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
6b03a638 371 a property or category.
1c4293cb
VZ
372 @event{EVT_PG_ITEM_EXPANDED(id, func)}
373 Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
6b03a638 374 a property or category.
58935d4a
JS
375 @event{EVT_PG_LABEL_EDIT_BEGIN(id, func)}
376 Respond to wxEVT_PG_LABEL_EDIT_BEGIN event, generated when is about to
377 begin editing a property label. You can veto this event to prevent the
378 action.
379 @event{EVT_PG_LABEL_EDIT_ENDING(id, func)}
380 Respond to wxEVT_PG_LABEL_EDIT_ENDING event, generated when is about to
381 end editing of a property label. You can veto this event to prevent the
382 action.
1c4293cb
VZ
383 @endEventTable
384
385 @remarks
0ad10f30
FM
386 Use Freeze() and Thaw() respectively to disable and enable drawing.
387 This will also delay sorting etc. miscellaneous calculations to the last
388 possible moment.
1c4293cb
VZ
389
390 @library{wxpropgrid}
391 @category{propgrid}
e4821c39 392 @appearance{propertygrid.png}
1c4293cb
VZ
393*/
394class wxPropertyGrid : public wxScrolledWindow, public wxPropertyGridInterface
395{
396public:
0ad10f30
FM
397 /**
398 Two step constructor.
399 Call Create() when this constructor is called to build up the wxPropertyGrid
400 */
1c4293cb
VZ
401 wxPropertyGrid();
402
6b03a638 403 /**
0ad10f30
FM
404 Constructor.
405 The styles to be used are styles valid for the wxWindow and wxScrolledWindow.
6b03a638
JS
406
407 @see @ref propgrid_window_styles.
1c4293cb
VZ
408 */
409 wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
0ad10f30
FM
410 const wxPoint& pos = wxDefaultPosition,
411 const wxSize& size = wxDefaultSize,
412 long style = wxPG_DEFAULT_STYLE,
413 const wxChar* name = wxPropertyGridNameStr );
1c4293cb
VZ
414
415 /** Destructor */
416 virtual ~wxPropertyGrid();
417
6b03a638
JS
418 /**
419 Adds given key combination to trigger given action.
420
1c4293cb 421 @param action
6b03a638 422 Which action to trigger. See @ref propgrid_keyboard_actions.
6b03a638
JS
423 @param keycode
424 Which keycode triggers the action.
6b03a638
JS
425 @param modifiers
426 Which key event modifiers, in addition to keycode, are needed to
427 trigger the action.
1c4293cb
VZ
428 */
429 void AddActionTrigger( int action, int keycode, int modifiers = 0 );
430
fc72fab6
JS
431 /**
432 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
433 extra style is not used, then this has same effect as
434 calling SelectProperty().
435
436 @remarks Multiple selection is not supported for categories. This
437 means that if you have properties selected, you cannot
438 add category to selection, and also if you have category
439 selected, you cannot add other properties to selection.
440 This member function will fail silently in these cases,
441 even returning true.
442 */
443 bool AddToSelection( wxPGPropArg id );
444
6b03a638
JS
445 /**
446 This static function enables or disables automatic use of
447 wxGetTranslation() for following strings: wxEnumProperty list labels,
448 wxFlagsProperty child property labels.
449
1c4293cb
VZ
450 Default is false.
451 */
452 static void AutoGetTranslation( bool enable );
453
58935d4a
JS
454 /**
455 Creates label editor wxTextCtrl for given column, for property
456 that is currently selected. When multiple selection is
457 enabled, this applies to whatever property GetSelection()
458 returns.
459
460 @param colIndex
461 Which column's label to edit. Note that you should not
462 use value 1, which is reserved for property value
463 column.
464
465 @see EndLabelEdit(), MakeColumnEditable()
466 */
467 void BeginLabelEdit( unsigned int column = 0 );
468
6b03a638
JS
469 /**
470 Changes value of a property, as if from an editor. Use this instead of
471 SetPropertyValue() if you need the value to run through validation
472 process, and also send the property change event.
1c4293cb 473
6b03a638 474 @return Returns true if value was successfully changed.
1c4293cb
VZ
475 */
476 bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
477
6b03a638
JS
478 /**
479 Centers the splitter. If argument is true, automatic splitter centering
480 is enabled (only applicable if style wxPG_SPLITTER_AUTO_CENTER was
481 defined).
1c4293cb
VZ
482 */
483 void CenterSplitter( bool enable_auto_centering = false );
484
6b03a638
JS
485 /**
486 Deletes all properties.
1c4293cb
VZ
487 */
488 virtual void Clear();
489
6b03a638
JS
490 /**
491 Clears action triggers for given action.
492
1c4293cb 493 @param action
6b03a638 494 Which action to trigger. @ref propgrid_keyboard_actions.
1c4293cb
VZ
495 */
496 void ClearActionTriggers( int action );
497
6b03a638
JS
498 /**
499 Forces updating the value of property from the editor control.
500 Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
501 ProcessEvent, meaning your event handlers will be called immediately.
1c4293cb 502
6b03a638 503 @return Returns @true if anything was changed.
1c4293cb
VZ
504 */
505 virtual bool CommitChangesFromEditor( wxUint32 flags = 0 );
506
6b03a638
JS
507 /**
508 Two step creation. Whenever the control is created without any
509 parameters, use Create to actually create it. Don't access the control's
510 public methods before this is called
511
512 @see @ref propgrid_window_styles.
1c4293cb
VZ
513 */
514 bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
0ad10f30
FM
515 const wxPoint& pos = wxDefaultPosition,
516 const wxSize& size = wxDefaultSize,
517 long style = wxPG_DEFAULT_STYLE,
518 const wxChar* name = wxPropertyGridNameStr );
1c4293cb 519
6b03a638
JS
520 /**
521 Enables or disables (shows/hides) categories according to parameter
522 enable.
1621f192
JS
523
524 @remarks This functions deselects selected property, if any. Validation
525 failure option wxPG_VFB_STAY_IN_PROPERTY is not respected, ie.
526 selection is cleared even if editor had invalid value.
6b03a638 527 */
1c4293cb
VZ
528 bool EnableCategories( bool enable );
529
58935d4a
JS
530 /**
531 Destroys label editor wxTextCtrl, if any.
532
533 @param commit
534 Use @true (default) to store edited label text in
535 property cell data.
536
537 @see BeginLabelEdit(), MakeColumnEditable()
538 */
539 void EndLabelEdit( bool commit = true );
540
6b03a638
JS
541 /**
542 Scrolls and/or expands items to ensure that the given item is visible.
543
544 @return Returns @true if something was actually done.
1c4293cb
VZ
545 */
546 bool EnsureVisible( wxPGPropArg id );
547
6b03a638
JS
548 /**
549 Reduces column sizes to minimum possible, while still retaining
550 fully visible grid contents (labels, images).
1c4293cb 551
6b03a638 552 @return Minimum size for the grid to still display everything.
1c4293cb 553
6b03a638 554 @remarks Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
1c4293cb 555
6b03a638
JS
556 This function only works properly if grid size prior to call was
557 already fairly large.
1c4293cb 558
6b03a638
JS
559 Note that you can also get calculated column widths by calling
560 GetState->GetColumnWidth() immediately after this function
561 returns.
1c4293cb 562 */
6b03a638 563 wxSize FitColumns();
1c4293cb 564
58935d4a
JS
565 /**
566 Returns currently active label editor, NULL if none.
567 */
568 wxTextCtrl* GetLabelEditor() const;
569
6b03a638
JS
570 /**
571 Returns wxWindow that the properties are painted on, and which should be
572 used as the parent for editor controls.
1c4293cb 573 */
6b03a638 574 wxPanel* GetPanel() const;
1c4293cb 575
6b03a638
JS
576 /**
577 Returns current category caption background colour.
578 */
579 wxColour GetCaptionBackgroundColour() const;
1c4293cb 580
6b03a638
JS
581 /**
582 Returns current category caption font.
583 */
584 wxFont& GetCaptionFont();
1c4293cb 585
6b03a638
JS
586 /**
587 Returns current category caption text colour.
588 */
589 wxColour GetCaptionForegroundColour() const;
1c4293cb 590
6b03a638
JS
591 /**
592 Returns current cell background colour.
593 */
594 wxColour GetCellBackgroundColour() const;
1c4293cb 595
6b03a638
JS
596 /**
597 Returns current cell text colour when disabled.
598 */
599 wxColour GetCellDisabledTextColour() const;
1c4293cb 600
6b03a638
JS
601 /**
602 Returns current cell text colour.
603 */
604 wxColour GetCellTextColour() const;
1c4293cb 605
6b03a638
JS
606 /**
607 Returns number of columns currently on grid.
608 */
68bcfd2c 609 unsigned int GetColumnCount() const;
1c4293cb 610
6b03a638
JS
611 /**
612 Returns colour of empty space below properties.
613 */
614 wxColour GetEmptySpaceColour() const;
1c4293cb 615
6b03a638
JS
616 /**
617 Returns height of highest characters of used font.
618 */
619 int GetFontHeight() const;
1c4293cb 620
6b03a638
JS
621 /**
622 Returns pointer to itself. Dummy function that enables same kind
1c4293cb
VZ
623 of code to use wxPropertyGrid and wxPropertyGridManager.
624 */
6b03a638
JS
625 wxPropertyGrid* GetGrid();
626
627 /**
628 Returns rectangle of custom paint image.
1c4293cb 629
6b03a638
JS
630 @param property
631 Return image rectangle for this property.
632
633 @param item
634 Which choice of property to use (each choice may have
635 different image).
1c4293cb 636 */
6b03a638
JS
637 wxRect GetImageRect( wxPGProperty* property, int item ) const;
638
639 /**
640 Returns size of the custom paint image in front of property.
1c4293cb 641
6b03a638
JS
642 @param property
643 Return image rectangle for this property.
644 If this argument is NULL, then preferred size is returned.
645
646 @param item
647 Which choice of property to use (each choice may have
648 different image).
1c4293cb 649 */
6b03a638
JS
650 wxSize GetImageSize( wxPGProperty* property = NULL, int item = -1 ) const;
651
652 /**
653 Returns last item which could be iterated using given flags.
1c4293cb 654
1c4293cb 655 @param flags
6b03a638 656 See @ref propgrid_iterator_flags.
1c4293cb 657 */
6b03a638 658 wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT );
1c4293cb 659
6b03a638
JS
660 /**
661 Returns colour of lines between cells.
662 */
663 wxColour GetLineColour() const;
1c4293cb 664
6b03a638
JS
665 /**
666 Returns background colour of margin.
667 */
668 wxColour GetMarginColour() const;
1c4293cb 669
6b03a638
JS
670 /**
671 Returns "root property". It does not have name, etc. and it is not
1c4293cb
VZ
672 visible. It is only useful for accessing its children.
673 */
6b03a638 674 wxPGProperty* GetRoot() const;
1c4293cb 675
6b03a638
JS
676 /**
677 Returns height of a single grid row (in pixels).
678 */
679 int GetRowHeight() const;
1c4293cb 680
6b03a638
JS
681 /**
682 Returns currently selected property.
683 */
684 wxPGProperty* GetSelectedProperty() const;
1c4293cb 685
6b03a638
JS
686 /**
687 Returns currently selected property.
688 */
689 wxPGProperty* GetSelection() const;
1c4293cb 690
6b03a638
JS
691 /**
692 Returns current selection background colour.
693 */
694 wxColour GetSelectionBackgroundColour() const;
1c4293cb 695
6b03a638
JS
696 /**
697 Returns current selection text colour.
698 */
699 wxColour GetSelectionForegroundColour() const;
1c4293cb 700
43396981
JS
701 /**
702 Returns the property sort function (default is @NULL).
703
704 @see SetSortFunction
705 */
706 wxPGSortCallback GetSortFunction() const;
707
6b03a638
JS
708 /**
709 Returns current splitter x position.
710 */
711 int GetSplitterPosition() const;
1c4293cb 712
6b03a638
JS
713 /**
714 Returns wxTextCtrl active in currently selected property, if any. Takes
715 wxOwnerDrawnComboBox into account.
1c4293cb
VZ
716 */
717 wxTextCtrl* GetEditorTextCtrl() const;
718
6b03a638
JS
719 /**
720 Returns current vertical spacing.
721 */
0ad10f30 722 int GetVerticalSpacing() const;
1c4293cb 723
6b03a638
JS
724 /**
725 Returns information about arbitrary position in the grid.
e276acb5
JS
726
727 @param pt
58b6a137
JS
728 Coordinates in the virtual grid space. You may need to use
729 wxScrolledWindow::CalcScrolledPosition() for translating
730 wxPropertyGrid client coordinates into something this member
731 function can use.
1c4293cb
VZ
732 */
733 wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
734
6b03a638
JS
735 /**
736 Returns true if any property has been modified by the user.
737 */
738 bool IsAnyModified() const;
1c4293cb 739
45843442
JS
740 /**
741 Returns @true if a property editor control has focus.
742 */
743 bool IsEditorFocused() const;
744
6b03a638
JS
745 /**
746 Returns true if updating is frozen (ie. Freeze() called but not
747 yet Thaw() ).
748 */
749 bool IsFrozen() const;
1c4293cb 750
58935d4a
JS
751 /**
752 Makes given column editable by user.
753
754 @see BeginLabelEdit(), EndLabelEdit()
755 */
756 void MakeColumnEditable( unsigned int column );
757
27c1f235 758 /**
6edd8829
JS
759 It is recommended that you call this function any time your code causes
760 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
761 handler should be able to detect most changes, but it is not perfect.
27c1f235
JS
762
763 @param newTLP
764 New top-level parent that is about to be set. Old top-level parent
765 window should still exist as the current one.
766
767 @remarks This function is automatically called from wxPropertyGrid::
768 Reparent() and wxPropertyGridManager::Reparent(). You only
769 need to use it if you reparent wxPropertyGrid indirectly.
770 */
771 void OnTLPChanging( wxWindow* newTLP );
772
f521bae6
JS
773 /**
774 Refreshes any active editor control.
775 */
776 void RefreshEditor();
777
6b03a638
JS
778 /**
779 Redraws given property.
1c4293cb
VZ
780 */
781 virtual void RefreshProperty( wxPGProperty* p );
782
6b03a638
JS
783 /**
784 Registers a new editor class.
785
786 @return Returns pointer to the editor class instance that should be used.
1c4293cb 787 */
6b03a638
JS
788 static wxPGEditor* RegisterEditorClass( wxPGEditor* editor,
789 const wxString& name,
1c4293cb
VZ
790 bool noDefCheck = false );
791
6b03a638
JS
792 /**
793 Resets all colours to the original system values.
1c4293cb
VZ
794 */
795 void ResetColours();
796
fc72fab6
JS
797 /**
798 Removes given property from selection. If property is not selected,
799 an assertion failure will occur.
800 */
801 bool RemoveFromSelection( wxPGPropArg id );
802
6b03a638
JS
803 /**
804 Selects a property. Editor widget is automatically created, but
01b5ad3b 805 not focused unless focus is true.
6b03a638 806
1c4293cb 807 @param id
6b03a638
JS
808 Property to select (name or pointer).
809
810 @param focus
811 If @true, move keyboard focus to the created editor right away.
812
813 @return returns @true if selection finished successfully. Usually only
814 fails if current value in editor is not valid.
815
01b5ad3b
JS
816 @remarks In wxPropertyGrid 1.4, this member function used to generate
817 wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
818 does that.
819
fc72fab6
JS
820 @remarks This clears any previous selection.
821
01b5ad3b 822 @see wxPropertyGridInterface::ClearSelection()
1c4293cb 823 */
6b03a638
JS
824 bool SelectProperty( wxPGPropArg id, bool focus = false );
825
826 /**
827 Changes keyboard shortcut to push the editor button.
1c4293cb 828
6b03a638
JS
829 @remarks You can set default with keycode 0. Good value for the platform
830 is guessed, but don't expect it to be very accurate.
1c4293cb
VZ
831 */
832 void SetButtonShortcut( int keycode, bool ctrlDown = false, bool altDown = false );
833
6b03a638
JS
834 /**
835 Sets category caption background colour.
836 */
1c4293cb
VZ
837 void SetCaptionBackgroundColour(const wxColour& col);
838
6b03a638
JS
839 /**
840 Sets category caption text colour.
841 */
1c4293cb
VZ
842 void SetCaptionTextColour(const wxColour& col);
843
6b03a638
JS
844 /**
845 Sets default cell background colour - applies to property cells.
1c4293cb
VZ
846 Note that appearance of editor widgets may not be affected.
847 */
848 void SetCellBackgroundColour(const wxColour& col);
849
6b03a638
JS
850 /**
851 Sets cell text colour for disabled properties.
1c4293cb
VZ
852 */
853 void SetCellDisabledTextColour(const wxColour& col);
854
6b03a638
JS
855 /**
856 Sets default cell text colour - applies to property name and value text.
1c4293cb
VZ
857 Note that appearance of editor widgets may not be affected.
858 */
859 void SetCellTextColour(const wxColour& col);
860
6b03a638
JS
861 /**
862 Set number of columns (2 or more).
1c4293cb 863 */
6b03a638 864 void SetColumnCount( int colCount );
1c4293cb 865
6b03a638
JS
866 /**
867 Sets the 'current' category - Append will add non-category properties
868 under it.
1c4293cb
VZ
869 */
870 void SetCurrentCategory( wxPGPropArg id );
871
6b03a638
JS
872 /**
873 Sets colour of empty space below properties.
874 */
1c4293cb
VZ
875 void SetEmptySpaceColour(const wxColour& col);
876
6b03a638
JS
877 /**
878 Sets colour of lines between cells.
879 */
1c4293cb
VZ
880 void SetLineColour(const wxColour& col);
881
6b03a638
JS
882 /**
883 Sets background colour of margin.
884 */
1c4293cb
VZ
885 void SetMarginColour(const wxColour& col);
886
fc72fab6
JS
887 /**
888 Set entire new selection from given list of properties.
889 */
890 void SetSelection( const wxArrayPGProperty& newSelection );
891
0ad10f30
FM
892 /**
893 Sets selection background colour - applies to selected property name
894 background.
895 */
1c4293cb
VZ
896 void SetSelectionBackgroundColour(const wxColour& col);
897
0ad10f30
FM
898 /**
899 Sets selection foreground colour - applies to selected property name text.
900 */
1c4293cb
VZ
901 void SetSelectionTextColour(const wxColour& col);
902
43396981
JS
903
904 /**
905 Sets the property sorting function.
906
907 @param sortFunction
908 The sorting function to be used. It should return a value greater
909 than 0 if position of p1 is after p2. So, for instance, when
910 comparing property names, you can use following implementation:
911
912 @code
913 int MyPropertySortFunction(wxPropertyGrid* propGrid,
914 wxPGProperty* p1,
915 wxPGProperty* p2)
916 {
917 return p1->GetBaseName().compare( p2->GetBaseName() );
918 }
919 @endcode
920
921 @remarks
922 Default property sort function sorts properties by their labels
923 (case-insensitively).
924
925 @see GetSortFunction, wxPropertyGridInterface::Sort,
926 wxPropertyGridInterface::SortChildren
927 */
928 void SetSortFunction( wxPGSortCallback sortFunction );
929
0ad10f30
FM
930 /**
931 Sets x coordinate of the splitter.
6b03a638
JS
932
933 @remarks Splitter position cannot exceed grid size, and therefore setting
934 it during form creation may fail as initial grid size is often
935 smaller than desired splitter position, especially when sizers
936 are being used.
1c4293cb 937 */
6b03a638 938 void SetSplitterPosition( int newxpos, int col = 0 );
1c4293cb 939
6b03a638
JS
940 /**
941 Moves splitter as left as possible, while still allowing all
1c4293cb 942 labels to be shown in full.
6b03a638
JS
943
944 @param privateChildrenToo
945 If @false, will still allow private children to be cropped.
1c4293cb 946 */
0ad10f30 947 void SetSplitterLeft( bool privateChildrenToo = false );
1c4293cb 948
6b03a638
JS
949 /**
950 Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1c4293cb 951 height. Value of 2 should be default on most platforms.
1c4293cb 952 */
6b03a638 953 void SetVerticalSpacing( int vspacing );
1c4293cb 954
7dfede7b
JS
955
956 /**
957 @name Property development functions
958
959 These member functions are usually only called when creating custom
960 user properties.
961 */
962 //@{
963
964 /**
965 Call when editor widget's contents is modified. For example, this is
966 called when changes text in wxTextCtrl (used in wxStringProperty and
967 wxIntProperty).
968
969 @remarks This function should only be called by custom properties.
970
971 @see wxPGProperty::OnEvent()
972 */
973 void EditorsValueWasModified();
974
975 /**
976 Reverse of EditorsValueWasModified().
977
978 @remarks This function should only be called by custom properties.
979 */
980 void EditorsValueWasNotModified();
981
982 /**
983 Returns most up-to-date value of selected property. This will return
984 value different from GetSelectedProperty()->GetValue() only when text
985 editor is activate and string edited by user represents valid,
986 uncommitted property value.
987 */
988 wxVariant GetUncommittedPropertyValue();
989
990 /**
991 Returns true if editor's value was marked modified.
992 */
993 bool IsEditorsValueModified() const;
994
6b03a638
JS
995 /**
996 Shows an brief error message that is related to a property.
997 */
998 void ShowPropertyError( wxPGPropArg id, const wxString& msg );
eddcc4b4
JS
999
1000 /**
1001 You can use this member function, for instance, to detect in
1002 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1003 already called in wxPGEditor::OnEvent(). It really only detects
1004 if was value was changed using wxPGProperty::SetValueInEvent(), which
1005 is usually used when a 'picker' dialog is displayed. If value was
1006 written by "normal means" in wxPGProperty::StringToValue() or
1007 IntToValue(), then this function will return false (on the other hand,
1008 wxPGProperty::OnEvent() is not even called in those cases).
1009 */
1010 bool WasValueChangedInEvent() const;
7dfede7b
JS
1011
1012 //@}
1c4293cb
VZ
1013};
1014
1015
6b03a638
JS
1016/**
1017 @class wxPropertyGridEvent
1c4293cb 1018
6b03a638 1019 A property grid event holds information about events associated with
1c4293cb
VZ
1020 wxPropertyGrid objects.
1021
1022 @library{wxpropgrid}
1023 @category{propgrid}
1024*/
1025class wxPropertyGridEvent : public wxCommandEvent
1026{
1027public:
1028
1029 /** Constructor. */
1030 wxPropertyGridEvent(wxEventType commandType=0, int id=0);
1031
1032 /** Copy constructor. */
1033 wxPropertyGridEvent(const wxPropertyGridEvent& event);
1034
1035 /** Destructor. */
1036 ~wxPropertyGridEvent();
1037
6b03a638
JS
1038 /**
1039 Returns true if you can veto the action that the event is signaling.
1040 */
0ad10f30 1041 bool CanVeto() const;
6b03a638 1042
6b03a638
JS
1043 /**
1044 Returns highest level non-category, non-root parent of property for
1045 which event occurred. Useful when you have nested properties with
1046 children.
1c4293cb 1047
6b03a638
JS
1048 @remarks If immediate parent is root or category, this will return the
1049 property itself.
1050 */
1051 wxPGProperty* GetMainParent() const;
1c4293cb 1052
6b03a638
JS
1053 /**
1054 Returns property associated with this event.
1055 */
1056 wxPGProperty* GetProperty() const;
1c4293cb 1057
6b03a638
JS
1058 /**
1059 Returns current validation failure flags.
1c4293cb 1060 */
6b03a638 1061 wxPGVFBFlags GetValidationFailureBehavior() const;
1c4293cb 1062
6b03a638
JS
1063 /**
1064 Returns value that is about to be set for wxEVT_PG_CHANGING.
1c4293cb 1065 */
6b03a638 1066 const wxVariant& GetValue() const;
1c4293cb 1067
6b03a638
JS
1068 /**
1069 Set if event can be vetoed.
1c4293cb 1070 */
6b03a638 1071 void SetCanVeto( bool canVeto );
0ad10f30 1072
6b03a638
JS
1073 /** Changes the property associated with this event. */
1074 void SetProperty( wxPGProperty* p );
1c4293cb 1075
6b03a638
JS
1076 /**
1077 Set override validation failure behavior. Only effective if Veto() was
1078 also called, and only allowed if event type is wxEVT_PG_CHANGING.
1c4293cb 1079 */
2a8312bc 1080 void SetValidationFailureBehavior( wxPGVFBFlags flags );
1c4293cb 1081
6b03a638
JS
1082 /**
1083 Sets custom failure message for this time only. Only applies if
1c4293cb
VZ
1084 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
1085 */
6b03a638 1086 void SetValidationFailureMessage( const wxString& message );
1c4293cb 1087
6b03a638
JS
1088 /**
1089 Call this from your event handler to veto action that the event is
1090 signaling. You can only veto a shutdown if wxPropertyGridEvent::CanVeto()
1091 returns true.
1c4293cb 1092
6b03a638
JS
1093 @remarks Currently only wxEVT_PG_CHANGING supports vetoing.
1094 */
1095 void Veto( bool veto = true );
1c4293cb 1096
6b03a638
JS
1097 /**
1098 Returns @true if event was vetoed.
1099 */
1100 bool WasVetoed() const;
1c4293cb 1101};