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