1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/propgrid/propgridpagestate.cpp
3 // Purpose: wxPropertyGridPageState class
4 // Author: Jaakko Salli
7 // Copyright: (c) Jaakko Salli
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx/wx.h".
12 #include "wx/wxprec.h"
22 #include "wx/object.h"
24 #include "wx/string.h"
27 #include "wx/window.h"
30 #include "wx/dcmemory.h"
34 #include "wx/stopwatch.h"
37 // This define is necessary to prevent macro clearing
38 #define __wxPG_SOURCE_FILE__
40 #include "wx/propgrid/propgridpagestate.h"
41 #include "wx/propgrid/propgrid.h"
42 #include "wx/propgrid/editors.h"
44 #define wxPG_DEFAULT_SPLITTERX 110
47 // -----------------------------------------------------------------------
48 // wxPropertyGridIterator
49 // -----------------------------------------------------------------------
51 void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState
* state
, int flags
, wxPGProperty
* property
, int dir
)
53 wxASSERT( dir
== 1 || dir
== -1 );
56 m_baseParent
= state
->DoGetRoot();
57 if ( !property
&& m_baseParent
->GetChildCount() )
58 property
= m_baseParent
->Item(0);
60 m_property
= property
;
62 wxPG_ITERATOR_CREATE_MASKS(flags
, m_itemExMask
, m_parentExMask
)
64 // Need to skip first?
65 if ( property
&& (property
->GetFlags() & m_itemExMask
) )
74 void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState
* state
, int flags
, int startPos
, int dir
)
76 wxPGProperty
* property
= NULL
;
78 if ( startPos
== wxTOP
)
83 else if ( startPos
== wxBOTTOM
)
85 property
= state
->GetLastItem(flags
);
91 wxFAIL_MSG("Only supported starting positions are wxTOP and wxBOTTOM");
94 Init( state
, flags
, property
, dir
);
97 void wxPropertyGridIteratorBase::Assign( const wxPropertyGridIteratorBase
& it
)
99 m_property
= it
.m_property
;
100 m_state
= it
.m_state
;
101 m_baseParent
= it
.m_baseParent
;
102 m_itemExMask
= it
.m_itemExMask
;
103 m_parentExMask
= it
.m_parentExMask
;
106 void wxPropertyGridIteratorBase::Prev()
108 wxPGProperty
* property
= m_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
;
158 if ( property
->GetChildCount() &&
159 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) &&
163 property
= property
->Item(0);
167 wxPGProperty
* parent
= property
->GetParent();
169 unsigned int index
= property
->GetIndexInParent() + 1;
171 if ( index
< parent
->GetChildCount() )
174 property
= parent
->Item(index
);
178 // Next sibling of parent
179 if ( parent
== m_baseParent
)
192 m_property
= property
;
194 // If property does not match our criteria, skip it
195 if ( property
->GetFlags() & m_itemExMask
)
199 // -----------------------------------------------------------------------
200 // wxPropertyGridPageState
201 // -----------------------------------------------------------------------
203 wxPropertyGridPageState::wxPropertyGridPageState()
206 m_regularArray
.SetParentState(this);
207 m_properties
= &m_regularArray
;
209 m_currentCategory
= NULL
;
212 m_lastCaptionBottomnest
= 1;
216 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
217 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
218 m_fSplitterX
= wxPG_DEFAULT_SPLITTERX
;
220 m_columnProportions
.push_back(1);
221 m_columnProportions
.push_back(1);
223 m_isSplitterPreSet
= false;
224 m_dontCenterSplitter
= false;
226 // By default, we only have the 'value' column editable
227 m_editableColumns
.push_back(1);
230 // -----------------------------------------------------------------------
232 wxPropertyGridPageState::~wxPropertyGridPageState()
237 // -----------------------------------------------------------------------
239 void wxPropertyGridPageState::InitNonCatMode()
243 m_abcArray
= new wxPGRootProperty(wxS("<Root_NonCat>"));
244 m_abcArray
->SetParentState(this);
245 m_abcArray
->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES
);
248 // Must be called when state::m_properties still points to regularArray.
249 wxPGProperty
* oldProperties
= m_properties
;
251 // Must use temp value in state::m_properties for item iteration loop
252 // to run as expected.
253 m_properties
= &m_regularArray
;
255 if ( m_properties
->GetChildCount() )
258 // Prepare m_abcArray
259 wxPropertyGridIterator
it( this, wxPG_ITERATE_PROPERTIES
);
261 for ( ; !it
.AtEnd(); it
.Next() )
263 wxPGProperty
* p
= it
.GetProperty();
264 wxPGProperty
* parent
= p
->GetParent();
265 if ( parent
->IsCategory() || parent
->IsRoot() )
267 m_abcArray
->DoAddChild(p
);
268 p
->m_parent
= &m_regularArray
;
273 m_properties
= oldProperties
;
276 // -----------------------------------------------------------------------
278 void wxPropertyGridPageState::DoClear()
280 if ( m_pPropGrid
&& m_pPropGrid
->GetState() == this )
282 m_pPropGrid
->ClearSelection(false);
289 m_regularArray
.Empty();
295 m_currentCategory
= NULL
;
296 m_lastCaptionBottomnest
= 1;
303 // -----------------------------------------------------------------------
305 void wxPropertyGridPageState::CalculateFontAndBitmapStuff( int WXUNUSED(vspacing
) )
307 wxPropertyGrid
* propGrid
= GetGrid();
309 VirtualHeightChanged();
311 // Recalculate caption text extents.
314 for ( i
=0;i
<m_regularArray
.GetChildCount();i
++ )
316 wxPGProperty
* p
=m_regularArray
.Item(i
);
318 if ( p
->IsCategory() )
319 ((wxPropertyCategory
*)p
)->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
323 // -----------------------------------------------------------------------
325 void wxPropertyGridPageState::SetVirtualWidth( int width
)
327 // Sometimes width less than 0 is offered. Let's make things easy for
328 // everybody and deal with it here.
332 wxPropertyGrid
* pg
= GetGrid();
333 int gw
= pg
->GetClientSize().x
;
340 // -----------------------------------------------------------------------
342 void wxPropertyGridPageState::OnClientWidthChange( int newWidth
, int widthChange
, bool fromOnResize
)
344 wxPropertyGrid
* pg
= GetGrid();
346 if ( pg
->HasVirtualWidth() )
348 if ( m_width
< newWidth
)
349 SetVirtualWidth( newWidth
);
351 CheckColumnWidths(widthChange
);
355 SetVirtualWidth( newWidth
);
357 // This should be done before splitter auto centering
358 // NOTE: Splitter auto-centering is done in this function.
361 CheckColumnWidths(widthChange
);
363 if ( !m_isSplitterPreSet
&& m_dontCenterSplitter
)
365 long timeSinceCreation
= (::wxGetLocalTimeMillis() - GetGrid()->m_timeCreated
).ToLong();
367 // If too long, don't set splitter
368 if ( timeSinceCreation
< 250 )
370 if ( m_properties
->GetChildCount() )
372 SetSplitterLeft( false );
376 DoSetSplitterPosition( newWidth
/ 2 );
377 m_isSplitterPreSet
= false;
384 // -----------------------------------------------------------------------
385 // wxPropertyGridPageState item iteration methods
386 // -----------------------------------------------------------------------
388 wxPGProperty
* wxPropertyGridPageState::GetLastItem( int flags
)
390 if ( !m_properties
->GetChildCount() )
393 wxPG_ITERATOR_CREATE_MASKS(flags
, int itemExMask
, int parentExMask
)
395 // First, get last child of last parent
396 wxPGProperty
* pwc
= (wxPGProperty
*)m_properties
->Last();
397 while ( pwc
->GetChildCount() &&
398 wxPG_ITERATOR_PARENTEXMASK_TEST(pwc
, parentExMask
) )
399 pwc
= (wxPGProperty
*) pwc
->Last();
401 // Then, if it doesn't fit our criteria, back up until we find something that does
402 if ( pwc
->GetFlags() & itemExMask
)
404 wxPropertyGridIterator
it( this, flags
, pwc
);
405 for ( ; !it
.AtEnd(); it
.Prev() )
407 pwc
= (wxPGProperty
*) it
.GetProperty();
413 wxPropertyCategory
* wxPropertyGridPageState::GetPropertyCategory( const wxPGProperty
* p
) const
415 const wxPGProperty
* parent
= (const wxPGProperty
*)p
;
416 const wxPGProperty
* grandparent
= (const wxPGProperty
*)parent
->GetParent();
419 parent
= grandparent
;
420 grandparent
= (wxPGProperty
*)parent
->GetParent();
421 if ( parent
->IsCategory() && grandparent
)
422 return (wxPropertyCategory
*)parent
;
423 } while ( grandparent
);
428 // -----------------------------------------------------------------------
429 // wxPropertyGridPageState GetPropertyXXX methods
430 // -----------------------------------------------------------------------
432 wxPGProperty
* wxPropertyGridPageState::GetPropertyByLabel( const wxString
& label
,
433 wxPGProperty
* parent
) const
438 if ( !parent
) parent
= (wxPGProperty
*) &m_regularArray
;
440 for ( i
=0; i
<parent
->GetChildCount(); i
++ )
442 wxPGProperty
* p
= parent
->Item(i
);
443 if ( p
->m_label
== label
)
445 // Check children recursively.
446 if ( p
->GetChildCount() )
448 p
= GetPropertyByLabel(label
,(wxPGProperty
*)p
);
457 // -----------------------------------------------------------------------
459 wxPGProperty
* wxPropertyGridPageState::BaseGetPropertyByName( const wxString
& name
) const
461 wxPGHashMapS2P::const_iterator it
;
462 it
= m_dictName
.find(name
);
463 if ( it
!= m_dictName
.end() )
464 return (wxPGProperty
*) it
->second
;
468 // -----------------------------------------------------------------------
470 void wxPropertyGridPageState::DoSetPropertyName( wxPGProperty
* p
,
471 const wxString
& newName
)
473 wxCHECK_RET( p
, wxT("invalid property id") );
475 wxPGProperty
* parent
= p
->GetParent();
477 if ( parent
->IsCategory() || parent
->IsRoot() )
479 if ( !p
->GetBaseName().empty() )
480 m_dictName
.erase( p
->GetBaseName() );
481 if ( !newName
.empty() )
482 m_dictName
[newName
] = (void*) p
;
485 p
->DoSetName(newName
);
488 // -----------------------------------------------------------------------
489 // wxPropertyGridPageState global operations
490 // -----------------------------------------------------------------------
492 // -----------------------------------------------------------------------
493 // Item iteration macros
494 // NB: Nowadays only needed for alphabetic/categoric mode switching.
495 // -----------------------------------------------------------------------
497 //#define II_INVALID_I 0x00FFFFFF
499 #define ITEM_ITERATION_VARIABLES \
500 wxPGProperty* parent; \
504 #define ITEM_ITERATION_INIT_FROM_THE_TOP \
505 parent = m_properties; \
509 #define ITEM_ITERATION_INIT(startparent, startindex, state) \
510 parent = startparent; \
511 i = (unsigned int)startindex; \
512 if ( parent == NULL ) \
514 parent = state->m_properties; \
519 #define ITEM_ITERATION_LOOP_BEGIN \
522 iMax = parent->GetChildCount(); \
525 wxPGProperty* p = parent->Item(i);
527 #define ITEM_ITERATION_LOOP_END \
528 if ( p->GetChildCount() ) \
531 parent = (wxPGProperty*)p; \
532 iMax = parent->GetChildCount(); \
537 i = parent->m_arrIndex + 1; \
538 parent = parent->m_parent; \
540 while ( parent != NULL );
542 bool wxPropertyGridPageState::EnableCategories( bool enable
)
545 // NB: We can't use wxPropertyGridIterator in this
546 // function, since it depends on m_arrIndexes,
547 // which, among other things, is being fixed here.
549 ITEM_ITERATION_VARIABLES
557 if ( !IsInNonCatMode() )
560 m_properties
= &m_regularArray
;
562 // fix parents, indexes, and depths
563 ITEM_ITERATION_INIT_FROM_THE_TOP
565 ITEM_ITERATION_LOOP_BEGIN
569 p
->m_parent
= parent
;
571 // If parent was category, and this is not,
572 // then the depth stays the same.
573 if ( parent
->IsCategory() &&
575 p
->m_depth
= parent
->m_depth
;
577 p
->m_depth
= parent
->m_depth
+ 1;
579 ITEM_ITERATION_LOOP_END
585 // Disable categories
588 if ( IsInNonCatMode() )
591 // Create array, if necessary.
595 m_properties
= m_abcArray
;
597 // fix parents, indexes, and depths
598 ITEM_ITERATION_INIT_FROM_THE_TOP
600 ITEM_ITERATION_LOOP_BEGIN
604 p
->m_parent
= parent
;
606 p
->m_depth
= parent
->m_depth
+ 1;
608 ITEM_ITERATION_LOOP_END
611 VirtualHeightChanged();
613 if ( m_pPropGrid
->GetState() == this )
614 m_pPropGrid
->RecalculateVirtualSize();
619 // -----------------------------------------------------------------------
621 static int wxPG_SortFunc_ByFunction(wxPGProperty
**pp1
, wxPGProperty
**pp2
)
623 wxPGProperty
*p1
= *pp1
;
624 wxPGProperty
*p2
= *pp2
;
625 wxPropertyGrid
* pg
= p1
->GetGrid();
626 wxPGSortCallback sortFunction
= pg
->GetSortFunction();
627 return sortFunction(pg
, p1
, p2
);
630 static int wxPG_SortFunc_ByLabel(wxPGProperty
**pp1
, wxPGProperty
**pp2
)
632 wxPGProperty
*p1
= *pp1
;
633 wxPGProperty
*p2
= *pp2
;
634 return p1
->GetLabel().CmpNoCase( p2
->GetLabel() );
639 // For wxVector w/ wxUSE_STL=1, you would use code like this instead:
644 static bool wxPG_SortFunc_ByFunction(wxPGProperty
*p1
, wxPGProperty
*p2
)
646 wxPropertyGrid
* pg
= p1
->GetGrid();
647 wxPGSortCallback sortFunction
= pg
->GetSortFunction();
648 return sortFunction(pg
, p1
, p2
) < 0;
651 static bool wxPG_SortFunc_ByLabel(wxPGProperty
*p1
, wxPGProperty
*p2
)
653 return p1
->GetLabel().CmpNoCase( p2
->GetLabel() ) < 0;
657 void wxPropertyGridPageState::DoSortChildren( wxPGProperty
* p
,
663 // Can only sort items with children
664 if ( !p
->GetChildCount() )
667 // Never sort children of aggregate properties
668 if ( p
->HasFlag(wxPG_PROP_AGGREGATE
) )
671 if ( (flags
& wxPG_SORT_TOP_LEVEL_ONLY
)
672 && !p
->IsCategory() && !p
->IsRoot() )
675 if ( GetGrid()->GetSortFunction() )
676 p
->m_children
.Sort( wxPG_SortFunc_ByFunction
);
678 p
->m_children
.Sort( wxPG_SortFunc_ByLabel
);
682 // For wxVector w/ wxUSE_STL=1, you would use code like this instead:
684 if ( GetGrid()->GetSortFunction() )
685 std::sort(p
->m_children
.begin(), p
->m_children
.end(),
686 wxPG_SortFunc_ByFunction
);
688 std::sort(p
->m_children
.begin(), p
->m_children
.end(),
689 wxPG_SortFunc_ByLabel
);
693 p
->FixIndicesOfChildren();
695 if ( flags
& wxPG_RECURSE
)
697 // Apply sort recursively
698 for ( unsigned int i
=0; i
<p
->GetChildCount(); i
++ )
699 DoSortChildren(p
->Item(i
), flags
);
703 // -----------------------------------------------------------------------
705 void wxPropertyGridPageState::DoSort( int flags
)
707 DoSortChildren( m_properties
, flags
| wxPG_RECURSE
);
709 // We used to sort categories as well here also if in non-categorized
710 // mode, but doing would naturally cause child indices to become
714 // -----------------------------------------------------------------------
716 bool wxPropertyGridPageState::PrepareAfterItemsAdded()
718 if ( !m_itemsAdded
) return false;
720 wxPropertyGrid
* pg
= GetGrid();
724 if ( pg
->HasFlag(wxPG_AUTO_SORT
) )
725 DoSort(wxPG_SORT_TOP_LEVEL_ONLY
);
730 // -----------------------------------------------------------------------
731 // wxPropertyGridPageState splitter, column and hittest functions
732 // -----------------------------------------------------------------------
734 wxPGProperty
* wxPropertyGridPageState::DoGetItemAtY( int y
) const
741 return m_properties
->GetItemAtY(y
, GetGrid()->m_lineHeight
, &a
);
744 // -----------------------------------------------------------------------
746 wxPropertyGridHitTestResult
747 wxPropertyGridPageState::HitTest( const wxPoint
&pt
) const
749 wxPropertyGridHitTestResult result
;
750 result
.m_column
= HitTestH( pt
.x
, &result
.m_splitter
,
751 &result
.m_splitterHitOffset
);
752 result
.m_property
= DoGetItemAtY( pt
.y
);
756 // -----------------------------------------------------------------------
758 // Used by SetSplitterLeft() and DotFitColumns()
759 int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC
& dc
,
764 wxPropertyGrid
* pg
= m_pPropGrid
;
769 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
771 wxPGProperty
* p
= pwc
->Item(i
);
772 if ( !p
->IsCategory() )
774 const wxPGCell
* cell
= NULL
;
776 p
->GetDisplayInfo(col
, -1, 0, &text
, &cell
);
777 dc
.GetTextExtent(text
, &w
, &h
);
779 w
+= ( ((int)p
->m_depth
-1) * pg
->m_subgroup_extramargin
);
781 // account for the bitmap
783 w
+= p
->GetImageOffset(pg
->GetImageRect(p
, -1).GetWidth());
786 w
+= (wxPG_XBEFORETEXT
*2);
792 if ( p
->GetChildCount() &&
793 ( subProps
|| p
->IsCategory() ) )
795 w
= GetColumnFitWidth( dc
, p
, col
, subProps
);
805 int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn
) const
807 int n
= GetGrid()->m_marginWidth
;
809 for ( i
=0; i
<=splitterColumn
; i
++ )
814 int wxPropertyGridPageState::GetColumnMinWidth( int WXUNUSED(column
) ) const
816 return wxPG_DRAG_MARGIN
;
819 void wxPropertyGridPageState::PropagateColSizeDec( int column
,
823 int origWidth
= m_colWidths
[column
];
824 m_colWidths
[column
] -= decrease
;
825 int min
= GetColumnMinWidth(column
);
827 if ( m_colWidths
[column
] < min
)
829 more
= decrease
- (origWidth
- min
);
830 m_colWidths
[column
] = min
;
834 // FIXME: Causes erratic splitter changing, so as a workaround
835 // disabled if two or less columns.
837 if ( m_colWidths
.size() <= 2 )
841 if ( more
&& column
< (int)m_colWidths
.size() && column
>= 0 )
842 PropagateColSizeDec( column
, more
, dir
);
845 void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos
,
849 wxPropertyGrid
* pg
= GetGrid();
851 int adjust
= newXPos
- DoGetSplitterPosition(splitterColumn
);
853 if ( !pg
->HasVirtualWidth() )
859 otherColumn
= splitterColumn
+ 1;
860 if ( otherColumn
== (int)m_colWidths
.size() )
862 m_colWidths
[splitterColumn
] += adjust
;
863 PropagateColSizeDec( otherColumn
, adjust
, 1 );
867 otherColumn
= splitterColumn
+ 1;
868 if ( otherColumn
== (int)m_colWidths
.size() )
870 m_colWidths
[otherColumn
] -= adjust
;
871 PropagateColSizeDec( splitterColumn
, -adjust
, -1 );
876 m_colWidths
[splitterColumn
] += adjust
;
879 if ( splitterColumn
== 0 )
880 m_fSplitterX
= (double) newXPos
;
882 if ( !(flags
& wxPG_SPLITTER_FROM_AUTO_CENTER
) &&
883 !(flags
& wxPG_SPLITTER_FROM_EVENT
) )
885 // Don't allow initial splitter auto-positioning after this.
886 m_isSplitterPreSet
= true;
892 // Moves splitter so that all labels are visible, but just.
893 void wxPropertyGridPageState::SetSplitterLeft( bool subProps
)
895 wxPropertyGrid
* pg
= GetGrid();
897 dc
.SetFont(pg
->GetFont());
899 int maxW
= GetColumnFitWidth(dc
, m_properties
, 0, subProps
);
903 maxW
+= pg
->m_marginWidth
;
904 DoSetSplitterPosition( maxW
);
907 m_dontCenterSplitter
= true;
910 wxSize
wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize
) )
912 wxPropertyGrid
* pg
= GetGrid();
914 dc
.SetFont(pg
->GetFont());
916 int marginWidth
= pg
->m_marginWidth
;
917 int accWid
= marginWidth
;
918 int maxColWidth
= 500;
920 for ( unsigned int col
=0; col
< GetColumnCount(); col
++ )
922 int fitWid
= GetColumnFitWidth(dc
, m_properties
, col
, true);
923 int colMinWidth
= GetColumnMinWidth(col
);
924 if ( fitWid
< colMinWidth
)
925 fitWid
= colMinWidth
;
926 else if ( fitWid
> maxColWidth
)
927 fitWid
= maxColWidth
;
929 m_colWidths
[col
] = fitWid
;
934 // Expand last one to fill the width
935 int remaining
= m_width
- accWid
;
936 m_colWidths
[GetColumnCount()-1] += remaining
;
938 m_dontCenterSplitter
= true;
940 int firstSplitterX
= marginWidth
+ m_colWidths
[0];
941 m_fSplitterX
= (double) firstSplitterX
;
943 // Don't allow initial splitter auto-positioning after this.
944 if ( pg
->GetState() == this )
946 pg
->SetSplitterPosition(firstSplitterX
, false);
951 pg
->GetVirtualSize(&x
, &y
);
953 return wxSize(accWid
, y
);
956 void wxPropertyGridPageState::CheckColumnWidths( int widthChange
)
961 wxPropertyGrid
* pg
= GetGrid();
964 unsigned int lastColumn
= m_colWidths
.size() - 1;
966 int clientWidth
= pg
->GetClientSize().x
;
969 // Column to reduce, if needed. Take last one that exceeds minimum width.
972 wxLogTrace("propgrid",
973 wxS("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"),
978 for ( i
=0; i
<m_colWidths
.size(); i
++ )
980 int min
= GetColumnMinWidth(i
);
981 if ( m_colWidths
[i
] <= min
)
983 m_colWidths
[i
] = min
;
987 // Always reduce the last column that is larger than minimum size
988 // (looks nicer, even with auto-centering enabled).
993 int colsWidth
= pg
->m_marginWidth
;
994 for ( i
=0; i
<m_colWidths
.size(); i
++ )
995 colsWidth
+= m_colWidths
[i
];
997 wxLogTrace("propgrid",
998 wxS(" HasVirtualWidth: %i colsWidth: %i"),
999 (int)pg
->HasVirtualWidth(), colsWidth
);
1001 // Then mode-based requirement
1002 if ( !pg
->HasVirtualWidth() )
1004 int widthHigher
= width
- colsWidth
;
1006 // Adapt colsWidth to width
1007 if ( colsWidth
< width
)
1010 wxLogTrace("propgrid",
1011 wxS(" Adjust last column to %i"),
1012 m_colWidths
[lastColumn
] + widthHigher
);
1013 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + widthHigher
;
1015 else if ( colsWidth
> width
)
1018 if ( reduceCol
!= -1 )
1020 wxLogTrace("propgrid",
1021 wxT(" Reduce column %i (by %i)"),
1022 reduceCol
, -widthHigher
);
1024 // Reduce widest column, and recheck
1025 m_colWidths
[reduceCol
] = m_colWidths
[reduceCol
] + widthHigher
;
1026 CheckColumnWidths();
1032 // Only check colsWidth against clientWidth
1033 if ( colsWidth
< clientWidth
)
1035 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + (clientWidth
-colsWidth
);
1038 m_width
= colsWidth
;
1040 // If width changed, recalculate virtual size
1041 if ( pg
->GetState() == this )
1042 pg
->RecalculateVirtualSize();
1045 for ( i
=0; i
<m_colWidths
.size(); i
++ )
1047 wxLogTrace("propgrid", wxS("col%i: %i"), i
, m_colWidths
[i
]);
1050 // Auto center splitter
1051 if ( !m_dontCenterSplitter
)
1053 if ( m_colWidths
.size() == 2 &&
1054 m_columnProportions
[0] == m_columnProportions
[1] )
1057 // When we have two columns of equal proportion, then use this
1058 // code. It will look nicer when the scrollbar visibility is
1059 // toggled on and off.
1061 // TODO: Adapt this to generic recenter code.
1063 float centerX
= (float)(pg
->m_width
/2);
1066 if ( m_fSplitterX
< 0.0 )
1068 splitterX
= centerX
;
1070 else if ( widthChange
)
1072 //float centerX = float(pg->GetSize().x) * 0.5;
1075 splitterX
= m_fSplitterX
+ (float(widthChange
) * 0.5);
1076 float deviation
= fabs(centerX
- splitterX
);
1078 // If deviating from center, adjust towards it
1079 if ( deviation
> 20.0 )
1081 if ( splitterX
> centerX
)
1089 // No width change, just keep sure we keep splitter position intact
1090 splitterX
= m_fSplitterX
;
1091 float deviation
= fabs(centerX
- splitterX
);
1092 if ( deviation
> 50.0 )
1094 splitterX
= centerX
;
1098 DoSetSplitterPosition((int)splitterX
, 0,
1099 wxPG_SPLITTER_FROM_AUTO_CENTER
);
1101 m_fSplitterX
= splitterX
; // needed to retain accuracy
1106 // Generic re-center code
1108 ResetColumnSizes(wxPG_SPLITTER_FROM_AUTO_CENTER
);
1113 void wxPropertyGridPageState::ResetColumnSizes( int setSplitterFlags
)
1116 // Calculate sum of proportions
1118 for ( i
=0; i
<m_colWidths
.size(); i
++ )
1119 psum
+= m_columnProportions
[i
];
1120 int puwid
= (m_pPropGrid
->m_width
*256) / psum
;
1123 // Convert proportion to splitter positions
1124 for ( i
=0; i
<(m_colWidths
.size() - 1); i
++ )
1126 int cwid
= (puwid
*m_columnProportions
[i
]) / 256;
1128 DoSetSplitterPosition(cpos
, i
,
1133 void wxPropertyGridPageState::SetColumnCount( int colCount
)
1135 wxASSERT( colCount
>= 2 );
1136 m_colWidths
.SetCount( colCount
, wxPG_DRAG_MARGIN
);
1137 m_columnProportions
.SetCount( colCount
, 1 );
1138 if ( m_colWidths
.size() > (unsigned int)colCount
)
1139 m_colWidths
.RemoveAt( m_colWidths
.size()-1,
1140 m_colWidths
.size() - colCount
);
1142 if ( m_pPropGrid
->GetState() == this )
1143 m_pPropGrid
->RecalculateVirtualSize();
1145 CheckColumnWidths();
1148 void wxPropertyGridPageState::DoSetColumnProportion( unsigned int column
,
1151 wxASSERT_MSG( proportion
>= 1,
1152 "Column proportion must 1 or higher" );
1154 if ( proportion
< 1 )
1157 while ( m_columnProportions
.size() <= column
)
1158 m_columnProportions
.push_back(1);
1160 m_columnProportions
[column
] = proportion
;
1163 // Returns column index, -1 for margin
1164 int wxPropertyGridPageState::HitTestH( int x
, int* pSplitterHit
, int* pSplitterHitOffset
) const
1166 int cx
= GetGrid()->m_marginWidth
;
1168 int prevSplitter
= -1;
1173 if ( col
>= (int)m_colWidths
.size() )
1179 cx
+= m_colWidths
[col
];
1182 // Near prev. splitter
1185 int diff
= x
- prevSplitter
;
1186 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1188 *pSplitterHit
= col
- 1;
1189 *pSplitterHitOffset
= diff
;
1194 // Near next splitter
1195 int nextSplitter
= cx
;
1196 if ( col
< (int)(m_colWidths
.size()-1) )
1198 int diff
= x
- nextSplitter
;
1199 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1201 *pSplitterHit
= col
;
1202 *pSplitterHitOffset
= diff
;
1211 bool wxPropertyGridPageState::ArePropertiesAdjacent( wxPGProperty
* prop1
,
1212 wxPGProperty
* prop2
,
1213 int iterFlags
) const
1215 const wxPGProperty
* ap1
=
1216 wxPropertyGridConstIterator::OneStep(this,
1220 if ( ap1
&& ap1
== prop2
)
1223 const wxPGProperty
* ap2
=
1224 wxPropertyGridConstIterator::OneStep(this,
1228 if ( ap2
&& ap2
== prop2
)
1234 // -----------------------------------------------------------------------
1235 // wxPropertyGridPageState property value setting and getting
1236 // -----------------------------------------------------------------------
1238 bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty
* p
, const wxString
& value
)
1242 int flags
= wxPG_REPORT_ERROR
|wxPG_FULL_VALUE
|wxPG_PROGRAMMATIC_VALUE
;
1244 wxVariant variant
= p
->GetValueRef();
1247 if ( p
->GetMaxLength() <= 0 )
1248 res
= p
->StringToValue( variant
, value
, flags
);
1250 res
= p
->StringToValue( variant
, value
.Mid(0,p
->GetMaxLength()), flags
);
1254 p
->SetValue(variant
);
1255 if ( p
== m_pPropGrid
->GetSelection() &&
1256 this == m_pPropGrid
->GetState() )
1257 m_pPropGrid
->RefreshEditor();
1265 // -----------------------------------------------------------------------
1267 bool wxPropertyGridPageState::DoSetPropertyValue( wxPGProperty
* p
, wxVariant
& value
)
1272 if ( p
== m_pPropGrid
->GetSelection() &&
1273 this == m_pPropGrid
->GetState() )
1274 m_pPropGrid
->RefreshEditor();
1281 // -----------------------------------------------------------------------
1283 bool wxPropertyGridPageState::DoSetPropertyValueWxObjectPtr( wxPGProperty
* p
, wxObject
* value
)
1287 // wnd_primary has to be given so the control can be updated as well.
1289 DoSetPropertyValue(p
, v
);
1295 // -----------------------------------------------------------------------
1296 // wxPropertyGridPageState property operations
1297 // -----------------------------------------------------------------------
1299 bool wxPropertyGridPageState::DoIsPropertySelected( wxPGProperty
* prop
) const
1301 if ( wxPGFindInVector(m_selection
, prop
) != wxNOT_FOUND
)
1307 // -----------------------------------------------------------------------
1309 void wxPropertyGridPageState::DoRemoveFromSelection( wxPGProperty
* prop
)
1311 for ( unsigned int i
=0; i
<m_selection
.size(); i
++ )
1313 if ( m_selection
[i
] == prop
)
1315 wxPropertyGrid
* pg
= m_pPropGrid
;
1316 if ( i
== 0 && pg
->GetState() == this )
1318 // If first item (ie. one with the active editor) was
1319 // deselected, then we need to take some extra measures.
1320 wxArrayPGProperty sel
= m_selection
;
1321 sel
.erase( sel
.begin() + i
);
1323 wxPGProperty
* newFirst
;
1329 pg
->DoSelectProperty(newFirst
,
1330 wxPG_SEL_DONT_SEND_EVENT
);
1338 m_selection
.erase( m_selection
.begin() + i
);
1345 // -----------------------------------------------------------------------
1347 bool wxPropertyGridPageState::DoCollapse( wxPGProperty
* p
)
1349 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1351 if ( !p
->GetChildCount() ) return false;
1353 if ( !p
->IsExpanded() ) return false;
1355 p
->SetExpanded(false);
1357 VirtualHeightChanged();
1362 // -----------------------------------------------------------------------
1364 bool wxPropertyGridPageState::DoExpand( wxPGProperty
* p
)
1366 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1368 if ( !p
->GetChildCount() ) return false;
1370 if ( p
->IsExpanded() ) return false;
1372 p
->SetExpanded(true);
1374 VirtualHeightChanged();
1379 // -----------------------------------------------------------------------
1381 bool wxPropertyGridPageState::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
1383 if ( this == m_pPropGrid
->GetState() )
1384 return m_pPropGrid
->DoSelectProperty( p
, flags
);
1390 // -----------------------------------------------------------------------
1392 bool wxPropertyGridPageState::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
1394 p
->DoHide(hide
, flags
);
1395 VirtualHeightChanged();
1400 // -----------------------------------------------------------------------
1401 // wxPropertyGridPageState wxVariant related routines
1402 // -----------------------------------------------------------------------
1404 // Returns list of wxVariant objects (non-categories and non-sub-properties only).
1405 // Never includes sub-properties (unless they are parented by wxParentProperty).
1406 wxVariant
wxPropertyGridPageState::DoGetPropertyValues( const wxString
& listname
,
1407 wxPGProperty
* baseparent
,
1410 wxPGProperty
* pwc
= (wxPGProperty
*) baseparent
;
1412 // Root is the default base-parent.
1416 wxVariantList tempList
;
1417 wxVariant
v( tempList
, listname
);
1419 if ( pwc
->GetChildCount() )
1421 if ( flags
& wxPG_KEEP_STRUCTURE
)
1423 wxASSERT( !pwc
->HasFlag(wxPG_PROP_AGGREGATE
) );
1426 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1428 wxPGProperty
* p
= pwc
->Item(i
);
1429 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1431 wxVariant variant
= p
->GetValue();
1432 variant
.SetName( p
->GetBaseName() );
1433 v
.Append( variant
);
1437 v
.Append( DoGetPropertyValues(p
->m_name
,p
,flags
|wxPG_KEEP_STRUCTURE
) );
1439 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1440 v
.Append( p
->GetAttributesAsList() );
1445 wxPropertyGridConstIterator
it( this, wxPG_ITERATE_DEFAULT
, pwc
->Item(0) );
1446 it
.SetBaseParent( pwc
);
1448 for ( ; !it
.AtEnd(); it
.Next() )
1450 const wxPGProperty
* p
= it
.GetProperty();
1452 // Use a trick to ignore wxParentProperty itself, but not its sub-properties.
1453 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1455 wxVariant variant
= p
->GetValue();
1456 variant
.SetName( p
->GetName() );
1457 v
.Append( variant
);
1458 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1459 v
.Append( p
->GetAttributesAsList() );
1468 // -----------------------------------------------------------------------
1470 void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList
& list
, wxPGProperty
* defaultCategory
)
1472 unsigned char origFrozen
= 1;
1474 if ( m_pPropGrid
->GetState() == this )
1476 origFrozen
= m_pPropGrid
->m_frozen
;
1477 if ( !origFrozen
) m_pPropGrid
->Freeze();
1480 wxPropertyCategory
* use_category
= (wxPropertyCategory
*)defaultCategory
;
1482 if ( !use_category
)
1483 use_category
= (wxPropertyCategory
*)m_properties
;
1485 // Let's iterate over the list of variants.
1486 wxVariantList::const_iterator node
;
1487 int numSpecialEntries
= 0;
1490 // Second pass for special entries
1491 for ( node
= list
.begin(); node
!= list
.end(); ++node
)
1493 wxVariant
*current
= (wxVariant
*)*node
;
1495 // Make sure it is wxVariant.
1496 wxASSERT( current
);
1497 wxASSERT( wxStrcmp(current
->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
1499 const wxString
& name
= current
->GetName();
1500 if ( !name
.empty() )
1503 // '@' signified a special entry
1504 if ( name
[0] == wxS('@') )
1506 numSpecialEntries
++;
1510 wxPGProperty
* foundProp
= BaseGetPropertyByName(name
);
1513 wxPGProperty
* p
= foundProp
;
1515 // If it was a list, we still have to go through it.
1516 if ( wxStrcmp(current
->GetType(), wxS("list")) == 0 )
1518 DoSetPropertyValues( current
->GetList(),
1519 p
->IsCategory()?p
:(NULL
)
1524 wxASSERT_LEVEL_2_MSG(
1525 wxStrcmp(current
->GetType(), p
->GetValue().GetType()) == 0,
1527 wxS("setting value of property \"%s\" from variant"),
1528 p
->GetName().c_str())
1531 p
->SetValue(*current
);
1537 if ( current
->GetType() != wxS("list") )
1543 // Yes, it is; create a sub category and append contents there.
1544 wxPGProperty
* newCat
= DoInsert(use_category
,-1,new wxPropertyCategory(current
->GetName(),wxPG_LABEL
));
1545 DoSetPropertyValues( current
->GetList(), newCat
);
1552 if ( numSpecialEntries
)
1554 for ( node
= list
.begin(); node
!= list
.end(); ++node
)
1556 wxVariant
*current
= (wxVariant
*)*node
;
1558 const wxString
& name
= current
->GetName();
1559 if ( !name
.empty() )
1562 // '@' signified a special entry
1563 if ( name
[0] == wxS('@') )
1565 numSpecialEntries
--;
1567 size_t pos2
= name
.rfind(wxS('@'));
1568 if ( pos2
> 0 && pos2
< (name
.size()-1) )
1570 wxString propName
= name
.substr(1, pos2
-1);
1571 wxString entryType
= name
.substr(pos2
+1, wxString::npos
);
1573 if ( entryType
== wxS("attr") )
1576 // List of attributes
1577 wxPGProperty
* foundProp
= BaseGetPropertyByName(propName
);
1580 wxASSERT( current
->GetType() == wxPG_VARIANT_TYPE_LIST
);
1582 wxVariantList
& list2
= current
->GetList();
1583 wxVariantList::const_iterator node2
;
1585 for ( node2
= list2
.begin(); node2
!= list2
.end(); ++node2
)
1587 wxVariant
*attr
= (wxVariant
*)*node2
;
1588 foundProp
->SetAttribute( attr
->GetName(), *attr
);
1593 // ERROR: No such property: 'propName'
1599 // ERROR: Special entry requires name of format @<propname>@<entrytype>
1604 if ( !numSpecialEntries
)
1611 m_pPropGrid
->Thaw();
1613 if ( this == m_pPropGrid
->GetState() )
1614 m_pPropGrid
->RefreshEditor();
1619 // -----------------------------------------------------------------------
1620 // wxPropertyGridPageState property adding and removal
1621 // -----------------------------------------------------------------------
1623 bool wxPropertyGridPageState::PrepareToAddItem( wxPGProperty
* property
,
1624 wxPGProperty
* scheduledParent
)
1626 wxPropertyGrid
* propGrid
= m_pPropGrid
;
1628 // This will allow better behaviour.
1629 if ( scheduledParent
== m_properties
)
1630 scheduledParent
= NULL
;
1632 if ( scheduledParent
&& !scheduledParent
->IsCategory() )
1634 wxASSERT_MSG( property
->GetBaseName().length(),
1635 "Property's children must have unique, non-empty names within their scope" );
1638 property
->m_parentState
= this;
1640 if ( property
->IsCategory() )
1643 // Parent of a category must be either root or another category
1644 // (otherwise Bad Things might happen).
1645 wxASSERT_MSG( scheduledParent
== NULL
||
1646 scheduledParent
== m_properties
||
1647 scheduledParent
->IsCategory(),
1648 wxT("Parent of a category must be either root or another category."));
1650 // If we already have category with same name, delete given property
1651 // and use it instead as most recent caption item.
1652 wxPGProperty
* found_id
= BaseGetPropertyByName( property
->GetBaseName() );
1655 wxPropertyCategory
* pwc
= (wxPropertyCategory
*) found_id
;
1656 if ( pwc
->IsCategory() ) // Must be a category.
1659 m_currentCategory
= pwc
;
1666 // Warn for identical names in debug mode.
1667 if ( BaseGetPropertyByName(property
->GetName()) &&
1668 (!scheduledParent
|| scheduledParent
->IsCategory()) )
1670 wxFAIL_MSG(wxString::Format(
1671 "wxPropertyGrid item with name \"%s\" already exists",
1672 property
->GetName()));
1674 wxPGGlobalVars
->m_warnings
++;
1676 #endif // wxDEBUG_LEVEL
1678 // NULL parent == root parent
1679 if ( !scheduledParent
)
1680 scheduledParent
= DoGetRoot();
1682 property
->m_parent
= scheduledParent
;
1684 property
->InitAfterAdded(this, propGrid
);
1686 if ( property
->IsCategory() )
1688 wxPropertyCategory
* pc
= wxStaticCast(property
, wxPropertyCategory
);
1690 m_currentCategory
= pc
;
1692 // Calculate text extent for category caption
1694 pc
->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
1700 // -----------------------------------------------------------------------
1702 wxPGProperty
* wxPropertyGridPageState::DoAppend( wxPGProperty
* property
)
1704 wxPropertyCategory
* cur_cat
= m_currentCategory
;
1705 if ( property
->IsCategory() )
1708 return DoInsert( cur_cat
, -1, property
);
1711 // -----------------------------------------------------------------------
1713 wxPGProperty
* wxPropertyGridPageState::DoInsert( wxPGProperty
* parent
, int index
, wxPGProperty
* property
)
1716 parent
= m_properties
;
1718 wxCHECK_MSG( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1720 wxT("when adding properties to fixed parents, use BeginAddChildren and EndAddChildren.") );
1722 bool res
= PrepareToAddItem( property
, (wxPropertyCategory
*)parent
);
1724 // PrepareToAddItem() may just decide to use current category
1725 // instead of adding new one.
1727 return m_currentCategory
;
1729 bool parentIsRoot
= parent
->IsRoot();
1730 bool parentIsCategory
= parent
->IsCategory();
1732 // Note that item must be added into current mode later.
1734 // If parent is wxParentProperty, just stick it in...
1735 // If parent is root (m_properties), then...
1736 // In categoric mode: Add as last item in m_abcArray (if not category).
1737 // Add to given index in m_regularArray.
1738 // In non-cat mode: Add as last item in m_regularArray.
1739 // Add to given index in m_abcArray.
1740 // If parent is category, then...
1741 // 1) Add to given category in given index.
1742 // 2) Add as last item in m_abcArray.
1744 if ( m_properties
== &m_regularArray
)
1746 // We are currently in Categorized mode
1748 // Only add non-categories to m_abcArray.
1749 if ( m_abcArray
&& !property
->IsCategory() &&
1750 (parentIsCategory
|| parentIsRoot
) )
1752 m_abcArray
->DoAddChild( property
, -1, false );
1755 // Add to current mode.
1756 parent
->DoAddChild( property
, index
, true );
1760 // We are currently in Non-categorized/Alphabetic mode
1762 if ( parentIsCategory
)
1763 // Parent is category.
1764 parent
->DoAddChild( property
, index
, false );
1765 else if ( parentIsRoot
)
1767 m_regularArray
.DoAddChild( property
, -1, false );
1769 // Add to current mode
1770 if ( !property
->IsCategory() )
1771 m_abcArray
->DoAddChild( property
, index
, true );
1775 if ( property
->IsCategory() )
1777 // This is a category caption item.
1779 // Last caption is not the bottom one (this info required by append)
1780 m_lastCaptionBottomnest
= 0;
1783 // Only add name to hashmap if parent is root or category
1784 if ( !property
->m_name
.empty() &&
1785 (parentIsCategory
|| parentIsRoot
) )
1786 m_dictName
[property
->m_name
] = (void*) property
;
1788 VirtualHeightChanged();
1790 property
->UpdateParentValues();
1797 // -----------------------------------------------------------------------
1799 void wxPropertyGridPageState::DoDelete( wxPGProperty
* item
, bool doDelete
)
1801 wxCHECK_RET( item
->GetParent(),
1802 wxT("this property was already deleted") );
1804 wxCHECK_RET( item
!= &m_regularArray
&& item
!= m_abcArray
,
1805 wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
1807 wxPropertyGrid
* pg
= GetGrid();
1809 // Must defer deletion? Yes, if handling a wxPG event.
1810 if ( pg
&& pg
->m_processedEvent
)
1813 pg
->m_deletedProperties
.push_back(item
);
1815 pg
->m_removedProperties
.push_back(item
);
1817 // Rename the property so it won't remain in the way
1818 // of the user code.
1820 // Let's trust that no sane property uses prefix like
1821 // this. It would be anyway fairly inconvenient (in
1822 // current code) to check whether a new name is used
1823 // by another property with parent (due to the child
1825 wxString newName
= wxS("_&/_%$") + item
->GetBaseName();
1826 DoSetPropertyName(item
, newName
);
1831 unsigned int indinparent
= item
->GetIndexInParent();
1833 wxPGProperty
* pwc
= (wxPGProperty
*)item
;
1834 wxPGProperty
* parent
= item
->GetParent();
1836 wxCHECK_RET( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1837 wxT("wxPropertyGrid: Do not attempt to remove sub-properties.") );
1839 wxASSERT( item
->GetParentState() == this );
1841 if ( DoIsPropertySelected(item
) )
1843 if ( pg
&& pg
->GetState() == this )
1845 pg
->DoRemoveFromSelection(item
,
1846 wxPG_SEL_DELETING
|wxPG_SEL_NOVALIDATE
);
1850 DoRemoveFromSelection(item
);
1854 item
->SetFlag(wxPG_PROP_BEING_DELETED
);
1857 if ( item
->GetChildCount() && !item
->HasFlag(wxPG_PROP_AGGREGATE
) )
1859 // deleting a category
1860 if ( item
->IsCategory() )
1862 if ( pwc
== m_currentCategory
)
1863 m_currentCategory
= NULL
;
1866 item
->DeleteChildren();
1869 if ( !IsInNonCatMode() )
1871 // categorized mode - non-categorized array
1873 // Remove from non-cat array
1874 if ( !item
->IsCategory() &&
1875 (parent
->IsCategory() || parent
->IsRoot()) )
1878 m_abcArray
->RemoveChild(item
);
1881 // categorized mode - categorized array
1882 wxArrayPGProperty
& parentsChildren
= parent
->m_children
;
1883 parentsChildren
.erase( parentsChildren
.begin() + indinparent
);
1884 item
->m_parent
->FixIndicesOfChildren();
1888 // non-categorized mode - categorized array
1890 // We need to find location of item.
1891 wxPGProperty
* cat_parent
= &m_regularArray
;
1892 int cat_index
= m_regularArray
.GetChildCount();
1894 for ( i
= 0; i
< m_regularArray
.GetChildCount(); i
++ )
1896 wxPGProperty
* p
= m_regularArray
.Item(i
);
1897 if ( p
== item
) { cat_index
= i
; break; }
1898 if ( p
->IsCategory() )
1900 int subind
= ((wxPGProperty
*)p
)->Index(item
);
1901 if ( subind
!= wxNOT_FOUND
)
1903 cat_parent
= ((wxPGProperty
*)p
);
1909 cat_parent
->m_children
.erase(cat_parent
->m_children
.begin()+cat_index
);
1911 // non-categorized mode - non-categorized array
1912 if ( !item
->IsCategory() )
1914 wxASSERT( item
->m_parent
== m_abcArray
);
1915 wxArrayPGProperty
& parentsChildren
= item
->m_parent
->m_children
;
1916 parentsChildren
.erase(parentsChildren
.begin() + indinparent
);
1917 item
->m_parent
->FixIndicesOfChildren(indinparent
);
1921 if ( !item
->GetBaseName().empty() &&
1922 (parent
->IsCategory() || parent
->IsRoot()) )
1923 m_dictName
.erase(item
->GetBaseName());
1925 // We need to clear parent grid's m_propHover, if it matches item
1926 if ( pg
&& pg
->m_propHover
== item
)
1927 pg
->m_propHover
= NULL
;
1929 // Mark the property as 'unattached'
1930 item
->m_parentState
= NULL
;
1931 item
->m_parent
= NULL
;
1933 // We can actually delete it now
1937 item
->OnDetached(this, pg
);
1939 m_itemsAdded
= 1; // Not a logical assignment (but required nonetheless).
1941 VirtualHeightChanged();
1944 // -----------------------------------------------------------------------
1946 #endif // wxUSE_PROPGRID