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