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
;
79 if ( startPos
== wxTOP
)
85 else if ( startPos
== wxBOTTOM
)
87 property
= state
->GetLastItem(flags
);
93 wxASSERT_MSG( false, wxT("Only supported stating positions are wxTOP and wxBOTTOM") );
97 Init( state
, flags
, property
, dir
);
100 void wxPropertyGridIteratorBase::Assign( const wxPropertyGridIteratorBase
& it
)
102 m_property
= it
.m_property
;
103 m_state
= it
.m_state
;
104 m_baseParent
= it
.m_baseParent
;
105 m_itemExMask
= it
.m_itemExMask
;
106 m_parentExMask
= it
.m_parentExMask
;
109 void wxPropertyGridIteratorBase::Prev()
111 wxPGProperty
* property
= m_property
;
112 wxASSERT( property
);
114 wxPGProperty
* parent
= property
->GetParent();
116 unsigned int index
= property
->GetIndexInParent();
123 property
= parent
->Item(index
);
125 // Go to last children?
126 if ( property
->GetChildCount() &&
127 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) )
130 property
= property
->Last();
136 if ( parent
== m_baseParent
)
147 m_property
= property
;
149 // If property does not match our criteria, skip it
150 if ( property
->GetFlags() & m_itemExMask
)
154 void wxPropertyGridIteratorBase::Next( bool iterateChildren
)
156 wxPGProperty
* property
= m_property
;
157 wxASSERT( 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()
206 m_pPropGrid
= (wxPropertyGrid
*) NULL
;
207 m_regularArray
.SetParentState(this);
208 m_properties
= &m_regularArray
;
209 m_abcArray
= (wxPGRootProperty
*) NULL
;
210 m_currentCategory
= (wxPropertyCategory
*) NULL
;
211 m_selected
= (wxPGProperty
*) NULL
;
214 m_lastCaptionBottomnest
= 1;
218 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
219 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
220 m_fSplitterX
= wxPG_DEFAULT_SPLITTERX
;
223 // -----------------------------------------------------------------------
225 wxPropertyGridPageState::~wxPropertyGridPageState()
230 // -----------------------------------------------------------------------
232 void wxPropertyGridPageState::InitNonCatMode()
236 m_abcArray
= new wxPGRootProperty();
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 wxPropertyGridIterator
it( this, wxPG_ITERATE_DEFAULT
|wxPG_ITERATE_CATEGORIES
);
253 for ( ; !it
.AtEnd(); it
.Next() )
255 wxPGProperty
* p
= it
.GetProperty();
256 wxPGProperty
* parent
= p
->GetParent();
257 if ( p
->HasFlag(wxPG_PROP_MISC_PARENT
) &&
258 ( parent
== m_properties
|| (parent
->IsCategory() || parent
->IsRoot()) ) )
260 m_abcArray
->AddChild2( p
);
261 p
->m_parent
= &m_regularArray
;
266 m_properties
= oldProperties
;
269 // -----------------------------------------------------------------------
271 void wxPropertyGridPageState::DoClear()
273 m_regularArray
.Empty();
279 m_currentCategory
= (wxPropertyCategory
*) NULL
;
280 m_lastCaptionBottomnest
= 1;
286 m_selected
= (wxPGProperty
*) NULL
;
289 // -----------------------------------------------------------------------
291 void wxPropertyGridPageState::CalculateFontAndBitmapStuff( int WXUNUSED(vspacing
) )
293 wxPropertyGrid
* propGrid
= GetGrid();
295 VirtualHeightChanged();
297 // Recalculate caption text extents.
300 for ( i
=0;i
<m_regularArray
.GetChildCount();i
++ )
302 wxPGProperty
* p
=m_regularArray
.Item(i
);
304 if ( p
->IsCategory() )
305 ((wxPropertyCategory
*)p
)->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
309 // -----------------------------------------------------------------------
311 void wxPropertyGridPageState::SetVirtualWidth( int width
)
313 wxASSERT( width
>= 0 );
314 wxPropertyGrid
* pg
= GetGrid();
315 int gw
= pg
->GetClientSize().x
;
322 // -----------------------------------------------------------------------
324 void wxPropertyGridPageState::OnClientWidthChange( int newWidth
, int widthChange
, bool fromOnResize
)
326 wxPropertyGrid
* pg
= GetGrid();
328 if ( pg
->HasVirtualWidth() )
330 if ( m_width
< newWidth
)
331 SetVirtualWidth( newWidth
);
333 CheckColumnWidths(widthChange
);
337 SetVirtualWidth( newWidth
);
339 // This should be done before splitter auto centering
340 // NOTE: Splitter auto-centering is done in this function.
343 CheckColumnWidths(widthChange
);
345 if ( !(GetGrid()->GetInternalFlags() & wxPG_FL_SPLITTER_PRE_SET
) &&
346 (GetGrid()->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER
) )
348 long timeSinceCreation
= (::wxGetLocalTimeMillis() - GetGrid()->m_timeCreated
).ToLong();
350 // If too long, don't set splitter
351 if ( timeSinceCreation
< 3000 )
353 if ( m_properties
->GetChildCount() || timeSinceCreation
> 750 )
355 SetSplitterLeft( false );
359 DoSetSplitterPosition( newWidth
/ 2 );
360 GetGrid()->ClearInternalFlag(wxPG_FL_SPLITTER_PRE_SET
);
367 // -----------------------------------------------------------------------
368 // wxPropertyGridPageState item iteration methods
369 // -----------------------------------------------------------------------
371 wxPGProperty
* wxPropertyGridPageState::GetLastItem( int flags
)
373 if ( !m_properties
->GetChildCount() )
374 return (wxPGProperty
*) NULL
;
376 wxPG_ITERATOR_CREATE_MASKS(flags
, int itemExMask
, int parentExMask
)
378 // First, get last child of last parent
379 wxPGProperty
* pwc
= (wxPGProperty
*)m_properties
->Last();
380 while ( pwc
->GetChildCount() &&
381 wxPG_ITERATOR_PARENTEXMASK_TEST(pwc
, parentExMask
) )
382 pwc
= (wxPGProperty
*) pwc
->Last();
384 // Then, if it doesn't fit our criteria, back up until we find something that does
385 if ( pwc
->GetFlags() & itemExMask
)
387 wxPropertyGridIterator
it( this, flags
, pwc
);
388 for ( ; !it
.AtEnd(); it
.Prev() )
390 pwc
= (wxPGProperty
*) it
.GetProperty();
396 wxPropertyCategory
* wxPropertyGridPageState::GetPropertyCategory( const wxPGProperty
* p
) const
398 const wxPGProperty
* parent
= (const wxPGProperty
*)p
;
399 const wxPGProperty
* grandparent
= (const wxPGProperty
*)parent
->GetParent();
402 parent
= grandparent
;
403 grandparent
= (wxPGProperty
*)parent
->GetParent();
404 if ( parent
->IsCategory() && grandparent
)
405 return (wxPropertyCategory
*)parent
;
406 } while ( grandparent
);
408 return (wxPropertyCategory
*) NULL
;
411 // -----------------------------------------------------------------------
412 // wxPropertyGridPageState GetPropertyXXX methods
413 // -----------------------------------------------------------------------
415 wxPGProperty
* wxPropertyGridPageState::GetPropertyByLabel( const wxString
& label
,
416 wxPGProperty
* parent
) const
421 if ( !parent
) parent
= (wxPGProperty
*) &m_regularArray
;
423 for ( i
=0; i
<parent
->GetChildCount(); i
++ )
425 wxPGProperty
* p
= parent
->Item(i
);
426 if ( p
->m_label
== label
)
428 // Check children recursively.
429 if ( p
->GetChildCount() )
431 p
= GetPropertyByLabel(label
,(wxPGProperty
*)p
);
440 // -----------------------------------------------------------------------
442 wxPGProperty
* wxPropertyGridPageState::BaseGetPropertyByName( const wxString
& name
) const
444 wxPGHashMapS2P::const_iterator it
;
445 it
= m_dictName
.find(name
);
446 if ( it
!= m_dictName
.end() )
447 return (wxPGProperty
*) it
->second
;
448 return (wxPGProperty
*) NULL
;
451 // -----------------------------------------------------------------------
453 void wxPropertyGridPageState::DoSetPropertyName( wxPGProperty
* p
,
454 const wxString
& newName
)
456 wxCHECK_RET( p
, wxT("invalid property id") );
458 if ( p
->GetBaseName().Len() ) m_dictName
.erase( p
->GetBaseName() );
459 if ( newName
.Len() ) m_dictName
[newName
] = (void*) p
;
461 p
->DoSetName(newName
);
464 // -----------------------------------------------------------------------
465 // wxPropertyGridPageState global operations
466 // -----------------------------------------------------------------------
468 // -----------------------------------------------------------------------
469 // Item iteration macros
470 // NB: Nowadays only needed for alphabetic/categoric mode switching.
471 // -----------------------------------------------------------------------
473 #define II_INVALID_I 0x00FFFFFF
475 #define ITEM_ITERATION_VARIABLES \
476 wxPGProperty* parent; \
480 #define ITEM_ITERATION_INIT_FROM_THE_TOP \
481 parent = m_properties; \
484 #define ITEM_ITERATION_INIT(startparent, startindex, state) \
485 parent = startparent; \
486 i = (unsigned int)startindex; \
487 if ( parent == (wxPGProperty*) NULL ) \
489 parent = state->m_properties; \
493 #define ITEM_ITERATION_LOOP_BEGIN \
496 iMax = parent->GetChildCount(); \
499 wxPGProperty* p = parent->Item(i);
501 #define ITEM_ITERATION_LOOP_END \
502 if ( p->GetChildCount() ) \
505 parent = (wxPGProperty*)p; \
506 iMax = parent->GetChildCount(); \
511 i = parent->m_arrIndex + 1; \
512 parent = parent->m_parent; \
514 while ( parent != NULL );
516 bool wxPropertyGridPageState::EnableCategories( bool enable
)
519 // NB: We can't use wxPropertyGridIterator in this
520 // function, since it depends on m_arrIndexes,
521 // which, among other things, is being fixed here.
523 ITEM_ITERATION_VARIABLES
531 if ( !IsInNonCatMode() )
534 m_properties
= &m_regularArray
;
536 // fix parents, indexes, and depths
537 ITEM_ITERATION_INIT_FROM_THE_TOP
539 ITEM_ITERATION_LOOP_BEGIN
543 p
->m_parent
= parent
;
545 // If parent was category, and this is not,
546 // then the depth stays the same.
547 if ( parent
->IsCategory() &&
549 p
->m_depth
= parent
->m_depth
;
551 p
->m_depth
= parent
->m_depth
+ 1;
553 ITEM_ITERATION_LOOP_END
559 // Disable categories
562 if ( IsInNonCatMode() )
565 // Create array, if necessary.
569 m_properties
= m_abcArray
;
571 // fix parents, indexes, and depths
572 ITEM_ITERATION_INIT_FROM_THE_TOP
574 ITEM_ITERATION_LOOP_BEGIN
578 p
->m_parent
= parent
;
580 p
->m_depth
= parent
->m_depth
+ 1;
582 ITEM_ITERATION_LOOP_END
585 VirtualHeightChanged();
587 if ( m_pPropGrid
->GetState() == this )
588 m_pPropGrid
->RecalculateVirtualSize();
593 // -----------------------------------------------------------------------
598 static bool wxPG_SortFunc(wxPGProperty
*p1
, wxPGProperty
*p2
)
600 return p1
->GetLabel() < p2
->GetLabel();
605 static int wxPG_SortFunc(wxPGProperty
**p1
, wxPGProperty
**p2
)
607 wxPGProperty
*pp1
= *p1
;
608 wxPGProperty
*pp2
= *p2
;
609 return pp1
->GetLabel().compare( pp2
->GetLabel() );
614 void wxPropertyGridPageState::SortChildren( wxPGProperty
* p
)
617 p
= (wxPGProperty
*)m_properties
;
619 if ( !p
->GetChildCount() )
622 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
624 // Can only sort items with children
625 if ( pwc
->GetChildCount() < 1 )
629 std::sort(pwc
->m_children
.begin(), pwc
->m_children
.end(), wxPG_SortFunc
);
631 pwc
->m_children
.Sort( wxPG_SortFunc
);
635 pwc
->FixIndexesOfChildren();
639 // -----------------------------------------------------------------------
641 void wxPropertyGridPageState::Sort()
643 SortChildren( m_properties
);
645 // Sort categories as well
646 if ( !IsInNonCatMode() )
649 for ( i
=0;i
<m_properties
->GetChildCount();i
++)
651 wxPGProperty
* p
= m_properties
->Item(i
);
652 if ( p
->IsCategory() )
658 // -----------------------------------------------------------------------
659 // wxPropertyGridPageState splitter, column and hittest functions
660 // -----------------------------------------------------------------------
662 wxPGProperty
* wxPropertyGridPageState::DoGetItemAtY( int y
) const
666 return (wxPGProperty
*) NULL
;
669 return m_properties
->GetItemAtY(y
, GetGrid()->m_lineHeight
, &a
);
672 // -----------------------------------------------------------------------
674 wxPropertyGridHitTestResult
wxPropertyGridPageState::HitTest( const wxPoint
&pt
) const
676 wxPropertyGridHitTestResult result
;
677 result
.column
= HitTestH( pt
.x
, &result
.splitter
, &result
.splitterHitOffset
);
678 result
.property
= DoGetItemAtY( pt
.y
);
682 // -----------------------------------------------------------------------
684 // Used by SetSplitterLeft() and DotFitColumns()
685 int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC
& dc
,
690 wxPropertyGrid
* pg
= m_pPropGrid
;
695 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
697 wxPGProperty
* p
= pwc
->Item(i
);
698 if ( !p
->IsCategory() )
700 dc
.GetTextExtent( p
->GetColumnText(col
), &w
, &h
);
702 w
+= ( ((int)p
->m_depth
-1) * pg
->m_subgroup_extramargin
);
705 // TODO: Add bitmap support.
707 w
+= (wxPG_XBEFORETEXT
*2);
713 if ( p
->GetChildCount() &&
714 ( subProps
|| p
->IsCategory() ) )
716 w
= GetColumnFitWidth( dc
, p
, col
, subProps
);
726 int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn
) const
728 int n
= GetGrid()->m_marginWidth
;
730 for ( i
=0; i
<=splitterColumn
; i
++ )
735 int wxPropertyGridPageState::GetColumnMinWidth( int WXUNUSED(column
) ) const
737 return wxPG_DRAG_MARGIN
;
740 void wxPropertyGridPageState::PropagateColSizeDec( int column
, int decrease
, int dir
)
742 int origWidth
= m_colWidths
[column
];
743 m_colWidths
[column
] -= decrease
;
744 int min
= GetColumnMinWidth(column
);
746 if ( m_colWidths
[column
] < min
)
748 more
= decrease
- (origWidth
- min
);
749 m_colWidths
[column
] = min
;
753 // FIXME: Causes erratic splitter changing, so as a workaround
754 // disabled if two or less columns.
756 if ( m_colWidths
.size() <= 2 )
760 if ( more
&& column
< (int)m_colWidths
.size() && column
>= 0 )
761 PropagateColSizeDec( column
, more
, dir
);
764 void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos
, int splitterColumn
, bool WXUNUSED(allPages
), bool fromAutoCenter
)
766 wxPropertyGrid
* pg
= GetGrid();
768 int adjust
= newXPos
- DoGetSplitterPosition(splitterColumn
);
770 if ( !pg
->HasVirtualWidth() )
776 otherColumn
= splitterColumn
+ 1;
777 if ( otherColumn
== (int)m_colWidths
.size() )
779 m_colWidths
[splitterColumn
] += adjust
;
780 PropagateColSizeDec( otherColumn
, adjust
, 1 );
784 otherColumn
= splitterColumn
+ 1;
785 if ( otherColumn
== (int)m_colWidths
.size() )
787 m_colWidths
[otherColumn
] -= adjust
;
788 PropagateColSizeDec( splitterColumn
, -adjust
, -1 );
793 m_colWidths
[splitterColumn
] += adjust
;
796 if ( splitterColumn
== 0 )
797 m_fSplitterX
= (double) newXPos
;
799 if ( !fromAutoCenter
)
801 // Don't allow initial splitter auto-positioning after this.
802 if ( pg
->GetState() == this )
803 pg
->SetInternalFlag(wxPG_FL_SPLITTER_PRE_SET
);
809 // Moves splitter so that all labels are visible, but just.
810 void wxPropertyGridPageState::SetSplitterLeft( bool subProps
)
812 wxPropertyGrid
* pg
= GetGrid();
814 dc
.SetFont(pg
->m_font
);
816 int maxW
= GetColumnFitWidth(dc
, m_properties
, 0, subProps
);
820 maxW
+= pg
->m_marginWidth
;
821 DoSetSplitterPosition( maxW
);
824 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
827 wxSize
wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize
) )
829 wxPropertyGrid
* pg
= GetGrid();
831 dc
.SetFont(pg
->m_font
);
833 int marginWidth
= pg
->m_marginWidth
;
834 int accWid
= marginWidth
;
835 int maxColWidth
= 500;
837 for ( unsigned int col
=0; col
< GetColumnCount(); col
++ )
839 int fitWid
= GetColumnFitWidth(dc
, m_properties
, col
, true);
840 int colMinWidth
= GetColumnMinWidth(col
);
841 if ( fitWid
< colMinWidth
)
842 fitWid
= colMinWidth
;
843 else if ( fitWid
> maxColWidth
)
844 fitWid
= maxColWidth
;
846 m_colWidths
[col
] = fitWid
;
851 // Expand last one to fill the width
852 int remaining
= m_width
- accWid
;
853 m_colWidths
[GetColumnCount()-1] += remaining
;
855 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
857 int firstSplitterX
= marginWidth
+ m_colWidths
[0];
858 m_fSplitterX
= (double) firstSplitterX
;
860 // Don't allow initial splitter auto-positioning after this.
861 if ( pg
->GetState() == this )
863 pg
->SetSplitterPosition(firstSplitterX
, false);
868 pg
->GetVirtualSize(&x
, &y
);
870 return wxSize(accWid
, y
);
873 void wxPropertyGridPageState::CheckColumnWidths( int widthChange
)
878 wxPropertyGrid
* pg
= GetGrid();
881 const bool debug
= false;
885 unsigned int lastColumn
= m_colWidths
.size() - 1;
887 int clientWidth
= pg
->GetClientSize().x
;
890 // Column to reduce, if needed. Take last one that exceeds minimum width.
891 // Except if auto splitter centering is used, in which case use widest.
893 int highestColWidth
= 0;
895 bool minimizedCols
= false;
899 wxLogDebug(wxT("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"), width
, clientWidth
);
904 for ( i
=0; i
<m_colWidths
.size(); i
++ )
906 int min
= GetColumnMinWidth(i
);
907 if ( m_colWidths
[i
] <= min
)
909 m_colWidths
[i
] = min
;
910 minimizedCols
= true;
914 if ( pg
->HasFlag(wxPG_SPLITTER_AUTO_CENTER
) )
916 if ( m_colWidths
[i
] >= highestColWidth
)
918 highestColWidth
= m_colWidths
[i
];
929 int colsWidth
= pg
->m_marginWidth
;
930 for ( i
=0; i
<m_colWidths
.size(); i
++ )
931 colsWidth
+= m_colWidths
[i
];
935 wxLogDebug(wxT(" HasVirtualWidth: %i colsWidth: %i"),(int)pg
->HasVirtualWidth(),colsWidth
);
938 // Then mode-based requirement
939 if ( !pg
->HasVirtualWidth() )
941 int widthHigher
= width
- colsWidth
;
943 // Adapt colsWidth to width
944 if ( colsWidth
< width
)
949 wxLogDebug(wxT(" Adjust last column to %i"), m_colWidths
[lastColumn
] + widthHigher
);
951 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + widthHigher
;
953 else if ( colsWidth
> width
)
956 if ( reduceCol
!= -1 )
960 wxLogDebug(wxT(" Reduce column %i (by %i)"), reduceCol
, -widthHigher
);
962 // Reduce widest column, and recheck
963 m_colWidths
[reduceCol
] = m_colWidths
[reduceCol
] + widthHigher
;
970 // Only check colsWidth against clientWidth
971 if ( colsWidth
< clientWidth
)
973 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + (clientWidth
-colsWidth
);
978 // If width changed, recalculate virtual size
979 if ( pg
->GetState() == this )
980 pg
->RecalculateVirtualSize();
985 for ( i
=0; i
<m_colWidths
.size(); i
++ )
986 wxLogDebug(wxT("col%i: %i"),i
,m_colWidths
[i
]);
989 // Auto center splitter
990 if ( !(pg
->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER
) &&
991 m_colWidths
.size() == 2 )
993 float centerX
= (float)(pg
->m_width
/2);
996 if ( m_fSplitterX
< 0.0 )
1000 else if ( widthChange
)
1002 //float centerX = float(pg->GetSize().x) * 0.5;
1005 splitterX
= m_fSplitterX
+ (float(widthChange
) * 0.5);
1006 float deviation
= fabs(centerX
- splitterX
);
1008 // If deviating from center, adjust towards it
1009 if ( deviation
> 20.0 )
1011 if ( splitterX
> centerX
)
1019 // No width change, just keep sure we keep splitter position intact
1020 splitterX
= m_fSplitterX
;
1021 float deviation
= fabs(centerX
- splitterX
);
1022 if ( deviation
> 50.0 )
1024 splitterX
= centerX
;
1028 DoSetSplitterPosition((int)splitterX
, 0, false, true);
1030 m_fSplitterX
= splitterX
; // needed to retain accuracy
1034 void wxPropertyGridPageState::SetColumnCount( int colCount
)
1036 wxASSERT( colCount
>= 2 );
1037 m_colWidths
.SetCount( colCount
, wxPG_DRAG_MARGIN
);
1038 if ( m_colWidths
.size() > (unsigned int)colCount
)
1039 m_colWidths
.RemoveAt( m_colWidths
.size(), m_colWidths
.size() - colCount
);
1041 if ( m_pPropGrid
->GetState() == this )
1042 m_pPropGrid
->RecalculateVirtualSize();
1044 CheckColumnWidths();
1047 // Returns column index, -1 for margin
1048 int wxPropertyGridPageState::HitTestH( int x
, int* pSplitterHit
, int* pSplitterHitOffset
) const
1050 int cx
= GetGrid()->m_marginWidth
;
1052 int prevSplitter
= -1;
1057 if ( col
>= (int)m_colWidths
.size() )
1063 cx
+= m_colWidths
[col
];
1066 // Near prev. splitter
1069 int diff
= x
- prevSplitter
;
1070 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1072 *pSplitterHit
= col
- 1;
1073 *pSplitterHitOffset
= diff
;
1078 // Near next splitter
1079 int nextSplitter
= cx
;
1080 if ( col
< (int)(m_colWidths
.size()-1) )
1082 int diff
= x
- nextSplitter
;
1083 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1085 *pSplitterHit
= col
;
1086 *pSplitterHitOffset
= diff
;
1095 // -----------------------------------------------------------------------
1096 // wxPropertyGridPageState property value setting and getting
1097 // -----------------------------------------------------------------------
1099 bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty
* p
, const wxString
& value
)
1103 int flags
= wxPG_REPORT_ERROR
|wxPG_FULL_VALUE
;
1105 wxVariant variant
= p
->GetValueRef();
1108 if ( p
->GetMaxLength() <= 0 )
1109 res
= p
->StringToValue( variant
, value
, flags
);
1111 res
= p
->StringToValue( variant
, value
.Mid(0,p
->GetMaxLength()), flags
);
1115 p
->SetValue(variant
);
1116 if ( m_selected
==p
&& this==m_pPropGrid
->GetState() )
1117 p
->UpdateControl(m_pPropGrid
->GetEditorControl());
1125 // -----------------------------------------------------------------------
1127 bool wxPropertyGridPageState::DoSetPropertyValue( wxPGProperty
* p
, wxVariant
& value
)
1132 if ( m_selected
==p
&& this==m_pPropGrid
->GetState() )
1133 p
->UpdateControl(m_pPropGrid
->GetEditorControl());
1140 // -----------------------------------------------------------------------
1142 bool wxPropertyGridPageState::DoSetPropertyValueWxObjectPtr( wxPGProperty
* p
, wxObject
* value
)
1146 // wnd_primary has to be given so the control can be updated as well.
1148 DoSetPropertyValue(p
, v
);
1154 // -----------------------------------------------------------------------
1156 void wxPropertyGridPageState::DoSetPropertyValueUnspecified( wxPGProperty
* p
)
1158 wxCHECK_RET( p
, wxT("invalid property id") );
1160 if ( !p
->IsValueUnspecified() )
1162 // Value should be set first - editor class methods may need it
1163 p
->m_value
.MakeNull();
1165 wxASSERT( m_pPropGrid
);
1167 if ( m_pPropGrid
->GetState() == this )
1169 if ( m_pPropGrid
->m_selected
== p
&& m_pPropGrid
->m_wndEditor
)
1171 p
->GetEditorClass()->SetValueToUnspecified(p
, m_pPropGrid
->GetEditorControl());
1176 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1177 DoSetPropertyValueUnspecified( p
->Item(i
) );
1181 // -----------------------------------------------------------------------
1182 // wxPropertyGridPageState property operations
1183 // -----------------------------------------------------------------------
1185 bool wxPropertyGridPageState::DoCollapse( wxPGProperty
* p
)
1187 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1189 if ( !p
->GetChildCount() ) return false;
1191 if ( !p
->IsExpanded() ) return false;
1193 p
->SetExpanded(false);
1195 VirtualHeightChanged();
1200 // -----------------------------------------------------------------------
1202 bool wxPropertyGridPageState::DoExpand( wxPGProperty
* p
)
1204 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1206 if ( !p
->GetChildCount() ) return false;
1208 if ( p
->IsExpanded() ) return false;
1210 p
->SetExpanded(true);
1212 VirtualHeightChanged();
1217 // -----------------------------------------------------------------------
1219 bool wxPropertyGridPageState::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
1221 if ( this == m_pPropGrid
->GetState() )
1222 return m_pPropGrid
->DoSelectProperty( p
, flags
);
1228 // -----------------------------------------------------------------------
1230 bool wxPropertyGridPageState::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
1233 p
->ClearFlag( wxPG_PROP_HIDDEN
);
1235 p
->SetFlag( wxPG_PROP_HIDDEN
);
1237 if ( flags
& wxPG_RECURSE
)
1240 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1241 DoHideProperty(p
->Item(i
), hide
, flags
| wxPG_RECURSE_STARTS
);
1244 VirtualHeightChanged();
1249 // -----------------------------------------------------------------------
1251 bool wxPropertyGridPageState::DoEnableProperty( wxPGProperty
* p
, bool enable
)
1257 if ( !(p
->m_flags
& wxPG_PROP_DISABLED
) )
1262 p
->m_flags
&= ~(wxPG_PROP_DISABLED
);
1266 if ( p
->m_flags
& wxPG_PROP_DISABLED
)
1271 p
->m_flags
|= wxPG_PROP_DISABLED
;
1275 // Apply same to sub-properties as well
1277 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1278 DoEnableProperty( p
->Item(i
), enable
);
1285 // -----------------------------------------------------------------------
1286 // wxPropertyGridPageState wxVariant related routines
1287 // -----------------------------------------------------------------------
1289 // Returns list of wxVariant objects (non-categories and non-sub-properties only).
1290 // Never includes sub-properties (unless they are parented by wxParentProperty).
1291 wxVariant
wxPropertyGridPageState::DoGetPropertyValues( const wxString
& listname
,
1292 wxPGProperty
* baseparent
,
1295 wxPGProperty
* pwc
= (wxPGProperty
*) baseparent
;
1297 // Root is the default base-parent.
1301 wxVariantList tempList
;
1302 wxVariant
v( tempList
, listname
);
1304 if ( pwc
->GetChildCount() )
1306 if ( flags
& wxPG_KEEP_STRUCTURE
)
1308 wxASSERT( !pwc
->HasFlag(wxPG_PROP_AGGREGATE
) );
1311 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1313 wxPGProperty
* p
= pwc
->Item(i
);
1314 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1316 wxVariant variant
= p
->GetValue();
1317 variant
.SetName( p
->GetBaseName() );
1318 v
.Append( variant
);
1322 v
.Append( DoGetPropertyValues(p
->m_name
,p
,flags
|wxPG_KEEP_STRUCTURE
) );
1324 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1325 v
.Append( p
->GetAttributesAsList() );
1330 wxPropertyGridConstIterator
it( this, wxPG_ITERATE_DEFAULT
, pwc
->Item(0) );
1331 it
.SetBaseParent( pwc
);
1333 for ( ; !it
.AtEnd(); it
.Next() )
1335 const wxPGProperty
* p
= it
.GetProperty();
1337 // Use a trick to ignore wxParentProperty itself, but not its sub-properties.
1338 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1340 wxVariant variant
= p
->GetValue();
1341 variant
.SetName( p
->GetName() );
1342 v
.Append( variant
);
1343 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1344 v
.Append( p
->GetAttributesAsList() );
1353 // -----------------------------------------------------------------------
1355 void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList
& list
, wxPGProperty
* defaultCategory
)
1357 unsigned char origFrozen
= 1;
1359 if ( m_pPropGrid
->GetState() == this )
1361 origFrozen
= m_pPropGrid
->m_frozen
;
1362 if ( !origFrozen
) m_pPropGrid
->Freeze();
1365 wxPropertyCategory
* use_category
= (wxPropertyCategory
*)defaultCategory
;
1367 if ( !use_category
)
1368 use_category
= (wxPropertyCategory
*)m_properties
;
1370 // Let's iterate over the list of variants.
1371 wxVariantList::const_iterator node
;
1372 int numSpecialEntries
= 0;
1375 // Second pass for special entries
1376 for ( node
= list
.begin(); node
!= list
.end(); node
++ )
1378 wxVariant
*current
= (wxVariant
*)*node
;
1380 // Make sure it is wxVariant.
1381 wxASSERT( current
);
1382 wxASSERT( wxStrcmp(current
->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
1384 const wxString
& name
= current
->GetName();
1385 if ( name
.length() > 0 )
1388 // '@' signified a special entry
1389 if ( name
[0] == wxS('@') )
1391 numSpecialEntries
++;
1395 wxPGProperty
* foundProp
= BaseGetPropertyByName(name
);
1398 wxPGProperty
* p
= foundProp
;
1400 // If it was a list, we still have to go through it.
1401 if ( wxStrcmp(current
->GetType(), wxS("list")) == 0 )
1403 DoSetPropertyValues( current
->GetList(),
1404 p
->IsCategory()?p
:((wxPGProperty
*)NULL
)
1410 if ( wxStrcmp(current
->GetType(), p
->GetValue().GetType()) != 0)
1412 wxLogDebug(wxT("wxPropertyGridPageState::DoSetPropertyValues Warning: Setting value of property \"%s\" from variant"),
1413 p
->GetName().c_str());
1417 p
->SetValue(*current
);
1423 if ( current
->GetType() != wxS("list") )
1429 // Yes, it is; create a sub category and append contents there.
1430 wxPGProperty
* newCat
= DoInsert(use_category
,-1,new wxPropertyCategory(current
->GetName(),wxPG_LABEL
));
1431 DoSetPropertyValues( current
->GetList(), newCat
);
1438 if ( numSpecialEntries
)
1440 for ( node
= list
.begin(); node
!= list
.end(); node
++ )
1442 wxVariant
*current
= (wxVariant
*)*node
;
1444 const wxString
& name
= current
->GetName();
1445 if ( name
.length() > 0 )
1448 // '@' signified a special entry
1449 if ( name
[0] == wxS('@') )
1451 numSpecialEntries
--;
1453 size_t pos2
= name
.rfind(wxS('@'));
1454 if ( pos2
> 0 && pos2
< (name
.size()-1) )
1456 wxString propName
= name
.substr(1, pos2
-1);
1457 wxString entryType
= name
.substr(pos2
+1, wxString::npos
);
1459 if ( entryType
== wxS("attr") )
1462 // List of attributes
1463 wxPGProperty
* foundProp
= BaseGetPropertyByName(propName
);
1466 wxASSERT( current
->GetType() == wxPG_VARIANT_TYPE_LIST
);
1468 wxVariantList
& list2
= current
->GetList();
1469 wxVariantList::const_iterator node2
;
1471 for ( node2
= list2
.begin(); node2
!= list2
.end(); node2
++ )
1473 wxVariant
*attr
= (wxVariant
*)*node2
;
1474 foundProp
->SetAttribute( attr
->GetName(), *attr
);
1479 // ERROR: No such property: 'propName'
1485 // ERROR: Special entry requires name of format @<propname>@<entrytype>
1490 if ( !numSpecialEntries
)
1497 m_pPropGrid
->Thaw();
1499 if ( this == m_pPropGrid
->GetState() )
1501 m_selected
->UpdateControl(m_pPropGrid
->GetEditorControl());
1507 // -----------------------------------------------------------------------
1508 // wxPropertyGridPageState property adding and removal
1509 // -----------------------------------------------------------------------
1511 int wxPropertyGridPageState::PrepareToAddItem( wxPGProperty
* property
,
1512 wxPGProperty
* scheduledParent
)
1514 wxPropertyGrid
* propGrid
= m_pPropGrid
;
1516 // This will allow better behavior.
1517 if ( scheduledParent
== m_properties
)
1518 scheduledParent
= (wxPGProperty
*) NULL
;
1520 if ( scheduledParent
&& !scheduledParent
->IsCategory() )
1522 wxASSERT_MSG( property
->GetBaseName().length(),
1523 "Property's children must have unique, non-empty names within their scope" );
1526 property
->m_parentState
= this;
1528 if ( property
->IsCategory() )
1531 // Parent of a category must be either root or another category
1532 // (otherwise Bad Things might happen).
1533 wxASSERT_MSG( scheduledParent
== NULL
||
1534 scheduledParent
== m_properties
||
1535 scheduledParent
->IsCategory(),
1536 wxT("Parent of a category must be either root or another category."));
1538 // If we already have category with same name, delete given property
1539 // and use it instead as most recent caption item.
1540 wxPGProperty
* found_id
= BaseGetPropertyByName( property
->GetBaseName() );
1543 wxPropertyCategory
* pwc
= (wxPropertyCategory
*) found_id
;
1544 if ( pwc
->IsCategory() ) // Must be a category.
1547 m_currentCategory
= pwc
;
1548 return 2; // Tells the caller what we did.
1554 // Warn for identical names in debug mode.
1555 if ( BaseGetPropertyByName(property
->GetName()) &&
1556 (!scheduledParent
|| scheduledParent
->IsCategory()) )
1558 wxLogError(wxT("wxPropertyGrid: Warning - item with name \"%s\" already exists."),
1559 property
->GetName().c_str());
1560 wxPGGlobalVars
->m_warnings
++;
1564 // Make sure nothing is selected.
1565 if ( propGrid
&& propGrid
->m_selected
)
1567 bool selRes
= propGrid
->ClearSelection();
1568 wxPG_CHECK_MSG_DBG( selRes
,
1570 wxT("failed to deselect a property (editor probably had invalid value)") );
1573 if ( scheduledParent
)
1575 // Use parent's colours.
1576 property
->m_bgColIndex
= scheduledParent
->m_bgColIndex
;
1577 property
->m_fgColIndex
= scheduledParent
->m_fgColIndex
;
1579 // Fix no parent does not yet have parenting flag yet, set one now
1580 if ( !scheduledParent
->HasFlag(wxPG_PROP_PARENTAL_FLAGS
) )
1581 scheduledParent
->SetParentalType(wxPG_PROP_MISC_PARENT
);
1582 //scheduledParent->SetFlag(wxPG_PROP_MISC_PARENT);
1585 // If in hideable adding mode, or if assigned parent is hideable, then
1586 // make this one hideable.
1588 ( scheduledParent
&& (scheduledParent
->m_flags
& wxPG_PROP_HIDDEN
) ) ||
1589 ( propGrid
&& (propGrid
->m_iFlags
& wxPG_FL_ADDING_HIDEABLES
) )
1591 property
->SetFlag( wxPG_PROP_HIDDEN
);
1593 // Set custom image flag.
1594 int custImgHeight
= property
->OnMeasureImage().y
;
1595 if ( custImgHeight
< 0 /*|| custImgHeight > 1*/ )
1597 property
->m_flags
|= wxPG_PROP_CUSTOMIMAGE
;
1600 if ( propGrid
&& (propGrid
->GetWindowStyleFlag() & wxPG_LIMITED_EDITING
) )
1601 property
->m_flags
|= wxPG_PROP_NOEDITOR
;
1603 if ( !property
->IsCategory() )
1605 // This is not a category.
1607 //wxASSERT_MSG( property->GetEditorClass(), wxT("Editor class not initialized!") );
1611 unsigned char depth
= 1;
1612 if ( scheduledParent
)
1614 depth
= scheduledParent
->m_depth
;
1615 if ( !scheduledParent
->IsCategory() )
1618 property
->m_depth
= depth
;
1619 unsigned char greyDepth
= depth
;
1621 if ( scheduledParent
)
1623 wxPropertyCategory
* pc
;
1625 if ( scheduledParent
->IsCategory() || scheduledParent
->IsRoot() )
1626 pc
= (wxPropertyCategory
*)scheduledParent
;
1628 // This conditional compile is necessary to
1629 // bypass some compiler bug.
1630 pc
= GetPropertyCategory(scheduledParent
);
1633 greyDepth
= pc
->GetDepth();
1635 greyDepth
= scheduledParent
->m_depthBgCol
;
1638 property
->m_depthBgCol
= greyDepth
;
1640 // Prepare children pre-added children
1641 if ( property
->GetChildCount() )
1643 property
->SetParentalType(wxPG_PROP_AGGREGATE
);
1645 property
->SetExpanded(false); // Properties with children are not expanded by default.
1646 if ( propGrid
&& propGrid
->GetWindowStyleFlag() & wxPG_HIDE_MARGIN
)
1647 property
->SetExpanded(true); // ...unless it cannot be expanded.
1649 property
->PrepareSubProperties();
1654 if ( propGrid
&& (propGrid
->GetExtraStyle() & wxPG_EX_AUTO_UNSPECIFIED_VALUES
) )
1655 property
->SetFlagRecursively(wxPG_PROP_AUTO_UNSPECIFIED
, true);
1661 // This is a category.
1664 unsigned char depth
= 1;
1665 if ( scheduledParent
)
1667 depth
= scheduledParent
->m_depth
+ 1;
1669 property
->m_depth
= depth
;
1670 property
->m_depthBgCol
= depth
;
1672 m_currentCategory
= (wxPropertyCategory
*)property
;
1674 wxPropertyCategory
* pc
= (wxPropertyCategory
*)property
;
1676 // Calculate text extent for caption item.
1678 pc
->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
1684 // -----------------------------------------------------------------------
1686 wxPGProperty
* wxPropertyGridPageState::DoAppend( wxPGProperty
* property
)
1688 wxPropertyCategory
* cur_cat
= m_currentCategory
;
1689 if ( property
->IsCategory() )
1690 cur_cat
= (wxPropertyCategory
*) NULL
;
1692 return DoInsert( cur_cat
, -1, property
);
1695 // -----------------------------------------------------------------------
1697 wxPGProperty
* wxPropertyGridPageState::DoInsert( wxPGProperty
* parent
, int index
, wxPGProperty
* property
)
1700 parent
= m_properties
;
1702 wxCHECK_MSG( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1704 wxT("when adding properties to fixed parents, use BeginAddChildren and EndAddChildren.") );
1706 int parenting
= PrepareToAddItem( property
, (wxPropertyCategory
*)parent
);
1708 // This type of invalid parenting value indicates we should exit now, returning
1709 // id of most recent category.
1710 if ( parenting
> 1 )
1711 return m_currentCategory
;
1713 // Note that item must be added into current mode later.
1715 // If parent is wxParentProperty, just stick it in...
1716 // If parent is root (m_properties), then...
1717 // In categoric mode: Add as last item in m_abcArray (if not category).
1718 // Add to given index in m_regularArray.
1719 // In non-cat mode: Add as last item in m_regularArray.
1720 // Add to given index in m_abcArray.
1721 // If parent is category, then...
1722 // 1) Add to given category in given index.
1723 // 2) Add as last item in m_abcArray.
1725 if ( !parent
->IsCategory() && !parent
->IsRoot() )
1727 // Parent is wxParentingProperty: Just stick it in...
1728 parent
->AddChild2( property
, index
);
1732 // Parent is Category or Root.
1734 if ( m_properties
== &m_regularArray
)
1738 // Only add non-categories to m_abcArray.
1739 if ( m_abcArray
&& parenting
<= 0 )
1740 m_abcArray
->AddChild2( property
, -1, false );
1742 // Add to current mode.
1743 parent
->AddChild2( property
, index
);
1748 // Non-categorized mode.
1750 if ( parent
!= m_properties
)
1751 // Parent is category.
1752 parent
->AddChild2( property
, index
, false );
1755 m_regularArray
.AddChild2( property
, -1, false );
1757 // Add to current mode (no categories).
1758 if ( parenting
<= 0 )
1759 m_abcArray
->AddChild2( property
, index
);
1764 if ( property
->IsCategory() )
1766 // This is a category caption item.
1768 // Last caption is not the bottom one (this info required by append)
1769 m_lastCaptionBottomnest
= 0;
1772 // Only add name to hashmap if parent is root or category
1773 if ( (parent
->IsCategory() || parent
->IsRoot()) && property
->m_name
.length() )
1774 m_dictName
[property
->m_name
] = (void*) property
;
1776 VirtualHeightChanged();
1778 property
->UpdateParentValues();
1785 // -----------------------------------------------------------------------
1787 void wxPropertyGridPageState::DoDelete( wxPGProperty
* item
)
1789 wxCHECK_RET( item
->GetParent(),
1790 wxT("this property was already deleted") );
1792 wxCHECK_RET( item
!= &m_regularArray
&& item
!= m_abcArray
,
1793 wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
1796 unsigned int indinparent
= item
->GetIndexInParent();
1798 wxPGProperty
* pwc
= (wxPGProperty
*)item
;
1800 wxCHECK_RET( !item
->GetParent()->HasFlag(wxPG_PROP_AGGREGATE
),
1801 wxT("wxPropertyGrid: Do not attempt to remove sub-properties.") );
1803 if ( item
->IsCategory() )
1805 // deleting a category
1807 // erase category entries from the hash table
1808 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1810 wxPGProperty
* sp
= pwc
->Item( i
);
1811 if ( sp
->GetBaseName().Len() ) m_dictName
.erase(sp
->GetBaseName());
1814 if ( pwc
== m_currentCategory
)
1815 m_currentCategory
= (wxPropertyCategory
*) NULL
;
1819 // Remove children from non-categorized array.
1820 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1822 wxPGProperty
* p
= pwc
->Item( i
);
1823 wxASSERT( p
!= NULL
);
1824 if ( !p
->IsCategory() )
1825 m_abcArray
->RemoveChild(p
);
1828 if ( IsInNonCatMode() )
1829 m_abcArray
->FixIndexesOfChildren();
1833 if ( !IsInNonCatMode() )
1835 // categorized mode - non-categorized array
1837 // Remove from non-cat array, but only if parent is in it
1838 if ( !item
->IsCategory() && item
->GetParent()->IsCategory() )
1841 m_abcArray
->RemoveChild(item
);
1844 // categorized mode - categorized array
1845 wxArrayPGProperty
& parentsChildren
= item
->m_parent
->m_children
;
1846 parentsChildren
.erase( parentsChildren
.begin() + indinparent
);
1847 item
->m_parent
->FixIndexesOfChildren();
1851 // non-categorized mode - categorized array
1853 // We need to find location of item.
1854 wxPGProperty
* cat_parent
= &m_regularArray
;
1855 int cat_index
= m_regularArray
.GetChildCount();
1857 for ( i
= 0; i
< m_regularArray
.GetChildCount(); i
++ )
1859 wxPGProperty
* p
= m_regularArray
.Item(i
);
1860 if ( p
== item
) { cat_index
= i
; break; }
1861 if ( p
->IsCategory() )
1863 int subind
= ((wxPGProperty
*)p
)->Index(item
);
1864 if ( subind
!= wxNOT_FOUND
)
1866 cat_parent
= ((wxPGProperty
*)p
);
1872 cat_parent
->m_children
.erase(cat_parent
->m_children
.begin()+cat_index
);
1874 // non-categorized mode - non-categorized array
1875 if ( !item
->IsCategory() )
1877 wxASSERT( item
->m_parent
== m_abcArray
);
1878 wxArrayPGProperty
& parentsChildren
= item
->m_parent
->m_children
;
1879 parentsChildren
.erase(parentsChildren
.begin() + indinparent
);
1880 item
->m_parent
->FixIndexesOfChildren(indinparent
);
1884 if ( item
->GetBaseName().Len() ) m_dictName
.erase(item
->GetBaseName());
1886 // We can actually delete it now
1889 m_itemsAdded
= 1; // Not a logical assignment (but required nonetheless).
1891 VirtualHeightChanged();
1894 // -----------------------------------------------------------------------
1896 #endif // wxUSE_PROPGRID