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