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.
3337 if ( !selected
|| selected
->HasFlag(wxPG_PROP_BEING_DELETED
) )
3340 if ( m_iFlags
& wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
)
3343 wxVariant
pendingValue(selected
->GetValueRef());
3344 wxWindow
* wnd
= GetEditorControl();
3345 wxWindow
* editorWnd
= wxDynamicCast(event
.GetEventObject(), wxWindow
);
3347 bool wasUnspecified
= selected
->IsValueUnspecified();
3348 int usesAutoUnspecified
= selected
->UsesAutoUnspecified();
3349 bool valueIsPending
= false;
3351 m_chgInfo_changedProperty
= NULL
;
3353 m_iFlags
&= ~(wxPG_FL_VALIDATION_FAILED
|wxPG_FL_VALUE_CHANGE_IN_EVENT
);
3356 // Filter out excess wxTextCtrl modified events
3357 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_UPDATED
&&
3359 wnd
->IsKindOf(CLASSINFO(wxTextCtrl
)) )
3361 wxTextCtrl
* tc
= (wxTextCtrl
*) wnd
;
3363 wxString newTcValue
= tc
->GetValue();
3364 if ( m_prevTcValue
== newTcValue
)
3367 m_prevTcValue
= newTcValue
;
3370 SetInternalFlag(wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
);
3372 bool validationFailure
= false;
3373 bool buttonWasHandled
= false;
3376 // Try common button handling
3377 if ( m_wndEditor2
&& event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
3379 wxPGEditorDialogAdapter
* adapter
= selected
->GetEditorDialog();
3383 buttonWasHandled
= true;
3384 // Store as res2, as previously (and still currently alternatively)
3385 // dialogs can be shown by handling wxEVT_COMMAND_BUTTON_CLICKED
3386 // in wxPGProperty::OnEvent().
3387 adapter
->ShowDialog( this, selected
);
3392 if ( !buttonWasHandled
)
3394 if ( wnd
|| m_wndEditor2
)
3396 // First call editor class' event handler.
3397 const wxPGEditor
* editor
= selected
->GetEditorClass();
3399 if ( editor
->OnEvent( this, selected
, editorWnd
, event
) )
3401 // If changes, validate them
3402 if ( DoEditorValidate() )
3404 if ( editor
->GetValueFromControl( pendingValue
,
3407 valueIsPending
= true;
3411 validationFailure
= true;
3416 // Then the property's custom handler (must be always called, unless
3417 // validation failed).
3418 if ( !validationFailure
)
3419 buttonWasHandled
= selected
->OnEvent( this, editorWnd
, event
);
3422 // SetValueInEvent(), as called in one of the functions referred above
3423 // overrides editor's value.
3424 if ( m_iFlags
& wxPG_FL_VALUE_CHANGE_IN_EVENT
)
3426 valueIsPending
= true;
3427 pendingValue
= m_changeInEventValue
;
3428 selFlags
|= wxPG_SEL_DIALOGVAL
;
3431 if ( !validationFailure
&& valueIsPending
)
3432 if ( !PerformValidation(selected
, pendingValue
) )
3433 validationFailure
= true;
3435 if ( validationFailure
)
3437 OnValidationFailure(selected
, pendingValue
);
3439 else if ( valueIsPending
)
3441 selFlags
|= ( !wasUnspecified
&& selected
->IsValueUnspecified() && usesAutoUnspecified
) ? wxPG_SEL_SETUNSPEC
: 0;
3443 DoPropertyChanged(selected
, selFlags
);
3444 EditorsValueWasNotModified();
3446 // Regardless of editor type, unfocus editor on
3447 // text-editing related enter press.
3448 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_ENTER
)
3455 // No value after all
3457 // Regardless of editor type, unfocus editor on
3458 // text-editing related enter press.
3459 if ( event
.GetEventType() == wxEVT_COMMAND_TEXT_ENTER
)
3464 // Let unhandled button click events go to the parent
3465 if ( !buttonWasHandled
&& event
.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED
)
3467 wxCommandEvent
evt(wxEVT_COMMAND_BUTTON_CLICKED
,GetId());
3468 GetEventHandler()->AddPendingEvent(evt
);
3472 ClearInternalFlag(wxPG_FL_IN_HANDLECUSTOMEDITOREVENT
);
3475 // -----------------------------------------------------------------------
3476 // wxPropertyGrid editor control helper methods
3477 // -----------------------------------------------------------------------
3479 wxRect
wxPropertyGrid::GetEditorWidgetRect( wxPGProperty
* p
, int column
) const
3481 int itemy
= p
->GetY2(m_lineHeight
);
3483 int splitterX
= m_pState
->DoGetSplitterPosition(column
-1);
3484 int colEnd
= splitterX
+ m_pState
->m_colWidths
[column
];
3485 int imageOffset
= 0;
3487 // TODO: If custom image detection changes from current, change this.
3488 if ( m_iFlags
& wxPG_FL_CUR_USES_CUSTOM_IMAGE
)
3490 //m_iFlags |= wxPG_FL_CUR_USES_CUSTOM_IMAGE;
3491 int iw
= p
->OnMeasureImage().x
;
3493 iw
= wxPG_CUSTOM_IMAGE_WIDTH
;
3494 imageOffset
= p
->GetImageOffset(iw
);
3499 splitterX
+imageOffset
+wxPG_XBEFOREWIDGET
+wxPG_CONTROL_MARGIN
+1,
3501 colEnd
-splitterX
-wxPG_XBEFOREWIDGET
-wxPG_CONTROL_MARGIN
-imageOffset
-1,
3506 // -----------------------------------------------------------------------
3508 wxRect
wxPropertyGrid::GetImageRect( wxPGProperty
* p
, int item
) const
3510 wxSize sz
= GetImageSize(p
, item
);
3511 return wxRect(wxPG_CONTROL_MARGIN
+ wxCC_CUSTOM_IMAGE_MARGIN1
,
3512 wxPG_CUSTOM_IMAGE_SPACINGY
,
3517 // return size of custom paint image
3518 wxSize
wxPropertyGrid::GetImageSize( wxPGProperty
* p
, int item
) const
3520 // If called with NULL property, then return default image
3521 // size for properties that use image.
3523 return wxSize(wxPG_CUSTOM_IMAGE_WIDTH
,wxPG_STD_CUST_IMAGE_HEIGHT(m_lineHeight
));
3525 wxSize cis
= p
->OnMeasureImage(item
);
3527 int choiceCount
= p
->m_choices
.GetCount();
3528 int comVals
= p
->GetDisplayedCommonValueCount();
3529 if ( item
>= choiceCount
&& comVals
> 0 )
3531 unsigned int cvi
= item
-choiceCount
;
3532 cis
= GetCommonValue(cvi
)->GetRenderer()->GetImageSize(NULL
, 1, cvi
);
3534 else if ( item
>= 0 && choiceCount
== 0 )
3535 return wxSize(0, 0);
3540 cis
.x
= wxPG_CUSTOM_IMAGE_WIDTH
;
3545 cis
.y
= wxPG_STD_CUST_IMAGE_HEIGHT(m_lineHeight
);
3552 // -----------------------------------------------------------------------
3554 // takes scrolling into account
3555 void wxPropertyGrid::ImprovedClientToScreen( int* px
, int* py
)
3558 GetViewStart(&vx
,&vy
);
3559 vy
*=wxPG_PIXELS_PER_UNIT
;
3560 vx
*=wxPG_PIXELS_PER_UNIT
;
3563 ClientToScreen( px
, py
);
3566 // -----------------------------------------------------------------------
3568 wxPropertyGridHitTestResult
wxPropertyGrid::HitTest( const wxPoint
& pt
) const
3571 GetViewStart(&pt2
.x
,&pt2
.y
);
3572 pt2
.x
*= wxPG_PIXELS_PER_UNIT
;
3573 pt2
.y
*= wxPG_PIXELS_PER_UNIT
;
3577 return m_pState
->HitTest(pt2
);
3580 // -----------------------------------------------------------------------
3582 // custom set cursor
3583 void wxPropertyGrid::CustomSetCursor( int type
, bool override
)
3585 if ( type
== m_curcursor
&& !override
) return;
3587 wxCursor
* cursor
= &wxPG_DEFAULT_CURSOR
;
3589 if ( type
== wxCURSOR_SIZEWE
)
3590 cursor
= m_cursorSizeWE
;
3592 m_canvas
->SetCursor( *cursor
);
3597 // -----------------------------------------------------------------------
3598 // wxPropertyGrid property selection, editor creation
3599 // -----------------------------------------------------------------------
3602 // This class forwards events from property editor controls to wxPropertyGrid.
3603 class wxPropertyGridEditorEventForwarder
: public wxEvtHandler
3606 wxPropertyGridEditorEventForwarder( wxPropertyGrid
* propGrid
)
3607 : wxEvtHandler(), m_propGrid(propGrid
)
3611 virtual ~wxPropertyGridEditorEventForwarder()
3616 bool ProcessEvent( wxEvent
& event
)
3621 m_propGrid
->HandleCustomEditorEvent(event
);
3623 return wxEvtHandler::ProcessEvent(event
);
3626 wxPropertyGrid
* m_propGrid
;
3629 // Setups event handling for child control
3630 void wxPropertyGrid::SetupChildEventHandling( wxWindow
* argWnd
)
3632 wxWindowID id
= argWnd
->GetId();
3634 if ( argWnd
== m_wndEditor
)
3636 argWnd
->Connect(id
, wxEVT_MOTION
,
3637 wxMouseEventHandler(wxPropertyGrid::OnMouseMoveChild
),
3639 argWnd
->Connect(id
, wxEVT_LEFT_UP
,
3640 wxMouseEventHandler(wxPropertyGrid::OnMouseUpChild
),
3642 argWnd
->Connect(id
, wxEVT_LEFT_DOWN
,
3643 wxMouseEventHandler(wxPropertyGrid::OnMouseClickChild
),
3645 argWnd
->Connect(id
, wxEVT_RIGHT_UP
,
3646 wxMouseEventHandler(wxPropertyGrid::OnMouseRightClickChild
),
3648 argWnd
->Connect(id
, wxEVT_ENTER_WINDOW
,
3649 wxMouseEventHandler(wxPropertyGrid::OnMouseEntry
),
3651 argWnd
->Connect(id
, wxEVT_LEAVE_WINDOW
,
3652 wxMouseEventHandler(wxPropertyGrid::OnMouseEntry
),
3656 wxPropertyGridEditorEventForwarder
* forwarder
;
3657 forwarder
= new wxPropertyGridEditorEventForwarder(this);
3658 argWnd
->PushEventHandler(forwarder
);
3660 argWnd
->Connect(id
, wxEVT_KEY_DOWN
,
3661 wxCharEventHandler(wxPropertyGrid::OnChildKeyDown
),
3665 void wxPropertyGrid::DestroyEditorWnd( wxWindow
* wnd
)
3672 // Do not free editors immediately (for sake of processing events)
3673 wxPendingDelete
.Append(wnd
);
3676 void wxPropertyGrid::FreeEditors()
3679 // Return focus back to canvas from children (this is required at least for
3680 // GTK+, which, unlike Windows, clears focus when control is destroyed
3681 // instead of moving it to closest parent).
3682 wxWindow
* focus
= wxWindow::FindFocus();
3685 wxWindow
* parent
= focus
->GetParent();
3688 if ( parent
== m_canvas
)
3693 parent
= parent
->GetParent();
3697 // Do not free editors immediately if processing events
3700 wxEvtHandler
* handler
= m_wndEditor2
->PopEventHandler(false);
3701 m_wndEditor2
->Hide();
3702 wxPendingDelete
.Append( handler
);
3703 DestroyEditorWnd(m_wndEditor2
);
3704 m_wndEditor2
= NULL
;
3709 wxEvtHandler
* handler
= m_wndEditor
->PopEventHandler(false);
3710 m_wndEditor
->Hide();
3711 wxPendingDelete
.Append( handler
);
3712 DestroyEditorWnd(m_wndEditor
);
3717 // Call with NULL to de-select property
3718 bool wxPropertyGrid::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
3723 wxLogDebug(wxT("SelectProperty( %s (%s[%i]) )"),p->m_label.c_str(),
3724 p->m_parent->m_label.c_str(),p->GetIndexInParent());
3728 wxLogDebug(wxT("SelectProperty( NULL, -1 )"));
3732 if ( m_inDoSelectProperty
)
3735 m_inDoSelectProperty
= 1;
3739 m_inDoSelectProperty
= 0;
3743 wxArrayPGProperty prevSelection
= m_pState
->m_selection
;
3744 wxPGProperty
* prevFirstSel
;
3746 if ( prevSelection
.size() > 0 )
3747 prevFirstSel
= prevSelection
[0];
3749 prevFirstSel
= NULL
;
3751 if ( prevFirstSel
&& prevFirstSel
->HasFlag(wxPG_PROP_BEING_DELETED
) )
3752 prevFirstSel
= NULL
;
3754 // Always send event, as this is indirect call
3755 DoEndLabelEdit(true, wxPG_SEL_NOVALIDATE
);
3759 wxPrintf( "Selected %s\n", prevFirstSel->GetClassInfo()->GetClassName() );
3761 wxPrintf( "None selected\n" );
3764 wxPrintf( "P = %s\n", p->GetClassInfo()->GetClassName() );
3766 wxPrintf( "P = NULL\n" );
3769 // If we are frozen, then just set the values.
3772 m_iFlags
&= ~(wxPG_FL_ABNORMAL_EDITOR
);
3773 m_editorFocused
= 0;
3774 m_pState
->DoSetSelection(p
);
3776 // If frozen, always free controls. But don't worry, as Thaw will
3777 // recall SelectProperty to recreate them.
3780 // Prevent any further selection measures in this call
3786 if ( prevFirstSel
== p
&&
3787 prevSelection
.size() <= 1 &&
3788 !(flags
& wxPG_SEL_FORCE
) )
3790 // Only set focus if not deselecting
3793 if ( flags
& wxPG_SEL_FOCUS
)
3797 m_wndEditor
->SetFocus();
3798 m_editorFocused
= 1;
3807 m_inDoSelectProperty
= 0;
3812 // First, deactivate previous
3815 OnValidationFailureReset(prevFirstSel
);
3817 // Must double-check if this is an selected in case of forceswitch
3818 if ( p
!= prevFirstSel
)
3820 if ( !CommitChangesFromEditor(flags
) )
3822 // Validation has failed, so we can't exit the previous editor
3823 //::wxMessageBox(_("Please correct the value or press ESC to cancel the edit."),
3824 // _("Invalid Value"),wxOK|wxICON_ERROR);
3825 m_inDoSelectProperty
= 0;
3832 m_iFlags
&= ~(wxPG_FL_ABNORMAL_EDITOR
);
3833 EditorsValueWasNotModified();
3836 SetInternalFlag(wxPG_FL_IN_SELECT_PROPERTY
);
3838 m_pState
->DoSetSelection(p
);
3840 // Redraw unselected
3841 for ( unsigned int i
=0; i
<prevSelection
.size(); i
++ )
3843 DrawItem(prevSelection
[i
]);
3847 // Then, activate the one given.
3850 int propY
= p
->GetY2(m_lineHeight
);
3852 int splitterX
= GetSplitterPosition();
3853 m_editorFocused
= 0;
3854 m_iFlags
|= wxPG_FL_PRIMARY_FILLS_ENTIRE
;
3855 if ( p
!= prevFirstSel
)
3856 m_iFlags
&= ~(wxPG_FL_VALIDATION_FAILED
);
3858 wxASSERT( m_wndEditor
== NULL
);
3861 // Only create editor for non-disabled non-caption
3862 if ( !p
->IsCategory() && !(p
->m_flags
& wxPG_PROP_DISABLED
) )
3864 // do this for non-caption items
3868 // Do we need to paint the custom image, if any?
3869 m_iFlags
&= ~(wxPG_FL_CUR_USES_CUSTOM_IMAGE
);
3870 if ( (p
->m_flags
& wxPG_PROP_CUSTOMIMAGE
) &&
3871 !p
->GetEditorClass()->CanContainCustomImage()
3873 m_iFlags
|= wxPG_FL_CUR_USES_CUSTOM_IMAGE
;
3875 wxRect grect
= GetEditorWidgetRect(p
, m_selColumn
);
3876 wxPoint goodPos
= grect
.GetPosition();
3878 const wxPGEditor
* editor
= p
->GetEditorClass();
3879 wxCHECK_MSG(editor
, false,
3880 wxT("NULL editor class not allowed"));
3882 m_iFlags
&= ~wxPG_FL_FIXED_WIDTH_EDITOR
;
3884 wxPGWindowList wndList
= editor
->CreateControls(this,
3889 m_wndEditor
= wndList
.m_primary
;
3890 m_wndEditor2
= wndList
.m_secondary
;
3891 wxWindow
* primaryCtrl
= GetEditorControl();
3894 // Essentially, primaryCtrl == m_wndEditor
3897 // NOTE: It is allowed for m_wndEditor to be NULL - in this case
3898 // value is drawn as normal, and m_wndEditor2 is assumed
3899 // to be a right-aligned button that triggers a separate editorCtrl
3904 wxASSERT_MSG( m_wndEditor
->GetParent() == GetPanel(),
3905 wxT("CreateControls must use result of wxPropertyGrid::GetPanel() as parent of controls.") );
3907 // Set validator, if any
3908 #if wxUSE_VALIDATORS
3909 wxValidator
* validator
= p
->GetValidator();
3911 primaryCtrl
->SetValidator(*validator
);
3914 if ( m_wndEditor
->GetSize().y
> (m_lineHeight
+6) )
3915 m_iFlags
|= wxPG_FL_ABNORMAL_EDITOR
;
3917 // If it has modified status, use bold font
3918 // (must be done before capturing m_ctrlXAdjust)
3919 if ( (p
->m_flags
& wxPG_PROP_MODIFIED
) && (m_windowStyle
& wxPG_BOLD_MODIFIED
) )
3920 SetCurControlBoldFont();
3922 // Store x relative to splitter (we'll need it).
3923 m_ctrlXAdjust
= m_wndEditor
->GetPosition().x
- splitterX
;
3925 // Check if background clear is not necessary
3926 wxPoint pos
= m_wndEditor
->GetPosition();
3927 if ( pos
.x
> (splitterX
+1) || pos
.y
> propY
)
3929 m_iFlags
&= ~(wxPG_FL_PRIMARY_FILLS_ENTIRE
);
3932 m_wndEditor
->SetSizeHints(3, 3);
3934 SetupChildEventHandling(primaryCtrl
);
3936 // Focus and select all (wxTextCtrl, wxComboBox etc)
3937 if ( flags
& wxPG_SEL_FOCUS
)
3939 primaryCtrl
->SetFocus();
3941 p
->GetEditorClass()->OnFocus(p
, primaryCtrl
);
3947 wxASSERT_MSG( m_wndEditor2
->GetParent() == GetPanel(),
3948 wxT("CreateControls must use result of wxPropertyGrid::GetPanel() as parent of controls.") );
3950 // Get proper id for wndSecondary
3951 m_wndSecId
= m_wndEditor2
->GetId();
3952 wxWindowList children
= m_wndEditor2
->GetChildren();
3953 wxWindowList::iterator node
= children
.begin();
3954 if ( node
!= children
.end() )
3955 m_wndSecId
= ((wxWindow
*)*node
)->GetId();
3957 m_wndEditor2
->SetSizeHints(3,3);
3959 m_wndEditor2
->Show();
3961 SetupChildEventHandling(m_wndEditor2
);
3963 // If no primary editor, focus to button to allow
3964 // it to interprete ENTER etc.
3965 // NOTE: Due to problems focusing away from it, this
3966 // has been disabled.
3968 if ( (flags & wxPG_SEL_FOCUS) && !m_wndEditor )
3969 m_wndEditor2->SetFocus();
3973 if ( flags
& wxPG_SEL_FOCUS
)
3974 m_editorFocused
= 1;
3979 // Make sure focus is in grid canvas (important for wxGTK, at least)
3983 EditorsValueWasNotModified();
3985 // If it's inside collapsed section, expand parent, scroll, etc.
3986 // Also, if it was partially visible, scroll it into view.
3987 if ( !(flags
& wxPG_SEL_NONVISIBLE
) )
3992 m_wndEditor
->Show(true);
3995 if ( !(flags
& wxPG_SEL_NO_REFRESH
) )
4000 // Make sure focus is in grid canvas
4004 ClearInternalFlag(wxPG_FL_IN_SELECT_PROPERTY
);
4010 // Show help text in status bar.
4011 // (if found and grid not embedded in manager with help box and
4012 // style wxPG_EX_HELP_AS_TOOLTIPS is not used).
4015 if ( !(GetExtraStyle() & wxPG_EX_HELP_AS_TOOLTIPS
) )
4017 wxStatusBar
* statusbar
= NULL
;
4018 if ( !(m_iFlags
& wxPG_FL_NOSTATUSBARHELP
) )
4020 wxFrame
* frame
= wxDynamicCast(::wxGetTopLevelParent(this),wxFrame
);
4022 statusbar
= frame
->GetStatusBar();
4027 const wxString
* pHelpString
= (const wxString
*) NULL
;
4031 pHelpString
= &p
->GetHelpString();
4032 if ( pHelpString
->length() )
4034 // Set help box text.
4035 statusbar
->SetStatusText( *pHelpString
);
4036 m_iFlags
|= wxPG_FL_STRING_IN_STATUSBAR
;
4040 if ( (!pHelpString
|| !pHelpString
->length()) &&
4041 (m_iFlags
& wxPG_FL_STRING_IN_STATUSBAR
) )
4043 // Clear help box - but only if it was written
4044 // by us at previous time.
4045 statusbar
->SetStatusText( m_emptyString
);
4046 m_iFlags
&= ~(wxPG_FL_STRING_IN_STATUSBAR
);
4052 m_inDoSelectProperty
= 0;
4054 // call wx event handler (here so that it also occurs on deselection)
4055 if ( !(flags
& wxPG_SEL_DONT_SEND_EVENT
) )
4056 SendEvent( wxEVT_PG_SELECTED
, p
, NULL
);
4061 // -----------------------------------------------------------------------
4063 bool wxPropertyGrid::UnfocusEditor()
4065 wxPGProperty
* selected
= GetSelection();
4067 if ( !selected
|| !m_wndEditor
|| m_frozen
)
4070 if ( !CommitChangesFromEditor(0) )
4079 // -----------------------------------------------------------------------
4081 void wxPropertyGrid::RefreshEditor()
4083 wxPGProperty
* p
= GetSelection();
4087 wxWindow
* wnd
= GetEditorControl();
4091 // Set editor font boldness - must do this before
4092 // calling UpdateControl().
4093 if ( HasFlag(wxPG_BOLD_MODIFIED
) )
4095 if ( p
->HasFlag(wxPG_PROP_MODIFIED
) )
4096 wnd
->SetFont(GetCaptionFont());
4098 wnd
->SetFont(GetFont());
4101 const wxPGEditor
* editorClass
= p
->GetEditorClass();
4103 editorClass
->UpdateControl(p
, wnd
);
4105 if ( p
->IsValueUnspecified() )
4106 editorClass
->SetValueToUnspecified(p
, wnd
);
4109 // -----------------------------------------------------------------------
4111 bool wxPropertyGrid::SelectProperty( wxPGPropArg id
, bool focus
)
4113 wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
4115 int flags
= wxPG_SEL_DONT_SEND_EVENT
;
4117 flags
|= wxPG_SEL_FOCUS
;
4119 return DoSelectProperty(p
, flags
);
4122 // -----------------------------------------------------------------------
4123 // wxPropertyGrid expand/collapse state
4124 // -----------------------------------------------------------------------
4126 bool wxPropertyGrid::DoCollapse( wxPGProperty
* p
, bool sendEvents
)
4128 wxPGProperty
* pwc
= wxStaticCast(p
, wxPGProperty
);
4129 wxPGProperty
* selected
= GetSelection();
4131 // If active editor was inside collapsed section, then disable it
4132 if ( selected
&& selected
->IsSomeParent(p
) )
4137 // Store dont-center-splitter flag 'cause we need to temporarily set it
4138 wxUint32 old_flag
= m_iFlags
& wxPG_FL_DONT_CENTER_SPLITTER
;
4139 m_iFlags
|= wxPG_FL_DONT_CENTER_SPLITTER
;
4141 bool res
= m_pState
->DoCollapse(pwc
);
4146 SendEvent( wxEVT_PG_ITEM_COLLAPSED
, p
);
4148 RecalculateVirtualSize();
4150 // Redraw etc. only if collapsed was visible.
4151 if (pwc
->IsVisible() &&
4153 ( !pwc
->IsCategory() || !(m_windowStyle
& wxPG_HIDE_CATEGORIES
) ) )
4155 // When item is collapsed so that scrollbar would move,
4156 // graphics mess is about (unless we redraw everything).
4161 // Clear dont-center-splitter flag if it wasn't set
4162 m_iFlags
= (m_iFlags
& ~wxPG_FL_DONT_CENTER_SPLITTER
) | old_flag
;
4167 // -----------------------------------------------------------------------
4169 bool wxPropertyGrid::DoExpand( wxPGProperty
* p
, bool sendEvents
)
4171 wxCHECK_MSG( p
, false, wxT("invalid property id") );
4173 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
4175 // Store dont-center-splitter flag 'cause we need to temporarily set it
4176 wxUint32 old_flag
= m_iFlags
& wxPG_FL_DONT_CENTER_SPLITTER
;
4177 m_iFlags
|= wxPG_FL_DONT_CENTER_SPLITTER
;
4179 bool res
= m_pState
->DoExpand(pwc
);
4184 SendEvent( wxEVT_PG_ITEM_EXPANDED
, p
);
4186 RecalculateVirtualSize();
4188 // Redraw etc. only if expanded was visible.
4189 if ( pwc
->IsVisible() && !m_frozen
&&
4190 ( !pwc
->IsCategory() || !(m_windowStyle
& wxPG_HIDE_CATEGORIES
) )
4194 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
4197 DrawItems(pwc
, NULL
);
4202 // Clear dont-center-splitter flag if it wasn't set
4203 m_iFlags
= (m_iFlags
& ~wxPG_FL_DONT_CENTER_SPLITTER
) | old_flag
;
4208 // -----------------------------------------------------------------------
4210 bool wxPropertyGrid::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
4213 return m_pState
->DoHideProperty(p
, hide
, flags
);
4215 wxArrayPGProperty selection
= m_pState
->m_selection
; // Must use a copy
4216 int selRemoveCount
= 0;
4217 for ( unsigned int i
=0; i
<selection
.size(); i
++ )
4219 wxPGProperty
* selected
= selection
[i
];
4220 if ( selected
== p
|| selected
->IsSomeParent(p
) )
4222 if ( !DoRemoveFromSelection(p
, flags
) )
4224 selRemoveCount
+= 1;
4228 m_pState
->DoHideProperty(p
, hide
, flags
);
4230 RecalculateVirtualSize();
4237 // -----------------------------------------------------------------------
4238 // wxPropertyGrid size related methods
4239 // -----------------------------------------------------------------------
4241 void wxPropertyGrid::RecalculateVirtualSize( int forceXPos
)
4243 if ( (m_iFlags
& wxPG_FL_RECALCULATING_VIRTUAL_SIZE
) || m_frozen
)
4247 // If virtual height was changed, then recalculate editor control position(s)
4248 if ( m_pState
->m_vhCalcPending
)
4249 CorrectEditorWidgetPosY();
4251 m_pState
->EnsureVirtualHeight();
4253 wxASSERT_LEVEL_2_MSG(
4254 m_pState
->GetVirtualHeight() == m_pState
->GetActualVirtualHeight(),
4255 "VirtualHeight and ActualVirtualHeight should match"
4258 m_iFlags
|= wxPG_FL_RECALCULATING_VIRTUAL_SIZE
;
4260 int x
= m_pState
->m_width
;
4261 int y
= m_pState
->m_virtualHeight
;
4264 GetClientSize(&width
,&height
);
4266 // Now adjust virtual size.
4267 SetVirtualSize(x
, y
);
4273 // Adjust scrollbars
4274 if ( HasVirtualWidth() )
4276 xAmount
= x
/wxPG_PIXELS_PER_UNIT
;
4277 xPos
= GetScrollPos( wxHORIZONTAL
);
4280 if ( forceXPos
!= -1 )
4283 else if ( xPos
> (xAmount
-(width
/wxPG_PIXELS_PER_UNIT
)) )
4286 int yAmount
= y
/ wxPG_PIXELS_PER_UNIT
;
4287 int yPos
= GetScrollPos( wxVERTICAL
);
4289 SetScrollbars( wxPG_PIXELS_PER_UNIT
, wxPG_PIXELS_PER_UNIT
,
4290 xAmount
, yAmount
, xPos
, yPos
, true );
4292 // Must re-get size now
4293 GetClientSize(&width
,&height
);
4295 if ( !HasVirtualWidth() )
4297 m_pState
->SetVirtualWidth(width
);
4304 // Explicitly pass the position - works around a bug in wxWidgets when the property grid
4305 // has a native XP border and a contained window creeps up-and-left when size is set without
4307 m_canvas
->SetSize( 0, 0, x
, y
);
4309 m_pState
->CheckColumnWidths();
4311 if ( GetSelection() )
4312 CorrectEditorWidgetSizeX();
4314 m_iFlags
&= ~wxPG_FL_RECALCULATING_VIRTUAL_SIZE
;
4317 // -----------------------------------------------------------------------
4319 void wxPropertyGrid::OnResize( wxSizeEvent
& event
)
4321 if ( !(m_iFlags
& wxPG_FL_INITIALIZED
) )
4325 GetClientSize(&width
,&height
);
4330 #if wxPG_DOUBLE_BUFFER
4331 if ( !(GetExtraStyle() & wxPG_EX_NATIVE_DOUBLE_BUFFERING
) )
4333 int dblh
= (m_lineHeight
*2);
4334 if ( !m_doubleBuffer
)
4336 // Create double buffer bitmap to draw on, if none
4337 int w
= (width
>250)?width
:250;
4338 int h
= height
+ dblh
;
4340 m_doubleBuffer
= new wxBitmap( w
, h
);
4344 int w
= m_doubleBuffer
->GetWidth();
4345 int h
= m_doubleBuffer
->GetHeight();
4347 // Double buffer must be large enough
4348 if ( w
< width
|| h
< (height
+dblh
) )
4350 if ( w
< width
) w
= width
;
4351 if ( h
< (height
+dblh
) ) h
= height
+ dblh
;
4352 delete m_doubleBuffer
;
4353 m_doubleBuffer
= new wxBitmap( w
, h
);
4360 m_pState
->OnClientWidthChange( width
, event
.GetSize().x
- m_ncWidth
, true );
4361 m_ncWidth
= event
.GetSize().x
;
4365 if ( m_pState
->m_itemsAdded
)
4366 PrepareAfterItemsAdded();
4368 // Without this, virtual size (atleast under wxGTK) will be skewed
4369 RecalculateVirtualSize();
4375 // -----------------------------------------------------------------------
4377 void wxPropertyGrid::SetVirtualWidth( int width
)
4381 // Disable virtual width
4382 width
= GetClientSize().x
;
4383 ClearInternalFlag(wxPG_FL_HAS_VIRTUAL_WIDTH
);
4387 // Enable virtual width
4388 SetInternalFlag(wxPG_FL_HAS_VIRTUAL_WIDTH
);
4390 m_pState
->SetVirtualWidth( width
);
4393 void wxPropertyGrid::SetFocusOnCanvas()
4395 m_canvas
->SetFocusIgnoringChildren();
4396 m_editorFocused
= 0;
4399 // -----------------------------------------------------------------------
4400 // wxPropertyGrid mouse event handling
4401 // -----------------------------------------------------------------------
4403 // selFlags uses same values DoSelectProperty's flags
4404 // Returns true if event was vetoed.
4405 bool wxPropertyGrid::SendEvent( int eventType
, wxPGProperty
* p
,
4407 unsigned int selFlags
,
4408 unsigned int column
)
4410 // Send property grid event of specific type and with specific property
4411 wxPropertyGridEvent
evt( eventType
, m_eventObject
->GetId() );
4412 evt
.SetPropertyGrid(this);
4413 evt
.SetEventObject(m_eventObject
);
4415 evt
.SetColumn(column
);
4416 if ( eventType
== wxEVT_PG_CHANGING
)
4419 evt
.SetCanVeto(true);
4420 m_validationInfo
.m_pValue
= pValue
;
4421 evt
.SetupValidationInfo();
4426 evt
.SetPropertyValue(p
->GetValue());
4428 if ( !(selFlags
& wxPG_SEL_NOVALIDATE
) )
4429 evt
.SetCanVeto(true);
4432 m_processedEvent
= &evt
;
4433 m_eventObject
->HandleWindowEvent(evt
);
4434 m_processedEvent
= NULL
;
4436 return evt
.WasVetoed();
4439 // -----------------------------------------------------------------------
4441 // Return false if should be skipped
4442 bool wxPropertyGrid::HandleMouseClick( int x
, unsigned int y
, wxMouseEvent
&event
)
4446 // Need to set focus?
4447 if ( !(m_iFlags
& wxPG_FL_FOCUSED
) )
4452 wxPropertyGridPageState
* state
= m_pState
;
4454 int splitterHitOffset
;
4455 int columnHit
= state
->HitTestH( x
, &splitterHit
, &splitterHitOffset
);
4457 wxPGProperty
* p
= DoGetItemAtY(y
);
4461 int depth
= (int)p
->GetDepth() - 1;
4463 int marginEnds
= m_marginWidth
+ ( depth
* m_subgroup_extramargin
);
4465 if ( x
>= marginEnds
)
4469 if ( p
->IsCategory() )
4471 // This is category.
4472 wxPropertyCategory
* pwc
= (wxPropertyCategory
*)p
;
4474 int textX
= m_marginWidth
+ ((unsigned int)((pwc
->m_depth
-1)*m_subgroup_extramargin
));
4476 // Expand, collapse, activate etc. if click on text or left of splitter.
4479 ( x
< (textX
+pwc
->GetTextExtent(this, m_captionFont
)+(wxPG_CAPRECTXMARGIN
*2)) ||
4484 if ( !AddToSelectionFromInputEvent( p
,
4489 // On double-click, expand/collapse.
4490 if ( event
.ButtonDClick() && !(m_windowStyle
& wxPG_HIDE_MARGIN
) )
4492 if ( pwc
->IsExpanded() ) DoCollapse( p
, true );
4493 else DoExpand( p
, true );
4497 else if ( splitterHit
== -1 )
4500 unsigned int selFlag
= 0;
4501 if ( columnHit
== 1 )
4503 m_iFlags
|= wxPG_FL_ACTIVATION_BY_CLICK
;
4504 selFlag
= wxPG_SEL_FOCUS
;
4506 if ( !AddToSelectionFromInputEvent( p
,
4512 m_iFlags
&= ~(wxPG_FL_ACTIVATION_BY_CLICK
);
4514 if ( p
->GetChildCount() && !p
->IsCategory() )
4515 // On double-click, expand/collapse.
4516 if ( event
.ButtonDClick() && !(m_windowStyle
& wxPG_HIDE_MARGIN
) )
4518 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
4519 if ( pwc
->IsExpanded() ) DoCollapse( p
, true );
4520 else DoExpand( p
, true );
4527 // click on splitter
4528 if ( !(m_windowStyle
& wxPG_STATIC_SPLITTER
) )
4530 if ( event
.GetEventType() == wxEVT_LEFT_DCLICK
)
4532 // Double-clicking the splitter causes auto-centering
4533 CenterSplitter( true );
4535 else if ( m_dragStatus
== 0 )
4538 // Begin draggin the splitter
4542 DoEndLabelEdit(true, wxPG_SEL_NOVALIDATE
);
4546 // Changes must be committed here or the
4547 // value won't be drawn correctly
4548 if ( !CommitChangesFromEditor() )
4551 m_wndEditor
->Show ( false );
4554 if ( !(m_iFlags
& wxPG_FL_MOUSE_CAPTURED
) )
4556 m_canvas
->CaptureMouse();
4557 m_iFlags
|= wxPG_FL_MOUSE_CAPTURED
;
4561 m_draggedSplitter
= splitterHit
;
4562 m_dragOffset
= splitterHitOffset
;
4564 wxClientDC
dc(m_canvas
);
4566 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
4567 // Fixes button disappearance bug
4569 m_wndEditor2
->Show ( false );
4572 m_startingSplitterX
= x
- splitterHitOffset
;
4580 if ( p
->GetChildCount() )
4582 int nx
= x
+ m_marginWidth
- marginEnds
; // Normalize x.
4584 if ( (nx
>= m_gutterWidth
&& nx
< (m_gutterWidth
+m_iconWidth
)) )
4586 int y2
= y
% m_lineHeight
;
4587 if ( (y2
>= m_buttonSpacingY
&& y2
< (m_buttonSpacingY
+m_iconHeight
)) )
4589 // On click on expander button, expand/collapse
4590 if ( ((wxPGProperty
*)p
)->IsExpanded() )
4591 DoCollapse( p
, true );
4593 DoExpand( p
, true );
4602 // -----------------------------------------------------------------------
4604 bool wxPropertyGrid::HandleMouseRightClick( int WXUNUSED(x
),
4605 unsigned int WXUNUSED(y
),
4606 wxMouseEvent
& event
)
4610 // Select property here as well
4611 wxPGProperty
* p
= m_propHover
;
4612 AddToSelectionFromInputEvent(p
, m_colHover
, &event
);
4614 // Send right click event.
4615 SendEvent( wxEVT_PG_RIGHT_CLICK
, p
);
4622 // -----------------------------------------------------------------------
4624 bool wxPropertyGrid::HandleMouseDoubleClick( int WXUNUSED(x
),
4625 unsigned int WXUNUSED(y
),
4626 wxMouseEvent
& event
)
4630 // Select property here as well
4631 wxPGProperty
* p
= m_propHover
;
4633 AddToSelectionFromInputEvent(p
, m_colHover
, &event
);
4635 // Send double-click event.
4636 SendEvent( wxEVT_PG_DOUBLE_CLICK
, m_propHover
);
4643 // -----------------------------------------------------------------------
4645 #if wxPG_SUPPORT_TOOLTIPS
4647 void wxPropertyGrid::SetToolTip( const wxString
& tipString
)
4649 if ( tipString
.length() )
4651 m_canvas
->SetToolTip(tipString
);
4655 #if wxPG_ALLOW_EMPTY_TOOLTIPS
4656 m_canvas
->SetToolTip( m_emptyString
);
4658 m_canvas
->SetToolTip( NULL
);
4663 #endif // #if wxPG_SUPPORT_TOOLTIPS
4665 // -----------------------------------------------------------------------
4667 // Return false if should be skipped
4668 bool wxPropertyGrid::HandleMouseMove( int x
, unsigned int y
, wxMouseEvent
&event
)
4670 // Safety check (needed because mouse capturing may
4671 // otherwise freeze the control)
4672 if ( m_dragStatus
> 0 && !event
.Dragging() )
4674 HandleMouseUp(x
,y
,event
);
4677 wxPropertyGridPageState
* state
= m_pState
;
4679 int splitterHitOffset
;
4680 int columnHit
= state
->HitTestH( x
, &splitterHit
, &splitterHitOffset
);
4681 int splitterX
= x
- splitterHitOffset
;
4683 m_colHover
= columnHit
;
4685 if ( m_dragStatus
> 0 )
4687 if ( x
> (m_marginWidth
+ wxPG_DRAG_MARGIN
) &&
4688 x
< (m_pState
->m_width
- wxPG_DRAG_MARGIN
) )
4691 int newSplitterX
= x
- m_dragOffset
;
4692 int splitterX
= x
- splitterHitOffset
;
4694 // Splitter redraw required?
4695 if ( newSplitterX
!= splitterX
)
4698 SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
4699 state
->DoSetSplitterPosition( newSplitterX
, m_draggedSplitter
, false );
4700 state
->m_fSplitterX
= (float) newSplitterX
;
4702 if ( GetSelection() )
4703 CorrectEditorWidgetSizeX();
4717 int ih
= m_lineHeight
;
4720 #if wxPG_SUPPORT_TOOLTIPS
4721 wxPGProperty
* prevHover
= m_propHover
;
4722 unsigned char prevSide
= m_mouseSide
;
4724 int curPropHoverY
= y
- (y
% ih
);
4726 // On which item it hovers
4729 ( sy
< m_propHoverY
|| sy
>= (m_propHoverY
+ih
) )
4732 // Mouse moves on another property
4734 m_propHover
= DoGetItemAtY(y
);
4735 m_propHoverY
= curPropHoverY
;
4738 SendEvent( wxEVT_PG_HIGHLIGHTED
, m_propHover
);
4741 #if wxPG_SUPPORT_TOOLTIPS
4742 // Store which side we are on
4744 if ( columnHit
== 1 )
4746 else if ( columnHit
== 0 )
4750 // If tooltips are enabled, show label or value as a tip
4751 // in case it doesn't otherwise show in full length.
4753 if ( m_windowStyle
& wxPG_TOOLTIPS
)
4755 wxToolTip
* tooltip
= m_canvas
->GetToolTip();
4757 if ( m_propHover
!= prevHover
|| prevSide
!= m_mouseSide
)
4759 if ( m_propHover
&& !m_propHover
->IsCategory() )
4762 if ( GetExtraStyle() & wxPG_EX_HELP_AS_TOOLTIPS
)
4764 // Show help string as a tooltip
4765 wxString tipString
= m_propHover
->GetHelpString();
4767 SetToolTip(tipString
);
4771 // Show cropped value string as a tooltip
4775 if ( m_mouseSide
== 1 )
4777 tipString
= m_propHover
->m_label
;
4778 space
= splitterX
-m_marginWidth
-3;
4780 else if ( m_mouseSide
== 2 )
4782 tipString
= m_propHover
->GetDisplayedString();
4784 space
= m_width
- splitterX
;
4785 if ( m_propHover
->m_flags
& wxPG_PROP_CUSTOMIMAGE
)
4786 space
-= wxPG_CUSTOM_IMAGE_WIDTH
+ wxCC_CUSTOM_IMAGE_MARGIN1
+ wxCC_CUSTOM_IMAGE_MARGIN2
;
4792 GetTextExtent( tipString
, &tw
, &th
, 0, 0 );
4795 SetToolTip( tipString
);
4802 #if wxPG_ALLOW_EMPTY_TOOLTIPS
4803 m_canvas
->SetToolTip( m_emptyString
);
4805 m_canvas
->SetToolTip( NULL
);
4816 #if wxPG_ALLOW_EMPTY_TOOLTIPS
4817 m_canvas
->SetToolTip( m_emptyString
);
4819 m_canvas
->SetToolTip( NULL
);
4827 if ( splitterHit
== -1 ||
4829 HasFlag(wxPG_STATIC_SPLITTER
) )
4831 // hovering on something else
4832 if ( m_curcursor
!= wxCURSOR_ARROW
)
4833 CustomSetCursor( wxCURSOR_ARROW
);
4837 // Do not allow splitter cursor on caption items.
4838 // (also not if we were dragging and its started
4839 // outside the splitter region)
4841 if ( !m_propHover
->IsCategory() &&
4845 // hovering on splitter
4847 // NB: Condition disabled since MouseLeave event (from the editor control) cannot be
4848 // reliably detected.
4849 //if ( m_curcursor != wxCURSOR_SIZEWE )
4850 CustomSetCursor( wxCURSOR_SIZEWE
, true );
4856 // hovering on something else
4857 if ( m_curcursor
!= wxCURSOR_ARROW
)
4858 CustomSetCursor( wxCURSOR_ARROW
);
4863 // Multi select by dragging
4865 if ( (GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION
) &&
4866 event
.LeftIsDown() &&
4870 !state
->DoIsPropertySelected(m_propHover
) )
4872 // Additional requirement is that the hovered property
4873 // is adjacent to edges of selection.
4874 const wxArrayPGProperty
& selection
= GetSelectedProperties();
4876 // Since categories cannot be selected along with 'other'
4877 // properties, exclude them from iterator flags.
4878 int iterFlags
= wxPG_ITERATE_VISIBLE
& (~wxPG_PROP_CATEGORY
);
4880 for ( int i
=(selection
.size()-1); i
>=0; i
-- )
4882 // TODO: This could be optimized by keeping track of
4883 // which properties are at the edges of selection.
4884 wxPGProperty
* selProp
= selection
[i
];
4885 if ( state
->ArePropertiesAdjacent(m_propHover
, selProp
,
4888 DoAddToSelection(m_propHover
);
4897 // -----------------------------------------------------------------------
4899 // Also handles Leaving event
4900 bool wxPropertyGrid::HandleMouseUp( int x
, unsigned int WXUNUSED(y
),
4901 wxMouseEvent
&WXUNUSED(event
) )
4903 wxPropertyGridPageState
* state
= m_pState
;
4907 int splitterHitOffset
;
4908 state
->HitTestH( x
, &splitterHit
, &splitterHitOffset
);
4910 // No event type check - basicly calling this method should
4911 // just stop dragging.
4912 // Left up after dragged?
4913 if ( m_dragStatus
>= 1 )
4916 // End Splitter Dragging
4918 // DO NOT ENABLE FOLLOWING LINE!
4919 // (it is only here as a reminder to not to do it)
4922 // Disable splitter auto-centering
4923 m_iFlags
|= wxPG_FL_DONT_CENTER_SPLITTER
;
4925 // This is necessary to return cursor
4926 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
4928 m_canvas
->ReleaseMouse();
4929 m_iFlags
&= ~(wxPG_FL_MOUSE_CAPTURED
);
4932 // Set back the default cursor, if necessary
4933 if ( splitterHit
== -1 ||
4936 CustomSetCursor( wxCURSOR_ARROW
);
4941 // Control background needs to be cleared
4942 wxPGProperty
* selected
= GetSelection();
4943 if ( !(m_iFlags
& wxPG_FL_PRIMARY_FILLS_ENTIRE
) && selected
)
4944 DrawItem( selected
);
4948 m_wndEditor
->Show ( true );
4951 #if wxPG_REFRESH_CONTROLS_AFTER_REPAINT
4952 // Fixes button disappearance bug
4954 m_wndEditor2
->Show ( true );
4957 // This clears the focus.
4958 m_editorFocused
= 0;
4964 // -----------------------------------------------------------------------
4966 bool wxPropertyGrid::OnMouseCommon( wxMouseEvent
& event
, int* px
, int* py
)
4968 int splitterX
= GetSplitterPosition();
4971 //CalcUnscrolledPosition( event.m_x, event.m_y, &ux, &uy );
4975 wxWindow
* wnd
= GetEditorControl();
4977 // Hide popup on clicks
4978 if ( event
.GetEventType() != wxEVT_MOTION
)
4979 if ( wnd
&& wnd
->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox
)) )
4981 ((wxOwnerDrawnComboBox
*)wnd
)->HidePopup();
4987 if ( wnd
== NULL
|| m_dragStatus
||
4989 ux
<= (splitterX
+ wxPG_SPLITTERX_DETECTMARGIN2
) ||
4990 ux
>= (r
.x
+r
.width
) ||
4992 event
.m_y
>= (r
.y
+r
.height
)
5002 if ( m_curcursor
!= wxCURSOR_ARROW
) CustomSetCursor ( wxCURSOR_ARROW
);
5007 // -----------------------------------------------------------------------
5009 void wxPropertyGrid::OnMouseClick( wxMouseEvent
&event
)
5012 if ( OnMouseCommon( event
, &x
, &y
) )
5014 HandleMouseClick(x
,y
,event
);
5019 // -----------------------------------------------------------------------
5021 void wxPropertyGrid::OnMouseRightClick( wxMouseEvent
&event
)
5024 CalcUnscrolledPosition( event
.m_x
, event
.m_y
, &x
, &y
);
5025 HandleMouseRightClick(x
,y
,event
);
5029 // -----------------------------------------------------------------------
5031 void wxPropertyGrid::OnMouseDoubleClick( wxMouseEvent
&event
)
5033 // Always run standard mouse-down handler as well
5034 OnMouseClick(event
);
5037 CalcUnscrolledPosition( event
.m_x
, event
.m_y
, &x
, &y
);
5038 HandleMouseDoubleClick(x
,y
,event
);
5042 // -----------------------------------------------------------------------
5044 void wxPropertyGrid::OnMouseMove( wxMouseEvent
&event
)
5047 if ( OnMouseCommon( event
, &x
, &y
) )
5049 HandleMouseMove(x
,y
,event
);
5054 // -----------------------------------------------------------------------
5056 void wxPropertyGrid::OnMouseMoveBottom( wxMouseEvent
& WXUNUSED(event
) )
5058 // Called when mouse moves in the empty space below the properties.
5059 CustomSetCursor( wxCURSOR_ARROW
);
5062 // -----------------------------------------------------------------------
5064 void wxPropertyGrid::OnMouseUp( wxMouseEvent
&event
)
5067 if ( OnMouseCommon( event
, &x
, &y
) )
5069 HandleMouseUp(x
,y
,event
);
5074 // -----------------------------------------------------------------------
5076 void wxPropertyGrid::OnMouseEntry( wxMouseEvent
&event
)
5078 // This may get called from child control as well, so event's
5079 // mouse position cannot be relied on.
5081 if ( event
.Entering() )
5083 if ( !(m_iFlags
& wxPG_FL_MOUSE_INSIDE
) )
5085 // TODO: Fix this (detect parent and only do
5086 // cursor trick if it is a manager).
5087 wxASSERT( GetParent() );
5088 GetParent()->SetCursor(wxNullCursor
);
5090 m_iFlags
|= wxPG_FL_MOUSE_INSIDE
;
5093 GetParent()->SetCursor(wxNullCursor
);
5095 else if ( event
.Leaving() )
5097 // Without this, wxSpinCtrl editor will sometimes have wrong cursor
5098 m_canvas
->SetCursor( wxNullCursor
);
5100 // Get real cursor position
5101 wxPoint pt
= ScreenToClient(::wxGetMousePosition());
5103 if ( ( pt
.x
<= 0 || pt
.y
<= 0 || pt
.x
>= m_width
|| pt
.y
>= m_height
) )
5106 if ( (m_iFlags
& wxPG_FL_MOUSE_INSIDE
) )
5108 m_iFlags
&= ~(wxPG_FL_MOUSE_INSIDE
);
5112 wxPropertyGrid::HandleMouseUp ( -1, 10000, event
);
5120 // -----------------------------------------------------------------------
5122 // Common code used by various OnMouseXXXChild methods.
5123 bool wxPropertyGrid::OnMouseChildCommon( wxMouseEvent
&event
, int* px
, int *py
)
5125 wxWindow
* topCtrlWnd
= (wxWindow
*)event
.GetEventObject();
5126 wxASSERT( topCtrlWnd
);
5128 event
.GetPosition(&x
,&y
);
5130 int splitterX
= GetSplitterPosition();
5132 wxRect r
= topCtrlWnd
->GetRect();
5133 if ( !m_dragStatus
&&
5134 x
> (splitterX
-r
.x
+wxPG_SPLITTERX_DETECTMARGIN2
) &&
5135 y
>= 0 && y
< r
.height \
5138 if ( m_curcursor
!= wxCURSOR_ARROW
) CustomSetCursor ( wxCURSOR_ARROW
);
5143 CalcUnscrolledPosition( event
.m_x
+ r
.x
, event
.m_y
+ r
.y
, \
5150 void wxPropertyGrid::OnMouseClickChild( wxMouseEvent
&event
)
5153 if ( OnMouseChildCommon(event
,&x
,&y
) )
5155 bool res
= HandleMouseClick(x
,y
,event
);
5156 if ( !res
) event
.Skip();
5160 void wxPropertyGrid::OnMouseRightClickChild( wxMouseEvent
&event
)
5163 wxASSERT( m_wndEditor
);
5164 // These coords may not be exact (about +-2),
5165 // but that should not matter (right click is about item, not position).
5166 wxPoint pt
= m_wndEditor
->GetPosition();
5167 CalcUnscrolledPosition( event
.m_x
+ pt
.x
, event
.m_y
+ pt
.y
, &x
, &y
);
5169 // FIXME: Used to set m_propHover to selection here. Was it really
5172 bool res
= HandleMouseRightClick(x
,y
,event
);
5173 if ( !res
) event
.Skip();
5176 void wxPropertyGrid::OnMouseMoveChild( wxMouseEvent
&event
)
5179 if ( OnMouseChildCommon(event
,&x
,&y
) )
5181 bool res
= HandleMouseMove(x
,y
,event
);
5182 if ( !res
) event
.Skip();
5186 void wxPropertyGrid::OnMouseUpChild( wxMouseEvent
&event
)
5189 if ( OnMouseChildCommon(event
,&x
,&y
) )
5191 bool res
= HandleMouseUp(x
,y
,event
);
5192 if ( !res
) event
.Skip();
5196 // -----------------------------------------------------------------------
5197 // wxPropertyGrid keyboard event handling
5198 // -----------------------------------------------------------------------
5200 int wxPropertyGrid::KeyEventToActions(wxKeyEvent
&event
, int* pSecond
) const
5202 // Translates wxKeyEvent to wxPG_ACTION_XXX
5204 int keycode
= event
.GetKeyCode();
5205 int modifiers
= event
.GetModifiers();
5207 wxASSERT( !(modifiers
&~(0xFFFF)) );
5209 int hashMapKey
= (keycode
& 0xFFFF) | ((modifiers
& 0xFFFF) << 16);
5211 wxPGHashMapI2I::const_iterator it
= m_actionTriggers
.find(hashMapKey
);
5213 if ( it
== m_actionTriggers
.end() )
5218 int second
= (it
->second
>>16) & 0xFFFF;
5222 return (it
->second
& 0xFFFF);
5225 void wxPropertyGrid::AddActionTrigger( int action
, int keycode
, int modifiers
)
5227 wxASSERT( !(modifiers
&~(0xFFFF)) );
5229 int hashMapKey
= (keycode
& 0xFFFF) | ((modifiers
& 0xFFFF) << 16);
5231 wxPGHashMapI2I::iterator it
= m_actionTriggers
.find(hashMapKey
);
5233 if ( it
!= m_actionTriggers
.end() )
5235 // This key combination is already used
5237 // Can add secondary?
5238 wxASSERT_MSG( !(it
->second
&~(0xFFFF)),
5239 wxT("You can only add up to two separate actions per key combination.") );
5241 action
= it
->second
| (action
<<16);
5244 m_actionTriggers
[hashMapKey
] = action
;
5247 void wxPropertyGrid::ClearActionTriggers( int action
)
5249 wxPGHashMapI2I::iterator it
;
5254 didSomething
= false;
5256 for ( it
= m_actionTriggers
.begin();
5257 it
!= m_actionTriggers
.end();
5260 if ( it
->second
== action
)
5262 m_actionTriggers
.erase(it
);
5263 didSomething
= true;
5268 while ( didSomething
);
5271 void wxPropertyGrid::HandleKeyEvent( wxKeyEvent
&event
, bool fromChild
)
5274 // Handles key event when editor control is not focused.
5277 wxCHECK2(!m_frozen
, return);
5279 // Travelsal between items, collapsing/expanding, etc.
5280 wxPGProperty
* selected
= GetSelection();
5281 int keycode
= event
.GetKeyCode();
5282 bool editorFocused
= IsEditorFocused();
5284 if ( keycode
== WXK_TAB
)
5286 wxWindow
* mainControl
;
5288 if ( HasInternalFlag(wxPG_FL_IN_MANAGER
) )
5289 mainControl
= GetParent();
5293 if ( !event
.ShiftDown() )
5295 if ( !editorFocused
&& m_wndEditor
)
5297 DoSelectProperty( selected
, wxPG_SEL_FOCUS
);
5301 // Tab traversal workaround for platforms on which
5302 // wxWindow::Navigate() may navigate into first child
5303 // instead of next sibling. Does not work perfectly
5304 // in every scenario (for instance, when property grid
5305 // is either first or last control).
5306 #if defined(__WXGTK__)
5307 wxWindow
* sibling
= mainControl
->GetNextSibling();
5309 sibling
->SetFocusFromKbd();
5311 Navigate(wxNavigationKeyEvent::IsForward
);
5317 if ( editorFocused
)
5323 #if defined(__WXGTK__)
5324 wxWindow
* sibling
= mainControl
->GetPrevSibling();
5326 sibling
->SetFocusFromKbd();
5328 Navigate(wxNavigationKeyEvent::IsBackward
);
5336 // Ignore Alt and Control when they are down alone
5337 if ( keycode
== WXK_ALT
||
5338 keycode
== WXK_CONTROL
)
5345 int action
= KeyEventToActions(event
, &secondAction
);
5347 if ( editorFocused
&& action
== wxPG_ACTION_CANCEL_EDIT
)
5350 // Esc cancels any changes
5351 if ( IsEditorsValueModified() )
5353 EditorsValueWasNotModified();
5355 // Update the control as well
5356 selected
->GetEditorClass()->
5357 SetControlStringValue( selected
,
5359 selected
->GetDisplayedString() );
5362 OnValidationFailureReset(selected
);
5368 // Except for TAB and ESC, handle child control events in child control
5371 // Only propagate event if it had modifiers
5372 if ( !event
.HasModifiers() )
5374 event
.StopPropagation();
5380 bool wasHandled
= false;
5385 if ( ButtonTriggerKeyTest(action
, event
) )
5388 wxPGProperty
* p
= selected
;
5390 // Travel and expand/collapse
5393 if ( p
->GetChildCount() )
5395 if ( action
== wxPG_ACTION_COLLAPSE_PROPERTY
|| secondAction
== wxPG_ACTION_COLLAPSE_PROPERTY
)
5397 if ( (m_windowStyle
& wxPG_HIDE_MARGIN
) || Collapse(p
) )
5400 else if ( action
== wxPG_ACTION_EXPAND_PROPERTY
|| secondAction
== wxPG_ACTION_EXPAND_PROPERTY
)
5402 if ( (m_windowStyle
& wxPG_HIDE_MARGIN
) || Expand(p
) )
5409 if ( action
== wxPG_ACTION_PREV_PROPERTY
|| secondAction
== wxPG_ACTION_PREV_PROPERTY
)
5413 else if ( action
== wxPG_ACTION_NEXT_PROPERTY
|| secondAction
== wxPG_ACTION_NEXT_PROPERTY
)
5419 if ( selectDir
>= -1 )
5421 p
= wxPropertyGridIterator::OneStep( m_pState
, wxPG_ITERATE_VISIBLE
, p
, selectDir
);
5423 DoSelectProperty(p
);
5429 // If nothing was selected, select the first item now
5430 // (or navigate out of tab).
5431 if ( action
!= wxPG_ACTION_CANCEL_EDIT
&& secondAction
!= wxPG_ACTION_CANCEL_EDIT
)
5433 wxPGProperty
* p
= wxPropertyGridInterface::GetFirst();
5434 if ( p
) DoSelectProperty(p
);
5443 // -----------------------------------------------------------------------
5445 void wxPropertyGrid::OnKey( wxKeyEvent
&event
)
5447 // If there was editor open and focused, then this event should not
5448 // really be processed here.
5449 if ( IsEditorFocused() )
5451 // However, if event had modifiers, it is probably still best
5453 if ( event
.HasModifiers() )
5456 event
.StopPropagation();
5460 HandleKeyEvent(event
, false);
5463 // -----------------------------------------------------------------------
5465 bool wxPropertyGrid::ButtonTriggerKeyTest( int action
, wxKeyEvent
& event
)
5470 action
= KeyEventToActions(event
, &secondAction
);
5473 // Does the keycode trigger button?
5474 if ( action
== wxPG_ACTION_PRESS_BUTTON
&&
5477 wxCommandEvent
evt(wxEVT_COMMAND_BUTTON_CLICKED
, m_wndEditor2
->GetId());
5478 GetEventHandler()->AddPendingEvent(evt
);
5485 // -----------------------------------------------------------------------
5487 void wxPropertyGrid::OnChildKeyDown( wxKeyEvent
&event
)
5489 HandleKeyEvent(event
, true);
5492 // -----------------------------------------------------------------------
5493 // wxPropertyGrid miscellaneous event handling
5494 // -----------------------------------------------------------------------
5496 void wxPropertyGrid::OnIdle( wxIdleEvent
& WXUNUSED(event
) )
5499 // Check if the focus is in this control or one of its children
5500 wxWindow
* newFocused
= wxWindow::FindFocus();
5502 if ( newFocused
!= m_curFocused
)
5503 HandleFocusChange( newFocused
);
5506 // Check if top-level parent has changed
5507 if ( GetExtraStyle() & wxPG_EX_ENABLE_TLP_TRACKING
)
5509 wxWindow
* tlp
= ::wxGetTopLevelParent(this);
5515 bool wxPropertyGrid::IsEditorFocused() const
5517 wxWindow
* focus
= wxWindow::FindFocus();
5519 if ( focus
== m_wndEditor
|| focus
== m_wndEditor2
||
5520 focus
== GetEditorControl() )
5526 // Called by focus event handlers. newFocused is the window that becomes focused.
5527 void wxPropertyGrid::HandleFocusChange( wxWindow
* newFocused
)
5529 unsigned int oldFlags
= m_iFlags
;
5531 m_iFlags
&= ~(wxPG_FL_FOCUSED
);
5533 wxWindow
* parent
= newFocused
;
5535 // This must be one of nextFocus' parents.
5538 // Use m_eventObject, which is either wxPropertyGrid or
5539 // wxPropertyGridManager, as appropriate.
5540 if ( parent
== m_eventObject
)
5542 m_iFlags
|= wxPG_FL_FOCUSED
;
5545 parent
= parent
->GetParent();
5548 m_curFocused
= newFocused
;
5550 if ( (m_iFlags
& wxPG_FL_FOCUSED
) !=
5551 (oldFlags
& wxPG_FL_FOCUSED
) )
5553 if ( !(m_iFlags
& wxPG_FL_FOCUSED
) )
5555 // Need to store changed value
5556 CommitChangesFromEditor();
5562 // Preliminary code for tab-order respecting
5563 // tab-traversal (but should be moved to
5566 wxWindow* prevFocus = event.GetWindow();
5567 wxWindow* useThis = this;
5568 if ( m_iFlags & wxPG_FL_IN_MANAGER )
5569 useThis = GetParent();
5572 prevFocus->GetParent() == useThis->GetParent() )
5574 wxList& children = useThis->GetParent()->GetChildren();
5576 wxNode* node = children.Find(prevFocus);
5578 if ( node->GetNext() &&
5579 useThis == node->GetNext()->GetData() )
5580 DoSelectProperty(GetFirst());
5581 else if ( node->GetPrevious () &&
5582 useThis == node->GetPrevious()->GetData() )
5583 DoSelectProperty(GetLastProperty());
5590 wxPGProperty
* selected
= GetSelection();
5591 if ( selected
&& (m_iFlags
& wxPG_FL_INITIALIZED
) )
5592 DrawItem( selected
);
5596 void wxPropertyGrid::OnFocusEvent( wxFocusEvent
& event
)
5598 if ( event
.GetEventType() == wxEVT_SET_FOCUS
)
5599 HandleFocusChange((wxWindow
*)event
.GetEventObject());
5600 // Line changed to "else" when applying wxPropertyGrid patch #1675902
5601 //else if ( event.GetWindow() )
5603 HandleFocusChange(event
.GetWindow());
5608 // -----------------------------------------------------------------------
5610 void wxPropertyGrid::OnChildFocusEvent( wxChildFocusEvent
& event
)
5612 HandleFocusChange((wxWindow
*)event
.GetEventObject());
5616 // -----------------------------------------------------------------------
5618 void wxPropertyGrid::OnScrollEvent( wxScrollWinEvent
&event
)
5620 m_iFlags
|= wxPG_FL_SCROLLED
;
5625 // -----------------------------------------------------------------------
5627 void wxPropertyGrid::OnCaptureChange( wxMouseCaptureChangedEvent
& WXUNUSED(event
) )
5629 if ( m_iFlags
& wxPG_FL_MOUSE_CAPTURED
)
5631 m_iFlags
&= ~(wxPG_FL_MOUSE_CAPTURED
);
5635 // -----------------------------------------------------------------------
5636 // Property editor related functions
5637 // -----------------------------------------------------------------------
5639 // noDefCheck = true prevents infinite recursion.
5640 wxPGEditor
* wxPropertyGrid::DoRegisterEditorClass( wxPGEditor
* editorClass
,
5641 const wxString
& editorName
,
5644 wxASSERT( editorClass
);
5646 if ( !noDefCheck
&& wxPGGlobalVars
->m_mapEditorClasses
.empty() )
5647 RegisterDefaultEditors();
5649 wxString name
= editorName
;
5650 if ( name
.length() == 0 )
5651 name
= editorClass
->GetName();
5653 // Existing editor under this name?
5654 wxPGHashMapS2P::iterator vt_it
= wxPGGlobalVars
->m_mapEditorClasses
.find(name
);
5656 if ( vt_it
!= wxPGGlobalVars
->m_mapEditorClasses
.end() )
5658 // If this name was already used, try class name.
5659 name
= editorClass
->GetClassInfo()->GetClassName();
5660 vt_it
= wxPGGlobalVars
->m_mapEditorClasses
.find(name
);
5663 wxCHECK_MSG( vt_it
== wxPGGlobalVars
->m_mapEditorClasses
.end(),
5664 (wxPGEditor
*) vt_it
->second
,
5665 "Editor with given name was already registered" );
5667 wxPGGlobalVars
->m_mapEditorClasses
[name
] = (void*)editorClass
;
5672 // Use this in RegisterDefaultEditors.
5673 #define wxPGRegisterDefaultEditorClass(EDITOR) \
5674 if ( wxPGEditor_##EDITOR == NULL ) \
5676 wxPGEditor_##EDITOR = wxPropertyGrid::RegisterEditorClass( \
5677 new wxPG##EDITOR##Editor, true ); \
5680 // Registers all default editor classes
5681 void wxPropertyGrid::RegisterDefaultEditors()
5683 wxPGRegisterDefaultEditorClass( TextCtrl
);
5684 wxPGRegisterDefaultEditorClass( Choice
);
5685 wxPGRegisterDefaultEditorClass( ComboBox
);
5686 wxPGRegisterDefaultEditorClass( TextCtrlAndButton
);
5687 #if wxPG_INCLUDE_CHECKBOX
5688 wxPGRegisterDefaultEditorClass( CheckBox
);
5690 wxPGRegisterDefaultEditorClass( ChoiceAndButton
);
5692 // Register SpinCtrl etc. editors before use
5693 RegisterAdditionalEditors();
5696 // -----------------------------------------------------------------------
5697 // wxPGStringTokenizer
5698 // Needed to handle C-style string lists (e.g. "str1" "str2")
5699 // -----------------------------------------------------------------------
5701 wxPGStringTokenizer::wxPGStringTokenizer( const wxString
& str
, wxChar delimeter
)
5702 : m_str(&str
), m_curPos(str
.begin()), m_delimeter(delimeter
)
5706 wxPGStringTokenizer::~wxPGStringTokenizer()
5710 bool wxPGStringTokenizer::HasMoreTokens()
5712 const wxString
& str
= *m_str
;
5714 wxString::const_iterator i
= m_curPos
;
5716 wxUniChar delim
= m_delimeter
;
5718 wxUniChar prev_a
= wxT('\0');
5720 bool inToken
= false;
5722 while ( i
!= str
.end() )
5731 m_readyToken
.clear();
5736 if ( prev_a
!= wxT('\\') )
5740 if ( a
!= wxT('\\') )
5760 m_curPos
= str
.end();
5768 wxString
wxPGStringTokenizer::GetNextToken()
5770 return m_readyToken
;
5773 // -----------------------------------------------------------------------
5775 // -----------------------------------------------------------------------
5777 wxPGChoiceEntry::wxPGChoiceEntry()
5778 : wxPGCell(), m_value(wxPG_INVALID_VALUE
)
5782 // -----------------------------------------------------------------------
5784 // -----------------------------------------------------------------------
5786 wxPGChoicesData::wxPGChoicesData()
5790 wxPGChoicesData::~wxPGChoicesData()
5795 void wxPGChoicesData::Clear()
5800 void wxPGChoicesData::CopyDataFrom( wxPGChoicesData
* data
)
5802 wxASSERT( m_items
.size() == 0 );
5804 m_items
= data
->m_items
;
5807 wxPGChoiceEntry
& wxPGChoicesData::Insert( int index
,
5808 const wxPGChoiceEntry
& item
)
5810 wxVector
<wxPGChoiceEntry
>::iterator it
;
5814 index
= (int) m_items
.size();
5818 it
= m_items
.begin() + index
;
5821 m_items
.insert(it
, item
);
5823 wxPGChoiceEntry
& ownEntry
= m_items
[index
];
5825 // Need to fix value?
5826 if ( ownEntry
.GetValue() == wxPG_INVALID_VALUE
)
5827 ownEntry
.SetValue(index
);
5832 // -----------------------------------------------------------------------
5833 // wxPropertyGridEvent
5834 // -----------------------------------------------------------------------
5836 IMPLEMENT_DYNAMIC_CLASS(wxPropertyGridEvent
, wxCommandEvent
)
5839 wxDEFINE_EVENT( wxEVT_PG_SELECTED
, wxPropertyGridEvent
);
5840 wxDEFINE_EVENT( wxEVT_PG_CHANGING
, wxPropertyGridEvent
);
5841 wxDEFINE_EVENT( wxEVT_PG_CHANGED
, wxPropertyGridEvent
);
5842 wxDEFINE_EVENT( wxEVT_PG_HIGHLIGHTED
, wxPropertyGridEvent
);
5843 wxDEFINE_EVENT( wxEVT_PG_RIGHT_CLICK
, wxPropertyGridEvent
);
5844 wxDEFINE_EVENT( wxEVT_PG_PAGE_CHANGED
, wxPropertyGridEvent
);
5845 wxDEFINE_EVENT( wxEVT_PG_ITEM_EXPANDED
, wxPropertyGridEvent
);
5846 wxDEFINE_EVENT( wxEVT_PG_ITEM_COLLAPSED
, wxPropertyGridEvent
);
5847 wxDEFINE_EVENT( wxEVT_PG_DOUBLE_CLICK
, wxPropertyGridEvent
);
5848 wxDEFINE_EVENT( wxEVT_PG_LABEL_EDIT_BEGIN
, wxPropertyGridEvent
);
5849 wxDEFINE_EVENT( wxEVT_PG_LABEL_EDIT_ENDING
, wxPropertyGridEvent
);
5851 // -----------------------------------------------------------------------
5853 void wxPropertyGridEvent::Init()
5855 m_validationInfo
= NULL
;
5858 m_wasVetoed
= false;
5861 // -----------------------------------------------------------------------
5863 wxPropertyGridEvent::wxPropertyGridEvent(wxEventType commandType
, int id
)
5864 : wxCommandEvent(commandType
,id
)
5870 // -----------------------------------------------------------------------
5872 wxPropertyGridEvent::wxPropertyGridEvent(const wxPropertyGridEvent
& event
)
5873 : wxCommandEvent(event
)
5875 m_eventType
= event
.GetEventType();
5876 m_eventObject
= event
.m_eventObject
;
5878 OnPropertyGridSet();
5879 m_property
= event
.m_property
;
5880 m_validationInfo
= event
.m_validationInfo
;
5881 m_canVeto
= event
.m_canVeto
;
5882 m_wasVetoed
= event
.m_wasVetoed
;
5885 // -----------------------------------------------------------------------
5887 void wxPropertyGridEvent::OnPropertyGridSet()
5893 wxCriticalSectionLocker(wxPGGlobalVars
->m_critSect
);
5895 m_pg
->m_liveEvents
.push_back(this);
5898 // -----------------------------------------------------------------------
5900 wxPropertyGridEvent::~wxPropertyGridEvent()
5905 wxCriticalSectionLocker(wxPGGlobalVars
->m_critSect
);
5908 // Use iterate from the back since it is more likely that the event
5909 // being desroyed is at the end of the array.
5910 wxVector
<wxPropertyGridEvent
*>& liveEvents
= m_pg
->m_liveEvents
;
5912 for ( int i
= liveEvents
.size()-1; i
>= 0; i
-- )
5914 if ( liveEvents
[i
] == this )
5916 liveEvents
.erase(liveEvents
.begin() + i
);
5923 // -----------------------------------------------------------------------
5925 wxEvent
* wxPropertyGridEvent::Clone() const
5927 return new wxPropertyGridEvent( *this );
5930 // -----------------------------------------------------------------------
5931 // wxPropertyGridPopulator
5932 // -----------------------------------------------------------------------
5934 wxPropertyGridPopulator::wxPropertyGridPopulator()
5938 wxPGGlobalVars
->m_offline
++;
5941 // -----------------------------------------------------------------------
5943 void wxPropertyGridPopulator::SetState( wxPropertyGridPageState
* state
)
5946 m_propHierarchy
.clear();
5949 // -----------------------------------------------------------------------
5951 void wxPropertyGridPopulator::SetGrid( wxPropertyGrid
* pg
)
5957 // -----------------------------------------------------------------------
5959 wxPropertyGridPopulator::~wxPropertyGridPopulator()
5962 // Free unused sets of choices
5963 wxPGHashMapS2P::iterator it
;
5965 for( it
= m_dictIdChoices
.begin(); it
!= m_dictIdChoices
.end(); ++it
)
5967 wxPGChoicesData
* data
= (wxPGChoicesData
*) it
->second
;
5974 m_pg
->GetPanel()->Refresh();
5976 wxPGGlobalVars
->m_offline
--;
5979 // -----------------------------------------------------------------------
5981 wxPGProperty
* wxPropertyGridPopulator::Add( const wxString
& propClass
,
5982 const wxString
& propLabel
,
5983 const wxString
& propName
,
5984 const wxString
* propValue
,
5985 wxPGChoices
* pChoices
)
5987 wxClassInfo
* classInfo
= wxClassInfo::FindClass(propClass
);
5988 wxPGProperty
* parent
= GetCurParent();
5990 if ( parent
->HasFlag(wxPG_PROP_AGGREGATE
) )
5992 ProcessError(wxString::Format(wxT("new children cannot be added to '%s'"),parent
->GetName().c_str()));
5996 if ( !classInfo
|| !classInfo
->IsKindOf(CLASSINFO(wxPGProperty
)) )
5998 ProcessError(wxString::Format(wxT("'%s' is not valid property class"),propClass
.c_str()));
6002 wxPGProperty
* property
= (wxPGProperty
*) classInfo
->CreateObject();
6004 property
->SetLabel(propLabel
);
6005 property
->DoSetName(propName
);
6007 if ( pChoices
&& pChoices
->IsOk() )
6008 property
->SetChoices(*pChoices
);
6010 m_state
->DoInsert(parent
, -1, property
);
6013 property
->SetValueFromString( *propValue
, wxPG_FULL_VALUE
|
6014 wxPG_PROGRAMMATIC_VALUE
);
6019 // -----------------------------------------------------------------------
6021 void wxPropertyGridPopulator::AddChildren( wxPGProperty
* property
)
6023 m_propHierarchy
.push_back(property
);
6024 DoScanForChildren();
6025 m_propHierarchy
.pop_back();
6028 // -----------------------------------------------------------------------
6030 wxPGChoices
wxPropertyGridPopulator::ParseChoices( const wxString
& choicesString
,
6031 const wxString
& idString
)
6033 wxPGChoices choices
;
6036 if ( choicesString
[0] == wxT('@') )
6038 wxString ids
= choicesString
.substr(1);
6039 wxPGHashMapS2P::iterator it
= m_dictIdChoices
.find(ids
);
6040 if ( it
== m_dictIdChoices
.end() )
6041 ProcessError(wxString::Format(wxT("No choices defined for id '%s'"),ids
.c_str()));
6043 choices
.AssignData((wxPGChoicesData
*)it
->second
);
6048 if ( idString
.length() )
6050 wxPGHashMapS2P::iterator it
= m_dictIdChoices
.find(idString
);
6051 if ( it
!= m_dictIdChoices
.end() )
6053 choices
.AssignData((wxPGChoicesData
*)it
->second
);
6060 // Parse choices string
6061 wxString::const_iterator it
= choicesString
.begin();
6065 bool labelValid
= false;
6067 for ( ; it
!= choicesString
.end(); ++it
)
6073 if ( c
== wxT('"') )
6078 if ( !value
.ToLong(&l
, 0) ) l
= wxPG_INVALID_VALUE
;
6079 choices
.Add(label
, l
);
6082 //wxLogDebug(wxT("%s, %s"),label.c_str(),value.c_str());
6087 else if ( c
== wxT('=') )
6094 else if ( state
== 2 && (wxIsalnum(c
) || c
== wxT('x')) )
6101 if ( c
== wxT('"') )
6114 if ( !value
.ToLong(&l
, 0) ) l
= wxPG_INVALID_VALUE
;
6115 choices
.Add(label
, l
);
6118 if ( !choices
.IsOk() )
6120 choices
.EnsureData();
6124 if ( idString
.length() )
6125 m_dictIdChoices
[idString
] = choices
.GetData();
6132 // -----------------------------------------------------------------------
6134 bool wxPropertyGridPopulator::ToLongPCT( const wxString
& s
, long* pval
, long max
)
6136 if ( s
.Last() == wxT('%') )
6138 wxString s2
= s
.substr(0,s
.length()-1);
6140 if ( s2
.ToLong(&val
, 10) )
6142 *pval
= (val
*max
)/100;
6148 return s
.ToLong(pval
, 10);
6151 // -----------------------------------------------------------------------
6153 bool wxPropertyGridPopulator::AddAttribute( const wxString
& name
,
6154 const wxString
& type
,
6155 const wxString
& value
)
6157 int l
= m_propHierarchy
.size();
6161 wxPGProperty
* p
= m_propHierarchy
[l
-1];
6162 wxString valuel
= value
.Lower();
6165 if ( type
.length() == 0 )
6170 if ( valuel
== wxT("true") || valuel
== wxT("yes") || valuel
== wxT("1") )
6172 else if ( valuel
== wxT("false") || valuel
== wxT("no") || valuel
== wxT("0") )
6174 else if ( value
.ToLong(&v
, 0) )
6181 if ( type
== wxT("string") )
6185 else if ( type
== wxT("int") )
6188 value
.ToLong(&v
, 0);
6191 else if ( type
== wxT("bool") )
6193 if ( valuel
== wxT("true") || valuel
== wxT("yes") || valuel
== wxT("1") )
6200 ProcessError(wxString::Format(wxT("Invalid attribute type '%s'"),type
.c_str()));
6205 p
->SetAttribute( name
, variant
);
6210 // -----------------------------------------------------------------------
6212 void wxPropertyGridPopulator::ProcessError( const wxString
& msg
)
6214 wxLogError(_("Error in resource: %s"),msg
.c_str());
6217 // -----------------------------------------------------------------------
6219 #endif // wxUSE_PROPGRID