]> git.saurik.com Git - wxWidgets.git/blame - include/wx/propgrid/propgrid.h
Fix signatures of various image handlers methods.
[wxWidgets.git] / include / wx / propgrid / propgrid.h
CommitLineData
1c4293cb
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/propgrid/propgrid.h
3// Purpose: wxPropertyGrid
4// Author: Jaakko Salli
5// Modified by:
6// Created: 2004-09-25
ea5af9c5 7// RCS-ID: $Id$
1c4293cb
VZ
8// Copyright: (c) Jaakko Salli
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_PROPGRID_PROPGRID_H_
13#define _WX_PROPGRID_PROPGRID_H_
14
f4bc1aa2
JS
15#if wxUSE_PROPGRID
16
1c4293cb
VZ
17#include "wx/dcclient.h"
18#include "wx/scrolwin.h"
19#include "wx/tooltip.h"
20#include "wx/datetime.h"
21
22#include "wx/propgrid/property.h"
23#include "wx/propgrid/propgridiface.h"
24
25
26#ifndef SWIG
23318a53 27extern WXDLLIMPEXP_DATA_PROPGRID(const char) wxPropertyGridNameStr[];
1c4293cb
VZ
28#endif
29
e9cc4973 30class wxPGComboBox;
1c4293cb
VZ
31
32// -----------------------------------------------------------------------
33// Global variables
34// -----------------------------------------------------------------------
35
36#ifndef SWIG
37
38// This is required for sharing common global variables.
39class WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass
40{
41public:
42
43 wxPGGlobalVarsClass();
44 ~wxPGGlobalVarsClass();
45
46 // Used by advprops, but here to make things easier.
47 wxString m_pDefaultImageWildcard;
48
49 // Map of editor class instances (keys are name string).
50 wxPGHashMapS2P m_mapEditorClasses;
51
52#if wxUSE_VALIDATORS
f7a094e1 53 wxVector<wxValidator*> m_arrValidators; // These wxValidators need to be freed
1c4293cb
VZ
54#endif
55
56 wxPGHashMapS2P m_dictPropertyClassInfo; // PropertyName -> ClassInfo
57
58 wxPGChoices* m_fontFamilyChoices;
59
60 // Replace with your own to affect all properties using default renderer.
61 wxPGCellRenderer* m_defaultRenderer;
62
1c4293cb
VZ
63 wxPGChoices m_boolChoices;
64
65 wxVariant m_vEmptyString;
66 wxVariant m_vZero;
67 wxVariant m_vMinusOne;
68 wxVariant m_vTrue;
69 wxVariant m_vFalse;
70
71 // Cached constant strings
0372d42e
JS
72 wxPGCachedString m_strstring;
73 wxPGCachedString m_strlong;
74 wxPGCachedString m_strbool;
75 wxPGCachedString m_strlist;
76
0ce8e27f 77 wxPGCachedString m_strDefaultValue;
1c4293cb
VZ
78 wxPGCachedString m_strMin;
79 wxPGCachedString m_strMax;
80 wxPGCachedString m_strUnits;
81 wxPGCachedString m_strInlineHelp;
82
83 // If true then some things are automatically translated
84 bool m_autoGetTranslation;
85
86 // > 0 if errors cannot or should not be shown in statusbar etc.
87 int m_offline;
88
89 int m_extraStyle; // global extra style
90
1c4293cb 91 int m_warnings;
1c4293cb
VZ
92
93 int HasExtraStyle( int style ) const { return (m_extraStyle & style); }
94};
95
96extern WXDLLIMPEXP_PROPGRID wxPGGlobalVarsClass* wxPGGlobalVars;
97
1c4293cb
VZ
98#define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
99#define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)
100#define wxPGVariant_MinusOne (wxPGGlobalVars->m_vMinusOne)
101#define wxPGVariant_True (wxPGGlobalVars->m_vTrue)
102#define wxPGVariant_False (wxPGGlobalVars->m_vFalse)
103
104#define wxPGVariant_Bool(A) (A?wxPGVariant_True:wxPGVariant_False)
105
b512ed93
JS
106// When wxPG is loaded dynamically after the application is already running
107// then the built-in module system won't pick this one up. Add it manually.
108WXDLLIMPEXP_PROPGRID void wxPGInitResourceModule();
109
1c4293cb
VZ
110#endif // !SWIG
111
112// -----------------------------------------------------------------------
113
114/** @section propgrid_window_styles wxPropertyGrid Window Styles
115
116 SetWindowStyleFlag method can be used to modify some of these at run-time.
117 @{
118*/
119enum wxPG_WINDOW_STYLES
120{
121
122/** This will cause Sort() automatically after an item is added.
123 When inserting a lot of items in this mode, it may make sense to
124 use Freeze() before operations and Thaw() afterwards to increase
125 performance.
126*/
127wxPG_AUTO_SORT = 0x00000010,
128
129/** Categories are not initially shown (even if added).
130 IMPORTANT NOTE: If you do not plan to use categories, then this
131 style will waste resources.
132 This flag can also be changed using wxPropertyGrid::EnableCategories method.
133*/
134wxPG_HIDE_CATEGORIES = 0x00000020,
135
136/* This style combines non-categoric mode and automatic sorting.
137*/
138wxPG_ALPHABETIC_MODE = (wxPG_HIDE_CATEGORIES|wxPG_AUTO_SORT),
139
140/** Modified values are shown in bold font. Changing this requires Refresh()
141 to show changes.
142*/
143wxPG_BOLD_MODIFIED = 0x00000040,
144
145/** When wxPropertyGrid is resized, splitter moves to the center. This
146 behavior stops once the user manually moves the splitter.
147*/
148wxPG_SPLITTER_AUTO_CENTER = 0x00000080,
149
150/** Display tooltips for cell text that cannot be shown completely. If
151 wxUSE_TOOLTIPS is 0, then this doesn't have any effect.
152*/
153wxPG_TOOLTIPS = 0x00000100,
154
155/** Disables margin and hides all expand/collapse buttons that would appear
156 outside the margin (for sub-properties). Toggling this style automatically
157 expands all collapsed items.
158*/
159wxPG_HIDE_MARGIN = 0x00000200,
160
161/** This style prevents user from moving the splitter.
162*/
163wxPG_STATIC_SPLITTER = 0x00000400,
164
165/** Combination of other styles that make it impossible for user to modify
166 the layout.
167*/
168wxPG_STATIC_LAYOUT = (wxPG_HIDE_MARGIN|wxPG_STATIC_SPLITTER),
169
170/** Disables wxTextCtrl based editors for properties which
171 can be edited in another way.
172
173 Equals calling wxPropertyGrid::LimitPropertyEditing for all added
174 properties.
175*/
176wxPG_LIMITED_EDITING = 0x00000800,
177
178/** wxPropertyGridManager only: Show toolbar for mode and page selection. */
179wxPG_TOOLBAR = 0x00001000,
180
181/** wxPropertyGridManager only: Show adjustable text box showing description
182 or help text, if available, for currently selected property.
183*/
184wxPG_DESCRIPTION = 0x00002000
185
186};
187
188enum wxPG_EX_WINDOW_STYLES
189{
190
191/**
192 NOTE: wxPG_EX_xxx are extra window styles and must be set using
193 SetExtraStyle() member function.
194
195 Speeds up switching to wxPG_HIDE_CATEGORIES mode. Initially, if
196 wxPG_HIDE_CATEGORIES is not defined, the non-categorized data storage is
197 not activated, and switching the mode first time becomes somewhat slower.
198 wxPG_EX_INIT_NOCAT activates the non-categorized data storage right away.
199 IMPORTANT NOTE: If you do plan not switching to non-categoric mode, or if
200 you don't plan to use categories at all, then using this style will result
201 in waste of resources.
202
203*/
204wxPG_EX_INIT_NOCAT = 0x00001000,
205
206/** Extended window style that sets wxPropertyGridManager toolbar to not
207 use flat style.
208*/
209wxPG_EX_NO_FLAT_TOOLBAR = 0x00002000,
210
211/** Shows alphabetic/categoric mode buttons from toolbar.
212*/
213wxPG_EX_MODE_BUTTONS = 0x00008000,
214
215/** Show property help strings as tool tips instead as text on the status bar.
216 You can set the help strings using SetPropertyHelpString member function.
217*/
218wxPG_EX_HELP_AS_TOOLTIPS = 0x00010000,
219
220/** Prevent TAB from focusing to wxButtons. This behavior was default
221 in version 1.2.0 and earlier.
222 NOTE! Tabbing to button doesn't work yet. Problem seems to be that on wxMSW
223 atleast the button doesn't properly propagate key events (yes, I'm using
224 wxWANTS_CHARS).
225*/
226//wxPG_EX_NO_TAB_TO_BUTTON = 0x00020000,
227
228/** Allows relying on native double-buffering.
229*/
230wxPG_EX_NATIVE_DOUBLE_BUFFERING = 0x00080000,
231
232/** Set this style to let user have ability to set values of properties to
233 unspecified state. Same as setting wxPG_PROP_AUTO_UNSPECIFIED for
234 all properties.
235*/
236wxPG_EX_AUTO_UNSPECIFIED_VALUES = 0x00200000,
237
238/**
239 If this style is used, built-in attributes (such as wxPG_FLOAT_PRECISION
240 and wxPG_STRING_PASSWORD) are not stored into property's attribute storage
241 (thus they are not readable).
242
243 Note that this option is global, and applies to all wxPG property
244 containers.
245*/
246wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES = 0x00400000,
247
1c4293cb
VZ
248/** Hides page selection buttons from toolbar.
249*/
fc72fab6
JS
250wxPG_EX_HIDE_PAGE_BUTTONS = 0x01000000,
251
252/** Allows multiple properties to be selected by user (by pressing SHIFT
253 when clicking on a property, or by dragging with left mouse button
254 down).
255
256 You can get array of selected properties with
257 wxPropertyGridInterface::GetSelectedProperties(). In multiple selection
258 mode wxPropertyGridInterface::GetSelection() returns
259 property which has editor active (usually the first one
260 selected). Other useful member functions are ClearSelection(),
261 AddToSelection() and RemoveFromSelection().
262*/
263wxPG_EX_MULTIPLE_SELECTION = 0x02000000
1c4293cb
VZ
264
265};
266
267/** Combines various styles.
268*/
269#define wxPG_DEFAULT_STYLE (0)
270
271/** Combines various styles.
272*/
273#define wxPGMAN_DEFAULT_STYLE (0)
274
275/** @}
276*/
277
278// -----------------------------------------------------------------------
279
280//
281// Ids for sub-controls
282// NB: It should not matter what these are.
283#define wxPG_SUBID1 2
284#define wxPG_SUBID2 3
285#define wxPG_SUBID_TEMP1 4
286
287// -----------------------------------------------------------------------
288
289/** @class wxPGCommonValue
290
291 wxPropertyGrid stores information about common values in these
292 records.
293
294 NB: Common value feature is not complete, and thus not mentioned in
295 documentation.
296*/
297class WXDLLIMPEXP_PROPGRID wxPGCommonValue
298{
299public:
300
301 wxPGCommonValue( const wxString& label, wxPGCellRenderer* renderer )
302 {
303 m_label = label;
304 m_renderer = renderer;
305 renderer->IncRef();
306 }
307 virtual ~wxPGCommonValue()
308 {
309 m_renderer->DecRef();
310 }
311
312 virtual wxString GetEditableText() const { return m_label; }
313 const wxString& GetLabel() const { return m_label; }
314 wxPGCellRenderer* GetRenderer() const { return m_renderer; }
315
316protected:
317 wxString m_label;
318 wxPGCellRenderer* m_renderer;
319};
320
321// -----------------------------------------------------------------------
322
323/** @section propgrid_vfbflags wxPropertyGrid Validation Failure Behavior Flags
324 @{
325*/
326
327enum wxPG_VALIDATION_FAILURE_BEHAVIOR_FLAGS
328{
329
330/** Prevents user from leaving property unless value is valid. If this
331 behavior flag is not used, then value change is instead cancelled.
332*/
333wxPG_VFB_STAY_IN_PROPERTY = 0x01,
334
335/** Calls wxBell() on validation failure.
336*/
337wxPG_VFB_BEEP = 0x02,
338
339/** Cell with invalid value will be marked (with red colour).
340*/
341wxPG_VFB_MARK_CELL = 0x04,
342
343/** Display customizable text message explaining the situation.
344*/
345wxPG_VFB_SHOW_MESSAGE = 0x08,
346
347/** Defaults. */
348wxPG_VFB_DEFAULT = wxPG_VFB_STAY_IN_PROPERTY|wxPG_VFB_BEEP,
349
350/** Only used internally. */
351wxPG_VFB_UNDEFINED = 0x80
352
353};
354
355/** @}
356*/
357
358typedef wxByte wxPGVFBFlags;
359
2a8312bc
JS
360/**
361 wxPGValidationInfo
1c4293cb
VZ
362
363 Used to convey validation information to and from functions that
2a8312bc
JS
364 actually perform validation. Mostly used in custom property
365 classes.
1c4293cb 366*/
47e343c6 367class WXDLLIMPEXP_PROPGRID wxPGValidationInfo
1c4293cb 368{
2a8312bc
JS
369 friend class wxPropertyGrid;
370public:
6b03a638
JS
371 /**
372 @return Returns failure behavior which is a combination of
373 @ref propgrid_vfbflags.
374 */
47e343c6
JS
375 wxPGVFBFlags GetFailureBehavior() const
376 { return m_failureBehavior; }
6b03a638
JS
377
378 /**
379 Returns current failure message.
380 */
381 const wxString& GetFailureMessage() const
382 { return m_failureMessage; }
383
2a8312bc
JS
384 /**
385 Returns reference to pending value.
386 */
387 const wxVariant& GetValue() const
388 {
389 wxASSERT(m_pValue);
390 return *m_pValue;
391 }
392
6b03a638 393 /** Set validation failure behavior
1c4293cb 394
6b03a638
JS
395 @param failureBehavior
396 Mixture of @ref propgrid_vfbflags.
397 */
1c4293cb
VZ
398 void SetFailureBehavior(wxPGVFBFlags failureBehavior)
399 { m_failureBehavior = failureBehavior; }
400
6b03a638
JS
401 /**
402 Set current failure message.
403 */
9891e165
JS
404 void SetFailureMessage(const wxString& message)
405 { m_failureMessage = message; }
2a8312bc
JS
406
407private:
408 /** Value to be validated.
409 */
410 wxVariant* m_pValue;
411
412 /** Message displayed on validation failure.
413 */
414 wxString m_failureMessage;
415
416 /** Validation failure behavior. Use wxPG_VFB_XXX flags.
417 */
418 wxPGVFBFlags m_failureBehavior;
1c4293cb
VZ
419};
420
421// -----------------------------------------------------------------------
422
423/** @section propgrid_pgactions wxPropertyGrid Action Identifiers
424
425 These are used with wxPropertyGrid::AddActionTrigger() and
426 wxPropertyGrid::ClearActionTriggers().
427 @{
428*/
429
430enum wxPG_KEYBOARD_ACTIONS
431{
432 wxPG_ACTION_INVALID = 0,
433 wxPG_ACTION_NEXT_PROPERTY,
434 wxPG_ACTION_PREV_PROPERTY,
435 wxPG_ACTION_EXPAND_PROPERTY,
436 wxPG_ACTION_COLLAPSE_PROPERTY,
437 wxPG_ACTION_CANCEL_EDIT,
23318a53 438 wxPG_ACTION_PRESS_BUTTON, // Causes editor button (if any) to be pressed
1c4293cb
VZ
439 wxPG_ACTION_MAX
440};
23318a53 441
1c4293cb
VZ
442/** @}
443*/
444
445// -----------------------------------------------------------------------
446
447
448// wxPropertyGrid::DoSelectProperty flags (selFlags)
449
450// Focuses to created editor
01b5ad3b 451#define wxPG_SEL_FOCUS 0x01
1c4293cb 452// Forces deletion and recreation of editor
01b5ad3b 453#define wxPG_SEL_FORCE 0x02
1c4293cb 454// For example, doesn't cause EnsureVisible
01b5ad3b 455#define wxPG_SEL_NONVISIBLE 0x04
1c4293cb 456// Do not validate editor's value before selecting
01b5ad3b 457#define wxPG_SEL_NOVALIDATE 0x08
1c4293cb 458// Property being deselected is about to be deleted
01b5ad3b 459#define wxPG_SEL_DELETING 0x10
1c4293cb 460// Property's values was set to unspecified by the user
01b5ad3b 461#define wxPG_SEL_SETUNSPEC 0x20
1c4293cb 462// Property's event handler changed the value
01b5ad3b
JS
463#define wxPG_SEL_DIALOGVAL 0x40
464// Set to disable sending of wxEVT_PG_SELECTED event
465#define wxPG_SEL_DONT_SEND_EVENT 0x80
1c4293cb
VZ
466
467
468// -----------------------------------------------------------------------
469
470#ifndef SWIG
471
472// Internal flags
473#define wxPG_FL_INITIALIZED 0x0001
474// Set when creating editor controls if it was clicked on.
475#define wxPG_FL_ACTIVATION_BY_CLICK 0x0002
476#define wxPG_FL_DONT_CENTER_SPLITTER 0x0004
477#define wxPG_FL_FOCUSED 0x0008
478#define wxPG_FL_MOUSE_CAPTURED 0x0010
479#define wxPG_FL_MOUSE_INSIDE 0x0020
480#define wxPG_FL_VALUE_MODIFIED 0x0040
481// don't clear background of m_wndEditor
482#define wxPG_FL_PRIMARY_FILLS_ENTIRE 0x0080
483// currently active editor uses custom image
484#define wxPG_FL_CUR_USES_CUSTOM_IMAGE 0x0100
485// cell colours override selection colours for selected cell
486#define wxPG_FL_CELL_OVERRIDES_SEL 0x0200
487#define wxPG_FL_SCROLLED 0x0400
488// set when all added/inserted properties get hideable flag
489#define wxPG_FL_ADDING_HIDEABLES 0x0800
490// Disables showing help strings on statusbar.
491#define wxPG_FL_NOSTATUSBARHELP 0x1000
492// Marks that we created the state, so we have to destroy it too.
493#define wxPG_FL_CREATEDSTATE 0x2000
494// Set if scrollbar's existence was detected in last onresize.
495#define wxPG_FL_SCROLLBAR_DETECTED 0x4000
496// Set if wxPGMan requires redrawing of description text box.
497#define wxPG_FL_DESC_REFRESH_REQUIRED 0x8000
498// Set if contained in wxPropertyGridManager
499#define wxPG_FL_IN_MANAGER 0x00020000
500// Set after wxPropertyGrid is shown in its initial good size
501#define wxPG_FL_GOOD_SIZE_SET 0x00040000
1c4293cb
VZ
502// Set when in SelectProperty.
503#define wxPG_FL_IN_SELECT_PROPERTY 0x00100000
504// Set when help string is shown in status bar
505#define wxPG_FL_STRING_IN_STATUSBAR 0x00200000
506// Splitter position has been custom-set by the user
507#define wxPG_FL_SPLITTER_PRE_SET 0x00400000
508// Validation failed. Clear on modify event.
509#define wxPG_FL_VALIDATION_FAILED 0x00800000
9bc11214
JS
510// Auto sort is enabled (for categorized mode)
511#define wxPG_FL_CATMODE_AUTO_SORT 0x01000000
1c4293cb
VZ
512// Set after page has been inserted to manager
513#define wxPG_MAN_FL_PAGE_INSERTED 0x02000000
514// Active editor control is abnormally large
515#define wxPG_FL_ABNORMAL_EDITOR 0x04000000
b0996c3d
JS
516// Recursion guard for HandleCustomEditorEvent
517#define wxPG_FL_IN_HANDLECUSTOMEDITOREVENT 0x08000000
1c4293cb
VZ
518#define wxPG_FL_VALUE_CHANGE_IN_EVENT 0x10000000
519// Editor control width should not change on resize
520#define wxPG_FL_FIXED_WIDTH_EDITOR 0x20000000
521// Width of panel can be different than width of grid
522#define wxPG_FL_HAS_VIRTUAL_WIDTH 0x40000000
523// Prevents RecalculateVirtualSize re-entrancy
524#define wxPG_FL_RECALCULATING_VIRTUAL_SIZE 0x80000000
525
526#endif // #ifndef SWIG
527
528#if !defined(__wxPG_SOURCE_FILE__) && !defined(SWIG)
529 // Reduce compile time, but still include in user app
530 #include "wx/propgrid/props.h"
531#endif
532
533// -----------------------------------------------------------------------
534
535/** @class wxPropertyGrid
536
537 wxPropertyGrid is a specialized grid for editing properties
538 such as strings, numbers, flagsets, fonts, and colours. wxPropertySheet
539 used to do the very same thing, but it hasn't been updated for a while
540 and it is currently deprecated.
541
542 Please note that most member functions are inherited and as such not
543 documented on this page. This means you will probably also want to read
544 wxPropertyGridInterface class reference.
545
546 See also @ref overview_propgrid.
547
548 @section propgrid_window_styles_ Window Styles
549
550 See @ref propgrid_window_styles.
551
552 @section propgrid_event_handling Event Handling
553
554 To process input from a propertygrid control, use these event handler
555 macros to direct input to member functions that take a wxPropertyGridEvent
556 argument.
557
558 @beginEventTable{wxPropertyGridEvent}
559 @event{EVT_PG_SELECTED (id, func)}
01b5ad3b
JS
560 Respond to wxEVT_PG_SELECTED event, generated when a property selection
561 has been changed, either by user action or by indirect program
562 function. For instance, collapsing a parent property programmatically
563 causes any selected child property to become unselected, and may
564 therefore cause this event to be generated.
1c4293cb
VZ
565 @event{EVT_PG_CHANGING(id, func)}
566 Respond to wxEVT_PG_CHANGING event, generated when property value
567 is about to be changed by user. Use wxPropertyGridEvent::GetValue()
568 to take a peek at the pending value, and wxPropertyGridEvent::Veto()
569 to prevent change from taking place, if necessary.
570 @event{EVT_PG_HIGHLIGHTED(id, func)}
571 Respond to wxEVT_PG_HIGHLIGHTED event, which occurs when mouse
572 moves over a property. Event's property is NULL if hovered area does
573 not belong to any property.
574 @event{EVT_PG_RIGHT_CLICK(id, func)}
575 Respond to wxEVT_PG_RIGHT_CLICK event, which occurs when property is
576 clicked on with right mouse button.
577 @event{EVT_PG_DOUBLE_CLICK(id, func)}
578 Respond to wxEVT_PG_DOUBLE_CLICK event, which occurs when property is
579 double-clicked onwith left mouse button.
580 @event{EVT_PG_ITEM_COLLAPSED(id, func)}
581 Respond to wxEVT_PG_ITEM_COLLAPSED event, generated when user collapses
582 a property or category..
583 @event{EVT_PG_ITEM_EXPANDED(id, func)}
584 Respond to wxEVT_PG_ITEM_EXPANDED event, generated when user expands
585 a property or category..
586 @endEventTable
587
588 @remarks
589
590 - Use Freeze() and Thaw() respectively to disable and enable drawing. This
591 will also delay sorting etc. miscellaneous calculations to the last
592 possible moment.
593
594 @library{wxpropgrid}
595 @category{propgrid}
596*/
597class WXDLLIMPEXP_PROPGRID
598 wxPropertyGrid : public wxScrolledWindow, public wxPropertyGridInterface
599{
600 friend class wxPropertyGridPageState;
601 friend class wxPropertyGridInterface;
602 friend class wxPropertyGridManager;
603 friend class wxPGCanvas;
604
1c4293cb 605 DECLARE_DYNAMIC_CLASS(wxPropertyGrid)
1c4293cb
VZ
606public:
607
14bac4b5 608#ifndef SWIG
1c4293cb
VZ
609 /**
610 Two step constructor.
611
612 Call Create when this constructor is called to build up the
613 wxPropertyGrid
614 */
615 wxPropertyGrid();
14bac4b5 616#endif
1c4293cb
VZ
617
618 /** The default constructor. The styles to be used are styles valid for
619 the wxWindow and wxScrolledWindow.
23318a53
FM
620
621 @see @link wndflags Additional Window Styles @endlink
1c4293cb
VZ
622 */
623 wxPropertyGrid( wxWindow *parent, wxWindowID id = wxID_ANY,
624 const wxPoint& pos = wxDefaultPosition,
625 const wxSize& size = wxDefaultSize,
626 long style = wxPG_DEFAULT_STYLE,
23318a53 627 const wxString& name = wxPropertyGridNameStr );
1c4293cb
VZ
628
629 /** Destructor */
630 virtual ~wxPropertyGrid();
1c4293cb
VZ
631
632 /** Adds given key combination to trigger given action.
23318a53 633
1c4293cb
VZ
634 @param action
635 Which action to trigger. See @link pgactions List of list of
636 wxPropertyGrid actions@endlink.
637 */
638 void AddActionTrigger( int action, int keycode, int modifiers = 0 );
639
640 /**
641 This static function enables or disables automatic use of
642 wxGetTranslation for following strings: wxEnumProperty list labels,
643 wxFlagsProperty sub-property labels.
644
645 Default is false.
646 */
647 static void AutoGetTranslation( bool enable );
648
649 /**
650 Changes value of a property, as if from an editor.
651
652 Use this instead of SetPropertyValue() if you need the value to run
653 through validation process, and also send the property change event.
654
655 @return
656 Returns true if value was successfully changed.
657 */
658 bool ChangePropertyValue( wxPGPropArg id, wxVariant newValue );
659
660 /**
661 Centers the splitter.
662
663 If argument is true, automatic splitter centering is enabled (only
664 applicapple if style wxPG_SPLITTER_AUTO_CENTER was defined).
665 */
666 void CenterSplitter( bool enable_auto_centering = false );
667
668 /** Deletes all properties.
669 */
670 virtual void Clear();
671
672 /** Clears action triggers for given action.
673 @param action
674 Which action to trigger. See @link pgactions List of list of
675 wxPropertyGrid actions@endlink.
676 */
677 void ClearActionTriggers( int action );
678
679 /** Forces updating the value of property from the editor control.
680
681 Note that wxEVT_PG_CHANGING and wxEVT_PG_CHANGED are dispatched using
682 ProcessEvent, meaning your event handlers will be called immediately.
683
684 @return
685 Returns true if anything was changed.
686 */
687 virtual bool CommitChangesFromEditor( wxUint32 flags = 0 );
688
689 /**
690 Two step creation.
691
692 Whenever the control is created without any parameters, use Create to
693 actually create it. Don't access the control's public methods before
694 this is called @see @link wndflags Additional Window Styles@endlink
695 */
696 bool Create( wxWindow *parent, wxWindowID id = wxID_ANY,
697 const wxPoint& pos = wxDefaultPosition,
698 const wxSize& size = wxDefaultSize,
699 long style = wxPG_DEFAULT_STYLE,
23318a53 700 const wxString& name = wxPropertyGridNameStr );
1c4293cb
VZ
701
702 /**
703 Call when editor widget's contents is modified.
704
705 For example, this is called when changes text in wxTextCtrl (used in
706 wxStringProperty and wxIntProperty).
707
708 @remarks
709 This function should only be called by custom properties.
710
711 @see wxPGProperty::OnEvent()
712 */
713 void EditorsValueWasModified() { m_iFlags |= wxPG_FL_VALUE_MODIFIED; }
714
715 /** Reverse of EditorsValueWasModified().
716
717 @remarks
718 This function should only be called by custom properties.
719 */
720 void EditorsValueWasNotModified()
721 {
722 m_iFlags &= ~(wxPG_FL_VALUE_MODIFIED);
723 }
724
725 /**
726 Enables or disables (shows/hides) categories according to parameter
727 enable.
728 */
729 bool EnableCategories( bool enable );
730
731 /** Scrolls and/or expands items to ensure that the given item is visible.
732 Returns true if something was actually done.
733 */
734 bool EnsureVisible( wxPGPropArg id );
735
736 /**
737 Reduces column sizes to minimum possible that contents are still
738 visibly (naturally some margin space will be applied as well).
739
740 @return
741 Minimum size for the grid to still display everything.
742
743 @remarks
744 Does not work well with wxPG_SPLITTER_AUTO_CENTER window style.
745
746 This function only works properly if grid size prior to call was already
747 fairly large.
748
749 Note that you can also get calculated column widths by calling
750 GetState->GetColumnWidth() immediately after this function returns.
751 */
752 wxSize FitColumns()
753 {
754 wxSize sz = m_pState->DoFitColumns();
755 return sz;
756 }
757
758 /**
759 Returns wxWindow that the properties are painted on, and which should
760 be used as the parent for editor controls.
761 */
762 wxPanel* GetPanel() const
763 {
764 return m_canvas;
765 }
766
767 /** Returns current category caption background colour. */
768 wxColour GetCaptionBackgroundColour() const { return m_colCapBack; }
769
770 wxFont& GetCaptionFont() { return m_captionFont; }
771
772 const wxFont& GetCaptionFont() const { return m_captionFont; }
773
774 /** Returns current category caption text colour. */
775 wxColour GetCaptionForegroundColour() const { return m_colCapFore; }
776
777 /** Returns current cell background colour. */
778 wxColour GetCellBackgroundColour() const { return m_colPropBack; }
779
780 /** Returns current cell text colour when disabled. */
781 wxColour GetCellDisabledTextColour() const { return m_colDisPropFore; }
782
783 /** Returns current cell text colour. */
784 wxColour GetCellTextColour() const { return m_colPropFore; }
785
6b03a638
JS
786 /**
787 Returns number of columns currently on grid.
788 */
68bcfd2c 789 unsigned int GetColumnCount() const
1c4293cb 790 {
68bcfd2c 791 return (unsigned int) m_pState->m_colWidths.size();
1c4293cb
VZ
792 }
793
794 /** Returns colour of empty space below properties. */
795 wxColour GetEmptySpaceColour() const { return m_colEmptySpace; }
796
797 /** Returns height of highest characters of used font. */
798 int GetFontHeight() const { return m_fontHeight; }
799
800 /** Returns pointer to itself. Dummy function that enables same kind
801 of code to use wxPropertyGrid and wxPropertyGridManager.
802 */
803 wxPropertyGrid* GetGrid() { return this; }
804
805 /** Returns rectangle of custom paint image.
806 */
807 wxRect GetImageRect( wxPGProperty* p, int item ) const;
808
809 /** Returns size of the custom paint image in front of property.
810 If no argument is given, returns preferred size.
811 */
812 wxSize GetImageSize( wxPGProperty* p = NULL, int item = -1 ) const;
813
814 //@{
815 /** Returns last item which could be iterated using given flags.
816 @param flags
817 See @ref propgrid_iterator_flags.
818 */
819 wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT )
820 {
821 return m_pState->GetLastItem(flags);
822 }
823
824 const wxPGProperty* GetLastItem( int flags = wxPG_ITERATE_DEFAULT ) const
825 {
826 return m_pState->GetLastItem(flags);
827 }
828 //@}
829
830 /** Returns colour of lines between cells. */
831 wxColour GetLineColour() const { return m_colLine; }
832
833 /** Returns background colour of margin. */
834 wxColour GetMarginColour() const { return m_colMargin; }
835
9b5bafcf
JS
836 /**
837 Returns most up-to-date value of selected property. This will return
838 value different from GetSelectedProperty()->GetValue() only when text
839 editor is activate and string edited by user represents valid,
840 uncommitted property value.
841 */
703ee9f5 842 wxVariant GetUncommittedPropertyValue();
9b5bafcf 843
1c4293cb
VZ
844 /** Returns "root property". It does not have name, etc. and it is not
845 visible. It is only useful for accessing its children.
846 */
847 wxPGProperty* GetRoot() const { return m_pState->m_properties; }
848
849 /** Returns height of a single grid row (in pixels). */
850 int GetRowHeight() const { return m_lineHeight; }
851
852 /** Returns currently selected property. */
6b03a638 853 wxPGProperty* GetSelectedProperty() const { return GetSelection(); }
1c4293cb 854
1c4293cb
VZ
855 /** Returns current selection background colour. */
856 wxColour GetSelectionBackgroundColour() const { return m_colSelBack; }
857
858 /** Returns current selection text colour. */
859 wxColour GetSelectionForegroundColour() const { return m_colSelFore; }
860
861 /** Returns current splitter x position. */
862 int GetSplitterPosition() const
863 { return m_pState->DoGetSplitterPosition(0); }
864
865 /** Returns wxTextCtrl active in currently selected property, if any. Takes
866 into account wxOwnerDrawnComboBox.
867 */
868 wxTextCtrl* GetEditorTextCtrl() const;
869
870 wxPGValidationInfo& GetValidationInfo()
871 {
872 return m_validationInfo;
873 }
874
875 /** Returns current vertical spacing. */
876 int GetVerticalSpacing() const { return (int)m_vspacing; }
877
45843442
JS
878 /**
879 Returns @true if a property editor control has focus.
880 */
881 bool IsEditorFocused() const;
882
1c4293cb
VZ
883 /** Returns true if editor's value was marked modified.
884 */
885 bool IsEditorsValueModified() const
886 { return ( m_iFlags & wxPG_FL_VALUE_MODIFIED ) ? true : false; }
887
e276acb5
JS
888 /**
889 Returns information about arbitrary position in the grid.
1c4293cb 890
e276acb5 891 @param pt
58b6a137
JS
892 Coordinates in the virtual grid space. You may need to use
893 wxScrolledWindow::CalcScrolledPosition() for translating
894 wxPropertyGrid client coordinates into something this member
895 function can use.
1c4293cb
VZ
896 */
897 wxPropertyGridHitTestResult HitTest( const wxPoint& pt ) const;
898
899 /** Returns true if any property has been modified by the user. */
900 bool IsAnyModified() const { return (m_pState->m_anyModified>0); }
901
902 /**
903 Returns true if updating is frozen (ie Freeze() called but not yet
904 Thaw() ).
905 */
906 bool IsFrozen() const { return (m_frozen>0)?true:false; }
907
27c1f235 908 /**
6edd8829
JS
909 It is recommended that you call this function any time your code causes
910 wxPropertyGrid's top-level parent to change. wxPropertyGrid's OnIdle()
911 handler should be able to detect most changes, but it is not perfect.
27c1f235
JS
912
913 @param newTLP
914 New top-level parent that is about to be set. Old top-level parent
915 window should still exist as the current one.
916
917 @remarks This function is automatically called from wxPropertyGrid::
918 Reparent() and wxPropertyGridManager::Reparent(). You only
919 need to use it if you reparent wxPropertyGrid indirectly.
920 */
921 void OnTLPChanging( wxWindow* newTLP );
922
1c4293cb
VZ
923 /** Redraws given property.
924 */
925 virtual void RefreshProperty( wxPGProperty* p );
926
927#ifndef SWIG
928 /** Registers a new editor class.
929 @return
930 Pointer to the editor class instance that should be used.
931 */
932 static wxPGEditor* RegisterEditorClass( wxPGEditor* editor,
b7d19850
JS
933 bool noDefCheck = false )
934 {
935 return DoRegisterEditorClass(editor, wxEmptyString, noDefCheck);
936 }
937
938 static wxPGEditor* DoRegisterEditorClass( wxPGEditor* editorClass,
939 const wxString& editorName,
940 bool noDefCheck = false );
1c4293cb
VZ
941#endif
942
943 /** Resets all colours to the original system values.
944 */
945 void ResetColours();
946
947 /**
948 Selects a property.
949 Editor widget is automatically created, but not focused unless focus is
01b5ad3b
JS
950 true.
951
1c4293cb
VZ
952 @param id
953 Property to select.
01b5ad3b 954
1c4293cb
VZ
955 @return
956 True if selection finished successfully. Usually only fails if
957 current value in editor is not valid.
01b5ad3b
JS
958
959 @remarks In wxPropertyGrid 1.4, this member function used to generate
960 wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
961 does that.
962
fc72fab6 963 @remarks This clears any previous selection.
1c4293cb 964 */
01b5ad3b 965 bool SelectProperty( wxPGPropArg id, bool focus = false );
1c4293cb 966
fc72fab6
JS
967 /**
968 Set entire new selection from given list of properties.
969 */
970 void SetSelection( const wxArrayPGProperty& newSelection )
971 {
972 DoSetSelection( newSelection, wxPG_SEL_DONT_SEND_EVENT );
973 }
974
975 /**
976 Adds given property into selection. If wxPG_EX_MULTIPLE_SELECTION
977 extra style is not used, then this has same effect as
978 calling SelectProperty().
979
980 @remarks Multiple selection is not supported for categories. This
981 means that if you have properties selected, you cannot
982 add category to selection, and also if you have category
983 selected, you cannot add other properties to selection.
984 This member function will fail silently in these cases,
985 even returning true.
986 */
987 bool AddToSelection( wxPGPropArg id )
988 {
989 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
990 return DoAddToSelection(p, wxPG_SEL_DONT_SEND_EVENT);
991 }
992
993 /**
994 Removes given property from selection. If property is not selected,
995 an assertion failure will occur.
996 */
997 bool RemoveFromSelection( wxPGPropArg id )
998 {
999 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1000 return DoRemoveFromSelection(p, wxPG_SEL_DONT_SEND_EVENT);
1001 }
1002
1c4293cb
VZ
1003 /** Sets category caption background colour. */
1004 void SetCaptionBackgroundColour(const wxColour& col);
1005
1006 /** Sets category caption text colour. */
1007 void SetCaptionTextColour(const wxColour& col);
1008
1009 /** Sets default cell background colour - applies to property cells.
1010 Note that appearance of editor widgets may not be affected.
1011 */
1012 void SetCellBackgroundColour(const wxColour& col);
1013
1014 /** Sets cell text colour for disabled properties.
1015 */
1016 void SetCellDisabledTextColour(const wxColour& col);
1017
1018 /** Sets default cell text colour - applies to property name and value text.
1019 Note that appearance of editor widgets may not be affected.
1020 */
1021 void SetCellTextColour(const wxColour& col);
1022
1023 /** Set number of columns (2 or more).
1024 */
1025 void SetColumnCount( int colCount )
1026 {
1027 m_pState->SetColumnCount(colCount);
1028 Refresh();
1029 }
1030
1031 /**
1032 Sets the 'current' category - Append will add non-category properties
1033 under it.
1034 */
1035 void SetCurrentCategory( wxPGPropArg id )
1036 {
1037 wxPG_PROP_ARG_CALL_PROLOG()
30595b81
JS
1038 wxPropertyCategory* pc = wxDynamicCast(p, wxPropertyCategory);
1039 wxASSERT(pc);
1c4293cb
VZ
1040 m_pState->m_currentCategory = pc;
1041 }
1042
1043 /** Sets colour of empty space below properties. */
1044 void SetEmptySpaceColour(const wxColour& col);
1045
1046 /** Sets colour of lines between cells. */
1047 void SetLineColour(const wxColour& col);
1048
1049 /** Sets background colour of margin. */
1050 void SetMarginColour(const wxColour& col);
1051
1c4293cb
VZ
1052 /**
1053 Sets selection background colour - applies to selected property name
1054 background.
1055 */
1056 void SetSelectionBackgroundColour(const wxColour& col);
1057
1058 /**
1059 Sets selection foreground colour - applies to selected property name
1060 text.
1061 */
1062 void SetSelectionTextColour(const wxColour& col);
1063
1064 /** Sets x coordinate of the splitter.
1065 @remarks
1066 Splitter position cannot exceed grid size, and therefore setting it
1067 during form creation may fail as initial grid size is often smaller
1068 than desired splitter position, especially when sizers are being used.
1069 */
1070 void SetSplitterPosition( int newxpos, int col = 0 )
1071 {
1072 DoSetSplitterPosition_(newxpos, true, col);
1073 m_iFlags |= wxPG_FL_SPLITTER_PRE_SET;
1074 }
1075
43396981
JS
1076 /**
1077 Sets the property sorting function.
1078
1079 @param sortFunction
1080 The sorting function to be used. It should return a value greater
1081 than 0 if position of p1 is after p2. So, for instance, when
1082 comparing property names, you can use following implementation:
1083
1084 @code
1085 int MyPropertySortFunction(wxPropertyGrid* propGrid,
1086 wxPGProperty* p1,
1087 wxPGProperty* p2)
1088 {
1089 return p1->GetBaseName().compare( p2->GetBaseName() );
1090 }
1091 @endcode
1092
1093 @remarks
1094 Default property sort function sorts properties by their labels
1095 (case-insensitively).
1096
1097 @see GetSortFunction, wxPropertyGridInterface::Sort,
1098 wxPropertyGridInterface::SortChildren
1099 */
1100 void SetSortFunction( wxPGSortCallback sortFunction )
1101 {
1102 m_sortFunction = sortFunction;
1103 }
1104
1105 /**
1106 Returns the property sort function (default is @NULL).
1107
1108 @see SetSortFunction
1109 */
1110 wxPGSortCallback GetSortFunction() const
1111 {
1112 return m_sortFunction;
1113 }
1114
1c4293cb
VZ
1115 /** Set virtual width for this particular page. Width -1 indicates that the
1116 virtual width should be disabled. */
1117 void SetVirtualWidth( int width );
1118
6b03a638
JS
1119 /**
1120 Moves splitter as left as possible, while still allowing all
1c4293cb 1121 labels to be shown in full.
6b03a638
JS
1122
1123 @param privateChildrenToo
1124 If @false, will still allow private children to be cropped.
1c4293cb 1125 */
6b03a638 1126 void SetSplitterLeft( bool privateChildrenToo = false )
1c4293cb 1127 {
6b03a638 1128 m_pState->SetSplitterLeft(privateChildrenToo);
1c4293cb
VZ
1129 }
1130
1131 /** Sets vertical spacing. Can be 1, 2, or 3 - a value relative to font
1132 height. Value of 2 should be default on most platforms.
1c4293cb
VZ
1133 */
1134 void SetVerticalSpacing( int vspacing )
1135 {
1136 m_vspacing = (unsigned char)vspacing;
1137 CalculateFontAndBitmapStuff( vspacing );
1138 if ( !m_pState->m_itemsAdded ) Refresh();
1139 }
1140
1141 /** Shows an brief error message that is related to a property. */
1142 void ShowPropertyError( wxPGPropArg id, const wxString& msg )
1143 {
1144 wxPG_PROP_ARG_CALL_PROLOG()
1145 DoShowPropertyError(p, msg);
1146 }
1147
1c4293cb
VZ
1148 /////////////////////////////////////////////////////////////////
1149 //
1150 // Following methods do not need to be (currently) documented
1151 //
1152 /////////////////////////////////////////////////////////////////
1153
1154 bool HasVirtualWidth() const
1155 { return (m_iFlags & wxPG_FL_HAS_VIRTUAL_WIDTH) ? true : false; }
1156
1157 const wxPGCommonValue* GetCommonValue( unsigned int i ) const
1158 {
1159 return (wxPGCommonValue*) m_commonValues[i];
1160 }
1161
1162 /** Returns number of common values.
1163 */
1164 unsigned int GetCommonValueCount() const
1165 {
68bcfd2c 1166 return (unsigned int) m_commonValues.size();
1c4293cb
VZ
1167 }
1168
1169 /** Returns label of given common value.
1170 */
1171 wxString GetCommonValueLabel( unsigned int i ) const
1172 {
1173 wxASSERT( GetCommonValue(i) );
1174 return GetCommonValue(i)->GetLabel();
1175 }
1176
1177 /**
1178 Returns index of common value that will truly change value to
1179 unspecified.
1180 */
1181 int GetUnspecifiedCommonValue() const { return m_cvUnspecified; }
1182
1183 /** Set index of common value that will truly change value to unspecified.
1184 Using -1 will set none to have such effect.
1185 Default is 0.
1186 */
1187 void SetUnspecifiedCommonValue( int index ) { m_cvUnspecified = index; }
1188
1189 /**
1190 Shortcut for creating dialog-caller button. Used, for example, by
1191 wxFontProperty.
1192 @remarks
1193 This should only be called by properties.
1194 */
1195 wxWindow* GenerateEditorButton( const wxPoint& pos, const wxSize& sz );
1196
1197 /** Fixes position of wxTextCtrl-like control (wxSpinCtrl usually
1198 fits as one). Call after control has been created (but before
1199 shown).
1200 */
1201 void FixPosForTextCtrl( wxWindow* ctrl,
1202 const wxPoint& offset = wxPoint(0, 0) );
1203
1204 /** Shortcut for creating text editor widget.
1205 @param pos
1206 Same as pos given for CreateEditor.
1207 @param sz
1208 Same as sz given for CreateEditor.
1209 @param value
1210 Initial text for wxTextCtrl.
1211 @param secondary
1212 If right-side control, such as button, also created, then create it
1213 first and pass it as this parameter.
1214 @param extraStyle
1215 Extra style flags to pass for wxTextCtrl.
1216 @remarks
1217 Note that this should generally be called only by new classes derived
1218 from wxPGProperty.
1219 */
1220 wxWindow* GenerateEditorTextCtrl( const wxPoint& pos,
1221 const wxSize& sz,
1222 const wxString& value,
1223 wxWindow* secondary,
1224 int extraStyle = 0,
1225 int maxLen = 0 );
1226
1227 /* Generates both textctrl and button.
1228 */
1229 wxWindow* GenerateEditorTextCtrlAndButton( const wxPoint& pos,
1230 const wxSize& sz, wxWindow** psecondary, int limited_editing,
1231 wxPGProperty* property );
1232
1233 /** Generates position for a widget editor dialog box.
1234 @param p
1235 Property for which dialog is positioned.
1236 @param sz
1237 Known or over-approximated size of the dialog.
1238 @return
1239 Position for dialog.
1240 */
1241 wxPoint GetGoodEditorDialogPosition( wxPGProperty* p,
1242 const wxSize& sz );
1243
1244 // Converts escape sequences in src_str to newlines,
1245 // tabs, etc. and copies result to dst_str.
1246 static wxString& ExpandEscapeSequences( wxString& dst_str,
1247 wxString& src_str );
1248
1249 // Converts newlines, tabs, etc. in src_str to escape
1250 // sequences, and copies result to dst_str.
1251 static wxString& CreateEscapeSequences( wxString& dst_str,
1252 wxString& src_str );
1253
1254 /**
1255 Returns rectangle that fully contains properties between and including
1256 p1 and p2.
1257 */
1258 wxRect GetPropertyRect( const wxPGProperty* p1,
1259 const wxPGProperty* p2 ) const;
1260
1261 /** Returns pointer to current active primary editor control (NULL if none).
1c4293cb
VZ
1262 */
1263 wxWindow* GetEditorControl() const;
1264
1c4293cb
VZ
1265 wxWindow* GetPrimaryEditor() const
1266 {
1267 return GetEditorControl();
1268 }
1269
1270 /**
1271 Returns pointer to current active secondary editor control (NULL if
1272 none).
1273 */
1274 wxWindow* GetEditorControlSecondary() const
1275 {
1276 return m_wndEditor2;
1277 }
1278
f521bae6
JS
1279 /**
1280 Refreshes any active editor control.
1281 */
1282 void RefreshEditor();
1283
b0996c3d
JS
1284 // Events from editor controls are forward to this function
1285 void HandleCustomEditorEvent( wxEvent &event );
1286
1c4293cb
VZ
1287#ifndef SWIG
1288
1289 /**
1290 Generates contents for string dst based on the contents of
1291 wxArrayString src.
1292
1293 Format will be "(preDelim)str1(postDelim) (preDelim)str2(postDelim) and
1294 so on. Set flags to 1 inorder to convert backslashes to double-back-
1295 slashes and "(preDelims)"'s to "(preDelims)".
1296 */
1297 static void ArrayStringToString( wxString& dst, const wxArrayString& src,
1298 wxChar preDelim, wxChar postDelim,
1299 int flags );
1300
1301 // Mostly useful for page switching.
1302 void SwitchState( wxPropertyGridPageState* pNewState );
1303
1c4293cb 1304 long GetInternalFlags() const { return m_iFlags; }
2fd4a524
JS
1305 bool HasInternalFlag( long flag ) const
1306 { return (m_iFlags & flag) ? true : false; }
1c4293cb
VZ
1307 void SetInternalFlag( long flag ) { m_iFlags |= flag; }
1308 void ClearInternalFlag( long flag ) { m_iFlags &= ~(flag); }
1309 void IncFrozen() { m_frozen++; }
1310 void DecFrozen() { m_frozen--; }
1311
e9cc4973
JS
1312 void OnComboItemPaint( const wxPGComboBox* pCb,
1313 int item,
1314 wxDC* pDc,
1315 wxRect& rect,
1316 int flags );
1c4293cb 1317
1c4293cb
VZ
1318 /** Standardized double-to-string conversion.
1319 */
1320 static void DoubleToString( wxString& target,
1321 double value,
1322 int precision,
1323 bool removeZeroes,
1324 wxString* precTemplate );
1325
1326 /**
1327 Call this from wxPGProperty::OnEvent() to cause property value to be
1328 changed after the function returns (with true as return value).
1329 ValueChangeInEvent() must be used if you wish the application to be
1330 able to use wxEVT_PG_CHANGING to potentially veto the given value.
1331 */
1332 void ValueChangeInEvent( wxVariant variant )
1333 {
1334 m_changeInEventValue = variant;
1335 m_iFlags |= wxPG_FL_VALUE_CHANGE_IN_EVENT;
1336 }
1337
eddcc4b4
JS
1338 /**
1339 You can use this member function, for instance, to detect in
1340 wxPGProperty::OnEvent() if wxPGProperty::SetValueInEvent() was
1341 already called in wxPGEditor::OnEvent(). It really only detects
1342 if was value was changed using wxPGProperty::SetValueInEvent(), which
1343 is usually used when a 'picker' dialog is displayed. If value was
1344 written by "normal means" in wxPGProperty::StringToValue() or
1345 IntToValue(), then this function will return false (on the other hand,
1346 wxPGProperty::OnEvent() is not even called in those cases).
1347 */
1348 bool WasValueChangedInEvent() const
1349 {
1350 return (m_iFlags & wxPG_FL_VALUE_CHANGE_IN_EVENT) ? true : false;
1351 }
1352
1c4293cb
VZ
1353 /** Returns true if given event is from first of an array of buttons
1354 (as can be in case when wxPGMultiButton is used).
1355 */
1356 bool IsMainButtonEvent( const wxEvent& event )
1357 {
1358 return (event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED)
1359 && (m_wndSecId == event.GetId());
1360 }
1361
1362 /** Pending value is expected to be passed in PerformValidation().
1363 */
1364 virtual bool DoPropertyChanged( wxPGProperty* p,
1365 unsigned int selFlags = 0 );
1366
1c4293cb
VZ
1367 /** Called when validation for given property fails.
1368 @param invalidValue
1369 Value which failed in validation.
1370 @return
1371 Return true if user is allowed to change to another property even
1372 if current has invalid value.
1373 @remarks
1374 To add your own validation failure behavior, override
1375 wxPropertyGrid::DoOnValidationFailure().
1376 */
d8812c6e
JS
1377 bool OnValidationFailure( wxPGProperty* property,
1378 wxVariant& invalidValue );
1c4293cb
VZ
1379
1380 /** Called to indicate property and editor has valid value now.
1381 */
1382 void OnValidationFailureReset( wxPGProperty* property )
1383 {
1384 if ( property && property->HasFlag(wxPG_PROP_INVALID_VALUE) )
1385 {
1386 DoOnValidationFailureReset(property);
1387 property->ClearFlag(wxPG_PROP_INVALID_VALUE);
1388 }
1389 m_validationInfo.m_failureMessage.clear();
1390 }
1391
1392 /** Override in derived class to display error messages in custom manner
1393 (these message usually only result from validation failure).
1394 */
1395 virtual void DoShowPropertyError( wxPGProperty* property,
1396 const wxString& msg );
1397
1398 /** Override to customize property validation failure behavior.
1399 @param invalidValue
1400 Value which failed in validation.
1401 @return
1402 Return true if user is allowed to change to another property even
1403 if current has invalid value.
1404 */
1405 virtual bool DoOnValidationFailure( wxPGProperty* property,
1406 wxVariant& invalidValue );
1407
1408 /** Override to customize resetting of property validation failure status.
1409 @remarks
1410 Property is guaranteed to have flag wxPG_PROP_INVALID_VALUE set.
1411 */
1412 virtual void DoOnValidationFailureReset( wxPGProperty* property );
1413
1414 int GetSpacingY() const { return m_spacingy; }
1415
1416 /**
1417 Must be called in wxPGEditor::CreateControls() if primary editor window
1418 is wxTextCtrl, just before textctrl is created.
1419 @param text
1420 Initial text value of created wxTextCtrl.
1421 */
1422 void SetupTextCtrlValue( const wxString text ) { m_prevTcValue = text; }
1423
1424 /**
1425 Unfocuses or closes editor if one was open, but does not deselect
1426 property.
1427 */
1428 bool UnfocusEditor();
1429
470f357f
PC
1430 virtual void SetWindowStyleFlag( long style );
1431
e777bd14
JS
1432 void DrawItems( const wxPGProperty* p1, const wxPGProperty* p2 );
1433
1434 void DrawItem( wxPGProperty* p )
1435 {
1436 DrawItems(p,p);
1437 }
1438
1439 virtual void DrawItemAndChildren( wxPGProperty* p );
1440
1441 /**
1442 Draws item, children, and consequtive parents as long as category is
1443 not met.
1444 */
1445 void DrawItemAndValueRelated( wxPGProperty* p );
1446
1c4293cb
VZ
1447protected:
1448
1449 /**
1450 wxPropertyGridPageState used by the grid is created here.
1451
1452 If grid is used in wxPropertyGridManager, there is no point overriding
1453 this - instead, set custom wxPropertyGridPage classes.
1454 */
1455 virtual wxPropertyGridPageState* CreateState() const;
1456
9b5bafcf
JS
1457 enum PerformValidationFlags
1458 {
1459 SendEvtChanging = 0x0001,
1460 IsStandaloneValidation = 0x0002 // Not called in response to event
1461 };
1462
1463 /**
1464 Runs all validation functionality (includes sending wxEVT_PG_CHANGING).
1465 Returns true if all tests passed. Implement in derived class to
1466 add additional validation behavior.
1467 */
1468 virtual bool PerformValidation( wxPGProperty* p,
1469 wxVariant& pendingValue,
1470 int flags = SendEvtChanging );
1471
1c4293cb
VZ
1472public:
1473
1474 // Control font changer helper.
1475 void SetCurControlBoldFont();
1476
d7e2b522
JS
1477 wxPGCell& GetPropertyDefaultCell()
1478 {
1479 return m_propertyDefaultCell;
1480 }
1481
1482 wxPGCell& GetCategoryDefaultCell()
1483 {
1484 return m_categoryDefaultCell;
1485 }
1486
1c4293cb
VZ
1487 //
1488 // Public methods for semi-public use
1c4293cb
VZ
1489 //
1490 bool DoSelectProperty( wxPGProperty* p, unsigned int flags = 0 );
1491
1492 // Overridden functions.
1493 virtual bool Destroy();
1c4293cb
VZ
1494 // Returns property at given y coordinate (relative to grid's top left).
1495 wxPGProperty* GetItemAtY( int y ) const { return DoGetItemAtY(y); }
1496
1497 virtual void Refresh( bool eraseBackground = true,
1498 const wxRect *rect = (const wxRect *) NULL );
1499 virtual bool SetFont( const wxFont& font );
1500#if wxPG_SUPPORT_TOOLTIPS
1501 void SetToolTip( const wxString& tipString );
1502#endif
1503 virtual void Freeze();
1504 virtual void SetExtraStyle( long exStyle );
1505 virtual void Thaw();
27c1f235 1506 virtual bool Reparent( wxWindowBase *newParent );
1c4293cb
VZ
1507
1508protected:
470f357f 1509 virtual wxSize DoGetBestSize() const;
1c4293cb
VZ
1510
1511#ifndef wxPG_ICON_WIDTH
1512 wxBitmap *m_expandbmp, *m_collbmp;
1513#endif
1514
1515 wxCursor *m_cursorSizeWE;
1516
1517 /** wxWindow pointers to editor control(s). */
1518 wxWindow *m_wndEditor;
1519 wxWindow *m_wndEditor2;
1520
1521 /** wxPGCanvas instance. */
1522 wxPanel *m_canvas;
1523
1524#if wxPG_DOUBLE_BUFFER
1525 wxBitmap *m_doubleBuffer;
1526#endif
1527
1c4293cb
VZ
1528 /** Local time ms when control was created. */
1529 wxLongLong m_timeCreated;
1530
1531 /** wxPGProperty::OnEvent can change value by setting this. */
1532 wxVariant m_changeInEventValue;
1533
1534 /** Id of m_wndEditor2, or its first child, if any. */
1535 int m_wndSecId;
1536
1537 /** Extra Y spacing between the items. */
1538 int m_spacingy;
1539
1540 /** Control client area width; updated on resize. */
1541 int m_width;
1542
1543 /** Control client area height; updated on resize. */
1544 int m_height;
1545
1546 /** Current non-client width (needed when auto-centering). */
1547 int m_ncWidth;
1548
1549 /** Non-client width (auto-centering helper). */
1550 //int m_fWidth;
1551
1552 /** Previously recorded scroll start position. */
1553 int m_prevVY;
1554
1555 /**
1556 The gutter spacing in front and back of the image.
1557 This determines the amount of spacing in front of each item
1558 */
1559 int m_gutterWidth;
1560
1561 /** Includes separator line. */
1562 int m_lineHeight;
1563
1564 /** Gutter*2 + image width. */
1565 int m_marginWidth;
1566
1567 // y spacing for expand/collapse button.
1568 int m_buttonSpacingY;
1569
1570 /** Extra margin for expanded sub-group items. */
1571 int m_subgroup_extramargin;
1572
1573 /**
1574 The image width of the [+] icon.
1575
1576 This is also calculated in the gutter
1577 */
1578 int m_iconWidth;
1579
1580#ifndef wxPG_ICON_WIDTH
1581
1582 /**
1583 The image height of the [+] icon.
1584
1585 This is calculated as minimal size and to align
1586 */
1587 int m_iconHeight;
1588#endif
1589
1590 /** Current cursor id. */
1591 int m_curcursor;
1592
1593 /**
1594 This captionFont is made equal to the font of the wxScrolledWindow.
1595
1596 As extra the bold face is set on it when this is wanted by the user
1597 (see flags)
1598 */
1599 wxFont m_captionFont;
1600
1601 int m_fontHeight; // Height of the font.
1602
1c4293cb
VZ
1603 /** m_splitterx when drag began. */
1604 int m_startingSplitterX;
1605
1606 /**
1607 Index to splitter currently being dragged (0=one after the first
1608 column).
1609 */
1610 int m_draggedSplitter;
1611
1612 /** Changed property, calculated in PerformValidation(). */
1613 wxPGProperty* m_chgInfo_changedProperty;
1614
1615 /**
1616 Lowest property for which editing happened, but which does not have
1617 aggregate parent
1618 */
1619 wxPGProperty* m_chgInfo_baseChangedProperty;
1620
1621 /** Changed property value, calculated in PerformValidation(). */
1622 wxVariant m_chgInfo_pendingValue;
1623
1624 /** Passed to SetValue. */
1625 wxVariant m_chgInfo_valueList;
1626
1627 /** Validation information. */
1628 wxPGValidationInfo m_validationInfo;
1629
1630 /** Actions and keys that trigger them. */
1631 wxPGHashMapI2I m_actionTriggers;
1632
1633 //
1634 // Temporary values
1635 //
1636
1637 /** Bits are used to indicate which colours are customized. */
1638 unsigned short m_coloursCustomized;
1639
1640 /** x - m_splitterx. */
1641 signed char m_dragOffset;
1642
1643 /** 0 = not dragging, 1 = drag just started, 2 = drag in progress */
1644 unsigned char m_dragStatus;
1645
1646 /** 0 = margin, 1 = label, 2 = value. */
1647 unsigned char m_mouseSide;
1648
1649 /** True when editor control is focused. */
1650 unsigned char m_editorFocused;
1651
1652 /** 1 if m_latsCaption is also the bottommost caption. */
1653 //unsigned char m_lastCaptionBottomnest;
1654
1655 /** Set to 1 when graphics frozen. */
1656 unsigned char m_frozen;
1657
1658 unsigned char m_vspacing;
1659
1c4293cb
VZ
1660 // Used to track when Alt/Ctrl+Key was consumed.
1661 unsigned char m_keyComboConsumed;
1662
1663 /** 1 if in DoPropertyChanged() */
1664 unsigned char m_inDoPropertyChanged;
1665
1666 /** 1 if in CommitChangesFromEditor() */
1667 unsigned char m_inCommitChangesFromEditor;
1668
1669 /** 1 if in DoSelectProperty() */
1670 unsigned char m_inDoSelectProperty;
1671
1672 wxPGVFBFlags m_permanentValidationFailureBehavior; // Set by app
1673
1674 /** Internal flags - see wxPG_FL_XXX constants. */
1675 wxUint32 m_iFlags;
1676
1677 /** When drawing next time, clear this many item slots at the end. */
1678 int m_clearThisMany;
1679
1c4293cb
VZ
1680 // pointer to property that has mouse hovering
1681 wxPGProperty* m_propHover;
1682
1683 // EventObject for wxPropertyGridEvents
1684 wxWindow* m_eventObject;
1685
1686 // What (global) window is currently focused (needed to resolve event
1687 // handling mess).
1688 wxWindow* m_curFocused;
1689
27c1f235 1690 // Last known top-level parent
1c4293cb
VZ
1691 wxWindow* m_tlp;
1692
6edd8829
JS
1693 // Last closed top-level parent
1694 wxWindow* m_tlpClosed;
1695
1696 // Local time ms when tlp was closed.
1697 wxLongLong m_tlpClosedTime;
1698
43396981
JS
1699 // Sort function
1700 wxPGSortCallback m_sortFunction;
1701
1c4293cb
VZ
1702 // y coordinate of property that mouse hovering
1703 int m_propHoverY;
1704 // Which column's editor is selected (usually 1)?
1705 int m_selColumn;
1706
1707 // x relative to splitter (needed for resize).
1708 int m_ctrlXAdjust;
1709
1710 // lines between cells
1711 wxColour m_colLine;
1712 // property labels and values are written in this colour
1713 wxColour m_colPropFore;
1714 // or with this colour when disabled
1715 wxColour m_colDisPropFore;
1716 // background for m_colPropFore
1717 wxColour m_colPropBack;
1718 // text color for captions
1719 wxColour m_colCapFore;
1720 // background color for captions
1721 wxColour m_colCapBack;
1722 // foreground for selected property
1723 wxColour m_colSelFore;
1724 // background for selected property (actually use background color when
1725 // control out-of-focus)
1726 wxColour m_colSelBack;
1727 // background colour for margin
1728 wxColour m_colMargin;
1729 // background colour for empty space below the grid
1730 wxColour m_colEmptySpace;
1731
d7e2b522
JS
1732 // Default property colours
1733 wxPGCell m_propertyDefaultCell;
1734
1735 // Default property category
1736 wxPGCell m_categoryDefaultCell;
1c4293cb 1737
d7e2b522
JS
1738 // Backup of selected property's cells
1739 wxVector<wxPGCell> m_propCellsBackup;
f7a094e1 1740
d7e2b522 1741 // NB: These *cannot* be moved to globals.
1c4293cb
VZ
1742
1743 // labels when properties use common values
f7a094e1
JS
1744 wxVector<wxPGCommonValue*> m_commonValues;
1745
1c4293cb
VZ
1746 // Which cv selection really sets value to unspecified?
1747 int m_cvUnspecified;
1748
1749 // Used to skip excess text editor events
1750 wxString m_prevTcValue;
1751
1752protected:
1753
1754 // Sets some members to defaults (called constructors).
1755 void Init1();
1756
1757 // Initializes some members (called by Create and complex constructor).
1758 void Init2();
1759
1760 void OnPaint(wxPaintEvent &event );
1761
1762 // main event receivers
1763 void OnMouseMove( wxMouseEvent &event );
1764 void OnMouseMoveBottom( wxMouseEvent &event );
1765 void OnMouseClick( wxMouseEvent &event );
1766 void OnMouseRightClick( wxMouseEvent &event );
1767 void OnMouseDoubleClick( wxMouseEvent &event );
1768 void OnMouseUp( wxMouseEvent &event );
1769 void OnKey( wxKeyEvent &event );
1c4293cb
VZ
1770 void OnResize( wxSizeEvent &event );
1771
1772 // event handlers
1773 bool HandleMouseMove( int x, unsigned int y, wxMouseEvent &event );
1774 bool HandleMouseClick( int x, unsigned int y, wxMouseEvent &event );
1775 bool HandleMouseRightClick( int x, unsigned int y, wxMouseEvent &event );
1776 bool HandleMouseDoubleClick( int x, unsigned int y, wxMouseEvent &event );
1777 bool HandleMouseUp( int x, unsigned int y, wxMouseEvent &event );
68f9e025 1778 void HandleKeyEvent( wxKeyEvent &event, bool fromChild );
1c4293cb
VZ
1779
1780 void OnMouseEntry( wxMouseEvent &event );
1781
1782 void OnIdle( wxIdleEvent &event );
1783 void OnFocusEvent( wxFocusEvent &event );
1784 void OnChildFocusEvent( wxChildFocusEvent& event );
1785
1786 bool OnMouseCommon( wxMouseEvent &event, int* px, int *py );
1787 bool OnMouseChildCommon( wxMouseEvent &event, int* px, int *py );
1788
1789 // sub-control event handlers
1790 void OnMouseClickChild( wxMouseEvent &event );
1791 void OnMouseRightClickChild( wxMouseEvent &event );
1792 void OnMouseMoveChild( wxMouseEvent &event );
1793 void OnMouseUpChild( wxMouseEvent &event );
1794 void OnChildKeyDown( wxKeyEvent &event );
1c4293cb
VZ
1795
1796 void OnCaptureChange( wxMouseCaptureChangedEvent &event );
1797
1798 void OnScrollEvent( wxScrollWinEvent &event );
1799
1800 void OnSysColourChanged( wxSysColourChangedEvent &event );
1801
27c1f235
JS
1802 void OnTLPClose( wxCloseEvent& event );
1803
1c4293cb
VZ
1804protected:
1805
fc72fab6
JS
1806 bool AddToSelectionFromInputEvent( wxPGProperty* prop,
1807 wxMouseEvent* event = NULL,
1808 int selFlags = 0 );
1809
1c4293cb
VZ
1810 /**
1811 Adjust the centering of the bitmap icons (collapse / expand) when the
1812 caption font changes.
1813
1814 They need to be centered in the middle of the font, so a bit of deltaY
1815 adjustment is needed. On entry, m_captionFont must be set to window
1816 font. It will be modified properly.
1817 */
1818 void CalculateFontAndBitmapStuff( int vspacing );
1819
1820 wxRect GetEditorWidgetRect( wxPGProperty* p, int column ) const;
1821
1822 void CorrectEditorWidgetSizeX();
1823
1824 /** Called in RecalculateVirtualSize() to reposition control
1825 on virtual height changes.
1826 */
1827 void CorrectEditorWidgetPosY();
1828
1c4293cb 1829 int DoDrawItems( wxDC& dc,
bcf324be 1830 const wxRect* clipRect,
1c4293cb
VZ
1831 bool isBuffered ) const;
1832
1c4293cb
VZ
1833 /** Draws an expand/collapse (ie. +/-) button.
1834 */
1835 virtual void DrawExpanderButton( wxDC& dc, const wxRect& rect,
1836 wxPGProperty* property ) const;
1837
1838 /** Draws items from topitemy to bottomitemy */
1839 void DrawItems( wxDC& dc, unsigned int topitemy, unsigned int bottomitemy,
1840 const wxRect* clip_rect = (const wxRect*) NULL );
1841
1c4293cb
VZ
1842 // Translate wxKeyEvent to wxPG_ACTION_XXX
1843 int KeyEventToActions(wxKeyEvent &event, int* pSecond) const;
1844
1845 int KeyEventToAction(wxKeyEvent &event) const
1846 {
1847 return KeyEventToActions(event, NULL);
1848 }
1849
1850 void ImprovedClientToScreen( int* px, int* py );
1851
1852 // Called by focus event handlers. newFocused is the window that becomes
1853 // focused.
1854 void HandleFocusChange( wxWindow* newFocused );
1855
1856 /** Reloads all non-customized colours from system settings. */
1857 void RegainColours();
1858
1859 bool DoEditorValidate();
1860
fc72fab6
JS
1861 void DoSetSelection( const wxArrayPGProperty& newSelection,
1862 int selFlags = 0 );
1863
1864 bool DoAddToSelection( wxPGProperty* prop,
1865 int selFlags = 0 );
1866
1867 bool DoRemoveFromSelection( wxPGProperty* prop,
1868 int selFlags = 0 );
1869
1c4293cb
VZ
1870 wxPGProperty* DoGetItemAtY( int y ) const;
1871
1872 void DoSetSplitterPosition_( int newxpos,
1873 bool refresh = true,
1874 int splitterIndex = 0,
1875 bool allPages = false );
1876
1877 void FreeEditors();
1878
1879 virtual bool DoExpand( wxPGProperty* p, bool sendEvent = false );
1880
1881 virtual bool DoCollapse( wxPGProperty* p, bool sendEvent = false );
1882
1883 // Returns nearest paint visible property (such that will be painted unless
1884 // window is scrolled or resized). If given property is paint visible, then
1885 // it itself will be returned.
1886 wxPGProperty* GetNearestPaintVisible( wxPGProperty* p ) const;
1887
1888 static void RegisterDefaultEditors();
1889
d9fb481c 1890 // Sets up basic event handling for child control
28fb19ef 1891 void SetupChildEventHandling( wxWindow* wnd );
1c4293cb
VZ
1892
1893 void CustomSetCursor( int type, bool override = false );
1894
1c4293cb
VZ
1895 /**
1896 Repositions scrollbar and underlying panel according to changed virtual
1897 size.
1898 */
1899 void RecalculateVirtualSize( int forceXPos = -1 );
1900
1901 void PrepareAfterItemsAdded();
1902
1903 bool SendEvent( int eventType,
1904 wxPGProperty* p,
1905 wxVariant* pValue = NULL,
1906 unsigned int selFlags = 0 );
1907
0ca422ef 1908 void SetFocusOnCanvas();
c29e714c 1909
1c4293cb
VZ
1910 bool DoHideProperty( wxPGProperty* p, bool hide, int flags );
1911
1912private:
1913
1766bf34 1914 bool ButtonTriggerKeyTest( int action, wxKeyEvent& event );
1c4293cb 1915
1c4293cb
VZ
1916 DECLARE_EVENT_TABLE()
1917#endif // #ifndef SWIG
1918};
1919
1920// -----------------------------------------------------------------------
1921//
1922// Bunch of inlines that need to resolved after all classes have been defined.
1923//
1924
1925#ifndef SWIG
1926inline bool wxPropertyGridPageState::IsDisplayed() const
1927{
1928 return ( this == m_pPropGrid->GetState() );
1929}
1930
1931inline unsigned int wxPropertyGridPageState::GetActualVirtualHeight() const
1932{
1933 return DoGetRoot()->GetChildrenHeight(GetGrid()->GetRowHeight());
1934}
1935#endif
1936
1937inline int wxPGProperty::GetDisplayedCommonValueCount() const
1938{
1939 if ( HasFlag(wxPG_PROP_USES_COMMON_VALUE) )
1940 {
1941 wxPropertyGrid* pg = GetGrid();
1942 if ( pg )
68bcfd2c 1943 return (int) pg->GetCommonValueCount();
1c4293cb
VZ
1944 }
1945 return 0;
1946}
1947
0ce8e27f
JS
1948inline void wxPGProperty::SetDefaultValue( wxVariant& value )
1949{
1950 SetAttribute(wxPG_ATTR_DEFAULT_VALUE, value);
1951}
1952
1c4293cb
VZ
1953inline void wxPGProperty::SetEditor( const wxString& editorName )
1954{
1955 m_customEditor = wxPropertyGridInterface::GetEditorByName(editorName);
1956}
1957
1c4293cb
VZ
1958inline bool wxPGProperty::Hide( bool hide, int flags )
1959{
1960 return GetGrid()->HideProperty(this, hide, flags);
1961}
1962
1963inline bool wxPGProperty::SetMaxLength( int maxLen )
1964{
1965 return GetGrid()->SetPropertyMaxLength(this,maxLen);
1966}
1967
1968// -----------------------------------------------------------------------
1969
c5bb5453 1970#define wxPG_BASE_EVT_PRE_ID 1775
1c4293cb
VZ
1971
1972#ifndef SWIG
1973
9b11752c
VZ
1974wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_SELECTED, wxPropertyGridEvent );
1975wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_CHANGING, wxPropertyGridEvent );
1976wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_CHANGED, wxPropertyGridEvent );
1977wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_HIGHLIGHTED, wxPropertyGridEvent );
1978wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_RIGHT_CLICK, wxPropertyGridEvent );
1979wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_PAGE_CHANGED, wxPropertyGridEvent );
1980wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_ITEM_COLLAPSED, wxPropertyGridEvent );
1981wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_ITEM_EXPANDED, wxPropertyGridEvent );
1982wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_PROPGRID, wxEVT_PG_DOUBLE_CLICK, wxPropertyGridEvent );
1c4293cb 1983
1c4293cb
VZ
1984#else
1985 enum {
1986 wxEVT_PG_SELECTED = wxPG_BASE_EVT_PRE_ID,
1987 wxEVT_PG_CHANGING,
1988 wxEVT_PG_CHANGED,
1989 wxEVT_PG_HIGHLIGHTED,
1990 wxEVT_PG_RIGHT_CLICK,
1991 wxEVT_PG_PAGE_CHANGED,
1992 wxEVT_PG_ITEM_COLLAPSED,
1993 wxEVT_PG_ITEM_EXPANDED,
1994 wxEVT_PG_DOUBLE_CLICK
1995 };
1996#endif
1997
1998
1999#define wxPG_BASE_EVT_TYPE wxEVT_PG_SELECTED
2000#define wxPG_MAX_EVT_TYPE (wxPG_BASE_EVT_TYPE+30)
2001
2002
2003#ifndef SWIG
2004typedef void (wxEvtHandler::*wxPropertyGridEventFunction)(wxPropertyGridEvent&);
2005
d3b9f782
VZ
2006#define EVT_PG_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_SELECTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2007#define EVT_PG_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGING, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2008#define EVT_PG_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2009#define EVT_PG_HIGHLIGHTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_HIGHLIGHTED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2010#define EVT_PG_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_RIGHT_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2011#define EVT_PG_DOUBLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_DOUBLE_CLICK, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2012#define EVT_PG_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_PAGE_CHANGED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2013#define EVT_PG_ITEM_COLLAPSED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_COLLAPSED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
2014#define EVT_PG_ITEM_EXPANDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_PG_ITEM_EXPANDED, id, -1, wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn ), NULL ),
3c778901
VZ
2015
2016#define wxPropertyGridEventHandler(fn) \
2017 wxEVENT_HANDLER_CAST( wxPropertyGridEventFunction, fn )
1c4293cb
VZ
2018
2019#endif
2020
2021
2022/** @class wxPropertyGridEvent
2023
2024 A propertygrid event holds information about events associated with
2025 wxPropertyGrid objects.
2026
2027 @library{wxpropgrid}
2028 @category{propgrid}
2029*/
2030class WXDLLIMPEXP_PROPGRID wxPropertyGridEvent : public wxCommandEvent
2031{
2032public:
2033
2034 /** Constructor. */
2035 wxPropertyGridEvent(wxEventType commandType=0, int id=0);
2036#ifndef SWIG
2037 /** Copy constructor. */
2038 wxPropertyGridEvent(const wxPropertyGridEvent& event);
2039#endif
2040 /** Destructor. */
2041 ~wxPropertyGridEvent();
2042
2043 /** Copyer. */
2044 virtual wxEvent* Clone() const;
2045
2046 wxPGProperty* GetMainParent() const
2047 {
2048 wxASSERT(m_property);
2049 return m_property->GetMainParent();
2050 }
2051
2052 /** Returns id of associated property. */
2053 wxPGProperty* GetProperty() const
2054 {
2055 return m_property;
2056 }
2057
2058 wxPGValidationInfo& GetValidationInfo()
2059 {
2060 wxASSERT(m_validationInfo);
2061 return *m_validationInfo;
2062 }
2063
1c4293cb
VZ
2064 /** Returns true if you can veto the action that the event is signaling.
2065 */
2066 bool CanVeto() const { return m_canVeto; }
2067
2068 /**
2069 Call this from your event handler to veto action that the event is
2070 signaling.
2071
2072 You can only veto a shutdown if wxPropertyGridEvent::CanVeto returns
2073 true.
2074 @remarks
2075 Currently only wxEVT_PG_CHANGING supports vetoing.
2076 */
2077 void Veto( bool veto = true ) { m_wasVetoed = veto; }
2078
2079 /** Returns value that is about to be set for wxEVT_PG_CHANGING.
2080 */
2081 const wxVariant& GetValue() const
2082 {
2083 wxASSERT_MSG( m_validationInfo,
2084 "Only call GetValue from a handler "
2085 "of event type that supports it" );
2a8312bc 2086 return m_validationInfo->GetValue();
1c4293cb
VZ
2087 }
2088
2089 /**
2090 Set override validation failure behavior.
2091
2092 Only effective if Veto was also called, and only allowed if event type
2093 is wxEVT_PG_CHANGING.
2094 */
2a8312bc 2095 void SetValidationFailureBehavior( wxPGVFBFlags flags )
1c4293cb
VZ
2096 {
2097 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
2a8312bc 2098 m_validationInfo->SetFailureBehavior( flags );
1c4293cb
VZ
2099 }
2100
2101 /** Sets custom failure message for this time only. Only applies if
2102 wxPG_VFB_SHOW_MESSAGE is set in validation failure flags.
2103 */
2104 void SetValidationFailureMessage( const wxString& message )
2105 {
2106 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
2a8312bc 2107 m_validationInfo->SetFailureMessage( message );
1c4293cb
VZ
2108 }
2109
2110#ifndef SWIG
2111 wxPGVFBFlags GetValidationFailureBehavior() const
2112 {
2113 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
2a8312bc 2114 return m_validationInfo->GetFailureBehavior();
1c4293cb
VZ
2115 }
2116
2117 void SetCanVeto( bool canVeto ) { m_canVeto = canVeto; }
2118 bool WasVetoed() const { return m_wasVetoed; }
2119
2120 /** Changes the associated property. */
2121 void SetProperty( wxPGProperty* p ) { m_property = p; }
2122
2123 void SetPropertyGrid( wxPropertyGrid* pg ) { m_pg = pg; }
2124
2125 void SetupValidationInfo()
2126 {
2127 wxASSERT(m_pg);
2128 wxASSERT( GetEventType() == wxEVT_PG_CHANGING );
2129 m_validationInfo = &m_pg->GetValidationInfo();
2130 }
2131
2132private:
2133 void Init();
2134 DECLARE_DYNAMIC_CLASS(wxPropertyGridEvent)
2135
2136 wxPGProperty* m_property;
2137 wxPropertyGrid* m_pg;
2138 wxPGValidationInfo* m_validationInfo;
2139
2140 bool m_canVeto;
2141 bool m_wasVetoed;
2142
2143#endif
2144};
2145
2146
2147// -----------------------------------------------------------------------
2148
2149/** @class wxPropertyGridPopulator
2150 @ingroup classes
2151 Allows populating wxPropertyGrid from arbitrary text source.
2152*/
2153class WXDLLIMPEXP_PROPGRID wxPropertyGridPopulator
2154{
2155public:
2156 /** Default constructor.
2157 */
2158 wxPropertyGridPopulator();
2159
2160 /** Destructor. */
2161 virtual ~wxPropertyGridPopulator();
2162
2163 void SetState( wxPropertyGridPageState* state );
2164
2165 void SetGrid( wxPropertyGrid* pg );
2166
2167 /** Appends a new property under bottommost parent.
2168 @param propClass
2169 Property class as string.
2170 */
2171 wxPGProperty* Add( const wxString& propClass,
2172 const wxString& propLabel,
2173 const wxString& propName,
2174 const wxString* propValue,
2175 wxPGChoices* pChoices = NULL );
2176
2177 /**
2178 Pushes property to the back of parent array (ie it becomes bottommost
2179 parent), and starts scanning/adding children for it.
2180
2181 When finished, parent array is returned to the original state.
2182 */
2183 void AddChildren( wxPGProperty* property );
2184
2185 /** Adds attribute to the bottommost property.
2186 @param type
2187 Allowed values: "string", (same as string), "int", "bool". Empty string
2188 mean autodetect.
2189 */
2190 bool AddAttribute( const wxString& name,
2191 const wxString& type,
2192 const wxString& value );
2193
2194 /** Called once in AddChildren.
2195 */
2196 virtual void DoScanForChildren() = 0;
2197
2198 /**
2199 Returns id of parent property for which children can currently be
2200 added.
2201 */
2202 wxPGProperty* GetCurParent() const
2203 {
2204 return (wxPGProperty*) m_propHierarchy[m_propHierarchy.size()-1];
2205 }
2206
2207 wxPropertyGridPageState* GetState() { return m_state; }
2208 const wxPropertyGridPageState* GetState() const { return m_state; }
2209
2210 /** Like wxString::ToLong, except allows N% in addition of N.
2211 */
2212 static bool ToLongPCT( const wxString& s, long* pval, long max );
2213
2214 /** Parses strings of format "choice1"[=value1] ... "choiceN"[=valueN] into
2215 wxPGChoices. Registers parsed result using idString (if not empty).
2216 Also, if choices with given id already registered, then don't parse but
2217 return those choices instead.
2218 */
2219 wxPGChoices ParseChoices( const wxString& choicesString,
2220 const wxString& idString );
2221
2222 /** Implement in derived class to do custom process when an error occurs.
2223 Default implementation uses wxLogError.
2224 */
2225 virtual void ProcessError( const wxString& msg );
2226
2227protected:
2228
2229 /** Used property grid. */
2230 wxPropertyGrid* m_pg;
2231
2232 /** Used property grid state. */
2233 wxPropertyGridPageState* m_state;
2234
2235 /** Tree-hierarchy of added properties (that can have children). */
2236 wxArrayPGProperty m_propHierarchy;
2237
2238 /** Hashmap for string-id to wxPGChoicesData mapping. */
2239 wxPGHashMapS2P m_dictIdChoices;
2240};
2241
2242// -----------------------------------------------------------------------
2243
2244//
2245// Undefine macros that are not needed outside propertygrid sources
2246//
2247#ifndef __wxPG_SOURCE_FILE__
2248 #undef wxPG_FL_DESC_REFRESH_REQUIRED
2249 #undef wxPG_FL_SCROLLBAR_DETECTED
2250 #undef wxPG_FL_CREATEDSTATE
2251 #undef wxPG_FL_NOSTATUSBARHELP
2252 #undef wxPG_FL_SCROLLED
2253 #undef wxPG_FL_FOCUS_INSIDE_CHILD
2254 #undef wxPG_FL_FOCUS_INSIDE
2255 #undef wxPG_FL_MOUSE_INSIDE_CHILD
2256 #undef wxPG_FL_CUR_USES_CUSTOM_IMAGE
2257 #undef wxPG_FL_PRIMARY_FILLS_ENTIRE
2258 #undef wxPG_FL_VALUE_MODIFIED
2259 #undef wxPG_FL_MOUSE_INSIDE
2260 #undef wxPG_FL_FOCUSED
2261 #undef wxPG_FL_MOUSE_CAPTURED
2262 #undef wxPG_FL_INITIALIZED
2263 #undef wxPG_FL_ACTIVATION_BY_CLICK
2264 #undef wxPG_FL_DONT_CENTER_SPLITTER
2265 #undef wxPG_SUPPORT_TOOLTIPS
2266 #undef wxPG_DOUBLE_BUFFER
2267 #undef wxPG_ICON_WIDTH
2268 #undef wxPG_USE_RENDERER_NATIVE
2269// Following are needed by the manager headers
2270// #undef const wxString&
2271#endif
2272
1c4293cb
VZ
2273// -----------------------------------------------------------------------
2274
f4bc1aa2
JS
2275#endif
2276
1c4293cb
VZ
2277#endif // _WX_PROPGRID_PROPGRID_H_
2278