1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/propgrid/propgridpagestate.cpp
3 // Purpose: wxPropertyGridPageState class
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"
35 #include "wx/stopwatch.h"
38 // This define is necessary to prevent macro clearing
39 #define __wxPG_SOURCE_FILE__
41 #include "wx/propgrid/propgridpagestate.h"
42 #include "wx/propgrid/propgrid.h"
43 #include "wx/propgrid/editors.h"
45 #define wxPG_DEFAULT_SPLITTERX 110
48 // -----------------------------------------------------------------------
49 // wxPropertyGridIterator
50 // -----------------------------------------------------------------------
52 void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState
* state
, int flags
, wxPGProperty
* property
, int dir
)
54 wxASSERT( dir
== 1 || dir
== -1 );
57 m_baseParent
= state
->DoGetRoot();
58 if ( !property
&& m_baseParent
->GetChildCount() )
59 property
= m_baseParent
->Item(0);
61 m_property
= property
;
63 wxPG_ITERATOR_CREATE_MASKS(flags
, m_itemExMask
, m_parentExMask
)
65 // Need to skip first?
66 if ( property
&& (property
->GetFlags() & m_itemExMask
) )
75 void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState
* state
, int flags
, int startPos
, int dir
)
77 wxPGProperty
* property
= NULL
;
79 if ( startPos
== wxTOP
)
84 else if ( startPos
== wxBOTTOM
)
86 property
= state
->GetLastItem(flags
);
92 wxFAIL_MSG("Only supported starting positions are wxTOP and wxBOTTOM");
95 Init( state
, flags
, property
, dir
);
98 void wxPropertyGridIteratorBase::Assign( const wxPropertyGridIteratorBase
& it
)
100 m_property
= it
.m_property
;
101 m_state
= it
.m_state
;
102 m_baseParent
= it
.m_baseParent
;
103 m_itemExMask
= it
.m_itemExMask
;
104 m_parentExMask
= it
.m_parentExMask
;
107 void wxPropertyGridIteratorBase::Prev()
109 wxPGProperty
* property
= m_property
;
110 wxASSERT( property
);
112 wxPGProperty
* parent
= property
->GetParent();
114 unsigned int index
= property
->GetIndexInParent();
121 property
= parent
->Item(index
);
123 // Go to last children?
124 if ( property
->GetChildCount() &&
125 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) )
128 property
= property
->Last();
134 if ( parent
== m_baseParent
)
145 m_property
= property
;
147 // If property does not match our criteria, skip it
148 if ( property
->GetFlags() & m_itemExMask
)
152 void wxPropertyGridIteratorBase::Next( bool iterateChildren
)
154 wxPGProperty
* property
= m_property
;
155 wxASSERT( property
);
157 if ( property
->GetChildCount() &&
158 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) &&
162 property
= property
->Item(0);
166 wxPGProperty
* parent
= property
->GetParent();
168 unsigned int index
= property
->GetIndexInParent() + 1;
170 if ( index
< parent
->GetChildCount() )
173 property
= parent
->Item(index
);
177 // Next sibling of parent
178 if ( parent
== m_baseParent
)
191 m_property
= property
;
193 // If property does not match our criteria, skip it
194 if ( property
->GetFlags() & m_itemExMask
)
198 // -----------------------------------------------------------------------
199 // wxPropertyGridPageState
200 // -----------------------------------------------------------------------
202 wxPropertyGridPageState::wxPropertyGridPageState()
205 m_regularArray
.SetParentState(this);
206 m_properties
= &m_regularArray
;
208 m_currentCategory
= NULL
;
211 m_lastCaptionBottomnest
= 1;
215 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
216 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
217 m_fSplitterX
= wxPG_DEFAULT_SPLITTERX
;
219 // By default, we only have the 'value' column editable
220 m_editableColumns
.push_back(1);
223 // -----------------------------------------------------------------------
225 wxPropertyGridPageState::~wxPropertyGridPageState()
230 // -----------------------------------------------------------------------
232 void wxPropertyGridPageState::InitNonCatMode()
236 m_abcArray
= new wxPGRootProperty(wxS("<Root_NonCat>"));
237 m_abcArray
->SetParentState(this);
238 m_abcArray
->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES
);
241 // Must be called when state::m_properties still points to regularArray.
242 wxPGProperty
* oldProperties
= m_properties
;
244 // Must use temp value in state::m_properties for item iteration loop
245 // to run as expected.
246 m_properties
= &m_regularArray
;
248 if ( m_properties
->GetChildCount() )
251 // Prepare m_abcArray
252 wxPropertyGridIterator
it( this, wxPG_ITERATE_PROPERTIES
);
254 for ( ; !it
.AtEnd(); it
.Next() )
256 wxPGProperty
* p
= it
.GetProperty();
257 wxPGProperty
* parent
= p
->GetParent();
258 if ( parent
->IsCategory() || parent
->IsRoot() )
260 m_abcArray
->DoAddChild(p
);
261 p
->m_parent
= &m_regularArray
;
266 m_properties
= oldProperties
;
269 // -----------------------------------------------------------------------
271 void wxPropertyGridPageState::DoClear()
273 if ( m_pPropGrid
&& m_pPropGrid
->GetState() == this )
275 m_pPropGrid
->ClearSelection(false);
282 m_regularArray
.Empty();
288 m_currentCategory
= NULL
;
289 m_lastCaptionBottomnest
= 1;
296 // -----------------------------------------------------------------------
298 void wxPropertyGridPageState::CalculateFontAndBitmapStuff( int WXUNUSED(vspacing
) )
300 wxPropertyGrid
* propGrid
= GetGrid();
302 VirtualHeightChanged();
304 // Recalculate caption text extents.
307 for ( i
=0;i
<m_regularArray
.GetChildCount();i
++ )
309 wxPGProperty
* p
=m_regularArray
.Item(i
);
311 if ( p
->IsCategory() )
312 ((wxPropertyCategory
*)p
)->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
316 // -----------------------------------------------------------------------
318 void wxPropertyGridPageState::SetVirtualWidth( int width
)
320 wxASSERT( width
>= 0 );
321 wxPropertyGrid
* pg
= GetGrid();
322 int gw
= pg
->GetClientSize().x
;
329 // -----------------------------------------------------------------------
331 void wxPropertyGridPageState::OnClientWidthChange( int newWidth
, int widthChange
, bool fromOnResize
)
333 wxPropertyGrid
* pg
= GetGrid();
335 if ( pg
->HasVirtualWidth() )
337 if ( m_width
< newWidth
)
338 SetVirtualWidth( newWidth
);
340 CheckColumnWidths(widthChange
);
344 SetVirtualWidth( newWidth
);
346 // This should be done before splitter auto centering
347 // NOTE: Splitter auto-centering is done in this function.
350 CheckColumnWidths(widthChange
);
352 if ( !(GetGrid()->GetInternalFlags() & wxPG_FL_SPLITTER_PRE_SET
) &&
353 (GetGrid()->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER
) )
355 long timeSinceCreation
= (::wxGetLocalTimeMillis() - GetGrid()->m_timeCreated
).ToLong();
357 // If too long, don't set splitter
358 if ( timeSinceCreation
< 250 )
360 if ( m_properties
->GetChildCount() )
362 SetSplitterLeft( false );
366 DoSetSplitterPosition( newWidth
/ 2 );
367 GetGrid()->ClearInternalFlag(wxPG_FL_SPLITTER_PRE_SET
);
374 // -----------------------------------------------------------------------
375 // wxPropertyGridPageState item iteration methods
376 // -----------------------------------------------------------------------
378 wxPGProperty
* wxPropertyGridPageState::GetLastItem( int flags
)
380 if ( !m_properties
->GetChildCount() )
383 wxPG_ITERATOR_CREATE_MASKS(flags
, int itemExMask
, int parentExMask
)
385 // First, get last child of last parent
386 wxPGProperty
* pwc
= (wxPGProperty
*)m_properties
->Last();
387 while ( pwc
->GetChildCount() &&
388 wxPG_ITERATOR_PARENTEXMASK_TEST(pwc
, parentExMask
) )
389 pwc
= (wxPGProperty
*) pwc
->Last();
391 // Then, if it doesn't fit our criteria, back up until we find something that does
392 if ( pwc
->GetFlags() & itemExMask
)
394 wxPropertyGridIterator
it( this, flags
, pwc
);
395 for ( ; !it
.AtEnd(); it
.Prev() )
397 pwc
= (wxPGProperty
*) it
.GetProperty();
403 wxPropertyCategory
* wxPropertyGridPageState::GetPropertyCategory( const wxPGProperty
* p
) const
405 const wxPGProperty
* parent
= (const wxPGProperty
*)p
;
406 const wxPGProperty
* grandparent
= (const wxPGProperty
*)parent
->GetParent();
409 parent
= grandparent
;
410 grandparent
= (wxPGProperty
*)parent
->GetParent();
411 if ( parent
->IsCategory() && grandparent
)
412 return (wxPropertyCategory
*)parent
;
413 } while ( grandparent
);
418 // -----------------------------------------------------------------------
419 // wxPropertyGridPageState GetPropertyXXX methods
420 // -----------------------------------------------------------------------
422 wxPGProperty
* wxPropertyGridPageState::GetPropertyByLabel( const wxString
& label
,
423 wxPGProperty
* parent
) const
428 if ( !parent
) parent
= (wxPGProperty
*) &m_regularArray
;
430 for ( i
=0; i
<parent
->GetChildCount(); i
++ )
432 wxPGProperty
* p
= parent
->Item(i
);
433 if ( p
->m_label
== label
)
435 // Check children recursively.
436 if ( p
->GetChildCount() )
438 p
= GetPropertyByLabel(label
,(wxPGProperty
*)p
);
447 // -----------------------------------------------------------------------
449 wxPGProperty
* wxPropertyGridPageState::BaseGetPropertyByName( const wxString
& name
) const
451 wxPGHashMapS2P::const_iterator it
;
452 it
= m_dictName
.find(name
);
453 if ( it
!= m_dictName
.end() )
454 return (wxPGProperty
*) it
->second
;
458 // -----------------------------------------------------------------------
460 void wxPropertyGridPageState::DoSetPropertyName( wxPGProperty
* p
,
461 const wxString
& newName
)
463 wxCHECK_RET( p
, wxT("invalid property id") );
465 wxPGProperty
* parent
= p
->GetParent();
467 if ( parent
->IsCategory() || parent
->IsRoot() )
469 if ( p
->GetBaseName().length() )
470 m_dictName
.erase( p
->GetBaseName() );
471 if ( newName
.length() )
472 m_dictName
[newName
] = (void*) p
;
475 p
->DoSetName(newName
);
478 // -----------------------------------------------------------------------
479 // wxPropertyGridPageState global operations
480 // -----------------------------------------------------------------------
482 // -----------------------------------------------------------------------
483 // Item iteration macros
484 // NB: Nowadays only needed for alphabetic/categoric mode switching.
485 // -----------------------------------------------------------------------
487 //#define II_INVALID_I 0x00FFFFFF
489 #define ITEM_ITERATION_VARIABLES \
490 wxPGProperty* parent; \
494 #define ITEM_ITERATION_INIT_FROM_THE_TOP \
495 parent = m_properties; \
499 #define ITEM_ITERATION_INIT(startparent, startindex, state) \
500 parent = startparent; \
501 i = (unsigned int)startindex; \
502 if ( parent == NULL ) \
504 parent = state->m_properties; \
509 #define ITEM_ITERATION_LOOP_BEGIN \
512 iMax = parent->GetChildCount(); \
515 wxPGProperty* p = parent->Item(i);
517 #define ITEM_ITERATION_LOOP_END \
518 if ( p->GetChildCount() ) \
521 parent = (wxPGProperty*)p; \
522 iMax = parent->GetChildCount(); \
527 i = parent->m_arrIndex + 1; \
528 parent = parent->m_parent; \
530 while ( parent != NULL );
532 bool wxPropertyGridPageState::EnableCategories( bool enable
)
535 // NB: We can't use wxPropertyGridIterator in this
536 // function, since it depends on m_arrIndexes,
537 // which, among other things, is being fixed here.
539 ITEM_ITERATION_VARIABLES
547 if ( !IsInNonCatMode() )
550 m_properties
= &m_regularArray
;
552 // fix parents, indexes, and depths
553 ITEM_ITERATION_INIT_FROM_THE_TOP
555 ITEM_ITERATION_LOOP_BEGIN
559 p
->m_parent
= parent
;
561 // If parent was category, and this is not,
562 // then the depth stays the same.
563 if ( parent
->IsCategory() &&
565 p
->m_depth
= parent
->m_depth
;
567 p
->m_depth
= parent
->m_depth
+ 1;
569 ITEM_ITERATION_LOOP_END
575 // Disable categories
578 if ( IsInNonCatMode() )
581 // Create array, if necessary.
585 m_properties
= m_abcArray
;
587 // fix parents, indexes, and depths
588 ITEM_ITERATION_INIT_FROM_THE_TOP
590 ITEM_ITERATION_LOOP_BEGIN
594 p
->m_parent
= parent
;
596 p
->m_depth
= parent
->m_depth
+ 1;
598 ITEM_ITERATION_LOOP_END
601 VirtualHeightChanged();
603 if ( m_pPropGrid
->GetState() == this )
604 m_pPropGrid
->RecalculateVirtualSize();
609 // -----------------------------------------------------------------------
611 static int wxPG_SortFunc_ByFunction(wxPGProperty
**pp1
, wxPGProperty
**pp2
)
613 wxPGProperty
*p1
= *pp1
;
614 wxPGProperty
*p2
= *pp2
;
615 wxPropertyGrid
* pg
= p1
->GetGrid();
616 wxPGSortCallback sortFunction
= pg
->GetSortFunction();
617 return sortFunction(pg
, p1
, p2
);
620 static int wxPG_SortFunc_ByLabel(wxPGProperty
**pp1
, wxPGProperty
**pp2
)
622 wxPGProperty
*p1
= *pp1
;
623 wxPGProperty
*p2
= *pp2
;
624 return p1
->GetLabel().CmpNoCase( p2
->GetLabel() );
629 // For wxVector w/ wxUSE_STL=1, you would use code like this instead:
634 static bool wxPG_SortFunc_ByFunction(wxPGProperty
*p1
, wxPGProperty
*p2
)
636 wxPropertyGrid
* pg
= p1
->GetGrid();
637 wxPGSortCallback sortFunction
= pg
->GetSortFunction();
638 return sortFunction(pg
, p1
, p2
) < 0;
641 static bool wxPG_SortFunc_ByLabel(wxPGProperty
*p1
, wxPGProperty
*p2
)
643 return p1
->GetLabel().CmpNoCase( p2
->GetLabel() ) < 0;
647 void wxPropertyGridPageState::DoSortChildren( wxPGProperty
* p
,
653 // Can only sort items with children
654 if ( !p
->GetChildCount() )
657 // Never sort children of aggregate properties
658 if ( p
->HasFlag(wxPG_PROP_AGGREGATE
) )
661 if ( (flags
& wxPG_SORT_TOP_LEVEL_ONLY
)
662 && !p
->IsCategory() && !p
->IsRoot() )
665 if ( GetGrid()->GetSortFunction() )
666 p
->m_children
.Sort( wxPG_SortFunc_ByFunction
);
668 p
->m_children
.Sort( wxPG_SortFunc_ByLabel
);
672 // For wxVector w/ wxUSE_STL=1, you would use code like this instead:
674 if ( GetGrid()->GetSortFunction() )
675 std::sort(p
->m_children
.begin(), p
->m_children
.end(),
676 wxPG_SortFunc_ByFunction
);
678 std::sort(p
->m_children
.begin(), p
->m_children
.end(),
679 wxPG_SortFunc_ByLabel
);
683 p
->FixIndicesOfChildren();
685 if ( flags
& wxPG_RECURSE
)
687 // Apply sort recursively
688 for ( unsigned int i
=0; i
<p
->GetChildCount(); i
++ )
689 DoSortChildren(p
->Item(i
), flags
);
693 // -----------------------------------------------------------------------
695 void wxPropertyGridPageState::DoSort( int flags
)
697 DoSortChildren( m_properties
, flags
| wxPG_RECURSE
);
699 // We used to sort categories as well here also if in non-categorized
700 // mode, but doing would naturally cause child indices to become
704 // -----------------------------------------------------------------------
706 bool wxPropertyGridPageState::PrepareAfterItemsAdded()
708 if ( !m_itemsAdded
) return false;
710 wxPropertyGrid
* pg
= GetGrid();
714 if ( pg
->HasFlag(wxPG_AUTO_SORT
) )
715 DoSort(wxPG_SORT_TOP_LEVEL_ONLY
);
720 // -----------------------------------------------------------------------
721 // wxPropertyGridPageState splitter, column and hittest functions
722 // -----------------------------------------------------------------------
724 wxPGProperty
* wxPropertyGridPageState::DoGetItemAtY( int y
) const
731 return m_properties
->GetItemAtY(y
, GetGrid()->m_lineHeight
, &a
);
734 // -----------------------------------------------------------------------
736 wxPropertyGridHitTestResult
wxPropertyGridPageState::HitTest( const wxPoint
&pt
) const
738 wxPropertyGridHitTestResult result
;
739 result
.column
= HitTestH( pt
.x
, &result
.splitter
, &result
.splitterHitOffset
);
740 result
.property
= DoGetItemAtY( pt
.y
);
744 // -----------------------------------------------------------------------
746 // Used by SetSplitterLeft() and DotFitColumns()
747 int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC
& dc
,
752 wxPropertyGrid
* pg
= m_pPropGrid
;
757 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
759 wxPGProperty
* p
= pwc
->Item(i
);
760 if ( !p
->IsCategory() )
762 const wxPGCell
* cell
= NULL
;
764 p
->GetDisplayInfo(col
, -1, 0, &text
, &cell
);
765 dc
.GetTextExtent(text
, &w
, &h
);
767 w
+= ( ((int)p
->m_depth
-1) * pg
->m_subgroup_extramargin
);
770 // TODO: Add bitmap support.
772 w
+= (wxPG_XBEFORETEXT
*2);
778 if ( p
->GetChildCount() &&
779 ( subProps
|| p
->IsCategory() ) )
781 w
= GetColumnFitWidth( dc
, p
, col
, subProps
);
791 int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn
) const
793 int n
= GetGrid()->m_marginWidth
;
795 for ( i
=0; i
<=splitterColumn
; i
++ )
800 int wxPropertyGridPageState::GetColumnMinWidth( int WXUNUSED(column
) ) const
802 return wxPG_DRAG_MARGIN
;
805 void wxPropertyGridPageState::PropagateColSizeDec( int column
, int decrease
, int dir
)
807 int origWidth
= m_colWidths
[column
];
808 m_colWidths
[column
] -= decrease
;
809 int min
= GetColumnMinWidth(column
);
811 if ( m_colWidths
[column
] < min
)
813 more
= decrease
- (origWidth
- min
);
814 m_colWidths
[column
] = min
;
818 // FIXME: Causes erratic splitter changing, so as a workaround
819 // disabled if two or less columns.
821 if ( m_colWidths
.size() <= 2 )
825 if ( more
&& column
< (int)m_colWidths
.size() && column
>= 0 )
826 PropagateColSizeDec( column
, more
, dir
);
829 void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos
, int splitterColumn
, bool WXUNUSED(allPages
), bool fromAutoCenter
)
831 wxPropertyGrid
* pg
= GetGrid();
833 int adjust
= newXPos
- DoGetSplitterPosition(splitterColumn
);
835 if ( !pg
->HasVirtualWidth() )
841 otherColumn
= splitterColumn
+ 1;
842 if ( otherColumn
== (int)m_colWidths
.size() )
844 m_colWidths
[splitterColumn
] += adjust
;
845 PropagateColSizeDec( otherColumn
, adjust
, 1 );
849 otherColumn
= splitterColumn
+ 1;
850 if ( otherColumn
== (int)m_colWidths
.size() )
852 m_colWidths
[otherColumn
] -= adjust
;
853 PropagateColSizeDec( splitterColumn
, -adjust
, -1 );
858 m_colWidths
[splitterColumn
] += adjust
;
861 if ( splitterColumn
== 0 )
862 m_fSplitterX
= (double) newXPos
;
864 if ( !fromAutoCenter
)
866 // Don't allow initial splitter auto-positioning after this.
867 if ( pg
->GetState() == this )
868 pg
->SetInternalFlag(wxPG_FL_SPLITTER_PRE_SET
);
874 // Moves splitter so that all labels are visible, but just.
875 void wxPropertyGridPageState::SetSplitterLeft( bool subProps
)
877 wxPropertyGrid
* pg
= GetGrid();
879 dc
.SetFont(pg
->GetFont());
881 int maxW
= GetColumnFitWidth(dc
, m_properties
, 0, subProps
);
885 maxW
+= pg
->m_marginWidth
;
886 DoSetSplitterPosition( maxW
);
889 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
892 wxSize
wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize
) )
894 wxPropertyGrid
* pg
= GetGrid();
896 dc
.SetFont(pg
->GetFont());
898 int marginWidth
= pg
->m_marginWidth
;
899 int accWid
= marginWidth
;
900 int maxColWidth
= 500;
902 for ( unsigned int col
=0; col
< GetColumnCount(); col
++ )
904 int fitWid
= GetColumnFitWidth(dc
, m_properties
, col
, true);
905 int colMinWidth
= GetColumnMinWidth(col
);
906 if ( fitWid
< colMinWidth
)
907 fitWid
= colMinWidth
;
908 else if ( fitWid
> maxColWidth
)
909 fitWid
= maxColWidth
;
911 m_colWidths
[col
] = fitWid
;
916 // Expand last one to fill the width
917 int remaining
= m_width
- accWid
;
918 m_colWidths
[GetColumnCount()-1] += remaining
;
920 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
922 int firstSplitterX
= marginWidth
+ m_colWidths
[0];
923 m_fSplitterX
= (double) firstSplitterX
;
925 // Don't allow initial splitter auto-positioning after this.
926 if ( pg
->GetState() == this )
928 pg
->SetSplitterPosition(firstSplitterX
, false);
933 pg
->GetVirtualSize(&x
, &y
);
935 return wxSize(accWid
, y
);
938 void wxPropertyGridPageState::CheckColumnWidths( int widthChange
)
943 wxPropertyGrid
* pg
= GetGrid();
946 unsigned int lastColumn
= m_colWidths
.size() - 1;
948 int clientWidth
= pg
->GetClientSize().x
;
951 // Column to reduce, if needed. Take last one that exceeds minimum width.
954 wxLogTrace("propgrid",
955 wxS("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"),
960 for ( i
=0; i
<m_colWidths
.size(); i
++ )
962 int min
= GetColumnMinWidth(i
);
963 if ( m_colWidths
[i
] <= min
)
965 m_colWidths
[i
] = min
;
969 // Always reduce the last column that is larger than minimum size
970 // (looks nicer, even with auto-centering enabled).
975 int colsWidth
= pg
->m_marginWidth
;
976 for ( i
=0; i
<m_colWidths
.size(); i
++ )
977 colsWidth
+= m_colWidths
[i
];
979 wxLogTrace("propgrid",
980 wxS(" HasVirtualWidth: %i colsWidth: %i"),
981 (int)pg
->HasVirtualWidth(), colsWidth
);
983 // Then mode-based requirement
984 if ( !pg
->HasVirtualWidth() )
986 int widthHigher
= width
- colsWidth
;
988 // Adapt colsWidth to width
989 if ( colsWidth
< width
)
992 wxLogTrace("propgrid",
993 wxS(" Adjust last column to %i"),
994 m_colWidths
[lastColumn
] + widthHigher
);
995 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + widthHigher
;
997 else if ( colsWidth
> width
)
1000 if ( reduceCol
!= -1 )
1002 wxLogTrace("propgrid",
1003 wxT(" Reduce column %i (by %i)"),
1004 reduceCol
, -widthHigher
);
1006 // Reduce widest column, and recheck
1007 m_colWidths
[reduceCol
] = m_colWidths
[reduceCol
] + widthHigher
;
1008 CheckColumnWidths();
1014 // Only check colsWidth against clientWidth
1015 if ( colsWidth
< clientWidth
)
1017 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + (clientWidth
-colsWidth
);
1020 m_width
= colsWidth
;
1022 // If width changed, recalculate virtual size
1023 if ( pg
->GetState() == this )
1024 pg
->RecalculateVirtualSize();
1027 for ( i
=0; i
<m_colWidths
.size(); i
++ )
1029 wxLogTrace("propgrid", wxS("col%i: %i"), i
, m_colWidths
[i
]);
1032 // Auto center splitter
1033 if ( !(pg
->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER
) &&
1034 m_colWidths
.size() == 2 )
1036 float centerX
= (float)(pg
->m_width
/2);
1039 if ( m_fSplitterX
< 0.0 )
1041 splitterX
= centerX
;
1043 else if ( widthChange
)
1045 //float centerX = float(pg->GetSize().x) * 0.5;
1048 splitterX
= m_fSplitterX
+ (float(widthChange
) * 0.5);
1049 float deviation
= fabs(centerX
- splitterX
);
1051 // If deviating from center, adjust towards it
1052 if ( deviation
> 20.0 )
1054 if ( splitterX
> centerX
)
1062 // No width change, just keep sure we keep splitter position intact
1063 splitterX
= m_fSplitterX
;
1064 float deviation
= fabs(centerX
- splitterX
);
1065 if ( deviation
> 50.0 )
1067 splitterX
= centerX
;
1071 DoSetSplitterPosition((int)splitterX
, 0, false, true);
1073 m_fSplitterX
= splitterX
; // needed to retain accuracy
1077 void wxPropertyGridPageState::SetColumnCount( int colCount
)
1079 wxASSERT( colCount
>= 2 );
1080 m_colWidths
.SetCount( colCount
, wxPG_DRAG_MARGIN
);
1081 if ( m_colWidths
.size() > (unsigned int)colCount
)
1082 m_colWidths
.RemoveAt( m_colWidths
.size(), m_colWidths
.size() - colCount
);
1084 if ( m_pPropGrid
->GetState() == this )
1085 m_pPropGrid
->RecalculateVirtualSize();
1087 CheckColumnWidths();
1090 // Returns column index, -1 for margin
1091 int wxPropertyGridPageState::HitTestH( int x
, int* pSplitterHit
, int* pSplitterHitOffset
) const
1093 int cx
= GetGrid()->m_marginWidth
;
1095 int prevSplitter
= -1;
1100 if ( col
>= (int)m_colWidths
.size() )
1106 cx
+= m_colWidths
[col
];
1109 // Near prev. splitter
1112 int diff
= x
- prevSplitter
;
1113 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1115 *pSplitterHit
= col
- 1;
1116 *pSplitterHitOffset
= diff
;
1121 // Near next splitter
1122 int nextSplitter
= cx
;
1123 if ( col
< (int)(m_colWidths
.size()-1) )
1125 int diff
= x
- nextSplitter
;
1126 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1128 *pSplitterHit
= col
;
1129 *pSplitterHitOffset
= diff
;
1138 // -----------------------------------------------------------------------
1139 // wxPropertyGridPageState property value setting and getting
1140 // -----------------------------------------------------------------------
1142 bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty
* p
, const wxString
& value
)
1146 int flags
= wxPG_REPORT_ERROR
|wxPG_FULL_VALUE
|wxPG_PROGRAMMATIC_VALUE
;
1148 wxVariant variant
= p
->GetValueRef();
1151 if ( p
->GetMaxLength() <= 0 )
1152 res
= p
->StringToValue( variant
, value
, flags
);
1154 res
= p
->StringToValue( variant
, value
.Mid(0,p
->GetMaxLength()), flags
);
1158 p
->SetValue(variant
);
1159 if ( p
== m_pPropGrid
->GetSelection() &&
1160 this == m_pPropGrid
->GetState() )
1161 m_pPropGrid
->RefreshEditor();
1169 // -----------------------------------------------------------------------
1171 bool wxPropertyGridPageState::DoSetPropertyValue( wxPGProperty
* p
, wxVariant
& value
)
1176 if ( p
== m_pPropGrid
->GetSelection() &&
1177 this == m_pPropGrid
->GetState() )
1178 m_pPropGrid
->RefreshEditor();
1185 // -----------------------------------------------------------------------
1187 bool wxPropertyGridPageState::DoSetPropertyValueWxObjectPtr( wxPGProperty
* p
, wxObject
* value
)
1191 // wnd_primary has to be given so the control can be updated as well.
1193 DoSetPropertyValue(p
, v
);
1199 // -----------------------------------------------------------------------
1200 // wxPropertyGridPageState property operations
1201 // -----------------------------------------------------------------------
1203 bool wxPropertyGridPageState::DoIsPropertySelected( wxPGProperty
* prop
) const
1205 const wxArrayPGProperty
& selection
= m_selection
;
1207 for ( unsigned int i
=0; i
<selection
.size(); i
++ )
1209 if ( selection
[i
] == prop
)
1216 // -----------------------------------------------------------------------
1218 void wxPropertyGridPageState::DoRemoveFromSelection( wxPGProperty
* prop
)
1220 for ( unsigned int i
=0; i
<m_selection
.size(); i
++ )
1222 if ( m_selection
[i
] == prop
)
1224 wxPropertyGrid
* pg
= m_pPropGrid
;
1225 if ( i
== 0 && pg
->GetState() == this )
1227 // If first item (ie. one with the active editor) was
1228 // deselected, then we need to take some extra measures.
1229 wxArrayPGProperty sel
= m_selection
;
1230 sel
.erase( sel
.begin() + i
);
1232 wxPGProperty
* newFirst
;
1238 pg
->DoSelectProperty(newFirst
,
1239 wxPG_SEL_DONT_SEND_EVENT
);
1247 m_selection
.erase( m_selection
.begin() + i
);
1254 // -----------------------------------------------------------------------
1256 bool wxPropertyGridPageState::DoCollapse( wxPGProperty
* p
)
1258 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1260 if ( !p
->GetChildCount() ) return false;
1262 if ( !p
->IsExpanded() ) return false;
1264 p
->SetExpanded(false);
1266 VirtualHeightChanged();
1271 // -----------------------------------------------------------------------
1273 bool wxPropertyGridPageState::DoExpand( wxPGProperty
* p
)
1275 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1277 if ( !p
->GetChildCount() ) return false;
1279 if ( p
->IsExpanded() ) return false;
1281 p
->SetExpanded(true);
1283 VirtualHeightChanged();
1288 // -----------------------------------------------------------------------
1290 bool wxPropertyGridPageState::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
1292 if ( this == m_pPropGrid
->GetState() )
1293 return m_pPropGrid
->DoSelectProperty( p
, flags
);
1299 // -----------------------------------------------------------------------
1301 bool wxPropertyGridPageState::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
1304 p
->ClearFlag( wxPG_PROP_HIDDEN
);
1306 p
->SetFlag( wxPG_PROP_HIDDEN
);
1308 if ( flags
& wxPG_RECURSE
)
1311 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1312 DoHideProperty(p
->Item(i
), hide
, flags
| wxPG_RECURSE_STARTS
);
1315 VirtualHeightChanged();
1320 // -----------------------------------------------------------------------
1322 bool wxPropertyGridPageState::DoEnableProperty( wxPGProperty
* p
, bool enable
)
1328 if ( !(p
->m_flags
& wxPG_PROP_DISABLED
) )
1333 p
->m_flags
&= ~(wxPG_PROP_DISABLED
);
1337 if ( p
->m_flags
& wxPG_PROP_DISABLED
)
1342 p
->m_flags
|= wxPG_PROP_DISABLED
;
1346 // Apply same to sub-properties as well
1348 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1349 DoEnableProperty( p
->Item(i
), enable
);
1356 // -----------------------------------------------------------------------
1357 // wxPropertyGridPageState wxVariant related routines
1358 // -----------------------------------------------------------------------
1360 // Returns list of wxVariant objects (non-categories and non-sub-properties only).
1361 // Never includes sub-properties (unless they are parented by wxParentProperty).
1362 wxVariant
wxPropertyGridPageState::DoGetPropertyValues( const wxString
& listname
,
1363 wxPGProperty
* baseparent
,
1366 wxPGProperty
* pwc
= (wxPGProperty
*) baseparent
;
1368 // Root is the default base-parent.
1372 wxVariantList tempList
;
1373 wxVariant
v( tempList
, listname
);
1375 if ( pwc
->GetChildCount() )
1377 if ( flags
& wxPG_KEEP_STRUCTURE
)
1379 wxASSERT( !pwc
->HasFlag(wxPG_PROP_AGGREGATE
) );
1382 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1384 wxPGProperty
* p
= pwc
->Item(i
);
1385 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1387 wxVariant variant
= p
->GetValue();
1388 variant
.SetName( p
->GetBaseName() );
1389 v
.Append( variant
);
1393 v
.Append( DoGetPropertyValues(p
->m_name
,p
,flags
|wxPG_KEEP_STRUCTURE
) );
1395 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1396 v
.Append( p
->GetAttributesAsList() );
1401 wxPropertyGridConstIterator
it( this, wxPG_ITERATE_DEFAULT
, pwc
->Item(0) );
1402 it
.SetBaseParent( pwc
);
1404 for ( ; !it
.AtEnd(); it
.Next() )
1406 const wxPGProperty
* p
= it
.GetProperty();
1408 // Use a trick to ignore wxParentProperty itself, but not its sub-properties.
1409 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1411 wxVariant variant
= p
->GetValue();
1412 variant
.SetName( p
->GetName() );
1413 v
.Append( variant
);
1414 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1415 v
.Append( p
->GetAttributesAsList() );
1424 // -----------------------------------------------------------------------
1426 void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList
& list
, wxPGProperty
* defaultCategory
)
1428 unsigned char origFrozen
= 1;
1430 if ( m_pPropGrid
->GetState() == this )
1432 origFrozen
= m_pPropGrid
->m_frozen
;
1433 if ( !origFrozen
) m_pPropGrid
->Freeze();
1436 wxPropertyCategory
* use_category
= (wxPropertyCategory
*)defaultCategory
;
1438 if ( !use_category
)
1439 use_category
= (wxPropertyCategory
*)m_properties
;
1441 // Let's iterate over the list of variants.
1442 wxVariantList::const_iterator node
;
1443 int numSpecialEntries
= 0;
1446 // Second pass for special entries
1447 for ( node
= list
.begin(); node
!= list
.end(); ++node
)
1449 wxVariant
*current
= (wxVariant
*)*node
;
1451 // Make sure it is wxVariant.
1452 wxASSERT( current
);
1453 wxASSERT( wxStrcmp(current
->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
1455 const wxString
& name
= current
->GetName();
1456 if ( name
.length() > 0 )
1459 // '@' signified a special entry
1460 if ( name
[0] == wxS('@') )
1462 numSpecialEntries
++;
1466 wxPGProperty
* foundProp
= BaseGetPropertyByName(name
);
1469 wxPGProperty
* p
= foundProp
;
1471 // If it was a list, we still have to go through it.
1472 if ( wxStrcmp(current
->GetType(), wxS("list")) == 0 )
1474 DoSetPropertyValues( current
->GetList(),
1475 p
->IsCategory()?p
:(NULL
)
1480 wxASSERT_LEVEL_2_MSG(
1481 wxStrcmp(current
->GetType(), p
->GetValue().GetType()) == 0,
1483 wxS("setting value of property \"%s\" from variant"),
1484 p
->GetName().c_str())
1487 p
->SetValue(*current
);
1493 if ( current
->GetType() != wxS("list") )
1499 // Yes, it is; create a sub category and append contents there.
1500 wxPGProperty
* newCat
= DoInsert(use_category
,-1,new wxPropertyCategory(current
->GetName(),wxPG_LABEL
));
1501 DoSetPropertyValues( current
->GetList(), newCat
);
1508 if ( numSpecialEntries
)
1510 for ( node
= list
.begin(); node
!= list
.end(); ++node
)
1512 wxVariant
*current
= (wxVariant
*)*node
;
1514 const wxString
& name
= current
->GetName();
1515 if ( name
.length() > 0 )
1518 // '@' signified a special entry
1519 if ( name
[0] == wxS('@') )
1521 numSpecialEntries
--;
1523 size_t pos2
= name
.rfind(wxS('@'));
1524 if ( pos2
> 0 && pos2
< (name
.size()-1) )
1526 wxString propName
= name
.substr(1, pos2
-1);
1527 wxString entryType
= name
.substr(pos2
+1, wxString::npos
);
1529 if ( entryType
== wxS("attr") )
1532 // List of attributes
1533 wxPGProperty
* foundProp
= BaseGetPropertyByName(propName
);
1536 wxASSERT( current
->GetType() == wxPG_VARIANT_TYPE_LIST
);
1538 wxVariantList
& list2
= current
->GetList();
1539 wxVariantList::const_iterator node2
;
1541 for ( node2
= list2
.begin(); node2
!= list2
.end(); ++node2
)
1543 wxVariant
*attr
= (wxVariant
*)*node2
;
1544 foundProp
->SetAttribute( attr
->GetName(), *attr
);
1549 // ERROR: No such property: 'propName'
1555 // ERROR: Special entry requires name of format @<propname>@<entrytype>
1560 if ( !numSpecialEntries
)
1567 m_pPropGrid
->Thaw();
1569 if ( this == m_pPropGrid
->GetState() )
1570 m_pPropGrid
->RefreshEditor();
1575 // -----------------------------------------------------------------------
1576 // wxPropertyGridPageState property adding and removal
1577 // -----------------------------------------------------------------------
1579 bool wxPropertyGridPageState::PrepareToAddItem( wxPGProperty
* property
,
1580 wxPGProperty
* scheduledParent
)
1582 wxPropertyGrid
* propGrid
= m_pPropGrid
;
1584 // This will allow better behavior.
1585 if ( scheduledParent
== m_properties
)
1586 scheduledParent
= NULL
;
1588 if ( scheduledParent
&& !scheduledParent
->IsCategory() )
1590 wxASSERT_MSG( property
->GetBaseName().length(),
1591 "Property's children must have unique, non-empty names within their scope" );
1594 property
->m_parentState
= this;
1596 if ( property
->IsCategory() )
1599 // Parent of a category must be either root or another category
1600 // (otherwise Bad Things might happen).
1601 wxASSERT_MSG( scheduledParent
== NULL
||
1602 scheduledParent
== m_properties
||
1603 scheduledParent
->IsCategory(),
1604 wxT("Parent of a category must be either root or another category."));
1606 // If we already have category with same name, delete given property
1607 // and use it instead as most recent caption item.
1608 wxPGProperty
* found_id
= BaseGetPropertyByName( property
->GetBaseName() );
1611 wxPropertyCategory
* pwc
= (wxPropertyCategory
*) found_id
;
1612 if ( pwc
->IsCategory() ) // Must be a category.
1615 m_currentCategory
= pwc
;
1622 // Warn for identical names in debug mode.
1623 if ( BaseGetPropertyByName(property
->GetName()) &&
1624 (!scheduledParent
|| scheduledParent
->IsCategory()) )
1626 wxFAIL_MSG(wxString::Format(
1627 "wxPropertyGrid item with name \"%s\" already exists",
1628 property
->GetName()));
1630 wxPGGlobalVars
->m_warnings
++;
1632 #endif // wxDEBUG_LEVEL
1634 // Make sure nothing is selected.
1636 propGrid
->ClearSelection(false);
1638 // NULL parent == root parent
1639 if ( !scheduledParent
)
1640 scheduledParent
= DoGetRoot();
1642 property
->m_parent
= scheduledParent
;
1644 property
->InitAfterAdded(this, propGrid
);
1646 if ( property
->IsCategory() )
1648 wxPropertyCategory
* pc
= wxStaticCast(property
, wxPropertyCategory
);
1650 m_currentCategory
= pc
;
1652 // Calculate text extent for category caption
1654 pc
->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
1660 // -----------------------------------------------------------------------
1662 wxPGProperty
* wxPropertyGridPageState::DoAppend( wxPGProperty
* property
)
1664 wxPropertyCategory
* cur_cat
= m_currentCategory
;
1665 if ( property
->IsCategory() )
1668 return DoInsert( cur_cat
, -1, property
);
1671 // -----------------------------------------------------------------------
1673 wxPGProperty
* wxPropertyGridPageState::DoInsert( wxPGProperty
* parent
, int index
, wxPGProperty
* property
)
1676 parent
= m_properties
;
1678 wxCHECK_MSG( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1680 wxT("when adding properties to fixed parents, use BeginAddChildren and EndAddChildren.") );
1682 bool res
= PrepareToAddItem( property
, (wxPropertyCategory
*)parent
);
1684 // PrepareToAddItem() may just decide to use use current category
1685 // instead of adding new one.
1687 return m_currentCategory
;
1689 bool parentIsRoot
= parent
->IsRoot();
1690 bool parentIsCategory
= parent
->IsCategory();
1692 // Note that item must be added into current mode later.
1694 // If parent is wxParentProperty, just stick it in...
1695 // If parent is root (m_properties), then...
1696 // In categoric mode: Add as last item in m_abcArray (if not category).
1697 // Add to given index in m_regularArray.
1698 // In non-cat mode: Add as last item in m_regularArray.
1699 // Add to given index in m_abcArray.
1700 // If parent is category, then...
1701 // 1) Add to given category in given index.
1702 // 2) Add as last item in m_abcArray.
1704 if ( m_properties
== &m_regularArray
)
1706 // We are currently in Categorized mode
1708 // Only add non-categories to m_abcArray.
1709 if ( m_abcArray
&& !property
->IsCategory() &&
1710 (parentIsCategory
|| parentIsRoot
) )
1712 m_abcArray
->DoAddChild( property
, -1, false );
1715 // Add to current mode.
1716 parent
->DoAddChild( property
, index
, true );
1720 // We are currently in Non-categorized/Alphabetic mode
1722 if ( parentIsCategory
)
1723 // Parent is category.
1724 parent
->DoAddChild( property
, index
, false );
1725 else if ( parentIsRoot
)
1727 m_regularArray
.DoAddChild( property
, -1, false );
1729 // Add to current mode
1730 if ( !property
->IsCategory() )
1731 m_abcArray
->DoAddChild( property
, index
, true );
1735 if ( property
->IsCategory() )
1737 // This is a category caption item.
1739 // Last caption is not the bottom one (this info required by append)
1740 m_lastCaptionBottomnest
= 0;
1743 // Only add name to hashmap if parent is root or category
1744 if ( property
->m_name
.length() &&
1745 (parentIsCategory
|| parentIsRoot
) )
1746 m_dictName
[property
->m_name
] = (void*) property
;
1748 VirtualHeightChanged();
1750 property
->UpdateParentValues();
1757 // -----------------------------------------------------------------------
1759 void wxPropertyGridPageState::DoDelete( wxPGProperty
* item
, bool doDelete
)
1761 wxCHECK_RET( item
->GetParent(),
1762 wxT("this property was already deleted") );
1764 wxCHECK_RET( item
!= &m_regularArray
&& item
!= m_abcArray
,
1765 wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
1767 unsigned int indinparent
= item
->GetIndexInParent();
1769 wxPGProperty
* pwc
= (wxPGProperty
*)item
;
1770 wxPGProperty
* parent
= item
->GetParent();
1772 wxCHECK_RET( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1773 wxT("wxPropertyGrid: Do not attempt to remove sub-properties.") );
1775 wxASSERT( item
->GetParentState() == this );
1777 wxPropertyGrid
* pg
= GetGrid();
1779 if ( DoIsPropertySelected(item
) )
1781 if ( pg
&& pg
->GetState() == this )
1783 pg
->DoRemoveFromSelection(item
,
1784 wxPG_SEL_DELETING
|wxPG_SEL_NOVALIDATE
);
1788 DoRemoveFromSelection(item
);
1792 item
->SetFlag(wxPG_PROP_BEING_DELETED
);
1795 if ( item
->GetChildCount() && !item
->HasFlag(wxPG_PROP_AGGREGATE
) )
1797 // deleting a category
1798 if ( item
->IsCategory() )
1800 if ( pwc
== m_currentCategory
)
1801 m_currentCategory
= NULL
;
1804 item
->DeleteChildren();
1807 if ( !IsInNonCatMode() )
1809 // categorized mode - non-categorized array
1811 // Remove from non-cat array
1812 if ( !item
->IsCategory() &&
1813 (parent
->IsCategory() || parent
->IsRoot()) )
1816 m_abcArray
->RemoveChild(item
);
1819 // categorized mode - categorized array
1820 wxArrayPGProperty
& parentsChildren
= parent
->m_children
;
1821 parentsChildren
.erase( parentsChildren
.begin() + indinparent
);
1822 item
->m_parent
->FixIndicesOfChildren();
1826 // non-categorized mode - categorized array
1828 // We need to find location of item.
1829 wxPGProperty
* cat_parent
= &m_regularArray
;
1830 int cat_index
= m_regularArray
.GetChildCount();
1832 for ( i
= 0; i
< m_regularArray
.GetChildCount(); i
++ )
1834 wxPGProperty
* p
= m_regularArray
.Item(i
);
1835 if ( p
== item
) { cat_index
= i
; break; }
1836 if ( p
->IsCategory() )
1838 int subind
= ((wxPGProperty
*)p
)->Index(item
);
1839 if ( subind
!= wxNOT_FOUND
)
1841 cat_parent
= ((wxPGProperty
*)p
);
1847 cat_parent
->m_children
.erase(cat_parent
->m_children
.begin()+cat_index
);
1849 // non-categorized mode - non-categorized array
1850 if ( !item
->IsCategory() )
1852 wxASSERT( item
->m_parent
== m_abcArray
);
1853 wxArrayPGProperty
& parentsChildren
= item
->m_parent
->m_children
;
1854 parentsChildren
.erase(parentsChildren
.begin() + indinparent
);
1855 item
->m_parent
->FixIndicesOfChildren(indinparent
);
1859 if ( item
->GetBaseName().length() &&
1860 (parent
->IsCategory() || parent
->IsRoot()) )
1861 m_dictName
.erase(item
->GetBaseName());
1863 // We need to clear parent grid's m_propHover, if it matches item
1864 if ( pg
&& pg
->m_propHover
== item
)
1865 pg
->m_propHover
= NULL
;
1867 // We can actually delete it now
1871 m_itemsAdded
= 1; // Not a logical assignment (but required nonetheless).
1873 VirtualHeightChanged();
1876 // -----------------------------------------------------------------------
1878 #endif // wxUSE_PROPGRID