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