1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/propgrid/propgridpagestate.cpp
3 // Purpose: wxPropertyGridPageState class
4 // Author: Jaakko Salli
8 // Copyright: (c) Jaakko Salli
9 // Licence: wxWindows licence
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
;
113 wxPGProperty
* parent
= property
->GetParent();
115 unsigned int index
= property
->GetIndexInParent();
122 property
= parent
->Item(index
);
124 // Go to last children?
125 if ( property
->GetChildCount() &&
126 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) )
129 property
= property
->Last();
135 if ( parent
== m_baseParent
)
146 m_property
= property
;
148 // If property does not match our criteria, skip it
149 if ( property
->GetFlags() & m_itemExMask
)
153 void wxPropertyGridIteratorBase::Next( bool iterateChildren
)
155 wxPGProperty
* property
= m_property
;
159 if ( property
->GetChildCount() &&
160 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) &&
164 property
= property
->Item(0);
168 wxPGProperty
* parent
= property
->GetParent();
170 unsigned int index
= property
->GetIndexInParent() + 1;
172 if ( index
< parent
->GetChildCount() )
175 property
= parent
->Item(index
);
179 // Next sibling of parent
180 if ( parent
== m_baseParent
)
193 m_property
= property
;
195 // If property does not match our criteria, skip it
196 if ( property
->GetFlags() & m_itemExMask
)
200 // -----------------------------------------------------------------------
201 // wxPropertyGridPageState
202 // -----------------------------------------------------------------------
204 wxPropertyGridPageState::wxPropertyGridPageState()
207 m_regularArray
.SetParentState(this);
208 m_properties
= &m_regularArray
;
210 m_currentCategory
= NULL
;
213 m_lastCaptionBottomnest
= 1;
217 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
218 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
219 m_fSplitterX
= wxPG_DEFAULT_SPLITTERX
;
221 m_columnProportions
.push_back(1);
222 m_columnProportions
.push_back(1);
224 m_isSplitterPreSet
= false;
225 m_dontCenterSplitter
= false;
227 // By default, we only have the 'value' column editable
228 m_editableColumns
.push_back(1);
231 // -----------------------------------------------------------------------
233 wxPropertyGridPageState::~wxPropertyGridPageState()
238 // -----------------------------------------------------------------------
240 void wxPropertyGridPageState::InitNonCatMode()
244 m_abcArray
= new wxPGRootProperty(wxS("<Root_NonCat>"));
245 m_abcArray
->SetParentState(this);
246 m_abcArray
->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES
);
249 // Must be called when state::m_properties still points to regularArray.
250 wxPGProperty
* oldProperties
= m_properties
;
252 // Must use temp value in state::m_properties for item iteration loop
253 // to run as expected.
254 m_properties
= &m_regularArray
;
256 if ( m_properties
->GetChildCount() )
259 // Prepare m_abcArray
260 wxPropertyGridIterator
it( this, wxPG_ITERATE_PROPERTIES
);
262 for ( ; !it
.AtEnd(); it
.Next() )
264 wxPGProperty
* p
= it
.GetProperty();
265 wxPGProperty
* parent
= p
->GetParent();
266 if ( parent
->IsCategory() || parent
->IsRoot() )
268 m_abcArray
->DoAddChild(p
);
269 p
->m_parent
= &m_regularArray
;
274 m_properties
= oldProperties
;
277 // -----------------------------------------------------------------------
279 void wxPropertyGridPageState::DoClear()
281 if ( m_pPropGrid
&& m_pPropGrid
->GetState() == this )
283 m_pPropGrid
->ClearSelection(false);
290 m_regularArray
.Empty();
296 m_currentCategory
= NULL
;
297 m_lastCaptionBottomnest
= 1;
304 // -----------------------------------------------------------------------
306 void wxPropertyGridPageState::CalculateFontAndBitmapStuff( int WXUNUSED(vspacing
) )
308 wxPropertyGrid
* propGrid
= GetGrid();
310 VirtualHeightChanged();
312 // Recalculate caption text extents.
315 for ( i
=0;i
<m_regularArray
.GetChildCount();i
++ )
317 wxPGProperty
* p
=m_regularArray
.Item(i
);
319 if ( p
->IsCategory() )
320 ((wxPropertyCategory
*)p
)->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
324 // -----------------------------------------------------------------------
326 void wxPropertyGridPageState::SetVirtualWidth( int width
)
328 // Sometimes width less than 0 is offered. Let's make things easy for
329 // everybody and deal with it here.
333 wxPropertyGrid
* pg
= GetGrid();
334 int gw
= pg
->GetClientSize().x
;
341 // -----------------------------------------------------------------------
343 void wxPropertyGridPageState::OnClientWidthChange( int newWidth
, int widthChange
, bool fromOnResize
)
345 wxPropertyGrid
* pg
= GetGrid();
347 if ( pg
->HasVirtualWidth() )
349 if ( m_width
< newWidth
)
350 SetVirtualWidth( newWidth
);
352 CheckColumnWidths(widthChange
);
356 SetVirtualWidth( newWidth
);
358 // This should be done before splitter auto centering
359 // NOTE: Splitter auto-centering is done in this function.
362 CheckColumnWidths(widthChange
);
364 if ( !m_isSplitterPreSet
&& m_dontCenterSplitter
)
366 long timeSinceCreation
= (::wxGetLocalTimeMillis() - GetGrid()->m_timeCreated
).ToLong();
368 // If too long, don't set splitter
369 if ( timeSinceCreation
< 250 )
371 if ( m_properties
->GetChildCount() )
373 SetSplitterLeft( false );
377 DoSetSplitterPosition( newWidth
/ 2 );
378 m_isSplitterPreSet
= false;
385 // -----------------------------------------------------------------------
386 // wxPropertyGridPageState item iteration methods
387 // -----------------------------------------------------------------------
389 wxPGProperty
* wxPropertyGridPageState::GetLastItem( int flags
)
391 if ( !m_properties
->GetChildCount() )
394 wxPG_ITERATOR_CREATE_MASKS(flags
, int itemExMask
, int parentExMask
)
396 // First, get last child of last parent
397 wxPGProperty
* pwc
= (wxPGProperty
*)m_properties
->Last();
398 while ( pwc
->GetChildCount() &&
399 wxPG_ITERATOR_PARENTEXMASK_TEST(pwc
, parentExMask
) )
400 pwc
= (wxPGProperty
*) pwc
->Last();
402 // Then, if it doesn't fit our criteria, back up until we find something that does
403 if ( pwc
->GetFlags() & itemExMask
)
405 wxPropertyGridIterator
it( this, flags
, pwc
);
406 for ( ; !it
.AtEnd(); it
.Prev() )
408 pwc
= (wxPGProperty
*) it
.GetProperty();
414 wxPropertyCategory
* wxPropertyGridPageState::GetPropertyCategory( const wxPGProperty
* p
) const
416 const wxPGProperty
* parent
= (const wxPGProperty
*)p
;
417 const wxPGProperty
* grandparent
= (const wxPGProperty
*)parent
->GetParent();
420 parent
= grandparent
;
421 grandparent
= (wxPGProperty
*)parent
->GetParent();
422 if ( parent
->IsCategory() && grandparent
)
423 return (wxPropertyCategory
*)parent
;
424 } while ( grandparent
);
429 // -----------------------------------------------------------------------
430 // wxPropertyGridPageState GetPropertyXXX methods
431 // -----------------------------------------------------------------------
433 wxPGProperty
* wxPropertyGridPageState::GetPropertyByLabel( const wxString
& label
,
434 wxPGProperty
* parent
) const
439 if ( !parent
) parent
= (wxPGProperty
*) &m_regularArray
;
441 for ( i
=0; i
<parent
->GetChildCount(); i
++ )
443 wxPGProperty
* p
= parent
->Item(i
);
444 if ( p
->m_label
== label
)
446 // Check children recursively.
447 if ( p
->GetChildCount() )
449 p
= GetPropertyByLabel(label
,(wxPGProperty
*)p
);
458 // -----------------------------------------------------------------------
460 wxPGProperty
* wxPropertyGridPageState::BaseGetPropertyByName( const wxString
& name
) const
462 wxPGHashMapS2P::const_iterator it
;
463 it
= m_dictName
.find(name
);
464 if ( it
!= m_dictName
.end() )
465 return (wxPGProperty
*) it
->second
;
469 // -----------------------------------------------------------------------
471 void wxPropertyGridPageState::DoSetPropertyName( wxPGProperty
* p
,
472 const wxString
& newName
)
474 wxCHECK_RET( p
, wxT("invalid property id") );
476 wxPGProperty
* parent
= p
->GetParent();
478 if ( parent
->IsCategory() || parent
->IsRoot() )
480 if ( p
->GetBaseName().length() )
481 m_dictName
.erase( p
->GetBaseName() );
482 if ( newName
.length() )
483 m_dictName
[newName
] = (void*) p
;
486 p
->DoSetName(newName
);
489 // -----------------------------------------------------------------------
490 // wxPropertyGridPageState global operations
491 // -----------------------------------------------------------------------
493 // -----------------------------------------------------------------------
494 // Item iteration macros
495 // NB: Nowadays only needed for alphabetic/categoric mode switching.
496 // -----------------------------------------------------------------------
498 //#define II_INVALID_I 0x00FFFFFF
500 #define ITEM_ITERATION_VARIABLES \
501 wxPGProperty* parent; \
505 #define ITEM_ITERATION_INIT_FROM_THE_TOP \
506 parent = m_properties; \
510 #define ITEM_ITERATION_INIT(startparent, startindex, state) \
511 parent = startparent; \
512 i = (unsigned int)startindex; \
513 if ( parent == NULL ) \
515 parent = state->m_properties; \
520 #define ITEM_ITERATION_LOOP_BEGIN \
523 iMax = parent->GetChildCount(); \
526 wxPGProperty* p = parent->Item(i);
528 #define ITEM_ITERATION_LOOP_END \
529 if ( p->GetChildCount() ) \
532 parent = (wxPGProperty*)p; \
533 iMax = parent->GetChildCount(); \
538 i = parent->m_arrIndex + 1; \
539 parent = parent->m_parent; \
541 while ( parent != NULL );
543 bool wxPropertyGridPageState::EnableCategories( bool enable
)
546 // NB: We can't use wxPropertyGridIterator in this
547 // function, since it depends on m_arrIndexes,
548 // which, among other things, is being fixed here.
550 ITEM_ITERATION_VARIABLES
558 if ( !IsInNonCatMode() )
561 m_properties
= &m_regularArray
;
563 // fix parents, indexes, and depths
564 ITEM_ITERATION_INIT_FROM_THE_TOP
566 ITEM_ITERATION_LOOP_BEGIN
570 p
->m_parent
= parent
;
572 // If parent was category, and this is not,
573 // then the depth stays the same.
574 if ( parent
->IsCategory() &&
576 p
->m_depth
= parent
->m_depth
;
578 p
->m_depth
= parent
->m_depth
+ 1;
580 ITEM_ITERATION_LOOP_END
586 // Disable categories
589 if ( IsInNonCatMode() )
592 // Create array, if necessary.
596 m_properties
= m_abcArray
;
598 // fix parents, indexes, and depths
599 ITEM_ITERATION_INIT_FROM_THE_TOP
601 ITEM_ITERATION_LOOP_BEGIN
605 p
->m_parent
= parent
;
607 p
->m_depth
= parent
->m_depth
+ 1;
609 ITEM_ITERATION_LOOP_END
612 VirtualHeightChanged();
614 if ( m_pPropGrid
->GetState() == this )
615 m_pPropGrid
->RecalculateVirtualSize();
620 // -----------------------------------------------------------------------
622 static int wxPG_SortFunc_ByFunction(wxPGProperty
**pp1
, wxPGProperty
**pp2
)
624 wxPGProperty
*p1
= *pp1
;
625 wxPGProperty
*p2
= *pp2
;
626 wxPropertyGrid
* pg
= p1
->GetGrid();
627 wxPGSortCallback sortFunction
= pg
->GetSortFunction();
628 return sortFunction(pg
, p1
, p2
);
631 static int wxPG_SortFunc_ByLabel(wxPGProperty
**pp1
, wxPGProperty
**pp2
)
633 wxPGProperty
*p1
= *pp1
;
634 wxPGProperty
*p2
= *pp2
;
635 return p1
->GetLabel().CmpNoCase( p2
->GetLabel() );
640 // For wxVector w/ wxUSE_STL=1, you would use code like this instead:
645 static bool wxPG_SortFunc_ByFunction(wxPGProperty
*p1
, wxPGProperty
*p2
)
647 wxPropertyGrid
* pg
= p1
->GetGrid();
648 wxPGSortCallback sortFunction
= pg
->GetSortFunction();
649 return sortFunction(pg
, p1
, p2
) < 0;
652 static bool wxPG_SortFunc_ByLabel(wxPGProperty
*p1
, wxPGProperty
*p2
)
654 return p1
->GetLabel().CmpNoCase( p2
->GetLabel() ) < 0;
658 void wxPropertyGridPageState::DoSortChildren( wxPGProperty
* p
,
664 // Can only sort items with children
665 if ( !p
->GetChildCount() )
668 // Never sort children of aggregate properties
669 if ( p
->HasFlag(wxPG_PROP_AGGREGATE
) )
672 if ( (flags
& wxPG_SORT_TOP_LEVEL_ONLY
)
673 && !p
->IsCategory() && !p
->IsRoot() )
676 if ( GetGrid()->GetSortFunction() )
677 p
->m_children
.Sort( wxPG_SortFunc_ByFunction
);
679 p
->m_children
.Sort( wxPG_SortFunc_ByLabel
);
683 // For wxVector w/ wxUSE_STL=1, you would use code like this instead:
685 if ( GetGrid()->GetSortFunction() )
686 std::sort(p
->m_children
.begin(), p
->m_children
.end(),
687 wxPG_SortFunc_ByFunction
);
689 std::sort(p
->m_children
.begin(), p
->m_children
.end(),
690 wxPG_SortFunc_ByLabel
);
694 p
->FixIndicesOfChildren();
696 if ( flags
& wxPG_RECURSE
)
698 // Apply sort recursively
699 for ( unsigned int i
=0; i
<p
->GetChildCount(); i
++ )
700 DoSortChildren(p
->Item(i
), flags
);
704 // -----------------------------------------------------------------------
706 void wxPropertyGridPageState::DoSort( int flags
)
708 DoSortChildren( m_properties
, flags
| wxPG_RECURSE
);
710 // We used to sort categories as well here also if in non-categorized
711 // mode, but doing would naturally cause child indices to become
715 // -----------------------------------------------------------------------
717 bool wxPropertyGridPageState::PrepareAfterItemsAdded()
719 if ( !m_itemsAdded
) return false;
721 wxPropertyGrid
* pg
= GetGrid();
725 if ( pg
->HasFlag(wxPG_AUTO_SORT
) )
726 DoSort(wxPG_SORT_TOP_LEVEL_ONLY
);
731 // -----------------------------------------------------------------------
732 // wxPropertyGridPageState splitter, column and hittest functions
733 // -----------------------------------------------------------------------
735 wxPGProperty
* wxPropertyGridPageState::DoGetItemAtY( int y
) const
742 return m_properties
->GetItemAtY(y
, GetGrid()->m_lineHeight
, &a
);
745 // -----------------------------------------------------------------------
747 wxPropertyGridHitTestResult
748 wxPropertyGridPageState::HitTest( const wxPoint
&pt
) const
750 wxPropertyGridHitTestResult result
;
751 result
.m_column
= HitTestH( pt
.x
, &result
.m_splitter
,
752 &result
.m_splitterHitOffset
);
753 result
.m_property
= DoGetItemAtY( pt
.y
);
757 // -----------------------------------------------------------------------
759 // Used by SetSplitterLeft() and DotFitColumns()
760 int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC
& dc
,
765 wxPropertyGrid
* pg
= m_pPropGrid
;
770 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
772 wxPGProperty
* p
= pwc
->Item(i
);
773 if ( !p
->IsCategory() )
775 const wxPGCell
* cell
= NULL
;
777 p
->GetDisplayInfo(col
, -1, 0, &text
, &cell
);
778 dc
.GetTextExtent(text
, &w
, &h
);
780 w
+= ( ((int)p
->m_depth
-1) * pg
->m_subgroup_extramargin
);
782 // account for the bitmap
784 w
+= p
->GetImageOffset(pg
->GetImageRect(p
, -1).GetWidth());
787 w
+= (wxPG_XBEFORETEXT
*2);
793 if ( p
->GetChildCount() &&
794 ( subProps
|| p
->IsCategory() ) )
796 w
= GetColumnFitWidth( dc
, p
, col
, subProps
);
806 int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn
) const
808 int n
= GetGrid()->m_marginWidth
;
810 for ( i
=0; i
<=splitterColumn
; i
++ )
815 int wxPropertyGridPageState::GetColumnMinWidth( int WXUNUSED(column
) ) const
817 return wxPG_DRAG_MARGIN
;
820 void wxPropertyGridPageState::PropagateColSizeDec( int column
,
824 int origWidth
= m_colWidths
[column
];
825 m_colWidths
[column
] -= decrease
;
826 int min
= GetColumnMinWidth(column
);
828 if ( m_colWidths
[column
] < min
)
830 more
= decrease
- (origWidth
- min
);
831 m_colWidths
[column
] = min
;
835 // FIXME: Causes erratic splitter changing, so as a workaround
836 // disabled if two or less columns.
838 if ( m_colWidths
.size() <= 2 )
842 if ( more
&& column
< (int)m_colWidths
.size() && column
>= 0 )
843 PropagateColSizeDec( column
, more
, dir
);
846 void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos
,
850 wxPropertyGrid
* pg
= GetGrid();
852 int adjust
= newXPos
- DoGetSplitterPosition(splitterColumn
);
854 if ( !pg
->HasVirtualWidth() )
860 otherColumn
= splitterColumn
+ 1;
861 if ( otherColumn
== (int)m_colWidths
.size() )
863 m_colWidths
[splitterColumn
] += adjust
;
864 PropagateColSizeDec( otherColumn
, adjust
, 1 );
868 otherColumn
= splitterColumn
+ 1;
869 if ( otherColumn
== (int)m_colWidths
.size() )
871 m_colWidths
[otherColumn
] -= adjust
;
872 PropagateColSizeDec( splitterColumn
, -adjust
, -1 );
877 m_colWidths
[splitterColumn
] += adjust
;
880 if ( splitterColumn
== 0 )
881 m_fSplitterX
= (double) newXPos
;
883 if ( !(flags
& wxPG_SPLITTER_FROM_AUTO_CENTER
) &&
884 !(flags
& wxPG_SPLITTER_FROM_EVENT
) )
886 // Don't allow initial splitter auto-positioning after this.
887 m_isSplitterPreSet
= true;
893 // Moves splitter so that all labels are visible, but just.
894 void wxPropertyGridPageState::SetSplitterLeft( bool subProps
)
896 wxPropertyGrid
* pg
= GetGrid();
898 dc
.SetFont(pg
->GetFont());
900 int maxW
= GetColumnFitWidth(dc
, m_properties
, 0, subProps
);
904 maxW
+= pg
->m_marginWidth
;
905 DoSetSplitterPosition( maxW
);
908 m_dontCenterSplitter
= true;
911 wxSize
wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize
) )
913 wxPropertyGrid
* pg
= GetGrid();
915 dc
.SetFont(pg
->GetFont());
917 int marginWidth
= pg
->m_marginWidth
;
918 int accWid
= marginWidth
;
919 int maxColWidth
= 500;
921 for ( unsigned int col
=0; col
< GetColumnCount(); col
++ )
923 int fitWid
= GetColumnFitWidth(dc
, m_properties
, col
, true);
924 int colMinWidth
= GetColumnMinWidth(col
);
925 if ( fitWid
< colMinWidth
)
926 fitWid
= colMinWidth
;
927 else if ( fitWid
> maxColWidth
)
928 fitWid
= maxColWidth
;
930 m_colWidths
[col
] = fitWid
;
935 // Expand last one to fill the width
936 int remaining
= m_width
- accWid
;
937 m_colWidths
[GetColumnCount()-1] += remaining
;
939 m_dontCenterSplitter
= true;
941 int firstSplitterX
= marginWidth
+ m_colWidths
[0];
942 m_fSplitterX
= (double) firstSplitterX
;
944 // Don't allow initial splitter auto-positioning after this.
945 if ( pg
->GetState() == this )
947 pg
->SetSplitterPosition(firstSplitterX
, false);
952 pg
->GetVirtualSize(&x
, &y
);
954 return wxSize(accWid
, y
);
957 void wxPropertyGridPageState::CheckColumnWidths( int widthChange
)
962 wxPropertyGrid
* pg
= GetGrid();
965 unsigned int lastColumn
= m_colWidths
.size() - 1;
967 int clientWidth
= pg
->GetClientSize().x
;
970 // Column to reduce, if needed. Take last one that exceeds minimum width.
973 wxLogTrace("propgrid",
974 wxS("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"),
979 for ( i
=0; i
<m_colWidths
.size(); i
++ )
981 int min
= GetColumnMinWidth(i
);
982 if ( m_colWidths
[i
] <= min
)
984 m_colWidths
[i
] = min
;
988 // Always reduce the last column that is larger than minimum size
989 // (looks nicer, even with auto-centering enabled).
994 int colsWidth
= pg
->m_marginWidth
;
995 for ( i
=0; i
<m_colWidths
.size(); i
++ )
996 colsWidth
+= m_colWidths
[i
];
998 wxLogTrace("propgrid",
999 wxS(" HasVirtualWidth: %i colsWidth: %i"),
1000 (int)pg
->HasVirtualWidth(), colsWidth
);
1002 // Then mode-based requirement
1003 if ( !pg
->HasVirtualWidth() )
1005 int widthHigher
= width
- colsWidth
;
1007 // Adapt colsWidth to width
1008 if ( colsWidth
< width
)
1011 wxLogTrace("propgrid",
1012 wxS(" Adjust last column to %i"),
1013 m_colWidths
[lastColumn
] + widthHigher
);
1014 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + widthHigher
;
1016 else if ( colsWidth
> width
)
1019 if ( reduceCol
!= -1 )
1021 wxLogTrace("propgrid",
1022 wxT(" Reduce column %i (by %i)"),
1023 reduceCol
, -widthHigher
);
1025 // Reduce widest column, and recheck
1026 m_colWidths
[reduceCol
] = m_colWidths
[reduceCol
] + widthHigher
;
1027 CheckColumnWidths();
1033 // Only check colsWidth against clientWidth
1034 if ( colsWidth
< clientWidth
)
1036 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + (clientWidth
-colsWidth
);
1039 m_width
= colsWidth
;
1041 // If width changed, recalculate virtual size
1042 if ( pg
->GetState() == this )
1043 pg
->RecalculateVirtualSize();
1046 for ( i
=0; i
<m_colWidths
.size(); i
++ )
1048 wxLogTrace("propgrid", wxS("col%i: %i"), i
, m_colWidths
[i
]);
1051 // Auto center splitter
1052 if ( !m_dontCenterSplitter
)
1054 if ( m_colWidths
.size() == 2 &&
1055 m_columnProportions
[0] == m_columnProportions
[1] )
1058 // When we have two columns of equal proportion, then use this
1059 // code. It will look nicer when the scrollbar visibility is
1060 // toggled on and off.
1062 // TODO: Adapt this to generic recenter code.
1064 float centerX
= (float)(pg
->m_width
/2);
1067 if ( m_fSplitterX
< 0.0 )
1069 splitterX
= centerX
;
1071 else if ( widthChange
)
1073 //float centerX = float(pg->GetSize().x) * 0.5;
1076 splitterX
= m_fSplitterX
+ (float(widthChange
) * 0.5);
1077 float deviation
= fabs(centerX
- splitterX
);
1079 // If deviating from center, adjust towards it
1080 if ( deviation
> 20.0 )
1082 if ( splitterX
> centerX
)
1090 // No width change, just keep sure we keep splitter position intact
1091 splitterX
= m_fSplitterX
;
1092 float deviation
= fabs(centerX
- splitterX
);
1093 if ( deviation
> 50.0 )
1095 splitterX
= centerX
;
1099 DoSetSplitterPosition((int)splitterX
, 0,
1100 wxPG_SPLITTER_FROM_AUTO_CENTER
);
1102 m_fSplitterX
= splitterX
; // needed to retain accuracy
1107 // Generic re-center code
1109 ResetColumnSizes(wxPG_SPLITTER_FROM_AUTO_CENTER
);
1114 void wxPropertyGridPageState::ResetColumnSizes( int setSplitterFlags
)
1117 // Calculate sum of proportions
1119 for ( i
=0; i
<m_colWidths
.size(); i
++ )
1120 psum
+= m_columnProportions
[i
];
1121 int puwid
= (m_pPropGrid
->m_width
*256) / psum
;
1124 // Convert proportion to splitter positions
1125 for ( i
=0; i
<(m_colWidths
.size() - 1); i
++ )
1127 int cwid
= (puwid
*m_columnProportions
[i
]) / 256;
1129 DoSetSplitterPosition(cpos
, i
,
1134 void wxPropertyGridPageState::SetColumnCount( int colCount
)
1136 wxASSERT( colCount
>= 2 );
1137 m_colWidths
.SetCount( colCount
, wxPG_DRAG_MARGIN
);
1138 m_columnProportions
.SetCount( colCount
, 1 );
1139 if ( m_colWidths
.size() > (unsigned int)colCount
)
1140 m_colWidths
.RemoveAt( m_colWidths
.size()-1,
1141 m_colWidths
.size() - colCount
);
1143 if ( m_pPropGrid
->GetState() == this )
1144 m_pPropGrid
->RecalculateVirtualSize();
1146 CheckColumnWidths();
1149 void wxPropertyGridPageState::DoSetColumnProportion( unsigned int column
,
1152 wxASSERT_MSG( proportion
>= 1,
1153 "Column proportion must 1 or higher" );
1155 if ( proportion
< 1 )
1158 while ( m_columnProportions
.size() <= column
)
1159 m_columnProportions
.push_back(1);
1161 m_columnProportions
[column
] = proportion
;
1164 // Returns column index, -1 for margin
1165 int wxPropertyGridPageState::HitTestH( int x
, int* pSplitterHit
, int* pSplitterHitOffset
) const
1167 int cx
= GetGrid()->m_marginWidth
;
1169 int prevSplitter
= -1;
1174 if ( col
>= (int)m_colWidths
.size() )
1180 cx
+= m_colWidths
[col
];
1183 // Near prev. splitter
1186 int diff
= x
- prevSplitter
;
1187 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1189 *pSplitterHit
= col
- 1;
1190 *pSplitterHitOffset
= diff
;
1195 // Near next splitter
1196 int nextSplitter
= cx
;
1197 if ( col
< (int)(m_colWidths
.size()-1) )
1199 int diff
= x
- nextSplitter
;
1200 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1202 *pSplitterHit
= col
;
1203 *pSplitterHitOffset
= diff
;
1212 bool wxPropertyGridPageState::ArePropertiesAdjacent( wxPGProperty
* prop1
,
1213 wxPGProperty
* prop2
,
1214 int iterFlags
) const
1216 const wxPGProperty
* ap1
=
1217 wxPropertyGridConstIterator::OneStep(this,
1221 if ( ap1
&& ap1
== prop2
)
1224 const wxPGProperty
* ap2
=
1225 wxPropertyGridConstIterator::OneStep(this,
1229 if ( ap2
&& ap2
== prop2
)
1235 // -----------------------------------------------------------------------
1236 // wxPropertyGridPageState property value setting and getting
1237 // -----------------------------------------------------------------------
1239 bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty
* p
, const wxString
& value
)
1243 int flags
= wxPG_REPORT_ERROR
|wxPG_FULL_VALUE
|wxPG_PROGRAMMATIC_VALUE
;
1245 wxVariant variant
= p
->GetValueRef();
1248 if ( p
->GetMaxLength() <= 0 )
1249 res
= p
->StringToValue( variant
, value
, flags
);
1251 res
= p
->StringToValue( variant
, value
.Mid(0,p
->GetMaxLength()), flags
);
1255 p
->SetValue(variant
);
1256 if ( p
== m_pPropGrid
->GetSelection() &&
1257 this == m_pPropGrid
->GetState() )
1258 m_pPropGrid
->RefreshEditor();
1266 // -----------------------------------------------------------------------
1268 bool wxPropertyGridPageState::DoSetPropertyValue( wxPGProperty
* p
, wxVariant
& value
)
1273 if ( p
== m_pPropGrid
->GetSelection() &&
1274 this == m_pPropGrid
->GetState() )
1275 m_pPropGrid
->RefreshEditor();
1282 // -----------------------------------------------------------------------
1284 bool wxPropertyGridPageState::DoSetPropertyValueWxObjectPtr( wxPGProperty
* p
, wxObject
* value
)
1288 // wnd_primary has to be given so the control can be updated as well.
1290 DoSetPropertyValue(p
, v
);
1296 // -----------------------------------------------------------------------
1297 // wxPropertyGridPageState property operations
1298 // -----------------------------------------------------------------------
1300 bool wxPropertyGridPageState::DoIsPropertySelected( wxPGProperty
* prop
) const
1302 if ( wxPGFindInVector(m_selection
, prop
) != wxNOT_FOUND
)
1308 // -----------------------------------------------------------------------
1310 void wxPropertyGridPageState::DoRemoveFromSelection( wxPGProperty
* prop
)
1312 for ( unsigned int i
=0; i
<m_selection
.size(); i
++ )
1314 if ( m_selection
[i
] == prop
)
1316 wxPropertyGrid
* pg
= m_pPropGrid
;
1317 if ( i
== 0 && pg
->GetState() == this )
1319 // If first item (ie. one with the active editor) was
1320 // deselected, then we need to take some extra measures.
1321 wxArrayPGProperty sel
= m_selection
;
1322 sel
.erase( sel
.begin() + i
);
1324 wxPGProperty
* newFirst
;
1330 pg
->DoSelectProperty(newFirst
,
1331 wxPG_SEL_DONT_SEND_EVENT
);
1339 m_selection
.erase( m_selection
.begin() + i
);
1346 // -----------------------------------------------------------------------
1348 bool wxPropertyGridPageState::DoCollapse( wxPGProperty
* p
)
1350 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1352 if ( !p
->GetChildCount() ) return false;
1354 if ( !p
->IsExpanded() ) return false;
1356 p
->SetExpanded(false);
1358 VirtualHeightChanged();
1363 // -----------------------------------------------------------------------
1365 bool wxPropertyGridPageState::DoExpand( wxPGProperty
* p
)
1367 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1369 if ( !p
->GetChildCount() ) return false;
1371 if ( p
->IsExpanded() ) return false;
1373 p
->SetExpanded(true);
1375 VirtualHeightChanged();
1380 // -----------------------------------------------------------------------
1382 bool wxPropertyGridPageState::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
1384 if ( this == m_pPropGrid
->GetState() )
1385 return m_pPropGrid
->DoSelectProperty( p
, flags
);
1391 // -----------------------------------------------------------------------
1393 bool wxPropertyGridPageState::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
1395 p
->DoHide(hide
, flags
);
1396 VirtualHeightChanged();
1401 // -----------------------------------------------------------------------
1402 // wxPropertyGridPageState wxVariant related routines
1403 // -----------------------------------------------------------------------
1405 // Returns list of wxVariant objects (non-categories and non-sub-properties only).
1406 // Never includes sub-properties (unless they are parented by wxParentProperty).
1407 wxVariant
wxPropertyGridPageState::DoGetPropertyValues( const wxString
& listname
,
1408 wxPGProperty
* baseparent
,
1411 wxPGProperty
* pwc
= (wxPGProperty
*) baseparent
;
1413 // Root is the default base-parent.
1417 wxVariantList tempList
;
1418 wxVariant
v( tempList
, listname
);
1420 if ( pwc
->GetChildCount() )
1422 if ( flags
& wxPG_KEEP_STRUCTURE
)
1424 wxASSERT( !pwc
->HasFlag(wxPG_PROP_AGGREGATE
) );
1427 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1429 wxPGProperty
* p
= pwc
->Item(i
);
1430 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1432 wxVariant variant
= p
->GetValue();
1433 variant
.SetName( p
->GetBaseName() );
1434 v
.Append( variant
);
1438 v
.Append( DoGetPropertyValues(p
->m_name
,p
,flags
|wxPG_KEEP_STRUCTURE
) );
1440 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1441 v
.Append( p
->GetAttributesAsList() );
1446 wxPropertyGridConstIterator
it( this, wxPG_ITERATE_DEFAULT
, pwc
->Item(0) );
1447 it
.SetBaseParent( pwc
);
1449 for ( ; !it
.AtEnd(); it
.Next() )
1451 const wxPGProperty
* p
= it
.GetProperty();
1453 // Use a trick to ignore wxParentProperty itself, but not its sub-properties.
1454 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1456 wxVariant variant
= p
->GetValue();
1457 variant
.SetName( p
->GetName() );
1458 v
.Append( variant
);
1459 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1460 v
.Append( p
->GetAttributesAsList() );
1469 // -----------------------------------------------------------------------
1471 void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList
& list
, wxPGProperty
* defaultCategory
)
1473 unsigned char origFrozen
= 1;
1475 if ( m_pPropGrid
->GetState() == this )
1477 origFrozen
= m_pPropGrid
->m_frozen
;
1478 if ( !origFrozen
) m_pPropGrid
->Freeze();
1481 wxPropertyCategory
* use_category
= (wxPropertyCategory
*)defaultCategory
;
1483 if ( !use_category
)
1484 use_category
= (wxPropertyCategory
*)m_properties
;
1486 // Let's iterate over the list of variants.
1487 wxVariantList::const_iterator node
;
1488 int numSpecialEntries
= 0;
1491 // Second pass for special entries
1492 for ( node
= list
.begin(); node
!= list
.end(); ++node
)
1494 wxVariant
*current
= (wxVariant
*)*node
;
1496 // Make sure it is wxVariant.
1497 wxASSERT( current
);
1498 wxASSERT( wxStrcmp(current
->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
1500 const wxString
& name
= current
->GetName();
1501 if ( name
.length() > 0 )
1504 // '@' signified a special entry
1505 if ( name
[0] == wxS('@') )
1507 numSpecialEntries
++;
1511 wxPGProperty
* foundProp
= BaseGetPropertyByName(name
);
1514 wxPGProperty
* p
= foundProp
;
1516 // If it was a list, we still have to go through it.
1517 if ( wxStrcmp(current
->GetType(), wxS("list")) == 0 )
1519 DoSetPropertyValues( current
->GetList(),
1520 p
->IsCategory()?p
:(NULL
)
1525 wxASSERT_LEVEL_2_MSG(
1526 wxStrcmp(current
->GetType(), p
->GetValue().GetType()) == 0,
1528 wxS("setting value of property \"%s\" from variant"),
1529 p
->GetName().c_str())
1532 p
->SetValue(*current
);
1538 if ( current
->GetType() != wxS("list") )
1544 // Yes, it is; create a sub category and append contents there.
1545 wxPGProperty
* newCat
= DoInsert(use_category
,-1,new wxPropertyCategory(current
->GetName(),wxPG_LABEL
));
1546 DoSetPropertyValues( current
->GetList(), newCat
);
1553 if ( numSpecialEntries
)
1555 for ( node
= list
.begin(); node
!= list
.end(); ++node
)
1557 wxVariant
*current
= (wxVariant
*)*node
;
1559 const wxString
& name
= current
->GetName();
1560 if ( name
.length() > 0 )
1563 // '@' signified a special entry
1564 if ( name
[0] == wxS('@') )
1566 numSpecialEntries
--;
1568 size_t pos2
= name
.rfind(wxS('@'));
1569 if ( pos2
> 0 && pos2
< (name
.size()-1) )
1571 wxString propName
= name
.substr(1, pos2
-1);
1572 wxString entryType
= name
.substr(pos2
+1, wxString::npos
);
1574 if ( entryType
== wxS("attr") )
1577 // List of attributes
1578 wxPGProperty
* foundProp
= BaseGetPropertyByName(propName
);
1581 wxASSERT( current
->GetType() == wxPG_VARIANT_TYPE_LIST
);
1583 wxVariantList
& list2
= current
->GetList();
1584 wxVariantList::const_iterator node2
;
1586 for ( node2
= list2
.begin(); node2
!= list2
.end(); ++node2
)
1588 wxVariant
*attr
= (wxVariant
*)*node2
;
1589 foundProp
->SetAttribute( attr
->GetName(), *attr
);
1594 // ERROR: No such property: 'propName'
1600 // ERROR: Special entry requires name of format @<propname>@<entrytype>
1605 if ( !numSpecialEntries
)
1612 m_pPropGrid
->Thaw();
1614 if ( this == m_pPropGrid
->GetState() )
1615 m_pPropGrid
->RefreshEditor();
1620 // -----------------------------------------------------------------------
1621 // wxPropertyGridPageState property adding and removal
1622 // -----------------------------------------------------------------------
1624 bool wxPropertyGridPageState::PrepareToAddItem( wxPGProperty
* property
,
1625 wxPGProperty
* scheduledParent
)
1627 wxPropertyGrid
* propGrid
= m_pPropGrid
;
1629 // This will allow better behavior.
1630 if ( scheduledParent
== m_properties
)
1631 scheduledParent
= NULL
;
1633 if ( scheduledParent
&& !scheduledParent
->IsCategory() )
1635 wxASSERT_MSG( property
->GetBaseName().length(),
1636 "Property's children must have unique, non-empty names within their scope" );
1639 property
->m_parentState
= this;
1641 if ( property
->IsCategory() )
1644 // Parent of a category must be either root or another category
1645 // (otherwise Bad Things might happen).
1646 wxASSERT_MSG( scheduledParent
== NULL
||
1647 scheduledParent
== m_properties
||
1648 scheduledParent
->IsCategory(),
1649 wxT("Parent of a category must be either root or another category."));
1651 // If we already have category with same name, delete given property
1652 // and use it instead as most recent caption item.
1653 wxPGProperty
* found_id
= BaseGetPropertyByName( property
->GetBaseName() );
1656 wxPropertyCategory
* pwc
= (wxPropertyCategory
*) found_id
;
1657 if ( pwc
->IsCategory() ) // Must be a category.
1660 m_currentCategory
= pwc
;
1667 // Warn for identical names in debug mode.
1668 if ( BaseGetPropertyByName(property
->GetName()) &&
1669 (!scheduledParent
|| scheduledParent
->IsCategory()) )
1671 wxFAIL_MSG(wxString::Format(
1672 "wxPropertyGrid item with name \"%s\" already exists",
1673 property
->GetName()));
1675 wxPGGlobalVars
->m_warnings
++;
1677 #endif // wxDEBUG_LEVEL
1679 // NULL parent == root parent
1680 if ( !scheduledParent
)
1681 scheduledParent
= DoGetRoot();
1683 property
->m_parent
= scheduledParent
;
1685 property
->InitAfterAdded(this, propGrid
);
1687 if ( property
->IsCategory() )
1689 wxPropertyCategory
* pc
= wxStaticCast(property
, wxPropertyCategory
);
1691 m_currentCategory
= pc
;
1693 // Calculate text extent for category caption
1695 pc
->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
1701 // -----------------------------------------------------------------------
1703 wxPGProperty
* wxPropertyGridPageState::DoAppend( wxPGProperty
* property
)
1705 wxPropertyCategory
* cur_cat
= m_currentCategory
;
1706 if ( property
->IsCategory() )
1709 return DoInsert( cur_cat
, -1, property
);
1712 // -----------------------------------------------------------------------
1714 wxPGProperty
* wxPropertyGridPageState::DoInsert( wxPGProperty
* parent
, int index
, wxPGProperty
* property
)
1717 parent
= m_properties
;
1719 wxCHECK_MSG( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1721 wxT("when adding properties to fixed parents, use BeginAddChildren and EndAddChildren.") );
1723 bool res
= PrepareToAddItem( property
, (wxPropertyCategory
*)parent
);
1725 // PrepareToAddItem() may just decide to use use current category
1726 // instead of adding new one.
1728 return m_currentCategory
;
1730 bool parentIsRoot
= parent
->IsRoot();
1731 bool parentIsCategory
= parent
->IsCategory();
1733 // Note that item must be added into current mode later.
1735 // If parent is wxParentProperty, just stick it in...
1736 // If parent is root (m_properties), then...
1737 // In categoric mode: Add as last item in m_abcArray (if not category).
1738 // Add to given index in m_regularArray.
1739 // In non-cat mode: Add as last item in m_regularArray.
1740 // Add to given index in m_abcArray.
1741 // If parent is category, then...
1742 // 1) Add to given category in given index.
1743 // 2) Add as last item in m_abcArray.
1745 if ( m_properties
== &m_regularArray
)
1747 // We are currently in Categorized mode
1749 // Only add non-categories to m_abcArray.
1750 if ( m_abcArray
&& !property
->IsCategory() &&
1751 (parentIsCategory
|| parentIsRoot
) )
1753 m_abcArray
->DoAddChild( property
, -1, false );
1756 // Add to current mode.
1757 parent
->DoAddChild( property
, index
, true );
1761 // We are currently in Non-categorized/Alphabetic mode
1763 if ( parentIsCategory
)
1764 // Parent is category.
1765 parent
->DoAddChild( property
, index
, false );
1766 else if ( parentIsRoot
)
1768 m_regularArray
.DoAddChild( property
, -1, false );
1770 // Add to current mode
1771 if ( !property
->IsCategory() )
1772 m_abcArray
->DoAddChild( property
, index
, true );
1776 if ( property
->IsCategory() )
1778 // This is a category caption item.
1780 // Last caption is not the bottom one (this info required by append)
1781 m_lastCaptionBottomnest
= 0;
1784 // Only add name to hashmap if parent is root or category
1785 if ( property
->m_name
.length() &&
1786 (parentIsCategory
|| parentIsRoot
) )
1787 m_dictName
[property
->m_name
] = (void*) property
;
1789 VirtualHeightChanged();
1791 property
->UpdateParentValues();
1798 // -----------------------------------------------------------------------
1800 void wxPropertyGridPageState::DoDelete( wxPGProperty
* item
, bool doDelete
)
1802 wxCHECK_RET( item
->GetParent(),
1803 wxT("this property was already deleted") );
1805 wxCHECK_RET( item
!= &m_regularArray
&& item
!= m_abcArray
,
1806 wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
1808 wxPropertyGrid
* pg
= GetGrid();
1810 // Must defer deletion? Yes, if handling a wxPG event.
1811 if ( pg
&& pg
->m_processedEvent
)
1814 pg
->m_deletedProperties
.push_back(item
);
1816 pg
->m_removedProperties
.push_back(item
);
1818 // Rename the property so it won't remain in the way
1819 // of the user code.
1821 // Let's trust that no sane property uses prefix like
1822 // this. It would be anyway fairly inconvenient (in
1823 // current code) to check whether a new name is used
1824 // by another property with parent (due to the child
1826 wxString newName
= wxS("_&/_%$") + item
->GetBaseName();
1827 DoSetPropertyName(item
, newName
);
1832 unsigned int indinparent
= item
->GetIndexInParent();
1834 wxPGProperty
* pwc
= (wxPGProperty
*)item
;
1835 wxPGProperty
* parent
= item
->GetParent();
1837 wxCHECK_RET( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1838 wxT("wxPropertyGrid: Do not attempt to remove sub-properties.") );
1840 wxASSERT( item
->GetParentState() == this );
1842 if ( DoIsPropertySelected(item
) )
1844 if ( pg
&& pg
->GetState() == this )
1846 pg
->DoRemoveFromSelection(item
,
1847 wxPG_SEL_DELETING
|wxPG_SEL_NOVALIDATE
);
1851 DoRemoveFromSelection(item
);
1855 item
->SetFlag(wxPG_PROP_BEING_DELETED
);
1858 if ( item
->GetChildCount() && !item
->HasFlag(wxPG_PROP_AGGREGATE
) )
1860 // deleting a category
1861 if ( item
->IsCategory() )
1863 if ( pwc
== m_currentCategory
)
1864 m_currentCategory
= NULL
;
1867 item
->DeleteChildren();
1870 if ( !IsInNonCatMode() )
1872 // categorized mode - non-categorized array
1874 // Remove from non-cat array
1875 if ( !item
->IsCategory() &&
1876 (parent
->IsCategory() || parent
->IsRoot()) )
1879 m_abcArray
->RemoveChild(item
);
1882 // categorized mode - categorized array
1883 wxArrayPGProperty
& parentsChildren
= parent
->m_children
;
1884 parentsChildren
.erase( parentsChildren
.begin() + indinparent
);
1885 item
->m_parent
->FixIndicesOfChildren();
1889 // non-categorized mode - categorized array
1891 // We need to find location of item.
1892 wxPGProperty
* cat_parent
= &m_regularArray
;
1893 int cat_index
= m_regularArray
.GetChildCount();
1895 for ( i
= 0; i
< m_regularArray
.GetChildCount(); i
++ )
1897 wxPGProperty
* p
= m_regularArray
.Item(i
);
1898 if ( p
== item
) { cat_index
= i
; break; }
1899 if ( p
->IsCategory() )
1901 int subind
= ((wxPGProperty
*)p
)->Index(item
);
1902 if ( subind
!= wxNOT_FOUND
)
1904 cat_parent
= ((wxPGProperty
*)p
);
1910 cat_parent
->m_children
.erase(cat_parent
->m_children
.begin()+cat_index
);
1912 // non-categorized mode - non-categorized array
1913 if ( !item
->IsCategory() )
1915 wxASSERT( item
->m_parent
== m_abcArray
);
1916 wxArrayPGProperty
& parentsChildren
= item
->m_parent
->m_children
;
1917 parentsChildren
.erase(parentsChildren
.begin() + indinparent
);
1918 item
->m_parent
->FixIndicesOfChildren(indinparent
);
1922 if ( item
->GetBaseName().length() &&
1923 (parent
->IsCategory() || parent
->IsRoot()) )
1924 m_dictName
.erase(item
->GetBaseName());
1926 // We need to clear parent grid's m_propHover, if it matches item
1927 if ( pg
&& pg
->m_propHover
== item
)
1928 pg
->m_propHover
= NULL
;
1930 // Mark the property as 'unattached'
1931 item
->m_parentState
= NULL
;
1932 item
->m_parent
= NULL
;
1934 // We can actually delete it now
1938 m_itemsAdded
= 1; // Not a logical assignment (but required nonetheless).
1940 VirtualHeightChanged();
1943 // -----------------------------------------------------------------------
1945 #endif // wxUSE_PROPGRID