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 // -----------------------------------------------------------------------
121 void wxPropertyGrid::AutoGetTranslation ( bool enable
)
123 wxPGGlobalVars
->m_autoGetTranslation
= enable
;
126 void wxPropertyGrid::AutoGetTranslation ( bool ) { }
129 // -----------------------------------------------------------------------
131 const char wxPropertyGridNameStr
[] = "wxPropertyGrid";
133 // -----------------------------------------------------------------------
134 // Statics in one class for easy destruction.
135 // -----------------------------------------------------------------------
137 #include "wx/module.h"
139 class wxPGGlobalVarsClassManager
: public wxModule
141 DECLARE_DYNAMIC_CLASS(wxPGGlobalVarsClassManager
)
143 wxPGGlobalVarsClassManager() {}
144 virtual bool OnInit() { wxPGGlobalVars
= new wxPGGlobalVarsClass(); return true; }
145 virtual void OnExit() { delete wxPGGlobalVars
; wxPGGlobalVars
= NULL
; }
148 IMPLEMENT_DYNAMIC_CLASS(wxPGGlobalVarsClassManager
, wxModule
)
151 // When wxPG is loaded dynamically after the application is already running
152 // then the built-in module system won't pick this one up. Add it manually.
153 void wxPGInitResourceModule()
155 wxModule
* module = new wxPGGlobalVarsClassManager
;
157 wxModule::RegisterModule(module);
160 wxPGGlobalVarsClass
* wxPGGlobalVars
= NULL
;
163 wxPGGlobalVarsClass::wxPGGlobalVarsClass()
165 wxPGProperty::sm_wxPG_LABEL
= new wxString(wxPG_LABEL_STRING
);
167 m_boolChoices
.Add(_("False"));
168 m_boolChoices
.Add(_("True"));
170 m_fontFamilyChoices
= NULL
;
172 m_defaultRenderer
= new wxPGDefaultRenderer();
174 m_autoGetTranslation
= false;
182 // Prepare some shared variants
183 m_vEmptyString
= wxString();
185 m_vMinusOne
= (long) -1;
189 // Prepare cached string constants
190 m_strstring
= wxS("string");
191 m_strlong
= wxS("long");
192 m_strbool
= wxS("bool");
193 m_strlist
= wxS("list");
194 m_strDefaultValue
= wxS("DefaultValue");
195 m_strMin
= wxS("Min");
196 m_strMax
= wxS("Max");
197 m_strUnits
= wxS("Units");
198 m_strInlineHelp
= wxS("InlineHelp");
204 wxPGGlobalVarsClass::~wxPGGlobalVarsClass()
208 delete m_defaultRenderer
;
210 // This will always have one ref
211 delete m_fontFamilyChoices
;
214 for ( i
=0; i
<m_arrValidators
.size(); i
++ )
215 delete ((wxValidator
*)m_arrValidators
[i
]);
219 // Destroy value type class instances.
220 wxPGHashMapS2P::iterator vt_it
;
222 // Destroy editor class instances.
223 // iterate over all the elements in the class
224 for( vt_it
= m_mapEditorClasses
.begin(); vt_it
!= m_mapEditorClasses
.end(); ++vt_it
)
226 delete ((wxPGEditor
*)vt_it
->second
);
229 delete wxPGProperty::sm_wxPG_LABEL
;
232 void wxPropertyGridInitGlobalsIfNeeded()
236 // -----------------------------------------------------------------------
238 // -----------------------------------------------------------------------
241 // wxPGCanvas acts as a graphics sub-window of the
242 // wxScrolledWindow that wxPropertyGrid is.
244 class wxPGCanvas
: public wxPanel
247 wxPGCanvas() : wxPanel()
250 virtual ~wxPGCanvas() { }
253 void OnMouseMove( wxMouseEvent
&event
)
255 wxPropertyGrid
* pg
= wxStaticCast(GetParent(), wxPropertyGrid
);
256 pg
->OnMouseMove( event
);
259 void OnMouseClick( wxMouseEvent
&event
)
261 wxPropertyGrid
* pg
= wxStaticCast(GetParent(), wxPropertyGrid
);
262 pg
->OnMouseClick( event
);
265 void OnMouseUp( wxMouseEvent
&event
)
267 wxPropertyGrid
* pg
= wxStaticCast(GetParent(), wxPropertyGrid
);
268 pg
->OnMouseUp( event
);
271 void OnMouseRightClick( wxMouseEvent
&event
)
273 wxPropertyGrid
* pg
= wxStaticCast(GetParent(), wxPropertyGrid
);
274 pg
->OnMouseRightClick( event
);
277 void OnMouseDoubleClick( wxMouseEvent
&event
)
279 wxPropertyGrid
* pg
= wxStaticCast(GetParent(), wxPropertyGrid
);
280 pg
->OnMouseDoubleClick( event
);
283 void OnKey( wxKeyEvent
& event
)
285 wxPropertyGrid
* pg
= wxStaticCast(GetParent(), wxPropertyGrid
);
289 void OnPaint( wxPaintEvent
& event
);
291 // Always be focussable, even with child windows
292 virtual void SetCanFocus(bool WXUNUSED(canFocus
))
293 { wxPanel::SetCanFocus(true); }
297 DECLARE_EVENT_TABLE()
298 DECLARE_ABSTRACT_CLASS(wxPGCanvas
)
302 IMPLEMENT_ABSTRACT_CLASS(wxPGCanvas
,wxPanel
)
304 BEGIN_EVENT_TABLE(wxPGCanvas
, wxPanel
)
305 EVT_MOTION(wxPGCanvas::OnMouseMove
)
306 EVT_PAINT(wxPGCanvas::OnPaint
)
307 EVT_LEFT_DOWN(wxPGCanvas::OnMouseClick
)
308 EVT_LEFT_UP(wxPGCanvas::OnMouseUp
)
309 EVT_RIGHT_UP(wxPGCanvas::OnMouseRightClick
)
310 EVT_LEFT_DCLICK(wxPGCanvas::OnMouseDoubleClick
)
311 EVT_KEY_DOWN(wxPGCanvas::OnKey
)
315 void wxPGCanvas::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
317 wxPropertyGrid
* pg
= wxStaticCast(GetParent(), wxPropertyGrid
);
318 wxASSERT( pg
->IsKindOf(CLASSINFO(wxPropertyGrid
)) );
322 // Don't paint after destruction has begun
323 if ( !(pg
->GetInternalFlags() & wxPG_FL_INITIALIZED
) )
326 // Update everything inside the box
327 wxRect r
= GetUpdateRegion().GetBox();
329 // FIXME: This is just a workaround for a bug that causes splitters not
330 // to paint when other windows are being dragged over the grid.
331 wxRect fullRect
= GetRect();
333 r
.width
= fullRect
.width
;
335 // Repaint this rectangle
336 pg
->DrawItems( dc
, r
.y
, r
.y
+ r
.height
, &r
);
338 // We assume that the size set when grid is shown
339 // is what is desired.
340 pg
->SetInternalFlag(wxPG_FL_GOOD_SIZE_SET
);
343 // -----------------------------------------------------------------------
345 // -----------------------------------------------------------------------
347 IMPLEMENT_DYNAMIC_CLASS(wxPropertyGrid
, wxScrolledWindow
)
349 BEGIN_EVENT_TABLE(wxPropertyGrid
, wxScrolledWindow
)
350 EVT_IDLE(wxPropertyGrid::OnIdle
)
351 EVT_MOTION(wxPropertyGrid::OnMouseMoveBottom
)
352 EVT_PAINT(wxPropertyGrid::OnPaint
)
353 EVT_SIZE(wxPropertyGrid::OnResize
)
354 EVT_ENTER_WINDOW(wxPropertyGrid::OnMouseEntry
)
355 EVT_LEAVE_WINDOW(wxPropertyGrid::OnMouseEntry
)
356 EVT_MOUSE_CAPTURE_CHANGED(wxPropertyGrid::OnCaptureChange
)
357 EVT_SCROLLWIN(wxPropertyGrid::OnScrollEvent
)
358 EVT_CHILD_FOCUS(wxPropertyGrid::OnChildFocusEvent
)
359 EVT_SET_FOCUS(wxPropertyGrid::OnFocusEvent
)
360 EVT_KILL_FOCUS(wxPropertyGrid::OnFocusEvent
)
361 EVT_SYS_COLOUR_CHANGED(wxPropertyGrid::OnSysColourChanged
)
365 // -----------------------------------------------------------------------
367 wxPropertyGrid::wxPropertyGrid()
373 // -----------------------------------------------------------------------
375 wxPropertyGrid::wxPropertyGrid( wxWindow
*parent
,
380 const wxString
& name
)
384 Create(parent
,id
,pos
,size
,style
,name
);
387 // -----------------------------------------------------------------------
389 bool wxPropertyGrid::Create( wxWindow
*parent
,
394 const wxString
& name
)
397 if (!(style
&wxBORDER_MASK
))
399 style
|= wxBORDER_THEME
;
404 // Filter out wxTAB_TRAVERSAL - we will handle TABs manually
405 style
&= ~(wxTAB_TRAVERSAL
);
406 style
|= wxWANTS_CHARS
;
408 wxScrolledWindow::Create(parent
,id
,pos
,size
,style
,name
);
415 // -----------------------------------------------------------------------
418 // Initialize values to defaults
420 void wxPropertyGrid::Init1()
422 // Register editor classes, if necessary.
423 if ( wxPGGlobalVars
->m_mapEditorClasses
.empty() )
424 wxPropertyGrid::RegisterDefaultEditors();
428 m_wndEditor
= m_wndEditor2
= NULL
;
432 m_labelEditor
= NULL
;
433 m_labelEditorProperty
= NULL
;
434 m_eventObject
= this;
436 m_processedEvent
= NULL
;
437 m_sortFunction
= NULL
;
438 m_inDoPropertyChanged
= 0;
439 m_inCommitChangesFromEditor
= 0;
440 m_inDoSelectProperty
= 0;
441 m_permanentValidationFailureBehavior
= wxPG_VFB_DEFAULT
;
447 AddActionTrigger( wxPG_ACTION_NEXT_PROPERTY
, WXK_RIGHT
);
448 AddActionTrigger( wxPG_ACTION_NEXT_PROPERTY
, WXK_DOWN
);
449 AddActionTrigger( wxPG_ACTION_PREV_PROPERTY
, WXK_LEFT
);
450 AddActionTrigger( wxPG_ACTION_PREV_PROPERTY
, WXK_UP
);
451 AddActionTrigger( wxPG_ACTION_EXPAND_PROPERTY
, WXK_RIGHT
);
452 AddActionTrigger( wxPG_ACTION_COLLAPSE_PROPERTY
, WXK_LEFT
);
453 AddActionTrigger( wxPG_ACTION_CANCEL_EDIT
, WXK_ESCAPE
);
454 AddActionTrigger( wxPG_ACTION_PRESS_BUTTON
, WXK_DOWN
, wxMOD_ALT
);
455 AddActionTrigger( wxPG_ACTION_PRESS_BUTTON
, WXK_F4
);
457 m_coloursCustomized
= 0;
462 #if wxPG_DOUBLE_BUFFER
463 m_doubleBuffer
= NULL
;
466 #ifndef wxPG_ICON_WIDTH
472 m_iconWidth
= wxPG_ICON_WIDTH
;
477 m_gutterWidth
= wxPG_GUTTER_MIN
;
478 m_subgroup_extramargin
= 10;
482 m_width
= m_height
= 0;
484 m_commonValues
.push_back(new wxPGCommonValue(_("Unspecified"), wxPGGlobalVars
->m_defaultRenderer
) );
487 m_chgInfo_changedProperty
= NULL
;
490 // -----------------------------------------------------------------------
493 // Initialize after parent etc. set
495 void wxPropertyGrid::Init2()
497 wxASSERT( !(m_iFlags
& wxPG_FL_INITIALIZED
) );
500 // Smaller controls on Mac
501 SetWindowVariant(wxWINDOW_VARIANT_SMALL
);
504 // Now create state, if one didn't exist already
505 // (wxPropertyGridManager might have created it for us).
508 m_pState
= CreateState();
509 m_pState
->m_pPropGrid
= this;
510 m_iFlags
|= wxPG_FL_CREATEDSTATE
;
513 if ( !(m_windowStyle
& wxPG_SPLITTER_AUTO_CENTER
) )
514 m_iFlags
|= wxPG_FL_DONT_CENTER_SPLITTER
;
516 if ( m_windowStyle
& wxPG_HIDE_CATEGORIES
)
518 m_pState
->InitNonCatMode();
520 m_pState
->m_properties
= m_pState
->m_abcArray
;
523 GetClientSize(&m_width
,&m_height
);
525 #ifndef wxPG_ICON_WIDTH
526 // create two bitmap nodes for drawing
527 m_expandbmp
= new wxBitmap(expand_xpm
);
528 m_collbmp
= new wxBitmap(collapse_xpm
);
530 // calculate average font height for bitmap centering
532 m_iconWidth
= m_expandbmp
->GetWidth();
533 m_iconHeight
= m_expandbmp
->GetHeight();
536 m_curcursor
= wxCURSOR_ARROW
;
537 m_cursorSizeWE
= new wxCursor( wxCURSOR_SIZEWE
);
539 // adjust bitmap icon y position so they are centered
540 m_vspacing
= wxPG_DEFAULT_VSPACING
;
542 CalculateFontAndBitmapStuff( wxPG_DEFAULT_VSPACING
);
544 // Allocate cell datas indirectly by calling setter
545 m_propertyDefaultCell
.SetBgCol(*wxBLACK
);
546 m_categoryDefaultCell
.SetBgCol(*wxBLACK
);
550 // This helps with flicker
551 SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
553 // Hook the top-level parent
558 // set virtual size to this window size
559 wxSize wndsize
= GetSize();
560 SetVirtualSize(wndsize
.GetWidth(), wndsize
.GetWidth());
562 m_timeCreated
= ::wxGetLocalTimeMillis();
564 m_canvas
= new wxPGCanvas();
565 m_canvas
->Create(this, wxID_ANY
, wxPoint(0, 0), GetClientSize(),
566 wxWANTS_CHARS
| wxCLIP_CHILDREN
);
567 m_canvas
->SetBackgroundStyle( wxBG_STYLE_CUSTOM
);
569 m_iFlags
|= wxPG_FL_INITIALIZED
;
571 m_ncWidth
= wndsize
.GetWidth();
573 // Need to call OnResize handler or size given in constructor/Create
575 wxSizeEvent
sizeEvent(wndsize
,0);
579 // -----------------------------------------------------------------------
581 wxPropertyGrid::~wxPropertyGrid()
586 wxCriticalSectionLocker(wxPGGlobalVars
->m_critSect
);
590 // Remove grid and property pointers from live wxPropertyGridEvents.
591 for ( i
=0; i
<m_liveEvents
.size(); i
++ )
593 wxPropertyGridEvent
* evt
= m_liveEvents
[i
];
594 evt
->SetPropertyGrid(NULL
);
595 evt
->SetProperty(NULL
);
597 m_liveEvents
.clear();
599 if ( m_processedEvent
)
601 // All right... we are being deleted while wxPropertyGrid event
602 // is being sent. Make sure that event propagates as little
603 // as possible (although usually this is not enough to prevent
605 m_processedEvent
->Skip(false);
606 m_processedEvent
->StopPropagation();
608 // Let's use wxMessageBox to make the message appear more
609 // reliably (and *before* the crash can happen).
610 ::wxMessageBox("wxPropertyGrid was being destroyed in an event "
611 "generated by it. This usually leads to a crash "
612 "so it is recommended to destroy the control "
613 "at idle time instead.");
616 DoSelectProperty(NULL
, wxPG_SEL_NOVALIDATE
|wxPG_SEL_DONT_SEND_EVENT
);
618 // This should do prevent things from going too badly wrong
619 m_iFlags
&= ~(wxPG_FL_INITIALIZED
);
621 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
622 m_canvas
->ReleaseMouse();
624 // Call with NULL to disconnect event handling
625 if ( GetExtraStyle() & wxPG_EX_ENABLE_TLP_TRACKING
)
629 wxASSERT_MSG( !IsEditorsValueModified(),
630 wxS("Most recent change in property editor was ")
631 wxS("lost!!! (if you don't want this to happen, ")
632 wxS("close your frames and dialogs using ")
633 wxS("Close(false).)") );
636 #if wxPG_DOUBLE_BUFFER
637 if ( m_doubleBuffer
)
638 delete m_doubleBuffer
;
641 if ( m_iFlags
& wxPG_FL_CREATEDSTATE
)
644 delete m_cursorSizeWE
;
646 #ifndef wxPG_ICON_WIDTH
651 // Delete common value records
652 for ( i
=0; i
<m_commonValues
.size(); i
++ )
654 // Use temporary variable to work around possible strange VC6 (asserts because m_size is zero)
655 wxPGCommonValue
* value
= m_commonValues
[i
];
660 // -----------------------------------------------------------------------
662 bool wxPropertyGrid::Destroy()
664 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
665 m_canvas
->ReleaseMouse();
667 return wxScrolledWindow::Destroy();
670 // -----------------------------------------------------------------------
672 wxPropertyGridPageState
* wxPropertyGrid::CreateState() const
674 return new wxPropertyGridPageState();
677 // -----------------------------------------------------------------------
678 // wxPropertyGrid overridden wxWindow methods
679 // -----------------------------------------------------------------------
681 void wxPropertyGrid::SetWindowStyleFlag( long style
)
683 long old_style
= m_windowStyle
;
685 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
687 wxASSERT( m_pState
);
689 if ( !(style
& wxPG_HIDE_CATEGORIES
) && (old_style
& wxPG_HIDE_CATEGORIES
) )
692 EnableCategories( true );
694 else if ( (style
& wxPG_HIDE_CATEGORIES
) && !(old_style
& wxPG_HIDE_CATEGORIES
) )
696 // Disable categories
697 EnableCategories( false );
699 if ( !(old_style
& wxPG_AUTO_SORT
) && (style
& wxPG_AUTO_SORT
) )
705 PrepareAfterItemsAdded();
707 m_pState
->m_itemsAdded
= 1;
709 #if wxPG_SUPPORT_TOOLTIPS
710 if ( !(old_style
& wxPG_TOOLTIPS
) && (style
& wxPG_TOOLTIPS
) )
716 wxToolTip* tooltip = new wxToolTip ( wxEmptyString );
717 SetToolTip ( tooltip );
718 tooltip->SetDelay ( wxPG_TOOLTIP_DELAY );
721 else if ( (old_style
& wxPG_TOOLTIPS
) && !(style
& wxPG_TOOLTIPS
) )
726 m_canvas
->SetToolTip( NULL
);
731 wxScrolledWindow::SetWindowStyleFlag ( style
);
733 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
735 if ( (old_style
& wxPG_HIDE_MARGIN
) != (style
& wxPG_HIDE_MARGIN
) )
737 CalculateFontAndBitmapStuff( m_vspacing
);
743 // -----------------------------------------------------------------------
745 void wxPropertyGrid::Freeze()
749 wxScrolledWindow::Freeze();
754 // -----------------------------------------------------------------------
756 void wxPropertyGrid::Thaw()
762 wxScrolledWindow::Thaw();
763 RecalculateVirtualSize();
764 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
768 // Force property re-selection
769 // NB: We must copy the selection.
770 wxArrayPGProperty selection
= m_pState
->m_selection
;
771 DoSetSelection(selection
, wxPG_SEL_FORCE
);
775 // -----------------------------------------------------------------------
777 bool wxPropertyGrid::DoAddToSelection( wxPGProperty
* prop
, int selFlags
)
779 wxCHECK( prop
, false );
781 if ( !(GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION
) )
782 return DoSelectProperty(prop
, selFlags
);
784 wxArrayPGProperty
& selection
= m_pState
->m_selection
;
786 if ( !selection
.size() )
788 return DoSelectProperty(prop
, selFlags
);
792 // For categories, only one can be selected at a time
793 if ( prop
->IsCategory() || selection
[0]->IsCategory() )
796 selection
.push_back(prop
);
798 if ( !(selFlags
& wxPG_SEL_DONT_SEND_EVENT
) )
800 SendEvent( wxEVT_PG_SELECTED
, prop
, NULL
);
809 // -----------------------------------------------------------------------
811 bool wxPropertyGrid::DoRemoveFromSelection( wxPGProperty
* prop
, int selFlags
)
813 wxCHECK( prop
, false );
816 wxArrayPGProperty
& selection
= m_pState
->m_selection
;
817 if ( selection
.size() <= 1 )
819 res
= DoSelectProperty(NULL
, selFlags
);
823 m_pState
->DoRemoveFromSelection(prop
);
831 // -----------------------------------------------------------------------
833 bool wxPropertyGrid::DoSelectAndEdit( wxPGProperty
* prop
,
834 unsigned int colIndex
,
835 unsigned int selFlags
)
838 // NB: Enable following if label editor background colour is
839 // ever changed to any other than m_colSelBack.
841 // We use this workaround to prevent visible flicker when editing
842 // a cell. Atleast on wxMSW, there is a difficult to find
843 // (and perhaps prevent) redraw somewhere between making property
844 // selected and enabling label editing.
846 //wxColour prevColSelBack = m_colSelBack;
847 //m_colSelBack = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
853 res
= DoSelectProperty(prop
, selFlags
);
858 DoClearSelection(false, wxPG_SEL_NO_REFRESH
);
860 if ( m_pState
->m_editableColumns
.Index(colIndex
) == wxNOT_FOUND
)
862 res
= DoAddToSelection(prop
, selFlags
);
866 res
= DoAddToSelection(prop
, selFlags
|wxPG_SEL_NO_REFRESH
);
868 DoBeginLabelEdit(colIndex
, selFlags
);
872 //m_colSelBack = prevColSelBack;
876 // -----------------------------------------------------------------------
878 bool wxPropertyGrid::AddToSelectionFromInputEvent( wxPGProperty
* prop
,
879 unsigned int colIndex
,
880 wxMouseEvent
* mouseEvent
,
883 bool alreadySelected
= m_pState
->DoIsPropertySelected(prop
);
885 bool addToExistingSelection
;
887 if ( GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION
)
891 if ( mouseEvent
->GetEventType() == wxEVT_RIGHT_DOWN
||
892 mouseEvent
->GetEventType() == wxEVT_RIGHT_UP
)
894 // Allow right-click for context menu without
895 // disturbing the selection.
896 if ( GetSelectedProperties().size() <= 1 ||
898 return DoSelectAndEdit(prop
, colIndex
, selFlags
);
903 addToExistingSelection
= mouseEvent
->ShiftDown();
908 addToExistingSelection
= false;
913 addToExistingSelection
= false;
916 if ( addToExistingSelection
)
918 if ( !alreadySelected
)
920 res
= DoAddToSelection(prop
, selFlags
);
922 else if ( GetSelectedProperties().size() > 1 )
924 res
= DoRemoveFromSelection(prop
, selFlags
);
929 res
= DoSelectAndEdit(prop
, colIndex
, selFlags
);
935 // -----------------------------------------------------------------------
937 void wxPropertyGrid::DoSetSelection( const wxArrayPGProperty
& newSelection
,
940 if ( newSelection
.size() > 0 )
942 if ( !DoSelectProperty(newSelection
[0], selFlags
) )
947 DoClearSelection(false, selFlags
);
950 for ( unsigned int i
= 1; i
< newSelection
.size(); i
++ )
952 DoAddToSelection(newSelection
[i
], selFlags
);
958 // -----------------------------------------------------------------------
960 void wxPropertyGrid::MakeColumnEditable( unsigned int column
,
963 wxASSERT( column
!= 1 );
965 wxArrayInt
& cols
= m_pState
->m_editableColumns
;
969 cols
.push_back(column
);
973 for ( int i
= cols
.size() - 1; i
> 0; i
-- )
975 if ( cols
[i
] == (int)column
)
976 cols
.erase( cols
.begin() + i
);
981 // -----------------------------------------------------------------------
983 void wxPropertyGrid::DoBeginLabelEdit( unsigned int colIndex
,
986 wxPGProperty
* selected
= GetSelection();
987 wxCHECK_RET(selected
, wxT("No property selected"));
988 wxCHECK_RET(colIndex
!= 1, wxT("Do not use this for column 1"));
990 if ( !(selFlags
& wxPG_SEL_DONT_SEND_EVENT
) )
992 if ( SendEvent( wxEVT_PG_LABEL_EDIT_BEGIN
,
999 const wxPGCell
* cell
= NULL
;
1000 if ( selected
->HasCell(colIndex
) )
1002 cell
= &selected
->GetCell(colIndex
);
1003 if ( !cell
->HasText() && colIndex
== 0 )
1004 text
= selected
->GetLabel();
1009 if ( colIndex
== 0 )
1010 text
= selected
->GetLabel();
1012 cell
= &selected
->GetOrCreateCell(colIndex
);
1015 if ( cell
&& cell
->HasText() )
1016 text
= cell
->GetText();
1018 DoEndLabelEdit(true, wxPG_SEL_NOVALIDATE
); // send event
1020 m_selColumn
= colIndex
;
1022 wxRect r
= GetEditorWidgetRect(selected
, m_selColumn
);
1024 wxWindow
* tc
= GenerateEditorTextCtrl(r
.GetPosition(),
1032 wxWindowID id
= tc
->GetId();
1033 tc
->Connect(id
, wxEVT_COMMAND_TEXT_ENTER
,
1034 wxCommandEventHandler(wxPropertyGrid::OnLabelEditorEnterPress
),
1036 tc
->Connect(id
, wxEVT_KEY_DOWN
,
1037 wxKeyEventHandler(wxPropertyGrid::OnLabelEditorKeyPress
),
1042 m_labelEditor
= wxStaticCast(tc
, wxTextCtrl
);
1043 m_labelEditorProperty
= selected
;
1046 // -----------------------------------------------------------------------
1049 wxPropertyGrid::OnLabelEditorEnterPress( wxCommandEvent
& WXUNUSED(event
) )
1051 DoEndLabelEdit(true);
1054 // -----------------------------------------------------------------------
1056 void wxPropertyGrid::OnLabelEditorKeyPress( wxKeyEvent
& event
)
1058 int keycode
= event
.GetKeyCode();
1060 if ( keycode
== WXK_ESCAPE
)
1062 DoEndLabelEdit(false);
1070 // -----------------------------------------------------------------------
1072 void wxPropertyGrid::DoEndLabelEdit( bool commit
, int selFlags
)
1074 if ( !m_labelEditor
)
1077 wxPGProperty
* prop
= m_labelEditorProperty
;
1082 if ( !(selFlags
& wxPG_SEL_DONT_SEND_EVENT
) )
1084 // wxPG_SEL_NOVALIDATE is passed correctly in selFlags
1085 if ( SendEvent( wxEVT_PG_LABEL_EDIT_ENDING
,
1086 prop
, NULL
, selFlags
,
1091 wxString text
= m_labelEditor
->GetValue();
1092 wxPGCell
* cell
= NULL
;
1093 if ( prop
->HasCell(m_selColumn
) )
1095 cell
= &prop
->GetCell(m_selColumn
);
1099 if ( m_selColumn
== 0 )
1100 prop
->SetLabel(text
);
1102 cell
= &prop
->GetOrCreateCell(m_selColumn
);
1106 cell
->SetText(text
);
1111 DestroyEditorWnd(m_labelEditor
);
1112 m_labelEditor
= NULL
;
1113 m_labelEditorProperty
= NULL
;
1118 // -----------------------------------------------------------------------
1120 void wxPropertyGrid::SetExtraStyle( long exStyle
)
1122 if ( exStyle
& wxPG_EX_ENABLE_TLP_TRACKING
)
1123 OnTLPChanging(::wxGetTopLevelParent(this));
1125 OnTLPChanging(NULL
);
1127 if ( exStyle
& wxPG_EX_NATIVE_DOUBLE_BUFFERING
)
1129 #if defined(__WXMSW__)
1132 // Don't use WS_EX_COMPOSITED just now.
1135 if ( m_iFlags & wxPG_FL_IN_MANAGER )
1136 hWnd = (HWND)GetParent()->GetHWND();
1138 hWnd = (HWND)GetHWND();
1140 ::SetWindowLong( hWnd, GWL_EXSTYLE,
1141 ::GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_COMPOSITED );
1144 //#elif defined(__WXGTK20__)
1146 // Only apply wxPG_EX_NATIVE_DOUBLE_BUFFERING if the window
1147 // truly was double-buffered.
1148 if ( !this->IsDoubleBuffered() )
1150 exStyle
&= ~(wxPG_EX_NATIVE_DOUBLE_BUFFERING
);
1154 #if wxPG_DOUBLE_BUFFER
1155 delete m_doubleBuffer
;
1156 m_doubleBuffer
= NULL
;
1161 wxScrolledWindow::SetExtraStyle( exStyle
);
1163 if ( exStyle
& wxPG_EX_INIT_NOCAT
)
1164 m_pState
->InitNonCatMode();
1166 if ( exStyle
& wxPG_EX_HELP_AS_TOOLTIPS
)
1167 m_windowStyle
|= wxPG_TOOLTIPS
;
1170 wxPGGlobalVars
->m_extraStyle
= exStyle
;
1173 // -----------------------------------------------------------------------
1175 // returns the best acceptable minimal size
1176 wxSize
wxPropertyGrid::DoGetBestSize() const
1178 int lineHeight
= wxMax(15, m_lineHeight
);
1180 // don't make the grid too tall (limit height to 10 items) but don't
1181 // make it too small neither
1182 int numLines
= wxMin
1184 wxMax(m_pState
->m_properties
->GetChildCount(), 3),
1188 wxClientDC
dc(const_cast<wxPropertyGrid
*>(this));
1189 int width
= m_marginWidth
;
1190 for ( unsigned int i
= 0; i
< m_pState
->m_colWidths
.size(); i
++ )
1192 width
+= m_pState
->GetColumnFitWidth(dc
, m_pState
->DoGetRoot(), i
, true);
1195 const wxSize sz
= wxSize(width
, lineHeight
*numLines
+ 40);
1201 // -----------------------------------------------------------------------
1203 void wxPropertyGrid::OnTLPChanging( wxWindow
* newTLP
)
1205 if ( newTLP
== m_tlp
)
1208 wxLongLong currentTime
= ::wxGetLocalTimeMillis();
1211 // Parent changed so let's redetermine and re-hook the
1212 // correct top-level window.
1215 m_tlp
->Disconnect( wxEVT_CLOSE_WINDOW
,
1216 wxCloseEventHandler(wxPropertyGrid::OnTLPClose
),
1218 m_tlpClosed
= m_tlp
;
1219 m_tlpClosedTime
= currentTime
;
1224 // Only accept new tlp if same one was not just dismissed.
1225 if ( newTLP
!= m_tlpClosed
||
1226 m_tlpClosedTime
+250 < currentTime
)
1228 newTLP
->Connect( wxEVT_CLOSE_WINDOW
,
1229 wxCloseEventHandler(wxPropertyGrid::OnTLPClose
),
1242 // -----------------------------------------------------------------------
1244 void wxPropertyGrid::OnTLPClose( wxCloseEvent
& event
)
1246 // ClearSelection forces value validation/commit.
1247 if ( event
.CanVeto() && !DoClearSelection() )
1253 // Ok, it can close, set tlp pointer to NULL. Some other event
1254 // handler can of course veto the close, but our OnIdle() should
1255 // then be able to regain the tlp pointer.
1256 OnTLPChanging(NULL
);
1261 // -----------------------------------------------------------------------
1263 bool wxPropertyGrid::Reparent( wxWindowBase
*newParent
)
1265 OnTLPChanging((wxWindow
*)newParent
);
1267 bool res
= wxScrolledWindow::Reparent(newParent
);
1272 // -----------------------------------------------------------------------
1273 // wxPropertyGrid Font and Colour Methods
1274 // -----------------------------------------------------------------------
1276 void wxPropertyGrid::CalculateFontAndBitmapStuff( int vspacing
)
1280 m_captionFont
= wxScrolledWindow::GetFont();
1282 GetTextExtent(wxS("jG"), &x
, &y
, 0, 0, &m_captionFont
);
1283 m_subgroup_extramargin
= x
+ (x
/2);
1286 #if wxPG_USE_RENDERER_NATIVE
1287 m_iconWidth
= wxPG_ICON_WIDTH
;
1288 #elif wxPG_ICON_WIDTH
1290 m_iconWidth
= (m_fontHeight
* wxPG_ICON_WIDTH
) / 13;
1291 if ( m_iconWidth
< 5 ) m_iconWidth
= 5;
1292 else if ( !(m_iconWidth
& 0x01) ) m_iconWidth
++; // must be odd
1296 m_gutterWidth
= m_iconWidth
/ wxPG_GUTTER_DIV
;
1297 if ( m_gutterWidth
< wxPG_GUTTER_MIN
)
1298 m_gutterWidth
= wxPG_GUTTER_MIN
;
1301 if ( vspacing
<= 1 ) vdiv
= 12;
1302 else if ( vspacing
>= 3 ) vdiv
= 3;
1304 m_spacingy
= m_fontHeight
/ vdiv
;
1305 if ( m_spacingy
< wxPG_YSPACING_MIN
)
1306 m_spacingy
= wxPG_YSPACING_MIN
;
1309 if ( !(m_windowStyle
& wxPG_HIDE_MARGIN
) )
1310 m_marginWidth
= m_gutterWidth
*2 + m_iconWidth
;
1312 m_captionFont
.SetWeight(wxBOLD
);
1313 GetTextExtent(wxS("jG"), &x
, &y
, 0, 0, &m_captionFont
);
1315 m_lineHeight
= m_fontHeight
+(2*m_spacingy
)+1;
1318 m_buttonSpacingY
= (m_lineHeight
- m_iconHeight
) / 2;
1319 if ( m_buttonSpacingY
< 0 ) m_buttonSpacingY
= 0;
1322 m_pState
->CalculateFontAndBitmapStuff(vspacing
);
1324 if ( m_iFlags
& wxPG_FL_INITIALIZED
)
1325 RecalculateVirtualSize();
1327 InvalidateBestSize();
1330 // -----------------------------------------------------------------------
1332 void wxPropertyGrid::OnSysColourChanged( wxSysColourChangedEvent
&WXUNUSED(event
) )
1338 // -----------------------------------------------------------------------
1340 static wxColour
wxPGAdjustColour(const wxColour
& src
, int ra
,
1341 int ga
= 1000, int ba
= 1000,
1342 bool forceDifferent
= false)
1349 // Recursion guard (allow 2 max)
1350 static int isinside
= 0;
1352 wxCHECK_MSG( isinside
< 3,
1354 wxT("wxPGAdjustColour should not be recursively called more than once") );
1359 int g
= src
.Green();
1362 if ( r2
>255 ) r2
= 255;
1363 else if ( r2
<0) r2
= 0;
1365 if ( g2
>255 ) g2
= 255;
1366 else if ( g2
<0) g2
= 0;
1368 if ( b2
>255 ) b2
= 255;
1369 else if ( b2
<0) b2
= 0;
1371 // Make sure they are somewhat different
1372 if ( forceDifferent
&& (abs((r
+g
+b
)-(r2
+g2
+b2
)) < abs(ra
/2)) )
1373 dst
= wxPGAdjustColour(src
,-(ra
*2));
1375 dst
= wxColour(r2
,g2
,b2
);
1377 // Recursion guard (allow 2 max)
1384 static int wxPGGetColAvg( const wxColour
& col
)
1386 return (col
.Red() + col
.Green() + col
.Blue()) / 3;
1390 void wxPropertyGrid::RegainColours()
1392 if ( !(m_coloursCustomized
& 0x0002) )
1394 wxColour col
= wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE
);
1396 // Make sure colour is dark enough
1398 int colDec
= wxPGGetColAvg(col
) - 230;
1400 int colDec
= wxPGGetColAvg(col
) - 200;
1403 m_colCapBack
= wxPGAdjustColour(col
,-colDec
);
1406 m_categoryDefaultCell
.GetData()->SetBgCol(m_colCapBack
);
1409 if ( !(m_coloursCustomized
& 0x0001) )
1410 m_colMargin
= m_colCapBack
;
1412 if ( !(m_coloursCustomized
& 0x0004) )
1419 wxColour capForeCol
= wxPGAdjustColour(m_colCapBack
,colDec
,5000,5000,true);
1420 m_colCapFore
= capForeCol
;
1421 m_categoryDefaultCell
.GetData()->SetFgCol(capForeCol
);
1424 if ( !(m_coloursCustomized
& 0x0008) )
1426 wxColour bgCol
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW
);
1427 m_colPropBack
= bgCol
;
1428 m_propertyDefaultCell
.GetData()->SetBgCol(bgCol
);
1431 if ( !(m_coloursCustomized
& 0x0010) )
1433 wxColour fgCol
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT
);
1434 m_colPropFore
= fgCol
;
1435 m_propertyDefaultCell
.GetData()->SetFgCol(fgCol
);
1438 if ( !(m_coloursCustomized
& 0x0020) )
1439 m_colSelBack
= wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHT
);
1441 if ( !(m_coloursCustomized
& 0x0040) )
1442 m_colSelFore
= wxSystemSettings::GetColour( wxSYS_COLOUR_HIGHLIGHTTEXT
);
1444 if ( !(m_coloursCustomized
& 0x0080) )
1445 m_colLine
= m_colCapBack
;
1447 if ( !(m_coloursCustomized
& 0x0100) )
1448 m_colDisPropFore
= m_colCapFore
;
1450 m_colEmptySpace
= wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW
);
1453 // -----------------------------------------------------------------------
1455 void wxPropertyGrid::ResetColours()
1457 m_coloursCustomized
= 0;
1464 // -----------------------------------------------------------------------
1466 bool wxPropertyGrid::SetFont( const wxFont
& font
)
1468 // Must disable active editor.
1471 bool res
= wxScrolledWindow::SetFont( font
);
1472 if ( res
&& GetParent()) // may not have been Create()ed yet if SetFont called from SetWindowVariant
1474 CalculateFontAndBitmapStuff( m_vspacing
);
1481 // -----------------------------------------------------------------------
1483 void wxPropertyGrid::SetLineColour( const wxColour
& col
)
1486 m_coloursCustomized
|= 0x80;
1490 // -----------------------------------------------------------------------
1492 void wxPropertyGrid::SetMarginColour( const wxColour
& col
)
1495 m_coloursCustomized
|= 0x01;
1499 // -----------------------------------------------------------------------
1501 void wxPropertyGrid::SetCellBackgroundColour( const wxColour
& col
)
1503 m_colPropBack
= col
;
1504 m_coloursCustomized
|= 0x08;
1506 m_propertyDefaultCell
.GetData()->SetBgCol(col
);
1511 // -----------------------------------------------------------------------
1513 void wxPropertyGrid::SetCellTextColour( const wxColour
& col
)
1515 m_colPropFore
= col
;
1516 m_coloursCustomized
|= 0x10;
1518 m_propertyDefaultCell
.GetData()->SetFgCol(col
);
1523 // -----------------------------------------------------------------------
1525 void wxPropertyGrid::SetEmptySpaceColour( const wxColour
& col
)
1527 m_colEmptySpace
= col
;
1532 // -----------------------------------------------------------------------
1534 void wxPropertyGrid::SetCellDisabledTextColour( const wxColour
& col
)
1536 m_colDisPropFore
= col
;
1537 m_coloursCustomized
|= 0x100;
1541 // -----------------------------------------------------------------------
1543 void wxPropertyGrid::SetSelectionBackgroundColour( const wxColour
& col
)
1546 m_coloursCustomized
|= 0x20;
1550 // -----------------------------------------------------------------------
1552 void wxPropertyGrid::SetSelectionTextColour( const wxColour
& col
)
1555 m_coloursCustomized
|= 0x40;
1559 // -----------------------------------------------------------------------
1561 void wxPropertyGrid::SetCaptionBackgroundColour( const wxColour
& col
)
1564 m_coloursCustomized
|= 0x02;
1566 m_categoryDefaultCell
.GetData()->SetBgCol(col
);
1571 // -----------------------------------------------------------------------
1573 void wxPropertyGrid::SetCaptionTextColour( const wxColour
& col
)
1576 m_coloursCustomized
|= 0x04;
1578 m_categoryDefaultCell
.GetData()->SetFgCol(col
);
1583 // -----------------------------------------------------------------------
1584 // wxPropertyGrid property adding and removal
1585 // -----------------------------------------------------------------------
1587 void wxPropertyGrid::PrepareAfterItemsAdded()
1589 if ( !m_pState
|| !m_pState
->m_itemsAdded
) return;
1591 m_pState
->m_itemsAdded
= 0;
1593 if ( m_windowStyle
& wxPG_AUTO_SORT
)
1594 Sort(wxPG_SORT_TOP_LEVEL_ONLY
);
1596 RecalculateVirtualSize();
1599 // -----------------------------------------------------------------------
1600 // wxPropertyGrid property operations
1601 // -----------------------------------------------------------------------
1603 bool wxPropertyGrid::EnsureVisible( wxPGPropArg id
)
1605 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
1609 bool changed
= false;
1611 // Is it inside collapsed section?
1612 if ( !p
->IsVisible() )
1615 wxPGProperty
* parent
= p
->GetParent();
1616 wxPGProperty
* grandparent
= parent
->GetParent();
1618 if ( grandparent
&& grandparent
!= m_pState
->m_properties
)
1619 Expand( grandparent
);
1627 GetViewStart(&vx
,&vy
);
1628 vy
*=wxPG_PIXELS_PER_UNIT
;
1634 Scroll(vx
, y
/wxPG_PIXELS_PER_UNIT
);
1635 m_iFlags
|= wxPG_FL_SCROLLED
;
1638 else if ( (y
+m_lineHeight
) > (vy
+m_height
) )
1640 Scroll(vx
, (y
-m_height
+(m_lineHeight
*2))/wxPG_PIXELS_PER_UNIT
);
1641 m_iFlags
|= wxPG_FL_SCROLLED
;
1651 // -----------------------------------------------------------------------
1652 // wxPropertyGrid helper methods called by properties
1653 // -----------------------------------------------------------------------
1655 // Control font changer helper.
1656 void wxPropertyGrid::SetCurControlBoldFont()
1658 wxASSERT( m_wndEditor
);
1659 m_wndEditor
->SetFont( m_captionFont
);
1662 // -----------------------------------------------------------------------
1664 wxPoint
wxPropertyGrid::GetGoodEditorDialogPosition( wxPGProperty
* p
,
1667 #if wxPG_SMALL_SCREEN
1668 // On small-screen devices, always show dialogs with default position and size.
1669 return wxDefaultPosition
;
1671 int splitterX
= GetSplitterPosition();
1675 wxCHECK_MSG( y
>= 0, wxPoint(-1,-1), wxT("invalid y?") );
1677 ImprovedClientToScreen( &x
, &y
);
1679 int sw
= wxSystemSettings::GetMetric( ::wxSYS_SCREEN_X
);
1680 int sh
= wxSystemSettings::GetMetric( ::wxSYS_SCREEN_Y
);
1687 new_x
= x
+ (m_width
-splitterX
) - sz
.x
;
1697 new_y
= y
+ m_lineHeight
;
1699 return wxPoint(new_x
,new_y
);
1703 // -----------------------------------------------------------------------
1705 wxString
& wxPropertyGrid::ExpandEscapeSequences( wxString
& dst_str
, wxString
& src_str
)
1707 if ( src_str
.length() == 0 )
1713 bool prev_is_slash
= false;
1715 wxString::const_iterator i
= src_str
.begin();
1719 for ( ; i
!= src_str
.end(); ++i
)
1723 if ( a
!= wxS('\\') )
1725 if ( !prev_is_slash
)
1731 if ( a
== wxS('n') )
1734 dst_str
<< wxS('\n');
1736 dst_str
<< wxS('\n');
1739 else if ( a
== wxS('t') )
1740 dst_str
<< wxS('\t');
1744 prev_is_slash
= false;
1748 if ( prev_is_slash
)
1750 dst_str
<< wxS('\\');
1751 prev_is_slash
= false;
1755 prev_is_slash
= true;
1762 // -----------------------------------------------------------------------
1764 wxString
& wxPropertyGrid::CreateEscapeSequences( wxString
& dst_str
, wxString
& src_str
)
1766 if ( src_str
.length() == 0 )
1772 wxString::const_iterator i
= src_str
.begin();
1773 wxUniChar prev_a
= wxS('\0');
1777 for ( ; i
!= src_str
.end(); ++i
)
1781 if ( a
>= wxS(' ') )
1783 // This surely is not something that requires an escape sequence.
1788 // This might need...
1789 if ( a
== wxS('\r') )
1791 // DOS style line end.
1792 // Already taken care below
1794 else if ( a
== wxS('\n') )
1795 // UNIX style line end.
1796 dst_str
<< wxS("\\n");
1797 else if ( a
== wxS('\t') )
1799 dst_str
<< wxS('\t');
1802 //wxLogDebug(wxT("WARNING: Could not create escape sequence for character #%i"),(int)a);
1812 // -----------------------------------------------------------------------
1814 wxPGProperty
* wxPropertyGrid::DoGetItemAtY( int y
) const
1821 return m_pState
->m_properties
->GetItemAtY(y
, m_lineHeight
, &a
);
1824 // -----------------------------------------------------------------------
1825 // wxPropertyGrid graphics related methods
1826 // -----------------------------------------------------------------------
1828 void wxPropertyGrid::OnPaint( wxPaintEvent
& WXUNUSED(event
) )
1832 // Update everything inside the box
1833 wxRect r
= GetUpdateRegion().GetBox();
1835 dc
.SetPen(m_colEmptySpace
);
1836 dc
.SetBrush(m_colEmptySpace
);
1837 dc
.DrawRectangle(r
);
1840 // -----------------------------------------------------------------------
1842 void wxPropertyGrid::DrawExpanderButton( wxDC
& dc
, const wxRect
& rect
,
1843 wxPGProperty
* property
) const
1845 // Prepare rectangle to be used
1847 r
.x
+= m_gutterWidth
; r
.y
+= m_buttonSpacingY
;
1848 r
.width
= m_iconWidth
; r
.height
= m_iconHeight
;
1850 #if (wxPG_USE_RENDERER_NATIVE)
1852 #elif wxPG_ICON_WIDTH
1853 // Drawing expand/collapse button manually
1854 dc
.SetPen(m_colPropFore
);
1855 if ( property
->IsCategory() )
1856 dc
.SetBrush(*wxTRANSPARENT_BRUSH
);
1858 dc
.SetBrush(m_colPropBack
);
1860 dc
.DrawRectangle( r
);
1861 int _y
= r
.y
+(m_iconWidth
/2);
1862 dc
.DrawLine(r
.x
+2,_y
,r
.x
+m_iconWidth
-2,_y
);
1867 if ( property
->IsExpanded() )
1869 // wxRenderer functions are non-mutating in nature, so it
1870 // should be safe to cast "const wxPropertyGrid*" to "wxWindow*".
1871 // Hopefully this does not cause problems.
1872 #if (wxPG_USE_RENDERER_NATIVE)
1873 wxRendererNative::Get().DrawTreeItemButton(
1879 #elif wxPG_ICON_WIDTH
1888 #if (wxPG_USE_RENDERER_NATIVE)
1889 wxRendererNative::Get().DrawTreeItemButton(
1895 #elif wxPG_ICON_WIDTH
1896 int _x
= r
.x
+(m_iconWidth
/2);
1897 dc
.DrawLine(_x
,r
.y
+2,_x
,r
.y
+m_iconWidth
-2);
1903 #if (wxPG_USE_RENDERER_NATIVE)
1905 #elif wxPG_ICON_WIDTH
1908 dc
.DrawBitmap( *bmp
, r
.x
, r
.y
, true );
1912 // -----------------------------------------------------------------------
1915 // This is the one called by OnPaint event handler and others.
1916 // topy and bottomy are already unscrolled (ie. physical)
1918 void wxPropertyGrid::DrawItems( wxDC
& dc
,
1920 unsigned int bottomy
,
1921 const wxRect
* clipRect
)
1923 if ( m_frozen
|| m_height
< 1 || bottomy
< topy
|| !m_pState
) return;
1925 m_pState
->EnsureVirtualHeight();
1927 wxRect tempClipRect
;
1930 tempClipRect
= wxRect(0,topy
,m_pState
->m_width
,bottomy
);
1931 clipRect
= &tempClipRect
;
1934 // items added check
1935 if ( m_pState
->m_itemsAdded
) PrepareAfterItemsAdded();
1937 int paintFinishY
= 0;
1939 if ( m_pState
->m_properties
->GetChildCount() > 0 )
1942 bool isBuffered
= false;
1944 #if wxPG_DOUBLE_BUFFER
1945 wxMemoryDC
* bufferDC
= NULL
;
1947 if ( !(GetExtraStyle() & wxPG_EX_NATIVE_DOUBLE_BUFFERING
) )
1949 if ( !m_doubleBuffer
)
1951 paintFinishY
= clipRect
->y
;
1956 bufferDC
= new wxMemoryDC();
1958 // If nothing was changed, then just copy from double-buffer
1959 bufferDC
->SelectObject( *m_doubleBuffer
);
1969 dc
.SetClippingRegion( *clipRect
);
1970 paintFinishY
= DoDrawItems( *dcPtr
, clipRect
, isBuffered
);
1973 #if wxPG_DOUBLE_BUFFER
1976 dc
.Blit( clipRect
->x
, clipRect
->y
, clipRect
->width
, clipRect
->height
,
1977 bufferDC
, 0, 0, wxCOPY
);
1978 dc
.DestroyClippingRegion(); // Is this really necessary?
1984 // Clear area beyond bottomY?
1985 if ( paintFinishY
< (clipRect
->y
+clipRect
->height
) )
1987 dc
.SetPen(m_colEmptySpace
);
1988 dc
.SetBrush(m_colEmptySpace
);
1989 dc
.DrawRectangle( 0, paintFinishY
, m_width
, (clipRect
->y
+clipRect
->height
) );
1993 // -----------------------------------------------------------------------
1995 int wxPropertyGrid::DoDrawItems( wxDC
& dc
,
1996 const wxRect
* clipRect
,
1997 bool isBuffered
) const
1999 const wxPGProperty
* firstItem
;
2000 const wxPGProperty
* lastItem
;
2002 firstItem
= DoGetItemAtY(clipRect
->y
);
2003 lastItem
= DoGetItemAtY(clipRect
->y
+clipRect
->height
-1);
2006 lastItem
= GetLastItem( wxPG_ITERATE_VISIBLE
);
2008 if ( m_frozen
|| m_height
< 1 || firstItem
== NULL
)
2011 wxCHECK_MSG( !m_pState
->m_itemsAdded
, clipRect
->y
, wxT("no items added") );
2012 wxASSERT( m_pState
->m_properties
->GetChildCount() );
2014 int lh
= m_lineHeight
;
2017 int lastItemBottomY
;
2019 firstItemTopY
= clipRect
->y
;
2020 lastItemBottomY
= clipRect
->y
+ clipRect
->height
;
2022 // Align y coordinates to item boundaries
2023 firstItemTopY
-= firstItemTopY
% lh
;
2024 lastItemBottomY
+= lh
- (lastItemBottomY
% lh
);
2025 lastItemBottomY
-= 1;
2027 // Entire range outside scrolled, visible area?
2028 if ( firstItemTopY
>= (int)m_pState
->GetVirtualHeight() || lastItemBottomY
<= 0 )
2031 wxCHECK_MSG( firstItemTopY
< lastItemBottomY
, clipRect
->y
, wxT("invalid y values") );
2035 wxLogDebug(wxT(" -> DoDrawItems ( \"%s\" -> \"%s\", height=%i (ch=%i), clipRect = 0x%lX )"),
2036 firstItem->GetLabel().c_str(),
2037 lastItem->GetLabel().c_str(),
2038 (int)(lastItemBottomY - firstItemTopY),
2040 (unsigned long)clipRect );
2045 long windowStyle
= m_windowStyle
;
2051 // With wxPG_DOUBLE_BUFFER, do double buffering
2052 // - buffer's y = 0, so align cliprect and coordinates to that
2054 #if wxPG_DOUBLE_BUFFER
2060 xRelMod
= clipRect
->x
;
2061 yRelMod
= clipRect
->y
;
2064 // clipRect 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 if ( p
->m_flags
& wxPG_PROP_MODIFIED
&& (windowStyle
& wxPG_BOLD_MODIFIED
) )
2340 dc
.SetFont(m_captionFont
);
2346 int nextCellWidth
= state
->m_colWidths
[0] -
2347 (greyDepthX
- m_marginWidth
);
2348 wxRect
cellRect(greyDepthX
+1, y
, 0, rowHeight
-1);
2349 int textXAdd
= textMarginHere
- greyDepthX
;
2351 for ( ci
=0; ci
<state
->m_colWidths
.size(); ci
++ )
2353 cellRect
.width
= nextCellWidth
- 1;
2355 wxWindow
* cellEditor
= NULL
;
2356 int cellRenderFlags
= renderFlags
;
2358 // Tree Item Button (must be drawn before clipping is set up)
2359 if ( ci
== 0 && !HasFlag(wxPG_HIDE_MARGIN
) && p
->HasVisibleChildren() )
2360 DrawExpanderButton( dc
, butRect
, p
);
2363 if ( isSelected
&& (ci
== 1 || ci
== m_selColumn
) )
2365 if ( p
== firstSelected
)
2367 if ( ci
== 1 && m_wndEditor
)
2368 cellEditor
= m_wndEditor
;
2369 else if ( ci
== m_selColumn
&& m_labelEditor
)
2370 cellEditor
= m_labelEditor
;
2375 wxColour editorBgCol
=
2376 cellEditor
->GetBackgroundColour();
2377 dc
.SetBrush(editorBgCol
);
2378 dc
.SetPen(editorBgCol
);
2379 dc
.SetTextForeground(m_colPropFore
);
2380 dc
.DrawRectangle(cellRect
);
2382 if ( m_dragStatus
!= 0 ||
2383 (m_iFlags
& wxPG_FL_CUR_USES_CUSTOM_IMAGE
) )
2388 dc
.SetBrush(m_colPropBack
);
2389 dc
.SetPen(m_colPropBack
);
2390 dc
.SetTextForeground(m_colDisPropFore
);
2391 if ( p
->IsEnabled() )
2392 dc
.SetTextForeground(rowFgCol
);
2394 dc
.SetTextForeground(m_colDisPropFore
);
2399 if ( renderFlags
& wxPGCellRenderer::DontUseCellBgCol
)
2401 dc
.SetBrush(rowBgBrush
);
2402 dc
.SetPen(rowBgCol
);
2405 if ( renderFlags
& wxPGCellRenderer::DontUseCellFgCol
)
2407 dc
.SetTextForeground(rowFgCol
);
2411 dc
.SetClippingRegion(cellRect
);
2413 cellRect
.x
+= textXAdd
;
2414 cellRect
.width
-= textXAdd
;
2419 wxPGCellRenderer
* renderer
;
2420 int cmnVal
= p
->GetCommonValue();
2421 if ( cmnVal
== -1 || ci
!= 1 )
2423 renderer
= p
->GetCellRenderer(ci
);
2424 renderer
->Render( dc
, cellRect
, this, p
, ci
, -1,
2429 renderer
= GetCommonValue(cmnVal
)->GetRenderer();
2430 renderer
->Render( dc
, cellRect
, this, p
, ci
, -1,
2435 cellX
+= state
->m_colWidths
[ci
];
2436 if ( ci
< (state
->m_colWidths
.size()-1) )
2437 nextCellWidth
= state
->m_colWidths
[ci
+1];
2439 dc
.DestroyClippingRegion(); // Is this really necessary?
2445 dc
.SetFont(normalFont
);
2450 // Refresh editor controls (seems not needed on msw)
2451 // NOTE: This code is mandatory for GTK!
2452 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
2453 if ( wasSelectedPainted
)
2456 m_wndEditor
->Refresh();
2458 m_wndEditor2
->Refresh();
2465 // -----------------------------------------------------------------------
2467 wxRect
wxPropertyGrid::GetPropertyRect( const wxPGProperty
* p1
, const wxPGProperty
* p2
) const
2471 if ( m_width
< 10 || m_height
< 10 ||
2472 !m_pState
->m_properties
->GetChildCount() ||
2474 return wxRect(0,0,0,0);
2479 // Return rect which encloses the given property range
2481 int visTop
= p1
->GetY();
2484 visBottom
= p2
->GetY() + m_lineHeight
;
2486 visBottom
= m_height
+ visTop
;
2488 // If seleced property is inside the range, we'll extend the range to include
2490 wxPGProperty
* selected
= GetSelection();
2493 int selectedY
= selected
->GetY();
2494 if ( selectedY
>= visTop
&& selectedY
< visBottom
)
2496 wxWindow
* editor
= GetEditorControl();
2499 int visBottom2
= selectedY
+ editor
->GetSize().y
;
2500 if ( visBottom2
> visBottom
)
2501 visBottom
= visBottom2
;
2506 return wxRect(0,visTop
-vy
,m_pState
->m_width
,visBottom
-visTop
);
2509 // -----------------------------------------------------------------------
2511 void wxPropertyGrid::DrawItems( const wxPGProperty
* p1
, const wxPGProperty
* p2
)
2516 if ( m_pState
->m_itemsAdded
)
2517 PrepareAfterItemsAdded();
2519 wxRect r
= GetPropertyRect(p1
, p2
);
2522 m_canvas
->RefreshRect(r
);
2526 // -----------------------------------------------------------------------
2528 void wxPropertyGrid::RefreshProperty( wxPGProperty
* p
)
2530 if ( m_pState
->DoIsPropertySelected(p
) )
2532 // NB: We must copy the selection.
2533 wxArrayPGProperty selection
= m_pState
->m_selection
;
2534 DoSetSelection(selection
, wxPG_SEL_FORCE
);
2537 DrawItemAndChildren(p
);
2540 // -----------------------------------------------------------------------
2542 void wxPropertyGrid::DrawItemAndValueRelated( wxPGProperty
* p
)
2547 // Draw item, children, and parent too, if it is not category
2548 wxPGProperty
* parent
= p
->GetParent();
2551 !parent
->IsCategory() &&
2552 parent
->GetParent() )
2555 parent
= parent
->GetParent();
2558 DrawItemAndChildren(p
);
2561 void wxPropertyGrid::DrawItemAndChildren( wxPGProperty
* p
)
2563 wxCHECK_RET( p
, wxT("invalid property id") );
2565 // Do not draw if in non-visible page
2566 if ( p
->GetParentState() != m_pState
)
2569 // do not draw a single item if multiple pending
2570 if ( m_pState
->m_itemsAdded
|| m_frozen
)
2573 // Update child control.
2574 wxPGProperty
* selected
= GetSelection();
2575 if ( selected
&& selected
->GetParent() == p
)
2578 const wxPGProperty
* lastDrawn
= p
->GetLastVisibleSubItem();
2580 DrawItems(p
, lastDrawn
);
2583 // -----------------------------------------------------------------------
2585 void wxPropertyGrid::Refresh( bool WXUNUSED(eraseBackground
),
2586 const wxRect
*rect
)
2588 PrepareAfterItemsAdded();
2590 wxWindow::Refresh(false);
2592 // TODO: Coordinate translation
2593 m_canvas
->Refresh(false, rect
);
2595 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
2596 // I think this really helps only GTK+1.2
2597 if ( m_wndEditor
) m_wndEditor
->Refresh();
2598 if ( m_wndEditor2
) m_wndEditor2
->Refresh();
2602 // -----------------------------------------------------------------------
2603 // wxPropertyGrid global operations
2604 // -----------------------------------------------------------------------
2606 void wxPropertyGrid::Clear()
2608 m_pState
->DoClear();
2614 RecalculateVirtualSize();
2616 // Need to clear some area at the end
2618 RefreshRect(wxRect(0, 0, m_width
, m_height
));
2621 // -----------------------------------------------------------------------
2623 bool wxPropertyGrid::EnableCategories( bool enable
)
2630 // Enable categories
2633 m_windowStyle
&= ~(wxPG_HIDE_CATEGORIES
);
2638 // Disable categories
2640 m_windowStyle
|= wxPG_HIDE_CATEGORIES
;
2643 if ( !m_pState
->EnableCategories(enable
) )
2648 if ( m_windowStyle
& wxPG_AUTO_SORT
)
2650 m_pState
->m_itemsAdded
= 1; // force
2651 PrepareAfterItemsAdded();
2655 m_pState
->m_itemsAdded
= 1;
2657 // No need for RecalculateVirtualSize() here - it is already called in
2658 // wxPropertyGridPageState method above.
2665 // -----------------------------------------------------------------------
2667 void wxPropertyGrid::SwitchState( wxPropertyGridPageState
* pNewState
)
2669 wxASSERT( pNewState
);
2670 wxASSERT( pNewState
->GetGrid() );
2672 if ( pNewState
== m_pState
)
2675 wxArrayPGProperty oldSelection
= m_pState
->m_selection
;
2677 // Call ClearSelection() instead of DoClearSelection()
2678 // so that selection clear events are not sent.
2681 m_pState
->m_selection
= oldSelection
;
2683 bool orig_mode
= m_pState
->IsInNonCatMode();
2684 bool new_state_mode
= pNewState
->IsInNonCatMode();
2686 m_pState
= pNewState
;
2689 int pgWidth
= GetClientSize().x
;
2690 if ( HasVirtualWidth() )
2692 int minWidth
= pgWidth
;
2693 if ( pNewState
->m_width
< minWidth
)
2695 pNewState
->m_width
= minWidth
;
2696 pNewState
->CheckColumnWidths();
2702 // Just in case, fully re-center splitter
2703 if ( HasFlag( wxPG_SPLITTER_AUTO_CENTER
) )
2704 pNewState
->m_fSplitterX
= -1.0;
2706 pNewState
->OnClientWidthChange( pgWidth
, pgWidth
- pNewState
->m_width
);
2711 // If necessary, convert state to correct mode.
2712 if ( orig_mode
!= new_state_mode
)
2714 // This should refresh as well.
2715 EnableCategories( orig_mode
?false:true );
2717 else if ( !m_frozen
)
2719 // Refresh, if not frozen.
2720 m_pState
->PrepareAfterItemsAdded();
2722 // Reselect (Use SetSelection() instead of Do-variant so that
2723 // events won't be sent).
2724 SetSelection(m_pState
->m_selection
);
2726 RecalculateVirtualSize(0);
2730 m_pState
->m_itemsAdded
= 1;
2733 // -----------------------------------------------------------------------
2735 // Call to SetSplitterPosition will always disable splitter auto-centering
2736 // if parent window is shown.
2737 void wxPropertyGrid::DoSetSplitterPosition_( int newxpos
, bool refresh
, int splitterIndex
, bool allPages
)
2739 if ( ( newxpos
< wxPG_DRAG_MARGIN
) )
2742 wxPropertyGridPageState
* state
= m_pState
;
2744 state
->DoSetSplitterPosition( newxpos
, splitterIndex
, allPages
);
2748 if ( GetSelection() )
2749 CorrectEditorWidgetSizeX();
2755 // -----------------------------------------------------------------------
2757 void wxPropertyGrid::CenterSplitter( bool enableAutoCentering
)
2759 SetSplitterPosition( m_width
/2, true );
2760 if ( enableAutoCentering
&& ( m_windowStyle
& wxPG_SPLITTER_AUTO_CENTER
) )
2761 m_iFlags
&= ~(wxPG_FL_DONT_CENTER_SPLITTER
);
2764 // -----------------------------------------------------------------------
2765 // wxPropertyGrid item iteration (GetNextProperty etc.) methods
2766 // -----------------------------------------------------------------------
2768 // Returns nearest paint visible property (such that will be painted unless
2769 // window is scrolled or resized). If given property is paint visible, then
2770 // it itself will be returned
2771 wxPGProperty
* wxPropertyGrid::GetNearestPaintVisible( wxPGProperty
* p
) const
2773 int vx
,vy1
;// Top left corner of client
2774 GetViewStart(&vx
,&vy1
);
2775 vy1
*= wxPG_PIXELS_PER_UNIT
;
2777 int vy2
= vy1
+ m_height
;
2778 int propY
= p
->GetY2(m_lineHeight
);
2780 if ( (propY
+ m_lineHeight
) < vy1
)
2783 return DoGetItemAtY( vy1
);
2785 else if ( propY
> vy2
)
2788 return DoGetItemAtY( vy2
);
2791 // Itself paint visible
2796 // -----------------------------------------------------------------------
2797 // Methods related to change in value, value modification and sending events
2798 // -----------------------------------------------------------------------
2800 // commits any changes in editor of selected property
2801 // return true if validation did not fail
2802 // flags are same as with DoSelectProperty
2803 bool wxPropertyGrid::CommitChangesFromEditor( wxUint32 flags
)
2805 // Committing already?
2806 if ( m_inCommitChangesFromEditor
)
2809 // Don't do this if already processing editor event. It might
2810 // induce recursive dialogs and crap like that.
2811 if ( m_iFlags
& wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
)
2813 if ( m_inDoPropertyChanged
)
2819 wxPGProperty
* selected
= GetSelection();
2822 IsEditorsValueModified() &&
2823 (m_iFlags
& wxPG_FL_INITIALIZED
) &&
2826 m_inCommitChangesFromEditor
= 1;
2828 wxVariant
variant(selected
->GetValueRef());
2829 bool valueIsPending
= false;
2831 // JACS - necessary to avoid new focus being found spuriously within OnIdle
2832 // due to another window getting focus
2833 wxWindow
* oldFocus
= m_curFocused
;
2835 bool validationFailure
= false;
2836 bool forceSuccess
= (flags
& (wxPG_SEL_NOVALIDATE
|wxPG_SEL_FORCE
)) ? true : false;
2838 m_chgInfo_changedProperty
= NULL
;
2840 // If truly modified, schedule value as pending.
2841 if ( selected
->GetEditorClass()->
2842 GetValueFromControl( variant
,
2844 GetEditorControl() ) )
2846 if ( DoEditorValidate() &&
2847 PerformValidation(selected
, variant
) )
2849 valueIsPending
= true;
2853 validationFailure
= true;
2858 EditorsValueWasNotModified();
2863 m_inCommitChangesFromEditor
= 0;
2865 if ( validationFailure
&& !forceSuccess
)
2869 oldFocus
->SetFocus();
2870 m_curFocused
= oldFocus
;
2873 res
= OnValidationFailure(selected
, variant
);
2875 // Now prevent further validation failure messages
2878 EditorsValueWasNotModified();
2879 OnValidationFailureReset(selected
);
2882 else if ( valueIsPending
)
2884 DoPropertyChanged( selected
, flags
);
2885 EditorsValueWasNotModified();
2894 // -----------------------------------------------------------------------
2896 bool wxPropertyGrid::PerformValidation( wxPGProperty
* p
, wxVariant
& pendingValue
,
2900 // Runs all validation functionality.
2901 // Returns true if value passes all tests.
2904 m_validationInfo
.m_failureBehavior
= m_permanentValidationFailureBehavior
;
2906 if ( pendingValue
.GetType() == wxPG_VARIANT_TYPE_LIST
)
2908 if ( !p
->ValidateValue(pendingValue
, m_validationInfo
) )
2913 // Adapt list to child values, if necessary
2914 wxVariant listValue
= pendingValue
;
2915 wxVariant
* pPendingValue
= &pendingValue
;
2916 wxVariant
* pList
= NULL
;
2918 // If parent has wxPG_PROP_AGGREGATE flag, or uses composite
2919 // string value, then we need treat as it was changed instead
2920 // (or, in addition, as is the case with composite string parent).
2921 // This includes creating list variant for child values.
2923 wxPGProperty
* pwc
= p
->GetParent();
2924 wxPGProperty
* changedProperty
= p
;
2925 wxPGProperty
* baseChangedProperty
= changedProperty
;
2926 wxVariant bcpPendingList
;
2928 listValue
= pendingValue
;
2929 listValue
.SetName(p
->GetBaseName());
2932 (pwc
->HasFlag(wxPG_PROP_AGGREGATE
) || pwc
->HasFlag(wxPG_PROP_COMPOSED_VALUE
)) )
2934 wxVariantList tempList
;
2935 wxVariant
lv(tempList
, pwc
->GetBaseName());
2936 lv
.Append(listValue
);
2938 pPendingValue
= &listValue
;
2940 if ( pwc
->HasFlag(wxPG_PROP_AGGREGATE
) )
2942 baseChangedProperty
= pwc
;
2943 bcpPendingList
= lv
;
2946 changedProperty
= pwc
;
2947 pwc
= pwc
->GetParent();
2951 wxPGProperty
* evtChangingProperty
= changedProperty
;
2953 if ( pPendingValue
->GetType() != wxPG_VARIANT_TYPE_LIST
)
2955 value
= *pPendingValue
;
2959 // Convert list to child values
2960 pList
= pPendingValue
;
2961 changedProperty
->AdaptListToValue( *pPendingValue
, &value
);
2964 wxVariant evtChangingValue
= value
;
2966 if ( flags
& SendEvtChanging
)
2968 // FIXME: After proper ValueToString()s added, remove
2969 // this. It is just a temporary fix, as evt_changing
2970 // will simply not work for wxPG_PROP_COMPOSED_VALUE
2971 // (unless it is selected, and textctrl editor is open).
2972 if ( changedProperty
->HasFlag(wxPG_PROP_COMPOSED_VALUE
) )
2974 evtChangingProperty
= baseChangedProperty
;
2975 if ( evtChangingProperty
!= p
)
2977 evtChangingProperty
->AdaptListToValue( bcpPendingList
, &evtChangingValue
);
2981 evtChangingValue
= pendingValue
;
2985 if ( evtChangingProperty
->HasFlag(wxPG_PROP_COMPOSED_VALUE
) )
2987 if ( changedProperty
== GetSelection() )
2989 wxWindow
* editor
= GetEditorControl();
2990 wxASSERT( editor
->IsKindOf(CLASSINFO(wxTextCtrl
)) );
2991 evtChangingValue
= wxStaticCast(editor
, wxTextCtrl
)->GetValue();
2995 wxLogDebug(wxT("WARNING: wxEVT_PG_CHANGING is about to happen with old value."));
3000 wxASSERT( m_chgInfo_changedProperty
== NULL
);
3001 m_chgInfo_changedProperty
= changedProperty
;
3002 m_chgInfo_baseChangedProperty
= baseChangedProperty
;
3003 m_chgInfo_pendingValue
= value
;
3006 m_chgInfo_valueList
= *pList
;
3008 m_chgInfo_valueList
.MakeNull();
3010 // If changedProperty is not property which value was edited,
3011 // then call wxPGProperty::ValidateValue() for that as well.
3012 if ( p
!= changedProperty
&& value
.GetType() != wxPG_VARIANT_TYPE_LIST
)
3014 if ( !changedProperty
->ValidateValue(value
, m_validationInfo
) )
3018 if ( flags
& SendEvtChanging
)
3020 // SendEvent returns true if event was vetoed
3021 if ( SendEvent( wxEVT_PG_CHANGING
, evtChangingProperty
,
3022 &evtChangingValue
) )
3026 if ( flags
& IsStandaloneValidation
)
3028 // If called in 'generic' context, we need to reset
3029 // m_chgInfo_changedProperty and write back translated value.
3030 m_chgInfo_changedProperty
= NULL
;
3031 pendingValue
= value
;
3037 // -----------------------------------------------------------------------
3039 void wxPropertyGrid::DoShowPropertyError( wxPGProperty
* WXUNUSED(property
), const wxString
& msg
)
3041 if ( !msg
.length() )
3045 if ( !wxPGGlobalVars
->m_offline
)
3047 wxWindow
* topWnd
= ::wxGetTopLevelParent(this);
3050 wxFrame
* pFrame
= wxDynamicCast(topWnd
, wxFrame
);
3053 wxStatusBar
* pStatusBar
= pFrame
->GetStatusBar();
3056 pStatusBar
->SetStatusText(msg
);
3064 ::wxMessageBox(msg
, wxT("Property Error"));
3067 // -----------------------------------------------------------------------
3069 bool wxPropertyGrid::OnValidationFailure( wxPGProperty
* property
,
3070 wxVariant
& invalidValue
)
3072 wxWindow
* editor
= GetEditorControl();
3074 // First call property's handler
3075 property
->OnValidationFailure(invalidValue
);
3077 bool res
= DoOnValidationFailure(property
, invalidValue
);
3080 // For non-wxTextCtrl editors, we do need to revert the value
3081 if ( !editor
->IsKindOf(CLASSINFO(wxTextCtrl
)) &&
3082 property
== GetSelection() )
3084 property
->GetEditorClass()->UpdateControl(property
, editor
);
3087 property
->SetFlag(wxPG_PROP_INVALID_VALUE
);
3092 bool wxPropertyGrid::DoOnValidationFailure( wxPGProperty
* property
, wxVariant
& WXUNUSED(invalidValue
) )
3094 int vfb
= m_validationInfo
.m_failureBehavior
;
3096 if ( vfb
& wxPG_VFB_BEEP
)
3099 if ( (vfb
& wxPG_VFB_MARK_CELL
) &&
3100 !property
->HasFlag(wxPG_PROP_INVALID_VALUE
) )
3102 unsigned int colCount
= m_pState
->GetColumnCount();
3104 // We need backup marked property's cells
3105 m_propCellsBackup
= property
->m_cells
;
3107 wxColour vfbFg
= *wxWHITE
;
3108 wxColour vfbBg
= *wxRED
;
3110 property
->EnsureCells(colCount
);
3112 for ( unsigned int i
=0; i
<colCount
; i
++ )
3114 wxPGCell
& cell
= property
->m_cells
[i
];
3115 cell
.SetFgCol(vfbFg
);
3116 cell
.SetBgCol(vfbBg
);
3119 DrawItemAndChildren(property
);
3121 if ( property
== GetSelection() )
3123 SetInternalFlag(wxPG_FL_CELL_OVERRIDES_SEL
);
3125 wxWindow
* editor
= GetEditorControl();
3128 editor
->SetForegroundColour(vfbFg
);
3129 editor
->SetBackgroundColour(vfbBg
);
3134 if ( vfb
& wxPG_VFB_SHOW_MESSAGE
)
3136 wxString msg
= m_validationInfo
.m_failureMessage
;
3138 if ( !msg
.length() )
3139 msg
= wxT("You have entered invalid value. Press ESC to cancel editing.");
3141 DoShowPropertyError(property
, msg
);
3144 return (vfb
& wxPG_VFB_STAY_IN_PROPERTY
) ? false : true;
3147 // -----------------------------------------------------------------------
3149 void wxPropertyGrid::DoOnValidationFailureReset( wxPGProperty
* property
)
3151 int vfb
= m_validationInfo
.m_failureBehavior
;
3153 if ( vfb
& wxPG_VFB_MARK_CELL
)
3156 property
->m_cells
= m_propCellsBackup
;
3158 ClearInternalFlag(wxPG_FL_CELL_OVERRIDES_SEL
);
3160 if ( property
== GetSelection() && GetEditorControl() )
3162 // Calling this will recreate the control, thus resetting its colour
3163 RefreshProperty(property
);
3167 DrawItemAndChildren(property
);
3172 // -----------------------------------------------------------------------
3174 // flags are same as with DoSelectProperty
3175 bool wxPropertyGrid::DoPropertyChanged( wxPGProperty
* p
, unsigned int selFlags
)
3177 if ( m_inDoPropertyChanged
)
3180 wxWindow
* editor
= GetEditorControl();
3181 wxPGProperty
* selected
= GetSelection();
3183 m_pState
->m_anyModified
= 1;
3185 m_inDoPropertyChanged
= 1;
3187 // Maybe need to update control
3188 wxASSERT( m_chgInfo_changedProperty
!= NULL
);
3190 // These values were calculated in PerformValidation()
3191 wxPGProperty
* changedProperty
= m_chgInfo_changedProperty
;
3192 wxVariant value
= m_chgInfo_pendingValue
;
3194 wxPGProperty
* topPaintedProperty
= changedProperty
;
3196 while ( !topPaintedProperty
->IsCategory() &&
3197 !topPaintedProperty
->IsRoot() )
3199 topPaintedProperty
= topPaintedProperty
->GetParent();
3202 changedProperty
->SetValue(value
, &m_chgInfo_valueList
, wxPG_SETVAL_BY_USER
);
3204 // Set as Modified (not if dragging just began)
3205 if ( !(p
->m_flags
& wxPG_PROP_MODIFIED
) )
3207 p
->m_flags
|= wxPG_PROP_MODIFIED
;
3208 if ( p
== selected
&& (m_windowStyle
& wxPG_BOLD_MODIFIED
) )
3211 SetCurControlBoldFont();
3217 // Propagate updates to parent(s)
3219 wxPGProperty
* prevPwc
= NULL
;
3221 while ( prevPwc
!= topPaintedProperty
)
3223 pwc
->m_flags
|= wxPG_PROP_MODIFIED
;
3225 if ( pwc
== selected
&& (m_windowStyle
& wxPG_BOLD_MODIFIED
) )
3228 SetCurControlBoldFont();
3232 pwc
= pwc
->GetParent();
3235 // Draw the actual property
3236 DrawItemAndChildren( topPaintedProperty
);
3239 // If value was set by wxPGProperty::OnEvent, then update the editor
3241 if ( selFlags
& wxPG_SEL_DIALOGVAL
)
3247 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
3248 if ( m_wndEditor
) m_wndEditor
->Refresh();
3249 if ( m_wndEditor2
) m_wndEditor2
->Refresh();
3254 wxASSERT( !changedProperty
->GetParent()->HasFlag(wxPG_PROP_AGGREGATE
) );
3256 // If top parent has composite string value, then send to child parents,
3257 // starting from baseChangedProperty.
3258 if ( changedProperty
->HasFlag(wxPG_PROP_COMPOSED_VALUE
) )
3260 pwc
= m_chgInfo_baseChangedProperty
;
3262 while ( pwc
!= changedProperty
)
3264 SendEvent( wxEVT_PG_CHANGED
, pwc
, NULL
);
3265 pwc
= pwc
->GetParent();
3269 SendEvent( wxEVT_PG_CHANGED
, changedProperty
, NULL
);
3271 m_inDoPropertyChanged
= 0;
3276 // -----------------------------------------------------------------------
3278 bool wxPropertyGrid::ChangePropertyValue( wxPGPropArg id
, wxVariant newValue
)
3280 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
3282 m_chgInfo_changedProperty
= NULL
;
3284 if ( PerformValidation(p
, newValue
) )
3286 DoPropertyChanged(p
);
3291 OnValidationFailure(p
, newValue
);
3297 // -----------------------------------------------------------------------
3299 wxVariant
wxPropertyGrid::GetUncommittedPropertyValue()
3301 wxPGProperty
* prop
= GetSelectedProperty();
3304 return wxNullVariant
;
3306 wxTextCtrl
* tc
= GetEditorTextCtrl();
3307 wxVariant value
= prop
->GetValue();
3309 if ( !tc
|| !IsEditorsValueModified() )
3312 if ( !prop
->StringToValue(value
, tc
->GetValue()) )
3315 if ( !PerformValidation(prop
, value
, IsStandaloneValidation
) )
3316 return prop
->GetValue();
3321 // -----------------------------------------------------------------------
3323 // Runs wxValidator for the selected property
3324 bool wxPropertyGrid::DoEditorValidate()
3329 // -----------------------------------------------------------------------
3331 void wxPropertyGrid::HandleCustomEditorEvent( wxEvent
&event
)
3333 wxPGProperty
* selected
= GetSelection();
3335 // Somehow, event is handled after property has been deselected.
3336 // Possibly, but very rare.
3338 selected
->HasFlag(wxPG_PROP_BEING_DELETED
) ||
3339 // Also don't handle editor event if wxEVT_PG_CHANGED or
3340 // similar is currently doing something (showing a
3341 // message box, for instance).
3345 if ( m_iFlags
& wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
)
3348 wxVariant
pendingValue(selected
->GetValueRef());
3349 wxWindow
* wnd
= GetEditorControl();
3350 wxWindow
* editorWnd
= wxDynamicCast(event
.GetEventObject(), wxWindow
);
3352 bool wasUnspecified
= selected
->IsValueUnspecified();
3353 int usesAutoUnspecified
= selected
->UsesAutoUnspecified();
3354 bool valueIsPending
= false;
3356 m_chgInfo_changedProperty
= NULL
;
3358 m_iFlags
&= ~(wxPG_FL_VALIDATION_FAILED
|wxPG_FL_VALUE_CHANGE_IN_EVENT
);
3361 // Filter out excess wxTextCtrl modified events
3362 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED
&&
3364 wnd
->IsKindOf(CLASSINFO(wxTextCtrl
)) )
3366 wxTextCtrl
* tc
= (wxTextCtrl
*) wnd
;
3368 wxString newTcValue
= tc
->GetValue();
3369 if ( m_prevTcValue
== newTcValue
)
3372 m_prevTcValue
= newTcValue
;
3375 SetInternalFlag(wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
);
3377 bool validationFailure
= false;
3378 bool buttonWasHandled
= false;
3381 // Try common button handling
3382 if ( m_wndEditor2
&& event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
3384 wxPGEditorDialogAdapter
* adapter
= selected
->GetEditorDialog();
3388 buttonWasHandled
= true;
3389 // Store as res2, as previously (and still currently alternatively)
3390 // dialogs can be shown by handling wxEVT_COMMAND_BUTTON_CLICKED
3391 // in wxPGProperty::OnEvent().
3392 adapter
->ShowDialog( this, selected
);
3397 if ( !buttonWasHandled
)
3399 if ( wnd
|| m_wndEditor2
)
3401 // First call editor class' event handler.
3402 const wxPGEditor
* editor
= selected
->GetEditorClass();
3404 if ( editor
->OnEvent( this, selected
, editorWnd
, event
) )
3406 // If changes, validate them
3407 if ( DoEditorValidate() )
3409 if ( editor
->GetValueFromControl( pendingValue
,
3412 valueIsPending
= true;
3416 validationFailure
= true;
3421 // Then the property's custom handler (must be always called, unless
3422 // validation failed).
3423 if ( !validationFailure
)
3424 buttonWasHandled
= selected
->OnEvent( this, editorWnd
, event
);
3427 // SetValueInEvent(), as called in one of the functions referred above
3428 // overrides editor's value.
3429 if ( m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
)
3431 valueIsPending
= true;
3432 pendingValue
= m_changeInEventValue
;
3433 selFlags
|= wxPG_SEL_DIALOGVAL
;
3436 if ( !validationFailure
&& valueIsPending
)
3437 if ( !PerformValidation(selected
, pendingValue
) )
3438 validationFailure
= true;
3440 if ( validationFailure
)
3442 OnValidationFailure(selected
, pendingValue
);
3444 else if ( valueIsPending
)
3446 selFlags
|= ( !wasUnspecified
&& selected
->IsValueUnspecified() && usesAutoUnspecified
) ? wxPG_SEL_SETUNSPEC
: 0;
3448 DoPropertyChanged(selected
, selFlags
);
3449 EditorsValueWasNotModified();
3451 // Regardless of editor type, unfocus editor on
3452 // text-editing related enter press.
3453 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_ENTER
)
3460 // No value after all
3462 // Regardless of editor type, unfocus editor on
3463 // text-editing related enter press.
3464 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_ENTER
)
3469 // Let unhandled button click events go to the parent
3470 if ( !buttonWasHandled
&& event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
3472 wxCommandEvent
evt(wxEVT_COMMAND_BUTTON_CLICKED
,GetId());
3473 GetEventHandler()->AddPendingEvent(evt
);
3477 ClearInternalFlag(wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
);
3480 // -----------------------------------------------------------------------
3481 // wxPropertyGrid editor control helper methods
3482 // -----------------------------------------------------------------------
3484 wxRect
wxPropertyGrid::GetEditorWidgetRect( wxPGProperty
* p
, int column
) const
3486 int itemy
= p
->GetY2(m_lineHeight
);
3488 int splitterX
= m_pState
->DoGetSplitterPosition(column
-1);
3489 int colEnd
= splitterX
+ m_pState
->m_colWidths
[column
];
3490 int imageOffset
= 0;
3492 // TODO: If custom image detection changes from current, change this.
3493 if ( m_iFlags
& wxPG_FL_CUR_USES_CUSTOM_IMAGE
)
3495 //m_iFlags |= wxPG_FL_CUR_USES_CUSTOM_IMAGE;
3496 int iw
= p
->OnMeasureImage().x
;
3498 iw
= wxPG_CUSTOM_IMAGE_WIDTH
;
3499 imageOffset
= p
->GetImageOffset(iw
);
3504 splitterX
+imageOffset
+wxPG_XBEFOREWIDGET
+wxPG_CONTROL_MARGIN
+1,
3506 colEnd
-splitterX
-wxPG_XBEFOREWIDGET
-wxPG_CONTROL_MARGIN
-imageOffset
-1,
3511 // -----------------------------------------------------------------------
3513 wxRect
wxPropertyGrid::GetImageRect( wxPGProperty
* p
, int item
) const
3515 wxSize sz
= GetImageSize(p
, item
);
3516 return wxRect(wxPG_CONTROL_MARGIN
+ wxCC_CUSTOM_IMAGE_MARGIN1
,
3517 wxPG_CUSTOM_IMAGE_SPACINGY
,
3522 // return size of custom paint image
3523 wxSize
wxPropertyGrid::GetImageSize( wxPGProperty
* p
, int item
) const
3525 // If called with NULL property, then return default image
3526 // size for properties that use image.
3528 return wxSize(wxPG_CUSTOM_IMAGE_WIDTH
,wxPG_STD_CUST_IMAGE_HEIGHT(m_lineHeight
));
3530 wxSize cis
= p
->OnMeasureImage(item
);
3532 int choiceCount
= p
->m_choices
.GetCount();
3533 int comVals
= p
->GetDisplayedCommonValueCount();
3534 if ( item
>= choiceCount
&& comVals
> 0 )
3536 unsigned int cvi
= item
-choiceCount
;
3537 cis
= GetCommonValue(cvi
)->GetRenderer()->GetImageSize(NULL
, 1, cvi
);
3539 else if ( item
>= 0 && choiceCount
== 0 )
3540 return wxSize(0, 0);
3545 cis
.x
= wxPG_CUSTOM_IMAGE_WIDTH
;
3550 cis
.y
= wxPG_STD_CUST_IMAGE_HEIGHT(m_lineHeight
);
3557 // -----------------------------------------------------------------------
3559 // takes scrolling into account
3560 void wxPropertyGrid::ImprovedClientToScreen( int* px
, int* py
)
3563 GetViewStart(&vx
,&vy
);
3564 vy
*=wxPG_PIXELS_PER_UNIT
;
3565 vx
*=wxPG_PIXELS_PER_UNIT
;
3568 ClientToScreen( px
, py
);
3571 // -----------------------------------------------------------------------
3573 wxPropertyGridHitTestResult
wxPropertyGrid::HitTest( const wxPoint
& pt
) const
3576 GetViewStart(&pt2
.x
,&pt2
.y
);
3577 pt2
.x
*= wxPG_PIXELS_PER_UNIT
;
3578 pt2
.y
*= wxPG_PIXELS_PER_UNIT
;
3582 return m_pState
->HitTest(pt2
);
3585 // -----------------------------------------------------------------------
3587 // custom set cursor
3588 void wxPropertyGrid::CustomSetCursor( int type
, bool override
)
3590 if ( type
== m_curcursor
&& !override
) return;
3592 wxCursor
* cursor
= &wxPG_DEFAULT_CURSOR
;
3594 if ( type
== wxCURSOR_SIZEWE
)
3595 cursor
= m_cursorSizeWE
;
3597 m_canvas
->SetCursor( *cursor
);
3602 // -----------------------------------------------------------------------
3603 // wxPropertyGrid property selection, editor creation
3604 // -----------------------------------------------------------------------
3607 // This class forwards events from property editor controls to wxPropertyGrid.
3608 class wxPropertyGridEditorEventForwarder
: public wxEvtHandler
3611 wxPropertyGridEditorEventForwarder( wxPropertyGrid
* propGrid
)
3612 : wxEvtHandler(), m_propGrid(propGrid
)
3616 virtual ~wxPropertyGridEditorEventForwarder()
3621 bool ProcessEvent( wxEvent
& event
)
3626 m_propGrid
->HandleCustomEditorEvent(event
);
3628 return wxEvtHandler::ProcessEvent(event
);
3631 wxPropertyGrid
* m_propGrid
;
3634 // Setups event handling for child control
3635 void wxPropertyGrid::SetupChildEventHandling( wxWindow
* argWnd
)
3637 wxWindowID id
= argWnd
->GetId();
3639 if ( argWnd
== m_wndEditor
)
3641 argWnd
->Connect(id
, wxEVT_MOTION
,
3642 wxMouseEventHandler(wxPropertyGrid::OnMouseMoveChild
),
3644 argWnd
->Connect(id
, wxEVT_LEFT_UP
,
3645 wxMouseEventHandler(wxPropertyGrid::OnMouseUpChild
),
3647 argWnd
->Connect(id
, wxEVT_LEFT_DOWN
,
3648 wxMouseEventHandler(wxPropertyGrid::OnMouseClickChild
),
3650 argWnd
->Connect(id
, wxEVT_RIGHT_UP
,
3651 wxMouseEventHandler(wxPropertyGrid::OnMouseRightClickChild
),
3653 argWnd
->Connect(id
, wxEVT_ENTER_WINDOW
,
3654 wxMouseEventHandler(wxPropertyGrid::OnMouseEntry
),
3656 argWnd
->Connect(id
, wxEVT_LEAVE_WINDOW
,
3657 wxMouseEventHandler(wxPropertyGrid::OnMouseEntry
),
3661 wxPropertyGridEditorEventForwarder
* forwarder
;
3662 forwarder
= new wxPropertyGridEditorEventForwarder(this);
3663 argWnd
->PushEventHandler(forwarder
);
3665 argWnd
->Connect(id
, wxEVT_KEY_DOWN
,
3666 wxCharEventHandler(wxPropertyGrid::OnChildKeyDown
),
3670 void wxPropertyGrid::DestroyEditorWnd( wxWindow
* wnd
)
3677 // Do not free editors immediately (for sake of processing events)
3678 wxPendingDelete
.Append(wnd
);
3681 void wxPropertyGrid::FreeEditors()
3684 // Return focus back to canvas from children (this is required at least for
3685 // GTK+, which, unlike Windows, clears focus when control is destroyed
3686 // instead of moving it to closest parent).
3687 wxWindow
* focus
= wxWindow::FindFocus();
3690 wxWindow
* parent
= focus
->GetParent();
3693 if ( parent
== m_canvas
)
3698 parent
= parent
->GetParent();
3702 // Do not free editors immediately if processing events
3705 wxEvtHandler
* handler
= m_wndEditor2
->PopEventHandler(false);
3706 m_wndEditor2
->Hide();
3707 wxPendingDelete
.Append( handler
);
3708 DestroyEditorWnd(m_wndEditor2
);
3709 m_wndEditor2
= NULL
;
3714 wxEvtHandler
* handler
= m_wndEditor
->PopEventHandler(false);
3715 m_wndEditor
->Hide();
3716 wxPendingDelete
.Append( handler
);
3717 DestroyEditorWnd(m_wndEditor
);
3722 // Call with NULL to de-select property
3723 bool wxPropertyGrid::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
3728 wxLogDebug(wxT("SelectProperty( %s (%s[%i]) )"),p->m_label.c_str(),
3729 p->m_parent->m_label.c_str(),p->GetIndexInParent());
3733 wxLogDebug(wxT("SelectProperty( NULL, -1 )"));
3737 if ( m_inDoSelectProperty
)
3740 m_inDoSelectProperty
= 1;
3744 m_inDoSelectProperty
= 0;
3748 wxArrayPGProperty prevSelection
= m_pState
->m_selection
;
3749 wxPGProperty
* prevFirstSel
;
3751 if ( prevSelection
.size() > 0 )
3752 prevFirstSel
= prevSelection
[0];
3754 prevFirstSel
= NULL
;
3756 if ( prevFirstSel
&& prevFirstSel
->HasFlag(wxPG_PROP_BEING_DELETED
) )
3757 prevFirstSel
= NULL
;
3759 // Always send event, as this is indirect call
3760 DoEndLabelEdit(true, wxPG_SEL_NOVALIDATE
);
3764 wxPrintf( "Selected %s\n", prevFirstSel->GetClassInfo()->GetClassName() );
3766 wxPrintf( "None selected\n" );
3769 wxPrintf( "P = %s\n", p->GetClassInfo()->GetClassName() );
3771 wxPrintf( "P = NULL\n" );
3774 // If we are frozen, then just set the values.
3777 m_iFlags
&= ~(wxPG_FL_ABNORMAL_EDITOR
);
3778 m_editorFocused
= 0;
3779 m_pState
->DoSetSelection(p
);
3781 // If frozen, always free controls. But don't worry, as Thaw will
3782 // recall SelectProperty to recreate them.
3785 // Prevent any further selection measures in this call
3791 if ( prevFirstSel
== p
&&
3792 prevSelection
.size() <= 1 &&
3793 !(flags
& wxPG_SEL_FORCE
) )
3795 // Only set focus if not deselecting
3798 if ( flags
& wxPG_SEL_FOCUS
)
3802 m_wndEditor
->SetFocus();
3803 m_editorFocused
= 1;
3812 m_inDoSelectProperty
= 0;
3817 // First, deactivate previous
3820 OnValidationFailureReset(prevFirstSel
);
3822 // Must double-check if this is an selected in case of forceswitch
3823 if ( p
!= prevFirstSel
)
3825 if ( !CommitChangesFromEditor(flags
) )
3827 // Validation has failed, so we can't exit the previous editor
3828 //::wxMessageBox(_("Please correct the value or press ESC to cancel the edit."),
3829 // _("Invalid Value"),wxOK|wxICON_ERROR);
3830 m_inDoSelectProperty
= 0;
3837 m_iFlags
&= ~(wxPG_FL_ABNORMAL_EDITOR
);
3838 EditorsValueWasNotModified();
3841 SetInternalFlag(wxPG_FL_IN_SELECT_PROPERTY
);
3843 m_pState
->DoSetSelection(p
);
3845 // Redraw unselected
3846 for ( unsigned int i
=0; i
<prevSelection
.size(); i
++ )
3848 DrawItem(prevSelection
[i
]);
3852 // Then, activate the one given.
3855 int propY
= p
->GetY2(m_lineHeight
);
3857 int splitterX
= GetSplitterPosition();
3858 m_editorFocused
= 0;
3859 m_iFlags
|= wxPG_FL_PRIMARY_FILLS_ENTIRE
;
3860 if ( p
!= prevFirstSel
)
3861 m_iFlags
&= ~(wxPG_FL_VALIDATION_FAILED
);
3863 wxASSERT( m_wndEditor
== NULL
);
3866 // Only create editor for non-disabled non-caption
3867 if ( !p
->IsCategory() && !(p
->m_flags
& wxPG_PROP_DISABLED
) )
3869 // do this for non-caption items
3873 // Do we need to paint the custom image, if any?
3874 m_iFlags
&= ~(wxPG_FL_CUR_USES_CUSTOM_IMAGE
);
3875 if ( (p
->m_flags
& wxPG_PROP_CUSTOMIMAGE
) &&
3876 !p
->GetEditorClass()->CanContainCustomImage()
3878 m_iFlags
|= wxPG_FL_CUR_USES_CUSTOM_IMAGE
;
3880 wxRect grect
= GetEditorWidgetRect(p
, m_selColumn
);
3881 wxPoint goodPos
= grect
.GetPosition();
3883 const wxPGEditor
* editor
= p
->GetEditorClass();
3884 wxCHECK_MSG(editor
, false,
3885 wxT("NULL editor class not allowed"));
3887 m_iFlags
&= ~wxPG_FL_FIXED_WIDTH_EDITOR
;
3889 wxPGWindowList wndList
= editor
->CreateControls(this,
3894 m_wndEditor
= wndList
.m_primary
;
3895 m_wndEditor2
= wndList
.m_secondary
;
3896 wxWindow
* primaryCtrl
= GetEditorControl();
3899 // Essentially, primaryCtrl == m_wndEditor
3902 // NOTE: It is allowed for m_wndEditor to be NULL - in this case
3903 // value is drawn as normal, and m_wndEditor2 is assumed
3904 // to be a right-aligned button that triggers a separate editorCtrl
3909 wxASSERT_MSG( m_wndEditor
->GetParent() == GetPanel(),
3910 wxT("CreateControls must use result of wxPropertyGrid::GetPanel() as parent of controls.") );
3912 // Set validator, if any
3913 #if wxUSE_VALIDATORS
3914 wxValidator
* validator
= p
->GetValidator();
3916 primaryCtrl
->SetValidator(*validator
);
3919 if ( m_wndEditor
->GetSize().y
> (m_lineHeight
+6) )
3920 m_iFlags
|= wxPG_FL_ABNORMAL_EDITOR
;
3922 // If it has modified status, use bold font
3923 // (must be done before capturing m_ctrlXAdjust)
3924 if ( (p
->m_flags
& wxPG_PROP_MODIFIED
) && (m_windowStyle
& wxPG_BOLD_MODIFIED
) )
3925 SetCurControlBoldFont();
3927 // Store x relative to splitter (we'll need it).
3928 m_ctrlXAdjust
= m_wndEditor
->GetPosition().x
- splitterX
;
3930 // Check if background clear is not necessary
3931 wxPoint pos
= m_wndEditor
->GetPosition();
3932 if ( pos
.x
> (splitterX
+1) || pos
.y
> propY
)
3934 m_iFlags
&= ~(wxPG_FL_PRIMARY_FILLS_ENTIRE
);
3937 m_wndEditor
->SetSizeHints(3, 3);
3939 SetupChildEventHandling(primaryCtrl
);
3941 // Focus and select all (wxTextCtrl, wxComboBox etc)
3942 if ( flags
& wxPG_SEL_FOCUS
)
3944 primaryCtrl
->SetFocus();
3946 p
->GetEditorClass()->OnFocus(p
, primaryCtrl
);
3952 wxASSERT_MSG( m_wndEditor2
->GetParent() == GetPanel(),
3953 wxT("CreateControls must use result of wxPropertyGrid::GetPanel() as parent of controls.") );
3955 // Get proper id for wndSecondary
3956 m_wndSecId
= m_wndEditor2
->GetId();
3957 wxWindowList children
= m_wndEditor2
->GetChildren();
3958 wxWindowList::iterator node
= children
.begin();
3959 if ( node
!= children
.end() )
3960 m_wndSecId
= ((wxWindow
*)*node
)->GetId();
3962 m_wndEditor2
->SetSizeHints(3,3);
3964 m_wndEditor2
->Show();
3966 SetupChildEventHandling(m_wndEditor2
);
3968 // If no primary editor, focus to button to allow
3969 // it to interprete ENTER etc.
3970 // NOTE: Due to problems focusing away from it, this
3971 // has been disabled.
3973 if ( (flags & wxPG_SEL_FOCUS) && !m_wndEditor )
3974 m_wndEditor2->SetFocus();
3978 if ( flags
& wxPG_SEL_FOCUS
)
3979 m_editorFocused
= 1;
3984 // Make sure focus is in grid canvas (important for wxGTK, at least)
3988 EditorsValueWasNotModified();
3990 // If it's inside collapsed section, expand parent, scroll, etc.
3991 // Also, if it was partially visible, scroll it into view.
3992 if ( !(flags
& wxPG_SEL_NONVISIBLE
) )
3997 m_wndEditor
->Show(true);
4000 if ( !(flags
& wxPG_SEL_NO_REFRESH
) )
4005 // Make sure focus is in grid canvas
4009 ClearInternalFlag(wxPG_FL_IN_SELECT_PROPERTY
);
4015 // Show help text in status bar.
4016 // (if found and grid not embedded in manager with help box and
4017 // style wxPG_EX_HELP_AS_TOOLTIPS is not used).
4020 if ( !(GetExtraStyle() & wxPG_EX_HELP_AS_TOOLTIPS
) )
4022 wxStatusBar
* statusbar
= NULL
;
4023 if ( !(m_iFlags
& wxPG_FL_NOSTATUSBARHELP
) )
4025 wxFrame
* frame
= wxDynamicCast(::wxGetTopLevelParent(this),wxFrame
);
4027 statusbar
= frame
->GetStatusBar();
4032 const wxString
* pHelpString
= (const wxString
*) NULL
;
4036 pHelpString
= &p
->GetHelpString();
4037 if ( pHelpString
->length() )
4039 // Set help box text.
4040 statusbar
->SetStatusText( *pHelpString
);
4041 m_iFlags
|= wxPG_FL_STRING_IN_STATUSBAR
;
4045 if ( (!pHelpString
|| !pHelpString
->length()) &&
4046 (m_iFlags
& wxPG_FL_STRING_IN_STATUSBAR
) )
4048 // Clear help box - but only if it was written
4049 // by us at previous time.
4050 statusbar
->SetStatusText( m_emptyString
);
4051 m_iFlags
&= ~(wxPG_FL_STRING_IN_STATUSBAR
);
4057 m_inDoSelectProperty
= 0;
4059 // call wx event handler (here so that it also occurs on deselection)
4060 if ( !(flags
& wxPG_SEL_DONT_SEND_EVENT
) )
4061 SendEvent( wxEVT_PG_SELECTED
, p
, NULL
);
4066 // -----------------------------------------------------------------------
4068 bool wxPropertyGrid::UnfocusEditor()
4070 wxPGProperty
* selected
= GetSelection();
4072 if ( !selected
|| !m_wndEditor
|| m_frozen
)
4075 if ( !CommitChangesFromEditor(0) )
4084 // -----------------------------------------------------------------------
4086 void wxPropertyGrid::RefreshEditor()
4088 wxPGProperty
* p
= GetSelection();
4092 wxWindow
* wnd
= GetEditorControl();
4096 // Set editor font boldness - must do this before
4097 // calling UpdateControl().
4098 if ( HasFlag(wxPG_BOLD_MODIFIED
) )
4100 if ( p
->HasFlag(wxPG_PROP_MODIFIED
) )
4101 wnd
->SetFont(GetCaptionFont());
4103 wnd
->SetFont(GetFont());
4106 const wxPGEditor
* editorClass
= p
->GetEditorClass();
4108 editorClass
->UpdateControl(p
, wnd
);
4110 if ( p
->IsValueUnspecified() )
4111 editorClass
->SetValueToUnspecified(p
, wnd
);
4114 // -----------------------------------------------------------------------
4116 bool wxPropertyGrid::SelectProperty( wxPGPropArg id
, bool focus
)
4118 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
4120 int flags
= wxPG_SEL_DONT_SEND_EVENT
;
4122 flags
|= wxPG_SEL_FOCUS
;
4124 return DoSelectProperty(p
, flags
);
4127 // -----------------------------------------------------------------------
4128 // wxPropertyGrid expand/collapse state
4129 // -----------------------------------------------------------------------
4131 bool wxPropertyGrid::DoCollapse( wxPGProperty
* p
, bool sendEvents
)
4133 wxPGProperty
* pwc
= wxStaticCast(p
, wxPGProperty
);
4134 wxPGProperty
* selected
= GetSelection();
4136 // If active editor was inside collapsed section, then disable it
4137 if ( selected
&& selected
->IsSomeParent(p
) )
4142 // Store dont-center-splitter flag 'cause we need to temporarily set it
4143 wxUint32 old_flag
= m_iFlags
& wxPG_FL_DONT_CENTER_SPLITTER
;
4144 m_iFlags
|= wxPG_FL_DONT_CENTER_SPLITTER
;
4146 bool res
= m_pState
->DoCollapse(pwc
);
4151 SendEvent( wxEVT_PG_ITEM_COLLAPSED
, p
);
4153 RecalculateVirtualSize();
4155 // Redraw etc. only if collapsed was visible.
4156 if (pwc
->IsVisible() &&
4158 ( !pwc
->IsCategory() || !(m_windowStyle
& wxPG_HIDE_CATEGORIES
) ) )
4160 // When item is collapsed so that scrollbar would move,
4161 // graphics mess is about (unless we redraw everything).
4166 // Clear dont-center-splitter flag if it wasn't set
4167 m_iFlags
= (m_iFlags
& ~wxPG_FL_DONT_CENTER_SPLITTER
) | old_flag
;
4172 // -----------------------------------------------------------------------
4174 bool wxPropertyGrid::DoExpand( wxPGProperty
* p
, bool sendEvents
)
4176 wxCHECK_MSG( p
, false, wxT("invalid property id") );
4178 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
4180 // Store dont-center-splitter flag 'cause we need to temporarily set it
4181 wxUint32 old_flag
= m_iFlags
& wxPG_FL_DONT_CENTER_SPLITTER
;
4182 m_iFlags
|= wxPG_FL_DONT_CENTER_SPLITTER
;
4184 bool res
= m_pState
->DoExpand(pwc
);
4189 SendEvent( wxEVT_PG_ITEM_EXPANDED
, p
);
4191 RecalculateVirtualSize();
4193 // Redraw etc. only if expanded was visible.
4194 if ( pwc
->IsVisible() && !m_frozen
&&
4195 ( !pwc
->IsCategory() || !(m_windowStyle
& wxPG_HIDE_CATEGORIES
) )
4199 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
4202 DrawItems(pwc
, NULL
);
4207 // Clear dont-center-splitter flag if it wasn't set
4208 m_iFlags
= (m_iFlags
& ~wxPG_FL_DONT_CENTER_SPLITTER
) | old_flag
;
4213 // -----------------------------------------------------------------------
4215 bool wxPropertyGrid::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
4218 return m_pState
->DoHideProperty(p
, hide
, flags
);
4220 wxArrayPGProperty selection
= m_pState
->m_selection
; // Must use a copy
4221 int selRemoveCount
= 0;
4222 for ( unsigned int i
=0; i
<selection
.size(); i
++ )
4224 wxPGProperty
* selected
= selection
[i
];
4225 if ( selected
== p
|| selected
->IsSomeParent(p
) )
4227 if ( !DoRemoveFromSelection(p
, flags
) )
4229 selRemoveCount
+= 1;
4233 m_pState
->DoHideProperty(p
, hide
, flags
);
4235 RecalculateVirtualSize();
4242 // -----------------------------------------------------------------------
4243 // wxPropertyGrid size related methods
4244 // -----------------------------------------------------------------------
4246 void wxPropertyGrid::RecalculateVirtualSize( int forceXPos
)
4248 if ( (m_iFlags
& wxPG_FL_RECALCULATING_VIRTUAL_SIZE
) || m_frozen
)
4252 // If virtual height was changed, then recalculate editor control position(s)
4253 if ( m_pState
->m_vhCalcPending
)
4254 CorrectEditorWidgetPosY();
4256 m_pState
->EnsureVirtualHeight();
4258 wxASSERT_LEVEL_2_MSG(
4259 m_pState
->GetVirtualHeight() == m_pState
->GetActualVirtualHeight(),
4260 "VirtualHeight and ActualVirtualHeight should match"
4263 m_iFlags
|= wxPG_FL_RECALCULATING_VIRTUAL_SIZE
;
4265 int x
= m_pState
->m_width
;
4266 int y
= m_pState
->m_virtualHeight
;
4269 GetClientSize(&width
,&height
);
4271 // Now adjust virtual size.
4272 SetVirtualSize(x
, y
);
4278 // Adjust scrollbars
4279 if ( HasVirtualWidth() )
4281 xAmount
= x
/wxPG_PIXELS_PER_UNIT
;
4282 xPos
= GetScrollPos( wxHORIZONTAL
);
4285 if ( forceXPos
!= -1 )
4288 else if ( xPos
> (xAmount
-(width
/wxPG_PIXELS_PER_UNIT
)) )
4291 int yAmount
= y
/ wxPG_PIXELS_PER_UNIT
;
4292 int yPos
= GetScrollPos( wxVERTICAL
);
4294 SetScrollbars( wxPG_PIXELS_PER_UNIT
, wxPG_PIXELS_PER_UNIT
,
4295 xAmount
, yAmount
, xPos
, yPos
, true );
4297 // Must re-get size now
4298 GetClientSize(&width
,&height
);
4300 if ( !HasVirtualWidth() )
4302 m_pState
->SetVirtualWidth(width
);
4309 // Explicitly pass the position - works around a bug in wxWidgets when the property grid
4310 // has a native XP border and a contained window creeps up-and-left when size is set without
4312 m_canvas
->SetSize( 0, 0, x
, y
);
4314 m_pState
->CheckColumnWidths();
4316 if ( GetSelection() )
4317 CorrectEditorWidgetSizeX();
4319 m_iFlags
&= ~wxPG_FL_RECALCULATING_VIRTUAL_SIZE
;
4322 // -----------------------------------------------------------------------
4324 void wxPropertyGrid::OnResize( wxSizeEvent
& event
)
4326 if ( !(m_iFlags
& wxPG_FL_INITIALIZED
) )
4330 GetClientSize(&width
,&height
);
4335 #if wxPG_DOUBLE_BUFFER
4336 if ( !(GetExtraStyle() & wxPG_EX_NATIVE_DOUBLE_BUFFERING
) )
4338 int dblh
= (m_lineHeight
*2);
4339 if ( !m_doubleBuffer
)
4341 // Create double buffer bitmap to draw on, if none
4342 int w
= (width
>250)?width
:250;
4343 int h
= height
+ dblh
;
4345 m_doubleBuffer
= new wxBitmap( w
, h
);
4349 int w
= m_doubleBuffer
->GetWidth();
4350 int h
= m_doubleBuffer
->GetHeight();
4352 // Double buffer must be large enough
4353 if ( w
< width
|| h
< (height
+dblh
) )
4355 if ( w
< width
) w
= width
;
4356 if ( h
< (height
+dblh
) ) h
= height
+ dblh
;
4357 delete m_doubleBuffer
;
4358 m_doubleBuffer
= new wxBitmap( w
, h
);
4365 m_pState
->OnClientWidthChange( width
, event
.GetSize().x
- m_ncWidth
, true );
4366 m_ncWidth
= event
.GetSize().x
;
4370 if ( m_pState
->m_itemsAdded
)
4371 PrepareAfterItemsAdded();
4373 // Without this, virtual size (atleast under wxGTK) will be skewed
4374 RecalculateVirtualSize();
4380 // -----------------------------------------------------------------------
4382 void wxPropertyGrid::SetVirtualWidth( int width
)
4386 // Disable virtual width
4387 width
= GetClientSize().x
;
4388 ClearInternalFlag(wxPG_FL_HAS_VIRTUAL_WIDTH
);
4392 // Enable virtual width
4393 SetInternalFlag(wxPG_FL_HAS_VIRTUAL_WIDTH
);
4395 m_pState
->SetVirtualWidth( width
);
4398 void wxPropertyGrid::SetFocusOnCanvas()
4400 m_canvas
->SetFocusIgnoringChildren();
4401 m_editorFocused
= 0;
4404 // -----------------------------------------------------------------------
4405 // wxPropertyGrid mouse event handling
4406 // -----------------------------------------------------------------------
4408 // selFlags uses same values DoSelectProperty's flags
4409 // Returns true if event was vetoed.
4410 bool wxPropertyGrid::SendEvent( int eventType
, wxPGProperty
* p
,
4412 unsigned int selFlags
,
4413 unsigned int column
)
4415 // Send property grid event of specific type and with specific property
4416 wxPropertyGridEvent
evt( eventType
, m_eventObject
->GetId() );
4417 evt
.SetPropertyGrid(this);
4418 evt
.SetEventObject(m_eventObject
);
4420 evt
.SetColumn(column
);
4421 if ( eventType
== wxEVT_PG_CHANGING
)
4424 evt
.SetCanVeto(true);
4425 m_validationInfo
.m_pValue
= pValue
;
4426 evt
.SetupValidationInfo();
4431 evt
.SetPropertyValue(p
->GetValue());
4433 if ( !(selFlags
& wxPG_SEL_NOVALIDATE
) )
4434 evt
.SetCanVeto(true);
4437 m_processedEvent
= &evt
;
4438 m_eventObject
->HandleWindowEvent(evt
);
4439 m_processedEvent
= NULL
;
4441 return evt
.WasVetoed();
4444 // -----------------------------------------------------------------------
4446 // Return false if should be skipped
4447 bool wxPropertyGrid::HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
)
4451 // Need to set focus?
4452 if ( !(m_iFlags
& wxPG_FL_FOCUSED
) )
4457 wxPropertyGridPageState
* state
= m_pState
;
4459 int splitterHitOffset
;
4460 int columnHit
= state
->HitTestH( x
, &splitterHit
, &splitterHitOffset
);
4462 wxPGProperty
* p
= DoGetItemAtY(y
);
4466 int depth
= (int)p
->GetDepth() - 1;
4468 int marginEnds
= m_marginWidth
+ ( depth
* m_subgroup_extramargin
);
4470 if ( x
>= marginEnds
)
4474 if ( p
->IsCategory() )
4476 // This is category.
4477 wxPropertyCategory
* pwc
= (wxPropertyCategory
*)p
;
4479 int textX
= m_marginWidth
+ ((unsigned int)((pwc
->m_depth
-1)*m_subgroup_extramargin
));
4481 // Expand, collapse, activate etc. if click on text or left of splitter.
4484 ( x
< (textX
+pwc
->GetTextExtent(this, m_captionFont
)+(wxPG_CAPRECTXMARGIN
*2)) ||
4489 if ( !AddToSelectionFromInputEvent( p
,
4494 // On double-click, expand/collapse.
4495 if ( event
.ButtonDClick() && !(m_windowStyle
& wxPG_HIDE_MARGIN
) )
4497 if ( pwc
->IsExpanded() ) DoCollapse( p
, true );
4498 else DoExpand( p
, true );
4502 else if ( splitterHit
== -1 )
4505 unsigned int selFlag
= 0;
4506 if ( columnHit
== 1 )
4508 m_iFlags
|= wxPG_FL_ACTIVATION_BY_CLICK
;
4509 selFlag
= wxPG_SEL_FOCUS
;
4511 if ( !AddToSelectionFromInputEvent( p
,
4517 m_iFlags
&= ~(wxPG_FL_ACTIVATION_BY_CLICK
);
4519 if ( p
->GetChildCount() && !p
->IsCategory() )
4520 // On double-click, expand/collapse.
4521 if ( event
.ButtonDClick() && !(m_windowStyle
& wxPG_HIDE_MARGIN
) )
4523 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
4524 if ( pwc
->IsExpanded() ) DoCollapse( p
, true );
4525 else DoExpand( p
, true );
4532 // click on splitter
4533 if ( !(m_windowStyle
& wxPG_STATIC_SPLITTER
) )
4535 if ( event
.GetEventType() == wxEVT_LEFT_DCLICK
)
4537 // Double-clicking the splitter causes auto-centering
4538 CenterSplitter( true );
4540 else if ( m_dragStatus
== 0 )
4543 // Begin draggin the splitter
4547 DoEndLabelEdit(true, wxPG_SEL_NOVALIDATE
);
4551 // Changes must be committed here or the
4552 // value won't be drawn correctly
4553 if ( !CommitChangesFromEditor() )
4556 m_wndEditor
->Show ( false );
4559 if ( !(m_iFlags
& wxPG_FL_MOUSE_CAPTURED
) )
4561 m_canvas
->CaptureMouse();
4562 m_iFlags
|= wxPG_FL_MOUSE_CAPTURED
;
4566 m_draggedSplitter
= splitterHit
;
4567 m_dragOffset
= splitterHitOffset
;
4569 wxClientDC
dc(m_canvas
);
4571 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
4572 // Fixes button disappearance bug
4574 m_wndEditor2
->Show ( false );
4577 m_startingSplitterX
= x
- splitterHitOffset
;
4585 if ( p
->GetChildCount() )
4587 int nx
= x
+ m_marginWidth
- marginEnds
; // Normalize x.
4589 if ( (nx
>= m_gutterWidth
&& nx
< (m_gutterWidth
+m_iconWidth
)) )
4591 int y2
= y
% m_lineHeight
;
4592 if ( (y2
>= m_buttonSpacingY
&& y2
< (m_buttonSpacingY
+m_iconHeight
)) )
4594 // On click on expander button, expand/collapse
4595 if ( ((wxPGProperty
*)p
)->IsExpanded() )
4596 DoCollapse( p
, true );
4598 DoExpand( p
, true );
4607 // -----------------------------------------------------------------------
4609 bool wxPropertyGrid::HandleMouseRightClick( int WXUNUSED(x
),
4610 unsigned int WXUNUSED(y
),
4611 wxMouseEvent
& event
)
4615 // Select property here as well
4616 wxPGProperty
* p
= m_propHover
;
4617 AddToSelectionFromInputEvent(p
, m_colHover
, &event
);
4619 // Send right click event.
4620 SendEvent( wxEVT_PG_RIGHT_CLICK
, p
);
4627 // -----------------------------------------------------------------------
4629 bool wxPropertyGrid::HandleMouseDoubleClick( int WXUNUSED(x
),
4630 unsigned int WXUNUSED(y
),
4631 wxMouseEvent
& event
)
4635 // Select property here as well
4636 wxPGProperty
* p
= m_propHover
;
4638 AddToSelectionFromInputEvent(p
, m_colHover
, &event
);
4640 // Send double-click event.
4641 SendEvent( wxEVT_PG_DOUBLE_CLICK
, m_propHover
);
4648 // -----------------------------------------------------------------------
4650 #if wxPG_SUPPORT_TOOLTIPS
4652 void wxPropertyGrid::SetToolTip( const wxString
& tipString
)
4654 if ( tipString
.length() )
4656 m_canvas
->SetToolTip(tipString
);
4660 #if wxPG_ALLOW_EMPTY_TOOLTIPS
4661 m_canvas
->SetToolTip( m_emptyString
);
4663 m_canvas
->SetToolTip( NULL
);
4668 #endif // #if wxPG_SUPPORT_TOOLTIPS
4670 // -----------------------------------------------------------------------
4672 // Return false if should be skipped
4673 bool wxPropertyGrid::HandleMouseMove( int x
, unsigned int y
, wxMouseEvent
&event
)
4675 // Safety check (needed because mouse capturing may
4676 // otherwise freeze the control)
4677 if ( m_dragStatus
> 0 && !event
.Dragging() )
4679 HandleMouseUp(x
,y
,event
);
4682 wxPropertyGridPageState
* state
= m_pState
;
4684 int splitterHitOffset
;
4685 int columnHit
= state
->HitTestH( x
, &splitterHit
, &splitterHitOffset
);
4686 int splitterX
= x
- splitterHitOffset
;
4688 m_colHover
= columnHit
;
4690 if ( m_dragStatus
> 0 )
4692 if ( x
> (m_marginWidth
+ wxPG_DRAG_MARGIN
) &&
4693 x
< (m_pState
->m_width
- wxPG_DRAG_MARGIN
) )
4696 int newSplitterX
= x
- m_dragOffset
;
4697 int splitterX
= x
- splitterHitOffset
;
4699 // Splitter redraw required?
4700 if ( newSplitterX
!= splitterX
)
4703 SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
4704 state
->DoSetSplitterPosition( newSplitterX
, m_draggedSplitter
, false );
4705 state
->m_fSplitterX
= (float) newSplitterX
;
4707 if ( GetSelection() )
4708 CorrectEditorWidgetSizeX();
4722 int ih
= m_lineHeight
;
4725 #if wxPG_SUPPORT_TOOLTIPS
4726 wxPGProperty
* prevHover
= m_propHover
;
4727 unsigned char prevSide
= m_mouseSide
;
4729 int curPropHoverY
= y
- (y
% ih
);
4731 // On which item it hovers
4734 ( sy
< m_propHoverY
|| sy
>= (m_propHoverY
+ih
) )
4737 // Mouse moves on another property
4739 m_propHover
= DoGetItemAtY(y
);
4740 m_propHoverY
= curPropHoverY
;
4743 SendEvent( wxEVT_PG_HIGHLIGHTED
, m_propHover
);
4746 #if wxPG_SUPPORT_TOOLTIPS
4747 // Store which side we are on
4749 if ( columnHit
== 1 )
4751 else if ( columnHit
== 0 )
4755 // If tooltips are enabled, show label or value as a tip
4756 // in case it doesn't otherwise show in full length.
4758 if ( m_windowStyle
& wxPG_TOOLTIPS
)
4760 wxToolTip
* tooltip
= m_canvas
->GetToolTip();
4762 if ( m_propHover
!= prevHover
|| prevSide
!= m_mouseSide
)
4764 if ( m_propHover
&& !m_propHover
->IsCategory() )
4767 if ( GetExtraStyle() & wxPG_EX_HELP_AS_TOOLTIPS
)
4769 // Show help string as a tooltip
4770 wxString tipString
= m_propHover
->GetHelpString();
4772 SetToolTip(tipString
);
4776 // Show cropped value string as a tooltip
4780 if ( m_mouseSide
== 1 )
4782 tipString
= m_propHover
->m_label
;
4783 space
= splitterX
-m_marginWidth
-3;
4785 else if ( m_mouseSide
== 2 )
4787 tipString
= m_propHover
->GetDisplayedString();
4789 space
= m_width
- splitterX
;
4790 if ( m_propHover
->m_flags
& wxPG_PROP_CUSTOMIMAGE
)
4791 space
-= wxPG_CUSTOM_IMAGE_WIDTH
+ wxCC_CUSTOM_IMAGE_MARGIN1
+ wxCC_CUSTOM_IMAGE_MARGIN2
;
4797 GetTextExtent( tipString
, &tw
, &th
, 0, 0 );
4800 SetToolTip( tipString
);
4807 #if wxPG_ALLOW_EMPTY_TOOLTIPS
4808 m_canvas
->SetToolTip( m_emptyString
);
4810 m_canvas
->SetToolTip( NULL
);
4821 #if wxPG_ALLOW_EMPTY_TOOLTIPS
4822 m_canvas
->SetToolTip( m_emptyString
);
4824 m_canvas
->SetToolTip( NULL
);
4832 if ( splitterHit
== -1 ||
4834 HasFlag(wxPG_STATIC_SPLITTER
) )
4836 // hovering on something else
4837 if ( m_curcursor
!= wxCURSOR_ARROW
)
4838 CustomSetCursor( wxCURSOR_ARROW
);
4842 // Do not allow splitter cursor on caption items.
4843 // (also not if we were dragging and its started
4844 // outside the splitter region)
4846 if ( !m_propHover
->IsCategory() &&
4850 // hovering on splitter
4852 // NB: Condition disabled since MouseLeave event (from the editor control) cannot be
4853 // reliably detected.
4854 //if ( m_curcursor != wxCURSOR_SIZEWE )
4855 CustomSetCursor( wxCURSOR_SIZEWE
, true );
4861 // hovering on something else
4862 if ( m_curcursor
!= wxCURSOR_ARROW
)
4863 CustomSetCursor( wxCURSOR_ARROW
);
4868 // Multi select by dragging
4870 if ( (GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION
) &&
4871 event
.LeftIsDown() &&
4875 !state
->DoIsPropertySelected(m_propHover
) )
4877 // Additional requirement is that the hovered property
4878 // is adjacent to edges of selection.
4879 const wxArrayPGProperty
& selection
= GetSelectedProperties();
4881 // Since categories cannot be selected along with 'other'
4882 // properties, exclude them from iterator flags.
4883 int iterFlags
= wxPG_ITERATE_VISIBLE
& (~wxPG_PROP_CATEGORY
);
4885 for ( int i
=(selection
.size()-1); i
>=0; i
-- )
4887 // TODO: This could be optimized by keeping track of
4888 // which properties are at the edges of selection.
4889 wxPGProperty
* selProp
= selection
[i
];
4890 if ( state
->ArePropertiesAdjacent(m_propHover
, selProp
,
4893 DoAddToSelection(m_propHover
);
4902 // -----------------------------------------------------------------------
4904 // Also handles Leaving event
4905 bool wxPropertyGrid::HandleMouseUp( int x
, unsigned int WXUNUSED(y
),
4906 wxMouseEvent
&WXUNUSED(event
) )
4908 wxPropertyGridPageState
* state
= m_pState
;
4912 int splitterHitOffset
;
4913 state
->HitTestH( x
, &splitterHit
, &splitterHitOffset
);
4915 // No event type check - basicly calling this method should
4916 // just stop dragging.
4917 // Left up after dragged?
4918 if ( m_dragStatus
>= 1 )
4921 // End Splitter Dragging
4923 // DO NOT ENABLE FOLLOWING LINE!
4924 // (it is only here as a reminder to not to do it)
4927 // Disable splitter auto-centering
4928 m_iFlags
|= wxPG_FL_DONT_CENTER_SPLITTER
;
4930 // This is necessary to return cursor
4931 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
4933 m_canvas
->ReleaseMouse();
4934 m_iFlags
&= ~(wxPG_FL_MOUSE_CAPTURED
);
4937 // Set back the default cursor, if necessary
4938 if ( splitterHit
== -1 ||
4941 CustomSetCursor( wxCURSOR_ARROW
);
4946 // Control background needs to be cleared
4947 wxPGProperty
* selected
= GetSelection();
4948 if ( !(m_iFlags
& wxPG_FL_PRIMARY_FILLS_ENTIRE
) && selected
)
4949 DrawItem( selected
);
4953 m_wndEditor
->Show ( true );
4956 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
4957 // Fixes button disappearance bug
4959 m_wndEditor2
->Show ( true );
4962 // This clears the focus.
4963 m_editorFocused
= 0;
4969 // -----------------------------------------------------------------------
4971 bool wxPropertyGrid::OnMouseCommon( wxMouseEvent
& event
, int* px
, int* py
)
4973 int splitterX
= GetSplitterPosition();
4976 //CalcUnscrolledPosition( event.m_x, event.m_y, &ux, &uy );
4980 wxWindow
* wnd
= GetEditorControl();
4982 // Hide popup on clicks
4983 if ( event
.GetEventType() != wxEVT_MOTION
)
4984 if ( wnd
&& wnd
->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox
)) )
4986 ((wxOwnerDrawnComboBox
*)wnd
)->HidePopup();
4992 if ( wnd
== NULL
|| m_dragStatus
||
4994 ux
<= (splitterX
+ wxPG_SPLITTERX_DETECTMARGIN2
) ||
4995 ux
>= (r
.x
+r
.width
) ||
4997 event
.m_y
>= (r
.y
+r
.height
)
5007 if ( m_curcursor
!= wxCURSOR_ARROW
) CustomSetCursor ( wxCURSOR_ARROW
);
5012 // -----------------------------------------------------------------------
5014 void wxPropertyGrid::OnMouseClick( wxMouseEvent
&event
)
5017 if ( OnMouseCommon( event
, &x
, &y
) )
5019 HandleMouseClick(x
,y
,event
);
5024 // -----------------------------------------------------------------------
5026 void wxPropertyGrid::OnMouseRightClick( wxMouseEvent
&event
)
5029 CalcUnscrolledPosition( event
.m_x
, event
.m_y
, &x
, &y
);
5030 HandleMouseRightClick(x
,y
,event
);
5034 // -----------------------------------------------------------------------
5036 void wxPropertyGrid::OnMouseDoubleClick( wxMouseEvent
&event
)
5038 // Always run standard mouse-down handler as well
5039 OnMouseClick(event
);
5042 CalcUnscrolledPosition( event
.m_x
, event
.m_y
, &x
, &y
);
5043 HandleMouseDoubleClick(x
,y
,event
);
5047 // -----------------------------------------------------------------------
5049 void wxPropertyGrid::OnMouseMove( wxMouseEvent
&event
)
5052 if ( OnMouseCommon( event
, &x
, &y
) )
5054 HandleMouseMove(x
,y
,event
);
5059 // -----------------------------------------------------------------------
5061 void wxPropertyGrid::OnMouseMoveBottom( wxMouseEvent
& WXUNUSED(event
) )
5063 // Called when mouse moves in the empty space below the properties.
5064 CustomSetCursor( wxCURSOR_ARROW
);
5067 // -----------------------------------------------------------------------
5069 void wxPropertyGrid::OnMouseUp( wxMouseEvent
&event
)
5072 if ( OnMouseCommon( event
, &x
, &y
) )
5074 HandleMouseUp(x
,y
,event
);
5079 // -----------------------------------------------------------------------
5081 void wxPropertyGrid::OnMouseEntry( wxMouseEvent
&event
)
5083 // This may get called from child control as well, so event's
5084 // mouse position cannot be relied on.
5086 if ( event
.Entering() )
5088 if ( !(m_iFlags
& wxPG_FL_MOUSE_INSIDE
) )
5090 // TODO: Fix this (detect parent and only do
5091 // cursor trick if it is a manager).
5092 wxASSERT( GetParent() );
5093 GetParent()->SetCursor(wxNullCursor
);
5095 m_iFlags
|= wxPG_FL_MOUSE_INSIDE
;
5098 GetParent()->SetCursor(wxNullCursor
);
5100 else if ( event
.Leaving() )
5102 // Without this, wxSpinCtrl editor will sometimes have wrong cursor
5103 m_canvas
->SetCursor( wxNullCursor
);
5105 // Get real cursor position
5106 wxPoint pt
= ScreenToClient(::wxGetMousePosition());
5108 if ( ( pt
.x
<= 0 || pt
.y
<= 0 || pt
.x
>= m_width
|| pt
.y
>= m_height
) )
5111 if ( (m_iFlags
& wxPG_FL_MOUSE_INSIDE
) )
5113 m_iFlags
&= ~(wxPG_FL_MOUSE_INSIDE
);
5117 wxPropertyGrid::HandleMouseUp ( -1, 10000, event
);
5125 // -----------------------------------------------------------------------
5127 // Common code used by various OnMouseXXXChild methods.
5128 bool wxPropertyGrid::OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
)
5130 wxWindow
* topCtrlWnd
= (wxWindow
*)event
.GetEventObject();
5131 wxASSERT( topCtrlWnd
);
5133 event
.GetPosition(&x
,&y
);
5135 int splitterX
= GetSplitterPosition();
5137 wxRect r
= topCtrlWnd
->GetRect();
5138 if ( !m_dragStatus
&&
5139 x
> (splitterX
-r
.x
+wxPG_SPLITTERX_DETECTMARGIN2
) &&
5140 y
>= 0 && y
< r
.height \
5143 if ( m_curcursor
!= wxCURSOR_ARROW
) CustomSetCursor ( wxCURSOR_ARROW
);
5148 CalcUnscrolledPosition( event
.m_x
+ r
.x
, event
.m_y
+ r
.y
, \
5155 void wxPropertyGrid::OnMouseClickChild( wxMouseEvent
&event
)
5158 if ( OnMouseChildCommon(event
,&x
,&y
) )
5160 bool res
= HandleMouseClick(x
,y
,event
);
5161 if ( !res
) event
.Skip();
5165 void wxPropertyGrid::OnMouseRightClickChild( wxMouseEvent
&event
)
5168 wxASSERT( m_wndEditor
);
5169 // These coords may not be exact (about +-2),
5170 // but that should not matter (right click is about item, not position).
5171 wxPoint pt
= m_wndEditor
->GetPosition();
5172 CalcUnscrolledPosition( event
.m_x
+ pt
.x
, event
.m_y
+ pt
.y
, &x
, &y
);
5174 // FIXME: Used to set m_propHover to selection here. Was it really
5177 bool res
= HandleMouseRightClick(x
,y
,event
);
5178 if ( !res
) event
.Skip();
5181 void wxPropertyGrid::OnMouseMoveChild( wxMouseEvent
&event
)
5184 if ( OnMouseChildCommon(event
,&x
,&y
) )
5186 bool res
= HandleMouseMove(x
,y
,event
);
5187 if ( !res
) event
.Skip();
5191 void wxPropertyGrid::OnMouseUpChild( wxMouseEvent
&event
)
5194 if ( OnMouseChildCommon(event
,&x
,&y
) )
5196 bool res
= HandleMouseUp(x
,y
,event
);
5197 if ( !res
) event
.Skip();
5201 // -----------------------------------------------------------------------
5202 // wxPropertyGrid keyboard event handling
5203 // -----------------------------------------------------------------------
5205 int wxPropertyGrid::KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const
5207 // Translates wxKeyEvent to wxPG_ACTION_XXX
5209 int keycode
= event
.GetKeyCode();
5210 int modifiers
= event
.GetModifiers();
5212 wxASSERT( !(modifiers
&~(0xFFFF)) );
5214 int hashMapKey
= (keycode
& 0xFFFF) | ((modifiers
& 0xFFFF) << 16);
5216 wxPGHashMapI2I::const_iterator it
= m_actionTriggers
.find(hashMapKey
);
5218 if ( it
== m_actionTriggers
.end() )
5223 int second
= (it
->second
>>16) & 0xFFFF;
5227 return (it
->second
& 0xFFFF);
5230 void wxPropertyGrid::AddActionTrigger( int action
, int keycode
, int modifiers
)
5232 wxASSERT( !(modifiers
&~(0xFFFF)) );
5234 int hashMapKey
= (keycode
& 0xFFFF) | ((modifiers
& 0xFFFF) << 16);
5236 wxPGHashMapI2I::iterator it
= m_actionTriggers
.find(hashMapKey
);
5238 if ( it
!= m_actionTriggers
.end() )
5240 // This key combination is already used
5242 // Can add secondary?
5243 wxASSERT_MSG( !(it
->second
&~(0xFFFF)),
5244 wxT("You can only add up to two separate actions per key combination.") );
5246 action
= it
->second
| (action
<<16);
5249 m_actionTriggers
[hashMapKey
] = action
;
5252 void wxPropertyGrid::ClearActionTriggers( int action
)
5254 wxPGHashMapI2I::iterator it
;
5259 didSomething
= false;
5261 for ( it
= m_actionTriggers
.begin();
5262 it
!= m_actionTriggers
.end();
5265 if ( it
->second
== action
)
5267 m_actionTriggers
.erase(it
);
5268 didSomething
= true;
5273 while ( didSomething
);
5276 void wxPropertyGrid::HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
)
5279 // Handles key event when editor control is not focused.
5282 wxCHECK2(!m_frozen
, return);
5284 // Travelsal between items, collapsing/expanding, etc.
5285 wxPGProperty
* selected
= GetSelection();
5286 int keycode
= event
.GetKeyCode();
5287 bool editorFocused
= IsEditorFocused();
5289 if ( keycode
== WXK_TAB
)
5291 wxWindow
* mainControl
;
5293 if ( HasInternalFlag(wxPG_FL_IN_MANAGER
) )
5294 mainControl
= GetParent();
5298 if ( !event
.ShiftDown() )
5300 if ( !editorFocused
&& m_wndEditor
)
5302 DoSelectProperty( selected
, wxPG_SEL_FOCUS
);
5306 // Tab traversal workaround for platforms on which
5307 // wxWindow::Navigate() may navigate into first child
5308 // instead of next sibling. Does not work perfectly
5309 // in every scenario (for instance, when property grid
5310 // is either first or last control).
5311 #if defined(__WXGTK__)
5312 wxWindow
* sibling
= mainControl
->GetNextSibling();
5314 sibling
->SetFocusFromKbd();
5316 Navigate(wxNavigationKeyEvent::IsForward
);
5322 if ( editorFocused
)
5328 #if defined(__WXGTK__)
5329 wxWindow
* sibling
= mainControl
->GetPrevSibling();
5331 sibling
->SetFocusFromKbd();
5333 Navigate(wxNavigationKeyEvent::IsBackward
);
5341 // Ignore Alt and Control when they are down alone
5342 if ( keycode
== WXK_ALT
||
5343 keycode
== WXK_CONTROL
)
5350 int action
= KeyEventToActions(event
, &secondAction
);
5352 if ( editorFocused
&& action
== wxPG_ACTION_CANCEL_EDIT
)
5355 // Esc cancels any changes
5356 if ( IsEditorsValueModified() )
5358 EditorsValueWasNotModified();
5360 // Update the control as well
5361 selected
->GetEditorClass()->
5362 SetControlStringValue( selected
,
5364 selected
->GetDisplayedString() );
5367 OnValidationFailureReset(selected
);
5373 // Except for TAB and ESC, handle child control events in child control
5376 // Only propagate event if it had modifiers
5377 if ( !event
.HasModifiers() )
5379 event
.StopPropagation();
5385 bool wasHandled
= false;
5390 if ( ButtonTriggerKeyTest(action
, event
) )
5393 wxPGProperty
* p
= selected
;
5395 // Travel and expand/collapse
5398 if ( p
->GetChildCount() )
5400 if ( action
== wxPG_ACTION_COLLAPSE_PROPERTY
|| secondAction
== wxPG_ACTION_COLLAPSE_PROPERTY
)
5402 if ( (m_windowStyle
& wxPG_HIDE_MARGIN
) || Collapse(p
) )
5405 else if ( action
== wxPG_ACTION_EXPAND_PROPERTY
|| secondAction
== wxPG_ACTION_EXPAND_PROPERTY
)
5407 if ( (m_windowStyle
& wxPG_HIDE_MARGIN
) || Expand(p
) )
5414 if ( action
== wxPG_ACTION_PREV_PROPERTY
|| secondAction
== wxPG_ACTION_PREV_PROPERTY
)
5418 else if ( action
== wxPG_ACTION_NEXT_PROPERTY
|| secondAction
== wxPG_ACTION_NEXT_PROPERTY
)
5424 if ( selectDir
>= -1 )
5426 p
= wxPropertyGridIterator::OneStep( m_pState
, wxPG_ITERATE_VISIBLE
, p
, selectDir
);
5428 DoSelectProperty(p
);
5434 // If nothing was selected, select the first item now
5435 // (or navigate out of tab).
5436 if ( action
!= wxPG_ACTION_CANCEL_EDIT
&& secondAction
!= wxPG_ACTION_CANCEL_EDIT
)
5438 wxPGProperty
* p
= wxPropertyGridInterface::GetFirst();
5439 if ( p
) DoSelectProperty(p
);
5448 // -----------------------------------------------------------------------
5450 void wxPropertyGrid::OnKey( wxKeyEvent
&event
)
5452 // If there was editor open and focused, then this event should not
5453 // really be processed here.
5454 if ( IsEditorFocused() )
5456 // However, if event had modifiers, it is probably still best
5458 if ( event
.HasModifiers() )
5461 event
.StopPropagation();
5465 HandleKeyEvent(event
, false);
5468 // -----------------------------------------------------------------------
5470 bool wxPropertyGrid::ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
)
5475 action
= KeyEventToActions(event
, &secondAction
);
5478 // Does the keycode trigger button?
5479 if ( action
== wxPG_ACTION_PRESS_BUTTON
&&
5482 wxCommandEvent
evt(wxEVT_COMMAND_BUTTON_CLICKED
, m_wndEditor2
->GetId());
5483 GetEventHandler()->AddPendingEvent(evt
);
5490 // -----------------------------------------------------------------------
5492 void wxPropertyGrid::OnChildKeyDown( wxKeyEvent
&event
)
5494 HandleKeyEvent(event
, true);
5497 // -----------------------------------------------------------------------
5498 // wxPropertyGrid miscellaneous event handling
5499 // -----------------------------------------------------------------------
5501 void wxPropertyGrid::OnIdle( wxIdleEvent
& WXUNUSED(event
) )
5504 // Check if the focus is in this control or one of its children
5505 wxWindow
* newFocused
= wxWindow::FindFocus();
5507 if ( newFocused
!= m_curFocused
)
5508 HandleFocusChange( newFocused
);
5511 // Check if top-level parent has changed
5512 if ( GetExtraStyle() & wxPG_EX_ENABLE_TLP_TRACKING
)
5514 wxWindow
* tlp
= ::wxGetTopLevelParent(this);
5520 bool wxPropertyGrid::IsEditorFocused() const
5522 wxWindow
* focus
= wxWindow::FindFocus();
5524 if ( focus
== m_wndEditor
|| focus
== m_wndEditor2
||
5525 focus
== GetEditorControl() )
5531 // Called by focus event handlers. newFocused is the window that becomes focused.
5532 void wxPropertyGrid::HandleFocusChange( wxWindow
* newFocused
)
5534 unsigned int oldFlags
= m_iFlags
;
5536 m_iFlags
&= ~(wxPG_FL_FOCUSED
);
5538 wxWindow
* parent
= newFocused
;
5540 // This must be one of nextFocus' parents.
5543 // Use m_eventObject, which is either wxPropertyGrid or
5544 // wxPropertyGridManager, as appropriate.
5545 if ( parent
== m_eventObject
)
5547 m_iFlags
|= wxPG_FL_FOCUSED
;
5550 parent
= parent
->GetParent();
5553 m_curFocused
= newFocused
;
5555 if ( (m_iFlags
& wxPG_FL_FOCUSED
) !=
5556 (oldFlags
& wxPG_FL_FOCUSED
) )
5558 if ( !(m_iFlags
& wxPG_FL_FOCUSED
) )
5560 // Need to store changed value
5561 CommitChangesFromEditor();
5567 // Preliminary code for tab-order respecting
5568 // tab-traversal (but should be moved to
5571 wxWindow* prevFocus = event.GetWindow();
5572 wxWindow* useThis = this;
5573 if ( m_iFlags & wxPG_FL_IN_MANAGER )
5574 useThis = GetParent();
5577 prevFocus->GetParent() == useThis->GetParent() )
5579 wxList& children = useThis->GetParent()->GetChildren();
5581 wxNode* node = children.Find(prevFocus);
5583 if ( node->GetNext() &&
5584 useThis == node->GetNext()->GetData() )
5585 DoSelectProperty(GetFirst());
5586 else if ( node->GetPrevious () &&
5587 useThis == node->GetPrevious()->GetData() )
5588 DoSelectProperty(GetLastProperty());
5595 wxPGProperty
* selected
= GetSelection();
5596 if ( selected
&& (m_iFlags
& wxPG_FL_INITIALIZED
) )
5597 DrawItem( selected
);
5601 void wxPropertyGrid::OnFocusEvent( wxFocusEvent
& event
)
5603 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
5604 HandleFocusChange((wxWindow
*)event
.GetEventObject());
5605 // Line changed to "else" when applying wxPropertyGrid patch #1675902
5606 //else if ( event.GetWindow() )
5608 HandleFocusChange(event
.GetWindow());
5613 // -----------------------------------------------------------------------
5615 void wxPropertyGrid::OnChildFocusEvent( wxChildFocusEvent
& event
)
5617 HandleFocusChange((wxWindow
*)event
.GetEventObject());
5621 // -----------------------------------------------------------------------
5623 void wxPropertyGrid::OnScrollEvent( wxScrollWinEvent
&event
)
5625 m_iFlags
|= wxPG_FL_SCROLLED
;
5630 // -----------------------------------------------------------------------
5632 void wxPropertyGrid::OnCaptureChange( wxMouseCaptureChangedEvent
& WXUNUSED(event
) )
5634 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
5636 m_iFlags
&= ~(wxPG_FL_MOUSE_CAPTURED
);
5640 // -----------------------------------------------------------------------
5641 // Property editor related functions
5642 // -----------------------------------------------------------------------
5644 // noDefCheck = true prevents infinite recursion.
5645 wxPGEditor
* wxPropertyGrid::DoRegisterEditorClass( wxPGEditor
* editorClass
,
5646 const wxString
& editorName
,
5649 wxASSERT( editorClass
);
5651 if ( !noDefCheck
&& wxPGGlobalVars
->m_mapEditorClasses
.empty() )
5652 RegisterDefaultEditors();
5654 wxString name
= editorName
;
5655 if ( name
.length() == 0 )
5656 name
= editorClass
->GetName();
5658 // Existing editor under this name?
5659 wxPGHashMapS2P::iterator vt_it
= wxPGGlobalVars
->m_mapEditorClasses
.find(name
);
5661 if ( vt_it
!= wxPGGlobalVars
->m_mapEditorClasses
.end() )
5663 // If this name was already used, try class name.
5664 name
= editorClass
->GetClassInfo()->GetClassName();
5665 vt_it
= wxPGGlobalVars
->m_mapEditorClasses
.find(name
);
5668 wxCHECK_MSG( vt_it
== wxPGGlobalVars
->m_mapEditorClasses
.end(),
5669 (wxPGEditor
*) vt_it
->second
,
5670 "Editor with given name was already registered" );
5672 wxPGGlobalVars
->m_mapEditorClasses
[name
] = (void*)editorClass
;
5677 // Use this in RegisterDefaultEditors.
5678 #define wxPGRegisterDefaultEditorClass(EDITOR) \
5679 if ( wxPGEditor_##EDITOR == NULL ) \
5681 wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \
5682 new wxPG##EDITOR##Editor, true ); \
5685 // Registers all default editor classes
5686 void wxPropertyGrid::RegisterDefaultEditors()
5688 wxPGRegisterDefaultEditorClass( TextCtrl
);
5689 wxPGRegisterDefaultEditorClass( Choice
);
5690 wxPGRegisterDefaultEditorClass( ComboBox
);
5691 wxPGRegisterDefaultEditorClass( TextCtrlAndButton
);
5692 #if wxPG_INCLUDE_CHECKBOX
5693 wxPGRegisterDefaultEditorClass( CheckBox
);
5695 wxPGRegisterDefaultEditorClass( ChoiceAndButton
);
5697 // Register SpinCtrl etc. editors before use
5698 RegisterAdditionalEditors();
5701 // -----------------------------------------------------------------------
5702 // wxPGStringTokenizer
5703 // Needed to handle C-style string lists (e.g. "str1" "str2")
5704 // -----------------------------------------------------------------------
5706 wxPGStringTokenizer::wxPGStringTokenizer( const wxString
& str
, wxChar delimeter
)
5707 : m_str(&str
), m_curPos(str
.begin()), m_delimeter(delimeter
)
5711 wxPGStringTokenizer::~wxPGStringTokenizer()
5715 bool wxPGStringTokenizer::HasMoreTokens()
5717 const wxString
& str
= *m_str
;
5719 wxString::const_iterator i
= m_curPos
;
5721 wxUniChar delim
= m_delimeter
;
5723 wxUniChar prev_a
= wxT('\0');
5725 bool inToken
= false;
5727 while ( i
!= str
.end() )
5736 m_readyToken
.clear();
5741 if ( prev_a
!= wxT('\\') )
5745 if ( a
!= wxT('\\') )
5765 m_curPos
= str
.end();
5773 wxString
wxPGStringTokenizer::GetNextToken()
5775 return m_readyToken
;
5778 // -----------------------------------------------------------------------
5780 // -----------------------------------------------------------------------
5782 wxPGChoiceEntry::wxPGChoiceEntry()
5783 : wxPGCell(), m_value(wxPG_INVALID_VALUE
)
5787 // -----------------------------------------------------------------------
5789 // -----------------------------------------------------------------------
5791 wxPGChoicesData::wxPGChoicesData()
5795 wxPGChoicesData::~wxPGChoicesData()
5800 void wxPGChoicesData::Clear()
5805 void wxPGChoicesData::CopyDataFrom( wxPGChoicesData
* data
)
5807 wxASSERT( m_items
.size() == 0 );
5809 m_items
= data
->m_items
;
5812 wxPGChoiceEntry
& wxPGChoicesData::Insert( int index
,
5813 const wxPGChoiceEntry
& item
)
5815 wxVector
<wxPGChoiceEntry
>::iterator it
;
5819 index
= (int) m_items
.size();
5823 it
= m_items
.begin() + index
;
5826 m_items
.insert(it
, item
);
5828 wxPGChoiceEntry
& ownEntry
= m_items
[index
];
5830 // Need to fix value?
5831 if ( ownEntry
.GetValue() == wxPG_INVALID_VALUE
)
5832 ownEntry
.SetValue(index
);
5837 // -----------------------------------------------------------------------
5838 // wxPropertyGridEvent
5839 // -----------------------------------------------------------------------
5841 IMPLEMENT_DYNAMIC_CLASS(wxPropertyGridEvent
, wxCommandEvent
)
5844 wxDEFINE_EVENT( wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
5845 wxDEFINE_EVENT( wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
5846 wxDEFINE_EVENT( wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
5847 wxDEFINE_EVENT( wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
5848 wxDEFINE_EVENT( wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
5849 wxDEFINE_EVENT( wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
5850 wxDEFINE_EVENT( wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
5851 wxDEFINE_EVENT( wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
5852 wxDEFINE_EVENT( wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
5853 wxDEFINE_EVENT( wxEVT_PG_LABEL_EDIT_BEGIN
, wxPropertyGridEvent
);
5854 wxDEFINE_EVENT( wxEVT_PG_LABEL_EDIT_ENDING
, wxPropertyGridEvent
);
5856 // -----------------------------------------------------------------------
5858 void wxPropertyGridEvent::Init()
5860 m_validationInfo
= NULL
;
5863 m_wasVetoed
= false;
5866 // -----------------------------------------------------------------------
5868 wxPropertyGridEvent::wxPropertyGridEvent(wxEventType commandType
, int id
)
5869 : wxCommandEvent(commandType
,id
)
5875 // -----------------------------------------------------------------------
5877 wxPropertyGridEvent::wxPropertyGridEvent(const wxPropertyGridEvent
& event
)
5878 : wxCommandEvent(event
)
5880 m_eventType
= event
.GetEventType();
5881 m_eventObject
= event
.m_eventObject
;
5883 OnPropertyGridSet();
5884 m_property
= event
.m_property
;
5885 m_validationInfo
= event
.m_validationInfo
;
5886 m_canVeto
= event
.m_canVeto
;
5887 m_wasVetoed
= event
.m_wasVetoed
;
5890 // -----------------------------------------------------------------------
5892 void wxPropertyGridEvent::OnPropertyGridSet()
5898 wxCriticalSectionLocker(wxPGGlobalVars
->m_critSect
);
5900 m_pg
->m_liveEvents
.push_back(this);
5903 // -----------------------------------------------------------------------
5905 wxPropertyGridEvent::~wxPropertyGridEvent()
5910 wxCriticalSectionLocker(wxPGGlobalVars
->m_critSect
);
5913 // Use iterate from the back since it is more likely that the event
5914 // being desroyed is at the end of the array.
5915 wxVector
<wxPropertyGridEvent
*>& liveEvents
= m_pg
->m_liveEvents
;
5917 for ( int i
= liveEvents
.size()-1; i
>= 0; i
-- )
5919 if ( liveEvents
[i
] == this )
5921 liveEvents
.erase(liveEvents
.begin() + i
);
5928 // -----------------------------------------------------------------------
5930 wxEvent
* wxPropertyGridEvent::Clone() const
5932 return new wxPropertyGridEvent( *this );
5935 // -----------------------------------------------------------------------
5936 // wxPropertyGridPopulator
5937 // -----------------------------------------------------------------------
5939 wxPropertyGridPopulator::wxPropertyGridPopulator()
5943 wxPGGlobalVars
->m_offline
++;
5946 // -----------------------------------------------------------------------
5948 void wxPropertyGridPopulator::SetState( wxPropertyGridPageState
* state
)
5951 m_propHierarchy
.clear();
5954 // -----------------------------------------------------------------------
5956 void wxPropertyGridPopulator::SetGrid( wxPropertyGrid
* pg
)
5962 // -----------------------------------------------------------------------
5964 wxPropertyGridPopulator::~wxPropertyGridPopulator()
5967 // Free unused sets of choices
5968 wxPGHashMapS2P::iterator it
;
5970 for( it
= m_dictIdChoices
.begin(); it
!= m_dictIdChoices
.end(); ++it
)
5972 wxPGChoicesData
* data
= (wxPGChoicesData
*) it
->second
;
5979 m_pg
->GetPanel()->Refresh();
5981 wxPGGlobalVars
->m_offline
--;
5984 // -----------------------------------------------------------------------
5986 wxPGProperty
* wxPropertyGridPopulator::Add( const wxString
& propClass
,
5987 const wxString
& propLabel
,
5988 const wxString
& propName
,
5989 const wxString
* propValue
,
5990 wxPGChoices
* pChoices
)
5992 wxClassInfo
* classInfo
= wxClassInfo::FindClass(propClass
);
5993 wxPGProperty
* parent
= GetCurParent();
5995 if ( parent
->HasFlag(wxPG_PROP_AGGREGATE
) )
5997 ProcessError(wxString::Format(wxT("new children cannot be added to '%s'"),parent
->GetName().c_str()));
6001 if ( !classInfo
|| !classInfo
->IsKindOf(CLASSINFO(wxPGProperty
)) )
6003 ProcessError(wxString::Format(wxT("'%s' is not valid property class"),propClass
.c_str()));
6007 wxPGProperty
* property
= (wxPGProperty
*) classInfo
->CreateObject();
6009 property
->SetLabel(propLabel
);
6010 property
->DoSetName(propName
);
6012 if ( pChoices
&& pChoices
->IsOk() )
6013 property
->SetChoices(*pChoices
);
6015 m_state
->DoInsert(parent
, -1, property
);
6018 property
->SetValueFromString( *propValue
, wxPG_FULL_VALUE
|
6019 wxPG_PROGRAMMATIC_VALUE
);
6024 // -----------------------------------------------------------------------
6026 void wxPropertyGridPopulator::AddChildren( wxPGProperty
* property
)
6028 m_propHierarchy
.push_back(property
);
6029 DoScanForChildren();
6030 m_propHierarchy
.pop_back();
6033 // -----------------------------------------------------------------------
6035 wxPGChoices
wxPropertyGridPopulator::ParseChoices( const wxString
& choicesString
,
6036 const wxString
& idString
)
6038 wxPGChoices choices
;
6041 if ( choicesString
[0] == wxT('@') )
6043 wxString ids
= choicesString
.substr(1);
6044 wxPGHashMapS2P::iterator it
= m_dictIdChoices
.find(ids
);
6045 if ( it
== m_dictIdChoices
.end() )
6046 ProcessError(wxString::Format(wxT("No choices defined for id '%s'"),ids
.c_str()));
6048 choices
.AssignData((wxPGChoicesData
*)it
->second
);
6053 if ( idString
.length() )
6055 wxPGHashMapS2P::iterator it
= m_dictIdChoices
.find(idString
);
6056 if ( it
!= m_dictIdChoices
.end() )
6058 choices
.AssignData((wxPGChoicesData
*)it
->second
);
6065 // Parse choices string
6066 wxString::const_iterator it
= choicesString
.begin();
6070 bool labelValid
= false;
6072 for ( ; it
!= choicesString
.end(); ++it
)
6078 if ( c
== wxT('"') )
6083 if ( !value
.ToLong(&l
, 0) ) l
= wxPG_INVALID_VALUE
;
6084 choices
.Add(label
, l
);
6087 //wxLogDebug(wxT("%s, %s"),label.c_str(),value.c_str());
6092 else if ( c
== wxT('=') )
6099 else if ( state
== 2 && (wxIsalnum(c
) || c
== wxT('x')) )
6106 if ( c
== wxT('"') )
6119 if ( !value
.ToLong(&l
, 0) ) l
= wxPG_INVALID_VALUE
;
6120 choices
.Add(label
, l
);
6123 if ( !choices
.IsOk() )
6125 choices
.EnsureData();
6129 if ( idString
.length() )
6130 m_dictIdChoices
[idString
] = choices
.GetData();
6137 // -----------------------------------------------------------------------
6139 bool wxPropertyGridPopulator::ToLongPCT( const wxString
& s
, long* pval
, long max
)
6141 if ( s
.Last() == wxT('%') )
6143 wxString s2
= s
.substr(0,s
.length()-1);
6145 if ( s2
.ToLong(&val
, 10) )
6147 *pval
= (val
*max
)/100;
6153 return s
.ToLong(pval
, 10);
6156 // -----------------------------------------------------------------------
6158 bool wxPropertyGridPopulator::AddAttribute( const wxString
& name
,
6159 const wxString
& type
,
6160 const wxString
& value
)
6162 int l
= m_propHierarchy
.size();
6166 wxPGProperty
* p
= m_propHierarchy
[l
-1];
6167 wxString valuel
= value
.Lower();
6170 if ( type
.length() == 0 )
6175 if ( valuel
== wxT("true") || valuel
== wxT("yes") || valuel
== wxT("1") )
6177 else if ( valuel
== wxT("false") || valuel
== wxT("no") || valuel
== wxT("0") )
6179 else if ( value
.ToLong(&v
, 0) )
6186 if ( type
== wxT("string") )
6190 else if ( type
== wxT("int") )
6193 value
.ToLong(&v
, 0);
6196 else if ( type
== wxT("bool") )
6198 if ( valuel
== wxT("true") || valuel
== wxT("yes") || valuel
== wxT("1") )
6205 ProcessError(wxString::Format(wxT("Invalid attribute type '%s'"),type
.c_str()));
6210 p
->SetAttribute( name
, variant
);
6215 // -----------------------------------------------------------------------
6217 void wxPropertyGridPopulator::ProcessError( const wxString
& msg
)
6219 wxLogError(_("Error in resource: %s"),msg
.c_str());
6222 // -----------------------------------------------------------------------
6224 #endif // wxUSE_PROPGRID