1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/propgrid/propgrid.cpp
3 // Purpose: wxPropertyGrid
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/object.h"
25 #include "wx/string.h"
28 #include "wx/window.h"
31 #include "wx/dcmemory.h"
32 #include "wx/button.h"
35 #include "wx/cursor.h"
36 #include "wx/dialog.h"
37 #include "wx/settings.h"
38 #include "wx/msgdlg.h"
39 #include "wx/choice.h"
40 #include "wx/stattext.h"
41 #include "wx/scrolwin.h"
42 #include "wx/dirdlg.h"
44 #include "wx/textdlg.h"
45 #include "wx/filedlg.h"
46 #include "wx/statusbr.h"
52 // This define is necessary to prevent macro clearing
53 #define __wxPG_SOURCE_FILE__
55 #include "wx/propgrid/propgrid.h"
56 #include "wx/propgrid/editors.h"
58 #if wxPG_USE_RENDERER_NATIVE
59 #include "wx/renderer.h"
62 #include "wx/odcombo.h"
65 #include "wx/dcbuffer.h"
67 // Two pics for the expand / collapse buttons.
68 // Files are not supplied with this project (since it is
69 // recommended to use either custom or native rendering).
70 // If you want them, get wxTreeMultiCtrl by Jorgen Bodde,
71 // and copy xpm files from archive to wxPropertyGrid src directory
72 // (and also comment/undef wxPG_ICON_WIDTH in propGrid.h
73 // and set wxPG_USE_RENDERER_NATIVE to 0).
74 #ifndef wxPG_ICON_WIDTH
75 #if defined(__WXMAC__)
76 #include "mac_collapse.xpm"
77 #include "mac_expand.xpm"
78 #elif defined(__WXGTK__)
79 #include "linux_collapse.xpm"
80 #include "linux_expand.xpm"
82 #include "default_collapse.xpm"
83 #include "default_expand.xpm"
88 //#define wxPG_TEXT_INDENT 4 // For the wxComboControl
89 //#define wxPG_ALLOW_CLIPPING 1 // If 1, GetUpdateRegion() in OnPaint event handler is not ignored
90 #define wxPG_GUTTER_DIV 3 // gutter is max(iconwidth/gutter_div,gutter_min)
91 #define wxPG_GUTTER_MIN 3 // gutter before and after image of [+] or [-]
92 #define wxPG_YSPACING_MIN 1
93 #define wxPG_DEFAULT_VSPACING 2 // This matches .NET propertygrid's value,
94 // but causes normal combobox to spill out under MSW
96 //#define wxPG_OPTIMAL_WIDTH 200 // Arbitrary
98 //#define wxPG_MIN_SCROLLBAR_WIDTH 10 // Smallest scrollbar width on any platform
99 // Must be larger than largest control border
103 #define wxPG_DEFAULT_CURSOR wxNullCursor
106 //#define wxPG_NAT_CHOICE_BORDER_ANY 0
108 //#define wxPG_HIDER_BUTTON_HEIGHT 25
110 #define wxPG_PIXELS_PER_UNIT m_lineHeight
112 #ifdef wxPG_ICON_WIDTH
113 #define m_iconHeight m_iconWidth
116 //#define wxPG_TOOLTIP_DELAY 1000
118 // This is the number of pixels the expander button inside
119 // property cells (i.e. not in the grey margin area are
121 #define IN_CELL_EXPANDER_BUTTON_X_ADJUST 2
123 // -----------------------------------------------------------------------
126 void wxPropertyGrid::AutoGetTranslation ( bool enable
)
128 wxPGGlobalVars
->m_autoGetTranslation
= enable
;
131 void wxPropertyGrid::AutoGetTranslation ( bool ) { }
134 // -----------------------------------------------------------------------
136 const char wxPropertyGridNameStr
[] = "wxPropertyGrid";
138 // -----------------------------------------------------------------------
139 // Statics in one class for easy destruction.
140 // -----------------------------------------------------------------------
142 #include "wx/module.h"
144 class wxPGGlobalVarsClassManager
: public wxModule
146 DECLARE_DYNAMIC_CLASS(wxPGGlobalVarsClassManager
)
148 wxPGGlobalVarsClassManager() {}
149 virtual bool OnInit() { wxPGGlobalVars
= new wxPGGlobalVarsClass(); return true; }
150 virtual void OnExit() { delete wxPGGlobalVars
; wxPGGlobalVars
= NULL
; }
153 IMPLEMENT_DYNAMIC_CLASS(wxPGGlobalVarsClassManager
, wxModule
)
156 // When wxPG is loaded dynamically after the application is already running
157 // then the built-in module system won't pick this one up. Add it manually.
158 void wxPGInitResourceModule()
160 wxModule
* module = new wxPGGlobalVarsClassManager
;
162 wxModule::RegisterModule(module);
165 wxPGGlobalVarsClass
* wxPGGlobalVars
= NULL
;
168 wxPGGlobalVarsClass::wxPGGlobalVarsClass()
170 wxPGProperty::sm_wxPG_LABEL
= new wxString(wxPG_LABEL_STRING
);
172 m_boolChoices
.Add(_("False"));
173 m_boolChoices
.Add(_("True"));
175 m_fontFamilyChoices
= NULL
;
177 m_defaultRenderer
= new wxPGDefaultRenderer();
179 m_autoGetTranslation
= false;
187 // Prepare some shared variants
188 m_vEmptyString
= wxString();
190 m_vMinusOne
= (long) -1;
194 // Prepare cached string constants
195 m_strstring
= wxS("string");
196 m_strlong
= wxS("long");
197 m_strbool
= wxS("bool");
198 m_strlist
= wxS("list");
199 m_strDefaultValue
= wxS("DefaultValue");
200 m_strMin
= wxS("Min");
201 m_strMax
= wxS("Max");
202 m_strUnits
= wxS("Units");
203 m_strInlineHelp
= wxS("InlineHelp");
209 wxPGGlobalVarsClass::~wxPGGlobalVarsClass()
213 delete m_defaultRenderer
;
215 // This will always have one ref
216 delete m_fontFamilyChoices
;
219 for ( i
=0; i
<m_arrValidators
.size(); i
++ )
220 delete ((wxValidator
*)m_arrValidators
[i
]);
224 // Destroy value type class instances.
225 wxPGHashMapS2P::iterator vt_it
;
227 // Destroy editor class instances.
228 // iterate over all the elements in the class
229 for( vt_it
= m_mapEditorClasses
.begin(); vt_it
!= m_mapEditorClasses
.end(); ++vt_it
)
231 delete ((wxPGEditor
*)vt_it
->second
);
234 delete wxPGProperty::sm_wxPG_LABEL
;
237 void wxPropertyGridInitGlobalsIfNeeded()
241 // -----------------------------------------------------------------------
243 // -----------------------------------------------------------------------
245 IMPLEMENT_DYNAMIC_CLASS(wxPropertyGrid
, wxScrolledWindow
)
247 BEGIN_EVENT_TABLE(wxPropertyGrid
, wxScrolledWindow
)
248 EVT_IDLE(wxPropertyGrid::OnIdle
)
249 EVT_PAINT(wxPropertyGrid::OnPaint
)
250 EVT_SIZE(wxPropertyGrid::OnResize
)
251 EVT_ENTER_WINDOW(wxPropertyGrid::OnMouseEntry
)
252 EVT_LEAVE_WINDOW(wxPropertyGrid::OnMouseEntry
)
253 EVT_MOUSE_CAPTURE_CHANGED(wxPropertyGrid::OnCaptureChange
)
254 EVT_SCROLLWIN(wxPropertyGrid::OnScrollEvent
)
255 EVT_CHILD_FOCUS(wxPropertyGrid::OnChildFocusEvent
)
256 EVT_SET_FOCUS(wxPropertyGrid::OnFocusEvent
)
257 EVT_KILL_FOCUS(wxPropertyGrid::OnFocusEvent
)
258 EVT_SYS_COLOUR_CHANGED(wxPropertyGrid::OnSysColourChanged
)
259 EVT_MOTION(wxPropertyGrid::OnMouseMove
)
260 EVT_LEFT_DOWN(wxPropertyGrid::OnMouseClick
)
261 EVT_LEFT_UP(wxPropertyGrid::OnMouseUp
)
262 EVT_RIGHT_UP(wxPropertyGrid::OnMouseRightClick
)
263 EVT_LEFT_DCLICK(wxPropertyGrid::OnMouseDoubleClick
)
264 EVT_KEY_DOWN(wxPropertyGrid::OnKey
)
267 // -----------------------------------------------------------------------
269 wxPropertyGrid::wxPropertyGrid()
275 // -----------------------------------------------------------------------
277 wxPropertyGrid::wxPropertyGrid( wxWindow
*parent
,
282 const wxString
& name
)
286 Create(parent
,id
,pos
,size
,style
,name
);
289 // -----------------------------------------------------------------------
291 bool wxPropertyGrid::Create( wxWindow
*parent
,
296 const wxString
& name
)
299 if (!(style
&wxBORDER_MASK
))
301 style
|= wxBORDER_THEME
;
306 // Filter out wxTAB_TRAVERSAL - we will handle TABs manually
307 style
&= ~(wxTAB_TRAVERSAL
);
308 style
|= wxWANTS_CHARS
;
310 wxScrolledWindow::Create(parent
,id
,pos
,size
,style
,name
);
317 // -----------------------------------------------------------------------
320 // Initialize values to defaults
322 void wxPropertyGrid::Init1()
324 // Register editor classes, if necessary.
325 if ( wxPGGlobalVars
->m_mapEditorClasses
.empty() )
326 wxPropertyGrid::RegisterDefaultEditors();
330 m_wndEditor
= m_wndEditor2
= NULL
;
334 m_labelEditor
= NULL
;
335 m_labelEditorProperty
= NULL
;
336 m_eventObject
= this;
338 m_processedEvent
= NULL
;
339 m_sortFunction
= NULL
;
340 m_inDoPropertyChanged
= 0;
341 m_inCommitChangesFromEditor
= 0;
342 m_inDoSelectProperty
= 0;
343 m_permanentValidationFailureBehavior
= wxPG_VFB_DEFAULT
;
349 AddActionTrigger( wxPG_ACTION_NEXT_PROPERTY
, WXK_RIGHT
);
350 AddActionTrigger( wxPG_ACTION_NEXT_PROPERTY
, WXK_DOWN
);
351 AddActionTrigger( wxPG_ACTION_PREV_PROPERTY
, WXK_LEFT
);
352 AddActionTrigger( wxPG_ACTION_PREV_PROPERTY
, WXK_UP
);
353 AddActionTrigger( wxPG_ACTION_EXPAND_PROPERTY
, WXK_RIGHT
);
354 AddActionTrigger( wxPG_ACTION_COLLAPSE_PROPERTY
, WXK_LEFT
);
355 AddActionTrigger( wxPG_ACTION_CANCEL_EDIT
, WXK_ESCAPE
);
356 AddActionTrigger( wxPG_ACTION_PRESS_BUTTON
, WXK_DOWN
, wxMOD_ALT
);
357 AddActionTrigger( wxPG_ACTION_PRESS_BUTTON
, WXK_F4
);
359 m_coloursCustomized
= 0;
362 #if wxPG_DOUBLE_BUFFER
363 m_doubleBuffer
= NULL
;
366 #ifndef wxPG_ICON_WIDTH
372 m_iconWidth
= wxPG_ICON_WIDTH
;
377 m_gutterWidth
= wxPG_GUTTER_MIN
;
378 m_subgroup_extramargin
= 10;
382 m_width
= m_height
= 0;
384 m_commonValues
.push_back(new wxPGCommonValue(_("Unspecified"), wxPGGlobalVars
->m_defaultRenderer
) );
387 m_chgInfo_changedProperty
= NULL
;
390 // -----------------------------------------------------------------------
393 // Initialize after parent etc. set
395 void wxPropertyGrid::Init2()
397 wxASSERT( !(m_iFlags
& wxPG_FL_INITIALIZED
) );
400 // Smaller controls on Mac
401 SetWindowVariant(wxWINDOW_VARIANT_SMALL
);
404 // Now create state, if one didn't exist already
405 // (wxPropertyGridManager might have created it for us).
408 m_pState
= CreateState();
409 m_pState
->m_pPropGrid
= this;
410 m_iFlags
|= wxPG_FL_CREATEDSTATE
;
413 if ( !(m_windowStyle
& wxPG_SPLITTER_AUTO_CENTER
) )
414 m_pState
->m_dontCenterSplitter
= true;
416 if ( m_windowStyle
& wxPG_HIDE_CATEGORIES
)
418 m_pState
->InitNonCatMode();
420 m_pState
->m_properties
= m_pState
->m_abcArray
;
423 GetClientSize(&m_width
,&m_height
);
425 #ifndef wxPG_ICON_WIDTH
426 // create two bitmap nodes for drawing
427 m_expandbmp
= new wxBitmap(expand_xpm
);
428 m_collbmp
= new wxBitmap(collapse_xpm
);
430 // calculate average font height for bitmap centering
432 m_iconWidth
= m_expandbmp
->GetWidth();
433 m_iconHeight
= m_expandbmp
->GetHeight();
436 m_curcursor
= wxCURSOR_ARROW
;
437 m_cursorSizeWE
= new wxCursor( wxCURSOR_SIZEWE
);
439 // adjust bitmap icon y position so they are centered
440 m_vspacing
= wxPG_DEFAULT_VSPACING
;
442 CalculateFontAndBitmapStuff( wxPG_DEFAULT_VSPACING
);
444 // Allocate cell datas indirectly by calling setter
445 m_propertyDefaultCell
.SetBgCol(*wxBLACK
);
446 m_categoryDefaultCell
.SetBgCol(*wxBLACK
);
450 // This helps with flicker
451 SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
453 // Hook the top-level parent
458 // set virtual size to this window size
459 wxSize wndsize
= GetSize();
460 SetVirtualSize(wndsize
.GetWidth(), wndsize
.GetWidth());
462 m_timeCreated
= ::wxGetLocalTimeMillis();
464 //m_canvas->Create(this, wxID_ANY, wxPoint(0, 0), GetClientSize(),
465 // wxWANTS_CHARS | wxCLIP_CHILDREN);
466 SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
468 m_iFlags
|= wxPG_FL_INITIALIZED
;
470 m_ncWidth
= wndsize
.GetWidth();
472 // Need to call OnResize handler or size given in constructor/Create
474 wxSizeEvent
sizeEvent(wndsize
,0);
478 // -----------------------------------------------------------------------
480 wxPropertyGrid::~wxPropertyGrid()
485 wxCriticalSectionLocker(wxPGGlobalVars
->m_critSect
);
489 // Remove grid and property pointers from live wxPropertyGridEvents.
490 for ( i
=0; i
<m_liveEvents
.size(); i
++ )
492 wxPropertyGridEvent
* evt
= m_liveEvents
[i
];
493 evt
->SetPropertyGrid(NULL
);
494 evt
->SetProperty(NULL
);
496 m_liveEvents
.clear();
498 if ( m_processedEvent
)
500 // All right... we are being deleted while wxPropertyGrid event
501 // is being sent. Make sure that event propagates as little
502 // as possible (although usually this is not enough to prevent
504 m_processedEvent
->Skip(false);
505 m_processedEvent
->StopPropagation();
507 // Let's use wxMessageBox to make the message appear more
508 // reliably (and *before* the crash can happen).
509 ::wxMessageBox("wxPropertyGrid was being destroyed in an event "
510 "generated by it. This usually leads to a crash "
511 "so it is recommended to destroy the control "
512 "at idle time instead.");
515 DoSelectProperty(NULL
, wxPG_SEL_NOVALIDATE
|wxPG_SEL_DONT_SEND_EVENT
);
517 // This should do prevent things from going too badly wrong
518 m_iFlags
&= ~(wxPG_FL_INITIALIZED
);
520 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
523 // Call with NULL to disconnect event handling
524 if ( GetExtraStyle() & wxPG_EX_ENABLE_TLP_TRACKING
)
528 wxASSERT_MSG( !IsEditorsValueModified(),
529 wxS("Most recent change in property editor was ")
530 wxS("lost!!! (if you don't want this to happen, ")
531 wxS("close your frames and dialogs using ")
532 wxS("Close(false).)") );
535 #if wxPG_DOUBLE_BUFFER
536 if ( m_doubleBuffer
)
537 delete m_doubleBuffer
;
540 if ( m_iFlags
& wxPG_FL_CREATEDSTATE
)
543 delete m_cursorSizeWE
;
545 #ifndef wxPG_ICON_WIDTH
550 // Delete common value records
551 for ( i
=0; i
<m_commonValues
.size(); i
++ )
553 // Use temporary variable to work around possible strange VC6 (asserts because m_size is zero)
554 wxPGCommonValue
* value
= m_commonValues
[i
];
559 // -----------------------------------------------------------------------
561 bool wxPropertyGrid::Destroy()
563 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
566 return wxScrolledWindow::Destroy();
569 // -----------------------------------------------------------------------
571 wxPropertyGridPageState
* wxPropertyGrid::CreateState() const
573 return new wxPropertyGridPageState();
576 // -----------------------------------------------------------------------
577 // wxPropertyGrid overridden wxWindow methods
578 // -----------------------------------------------------------------------
580 void wxPropertyGrid::SetWindowStyleFlag( long style
)
582 long old_style
= m_windowStyle
;
584 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
586 wxASSERT( m_pState
);
588 if ( !(style
& wxPG_HIDE_CATEGORIES
) && (old_style
& wxPG_HIDE_CATEGORIES
) )
591 EnableCategories( true );
593 else if ( (style
& wxPG_HIDE_CATEGORIES
) && !(old_style
& wxPG_HIDE_CATEGORIES
) )
595 // Disable categories
596 EnableCategories( false );
598 if ( !(old_style
& wxPG_AUTO_SORT
) && (style
& wxPG_AUTO_SORT
) )
604 PrepareAfterItemsAdded();
606 m_pState
->m_itemsAdded
= 1;
608 #if wxPG_SUPPORT_TOOLTIPS
609 if ( !(old_style
& wxPG_TOOLTIPS
) && (style
& wxPG_TOOLTIPS
) )
615 wxToolTip* tooltip = new wxToolTip ( wxEmptyString );
616 SetToolTip ( tooltip );
617 tooltip->SetDelay ( wxPG_TOOLTIP_DELAY );
620 else if ( (old_style
& wxPG_TOOLTIPS
) && !(style
& wxPG_TOOLTIPS
) )
625 wxScrolledWindow::SetToolTip( NULL
);
630 wxScrolledWindow::SetWindowStyleFlag ( style
);
632 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
634 if ( (old_style
& wxPG_HIDE_MARGIN
) != (style
& wxPG_HIDE_MARGIN
) )
636 CalculateFontAndBitmapStuff( m_vspacing
);
642 // -----------------------------------------------------------------------
644 void wxPropertyGrid::Freeze()
648 wxScrolledWindow::Freeze();
653 // -----------------------------------------------------------------------
655 void wxPropertyGrid::Thaw()
661 wxScrolledWindow::Thaw();
662 RecalculateVirtualSize();
663 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
667 // Force property re-selection
668 // NB: We must copy the selection.
669 wxArrayPGProperty selection
= m_pState
->m_selection
;
670 DoSetSelection(selection
, wxPG_SEL_FORCE
| wxPG_SEL_NONVISIBLE
);
674 // -----------------------------------------------------------------------
676 bool wxPropertyGrid::DoAddToSelection( wxPGProperty
* prop
, int selFlags
)
678 wxCHECK( prop
, false );
680 if ( !(GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION
) )
681 return DoSelectProperty(prop
, selFlags
);
683 wxArrayPGProperty
& selection
= m_pState
->m_selection
;
685 if ( !selection
.size() )
687 return DoSelectProperty(prop
, selFlags
);
691 // For categories, only one can be selected at a time
692 if ( prop
->IsCategory() || selection
[0]->IsCategory() )
695 selection
.push_back(prop
);
697 if ( !(selFlags
& wxPG_SEL_DONT_SEND_EVENT
) )
699 SendEvent( wxEVT_PG_SELECTED
, prop
, NULL
);
708 // -----------------------------------------------------------------------
710 bool wxPropertyGrid::DoRemoveFromSelection( wxPGProperty
* prop
, int selFlags
)
712 wxCHECK( prop
, false );
715 wxArrayPGProperty
& selection
= m_pState
->m_selection
;
716 if ( selection
.size() <= 1 )
718 res
= DoSelectProperty(NULL
, selFlags
);
722 m_pState
->DoRemoveFromSelection(prop
);
730 // -----------------------------------------------------------------------
732 bool wxPropertyGrid::DoSelectAndEdit( wxPGProperty
* prop
,
733 unsigned int colIndex
,
734 unsigned int selFlags
)
737 // NB: Enable following if label editor background colour is
738 // ever changed to any other than m_colSelBack.
740 // We use this workaround to prevent visible flicker when editing
741 // a cell. Atleast on wxMSW, there is a difficult to find
742 // (and perhaps prevent) redraw somewhere between making property
743 // selected and enabling label editing.
745 //wxColour prevColSelBack = m_colSelBack;
746 //m_colSelBack = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
752 res
= DoSelectProperty(prop
, selFlags
);
757 DoClearSelection(false, wxPG_SEL_NO_REFRESH
);
759 if ( m_pState
->m_editableColumns
.Index(colIndex
) == wxNOT_FOUND
)
761 res
= DoAddToSelection(prop
, selFlags
);
765 res
= DoAddToSelection(prop
, selFlags
|wxPG_SEL_NO_REFRESH
);
767 DoBeginLabelEdit(colIndex
, selFlags
);
771 //m_colSelBack = prevColSelBack;
775 // -----------------------------------------------------------------------
777 bool wxPropertyGrid::AddToSelectionFromInputEvent( wxPGProperty
* prop
,
778 unsigned int colIndex
,
779 wxMouseEvent
* mouseEvent
,
782 const wxArrayPGProperty
& selection
= GetSelectedProperties();
783 bool alreadySelected
= m_pState
->DoIsPropertySelected(prop
);
786 // Set to 2 if also add all items in between
787 int addToExistingSelection
= 0;
789 if ( GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION
)
793 if ( mouseEvent
->GetEventType() == wxEVT_RIGHT_DOWN
||
794 mouseEvent
->GetEventType() == wxEVT_RIGHT_UP
)
796 // Allow right-click for context menu without
797 // disturbing the selection.
798 if ( GetSelectedProperties().size() <= 1 ||
800 return DoSelectAndEdit(prop
, colIndex
, selFlags
);
805 if ( mouseEvent
->ControlDown() )
807 addToExistingSelection
= 1;
809 else if ( mouseEvent
->ShiftDown() )
811 if ( selection
.size() > 0 && !prop
->IsCategory() )
812 addToExistingSelection
= 2;
814 addToExistingSelection
= 1;
820 if ( addToExistingSelection
== 1 )
823 if ( !alreadySelected
)
825 res
= DoAddToSelection(prop
, selFlags
);
827 else if ( GetSelectedProperties().size() > 1 )
829 res
= DoRemoveFromSelection(prop
, selFlags
);
832 else if ( addToExistingSelection
== 2 )
834 // Add this, and all in between
836 // Find top selected property
837 wxPGProperty
* topSelProp
= selection
[0];
838 int topSelPropY
= topSelProp
->GetY();
839 for ( unsigned int i
=1; i
<selection
.size(); i
++ )
841 wxPGProperty
* p
= selection
[i
];
843 if ( y
< topSelPropY
)
850 wxPGProperty
* startFrom
;
851 wxPGProperty
* stopAt
;
853 if ( prop
->GetY() <= topSelPropY
)
855 // Property is above selection (or same)
861 // Property is below selection
862 startFrom
= topSelProp
;
866 // Iterate through properties in-between, and select them
867 wxPropertyGridIterator it
;
869 for ( it
= GetIterator(wxPG_ITERATE_VISIBLE
, startFrom
);
873 wxPGProperty
* p
= *it
;
875 if ( !p
->IsCategory() &&
876 !m_pState
->DoIsPropertySelected(p
) )
878 DoAddToSelection(p
, selFlags
);
887 res
= DoSelectAndEdit(prop
, colIndex
, selFlags
);
893 // -----------------------------------------------------------------------
895 void wxPropertyGrid::DoSetSelection( const wxArrayPGProperty
& newSelection
,
898 if ( newSelection
.size() > 0 )
900 if ( !DoSelectProperty(newSelection
[0], selFlags
) )
905 DoClearSelection(false, selFlags
);
908 for ( unsigned int i
= 1; i
< newSelection
.size(); i
++ )
910 DoAddToSelection(newSelection
[i
], selFlags
);
916 // -----------------------------------------------------------------------
918 void wxPropertyGrid::MakeColumnEditable( unsigned int column
,
921 wxASSERT( column
!= 1 );
923 wxArrayInt
& cols
= m_pState
->m_editableColumns
;
927 cols
.push_back(column
);
931 for ( int i
= cols
.size() - 1; i
> 0; i
-- )
933 if ( cols
[i
] == (int)column
)
934 cols
.erase( cols
.begin() + i
);
939 // -----------------------------------------------------------------------
941 void wxPropertyGrid::DoBeginLabelEdit( unsigned int colIndex
,
944 wxPGProperty
* selected
= GetSelection();
945 wxCHECK_RET(selected
, wxT("No property selected"));
946 wxCHECK_RET(colIndex
!= 1, wxT("Do not use this for column 1"));
948 if ( !(selFlags
& wxPG_SEL_DONT_SEND_EVENT
) )
950 if ( SendEvent( wxEVT_PG_LABEL_EDIT_BEGIN
,
957 const wxPGCell
* cell
= NULL
;
958 if ( selected
->HasCell(colIndex
) )
960 cell
= &selected
->GetCell(colIndex
);
961 if ( !cell
->HasText() && colIndex
== 0 )
962 text
= selected
->GetLabel();
968 text
= selected
->GetLabel();
970 cell
= &selected
->GetOrCreateCell(colIndex
);
973 if ( cell
&& cell
->HasText() )
974 text
= cell
->GetText();
976 DoEndLabelEdit(true, wxPG_SEL_NOVALIDATE
); // send event
978 m_selColumn
= colIndex
;
980 wxRect r
= GetEditorWidgetRect(selected
, m_selColumn
);
982 wxWindow
* tc
= GenerateEditorTextCtrl(r
.GetPosition(),
990 wxWindowID id
= tc
->GetId();
991 tc
->Connect(id
, wxEVT_COMMAND_TEXT_ENTER
,
992 wxCommandEventHandler(wxPropertyGrid::OnLabelEditorEnterPress
),
994 tc
->Connect(id
, wxEVT_KEY_DOWN
,
995 wxKeyEventHandler(wxPropertyGrid::OnLabelEditorKeyPress
),
1000 m_labelEditor
= wxStaticCast(tc
, wxTextCtrl
);
1001 m_labelEditorProperty
= selected
;
1004 // -----------------------------------------------------------------------
1007 wxPropertyGrid::OnLabelEditorEnterPress( wxCommandEvent
& WXUNUSED(event
) )
1009 DoEndLabelEdit(true);
1012 // -----------------------------------------------------------------------
1014 void wxPropertyGrid::OnLabelEditorKeyPress( wxKeyEvent
& event
)
1016 int keycode
= event
.GetKeyCode();
1018 if ( keycode
== WXK_ESCAPE
)
1020 DoEndLabelEdit(false);
1028 // -----------------------------------------------------------------------
1030 void wxPropertyGrid::DoEndLabelEdit( bool commit
, int selFlags
)
1032 if ( !m_labelEditor
)
1035 wxPGProperty
* prop
= m_labelEditorProperty
;
1040 if ( !(selFlags
& wxPG_SEL_DONT_SEND_EVENT
) )
1042 // wxPG_SEL_NOVALIDATE is passed correctly in selFlags
1043 if ( SendEvent( wxEVT_PG_LABEL_EDIT_ENDING
,
1044 prop
, NULL
, selFlags
,
1049 wxString text
= m_labelEditor
->GetValue();
1050 wxPGCell
* cell
= NULL
;
1051 if ( prop
->HasCell(m_selColumn
) )
1053 cell
= &prop
->GetCell(m_selColumn
);
1057 if ( m_selColumn
== 0 )
1058 prop
->SetLabel(text
);
1060 cell
= &prop
->GetOrCreateCell(m_selColumn
);
1064 cell
->SetText(text
);
1069 DestroyEditorWnd(m_labelEditor
);
1070 m_labelEditor
= NULL
;
1071 m_labelEditorProperty
= NULL
;
1076 // -----------------------------------------------------------------------
1078 void wxPropertyGrid::SetExtraStyle( long exStyle
)
1080 if ( exStyle
& wxPG_EX_ENABLE_TLP_TRACKING
)
1081 OnTLPChanging(::wxGetTopLevelParent(this));
1083 OnTLPChanging(NULL
);
1085 if ( exStyle
& wxPG_EX_NATIVE_DOUBLE_BUFFERING
)
1087 #if defined(__WXMSW__)
1090 // Don't use WS_EX_COMPOSITED just now.
1093 if ( m_iFlags & wxPG_FL_IN_MANAGER )
1094 hWnd = (HWND)GetParent()->GetHWND();
1096 hWnd = (HWND)GetHWND();
1098 ::SetWindowLong( hWnd, GWL_EXSTYLE,
1099 ::GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_COMPOSITED );
1102 //#elif defined(__WXGTK20__)
1104 // Only apply wxPG_EX_NATIVE_DOUBLE_BUFFERING if the window
1105 // truly was double-buffered.
1106 if ( !this->IsDoubleBuffered() )
1108 exStyle
&= ~(wxPG_EX_NATIVE_DOUBLE_BUFFERING
);
1112 #if wxPG_DOUBLE_BUFFER
1113 delete m_doubleBuffer
;
1114 m_doubleBuffer
= NULL
;
1119 wxScrolledWindow::SetExtraStyle( exStyle
);
1121 if ( exStyle
& wxPG_EX_INIT_NOCAT
)
1122 m_pState
->InitNonCatMode();
1124 if ( exStyle
& wxPG_EX_HELP_AS_TOOLTIPS
)
1125 m_windowStyle
|= wxPG_TOOLTIPS
;
1128 wxPGGlobalVars
->m_extraStyle
= exStyle
;
1131 // -----------------------------------------------------------------------
1133 // returns the best acceptable minimal size
1134 wxSize
wxPropertyGrid::DoGetBestSize() const
1136 int lineHeight
= wxMax(15, m_lineHeight
);
1138 // don't make the grid too tall (limit height to 10 items) but don't
1139 // make it too small neither
1140 int numLines
= wxMin
1142 wxMax(m_pState
->m_properties
->GetChildCount(), 3),
1146 wxClientDC
dc(const_cast<wxPropertyGrid
*>(this));
1147 int width
= m_marginWidth
;
1148 for ( unsigned int i
= 0; i
< m_pState
->m_colWidths
.size(); i
++ )
1150 width
+= m_pState
->GetColumnFitWidth(dc
, m_pState
->DoGetRoot(), i
, true);
1153 const wxSize sz
= wxSize(width
, lineHeight
*numLines
+ 40);
1159 // -----------------------------------------------------------------------
1161 void wxPropertyGrid::OnTLPChanging( wxWindow
* newTLP
)
1163 if ( newTLP
== m_tlp
)
1166 wxLongLong currentTime
= ::wxGetLocalTimeMillis();
1169 // Parent changed so let's redetermine and re-hook the
1170 // correct top-level window.
1173 m_tlp
->Disconnect( wxEVT_CLOSE_WINDOW
,
1174 wxCloseEventHandler(wxPropertyGrid::OnTLPClose
),
1176 m_tlpClosed
= m_tlp
;
1177 m_tlpClosedTime
= currentTime
;
1182 // Only accept new tlp if same one was not just dismissed.
1183 if ( newTLP
!= m_tlpClosed
||
1184 m_tlpClosedTime
+250 < currentTime
)
1186 newTLP
->Connect( wxEVT_CLOSE_WINDOW
,
1187 wxCloseEventHandler(wxPropertyGrid::OnTLPClose
),
1200 // -----------------------------------------------------------------------
1202 void wxPropertyGrid::OnTLPClose( wxCloseEvent
& event
)
1204 // ClearSelection forces value validation/commit.
1205 if ( event
.CanVeto() && !DoClearSelection() )
1211 // Ok, it can close, set tlp pointer to NULL. Some other event
1212 // handler can of course veto the close, but our OnIdle() should
1213 // then be able to regain the tlp pointer.
1214 OnTLPChanging(NULL
);
1219 // -----------------------------------------------------------------------
1221 bool wxPropertyGrid::Reparent( wxWindowBase
*newParent
)
1223 OnTLPChanging((wxWindow
*)newParent
);
1225 bool res
= wxScrolledWindow::Reparent(newParent
);
1230 // -----------------------------------------------------------------------
1231 // wxPropertyGrid Font and Colour Methods
1232 // -----------------------------------------------------------------------
1234 void wxPropertyGrid::CalculateFontAndBitmapStuff( int vspacing
)
1238 m_captionFont
= wxScrolledWindow::GetFont();
1240 GetTextExtent(wxS("jG"), &x
, &y
, 0, 0, &m_captionFont
);
1241 m_subgroup_extramargin
= x
+ (x
/2);
1244 #if wxPG_USE_RENDERER_NATIVE
1245 m_iconWidth
= wxPG_ICON_WIDTH
;
1246 #elif wxPG_ICON_WIDTH
1248 m_iconWidth
= (m_fontHeight
* wxPG_ICON_WIDTH
) / 13;
1249 if ( m_iconWidth
< 5 ) m_iconWidth
= 5;
1250 else if ( !(m_iconWidth
& 0x01) ) m_iconWidth
++; // must be odd
1254 m_gutterWidth
= m_iconWidth
/ wxPG_GUTTER_DIV
;
1255 if ( m_gutterWidth
< wxPG_GUTTER_MIN
)
1256 m_gutterWidth
= wxPG_GUTTER_MIN
;
1259 if ( vspacing
<= 1 ) vdiv
= 12;
1260 else if ( vspacing
>= 3 ) vdiv
= 3;
1262 m_spacingy
= m_fontHeight
/ vdiv
;
1263 if ( m_spacingy
< wxPG_YSPACING_MIN
)
1264 m_spacingy
= wxPG_YSPACING_MIN
;
1267 if ( !(m_windowStyle
& wxPG_HIDE_MARGIN
) )
1268 m_marginWidth
= m_gutterWidth
*2 + m_iconWidth
;
1270 m_captionFont
.SetWeight(wxBOLD
);
1271 GetTextExtent(wxS("jG"), &x
, &y
, 0, 0, &m_captionFont
);
1273 m_lineHeight
= m_fontHeight
+(2*m_spacingy
)+1;
1276 m_buttonSpacingY
= (m_lineHeight
- m_iconHeight
) / 2;
1277 if ( m_buttonSpacingY
< 0 ) m_buttonSpacingY
= 0;
1280 m_pState
->CalculateFontAndBitmapStuff(vspacing
);
1282 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
1283 RecalculateVirtualSize();
1285 InvalidateBestSize();
1288 // -----------------------------------------------------------------------
1290 void wxPropertyGrid::OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) )
1296 // -----------------------------------------------------------------------
1298 static wxColour
wxPGAdjustColour(const wxColour
& src
, int ra
,
1299 int ga
= 1000, int ba
= 1000,
1300 bool forceDifferent
= false)
1307 // Recursion guard (allow 2 max)
1308 static int isinside
= 0;
1310 wxCHECK_MSG( isinside
< 3,
1312 wxT("wxPGAdjustColour should not be recursively called more than once") );
1317 int g
= src
.Green();
1320 if ( r2
>255 ) r2
= 255;
1321 else if ( r2
<0) r2
= 0;
1323 if ( g2
>255 ) g2
= 255;
1324 else if ( g2
<0) g2
= 0;
1326 if ( b2
>255 ) b2
= 255;
1327 else if ( b2
<0) b2
= 0;
1329 // Make sure they are somewhat different
1330 if ( forceDifferent
&& (abs((r
+g
+b
)-(r2
+g2
+b2
)) < abs(ra
/2)) )
1331 dst
= wxPGAdjustColour(src
,-(ra
*2));
1333 dst
= wxColour(r2
,g2
,b2
);
1335 // Recursion guard (allow 2 max)
1342 static int wxPGGetColAvg( const wxColour
& col
)
1344 return (col
.Red() + col
.Green() + col
.Blue()) / 3;
1348 void wxPropertyGrid::RegainColours()
1350 if ( !(m_coloursCustomized
& 0x0002) )
1352 wxColour col
= wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE
);
1354 // Make sure colour is dark enough
1356 int colDec
= wxPGGetColAvg(col
) - 230;
1358 int colDec
= wxPGGetColAvg(col
) - 200;
1361 m_colCapBack
= wxPGAdjustColour(col
,-colDec
);
1364 m_categoryDefaultCell
.GetData()->SetBgCol(m_colCapBack
);
1367 if ( !(m_coloursCustomized
& 0x0001) )
1368 m_colMargin
= m_colCapBack
;
1370 if ( !(m_coloursCustomized
& 0x0004) )
1377 wxColour capForeCol
= wxPGAdjustColour(m_colCapBack
,colDec
,5000,5000,true);
1378 m_colCapFore
= capForeCol
;
1379 m_categoryDefaultCell
.GetData()->SetFgCol(capForeCol
);
1382 if ( !(m_coloursCustomized
& 0x0008) )
1384 wxColour bgCol
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW
);
1385 m_colPropBack
= bgCol
;
1386 m_propertyDefaultCell
.GetData()->SetBgCol(bgCol
);
1389 if ( !(m_coloursCustomized
& 0x0010) )
1391 wxColour fgCol
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT
);
1392 m_colPropFore
= fgCol
;
1393 m_propertyDefaultCell
.GetData()->SetFgCol(fgCol
);
1396 if ( !(m_coloursCustomized
& 0x0020) )
1397 m_colSelBack
= wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT
);
1399 if ( !(m_coloursCustomized
& 0x0040) )
1400 m_colSelFore
= wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT
);
1402 if ( !(m_coloursCustomized
& 0x0080) )
1403 m_colLine
= m_colCapBack
;
1405 if ( !(m_coloursCustomized
& 0x0100) )
1406 m_colDisPropFore
= m_colCapFore
;
1408 m_colEmptySpace
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW
);
1411 // -----------------------------------------------------------------------
1413 void wxPropertyGrid::ResetColours()
1415 m_coloursCustomized
= 0;
1422 // -----------------------------------------------------------------------
1424 bool wxPropertyGrid::SetFont( const wxFont
& font
)
1426 // Must disable active editor.
1429 bool res
= wxScrolledWindow::SetFont( font
);
1430 if ( res
&& GetParent()) // may not have been Create()ed yet if SetFont called from SetWindowVariant
1432 CalculateFontAndBitmapStuff( m_vspacing
);
1439 // -----------------------------------------------------------------------
1441 void wxPropertyGrid::SetLineColour( const wxColour
& col
)
1444 m_coloursCustomized
|= 0x80;
1448 // -----------------------------------------------------------------------
1450 void wxPropertyGrid::SetMarginColour( const wxColour
& col
)
1453 m_coloursCustomized
|= 0x01;
1457 // -----------------------------------------------------------------------
1459 void wxPropertyGrid::SetCellBackgroundColour( const wxColour
& col
)
1461 m_colPropBack
= col
;
1462 m_coloursCustomized
|= 0x08;
1464 m_propertyDefaultCell
.GetData()->SetBgCol(col
);
1469 // -----------------------------------------------------------------------
1471 void wxPropertyGrid::SetCellTextColour( const wxColour
& col
)
1473 m_colPropFore
= col
;
1474 m_coloursCustomized
|= 0x10;
1476 m_propertyDefaultCell
.GetData()->SetFgCol(col
);
1481 // -----------------------------------------------------------------------
1483 void wxPropertyGrid::SetEmptySpaceColour( const wxColour
& col
)
1485 m_colEmptySpace
= col
;
1490 // -----------------------------------------------------------------------
1492 void wxPropertyGrid::SetCellDisabledTextColour( const wxColour
& col
)
1494 m_colDisPropFore
= col
;
1495 m_coloursCustomized
|= 0x100;
1499 // -----------------------------------------------------------------------
1501 void wxPropertyGrid::SetSelectionBackgroundColour( const wxColour
& col
)
1504 m_coloursCustomized
|= 0x20;
1508 // -----------------------------------------------------------------------
1510 void wxPropertyGrid::SetSelectionTextColour( const wxColour
& col
)
1513 m_coloursCustomized
|= 0x40;
1517 // -----------------------------------------------------------------------
1519 void wxPropertyGrid::SetCaptionBackgroundColour( const wxColour
& col
)
1522 m_coloursCustomized
|= 0x02;
1524 m_categoryDefaultCell
.GetData()->SetBgCol(col
);
1529 // -----------------------------------------------------------------------
1531 void wxPropertyGrid::SetCaptionTextColour( const wxColour
& col
)
1534 m_coloursCustomized
|= 0x04;
1536 m_categoryDefaultCell
.GetData()->SetFgCol(col
);
1541 // -----------------------------------------------------------------------
1542 // wxPropertyGrid property adding and removal
1543 // -----------------------------------------------------------------------
1545 void wxPropertyGrid::PrepareAfterItemsAdded()
1547 if ( !m_pState
|| !m_pState
->m_itemsAdded
) return;
1549 m_pState
->m_itemsAdded
= 0;
1551 if ( m_windowStyle
& wxPG_AUTO_SORT
)
1552 Sort(wxPG_SORT_TOP_LEVEL_ONLY
);
1554 RecalculateVirtualSize();
1557 // -----------------------------------------------------------------------
1558 // wxPropertyGrid property operations
1559 // -----------------------------------------------------------------------
1561 bool wxPropertyGrid::EnsureVisible( wxPGPropArg id
)
1563 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1567 bool changed
= false;
1569 // Is it inside collapsed section?
1570 if ( !p
->IsVisible() )
1573 wxPGProperty
* parent
= p
->GetParent();
1574 wxPGProperty
* grandparent
= parent
->GetParent();
1576 if ( grandparent
&& grandparent
!= m_pState
->m_properties
)
1577 Expand( grandparent
);
1585 GetViewStart(&vx
,&vy
);
1586 vy
*=wxPG_PIXELS_PER_UNIT
;
1592 Scroll(vx
, y
/wxPG_PIXELS_PER_UNIT
);
1593 m_iFlags
|= wxPG_FL_SCROLLED
;
1596 else if ( (y
+m_lineHeight
) > (vy
+m_height
) )
1598 Scroll(vx
, (y
-m_height
+(m_lineHeight
*2))/wxPG_PIXELS_PER_UNIT
);
1599 m_iFlags
|= wxPG_FL_SCROLLED
;
1609 // -----------------------------------------------------------------------
1610 // wxPropertyGrid helper methods called by properties
1611 // -----------------------------------------------------------------------
1613 // Control font changer helper.
1614 void wxPropertyGrid::SetCurControlBoldFont()
1616 wxASSERT( m_wndEditor
);
1617 m_wndEditor
->SetFont( m_captionFont
);
1620 // -----------------------------------------------------------------------
1622 wxPoint
wxPropertyGrid::GetGoodEditorDialogPosition( wxPGProperty
* p
,
1625 #if wxPG_SMALL_SCREEN
1626 // On small-screen devices, always show dialogs with default position and size.
1627 return wxDefaultPosition
;
1629 int splitterX
= GetSplitterPosition();
1633 wxCHECK_MSG( y
>= 0, wxPoint(-1,-1), wxT("invalid y?") );
1635 ImprovedClientToScreen( &x
, &y
);
1637 int sw
= wxSystemSettings::GetMetric( ::wxSYS_SCREEN_X
);
1638 int sh
= wxSystemSettings::GetMetric( ::wxSYS_SCREEN_Y
);
1645 new_x
= x
+ (m_width
-splitterX
) - sz
.x
;
1655 new_y
= y
+ m_lineHeight
;
1657 return wxPoint(new_x
,new_y
);
1661 // -----------------------------------------------------------------------
1663 wxString
& wxPropertyGrid::ExpandEscapeSequences( wxString
& dst_str
, wxString
& src_str
)
1665 if ( src_str
.length() == 0 )
1671 bool prev_is_slash
= false;
1673 wxString::const_iterator i
= src_str
.begin();
1677 for ( ; i
!= src_str
.end(); ++i
)
1681 if ( a
!= wxS('\\') )
1683 if ( !prev_is_slash
)
1689 if ( a
== wxS('n') )
1692 dst_str
<< wxS('\n');
1694 dst_str
<< wxS('\n');
1697 else if ( a
== wxS('t') )
1698 dst_str
<< wxS('\t');
1702 prev_is_slash
= false;
1706 if ( prev_is_slash
)
1708 dst_str
<< wxS('\\');
1709 prev_is_slash
= false;
1713 prev_is_slash
= true;
1720 // -----------------------------------------------------------------------
1722 wxString
& wxPropertyGrid::CreateEscapeSequences( wxString
& dst_str
, wxString
& src_str
)
1724 if ( src_str
.length() == 0 )
1730 wxString::const_iterator i
= src_str
.begin();
1731 wxUniChar prev_a
= wxS('\0');
1735 for ( ; i
!= src_str
.end(); ++i
)
1739 if ( a
>= wxS(' ') )
1741 // This surely is not something that requires an escape sequence.
1746 // This might need...
1747 if ( a
== wxS('\r') )
1749 // DOS style line end.
1750 // Already taken care below
1752 else if ( a
== wxS('\n') )
1753 // UNIX style line end.
1754 dst_str
<< wxS("\\n");
1755 else if ( a
== wxS('\t') )
1757 dst_str
<< wxS('\t');
1760 //wxLogDebug(wxT("WARNING: Could not create escape sequence for character #%i"),(int)a);
1770 // -----------------------------------------------------------------------
1772 wxPGProperty
* wxPropertyGrid::DoGetItemAtY( int y
) const
1779 return m_pState
->m_properties
->GetItemAtY(y
, m_lineHeight
, &a
);
1782 // -----------------------------------------------------------------------
1783 // wxPropertyGrid graphics related methods
1784 // -----------------------------------------------------------------------
1786 void wxPropertyGrid::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
1791 // Don't paint after destruction has begun
1792 if ( !HasInternalFlag(wxPG_FL_INITIALIZED
) )
1795 // Find out where the window is scrolled to
1796 int vx
,vy
; // Top left corner of client
1797 GetViewStart(&vx
,&vy
);
1798 vy
*= wxPG_PIXELS_PER_UNIT
;
1800 // Update everything inside the box
1801 wxRect r
= GetUpdateRegion().GetBox();
1805 // FIXME: This is just a workaround for a bug that causes splitters not
1806 // to paint when other windows are being dragged over the grid.
1808 r
.width
= GetClientSize().x
;
1810 // Repaint this rectangle
1811 DrawItems( dc
, r
.y
, r
.y
+ r
.height
, &r
);
1813 // We assume that the size set when grid is shown
1814 // is what is desired.
1815 SetInternalFlag(wxPG_FL_GOOD_SIZE_SET
);
1818 // -----------------------------------------------------------------------
1820 void wxPropertyGrid::DrawExpanderButton( wxDC
& dc
, const wxRect
& rect
,
1821 wxPGProperty
* property
) const
1823 // Prepare rectangle to be used
1825 r
.x
+= m_gutterWidth
; r
.y
+= m_buttonSpacingY
;
1826 r
.width
= m_iconWidth
; r
.height
= m_iconHeight
;
1828 #if (wxPG_USE_RENDERER_NATIVE)
1830 #elif wxPG_ICON_WIDTH
1831 // Drawing expand/collapse button manually
1832 dc
.SetPen(m_colPropFore
);
1833 if ( property
->IsCategory() )
1834 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
1836 dc
.SetBrush(m_colPropBack
);
1838 dc
.DrawRectangle( r
);
1839 int _y
= r
.y
+(m_iconWidth
/2);
1840 dc
.DrawLine(r
.x
+2,_y
,r
.x
+m_iconWidth
-2,_y
);
1845 if ( property
->IsExpanded() )
1847 // wxRenderer functions are non-mutating in nature, so it
1848 // should be safe to cast "const wxPropertyGrid*" to "wxWindow*".
1849 // Hopefully this does not cause problems.
1850 #if (wxPG_USE_RENDERER_NATIVE)
1851 wxRendererNative::Get().DrawTreeItemButton(
1857 #elif wxPG_ICON_WIDTH
1866 #if (wxPG_USE_RENDERER_NATIVE)
1867 wxRendererNative::Get().DrawTreeItemButton(
1873 #elif wxPG_ICON_WIDTH
1874 int _x
= r
.x
+(m_iconWidth
/2);
1875 dc
.DrawLine(_x
,r
.y
+2,_x
,r
.y
+m_iconWidth
-2);
1881 #if (wxPG_USE_RENDERER_NATIVE)
1883 #elif wxPG_ICON_WIDTH
1886 dc
.DrawBitmap( *bmp
, r
.x
, r
.y
, true );
1890 // -----------------------------------------------------------------------
1893 // This is the one called by OnPaint event handler and others.
1894 // topy and bottomy are already unscrolled (ie. physical)
1896 void wxPropertyGrid::DrawItems( wxDC
& dc
,
1897 unsigned int topItemY
,
1898 unsigned int bottomItemY
,
1899 const wxRect
* drawRect
)
1903 bottomItemY
< topItemY
||
1907 m_pState
->EnsureVirtualHeight();
1909 wxRect tempDrawRect
;
1912 tempDrawRect
= wxRect(0, topItemY
,
1915 drawRect
= &tempDrawRect
;
1918 // items added check
1919 if ( m_pState
->m_itemsAdded
) PrepareAfterItemsAdded();
1921 int paintFinishY
= 0;
1923 if ( m_pState
->m_properties
->GetChildCount() > 0 )
1926 bool isBuffered
= false;
1928 #if wxPG_DOUBLE_BUFFER
1929 wxMemoryDC
* bufferDC
= NULL
;
1931 if ( !(GetExtraStyle() & wxPG_EX_NATIVE_DOUBLE_BUFFERING
) )
1933 if ( !m_doubleBuffer
)
1935 paintFinishY
= drawRect
->y
;
1940 bufferDC
= new wxMemoryDC();
1942 // If nothing was changed, then just copy from double-buffer
1943 bufferDC
->SelectObject( *m_doubleBuffer
);
1953 dc
.SetClippingRegion( *drawRect
);
1954 paintFinishY
= DoDrawItems( *dcPtr
, drawRect
, isBuffered
);
1955 int drawBottomY
= drawRect
->y
+ drawRect
->height
;
1957 // Clear area beyond last painted property
1958 if ( paintFinishY
< drawBottomY
)
1960 dcPtr
->SetPen(m_colEmptySpace
);
1961 dcPtr
->SetBrush(m_colEmptySpace
);
1962 dcPtr
->DrawRectangle(0, paintFinishY
,
1967 dc
.DestroyClippingRegion();
1970 #if wxPG_DOUBLE_BUFFER
1973 dc
.Blit( drawRect
->x
, drawRect
->y
, drawRect
->width
,
1975 bufferDC
, 0, 0, wxCOPY
);
1982 // Just clear the area
1983 dc
.SetPen(m_colEmptySpace
);
1984 dc
.SetBrush(m_colEmptySpace
);
1985 dc
.DrawRectangle(*drawRect
);
1989 // -----------------------------------------------------------------------
1991 int wxPropertyGrid::DoDrawItems( wxDC
& dc
,
1992 const wxRect
* drawRect
,
1993 bool isBuffered
) const
1995 const wxPGProperty
* firstItem
;
1996 const wxPGProperty
* lastItem
;
1998 firstItem
= DoGetItemAtY(drawRect
->y
);
1999 lastItem
= DoGetItemAtY(drawRect
->y
+drawRect
->height
-1);
2002 lastItem
= GetLastItem( wxPG_ITERATE_VISIBLE
);
2004 if ( m_frozen
|| m_height
< 1 || firstItem
== NULL
)
2007 wxCHECK_MSG( !m_pState
->m_itemsAdded
, drawRect
->y
,
2009 wxASSERT( m_pState
->m_properties
->GetChildCount() );
2011 int lh
= m_lineHeight
;
2014 int lastItemBottomY
;
2016 firstItemTopY
= drawRect
->y
;
2017 lastItemBottomY
= drawRect
->y
+ drawRect
->height
;
2019 // Align y coordinates to item boundaries
2020 firstItemTopY
-= firstItemTopY
% lh
;
2021 lastItemBottomY
+= lh
- (lastItemBottomY
% lh
);
2022 lastItemBottomY
-= 1;
2024 // Entire range outside scrolled, visible area?
2025 if ( firstItemTopY
>= (int)m_pState
->GetVirtualHeight() ||
2026 lastItemBottomY
<= 0 )
2029 wxCHECK_MSG( firstItemTopY
< lastItemBottomY
,
2031 "invalid y values" );
2034 wxLogDebug(" -> DoDrawItems ( \"%s\" -> \"%s\"
2035 "height=%i (ch=%i), drawRect = 0x%lX )",
2036 firstItem->GetLabel().c_str(),
2037 lastItem->GetLabel().c_str(),
2038 (int)(lastItemBottomY - firstItemTopY),
2040 (unsigned long)drawRect );
2045 long windowStyle
= m_windowStyle
;
2050 // With wxPG_DOUBLE_BUFFER, do double buffering
2051 // - buffer's y = 0, so align drawRect and coordinates to that
2053 #if wxPG_DOUBLE_BUFFER
2060 xRelMod
= drawRect
->x
;
2061 yRelMod
= drawRect
->y
;
2064 // drawRect conversion
2069 firstItemTopY
-= yRelMod
;
2070 lastItemBottomY
-= yRelMod
;
2073 wxUnusedVar(isBuffered
);
2076 int x
= m_marginWidth
- xRelMod
;
2078 wxFont normalFont
= GetFont();
2080 bool reallyFocused
= (m_iFlags
& wxPG_FL_FOCUSED
) != 0;
2082 bool isPgEnabled
= IsEnabled();
2085 // Prepare some pens and brushes that are often changed to.
2088 wxBrush
marginBrush(m_colMargin
);
2089 wxPen
marginPen(m_colMargin
);
2090 wxBrush
capbgbrush(m_colCapBack
,wxSOLID
);
2091 wxPen
linepen(m_colLine
,1,wxSOLID
);
2093 wxColour selBackCol
;
2095 selBackCol
= m_colSelBack
;
2097 selBackCol
= m_colMargin
;
2099 // pen that has same colour as text
2100 wxPen
outlinepen(m_colPropFore
,1,wxSOLID
);
2103 // Clear margin with background colour
2105 dc
.SetBrush( marginBrush
);
2106 if ( !(windowStyle
& wxPG_HIDE_MARGIN
) )
2108 dc
.SetPen( *wxTRANSPARENT_PEN
);
2109 dc
.DrawRectangle(-1-xRelMod
,firstItemTopY
-1,x
+2,lastItemBottomY
-firstItemTopY
+2);
2112 const wxPGProperty
* firstSelected
= GetSelection();
2113 const wxPropertyGridPageState
* state
= m_pState
;
2115 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
2116 bool wasSelectedPainted
= false;
2119 // TODO: Only render columns that are within clipping region.
2121 dc
.SetFont(normalFont
);
2123 wxPropertyGridConstIterator
it( state
, wxPG_ITERATE_VISIBLE
, firstItem
);
2124 int endScanBottomY
= lastItemBottomY
+ lh
;
2125 int y
= firstItemTopY
;
2128 // Pregenerate list of visible properties.
2129 wxArrayPGProperty visPropArray
;
2130 visPropArray
.reserve((m_height
/m_lineHeight
)+6);
2132 for ( ; !it
.AtEnd(); it
.Next() )
2134 const wxPGProperty
* p
= *it
;
2136 if ( !p
->HasFlag(wxPG_PROP_HIDDEN
) )
2138 visPropArray
.push_back((wxPGProperty
*)p
);
2140 if ( y
> endScanBottomY
)
2147 visPropArray
.push_back(NULL
);
2149 wxPGProperty
* nextP
= visPropArray
[0];
2151 int gridWidth
= state
->m_width
;
2154 for ( unsigned int arrInd
=1;
2155 nextP
&& y
<= lastItemBottomY
;
2158 wxPGProperty
* p
= nextP
;
2159 nextP
= visPropArray
[arrInd
];
2161 int rowHeight
= m_fontHeight
+(m_spacingy
*2)+1;
2162 int textMarginHere
= x
;
2163 int renderFlags
= 0;
2165 int greyDepth
= m_marginWidth
;
2166 if ( !(windowStyle
& wxPG_HIDE_CATEGORIES
) )
2167 greyDepth
= (((int)p
->m_depthBgCol
)-1) * m_subgroup_extramargin
+ m_marginWidth
;
2169 int greyDepthX
= greyDepth
- xRelMod
;
2171 // Use basic depth if in non-categoric mode and parent is base array.
2172 if ( !(windowStyle
& wxPG_HIDE_CATEGORIES
) || p
->GetParent() != m_pState
->m_properties
)
2174 textMarginHere
+= ((unsigned int)((p
->m_depth
-1)*m_subgroup_extramargin
));
2177 // Paint margin area
2178 dc
.SetBrush(marginBrush
);
2179 dc
.SetPen(marginPen
);
2180 dc
.DrawRectangle( -xRelMod
, y
, greyDepth
, lh
);
2182 dc
.SetPen( linepen
);
2188 // Modified by JACS to not draw a margin if wxPG_HIDE_MARGIN is specified, since it
2189 // looks better, at least under Windows when we have a themed border (the themed-window-specific
2190 // whitespace between the real border and the propgrid margin exacerbates the double-border look).
2192 // Is this or its parent themed?
2193 bool suppressMarginEdge
= (GetWindowStyle() & wxPG_HIDE_MARGIN
) &&
2194 (((GetWindowStyle() & wxBORDER_MASK
) == wxBORDER_THEME
) ||
2195 (((GetWindowStyle() & wxBORDER_MASK
) == wxBORDER_NONE
) && ((GetParent()->GetWindowStyle() & wxBORDER_MASK
) == wxBORDER_THEME
)));
2197 bool suppressMarginEdge
= false;
2199 if (!suppressMarginEdge
)
2200 dc
.DrawLine( greyDepthX
, y
, greyDepthX
, y2
);
2203 // Blank out the margin edge
2204 dc
.SetPen(wxPen(GetBackgroundColour()));
2205 dc
.DrawLine( greyDepthX
, y
, greyDepthX
, y2
);
2206 dc
.SetPen( linepen
);
2213 for ( si
=0; si
<state
->m_colWidths
.size(); si
++ )
2215 sx
+= state
->m_colWidths
[si
];
2216 dc
.DrawLine( sx
, y
, sx
, y2
);
2219 // Horizontal Line, below
2220 // (not if both this and next is category caption)
2221 if ( p
->IsCategory() &&
2222 nextP
&& nextP
->IsCategory() )
2223 dc
.SetPen(m_colCapBack
);
2225 dc
.DrawLine( greyDepthX
, y2
-1, gridWidth
-xRelMod
, y2
-1 );
2228 // Need to override row colours?
2232 bool isSelected
= state
->DoIsPropertySelected(p
);
2236 // Disabled may get different colour.
2237 if ( !p
->IsEnabled() )
2239 renderFlags
|= wxPGCellRenderer::Disabled
|
2240 wxPGCellRenderer::DontUseCellFgCol
;
2241 rowFgCol
= m_colDisPropFore
;
2246 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
2247 if ( p
== firstSelected
)
2248 wasSelectedPainted
= true;
2251 renderFlags
|= wxPGCellRenderer::Selected
;
2253 if ( !p
->IsCategory() )
2255 renderFlags
|= wxPGCellRenderer::DontUseCellFgCol
|
2256 wxPGCellRenderer::DontUseCellBgCol
;
2258 if ( reallyFocused
&& p
== firstSelected
)
2260 rowFgCol
= m_colSelFore
;
2261 rowBgCol
= selBackCol
;
2263 else if ( isPgEnabled
)
2265 rowFgCol
= m_colPropFore
;
2266 if ( p
== firstSelected
)
2267 rowBgCol
= m_colMargin
;
2269 rowBgCol
= selBackCol
;
2273 rowFgCol
= m_colDisPropFore
;
2274 rowBgCol
= selBackCol
;
2281 if ( rowBgCol
.IsOk() )
2282 rowBgBrush
= wxBrush(rowBgCol
);
2284 if ( HasInternalFlag(wxPG_FL_CELL_OVERRIDES_SEL
) )
2285 renderFlags
= renderFlags
& ~wxPGCellRenderer::DontUseCellColours
;
2288 // Fill additional margin area with background colour of first cell
2289 if ( greyDepthX
< textMarginHere
)
2291 if ( !(renderFlags
& wxPGCellRenderer::DontUseCellBgCol
) )
2293 wxPGCell
& cell
= p
->GetCell(0);
2294 rowBgCol
= cell
.GetBgCol();
2295 rowBgBrush
= wxBrush(rowBgCol
);
2297 dc
.SetBrush(rowBgBrush
);
2298 dc
.SetPen(rowBgCol
);
2299 dc
.DrawRectangle(greyDepthX
+1, y
,
2300 textMarginHere
-greyDepthX
, lh
-1);
2303 bool fontChanged
= false;
2305 // Expander button rectangle
2306 wxRect
butRect( ((p
->m_depth
- 1) * m_subgroup_extramargin
) - xRelMod
,
2311 if ( p
->IsCategory() )
2313 // Captions have their cell areas merged as one
2314 dc
.SetFont(m_captionFont
);
2316 wxRect
cellRect(greyDepthX
, y
, gridWidth
- greyDepth
+ 2, rowHeight
-1 );
2318 if ( renderFlags
& wxPGCellRenderer::DontUseCellBgCol
)
2320 dc
.SetBrush(rowBgBrush
);
2321 dc
.SetPen(rowBgCol
);
2324 if ( renderFlags
& wxPGCellRenderer::DontUseCellFgCol
)
2326 dc
.SetTextForeground(rowFgCol
);
2329 wxPGCellRenderer
* renderer
= p
->GetCellRenderer(0);
2330 renderer
->Render( dc
, cellRect
, this, p
, 0, -1, renderFlags
);
2333 if ( !HasFlag(wxPG_HIDE_MARGIN
) && p
->HasVisibleChildren() )
2334 DrawExpanderButton( dc
, butRect
, p
);
2338 // Fine tune button rectangle to actually fit the cell
2339 if ( butRect
.x
> 0 )
2340 butRect
.x
+= IN_CELL_EXPANDER_BUTTON_X_ADJUST
;
2342 if ( p
->m_flags
& wxPG_PROP_MODIFIED
&& (windowStyle
& wxPG_BOLD_MODIFIED
) )
2344 dc
.SetFont(m_captionFont
);
2350 int nextCellWidth
= state
->m_colWidths
[0] -
2351 (greyDepthX
- m_marginWidth
);
2352 wxRect
cellRect(greyDepthX
+1, y
, 0, rowHeight
-1);
2353 int textXAdd
= textMarginHere
- greyDepthX
;
2355 for ( ci
=0; ci
<state
->m_colWidths
.size(); ci
++ )
2357 cellRect
.width
= nextCellWidth
- 1;
2359 wxWindow
* cellEditor
= NULL
;
2360 int cellRenderFlags
= renderFlags
;
2362 // Tree Item Button (must be drawn before clipping is set up)
2363 if ( ci
== 0 && !HasFlag(wxPG_HIDE_MARGIN
) && p
->HasVisibleChildren() )
2364 DrawExpanderButton( dc
, butRect
, p
);
2367 if ( isSelected
&& (ci
== 1 || ci
== m_selColumn
) )
2369 if ( p
== firstSelected
)
2371 if ( ci
== 1 && m_wndEditor
)
2372 cellEditor
= m_wndEditor
;
2373 else if ( ci
== m_selColumn
&& m_labelEditor
)
2374 cellEditor
= m_labelEditor
;
2379 wxColour editorBgCol
=
2380 cellEditor
->GetBackgroundColour();
2381 dc
.SetBrush(editorBgCol
);
2382 dc
.SetPen(editorBgCol
);
2383 dc
.SetTextForeground(m_colPropFore
);
2384 dc
.DrawRectangle(cellRect
);
2386 if ( m_dragStatus
!= 0 ||
2387 (m_iFlags
& wxPG_FL_CUR_USES_CUSTOM_IMAGE
) )
2392 dc
.SetBrush(m_colPropBack
);
2393 dc
.SetPen(m_colPropBack
);
2394 dc
.SetTextForeground(m_colDisPropFore
);
2395 if ( p
->IsEnabled() )
2396 dc
.SetTextForeground(rowFgCol
);
2398 dc
.SetTextForeground(m_colDisPropFore
);
2403 if ( renderFlags
& wxPGCellRenderer::DontUseCellBgCol
)
2405 dc
.SetBrush(rowBgBrush
);
2406 dc
.SetPen(rowBgCol
);
2409 if ( renderFlags
& wxPGCellRenderer::DontUseCellFgCol
)
2411 dc
.SetTextForeground(rowFgCol
);
2415 dc
.SetClippingRegion(cellRect
);
2417 cellRect
.x
+= textXAdd
;
2418 cellRect
.width
-= textXAdd
;
2423 wxPGCellRenderer
* renderer
;
2424 int cmnVal
= p
->GetCommonValue();
2425 if ( cmnVal
== -1 || ci
!= 1 )
2427 renderer
= p
->GetCellRenderer(ci
);
2428 renderer
->Render( dc
, cellRect
, this, p
, ci
, -1,
2433 renderer
= GetCommonValue(cmnVal
)->GetRenderer();
2434 renderer
->Render( dc
, cellRect
, this, p
, ci
, -1,
2439 cellX
+= state
->m_colWidths
[ci
];
2440 if ( ci
< (state
->m_colWidths
.size()-1) )
2441 nextCellWidth
= state
->m_colWidths
[ci
+1];
2443 dc
.DestroyClippingRegion(); // Is this really necessary?
2449 dc
.SetFont(normalFont
);
2454 // Refresh editor controls (seems not needed on msw)
2455 // NOTE: This code is mandatory for GTK!
2456 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
2457 if ( wasSelectedPainted
)
2460 m_wndEditor
->Refresh();
2462 m_wndEditor2
->Refresh();
2469 // -----------------------------------------------------------------------
2471 wxRect
wxPropertyGrid::GetPropertyRect( const wxPGProperty
* p1
, const wxPGProperty
* p2
) const
2475 if ( m_width
< 10 || m_height
< 10 ||
2476 !m_pState
->m_properties
->GetChildCount() ||
2478 return wxRect(0,0,0,0);
2483 // Return rect which encloses the given property range
2485 int visTop
= p1
->GetY();
2488 visBottom
= p2
->GetY() + m_lineHeight
;
2490 visBottom
= m_height
+ visTop
;
2492 // If seleced property is inside the range, we'll extend the range to include
2494 wxPGProperty
* selected
= GetSelection();
2497 int selectedY
= selected
->GetY();
2498 if ( selectedY
>= visTop
&& selectedY
< visBottom
)
2500 wxWindow
* editor
= GetEditorControl();
2503 int visBottom2
= selectedY
+ editor
->GetSize().y
;
2504 if ( visBottom2
> visBottom
)
2505 visBottom
= visBottom2
;
2510 return wxRect(0,visTop
-vy
,m_pState
->m_width
,visBottom
-visTop
);
2513 // -----------------------------------------------------------------------
2515 void wxPropertyGrid::DrawItems( const wxPGProperty
* p1
, const wxPGProperty
* p2
)
2520 if ( m_pState
->m_itemsAdded
)
2521 PrepareAfterItemsAdded();
2523 wxRect r
= GetPropertyRect(p1
, p2
);
2530 // -----------------------------------------------------------------------
2532 void wxPropertyGrid::RefreshProperty( wxPGProperty
* p
)
2534 if ( m_pState
->DoIsPropertySelected(p
) )
2536 // NB: We must copy the selection.
2537 wxArrayPGProperty selection
= m_pState
->m_selection
;
2538 DoSetSelection(selection
, wxPG_SEL_FORCE
);
2541 DrawItemAndChildren(p
);
2544 // -----------------------------------------------------------------------
2546 void wxPropertyGrid::DrawItemAndValueRelated( wxPGProperty
* p
)
2551 // Draw item, children, and parent too, if it is not category
2552 wxPGProperty
* parent
= p
->GetParent();
2555 !parent
->IsCategory() &&
2556 parent
->GetParent() )
2559 parent
= parent
->GetParent();
2562 DrawItemAndChildren(p
);
2565 void wxPropertyGrid::DrawItemAndChildren( wxPGProperty
* p
)
2567 wxCHECK_RET( p
, wxT("invalid property id") );
2569 // Do not draw if in non-visible page
2570 if ( p
->GetParentState() != m_pState
)
2573 // do not draw a single item if multiple pending
2574 if ( m_pState
->m_itemsAdded
|| m_frozen
)
2577 // Update child control.
2578 wxPGProperty
* selected
= GetSelection();
2579 if ( selected
&& selected
->GetParent() == p
)
2582 const wxPGProperty
* lastDrawn
= p
->GetLastVisibleSubItem();
2584 DrawItems(p
, lastDrawn
);
2587 // -----------------------------------------------------------------------
2589 void wxPropertyGrid::Refresh( bool WXUNUSED(eraseBackground
),
2590 const wxRect
*rect
)
2592 PrepareAfterItemsAdded();
2594 wxWindow::Refresh(false, rect
);
2596 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
2597 // I think this really helps only GTK+1.2
2598 if ( m_wndEditor
) m_wndEditor
->Refresh();
2599 if ( m_wndEditor2
) m_wndEditor2
->Refresh();
2603 // -----------------------------------------------------------------------
2604 // wxPropertyGrid global operations
2605 // -----------------------------------------------------------------------
2607 void wxPropertyGrid::Clear()
2609 m_pState
->DoClear();
2615 RecalculateVirtualSize();
2617 // Need to clear some area at the end
2619 RefreshRect(wxRect(0, 0, m_width
, m_height
));
2622 // -----------------------------------------------------------------------
2624 bool wxPropertyGrid::EnableCategories( bool enable
)
2631 // Enable categories
2634 m_windowStyle
&= ~(wxPG_HIDE_CATEGORIES
);
2639 // Disable categories
2641 m_windowStyle
|= wxPG_HIDE_CATEGORIES
;
2644 if ( !m_pState
->EnableCategories(enable
) )
2649 if ( m_windowStyle
& wxPG_AUTO_SORT
)
2651 m_pState
->m_itemsAdded
= 1; // force
2652 PrepareAfterItemsAdded();
2656 m_pState
->m_itemsAdded
= 1;
2658 // No need for RecalculateVirtualSize() here - it is already called in
2659 // wxPropertyGridPageState method above.
2666 // -----------------------------------------------------------------------
2668 void wxPropertyGrid::SwitchState( wxPropertyGridPageState
* pNewState
)
2670 wxASSERT( pNewState
);
2671 wxASSERT( pNewState
->GetGrid() );
2673 if ( pNewState
== m_pState
)
2676 wxArrayPGProperty oldSelection
= m_pState
->m_selection
;
2678 // Call ClearSelection() instead of DoClearSelection()
2679 // so that selection clear events are not sent.
2682 m_pState
->m_selection
= oldSelection
;
2684 bool orig_mode
= m_pState
->IsInNonCatMode();
2685 bool new_state_mode
= pNewState
->IsInNonCatMode();
2687 m_pState
= pNewState
;
2690 int pgWidth
= GetClientSize().x
;
2691 if ( HasVirtualWidth() )
2693 int minWidth
= pgWidth
;
2694 if ( pNewState
->m_width
< minWidth
)
2696 pNewState
->m_width
= minWidth
;
2697 pNewState
->CheckColumnWidths();
2703 // Just in case, fully re-center splitter
2704 //if ( HasFlag( wxPG_SPLITTER_AUTO_CENTER ) )
2705 // pNewState->m_fSplitterX = -1.0;
2707 pNewState
->OnClientWidthChange(pgWidth
,
2708 pgWidth
- pNewState
->m_width
);
2713 // If necessary, convert state to correct mode.
2714 if ( orig_mode
!= new_state_mode
)
2716 // This should refresh as well.
2717 EnableCategories( orig_mode
?false:true );
2719 else if ( !m_frozen
)
2721 // Refresh, if not frozen.
2722 m_pState
->PrepareAfterItemsAdded();
2724 // Reselect (Use SetSelection() instead of Do-variant so that
2725 // events won't be sent).
2726 SetSelection(m_pState
->m_selection
);
2728 RecalculateVirtualSize(0);
2732 m_pState
->m_itemsAdded
= 1;
2735 // -----------------------------------------------------------------------
2737 // Call to SetSplitterPosition will always disable splitter auto-centering
2738 // if parent window is shown.
2739 void wxPropertyGrid::DoSetSplitterPosition( int newxpos
,
2743 if ( ( newxpos
< wxPG_DRAG_MARGIN
) )
2746 wxPropertyGridPageState
* state
= m_pState
;
2748 if ( flags
& wxPG_SPLITTER_FROM_EVENT
)
2749 state
->m_dontCenterSplitter
= true;
2751 state
->DoSetSplitterPosition(newxpos
, splitterIndex
, flags
);
2753 if ( flags
& wxPG_SPLITTER_REFRESH
)
2755 if ( GetSelection() )
2756 CorrectEditorWidgetSizeX();
2764 // -----------------------------------------------------------------------
2766 void wxPropertyGrid::CenterSplitter( bool enableAutoCentering
)
2768 SetSplitterPosition( m_width
/2 );
2769 if ( enableAutoCentering
&& HasFlag(wxPG_SPLITTER_AUTO_CENTER
) )
2770 m_pState
->m_dontCenterSplitter
= false;
2773 // -----------------------------------------------------------------------
2774 // wxPropertyGrid item iteration (GetNextProperty etc.) methods
2775 // -----------------------------------------------------------------------
2777 // Returns nearest paint visible property (such that will be painted unless
2778 // window is scrolled or resized). If given property is paint visible, then
2779 // it itself will be returned
2780 wxPGProperty
* wxPropertyGrid::GetNearestPaintVisible( wxPGProperty
* p
) const
2782 int vx
,vy1
;// Top left corner of client
2783 GetViewStart(&vx
,&vy1
);
2784 vy1
*= wxPG_PIXELS_PER_UNIT
;
2786 int vy2
= vy1
+ m_height
;
2787 int propY
= p
->GetY2(m_lineHeight
);
2789 if ( (propY
+ m_lineHeight
) < vy1
)
2792 return DoGetItemAtY( vy1
);
2794 else if ( propY
> vy2
)
2797 return DoGetItemAtY( vy2
);
2800 // Itself paint visible
2805 // -----------------------------------------------------------------------
2806 // Methods related to change in value, value modification and sending events
2807 // -----------------------------------------------------------------------
2809 // commits any changes in editor of selected property
2810 // return true if validation did not fail
2811 // flags are same as with DoSelectProperty
2812 bool wxPropertyGrid::CommitChangesFromEditor( wxUint32 flags
)
2814 // Committing already?
2815 if ( m_inCommitChangesFromEditor
)
2818 // Don't do this if already processing editor event. It might
2819 // induce recursive dialogs and crap like that.
2820 if ( m_iFlags
& wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
)
2822 if ( m_inDoPropertyChanged
)
2828 wxPGProperty
* selected
= GetSelection();
2831 IsEditorsValueModified() &&
2832 (m_iFlags
& wxPG_FL_INITIALIZED
) &&
2835 m_inCommitChangesFromEditor
= 1;
2837 wxVariant
variant(selected
->GetValueRef());
2838 bool valueIsPending
= false;
2840 // JACS - necessary to avoid new focus being found spuriously within OnIdle
2841 // due to another window getting focus
2842 wxWindow
* oldFocus
= m_curFocused
;
2844 bool validationFailure
= false;
2845 bool forceSuccess
= (flags
& (wxPG_SEL_NOVALIDATE
|wxPG_SEL_FORCE
)) ? true : false;
2847 m_chgInfo_changedProperty
= NULL
;
2849 // If truly modified, schedule value as pending.
2850 if ( selected
->GetEditorClass()->
2851 GetValueFromControl( variant
,
2853 GetEditorControl() ) )
2855 if ( DoEditorValidate() &&
2856 PerformValidation(selected
, variant
) )
2858 valueIsPending
= true;
2862 validationFailure
= true;
2867 EditorsValueWasNotModified();
2872 m_inCommitChangesFromEditor
= 0;
2874 if ( validationFailure
&& !forceSuccess
)
2878 oldFocus
->SetFocus();
2879 m_curFocused
= oldFocus
;
2882 res
= OnValidationFailure(selected
, variant
);
2884 // Now prevent further validation failure messages
2887 EditorsValueWasNotModified();
2888 OnValidationFailureReset(selected
);
2891 else if ( valueIsPending
)
2893 DoPropertyChanged( selected
, flags
);
2894 EditorsValueWasNotModified();
2903 // -----------------------------------------------------------------------
2905 bool wxPropertyGrid::PerformValidation( wxPGProperty
* p
, wxVariant
& pendingValue
,
2909 // Runs all validation functionality.
2910 // Returns true if value passes all tests.
2913 m_validationInfo
.m_failureBehavior
= m_permanentValidationFailureBehavior
;
2916 // Variant list a special value that cannot be validated
2918 if ( pendingValue
.GetType() != wxPG_VARIANT_TYPE_LIST
)
2920 if ( !p
->ValidateValue(pendingValue
, m_validationInfo
) )
2925 // Adapt list to child values, if necessary
2926 wxVariant listValue
= pendingValue
;
2927 wxVariant
* pPendingValue
= &pendingValue
;
2928 wxVariant
* pList
= NULL
;
2930 // If parent has wxPG_PROP_AGGREGATE flag, or uses composite
2931 // string value, then we need treat as it was changed instead
2932 // (or, in addition, as is the case with composite string parent).
2933 // This includes creating list variant for child values.
2935 wxPGProperty
* pwc
= p
->GetParent();
2936 wxPGProperty
* changedProperty
= p
;
2937 wxPGProperty
* baseChangedProperty
= changedProperty
;
2938 wxVariant bcpPendingList
;
2940 listValue
= pendingValue
;
2941 listValue
.SetName(p
->GetBaseName());
2944 (pwc
->HasFlag(wxPG_PROP_AGGREGATE
) || pwc
->HasFlag(wxPG_PROP_COMPOSED_VALUE
)) )
2946 wxVariantList tempList
;
2947 wxVariant
lv(tempList
, pwc
->GetBaseName());
2948 lv
.Append(listValue
);
2950 pPendingValue
= &listValue
;
2952 if ( pwc
->HasFlag(wxPG_PROP_AGGREGATE
) )
2954 baseChangedProperty
= pwc
;
2955 bcpPendingList
= lv
;
2958 changedProperty
= pwc
;
2959 pwc
= pwc
->GetParent();
2963 wxPGProperty
* evtChangingProperty
= changedProperty
;
2965 if ( pPendingValue
->GetType() != wxPG_VARIANT_TYPE_LIST
)
2967 value
= *pPendingValue
;
2971 // Convert list to child values
2972 pList
= pPendingValue
;
2973 changedProperty
->AdaptListToValue( *pPendingValue
, &value
);
2976 wxVariant evtChangingValue
= value
;
2978 if ( flags
& SendEvtChanging
)
2980 // FIXME: After proper ValueToString()s added, remove
2981 // this. It is just a temporary fix, as evt_changing
2982 // will simply not work for wxPG_PROP_COMPOSED_VALUE
2983 // (unless it is selected, and textctrl editor is open).
2984 if ( changedProperty
->HasFlag(wxPG_PROP_COMPOSED_VALUE
) )
2986 evtChangingProperty
= baseChangedProperty
;
2987 if ( evtChangingProperty
!= p
)
2989 evtChangingProperty
->AdaptListToValue( bcpPendingList
, &evtChangingValue
);
2993 evtChangingValue
= pendingValue
;
2997 if ( evtChangingProperty
->HasFlag(wxPG_PROP_COMPOSED_VALUE
) )
2999 if ( changedProperty
== GetSelection() )
3001 wxWindow
* editor
= GetEditorControl();
3002 wxASSERT( editor
->IsKindOf(CLASSINFO(wxTextCtrl
)) );
3003 evtChangingValue
= wxStaticCast(editor
, wxTextCtrl
)->GetValue();
3007 wxLogDebug(wxT("WARNING: wxEVT_PG_CHANGING is about to happen with old value."));
3012 wxASSERT( m_chgInfo_changedProperty
== NULL
);
3013 m_chgInfo_changedProperty
= changedProperty
;
3014 m_chgInfo_baseChangedProperty
= baseChangedProperty
;
3015 m_chgInfo_pendingValue
= value
;
3018 m_chgInfo_valueList
= *pList
;
3020 m_chgInfo_valueList
.MakeNull();
3022 // If changedProperty is not property which value was edited,
3023 // then call wxPGProperty::ValidateValue() for that as well.
3024 if ( p
!= changedProperty
&& value
.GetType() != wxPG_VARIANT_TYPE_LIST
)
3026 if ( !changedProperty
->ValidateValue(value
, m_validationInfo
) )
3030 if ( flags
& SendEvtChanging
)
3032 // SendEvent returns true if event was vetoed
3033 if ( SendEvent( wxEVT_PG_CHANGING
, evtChangingProperty
,
3034 &evtChangingValue
) )
3038 if ( flags
& IsStandaloneValidation
)
3040 // If called in 'generic' context, we need to reset
3041 // m_chgInfo_changedProperty and write back translated value.
3042 m_chgInfo_changedProperty
= NULL
;
3043 pendingValue
= value
;
3049 // -----------------------------------------------------------------------
3051 void wxPropertyGrid::DoShowPropertyError( wxPGProperty
* WXUNUSED(property
), const wxString
& msg
)
3053 if ( !msg
.length() )
3057 if ( !wxPGGlobalVars
->m_offline
)
3059 wxWindow
* topWnd
= ::wxGetTopLevelParent(this);
3062 wxFrame
* pFrame
= wxDynamicCast(topWnd
, wxFrame
);
3065 wxStatusBar
* pStatusBar
= pFrame
->GetStatusBar();
3068 pStatusBar
->SetStatusText(msg
);
3076 ::wxMessageBox(msg
, wxT("Property Error"));
3079 // -----------------------------------------------------------------------
3081 bool wxPropertyGrid::OnValidationFailure( wxPGProperty
* property
,
3082 wxVariant
& invalidValue
)
3084 wxWindow
* editor
= GetEditorControl();
3086 // First call property's handler
3087 property
->OnValidationFailure(invalidValue
);
3089 bool res
= DoOnValidationFailure(property
, invalidValue
);
3092 // For non-wxTextCtrl editors, we do need to revert the value
3093 if ( !editor
->IsKindOf(CLASSINFO(wxTextCtrl
)) &&
3094 property
== GetSelection() )
3096 property
->GetEditorClass()->UpdateControl(property
, editor
);
3099 property
->SetFlag(wxPG_PROP_INVALID_VALUE
);
3104 bool wxPropertyGrid::DoOnValidationFailure( wxPGProperty
* property
, wxVariant
& WXUNUSED(invalidValue
) )
3106 int vfb
= m_validationInfo
.m_failureBehavior
;
3108 if ( vfb
& wxPG_VFB_BEEP
)
3111 if ( (vfb
& wxPG_VFB_MARK_CELL
) &&
3112 !property
->HasFlag(wxPG_PROP_INVALID_VALUE
) )
3114 unsigned int colCount
= m_pState
->GetColumnCount();
3116 // We need backup marked property's cells
3117 m_propCellsBackup
= property
->m_cells
;
3119 wxColour vfbFg
= *wxWHITE
;
3120 wxColour vfbBg
= *wxRED
;
3122 property
->EnsureCells(colCount
);
3124 for ( unsigned int i
=0; i
<colCount
; i
++ )
3126 wxPGCell
& cell
= property
->m_cells
[i
];
3127 cell
.SetFgCol(vfbFg
);
3128 cell
.SetBgCol(vfbBg
);
3131 DrawItemAndChildren(property
);
3133 if ( property
== GetSelection() )
3135 SetInternalFlag(wxPG_FL_CELL_OVERRIDES_SEL
);
3137 wxWindow
* editor
= GetEditorControl();
3140 editor
->SetForegroundColour(vfbFg
);
3141 editor
->SetBackgroundColour(vfbBg
);
3146 if ( vfb
& wxPG_VFB_SHOW_MESSAGE
)
3148 wxString msg
= m_validationInfo
.m_failureMessage
;
3150 if ( !msg
.length() )
3151 msg
= wxT("You have entered invalid value. Press ESC to cancel editing.");
3153 DoShowPropertyError(property
, msg
);
3156 return (vfb
& wxPG_VFB_STAY_IN_PROPERTY
) ? false : true;
3159 // -----------------------------------------------------------------------
3161 void wxPropertyGrid::DoOnValidationFailureReset( wxPGProperty
* property
)
3163 int vfb
= m_validationInfo
.m_failureBehavior
;
3165 if ( vfb
& wxPG_VFB_MARK_CELL
)
3168 property
->m_cells
= m_propCellsBackup
;
3170 ClearInternalFlag(wxPG_FL_CELL_OVERRIDES_SEL
);
3172 if ( property
== GetSelection() && GetEditorControl() )
3174 // Calling this will recreate the control, thus resetting its colour
3175 RefreshProperty(property
);
3179 DrawItemAndChildren(property
);
3184 // -----------------------------------------------------------------------
3186 // flags are same as with DoSelectProperty
3187 bool wxPropertyGrid::DoPropertyChanged( wxPGProperty
* p
, unsigned int selFlags
)
3189 if ( m_inDoPropertyChanged
)
3192 wxWindow
* editor
= GetEditorControl();
3193 wxPGProperty
* selected
= GetSelection();
3195 m_pState
->m_anyModified
= 1;
3197 m_inDoPropertyChanged
= 1;
3199 // Maybe need to update control
3200 wxASSERT( m_chgInfo_changedProperty
!= NULL
);
3202 // These values were calculated in PerformValidation()
3203 wxPGProperty
* changedProperty
= m_chgInfo_changedProperty
;
3204 wxVariant value
= m_chgInfo_pendingValue
;
3206 wxPGProperty
* topPaintedProperty
= changedProperty
;
3208 while ( !topPaintedProperty
->IsCategory() &&
3209 !topPaintedProperty
->IsRoot() )
3211 topPaintedProperty
= topPaintedProperty
->GetParent();
3214 changedProperty
->SetValue(value
, &m_chgInfo_valueList
, wxPG_SETVAL_BY_USER
);
3216 // Set as Modified (not if dragging just began)
3217 if ( !(p
->m_flags
& wxPG_PROP_MODIFIED
) )
3219 p
->m_flags
|= wxPG_PROP_MODIFIED
;
3220 if ( p
== selected
&& (m_windowStyle
& wxPG_BOLD_MODIFIED
) )
3223 SetCurControlBoldFont();
3229 // Propagate updates to parent(s)
3231 wxPGProperty
* prevPwc
= NULL
;
3233 while ( prevPwc
!= topPaintedProperty
)
3235 pwc
->m_flags
|= wxPG_PROP_MODIFIED
;
3237 if ( pwc
== selected
&& (m_windowStyle
& wxPG_BOLD_MODIFIED
) )
3240 SetCurControlBoldFont();
3244 pwc
= pwc
->GetParent();
3247 // Draw the actual property
3248 DrawItemAndChildren( topPaintedProperty
);
3251 // If value was set by wxPGProperty::OnEvent, then update the editor
3253 if ( selFlags
& wxPG_SEL_DIALOGVAL
)
3259 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
3260 if ( m_wndEditor
) m_wndEditor
->Refresh();
3261 if ( m_wndEditor2
) m_wndEditor2
->Refresh();
3266 wxASSERT( !changedProperty
->GetParent()->HasFlag(wxPG_PROP_AGGREGATE
) );
3268 // If top parent has composite string value, then send to child parents,
3269 // starting from baseChangedProperty.
3270 if ( changedProperty
->HasFlag(wxPG_PROP_COMPOSED_VALUE
) )
3272 pwc
= m_chgInfo_baseChangedProperty
;
3274 while ( pwc
!= changedProperty
)
3276 SendEvent( wxEVT_PG_CHANGED
, pwc
, NULL
);
3277 pwc
= pwc
->GetParent();
3281 SendEvent( wxEVT_PG_CHANGED
, changedProperty
, NULL
);
3283 m_inDoPropertyChanged
= 0;
3288 // -----------------------------------------------------------------------
3290 bool wxPropertyGrid::ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
)
3292 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
3294 m_chgInfo_changedProperty
= NULL
;
3296 if ( PerformValidation(p
, newValue
) )
3298 DoPropertyChanged(p
);
3303 OnValidationFailure(p
, newValue
);
3309 // -----------------------------------------------------------------------
3311 wxVariant
wxPropertyGrid::GetUncommittedPropertyValue()
3313 wxPGProperty
* prop
= GetSelectedProperty();
3316 return wxNullVariant
;
3318 wxTextCtrl
* tc
= GetEditorTextCtrl();
3319 wxVariant value
= prop
->GetValue();
3321 if ( !tc
|| !IsEditorsValueModified() )
3324 if ( !prop
->StringToValue(value
, tc
->GetValue()) )
3327 if ( !PerformValidation(prop
, value
, IsStandaloneValidation
) )
3328 return prop
->GetValue();
3333 // -----------------------------------------------------------------------
3335 // Runs wxValidator for the selected property
3336 bool wxPropertyGrid::DoEditorValidate()
3341 // -----------------------------------------------------------------------
3343 void wxPropertyGrid::HandleCustomEditorEvent( wxEvent
&event
)
3345 // It is possible that this handler receives event even before
3346 // the control has been properly initialized. Let's skip the
3347 // event handling in that case.
3351 wxPGProperty
* selected
= GetSelection();
3353 // Somehow, event is handled after property has been deselected.
3354 // Possibly, but very rare.
3356 selected
->HasFlag(wxPG_PROP_BEING_DELETED
) ||
3357 // Also don't handle editor event if wxEVT_PG_CHANGED or
3358 // similar is currently doing something (showing a
3359 // message box, for instance).
3363 if ( m_iFlags
& wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
)
3366 wxVariant
pendingValue(selected
->GetValueRef());
3367 wxWindow
* wnd
= GetEditorControl();
3368 wxWindow
* editorWnd
= wxDynamicCast(event
.GetEventObject(), wxWindow
);
3370 bool wasUnspecified
= selected
->IsValueUnspecified();
3371 int usesAutoUnspecified
= selected
->UsesAutoUnspecified();
3372 bool valueIsPending
= false;
3374 m_chgInfo_changedProperty
= NULL
;
3376 m_iFlags
&= ~(wxPG_FL_VALIDATION_FAILED
|wxPG_FL_VALUE_CHANGE_IN_EVENT
);
3379 // Filter out excess wxTextCtrl modified events
3380 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED
&& wnd
)
3382 if ( wnd
->IsKindOf(CLASSINFO(wxTextCtrl
)) )
3384 wxTextCtrl
* tc
= (wxTextCtrl
*) wnd
;
3386 wxString newTcValue
= tc
->GetValue();
3387 if ( m_prevTcValue
== newTcValue
)
3389 m_prevTcValue
= newTcValue
;
3391 else if ( wnd
->IsKindOf(CLASSINFO(wxComboCtrl
)) )
3393 wxComboCtrl
* cc
= (wxComboCtrl
*) wnd
;
3395 wxString newTcValue
= cc
->GetTextCtrl()->GetValue();
3396 if ( m_prevTcValue
== newTcValue
)
3398 m_prevTcValue
= newTcValue
;
3402 SetInternalFlag(wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
);
3404 bool validationFailure
= false;
3405 bool buttonWasHandled
= false;
3408 // Try common button handling
3409 if ( m_wndEditor2
&& event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
3411 wxPGEditorDialogAdapter
* adapter
= selected
->GetEditorDialog();
3415 buttonWasHandled
= true;
3416 // Store as res2, as previously (and still currently alternatively)
3417 // dialogs can be shown by handling wxEVT_COMMAND_BUTTON_CLICKED
3418 // in wxPGProperty::OnEvent().
3419 adapter
->ShowDialog( this, selected
);
3424 if ( !buttonWasHandled
)
3426 if ( wnd
|| m_wndEditor2
)
3428 // First call editor class' event handler.
3429 const wxPGEditor
* editor
= selected
->GetEditorClass();
3431 if ( editor
->OnEvent( this, selected
, editorWnd
, event
) )
3433 // If changes, validate them
3434 if ( DoEditorValidate() )
3436 if ( editor
->GetValueFromControl( pendingValue
,
3439 valueIsPending
= true;
3443 validationFailure
= true;
3448 // Then the property's custom handler (must be always called, unless
3449 // validation failed).
3450 if ( !validationFailure
)
3451 buttonWasHandled
= selected
->OnEvent( this, editorWnd
, event
);
3454 // SetValueInEvent(), as called in one of the functions referred above
3455 // overrides editor's value.
3456 if ( m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
)
3458 valueIsPending
= true;
3459 pendingValue
= m_changeInEventValue
;
3460 selFlags
|= wxPG_SEL_DIALOGVAL
;
3463 if ( !validationFailure
&& valueIsPending
)
3464 if ( !PerformValidation(selected
, pendingValue
) )
3465 validationFailure
= true;
3467 if ( validationFailure
)
3469 OnValidationFailure(selected
, pendingValue
);
3471 else if ( valueIsPending
)
3473 selFlags
|= ( !wasUnspecified
&& selected
->IsValueUnspecified() && usesAutoUnspecified
) ? wxPG_SEL_SETUNSPEC
: 0;
3475 DoPropertyChanged(selected
, selFlags
);
3476 EditorsValueWasNotModified();
3478 // Regardless of editor type, unfocus editor on
3479 // text-editing related enter press.
3480 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_ENTER
)
3487 // No value after all
3489 // Regardless of editor type, unfocus editor on
3490 // text-editing related enter press.
3491 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_ENTER
)
3496 // Let unhandled button click events go to the parent
3497 if ( !buttonWasHandled
&& event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
3499 wxCommandEvent
evt(wxEVT_COMMAND_BUTTON_CLICKED
,GetId());
3500 GetEventHandler()->AddPendingEvent(evt
);
3504 ClearInternalFlag(wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
);
3507 // -----------------------------------------------------------------------
3508 // wxPropertyGrid editor control helper methods
3509 // -----------------------------------------------------------------------
3511 wxRect
wxPropertyGrid::GetEditorWidgetRect( wxPGProperty
* p
, int column
) const
3513 int itemy
= p
->GetY2(m_lineHeight
);
3514 int splitterX
= m_pState
->DoGetSplitterPosition(column
-1);
3515 int colEnd
= splitterX
+ m_pState
->m_colWidths
[column
];
3516 int imageOffset
= 0;
3518 int vx
, vy
; // Top left corner of client
3519 GetViewStart(&vx
, &vy
);
3520 vy
*= wxPG_PIXELS_PER_UNIT
;
3522 // TODO: If custom image detection changes from current, change this.
3523 if ( m_iFlags
& wxPG_FL_CUR_USES_CUSTOM_IMAGE
)
3525 //m_iFlags |= wxPG_FL_CUR_USES_CUSTOM_IMAGE;
3526 int iw
= p
->OnMeasureImage().x
;
3528 iw
= wxPG_CUSTOM_IMAGE_WIDTH
;
3529 imageOffset
= p
->GetImageOffset(iw
);
3534 splitterX
+imageOffset
+wxPG_XBEFOREWIDGET
+wxPG_CONTROL_MARGIN
+1,
3536 colEnd
-splitterX
-wxPG_XBEFOREWIDGET
-wxPG_CONTROL_MARGIN
-imageOffset
-1,
3541 // -----------------------------------------------------------------------
3543 wxRect
wxPropertyGrid::GetImageRect( wxPGProperty
* p
, int item
) const
3545 wxSize sz
= GetImageSize(p
, item
);
3546 return wxRect(wxPG_CONTROL_MARGIN
+ wxCC_CUSTOM_IMAGE_MARGIN1
,
3547 wxPG_CUSTOM_IMAGE_SPACINGY
,
3552 // return size of custom paint image
3553 wxSize
wxPropertyGrid::GetImageSize( wxPGProperty
* p
, int item
) const
3555 // If called with NULL property, then return default image
3556 // size for properties that use image.
3558 return wxSize(wxPG_CUSTOM_IMAGE_WIDTH
,wxPG_STD_CUST_IMAGE_HEIGHT(m_lineHeight
));
3560 wxSize cis
= p
->OnMeasureImage(item
);
3562 int choiceCount
= p
->m_choices
.GetCount();
3563 int comVals
= p
->GetDisplayedCommonValueCount();
3564 if ( item
>= choiceCount
&& comVals
> 0 )
3566 unsigned int cvi
= item
-choiceCount
;
3567 cis
= GetCommonValue(cvi
)->GetRenderer()->GetImageSize(NULL
, 1, cvi
);
3569 else if ( item
>= 0 && choiceCount
== 0 )
3570 return wxSize(0, 0);
3575 cis
.x
= wxPG_CUSTOM_IMAGE_WIDTH
;
3580 cis
.y
= wxPG_STD_CUST_IMAGE_HEIGHT(m_lineHeight
);
3587 // -----------------------------------------------------------------------
3589 // takes scrolling into account
3590 void wxPropertyGrid::ImprovedClientToScreen( int* px
, int* py
)
3593 GetViewStart(&vx
,&vy
);
3594 vy
*=wxPG_PIXELS_PER_UNIT
;
3595 vx
*=wxPG_PIXELS_PER_UNIT
;
3598 ClientToScreen( px
, py
);
3601 // -----------------------------------------------------------------------
3603 wxPropertyGridHitTestResult
wxPropertyGrid::HitTest( const wxPoint
& pt
) const
3606 GetViewStart(&pt2
.x
,&pt2
.y
);
3607 pt2
.x
*= wxPG_PIXELS_PER_UNIT
;
3608 pt2
.y
*= wxPG_PIXELS_PER_UNIT
;
3612 return m_pState
->HitTest(pt2
);
3615 // -----------------------------------------------------------------------
3617 // custom set cursor
3618 void wxPropertyGrid::CustomSetCursor( int type
, bool override
)
3620 if ( type
== m_curcursor
&& !override
) return;
3622 wxCursor
* cursor
= &wxPG_DEFAULT_CURSOR
;
3624 if ( type
== wxCURSOR_SIZEWE
)
3625 cursor
= m_cursorSizeWE
;
3627 SetCursor( *cursor
);
3633 wxPropertyGrid::GetUnspecifiedValueText( int WXUNUSED(argFlags
) ) const
3635 return wxEmptyString
;
3638 // -----------------------------------------------------------------------
3639 // wxPropertyGrid property selection, editor creation
3640 // -----------------------------------------------------------------------
3643 // This class forwards events from property editor controls to wxPropertyGrid.
3644 class wxPropertyGridEditorEventForwarder
: public wxEvtHandler
3647 wxPropertyGridEditorEventForwarder( wxPropertyGrid
* propGrid
)
3648 : wxEvtHandler(), m_propGrid(propGrid
)
3652 virtual ~wxPropertyGridEditorEventForwarder()
3657 bool ProcessEvent( wxEvent
& event
)
3662 m_propGrid
->HandleCustomEditorEvent(event
);
3664 return wxEvtHandler::ProcessEvent(event
);
3667 wxPropertyGrid
* m_propGrid
;
3670 // Setups event handling for child control
3671 void wxPropertyGrid::SetupChildEventHandling( wxWindow
* argWnd
)
3673 wxWindowID id
= argWnd
->GetId();
3675 if ( argWnd
== m_wndEditor
)
3677 argWnd
->Connect(id
, wxEVT_MOTION
,
3678 wxMouseEventHandler(wxPropertyGrid::OnMouseMoveChild
),
3680 argWnd
->Connect(id
, wxEVT_LEFT_UP
,
3681 wxMouseEventHandler(wxPropertyGrid::OnMouseUpChild
),
3683 argWnd
->Connect(id
, wxEVT_LEFT_DOWN
,
3684 wxMouseEventHandler(wxPropertyGrid::OnMouseClickChild
),
3686 argWnd
->Connect(id
, wxEVT_RIGHT_UP
,
3687 wxMouseEventHandler(wxPropertyGrid::OnMouseRightClickChild
),
3689 argWnd
->Connect(id
, wxEVT_ENTER_WINDOW
,
3690 wxMouseEventHandler(wxPropertyGrid::OnMouseEntry
),
3692 argWnd
->Connect(id
, wxEVT_LEAVE_WINDOW
,
3693 wxMouseEventHandler(wxPropertyGrid::OnMouseEntry
),
3697 wxPropertyGridEditorEventForwarder
* forwarder
;
3698 forwarder
= new wxPropertyGridEditorEventForwarder(this);
3699 argWnd
->PushEventHandler(forwarder
);
3701 argWnd
->Connect(id
, wxEVT_KEY_DOWN
,
3702 wxCharEventHandler(wxPropertyGrid::OnChildKeyDown
),
3706 void wxPropertyGrid::DestroyEditorWnd( wxWindow
* wnd
)
3713 // Do not free editors immediately (for sake of processing events)
3714 wxPendingDelete
.Append(wnd
);
3717 void wxPropertyGrid::FreeEditors()
3720 // Return focus back to canvas from children (this is required at least for
3721 // GTK+, which, unlike Windows, clears focus when control is destroyed
3722 // instead of moving it to closest parent).
3723 wxWindow
* focus
= wxWindow::FindFocus();
3726 wxWindow
* parent
= focus
->GetParent();
3729 if ( parent
== this )
3734 parent
= parent
->GetParent();
3738 // Do not free editors immediately if processing events
3741 wxEvtHandler
* handler
= m_wndEditor2
->PopEventHandler(false);
3742 m_wndEditor2
->Hide();
3743 wxPendingDelete
.Append( handler
);
3744 DestroyEditorWnd(m_wndEditor2
);
3745 m_wndEditor2
= NULL
;
3750 wxEvtHandler
* handler
= m_wndEditor
->PopEventHandler(false);
3751 m_wndEditor
->Hide();
3752 wxPendingDelete
.Append( handler
);
3753 DestroyEditorWnd(m_wndEditor
);
3758 // Call with NULL to de-select property
3759 bool wxPropertyGrid::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
3764 wxLogDebug(wxT("SelectProperty( %s (%s[%i]) )"),p->m_label.c_str(),
3765 p->m_parent->m_label.c_str(),p->GetIndexInParent());
3769 wxLogDebug(wxT("SelectProperty( NULL, -1 )"));
3773 if ( m_inDoSelectProperty
)
3776 m_inDoSelectProperty
= 1;
3780 m_inDoSelectProperty
= 0;
3784 wxArrayPGProperty prevSelection
= m_pState
->m_selection
;
3785 wxPGProperty
* prevFirstSel
;
3787 if ( prevSelection
.size() > 0 )
3788 prevFirstSel
= prevSelection
[0];
3790 prevFirstSel
= NULL
;
3792 if ( prevFirstSel
&& prevFirstSel
->HasFlag(wxPG_PROP_BEING_DELETED
) )
3793 prevFirstSel
= NULL
;
3795 // Always send event, as this is indirect call
3796 DoEndLabelEdit(true, wxPG_SEL_NOVALIDATE
);
3800 wxPrintf( "Selected %s\n", prevFirstSel->GetClassInfo()->GetClassName() );
3802 wxPrintf( "None selected\n" );
3805 wxPrintf( "P = %s\n", p->GetClassInfo()->GetClassName() );
3807 wxPrintf( "P = NULL\n" );
3810 // If we are frozen, then just set the values.
3813 m_iFlags
&= ~(wxPG_FL_ABNORMAL_EDITOR
);
3814 m_editorFocused
= 0;
3815 m_pState
->DoSetSelection(p
);
3817 // If frozen, always free controls. But don't worry, as Thaw will
3818 // recall SelectProperty to recreate them.
3821 // Prevent any further selection measures in this call
3827 if ( prevFirstSel
== p
&&
3828 prevSelection
.size() <= 1 &&
3829 !(flags
& wxPG_SEL_FORCE
) )
3831 // Only set focus if not deselecting
3834 if ( flags
& wxPG_SEL_FOCUS
)
3838 m_wndEditor
->SetFocus();
3839 m_editorFocused
= 1;
3848 m_inDoSelectProperty
= 0;
3853 // First, deactivate previous
3856 OnValidationFailureReset(prevFirstSel
);
3858 // Must double-check if this is an selected in case of forceswitch
3859 if ( p
!= prevFirstSel
)
3861 if ( !CommitChangesFromEditor(flags
) )
3863 // Validation has failed, so we can't exit the previous editor
3864 //::wxMessageBox(_("Please correct the value or press ESC to cancel the edit."),
3865 // _("Invalid Value"),wxOK|wxICON_ERROR);
3866 m_inDoSelectProperty
= 0;
3873 m_iFlags
&= ~(wxPG_FL_ABNORMAL_EDITOR
);
3874 EditorsValueWasNotModified();
3877 SetInternalFlag(wxPG_FL_IN_SELECT_PROPERTY
);
3879 m_pState
->DoSetSelection(p
);
3881 // Redraw unselected
3882 for ( unsigned int i
=0; i
<prevSelection
.size(); i
++ )
3884 DrawItem(prevSelection
[i
]);
3888 // Then, activate the one given.
3891 int propY
= p
->GetY2(m_lineHeight
);
3893 int splitterX
= GetSplitterPosition();
3894 m_editorFocused
= 0;
3895 m_iFlags
|= wxPG_FL_PRIMARY_FILLS_ENTIRE
;
3896 if ( p
!= prevFirstSel
)
3897 m_iFlags
&= ~(wxPG_FL_VALIDATION_FAILED
);
3899 wxASSERT( m_wndEditor
== NULL
);
3902 // Only create editor for non-disabled non-caption
3903 if ( !p
->IsCategory() && !(p
->m_flags
& wxPG_PROP_DISABLED
) )
3905 // do this for non-caption items
3909 // Do we need to paint the custom image, if any?
3910 m_iFlags
&= ~(wxPG_FL_CUR_USES_CUSTOM_IMAGE
);
3911 if ( (p
->m_flags
& wxPG_PROP_CUSTOMIMAGE
) &&
3912 !p
->GetEditorClass()->CanContainCustomImage()
3914 m_iFlags
|= wxPG_FL_CUR_USES_CUSTOM_IMAGE
;
3916 wxRect grect
= GetEditorWidgetRect(p
, m_selColumn
);
3917 wxPoint goodPos
= grect
.GetPosition();
3919 const wxPGEditor
* editor
= p
->GetEditorClass();
3920 wxCHECK_MSG(editor
, false,
3921 wxT("NULL editor class not allowed"));
3923 m_iFlags
&= ~wxPG_FL_FIXED_WIDTH_EDITOR
;
3925 wxPGWindowList wndList
=
3926 editor
->CreateControls(this,
3931 m_wndEditor
= wndList
.m_primary
;
3932 m_wndEditor2
= wndList
.m_secondary
;
3933 wxWindow
* primaryCtrl
= GetEditorControl();
3936 // Essentially, primaryCtrl == m_wndEditor
3939 // NOTE: It is allowed for m_wndEditor to be NULL - in this
3940 // case value is drawn as normal, and m_wndEditor2 is
3941 // assumed to be a right-aligned button that triggers
3942 // a separate editorCtrl window.
3946 wxASSERT_MSG( m_wndEditor
->GetParent() == GetPanel(),
3947 "CreateControls must use result of "
3948 "wxPropertyGrid::GetPanel() as parent "
3951 // Set validator, if any
3952 #if wxUSE_VALIDATORS
3953 wxValidator
* validator
= p
->GetValidator();
3955 primaryCtrl
->SetValidator(*validator
);
3958 if ( m_wndEditor
->GetSize().y
> (m_lineHeight
+6) )
3959 m_iFlags
|= wxPG_FL_ABNORMAL_EDITOR
;
3961 // If it has modified status, use bold font
3962 // (must be done before capturing m_ctrlXAdjust)
3963 if ( (p
->m_flags
& wxPG_PROP_MODIFIED
) &&
3964 (m_windowStyle
& wxPG_BOLD_MODIFIED
) )
3965 SetCurControlBoldFont();
3967 // Store x relative to splitter (we'll need it).
3968 m_ctrlXAdjust
= m_wndEditor
->GetPosition().x
- splitterX
;
3970 // Check if background clear is not necessary
3971 wxPoint pos
= m_wndEditor
->GetPosition();
3972 if ( pos
.x
> (splitterX
+1) || pos
.y
> propY
)
3974 m_iFlags
&= ~(wxPG_FL_PRIMARY_FILLS_ENTIRE
);
3977 m_wndEditor
->SetSizeHints(3, 3);
3979 SetupChildEventHandling(primaryCtrl
);
3981 // Focus and select all (wxTextCtrl, wxComboBox etc)
3982 if ( flags
& wxPG_SEL_FOCUS
)
3984 primaryCtrl
->SetFocus();
3986 p
->GetEditorClass()->OnFocus(p
, primaryCtrl
);
3992 wxASSERT_MSG( m_wndEditor2
->GetParent() == GetPanel(),
3993 "CreateControls must use result of "
3994 "wxPropertyGrid::GetPanel() as parent "
3997 // Get proper id for wndSecondary
3998 m_wndSecId
= m_wndEditor2
->GetId();
3999 wxWindowList children
= m_wndEditor2
->GetChildren();
4000 wxWindowList::iterator node
= children
.begin();
4001 if ( node
!= children
.end() )
4002 m_wndSecId
= ((wxWindow
*)*node
)->GetId();
4004 m_wndEditor2
->SetSizeHints(3,3);
4006 m_wndEditor2
->Show();
4008 SetupChildEventHandling(m_wndEditor2
);
4010 // If no primary editor, focus to button to allow
4011 // it to interprete ENTER etc.
4012 // NOTE: Due to problems focusing away from it, this
4013 // has been disabled.
4015 if ( (flags & wxPG_SEL_FOCUS) && !m_wndEditor )
4016 m_wndEditor2->SetFocus();
4020 if ( flags
& wxPG_SEL_FOCUS
)
4021 m_editorFocused
= 1;
4026 // Make sure focus is in grid canvas (important for wxGTK,
4031 EditorsValueWasNotModified();
4033 // If it's inside collapsed section, expand parent, scroll, etc.
4034 // Also, if it was partially visible, scroll it into view.
4035 if ( !(flags
& wxPG_SEL_NONVISIBLE
) )
4040 m_wndEditor
->Show(true);
4043 if ( !(flags
& wxPG_SEL_NO_REFRESH
) )
4048 // Make sure focus is in grid canvas
4052 ClearInternalFlag(wxPG_FL_IN_SELECT_PROPERTY
);
4058 // Show help text in status bar.
4059 // (if found and grid not embedded in manager with help box and
4060 // style wxPG_EX_HELP_AS_TOOLTIPS is not used).
4063 if ( !(GetExtraStyle() & wxPG_EX_HELP_AS_TOOLTIPS
) )
4065 wxStatusBar
* statusbar
= NULL
;
4066 if ( !(m_iFlags
& wxPG_FL_NOSTATUSBARHELP
) )
4068 wxFrame
* frame
= wxDynamicCast(::wxGetTopLevelParent(this),wxFrame
);
4070 statusbar
= frame
->GetStatusBar();
4075 const wxString
* pHelpString
= (const wxString
*) NULL
;
4079 pHelpString
= &p
->GetHelpString();
4080 if ( pHelpString
->length() )
4082 // Set help box text.
4083 statusbar
->SetStatusText( *pHelpString
);
4084 m_iFlags
|= wxPG_FL_STRING_IN_STATUSBAR
;
4088 if ( (!pHelpString
|| !pHelpString
->length()) &&
4089 (m_iFlags
& wxPG_FL_STRING_IN_STATUSBAR
) )
4091 // Clear help box - but only if it was written
4092 // by us at previous time.
4093 statusbar
->SetStatusText( m_emptyString
);
4094 m_iFlags
&= ~(wxPG_FL_STRING_IN_STATUSBAR
);
4100 m_inDoSelectProperty
= 0;
4102 // call wx event handler (here so that it also occurs on deselection)
4103 if ( !(flags
& wxPG_SEL_DONT_SEND_EVENT
) )
4104 SendEvent( wxEVT_PG_SELECTED
, p
, NULL
);
4109 // -----------------------------------------------------------------------
4111 bool wxPropertyGrid::UnfocusEditor()
4113 wxPGProperty
* selected
= GetSelection();
4115 if ( !selected
|| !m_wndEditor
|| m_frozen
)
4118 if ( !CommitChangesFromEditor(0) )
4127 // -----------------------------------------------------------------------
4129 void wxPropertyGrid::RefreshEditor()
4131 wxPGProperty
* p
= GetSelection();
4135 wxWindow
* wnd
= GetEditorControl();
4139 // Set editor font boldness - must do this before
4140 // calling UpdateControl().
4141 if ( HasFlag(wxPG_BOLD_MODIFIED
) )
4143 if ( p
->HasFlag(wxPG_PROP_MODIFIED
) )
4144 wnd
->SetFont(GetCaptionFont());
4146 wnd
->SetFont(GetFont());
4149 const wxPGEditor
* editorClass
= p
->GetEditorClass();
4151 editorClass
->UpdateControl(p
, wnd
);
4153 if ( p
->IsValueUnspecified() )
4154 editorClass
->SetValueToUnspecified(p
, wnd
);
4157 // -----------------------------------------------------------------------
4159 bool wxPropertyGrid::SelectProperty( wxPGPropArg id
, bool focus
)
4161 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
4163 int flags
= wxPG_SEL_DONT_SEND_EVENT
;
4165 flags
|= wxPG_SEL_FOCUS
;
4167 return DoSelectProperty(p
, flags
);
4170 // -----------------------------------------------------------------------
4171 // wxPropertyGrid expand/collapse state
4172 // -----------------------------------------------------------------------
4174 bool wxPropertyGrid::DoCollapse( wxPGProperty
* p
, bool sendEvents
)
4176 wxPGProperty
* pwc
= wxStaticCast(p
, wxPGProperty
);
4177 wxPGProperty
* selected
= GetSelection();
4179 // If active editor was inside collapsed section, then disable it
4180 if ( selected
&& selected
->IsSomeParent(p
) )
4185 // Store dont-center-splitter flag 'cause we need to temporarily set it
4186 bool prevDontCenterSplitter
= m_pState
->m_dontCenterSplitter
;
4187 m_pState
->m_dontCenterSplitter
= true;
4189 bool res
= m_pState
->DoCollapse(pwc
);
4194 SendEvent( wxEVT_PG_ITEM_COLLAPSED
, p
);
4196 RecalculateVirtualSize();
4200 m_pState
->m_dontCenterSplitter
= prevDontCenterSplitter
;
4205 // -----------------------------------------------------------------------
4207 bool wxPropertyGrid::DoExpand( wxPGProperty
* p
, bool sendEvents
)
4209 wxCHECK_MSG( p
, false, wxT("invalid property id") );
4211 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
4213 // Store dont-center-splitter flag 'cause we need to temporarily set it
4214 bool prevDontCenterSplitter
= m_pState
->m_dontCenterSplitter
;
4215 m_pState
->m_dontCenterSplitter
= true;
4217 bool res
= m_pState
->DoExpand(pwc
);
4222 SendEvent( wxEVT_PG_ITEM_EXPANDED
, p
);
4224 RecalculateVirtualSize();
4228 m_pState
->m_dontCenterSplitter
= prevDontCenterSplitter
;
4233 // -----------------------------------------------------------------------
4235 bool wxPropertyGrid::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
4238 return m_pState
->DoHideProperty(p
, hide
, flags
);
4240 wxArrayPGProperty selection
= m_pState
->m_selection
; // Must use a copy
4241 int selRemoveCount
= 0;
4242 for ( unsigned int i
=0; i
<selection
.size(); i
++ )
4244 wxPGProperty
* selected
= selection
[i
];
4245 if ( selected
== p
|| selected
->IsSomeParent(p
) )
4247 if ( !DoRemoveFromSelection(p
, flags
) )
4249 selRemoveCount
+= 1;
4253 m_pState
->DoHideProperty(p
, hide
, flags
);
4255 RecalculateVirtualSize();
4262 // -----------------------------------------------------------------------
4263 // wxPropertyGrid size related methods
4264 // -----------------------------------------------------------------------
4266 void wxPropertyGrid::RecalculateVirtualSize( int forceXPos
)
4268 // Don't check for !HasInternalFlag(wxPG_FL_INITIALIZED) here. Otherwise
4269 // virtual size calculation may go wrong.
4270 if ( HasInternalFlag(wxPG_FL_RECALCULATING_VIRTUAL_SIZE
) ||
4276 // If virtual height was changed, then recalculate editor control position(s)
4277 if ( m_pState
->m_vhCalcPending
)
4278 CorrectEditorWidgetPosY();
4280 m_pState
->EnsureVirtualHeight();
4282 wxASSERT_LEVEL_2_MSG(
4283 m_pState
->GetVirtualHeight() == m_pState
->GetActualVirtualHeight(),
4284 "VirtualHeight and ActualVirtualHeight should match"
4287 m_iFlags
|= wxPG_FL_RECALCULATING_VIRTUAL_SIZE
;
4289 int x
= m_pState
->m_width
;
4290 int y
= m_pState
->m_virtualHeight
;
4293 GetClientSize(&width
,&height
);
4295 // Now adjust virtual size.
4296 SetVirtualSize(x
, y
);
4302 // Adjust scrollbars
4303 if ( HasVirtualWidth() )
4305 xAmount
= x
/wxPG_PIXELS_PER_UNIT
;
4306 xPos
= GetScrollPos( wxHORIZONTAL
);
4309 if ( forceXPos
!= -1 )
4312 else if ( xPos
> (xAmount
-(width
/wxPG_PIXELS_PER_UNIT
)) )
4315 int yAmount
= y
/ wxPG_PIXELS_PER_UNIT
;
4316 int yPos
= GetScrollPos( wxVERTICAL
);
4318 SetScrollbars( wxPG_PIXELS_PER_UNIT
, wxPG_PIXELS_PER_UNIT
,
4319 xAmount
, yAmount
, xPos
, yPos
, true );
4321 // Must re-get size now
4322 GetClientSize(&width
,&height
);
4324 if ( !HasVirtualWidth() )
4326 m_pState
->SetVirtualWidth(width
);
4333 m_pState
->CheckColumnWidths();
4335 if ( GetSelection() )
4336 CorrectEditorWidgetSizeX();
4338 m_iFlags
&= ~wxPG_FL_RECALCULATING_VIRTUAL_SIZE
;
4341 // -----------------------------------------------------------------------
4343 void wxPropertyGrid::OnResize( wxSizeEvent
& event
)
4345 if ( !(m_iFlags
& wxPG_FL_INITIALIZED
) )
4349 GetClientSize(&width
, &height
);
4354 #if wxPG_DOUBLE_BUFFER
4355 if ( !(GetExtraStyle() & wxPG_EX_NATIVE_DOUBLE_BUFFERING
) )
4357 int dblh
= (m_lineHeight
*2);
4358 if ( !m_doubleBuffer
)
4360 // Create double buffer bitmap to draw on, if none
4361 int w
= (width
>250)?width
:250;
4362 int h
= height
+ dblh
;
4364 m_doubleBuffer
= new wxBitmap( w
, h
);
4368 int w
= m_doubleBuffer
->GetWidth();
4369 int h
= m_doubleBuffer
->GetHeight();
4371 // Double buffer must be large enough
4372 if ( w
< width
|| h
< (height
+dblh
) )
4374 if ( w
< width
) w
= width
;
4375 if ( h
< (height
+dblh
) ) h
= height
+ dblh
;
4376 delete m_doubleBuffer
;
4377 m_doubleBuffer
= new wxBitmap( w
, h
);
4384 m_pState
->OnClientWidthChange( width
, event
.GetSize().x
- m_ncWidth
, true );
4385 m_ncWidth
= event
.GetSize().x
;
4389 if ( m_pState
->m_itemsAdded
)
4390 PrepareAfterItemsAdded();
4392 // Without this, virtual size (atleast under wxGTK) will be skewed
4393 RecalculateVirtualSize();
4399 // -----------------------------------------------------------------------
4401 void wxPropertyGrid::SetVirtualWidth( int width
)
4405 // Disable virtual width
4406 width
= GetClientSize().x
;
4407 ClearInternalFlag(wxPG_FL_HAS_VIRTUAL_WIDTH
);
4411 // Enable virtual width
4412 SetInternalFlag(wxPG_FL_HAS_VIRTUAL_WIDTH
);
4414 m_pState
->SetVirtualWidth( width
);
4417 void wxPropertyGrid::SetFocusOnCanvas()
4419 SetFocusIgnoringChildren();
4420 m_editorFocused
= 0;
4423 // -----------------------------------------------------------------------
4424 // wxPropertyGrid mouse event handling
4425 // -----------------------------------------------------------------------
4427 // selFlags uses same values DoSelectProperty's flags
4428 // Returns true if event was vetoed.
4429 bool wxPropertyGrid::SendEvent( int eventType
, wxPGProperty
* p
,
4431 unsigned int selFlags
,
4432 unsigned int column
)
4434 // selFlags should have wxPG_SEL_NOVALIDATE if event is not
4437 // Send property grid event of specific type and with specific property
4438 wxPropertyGridEvent
evt( eventType
, m_eventObject
->GetId() );
4439 evt
.SetPropertyGrid(this);
4440 evt
.SetEventObject(m_eventObject
);
4442 evt
.SetColumn(column
);
4443 if ( eventType
== wxEVT_PG_CHANGING
)
4446 evt
.SetCanVeto(true);
4447 m_validationInfo
.m_pValue
= pValue
;
4448 evt
.SetupValidationInfo();
4453 evt
.SetPropertyValue(p
->GetValue());
4455 if ( !(selFlags
& wxPG_SEL_NOVALIDATE
) )
4456 evt
.SetCanVeto(true);
4459 m_processedEvent
= &evt
;
4460 m_eventObject
->HandleWindowEvent(evt
);
4461 m_processedEvent
= NULL
;
4463 return evt
.WasVetoed();
4466 // -----------------------------------------------------------------------
4468 // Return false if should be skipped
4469 bool wxPropertyGrid::HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
)
4473 // Need to set focus?
4474 if ( !(m_iFlags
& wxPG_FL_FOCUSED
) )
4479 wxPropertyGridPageState
* state
= m_pState
;
4481 int splitterHitOffset
;
4482 int columnHit
= state
->HitTestH( x
, &splitterHit
, &splitterHitOffset
);
4484 wxPGProperty
* p
= DoGetItemAtY(y
);
4488 int depth
= (int)p
->GetDepth() - 1;
4490 int marginEnds
= m_marginWidth
+ ( depth
* m_subgroup_extramargin
);
4492 if ( x
>= marginEnds
)
4496 if ( p
->IsCategory() )
4498 // This is category.
4499 wxPropertyCategory
* pwc
= (wxPropertyCategory
*)p
;
4501 int textX
= m_marginWidth
+ ((unsigned int)((pwc
->m_depth
-1)*m_subgroup_extramargin
));
4503 // Expand, collapse, activate etc. if click on text or left of splitter.
4506 ( x
< (textX
+pwc
->GetTextExtent(this, m_captionFont
)+(wxPG_CAPRECTXMARGIN
*2)) ||
4511 if ( !AddToSelectionFromInputEvent( p
,
4516 // On double-click, expand/collapse.
4517 if ( event
.ButtonDClick() && !(m_windowStyle
& wxPG_HIDE_MARGIN
) )
4519 if ( pwc
->IsExpanded() ) DoCollapse( p
, true );
4520 else DoExpand( p
, true );
4524 else if ( splitterHit
== -1 )
4527 unsigned int selFlag
= 0;
4528 if ( columnHit
== 1 )
4530 m_iFlags
|= wxPG_FL_ACTIVATION_BY_CLICK
;
4531 selFlag
= wxPG_SEL_FOCUS
;
4533 if ( !AddToSelectionFromInputEvent( p
,
4539 m_iFlags
&= ~(wxPG_FL_ACTIVATION_BY_CLICK
);
4541 if ( p
->GetChildCount() && !p
->IsCategory() )
4542 // On double-click, expand/collapse.
4543 if ( event
.ButtonDClick() && !(m_windowStyle
& wxPG_HIDE_MARGIN
) )
4545 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
4546 if ( pwc
->IsExpanded() ) DoCollapse( p
, true );
4547 else DoExpand( p
, true );
4554 // click on splitter
4555 if ( !(m_windowStyle
& wxPG_STATIC_SPLITTER
) )
4557 if ( event
.GetEventType() == wxEVT_LEFT_DCLICK
)
4559 // Double-clicking the splitter causes auto-centering
4560 if ( m_pState
->GetColumnCount() <= 2 )
4562 CenterSplitter( true );
4564 SendEvent(wxEVT_PG_COL_DRAGGING
,
4567 wxPG_SEL_NOVALIDATE
,
4568 (unsigned int)m_draggedSplitter
);
4571 else if ( m_dragStatus
== 0 )
4574 // Begin draggin the splitter
4578 DoEndLabelEdit(true, wxPG_SEL_NOVALIDATE
);
4580 // Allow application to veto dragging
4581 if ( !SendEvent(wxEVT_PG_COL_BEGIN_DRAG
,
4583 (unsigned int)splitterHit
) )
4587 // Changes must be committed here or the
4588 // value won't be drawn correctly
4589 if ( !CommitChangesFromEditor() )
4592 m_wndEditor
->Show ( false );
4595 if ( !(m_iFlags
& wxPG_FL_MOUSE_CAPTURED
) )
4598 m_iFlags
|= wxPG_FL_MOUSE_CAPTURED
;
4602 m_draggedSplitter
= splitterHit
;
4603 m_dragOffset
= splitterHitOffset
;
4605 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
4606 // Fixes button disappearance bug
4608 m_wndEditor2
->Show ( false );
4611 m_startingSplitterX
= x
- splitterHitOffset
;
4620 if ( p
->GetChildCount() )
4622 int nx
= x
+ m_marginWidth
- marginEnds
; // Normalize x.
4624 // Fine tune cell button x
4625 if ( !p
->IsCategory() )
4626 nx
-= IN_CELL_EXPANDER_BUTTON_X_ADJUST
;
4628 if ( (nx
>= m_gutterWidth
&& nx
< (m_gutterWidth
+m_iconWidth
)) )
4630 int y2
= y
% m_lineHeight
;
4631 if ( (y2
>= m_buttonSpacingY
&& y2
< (m_buttonSpacingY
+m_iconHeight
)) )
4633 // On click on expander button, expand/collapse
4634 if ( ((wxPGProperty
*)p
)->IsExpanded() )
4635 DoCollapse( p
, true );
4637 DoExpand( p
, true );
4646 // -----------------------------------------------------------------------
4648 bool wxPropertyGrid::HandleMouseRightClick( int WXUNUSED(x
),
4649 unsigned int WXUNUSED(y
),
4650 wxMouseEvent
& event
)
4654 // Select property here as well
4655 wxPGProperty
* p
= m_propHover
;
4656 AddToSelectionFromInputEvent(p
, m_colHover
, &event
);
4658 // Send right click event.
4659 SendEvent( wxEVT_PG_RIGHT_CLICK
, p
);
4666 // -----------------------------------------------------------------------
4668 bool wxPropertyGrid::HandleMouseDoubleClick( int WXUNUSED(x
),
4669 unsigned int WXUNUSED(y
),
4670 wxMouseEvent
& event
)
4674 // Select property here as well
4675 wxPGProperty
* p
= m_propHover
;
4677 AddToSelectionFromInputEvent(p
, m_colHover
, &event
);
4679 // Send double-click event.
4680 SendEvent( wxEVT_PG_DOUBLE_CLICK
, m_propHover
);
4687 // -----------------------------------------------------------------------
4689 #if wxPG_SUPPORT_TOOLTIPS
4691 void wxPropertyGrid::SetToolTip( const wxString
& tipString
)
4693 if ( tipString
.length() )
4695 wxScrolledWindow::SetToolTip(tipString
);
4699 #if wxPG_ALLOW_EMPTY_TOOLTIPS
4700 wxScrolledWindow::SetToolTip( m_emptyString
);
4702 wxScrolledWindow::SetToolTip( NULL
);
4707 #endif // #if wxPG_SUPPORT_TOOLTIPS
4709 // -----------------------------------------------------------------------
4711 // Return false if should be skipped
4712 bool wxPropertyGrid::HandleMouseMove( int x
, unsigned int y
,
4713 wxMouseEvent
&event
)
4715 // Safety check (needed because mouse capturing may
4716 // otherwise freeze the control)
4717 if ( m_dragStatus
> 0 && !event
.Dragging() )
4719 HandleMouseUp(x
, y
, event
);
4722 wxPropertyGridPageState
* state
= m_pState
;
4724 int splitterHitOffset
;
4725 int columnHit
= state
->HitTestH( x
, &splitterHit
, &splitterHitOffset
);
4726 int splitterX
= x
- splitterHitOffset
;
4728 m_colHover
= columnHit
;
4730 if ( m_dragStatus
> 0 )
4732 if ( x
> (m_marginWidth
+ wxPG_DRAG_MARGIN
) &&
4733 x
< (m_pState
->m_width
- wxPG_DRAG_MARGIN
) )
4736 int newSplitterX
= x
- m_dragOffset
;
4737 int splitterX
= x
- splitterHitOffset
;
4739 // Splitter redraw required?
4740 if ( newSplitterX
!= splitterX
)
4743 DoSetSplitterPosition(newSplitterX
,
4745 wxPG_SPLITTER_REFRESH
|
4746 wxPG_SPLITTER_FROM_EVENT
);
4748 SendEvent(wxEVT_PG_COL_DRAGGING
,
4751 wxPG_SEL_NOVALIDATE
,
4752 (unsigned int)m_draggedSplitter
);
4763 int ih
= m_lineHeight
;
4766 #if wxPG_SUPPORT_TOOLTIPS
4767 wxPGProperty
* prevHover
= m_propHover
;
4768 unsigned char prevSide
= m_mouseSide
;
4770 int curPropHoverY
= y
- (y
% ih
);
4772 // On which item it hovers
4775 ( sy
< m_propHoverY
|| sy
>= (m_propHoverY
+ih
) )
4778 // Mouse moves on another property
4780 m_propHover
= DoGetItemAtY(y
);
4781 m_propHoverY
= curPropHoverY
;
4784 SendEvent( wxEVT_PG_HIGHLIGHTED
, m_propHover
);
4787 #if wxPG_SUPPORT_TOOLTIPS
4788 // Store which side we are on
4790 if ( columnHit
== 1 )
4792 else if ( columnHit
== 0 )
4796 // If tooltips are enabled, show label or value as a tip
4797 // in case it doesn't otherwise show in full length.
4799 if ( m_windowStyle
& wxPG_TOOLTIPS
)
4801 wxToolTip
* tooltip
= GetToolTip();
4803 if ( m_propHover
!= prevHover
|| prevSide
!= m_mouseSide
)
4805 if ( m_propHover
&& !m_propHover
->IsCategory() )
4808 if ( GetExtraStyle() & wxPG_EX_HELP_AS_TOOLTIPS
)
4810 // Show help string as a tooltip
4811 wxString tipString
= m_propHover
->GetHelpString();
4813 SetToolTip(tipString
);
4817 // Show cropped value string as a tooltip
4821 if ( m_mouseSide
== 1 )
4823 tipString
= m_propHover
->m_label
;
4824 space
= splitterX
-m_marginWidth
-3;
4826 else if ( m_mouseSide
== 2 )
4828 tipString
= m_propHover
->GetDisplayedString();
4830 space
= m_width
- splitterX
;
4831 if ( m_propHover
->m_flags
& wxPG_PROP_CUSTOMIMAGE
)
4832 space
-= wxPG_CUSTOM_IMAGE_WIDTH
+
4833 wxCC_CUSTOM_IMAGE_MARGIN1
+
4834 wxCC_CUSTOM_IMAGE_MARGIN2
;
4840 GetTextExtent( tipString
, &tw
, &th
, 0, 0 );
4843 SetToolTip( tipString
);
4850 #if wxPG_ALLOW_EMPTY_TOOLTIPS
4851 SetToolTip( m_emptyString
);
4853 wxScrolledWindow::SetToolTip( NULL
);
4864 #if wxPG_ALLOW_EMPTY_TOOLTIPS
4865 SetToolTip( m_emptyString
);
4867 wxScrolledWindow::SetToolTip( NULL
);
4875 if ( splitterHit
== -1 ||
4877 HasFlag(wxPG_STATIC_SPLITTER
) )
4879 // hovering on something else
4880 if ( m_curcursor
!= wxCURSOR_ARROW
)
4881 CustomSetCursor( wxCURSOR_ARROW
);
4885 // Do not allow splitter cursor on caption items.
4886 // (also not if we were dragging and its started
4887 // outside the splitter region)
4889 if ( !m_propHover
->IsCategory() &&
4893 // hovering on splitter
4895 // NB: Condition disabled since MouseLeave event (from the
4896 // editor control) cannot be reliably detected.
4897 //if ( m_curcursor != wxCURSOR_SIZEWE )
4898 CustomSetCursor( wxCURSOR_SIZEWE
, true );
4904 // hovering on something else
4905 if ( m_curcursor
!= wxCURSOR_ARROW
)
4906 CustomSetCursor( wxCURSOR_ARROW
);
4911 // Multi select by dragging
4913 if ( (GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION
) &&
4914 event
.LeftIsDown() &&
4918 !state
->DoIsPropertySelected(m_propHover
) )
4920 // Additional requirement is that the hovered property
4921 // is adjacent to edges of selection.
4922 const wxArrayPGProperty
& selection
= GetSelectedProperties();
4924 // Since categories cannot be selected along with 'other'
4925 // properties, exclude them from iterator flags.
4926 int iterFlags
= wxPG_ITERATE_VISIBLE
& (~wxPG_PROP_CATEGORY
);
4928 for ( int i
=(selection
.size()-1); i
>=0; i
-- )
4930 // TODO: This could be optimized by keeping track of
4931 // which properties are at the edges of selection.
4932 wxPGProperty
* selProp
= selection
[i
];
4933 if ( state
->ArePropertiesAdjacent(m_propHover
, selProp
,
4936 DoAddToSelection(m_propHover
);
4945 // -----------------------------------------------------------------------
4947 // Also handles Leaving event
4948 bool wxPropertyGrid::HandleMouseUp( int x
, unsigned int WXUNUSED(y
),
4949 wxMouseEvent
&WXUNUSED(event
) )
4951 wxPropertyGridPageState
* state
= m_pState
;
4955 int splitterHitOffset
;
4956 state
->HitTestH( x
, &splitterHit
, &splitterHitOffset
);
4958 // No event type check - basicly calling this method should
4959 // just stop dragging.
4960 // Left up after dragged?
4961 if ( m_dragStatus
>= 1 )
4964 // End Splitter Dragging
4966 // DO NOT ENABLE FOLLOWING LINE!
4967 // (it is only here as a reminder to not to do it)
4970 SendEvent(wxEVT_PG_COL_END_DRAG
,
4973 wxPG_SEL_NOVALIDATE
,
4974 (unsigned int)m_draggedSplitter
);
4976 // Disable splitter auto-centering
4977 state
->m_dontCenterSplitter
= true;
4979 // This is necessary to return cursor
4980 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
4983 m_iFlags
&= ~(wxPG_FL_MOUSE_CAPTURED
);
4986 // Set back the default cursor, if necessary
4987 if ( splitterHit
== -1 ||
4990 CustomSetCursor( wxCURSOR_ARROW
);
4995 // Control background needs to be cleared
4996 wxPGProperty
* selected
= GetSelection();
4997 if ( !(m_iFlags
& wxPG_FL_PRIMARY_FILLS_ENTIRE
) && selected
)
4998 DrawItem( selected
);
5002 m_wndEditor
->Show ( true );
5005 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
5006 // Fixes button disappearance bug
5008 m_wndEditor2
->Show ( true );
5011 // This clears the focus.
5012 m_editorFocused
= 0;
5018 // -----------------------------------------------------------------------
5020 bool wxPropertyGrid::OnMouseCommon( wxMouseEvent
& event
, int* px
, int* py
)
5022 int splitterX
= GetSplitterPosition();
5025 CalcUnscrolledPosition( event
.m_x
, event
.m_y
, &ux
, &uy
);
5027 wxWindow
* wnd
= GetEditorControl();
5029 // Hide popup on clicks
5030 if ( event
.GetEventType() != wxEVT_MOTION
)
5031 if ( wnd
&& wnd
->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox
)) )
5033 ((wxOwnerDrawnComboBox
*)wnd
)->HidePopup();
5039 if ( wnd
== NULL
|| m_dragStatus
||
5041 ux
<= (splitterX
+ wxPG_SPLITTERX_DETECTMARGIN2
) ||
5042 ux
>= (r
.x
+r
.width
) ||
5044 event
.m_y
>= (r
.y
+r
.height
)
5054 if ( m_curcursor
!= wxCURSOR_ARROW
) CustomSetCursor ( wxCURSOR_ARROW
);
5059 // -----------------------------------------------------------------------
5061 void wxPropertyGrid::OnMouseClick( wxMouseEvent
&event
)
5064 if ( OnMouseCommon( event
, &x
, &y
) )
5066 HandleMouseClick(x
,y
,event
);
5071 // -----------------------------------------------------------------------
5073 void wxPropertyGrid::OnMouseRightClick( wxMouseEvent
&event
)
5076 CalcUnscrolledPosition( event
.m_x
, event
.m_y
, &x
, &y
);
5077 HandleMouseRightClick(x
,y
,event
);
5081 // -----------------------------------------------------------------------
5083 void wxPropertyGrid::OnMouseDoubleClick( wxMouseEvent
&event
)
5085 // Always run standard mouse-down handler as well
5086 OnMouseClick(event
);
5089 CalcUnscrolledPosition( event
.m_x
, event
.m_y
, &x
, &y
);
5090 HandleMouseDoubleClick(x
,y
,event
);
5094 // -----------------------------------------------------------------------
5096 void wxPropertyGrid::OnMouseMove( wxMouseEvent
&event
)
5099 if ( OnMouseCommon( event
, &x
, &y
) )
5101 HandleMouseMove(x
,y
,event
);
5106 // -----------------------------------------------------------------------
5108 void wxPropertyGrid::OnMouseUp( wxMouseEvent
&event
)
5111 if ( OnMouseCommon( event
, &x
, &y
) )
5113 HandleMouseUp(x
,y
,event
);
5118 // -----------------------------------------------------------------------
5120 void wxPropertyGrid::OnMouseEntry( wxMouseEvent
&event
)
5122 // This may get called from child control as well, so event's
5123 // mouse position cannot be relied on.
5125 if ( event
.Entering() )
5127 if ( !(m_iFlags
& wxPG_FL_MOUSE_INSIDE
) )
5129 // TODO: Fix this (detect parent and only do
5130 // cursor trick if it is a manager).
5131 wxASSERT( GetParent() );
5132 GetParent()->SetCursor(wxNullCursor
);
5134 m_iFlags
|= wxPG_FL_MOUSE_INSIDE
;
5137 GetParent()->SetCursor(wxNullCursor
);
5139 else if ( event
.Leaving() )
5141 // Without this, wxSpinCtrl editor will sometimes have wrong cursor
5142 SetCursor( wxNullCursor
);
5144 // Get real cursor position
5145 wxPoint pt
= ScreenToClient(::wxGetMousePosition());
5147 if ( ( pt
.x
<= 0 || pt
.y
<= 0 || pt
.x
>= m_width
|| pt
.y
>= m_height
) )
5150 if ( (m_iFlags
& wxPG_FL_MOUSE_INSIDE
) )
5152 m_iFlags
&= ~(wxPG_FL_MOUSE_INSIDE
);
5156 wxPropertyGrid::HandleMouseUp ( -1, 10000, event
);
5164 // -----------------------------------------------------------------------
5166 // Common code used by various OnMouseXXXChild methods.
5167 bool wxPropertyGrid::OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
)
5169 wxWindow
* topCtrlWnd
= (wxWindow
*)event
.GetEventObject();
5170 wxASSERT( topCtrlWnd
);
5172 event
.GetPosition(&x
,&y
);
5174 int splitterX
= GetSplitterPosition();
5176 wxRect r
= topCtrlWnd
->GetRect();
5177 if ( !m_dragStatus
&&
5178 x
> (splitterX
-r
.x
+wxPG_SPLITTERX_DETECTMARGIN2
) &&
5179 y
>= 0 && y
< r
.height \
5182 if ( m_curcursor
!= wxCURSOR_ARROW
) CustomSetCursor ( wxCURSOR_ARROW
);
5187 CalcUnscrolledPosition( event
.m_x
+ r
.x
, event
.m_y
+ r
.y
, \
5194 void wxPropertyGrid::OnMouseClickChild( wxMouseEvent
&event
)
5197 if ( OnMouseChildCommon(event
,&x
,&y
) )
5199 bool res
= HandleMouseClick(x
,y
,event
);
5200 if ( !res
) event
.Skip();
5204 void wxPropertyGrid::OnMouseRightClickChild( wxMouseEvent
&event
)
5207 wxASSERT( m_wndEditor
);
5208 // These coords may not be exact (about +-2),
5209 // but that should not matter (right click is about item, not position).
5210 wxPoint pt
= m_wndEditor
->GetPosition();
5211 CalcUnscrolledPosition( event
.m_x
+ pt
.x
, event
.m_y
+ pt
.y
, &x
, &y
);
5213 // FIXME: Used to set m_propHover to selection here. Was it really
5216 bool res
= HandleMouseRightClick(x
,y
,event
);
5217 if ( !res
) event
.Skip();
5220 void wxPropertyGrid::OnMouseMoveChild( wxMouseEvent
&event
)
5223 if ( OnMouseChildCommon(event
,&x
,&y
) )
5225 bool res
= HandleMouseMove(x
,y
,event
);
5226 if ( !res
) event
.Skip();
5230 void wxPropertyGrid::OnMouseUpChild( wxMouseEvent
&event
)
5233 if ( OnMouseChildCommon(event
,&x
,&y
) )
5235 bool res
= HandleMouseUp(x
,y
,event
);
5236 if ( !res
) event
.Skip();
5240 // -----------------------------------------------------------------------
5241 // wxPropertyGrid keyboard event handling
5242 // -----------------------------------------------------------------------
5244 int wxPropertyGrid::KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const
5246 // Translates wxKeyEvent to wxPG_ACTION_XXX
5248 int keycode
= event
.GetKeyCode();
5249 int modifiers
= event
.GetModifiers();
5251 wxASSERT( !(modifiers
&~(0xFFFF)) );
5253 int hashMapKey
= (keycode
& 0xFFFF) | ((modifiers
& 0xFFFF) << 16);
5255 wxPGHashMapI2I::const_iterator it
= m_actionTriggers
.find(hashMapKey
);
5257 if ( it
== m_actionTriggers
.end() )
5262 int second
= (it
->second
>>16) & 0xFFFF;
5266 return (it
->second
& 0xFFFF);
5269 void wxPropertyGrid::AddActionTrigger( int action
, int keycode
, int modifiers
)
5271 wxASSERT( !(modifiers
&~(0xFFFF)) );
5273 int hashMapKey
= (keycode
& 0xFFFF) | ((modifiers
& 0xFFFF) << 16);
5275 wxPGHashMapI2I::iterator it
= m_actionTriggers
.find(hashMapKey
);
5277 if ( it
!= m_actionTriggers
.end() )
5279 // This key combination is already used
5281 // Can add secondary?
5282 wxASSERT_MSG( !(it
->second
&~(0xFFFF)),
5283 wxT("You can only add up to two separate actions per key combination.") );
5285 action
= it
->second
| (action
<<16);
5288 m_actionTriggers
[hashMapKey
] = action
;
5291 void wxPropertyGrid::ClearActionTriggers( int action
)
5293 wxPGHashMapI2I::iterator it
;
5298 didSomething
= false;
5300 for ( it
= m_actionTriggers
.begin();
5301 it
!= m_actionTriggers
.end();
5304 if ( it
->second
== action
)
5306 m_actionTriggers
.erase(it
);
5307 didSomething
= true;
5312 while ( didSomething
);
5315 void wxPropertyGrid::HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
)
5318 // Handles key event when editor control is not focused.
5321 wxCHECK2(!m_frozen
, return);
5323 // Travelsal between items, collapsing/expanding, etc.
5324 wxPGProperty
* selected
= GetSelection();
5325 int keycode
= event
.GetKeyCode();
5326 bool editorFocused
= IsEditorFocused();
5328 if ( keycode
== WXK_TAB
)
5330 wxWindow
* mainControl
;
5332 if ( HasInternalFlag(wxPG_FL_IN_MANAGER
) )
5333 mainControl
= GetParent();
5337 if ( !event
.ShiftDown() )
5339 if ( !editorFocused
&& m_wndEditor
)
5341 DoSelectProperty( selected
, wxPG_SEL_FOCUS
);
5345 // Tab traversal workaround for platforms on which
5346 // wxWindow::Navigate() may navigate into first child
5347 // instead of next sibling. Does not work perfectly
5348 // in every scenario (for instance, when property grid
5349 // is either first or last control).
5350 #if defined(__WXGTK__)
5351 wxWindow
* sibling
= mainControl
->GetNextSibling();
5353 sibling
->SetFocusFromKbd();
5355 Navigate(wxNavigationKeyEvent::IsForward
);
5361 if ( editorFocused
)
5367 #if defined(__WXGTK__)
5368 wxWindow
* sibling
= mainControl
->GetPrevSibling();
5370 sibling
->SetFocusFromKbd();
5372 Navigate(wxNavigationKeyEvent::IsBackward
);
5380 // Ignore Alt and Control when they are down alone
5381 if ( keycode
== WXK_ALT
||
5382 keycode
== WXK_CONTROL
)
5389 int action
= KeyEventToActions(event
, &secondAction
);
5391 if ( editorFocused
&& action
== wxPG_ACTION_CANCEL_EDIT
)
5394 // Esc cancels any changes
5395 if ( IsEditorsValueModified() )
5397 EditorsValueWasNotModified();
5399 // Update the control as well
5400 selected
->GetEditorClass()->
5401 SetControlStringValue( selected
,
5403 selected
->GetDisplayedString() );
5406 OnValidationFailureReset(selected
);
5412 // Except for TAB and ESC, handle child control events in child control
5415 // Only propagate event if it had modifiers
5416 if ( !event
.HasModifiers() )
5418 event
.StopPropagation();
5424 bool wasHandled
= false;
5429 if ( ButtonTriggerKeyTest(action
, event
) )
5432 wxPGProperty
* p
= selected
;
5434 // Travel and expand/collapse
5437 if ( p
->GetChildCount() )
5439 if ( action
== wxPG_ACTION_COLLAPSE_PROPERTY
|| secondAction
== wxPG_ACTION_COLLAPSE_PROPERTY
)
5441 if ( (m_windowStyle
& wxPG_HIDE_MARGIN
) || Collapse(p
) )
5444 else if ( action
== wxPG_ACTION_EXPAND_PROPERTY
|| secondAction
== wxPG_ACTION_EXPAND_PROPERTY
)
5446 if ( (m_windowStyle
& wxPG_HIDE_MARGIN
) || Expand(p
) )
5453 if ( action
== wxPG_ACTION_PREV_PROPERTY
|| secondAction
== wxPG_ACTION_PREV_PROPERTY
)
5457 else if ( action
== wxPG_ACTION_NEXT_PROPERTY
|| secondAction
== wxPG_ACTION_NEXT_PROPERTY
)
5463 if ( selectDir
>= -1 )
5465 p
= wxPropertyGridIterator::OneStep( m_pState
, wxPG_ITERATE_VISIBLE
, p
, selectDir
);
5467 DoSelectProperty(p
);
5473 // If nothing was selected, select the first item now
5474 // (or navigate out of tab).
5475 if ( action
!= wxPG_ACTION_CANCEL_EDIT
&& secondAction
!= wxPG_ACTION_CANCEL_EDIT
)
5477 wxPGProperty
* p
= wxPropertyGridInterface::GetFirst();
5478 if ( p
) DoSelectProperty(p
);
5487 // -----------------------------------------------------------------------
5489 void wxPropertyGrid::OnKey( wxKeyEvent
&event
)
5491 // If there was editor open and focused, then this event should not
5492 // really be processed here.
5493 if ( IsEditorFocused() )
5495 // However, if event had modifiers, it is probably still best
5497 if ( event
.HasModifiers() )
5500 event
.StopPropagation();
5504 HandleKeyEvent(event
, false);
5507 // -----------------------------------------------------------------------
5509 bool wxPropertyGrid::ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
)
5514 action
= KeyEventToActions(event
, &secondAction
);
5517 // Does the keycode trigger button?
5518 if ( action
== wxPG_ACTION_PRESS_BUTTON
&&
5521 wxCommandEvent
evt(wxEVT_COMMAND_BUTTON_CLICKED
, m_wndEditor2
->GetId());
5522 GetEventHandler()->AddPendingEvent(evt
);
5529 // -----------------------------------------------------------------------
5531 void wxPropertyGrid::OnChildKeyDown( wxKeyEvent
&event
)
5533 HandleKeyEvent(event
, true);
5536 // -----------------------------------------------------------------------
5537 // wxPropertyGrid miscellaneous event handling
5538 // -----------------------------------------------------------------------
5540 void wxPropertyGrid::OnIdle( wxIdleEvent
& WXUNUSED(event
) )
5543 // Check if the focus is in this control or one of its children
5544 wxWindow
* newFocused
= wxWindow::FindFocus();
5546 if ( newFocused
!= m_curFocused
)
5547 HandleFocusChange( newFocused
);
5550 // Check if top-level parent has changed
5551 if ( GetExtraStyle() & wxPG_EX_ENABLE_TLP_TRACKING
)
5553 wxWindow
* tlp
= ::wxGetTopLevelParent(this);
5559 bool wxPropertyGrid::IsEditorFocused() const
5561 wxWindow
* focus
= wxWindow::FindFocus();
5563 if ( focus
== m_wndEditor
|| focus
== m_wndEditor2
||
5564 focus
== GetEditorControl() )
5570 // Called by focus event handlers. newFocused is the window that becomes focused.
5571 void wxPropertyGrid::HandleFocusChange( wxWindow
* newFocused
)
5573 unsigned int oldFlags
= m_iFlags
;
5574 bool wasEditorFocused
= false;
5575 wxWindow
* wndEditor
= m_wndEditor
;
5577 m_iFlags
&= ~(wxPG_FL_FOCUSED
);
5579 wxWindow
* parent
= newFocused
;
5581 // This must be one of nextFocus' parents.
5584 if ( parent
== wndEditor
)
5586 wasEditorFocused
= true;
5588 // Use m_eventObject, which is either wxPropertyGrid or
5589 // wxPropertyGridManager, as appropriate.
5590 else if ( parent
== m_eventObject
)
5592 m_iFlags
|= wxPG_FL_FOCUSED
;
5595 parent
= parent
->GetParent();
5598 // Notify editor control when it receives a focus
5599 if ( wasEditorFocused
&& m_curFocused
!= newFocused
)
5601 wxPGProperty
* p
= GetSelection();
5604 const wxPGEditor
* editor
= p
->GetEditorClass();
5605 editor
->OnFocus(p
, GetEditorControl());
5609 m_curFocused
= newFocused
;
5611 if ( (m_iFlags
& wxPG_FL_FOCUSED
) !=
5612 (oldFlags
& wxPG_FL_FOCUSED
) )
5614 if ( !(m_iFlags
& wxPG_FL_FOCUSED
) )
5616 // Need to store changed value
5617 CommitChangesFromEditor();
5623 // Preliminary code for tab-order respecting
5624 // tab-traversal (but should be moved to
5627 wxWindow* prevFocus = event.GetWindow();
5628 wxWindow* useThis = this;
5629 if ( m_iFlags & wxPG_FL_IN_MANAGER )
5630 useThis = GetParent();
5633 prevFocus->GetParent() == useThis->GetParent() )
5635 wxList& children = useThis->GetParent()->GetChildren();
5637 wxNode* node = children.Find(prevFocus);
5639 if ( node->GetNext() &&
5640 useThis == node->GetNext()->GetData() )
5641 DoSelectProperty(GetFirst());
5642 else if ( node->GetPrevious () &&
5643 useThis == node->GetPrevious()->GetData() )
5644 DoSelectProperty(GetLastProperty());
5651 wxPGProperty
* selected
= GetSelection();
5652 if ( selected
&& (m_iFlags
& wxPG_FL_INITIALIZED
) )
5653 DrawItem( selected
);
5657 void wxPropertyGrid::OnFocusEvent( wxFocusEvent
& event
)
5659 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
5660 HandleFocusChange((wxWindow
*)event
.GetEventObject());
5661 // Line changed to "else" when applying wxPropertyGrid patch #1675902
5662 //else if ( event.GetWindow() )
5664 HandleFocusChange(event
.GetWindow());
5669 // -----------------------------------------------------------------------
5671 void wxPropertyGrid::OnChildFocusEvent( wxChildFocusEvent
& event
)
5673 HandleFocusChange((wxWindow
*)event
.GetEventObject());
5677 // -----------------------------------------------------------------------
5679 void wxPropertyGrid::OnScrollEvent( wxScrollWinEvent
&event
)
5681 m_iFlags
|= wxPG_FL_SCROLLED
;
5686 // -----------------------------------------------------------------------
5688 void wxPropertyGrid::OnCaptureChange( wxMouseCaptureChangedEvent
& WXUNUSED(event
) )
5690 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
5692 m_iFlags
&= ~(wxPG_FL_MOUSE_CAPTURED
);
5696 // -----------------------------------------------------------------------
5697 // Property editor related functions
5698 // -----------------------------------------------------------------------
5700 // noDefCheck = true prevents infinite recursion.
5701 wxPGEditor
* wxPropertyGrid::DoRegisterEditorClass( wxPGEditor
* editorClass
,
5702 const wxString
& editorName
,
5705 wxASSERT( editorClass
);
5707 if ( !noDefCheck
&& wxPGGlobalVars
->m_mapEditorClasses
.empty() )
5708 RegisterDefaultEditors();
5710 wxString name
= editorName
;
5711 if ( name
.length() == 0 )
5712 name
= editorClass
->GetName();
5714 // Existing editor under this name?
5715 wxPGHashMapS2P::iterator vt_it
= wxPGGlobalVars
->m_mapEditorClasses
.find(name
);
5717 if ( vt_it
!= wxPGGlobalVars
->m_mapEditorClasses
.end() )
5719 // If this name was already used, try class name.
5720 name
= editorClass
->GetClassInfo()->GetClassName();
5721 vt_it
= wxPGGlobalVars
->m_mapEditorClasses
.find(name
);
5724 wxCHECK_MSG( vt_it
== wxPGGlobalVars
->m_mapEditorClasses
.end(),
5725 (wxPGEditor
*) vt_it
->second
,
5726 "Editor with given name was already registered" );
5728 wxPGGlobalVars
->m_mapEditorClasses
[name
] = (void*)editorClass
;
5733 // Use this in RegisterDefaultEditors.
5734 #define wxPGRegisterDefaultEditorClass(EDITOR) \
5735 if ( wxPGEditor_##EDITOR == NULL ) \
5737 wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \
5738 new wxPG##EDITOR##Editor, true ); \
5741 // Registers all default editor classes
5742 void wxPropertyGrid::RegisterDefaultEditors()
5744 wxPGRegisterDefaultEditorClass( TextCtrl
);
5745 wxPGRegisterDefaultEditorClass( Choice
);
5746 wxPGRegisterDefaultEditorClass( ComboBox
);
5747 wxPGRegisterDefaultEditorClass( TextCtrlAndButton
);
5748 #if wxPG_INCLUDE_CHECKBOX
5749 wxPGRegisterDefaultEditorClass( CheckBox
);
5751 wxPGRegisterDefaultEditorClass( ChoiceAndButton
);
5753 // Register SpinCtrl etc. editors before use
5754 RegisterAdditionalEditors();
5757 // -----------------------------------------------------------------------
5758 // wxPGStringTokenizer
5759 // Needed to handle C-style string lists (e.g. "str1" "str2")
5760 // -----------------------------------------------------------------------
5762 wxPGStringTokenizer::wxPGStringTokenizer( const wxString
& str
, wxChar delimeter
)
5763 : m_str(&str
), m_curPos(str
.begin()), m_delimeter(delimeter
)
5767 wxPGStringTokenizer::~wxPGStringTokenizer()
5771 bool wxPGStringTokenizer::HasMoreTokens()
5773 const wxString
& str
= *m_str
;
5775 wxString::const_iterator i
= m_curPos
;
5777 wxUniChar delim
= m_delimeter
;
5779 wxUniChar prev_a
= wxT('\0');
5781 bool inToken
= false;
5783 while ( i
!= str
.end() )
5792 m_readyToken
.clear();
5797 if ( prev_a
!= wxT('\\') )
5801 if ( a
!= wxT('\\') )
5821 m_curPos
= str
.end();
5829 wxString
wxPGStringTokenizer::GetNextToken()
5831 return m_readyToken
;
5834 // -----------------------------------------------------------------------
5836 // -----------------------------------------------------------------------
5838 wxPGChoiceEntry::wxPGChoiceEntry()
5839 : wxPGCell(), m_value(wxPG_INVALID_VALUE
)
5843 // -----------------------------------------------------------------------
5845 // -----------------------------------------------------------------------
5847 wxPGChoicesData::wxPGChoicesData()
5851 wxPGChoicesData::~wxPGChoicesData()
5856 void wxPGChoicesData::Clear()
5861 void wxPGChoicesData::CopyDataFrom( wxPGChoicesData
* data
)
5863 wxASSERT( m_items
.size() == 0 );
5865 m_items
= data
->m_items
;
5868 wxPGChoiceEntry
& wxPGChoicesData::Insert( int index
,
5869 const wxPGChoiceEntry
& item
)
5871 wxVector
<wxPGChoiceEntry
>::iterator it
;
5875 index
= (int) m_items
.size();
5879 it
= m_items
.begin() + index
;
5882 m_items
.insert(it
, item
);
5884 wxPGChoiceEntry
& ownEntry
= m_items
[index
];
5886 // Need to fix value?
5887 if ( ownEntry
.GetValue() == wxPG_INVALID_VALUE
)
5888 ownEntry
.SetValue(index
);
5893 // -----------------------------------------------------------------------
5894 // wxPropertyGridEvent
5895 // -----------------------------------------------------------------------
5897 IMPLEMENT_DYNAMIC_CLASS(wxPropertyGridEvent
, wxCommandEvent
)
5900 wxDEFINE_EVENT( wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
5901 wxDEFINE_EVENT( wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
5902 wxDEFINE_EVENT( wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
5903 wxDEFINE_EVENT( wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
5904 wxDEFINE_EVENT( wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
5905 wxDEFINE_EVENT( wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
5906 wxDEFINE_EVENT( wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
5907 wxDEFINE_EVENT( wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
5908 wxDEFINE_EVENT( wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
5909 wxDEFINE_EVENT( wxEVT_PG_LABEL_EDIT_BEGIN
, wxPropertyGridEvent
);
5910 wxDEFINE_EVENT( wxEVT_PG_LABEL_EDIT_ENDING
, wxPropertyGridEvent
);
5911 wxDEFINE_EVENT( wxEVT_PG_COL_BEGIN_DRAG
, wxPropertyGridEvent
);
5912 wxDEFINE_EVENT( wxEVT_PG_COL_DRAGGING
, wxPropertyGridEvent
);
5913 wxDEFINE_EVENT( wxEVT_PG_COL_END_DRAG
, wxPropertyGridEvent
);
5915 // -----------------------------------------------------------------------
5917 void wxPropertyGridEvent::Init()
5919 m_validationInfo
= NULL
;
5922 m_wasVetoed
= false;
5925 // -----------------------------------------------------------------------
5927 wxPropertyGridEvent::wxPropertyGridEvent(wxEventType commandType
, int id
)
5928 : wxCommandEvent(commandType
,id
)
5934 // -----------------------------------------------------------------------
5936 wxPropertyGridEvent::wxPropertyGridEvent(const wxPropertyGridEvent
& event
)
5937 : wxCommandEvent(event
)
5939 m_eventType
= event
.GetEventType();
5940 m_eventObject
= event
.m_eventObject
;
5942 OnPropertyGridSet();
5943 m_property
= event
.m_property
;
5944 m_validationInfo
= event
.m_validationInfo
;
5945 m_canVeto
= event
.m_canVeto
;
5946 m_wasVetoed
= event
.m_wasVetoed
;
5949 // -----------------------------------------------------------------------
5951 void wxPropertyGridEvent::OnPropertyGridSet()
5957 wxCriticalSectionLocker(wxPGGlobalVars
->m_critSect
);
5959 m_pg
->m_liveEvents
.push_back(this);
5962 // -----------------------------------------------------------------------
5964 wxPropertyGridEvent::~wxPropertyGridEvent()
5969 wxCriticalSectionLocker(wxPGGlobalVars
->m_critSect
);
5972 // Use iterate from the back since it is more likely that the event
5973 // being desroyed is at the end of the array.
5974 wxVector
<wxPropertyGridEvent
*>& liveEvents
= m_pg
->m_liveEvents
;
5976 for ( int i
= liveEvents
.size()-1; i
>= 0; i
-- )
5978 if ( liveEvents
[i
] == this )
5980 liveEvents
.erase(liveEvents
.begin() + i
);
5987 // -----------------------------------------------------------------------
5989 wxEvent
* wxPropertyGridEvent::Clone() const
5991 return new wxPropertyGridEvent( *this );
5994 // -----------------------------------------------------------------------
5995 // wxPropertyGridPopulator
5996 // -----------------------------------------------------------------------
5998 wxPropertyGridPopulator::wxPropertyGridPopulator()
6002 wxPGGlobalVars
->m_offline
++;
6005 // -----------------------------------------------------------------------
6007 void wxPropertyGridPopulator::SetState( wxPropertyGridPageState
* state
)
6010 m_propHierarchy
.clear();
6013 // -----------------------------------------------------------------------
6015 void wxPropertyGridPopulator::SetGrid( wxPropertyGrid
* pg
)
6021 // -----------------------------------------------------------------------
6023 wxPropertyGridPopulator::~wxPropertyGridPopulator()
6026 // Free unused sets of choices
6027 wxPGHashMapS2P::iterator it
;
6029 for( it
= m_dictIdChoices
.begin(); it
!= m_dictIdChoices
.end(); ++it
)
6031 wxPGChoicesData
* data
= (wxPGChoicesData
*) it
->second
;
6038 m_pg
->GetPanel()->Refresh();
6040 wxPGGlobalVars
->m_offline
--;
6043 // -----------------------------------------------------------------------
6045 wxPGProperty
* wxPropertyGridPopulator::Add( const wxString
& propClass
,
6046 const wxString
& propLabel
,
6047 const wxString
& propName
,
6048 const wxString
* propValue
,
6049 wxPGChoices
* pChoices
)
6051 wxClassInfo
* classInfo
= wxClassInfo::FindClass(propClass
);
6052 wxPGProperty
* parent
= GetCurParent();
6054 if ( parent
->HasFlag(wxPG_PROP_AGGREGATE
) )
6056 ProcessError(wxString::Format(wxT("new children cannot be added to '%s'"),parent
->GetName().c_str()));
6060 if ( !classInfo
|| !classInfo
->IsKindOf(CLASSINFO(wxPGProperty
)) )
6062 ProcessError(wxString::Format(wxT("'%s' is not valid property class"),propClass
.c_str()));
6066 wxPGProperty
* property
= (wxPGProperty
*) classInfo
->CreateObject();
6068 property
->SetLabel(propLabel
);
6069 property
->DoSetName(propName
);
6071 if ( pChoices
&& pChoices
->IsOk() )
6072 property
->SetChoices(*pChoices
);
6074 m_state
->DoInsert(parent
, -1, property
);
6077 property
->SetValueFromString( *propValue
, wxPG_FULL_VALUE
|
6078 wxPG_PROGRAMMATIC_VALUE
);
6083 // -----------------------------------------------------------------------
6085 void wxPropertyGridPopulator::AddChildren( wxPGProperty
* property
)
6087 m_propHierarchy
.push_back(property
);
6088 DoScanForChildren();
6089 m_propHierarchy
.pop_back();
6092 // -----------------------------------------------------------------------
6094 wxPGChoices
wxPropertyGridPopulator::ParseChoices( const wxString
& choicesString
,
6095 const wxString
& idString
)
6097 wxPGChoices choices
;
6100 if ( choicesString
[0] == wxT('@') )
6102 wxString ids
= choicesString
.substr(1);
6103 wxPGHashMapS2P::iterator it
= m_dictIdChoices
.find(ids
);
6104 if ( it
== m_dictIdChoices
.end() )
6105 ProcessError(wxString::Format(wxT("No choices defined for id '%s'"),ids
.c_str()));
6107 choices
.AssignData((wxPGChoicesData
*)it
->second
);
6112 if ( idString
.length() )
6114 wxPGHashMapS2P::iterator it
= m_dictIdChoices
.find(idString
);
6115 if ( it
!= m_dictIdChoices
.end() )
6117 choices
.AssignData((wxPGChoicesData
*)it
->second
);
6124 // Parse choices string
6125 wxString::const_iterator it
= choicesString
.begin();
6129 bool labelValid
= false;
6131 for ( ; it
!= choicesString
.end(); ++it
)
6137 if ( c
== wxT('"') )
6142 if ( !value
.ToLong(&l
, 0) ) l
= wxPG_INVALID_VALUE
;
6143 choices
.Add(label
, l
);
6146 //wxLogDebug(wxT("%s, %s"),label.c_str(),value.c_str());
6151 else if ( c
== wxT('=') )
6158 else if ( state
== 2 && (wxIsalnum(c
) || c
== wxT('x')) )
6165 if ( c
== wxT('"') )
6178 if ( !value
.ToLong(&l
, 0) ) l
= wxPG_INVALID_VALUE
;
6179 choices
.Add(label
, l
);
6182 if ( !choices
.IsOk() )
6184 choices
.EnsureData();
6188 if ( idString
.length() )
6189 m_dictIdChoices
[idString
] = choices
.GetData();
6196 // -----------------------------------------------------------------------
6198 bool wxPropertyGridPopulator::ToLongPCT( const wxString
& s
, long* pval
, long max
)
6200 if ( s
.Last() == wxT('%') )
6202 wxString s2
= s
.substr(0,s
.length()-1);
6204 if ( s2
.ToLong(&val
, 10) )
6206 *pval
= (val
*max
)/100;
6212 return s
.ToLong(pval
, 10);
6215 // -----------------------------------------------------------------------
6217 bool wxPropertyGridPopulator::AddAttribute( const wxString
& name
,
6218 const wxString
& type
,
6219 const wxString
& value
)
6221 int l
= m_propHierarchy
.size();
6225 wxPGProperty
* p
= m_propHierarchy
[l
-1];
6226 wxString valuel
= value
.Lower();
6229 if ( type
.length() == 0 )
6234 if ( valuel
== wxT("true") || valuel
== wxT("yes") || valuel
== wxT("1") )
6236 else if ( valuel
== wxT("false") || valuel
== wxT("no") || valuel
== wxT("0") )
6238 else if ( value
.ToLong(&v
, 0) )
6245 if ( type
== wxT("string") )
6249 else if ( type
== wxT("int") )
6252 value
.ToLong(&v
, 0);
6255 else if ( type
== wxT("bool") )
6257 if ( valuel
== wxT("true") || valuel
== wxT("yes") || valuel
== wxT("1") )
6264 ProcessError(wxString::Format(wxT("Invalid attribute type '%s'"),type
.c_str()));
6269 p
->SetAttribute( name
, variant
);
6274 // -----------------------------------------------------------------------
6276 void wxPropertyGridPopulator::ProcessError( const wxString
& msg
)
6278 wxLogError(_("Error in resource: %s"),msg
.c_str());
6281 // -----------------------------------------------------------------------
6283 #endif // wxUSE_PROPGRID