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