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"
21 #include "wx/object.h"
23 #include "wx/string.h"
26 #include "wx/window.h"
29 #include "wx/dcmemory.h"
30 #include "wx/button.h"
33 #include "wx/cursor.h"
34 #include "wx/dialog.h"
35 #include "wx/settings.h"
36 #include "wx/msgdlg.h"
37 #include "wx/choice.h"
38 #include "wx/stattext.h"
39 #include "wx/scrolwin.h"
40 #include "wx/dirdlg.h"
41 #include "wx/layout.h"
43 #include "wx/textdlg.h"
44 #include "wx/filedlg.h"
45 #include "wx/statusbr.h"
48 #include "wx/stopwatch.h"
51 // This define is necessary to prevent macro clearing
52 #define __wxPG_SOURCE_FILE__
54 #include <wx/propgrid/propgridpagestate.h>
55 #include <wx/propgrid/propgrid.h>
56 #include <wx/propgrid/editors.h>
60 #define wxPG_DEFAULT_SPLITTERX 110
63 // -----------------------------------------------------------------------
64 // wxPropertyGridIterator
65 // -----------------------------------------------------------------------
67 void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState
* state
, int flags
, wxPGProperty
* property
, int dir
)
69 wxASSERT( dir
== 1 || dir
== -1 );
72 m_baseParent
= state
->DoGetRoot();
73 if ( !property
&& m_baseParent
->GetChildCount() )
74 property
= m_baseParent
->Item(0);
76 m_property
= property
;
78 wxPG_ITERATOR_CREATE_MASKS(flags
, m_itemExMask
, m_parentExMask
)
80 // Need to skip first?
81 if ( property
&& (property
->GetFlags() & m_itemExMask
) )
90 void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState
* state
, int flags
, int startPos
, int dir
)
92 wxPGProperty
* property
;
94 if ( startPos
== wxTOP
)
100 else if ( startPos
== wxBOTTOM
)
102 property
= state
->GetLastItem(flags
);
108 wxASSERT_MSG( false, wxT("Only supported stating positions are wxTOP and wxBOTTOM") );
112 Init( state
, flags
, property
, dir
);
115 void wxPropertyGridIteratorBase::Assign( const wxPropertyGridIteratorBase
& it
)
117 m_property
= it
.m_property
;
118 m_state
= it
.m_state
;
119 m_baseParent
= it
.m_baseParent
;
120 m_itemExMask
= it
.m_itemExMask
;
121 m_parentExMask
= it
.m_parentExMask
;
124 void wxPropertyGridIteratorBase::Prev()
126 wxPGProperty
* property
= m_property
;
127 wxASSERT( property
);
129 wxPGProperty
* parent
= property
->GetParent();
131 unsigned int index
= property
->GetIndexInParent();
138 property
= parent
->Item(index
);
140 // Go to last children?
141 if ( property
->GetChildCount() &&
142 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) )
145 property
= property
->Last();
151 if ( parent
== m_baseParent
)
162 m_property
= property
;
164 // If property does not match our criteria, skip it
165 if ( property
->GetFlags() & m_itemExMask
)
169 void wxPropertyGridIteratorBase::Next( bool iterateChildren
)
171 wxPGProperty
* property
= m_property
;
172 wxASSERT( property
);
174 if ( property
->GetChildCount() &&
175 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) &&
179 property
= property
->Item(0);
183 wxPGProperty
* parent
= property
->GetParent();
185 unsigned int index
= property
->GetIndexInParent() + 1;
187 if ( index
< parent
->GetChildCount() )
190 property
= parent
->Item(index
);
194 // Next sibling of parent
195 if ( parent
== m_baseParent
)
208 m_property
= property
;
210 // If property does not match our criteria, skip it
211 if ( property
->GetFlags() & m_itemExMask
)
215 // -----------------------------------------------------------------------
216 // wxPropertyGridPageState
217 // -----------------------------------------------------------------------
219 wxPropertyGridPageState::wxPropertyGridPageState()
221 m_pPropGrid
= (wxPropertyGrid
*) NULL
;
222 m_regularArray
.SetParentState(this);
223 m_properties
= &m_regularArray
;
224 m_abcArray
= (wxPGRootProperty
*) NULL
;
225 m_currentCategory
= (wxPropertyCategory
*) NULL
;
226 m_selected
= (wxPGProperty
*) NULL
;
229 m_lastCaptionBottomnest
= 1;
233 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
234 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
235 m_fSplitterX
= wxPG_DEFAULT_SPLITTERX
;
238 // -----------------------------------------------------------------------
240 wxPropertyGridPageState::~wxPropertyGridPageState()
245 // -----------------------------------------------------------------------
247 void wxPropertyGridPageState::InitNonCatMode()
251 m_abcArray
= new wxPGRootProperty();
252 m_abcArray
->SetParentState(this);
253 m_abcArray
->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES
);
256 // Must be called when state::m_properties still points to regularArray.
257 wxPGProperty
* oldProperties
= m_properties
;
259 // Must use temp value in state::m_properties for item iteration loop
260 // to run as expected.
261 m_properties
= &m_regularArray
;
263 if ( m_properties
->GetChildCount() )
266 wxPropertyGridIterator
it( this, wxPG_ITERATE_DEFAULT
|wxPG_ITERATE_CATEGORIES
);
268 for ( ; !it
.AtEnd(); it
.Next() )
270 wxPGProperty
* p
= it
.GetProperty();
271 wxPGProperty
* parent
= p
->GetParent();
272 if ( p
->HasFlag(wxPG_PROP_MISC_PARENT
) &&
273 ( parent
== m_properties
|| (parent
->IsCategory() || parent
->IsRoot()) ) )
275 m_abcArray
->AddChild2( p
);
276 p
->m_parent
= &m_regularArray
;
281 m_properties
= oldProperties
;
284 // -----------------------------------------------------------------------
286 void wxPropertyGridPageState::DoClear()
288 m_regularArray
.Empty();
294 m_currentCategory
= (wxPropertyCategory
*) NULL
;
295 m_lastCaptionBottomnest
= 1;
301 m_selected
= (wxPGProperty
*) NULL
;
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 wxASSERT( width
>= 0 );
329 wxPropertyGrid
* pg
= GetGrid();
330 int gw
= pg
->GetClientSize().x
;
337 // -----------------------------------------------------------------------
339 void wxPropertyGridPageState::OnClientWidthChange( int newWidth
, int widthChange
, bool fromOnResize
)
341 wxPropertyGrid
* pg
= GetGrid();
343 if ( pg
->HasVirtualWidth() )
345 if ( m_width
< newWidth
)
346 SetVirtualWidth( newWidth
);
348 CheckColumnWidths(widthChange
);
352 SetVirtualWidth( newWidth
);
354 // This should be done before splitter auto centering
355 // NOTE: Splitter auto-centering is done in this function.
358 CheckColumnWidths(widthChange
);
360 if ( !(GetGrid()->GetInternalFlags() & wxPG_FL_SPLITTER_PRE_SET
) &&
361 (GetGrid()->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER
) )
363 long timeSinceCreation
= (::wxGetLocalTimeMillis() - GetGrid()->m_timeCreated
).ToLong();
365 // If too long, don't set splitter
366 if ( timeSinceCreation
< 3000 )
368 if ( m_properties
->GetChildCount() || timeSinceCreation
> 750 )
370 SetSplitterLeft( false );
374 DoSetSplitterPosition( newWidth
/ 2 );
375 GetGrid()->ClearInternalFlag(wxPG_FL_SPLITTER_PRE_SET
);
382 // -----------------------------------------------------------------------
383 // wxPropertyGridPageState item iteration methods
384 // -----------------------------------------------------------------------
386 wxPGProperty
* wxPropertyGridPageState::GetLastItem( int flags
)
388 if ( !m_properties
->GetChildCount() )
389 return (wxPGProperty
*) NULL
;
391 wxPG_ITERATOR_CREATE_MASKS(flags
, int itemExMask
, int parentExMask
)
393 // First, get last child of last parent
394 wxPGProperty
* pwc
= (wxPGProperty
*)m_properties
->Last();
395 while ( pwc
->GetChildCount() &&
396 wxPG_ITERATOR_PARENTEXMASK_TEST(pwc
, parentExMask
) )
397 pwc
= (wxPGProperty
*) pwc
->Last();
399 // Then, if it doesn't fit our criteria, back up until we find something that does
400 if ( pwc
->GetFlags() & itemExMask
)
402 wxPropertyGridIterator
it( this, flags
, pwc
);
403 for ( ; !it
.AtEnd(); it
.Prev() )
405 pwc
= (wxPGProperty
*) it
.GetProperty();
411 wxPropertyCategory
* wxPropertyGridPageState::GetPropertyCategory( const wxPGProperty
* p
) const
413 const wxPGProperty
* parent
= (const wxPGProperty
*)p
;
414 const wxPGProperty
* grandparent
= (const wxPGProperty
*)parent
->GetParent();
417 parent
= grandparent
;
418 grandparent
= (wxPGProperty
*)parent
->GetParent();
419 if ( parent
->IsCategory() && grandparent
)
420 return (wxPropertyCategory
*)parent
;
421 } while ( grandparent
);
423 return (wxPropertyCategory
*) NULL
;
426 // -----------------------------------------------------------------------
427 // wxPropertyGridPageState GetPropertyXXX methods
428 // -----------------------------------------------------------------------
430 wxPGProperty
* wxPropertyGridPageState::GetPropertyByLabel( const wxString
& label
,
431 wxPGProperty
* parent
) const
436 if ( !parent
) parent
= (wxPGProperty
*) &m_regularArray
;
438 for ( i
=0; i
<parent
->GetChildCount(); i
++ )
440 wxPGProperty
* p
= parent
->Item(i
);
441 if ( p
->m_label
== label
)
443 // Check children recursively.
444 if ( p
->GetChildCount() )
446 p
= GetPropertyByLabel(label
,(wxPGProperty
*)p
);
455 // -----------------------------------------------------------------------
457 wxPGProperty
* wxPropertyGridPageState::BaseGetPropertyByName( const wxString
& name
) const
459 wxPGHashMapS2P::const_iterator it
;
460 it
= m_dictName
.find(name
);
461 if ( it
!= m_dictName
.end() )
462 return (wxPGProperty
*) it
->second
;
463 return (wxPGProperty
*) NULL
;
466 // -----------------------------------------------------------------------
467 // wxPropertyGridPageState global operations
468 // -----------------------------------------------------------------------
470 // -----------------------------------------------------------------------
471 // Item iteration macros
472 // NB: Nowadays only needed for alphabetic/categoric mode switching.
473 // -----------------------------------------------------------------------
475 #define II_INVALID_I 0x00FFFFFF
477 #define ITEM_ITERATION_VARIABLES \
478 wxPGProperty* parent; \
482 #define ITEM_ITERATION_INIT_FROM_THE_TOP \
483 parent = m_properties; \
486 #define ITEM_ITERATION_INIT(startparent, startindex, state) \
487 parent = startparent; \
488 i = (unsigned int)startindex; \
489 if ( parent == (wxPGProperty*) NULL ) \
491 parent = state->m_properties; \
495 #define ITEM_ITERATION_LOOP_BEGIN \
498 iMax = parent->GetChildCount(); \
501 wxPGProperty* p = parent->Item(i);
503 #define ITEM_ITERATION_LOOP_END \
504 if ( p->GetChildCount() ) \
507 parent = (wxPGProperty*)p; \
508 iMax = parent->GetChildCount(); \
513 i = parent->m_arrIndex + 1; \
514 parent = parent->m_parent; \
516 while ( parent != NULL );
518 bool wxPropertyGridPageState::EnableCategories( bool enable
)
521 // NB: We can't use wxPropertyGridIterator in this
522 // function, since it depends on m_arrIndexes,
523 // which, among other things, is being fixed here.
525 ITEM_ITERATION_VARIABLES
533 if ( !IsInNonCatMode() )
536 m_properties
= &m_regularArray
;
538 // fix parents, indexes, and depths
539 ITEM_ITERATION_INIT_FROM_THE_TOP
541 ITEM_ITERATION_LOOP_BEGIN
545 p
->m_parent
= parent
;
547 // If parent was category, and this is not,
548 // then the depth stays the same.
549 if ( parent
->IsCategory() &&
551 p
->m_depth
= parent
->m_depth
;
553 p
->m_depth
= parent
->m_depth
+ 1;
555 ITEM_ITERATION_LOOP_END
561 // Disable categories
564 if ( IsInNonCatMode() )
567 // Create array, if necessary.
571 m_properties
= m_abcArray
;
573 // fix parents, indexes, and depths
574 ITEM_ITERATION_INIT_FROM_THE_TOP
576 ITEM_ITERATION_LOOP_BEGIN
580 p
->m_parent
= parent
;
582 p
->m_depth
= parent
->m_depth
+ 1;
584 ITEM_ITERATION_LOOP_END
587 VirtualHeightChanged();
589 if ( m_pPropGrid
->GetState() == this )
590 m_pPropGrid
->RecalculateVirtualSize();
595 // -----------------------------------------------------------------------
597 static int wxPG_SortFunc(void **p1
, void **p2
)
599 wxPGProperty
*pp1
= *((wxPGProperty
**)p1
);
600 wxPGProperty
*pp2
= *((wxPGProperty
**)p2
);
601 return pp1
->GetLabel().compare( pp2
->GetLabel() );
604 void wxPropertyGridPageState::SortChildren( wxPGProperty
* p
)
607 p
= (wxPGProperty
*)m_properties
;
609 if ( !p
->GetChildCount() )
612 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
614 // Can only sort items with children
615 if ( pwc
->GetChildCount() < 1 )
618 pwc
->m_children
.Sort( wxPG_SortFunc
);
621 pwc
->FixIndexesOfChildren();
625 // -----------------------------------------------------------------------
627 void wxPropertyGridPageState::Sort()
629 SortChildren( m_properties
);
631 // Sort categories as well
632 if ( !IsInNonCatMode() )
635 for ( i
=0;i
<m_properties
->GetChildCount();i
++)
637 wxPGProperty
* p
= m_properties
->Item(i
);
638 if ( p
->IsCategory() )
644 // -----------------------------------------------------------------------
645 // wxPropertyGridPageState splitter, column and hittest functions
646 // -----------------------------------------------------------------------
648 wxPGProperty
* wxPropertyGridPageState::DoGetItemAtY( int y
) const
652 return (wxPGProperty
*) NULL
;
655 return m_properties
->GetItemAtY(y
, GetGrid()->m_lineHeight
, &a
);
658 // -----------------------------------------------------------------------
660 wxPropertyGridHitTestResult
wxPropertyGridPageState::HitTest( const wxPoint
&pt
) const
662 wxPropertyGridHitTestResult result
;
663 result
.column
= HitTestH( pt
.x
, &result
.splitter
, &result
.splitterHitOffset
);
664 result
.property
= DoGetItemAtY( pt
.y
);
668 // -----------------------------------------------------------------------
670 // Used by SetSplitterLeft() and DotFitColumns()
671 int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC
& dc
,
676 wxPropertyGrid
* pg
= m_pPropGrid
;
681 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
683 wxPGProperty
* p
= pwc
->Item(i
);
684 if ( !p
->IsCategory() )
686 dc
.GetTextExtent( p
->GetColumnText(col
), &w
, &h
);
688 w
+= ( ((int)p
->m_depth
-1) * pg
->m_subgroup_extramargin
);
691 // TODO: Add bitmap support.
693 w
+= (wxPG_XBEFORETEXT
*2);
699 if ( p
->GetChildCount() &&
700 ( subProps
|| p
->IsCategory() ) )
702 w
= GetColumnFitWidth( dc
, p
, col
, subProps
);
712 int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn
) const
714 int n
= GetGrid()->m_marginWidth
;
716 for ( i
=0; i
<=splitterColumn
; i
++ )
721 int wxPropertyGridPageState::GetColumnMinWidth( int WXUNUSED(column
) ) const
723 return wxPG_DRAG_MARGIN
;
726 void wxPropertyGridPageState::PropagateColSizeDec( int column
, int decrease
, int dir
)
728 int origWidth
= m_colWidths
[column
];
729 m_colWidths
[column
] -= decrease
;
730 int min
= GetColumnMinWidth(column
);
732 if ( m_colWidths
[column
] < min
)
734 more
= decrease
- (origWidth
- min
);
735 m_colWidths
[column
] = min
;
739 // FIXME: Causes erratic splitter changing, so as a workaround
740 // disabled if two or less columns.
742 if ( m_colWidths
.size() <= 2 )
746 if ( more
&& column
< (int)m_colWidths
.size() && column
>= 0 )
747 PropagateColSizeDec( column
, more
, dir
);
750 void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos
, int splitterColumn
, bool WXUNUSED(allPages
), bool fromAutoCenter
)
752 wxPropertyGrid
* pg
= GetGrid();
754 int adjust
= newXPos
- DoGetSplitterPosition(splitterColumn
);
756 if ( !pg
->HasVirtualWidth() )
762 otherColumn
= splitterColumn
+ 1;
763 if ( otherColumn
== (int)m_colWidths
.size() )
765 m_colWidths
[splitterColumn
] += adjust
;
766 PropagateColSizeDec( otherColumn
, adjust
, 1 );
770 otherColumn
= splitterColumn
+ 1;
771 if ( otherColumn
== (int)m_colWidths
.size() )
773 m_colWidths
[otherColumn
] -= adjust
;
774 PropagateColSizeDec( splitterColumn
, -adjust
, -1 );
779 m_colWidths
[splitterColumn
] += adjust
;
782 if ( splitterColumn
== 0 )
783 m_fSplitterX
= (double) newXPos
;
785 if ( !fromAutoCenter
)
787 // Don't allow initial splitter auto-positioning after this.
788 if ( pg
->GetState() == this )
789 pg
->SetInternalFlag(wxPG_FL_SPLITTER_PRE_SET
);
795 // Moves splitter so that all labels are visible, but just.
796 void wxPropertyGridPageState::SetSplitterLeft( bool subProps
)
798 wxPropertyGrid
* pg
= GetGrid();
800 dc
.SetFont(pg
->m_font
);
802 int maxW
= GetColumnFitWidth(dc
, m_properties
, 0, subProps
);
806 maxW
+= pg
->m_marginWidth
;
807 DoSetSplitterPosition( maxW
);
810 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
813 wxSize
wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize
) )
815 wxPropertyGrid
* pg
= GetGrid();
817 dc
.SetFont(pg
->m_font
);
819 int marginWidth
= pg
->m_marginWidth
;
820 int accWid
= marginWidth
;
821 int maxColWidth
= 500;
823 for ( unsigned int col
=0; col
< GetColumnCount(); col
++ )
825 int fitWid
= GetColumnFitWidth(dc
, m_properties
, col
, true);
826 int colMinWidth
= GetColumnMinWidth(col
);
827 if ( fitWid
< colMinWidth
)
828 fitWid
= colMinWidth
;
829 else if ( fitWid
> maxColWidth
)
830 fitWid
= maxColWidth
;
832 m_colWidths
[col
] = fitWid
;
837 // Expand last one to fill the width
838 int remaining
= m_width
- accWid
;
839 m_colWidths
[GetColumnCount()-1] += remaining
;
841 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
843 int firstSplitterX
= marginWidth
+ m_colWidths
[0];
844 m_fSplitterX
= (double) firstSplitterX
;
846 // Don't allow initial splitter auto-positioning after this.
847 if ( pg
->GetState() == this )
849 pg
->SetSplitterPosition(firstSplitterX
, false);
854 pg
->GetVirtualSize(&x
, &y
);
856 return wxSize(accWid
, y
);
859 void wxPropertyGridPageState::CheckColumnWidths( int widthChange
)
864 wxPropertyGrid
* pg
= GetGrid();
867 const bool debug
= false;
871 unsigned int lastColumn
= m_colWidths
.size() - 1;
873 int clientWidth
= pg
->GetClientSize().x
;
876 // Column to reduce, if needed. Take last one that exceeds minimum width.
877 // Except if auto splitter centering is used, in which case use widest.
879 int highestColWidth
= 0;
881 bool minimizedCols
= false;
885 wxLogDebug(wxT("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"), width
, clientWidth
);
890 for ( i
=0; i
<m_colWidths
.size(); i
++ )
892 int min
= GetColumnMinWidth(i
);
893 if ( m_colWidths
[i
] <= min
)
895 m_colWidths
[i
] = min
;
896 minimizedCols
= true;
900 if ( pg
->HasFlag(wxPG_SPLITTER_AUTO_CENTER
) )
902 if ( m_colWidths
[i
] >= highestColWidth
)
904 highestColWidth
= m_colWidths
[i
];
915 int colsWidth
= pg
->m_marginWidth
;
916 for ( i
=0; i
<m_colWidths
.size(); i
++ )
917 colsWidth
+= m_colWidths
[i
];
921 wxLogDebug(wxT(" HasVirtualWidth: %i colsWidth: %i"),(int)pg
->HasVirtualWidth(),colsWidth
);
924 // Then mode-based requirement
925 if ( !pg
->HasVirtualWidth() )
927 int widthHigher
= width
- colsWidth
;
929 // Adapt colsWidth to width
930 if ( colsWidth
< width
)
935 wxLogDebug(wxT(" Adjust last column to %i"), m_colWidths
[lastColumn
] + widthHigher
);
937 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + widthHigher
;
939 else if ( colsWidth
> width
)
942 if ( reduceCol
!= -1 )
946 wxLogDebug(wxT(" Reduce column %i (by %i)"), reduceCol
, -widthHigher
);
948 // Reduce widest column, and recheck
949 m_colWidths
[reduceCol
] = m_colWidths
[reduceCol
] + widthHigher
;
956 // Only check colsWidth against clientWidth
957 if ( colsWidth
< clientWidth
)
959 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + (clientWidth
-colsWidth
);
964 // If width changed, recalculate virtual size
965 if ( pg
->GetState() == this )
966 pg
->RecalculateVirtualSize();
971 for ( i
=0; i
<m_colWidths
.size(); i
++ )
972 wxLogDebug(wxT("col%i: %i"),i
,m_colWidths
[i
]);
975 // Auto center splitter
976 if ( !(pg
->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER
) &&
977 m_colWidths
.size() == 2 )
979 float centerX
= (float)(pg
->m_width
/2);
982 if ( m_fSplitterX
< 0.0 )
986 else if ( widthChange
)
988 //float centerX = float(pg->GetSize().x) * 0.5;
991 splitterX
= m_fSplitterX
+ (float(widthChange
) * 0.5);
992 float deviation
= fabs(centerX
- splitterX
);
994 // If deviating from center, adjust towards it
995 if ( deviation
> 20.0 )
997 if ( splitterX
> centerX
)
1005 // No width change, just keep sure we keep splitter position intact
1006 splitterX
= m_fSplitterX
;
1007 float deviation
= fabs(centerX
- splitterX
);
1008 if ( deviation
> 50.0 )
1010 splitterX
= centerX
;
1014 DoSetSplitterPosition((int)splitterX
, 0, false, true);
1016 m_fSplitterX
= splitterX
; // needed to retain accuracy
1020 void wxPropertyGridPageState::SetColumnCount( int colCount
)
1022 wxASSERT( colCount
>= 2 );
1023 m_colWidths
.SetCount( colCount
, wxPG_DRAG_MARGIN
);
1024 if ( m_colWidths
.size() > (unsigned int)colCount
)
1025 m_colWidths
.RemoveAt( m_colWidths
.size(), m_colWidths
.size() - colCount
);
1027 if ( m_pPropGrid
->GetState() == this )
1028 m_pPropGrid
->RecalculateVirtualSize();
1030 CheckColumnWidths();
1033 // Returns column index, -1 for margin
1034 int wxPropertyGridPageState::HitTestH( int x
, int* pSplitterHit
, int* pSplitterHitOffset
) const
1036 int cx
= GetGrid()->m_marginWidth
;
1038 int prevSplitter
= -1;
1043 if ( col
>= (int)m_colWidths
.size() )
1049 cx
+= m_colWidths
[col
];
1052 // Near prev. splitter
1055 int diff
= x
- prevSplitter
;
1056 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1058 *pSplitterHit
= col
- 1;
1059 *pSplitterHitOffset
= diff
;
1064 // Near next splitter
1065 int nextSplitter
= cx
;
1066 if ( col
< (int)(m_colWidths
.size()-1) )
1068 int diff
= x
- nextSplitter
;
1069 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1071 *pSplitterHit
= col
;
1072 *pSplitterHitOffset
= diff
;
1081 // -----------------------------------------------------------------------
1082 // wxPropertyGridPageState property value setting and getting
1083 // -----------------------------------------------------------------------
1085 bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty
* p
, const wxString
& value
)
1089 int flags
= wxPG_REPORT_ERROR
|wxPG_FULL_VALUE
;
1091 wxVariant variant
= p
->GetValueRef();
1094 if ( p
->GetMaxLength() <= 0 )
1095 res
= p
->StringToValue( variant
, value
, flags
);
1097 res
= p
->StringToValue( variant
, value
.Mid(0,p
->GetMaxLength()), flags
);
1101 p
->SetValue(variant
);
1102 if ( m_selected
==p
&& this==m_pPropGrid
->GetState() )
1103 p
->UpdateControl(m_pPropGrid
->GetEditorControl());
1111 // -----------------------------------------------------------------------
1113 bool wxPropertyGridPageState::DoSetPropertyValue( wxPGProperty
* p
, wxVariant
& value
)
1118 if ( m_selected
==p
&& this==m_pPropGrid
->GetState() )
1119 p
->UpdateControl(m_pPropGrid
->GetEditorControl());
1126 // -----------------------------------------------------------------------
1128 bool wxPropertyGridPageState::DoSetPropertyValueWxObjectPtr( wxPGProperty
* p
, wxObject
* value
)
1132 // wnd_primary has to be given so the control can be updated as well.
1134 DoSetPropertyValue(p
, v
);
1140 // -----------------------------------------------------------------------
1142 void wxPropertyGridPageState::DoSetPropertyValueUnspecified( wxPGProperty
* p
)
1144 wxCHECK_RET( p
, wxT("invalid property id") );
1146 if ( !p
->IsValueUnspecified() )
1148 // Value should be set first - editor class methods may need it
1149 p
->m_value
.MakeNull();
1151 wxASSERT( m_pPropGrid
);
1153 if ( m_pPropGrid
->GetState() == this )
1155 if ( m_pPropGrid
->m_selected
== p
&& m_pPropGrid
->m_wndEditor
)
1157 p
->GetEditorClass()->SetValueToUnspecified(p
, m_pPropGrid
->GetEditorControl());
1162 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1163 DoSetPropertyValueUnspecified( p
->Item(i
) );
1167 // -----------------------------------------------------------------------
1168 // wxPropertyGridPageState property operations
1169 // -----------------------------------------------------------------------
1171 bool wxPropertyGridPageState::DoCollapse( wxPGProperty
* p
)
1173 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1175 if ( !p
->GetChildCount() ) return false;
1177 if ( !p
->IsExpanded() ) return false;
1179 p
->SetExpanded(false);
1181 VirtualHeightChanged();
1186 // -----------------------------------------------------------------------
1188 bool wxPropertyGridPageState::DoExpand( wxPGProperty
* p
)
1190 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1192 if ( !p
->GetChildCount() ) return false;
1194 if ( p
->IsExpanded() ) return false;
1196 p
->SetExpanded(true);
1198 VirtualHeightChanged();
1203 // -----------------------------------------------------------------------
1205 bool wxPropertyGridPageState::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
1207 if ( this == m_pPropGrid
->GetState() )
1208 return m_pPropGrid
->DoSelectProperty( p
, flags
);
1214 // -----------------------------------------------------------------------
1216 bool wxPropertyGridPageState::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
1219 p
->ClearFlag( wxPG_PROP_HIDDEN
);
1221 p
->SetFlag( wxPG_PROP_HIDDEN
);
1223 if ( flags
& wxPG_RECURSE
)
1226 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1227 DoHideProperty(p
->Item(i
), hide
, flags
| wxPG_RECURSE_STARTS
);
1230 VirtualHeightChanged();
1235 // -----------------------------------------------------------------------
1237 bool wxPropertyGridPageState::DoEnableProperty( wxPGProperty
* p
, bool enable
)
1243 if ( !(p
->m_flags
& wxPG_PROP_DISABLED
) )
1248 p
->m_flags
&= ~(wxPG_PROP_DISABLED
);
1252 if ( p
->m_flags
& wxPG_PROP_DISABLED
)
1257 p
->m_flags
|= wxPG_PROP_DISABLED
;
1261 // Apply same to sub-properties as well
1263 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1264 DoEnableProperty( p
->Item(i
), enable
);
1271 // -----------------------------------------------------------------------
1272 // wxPropertyGridPageState wxVariant related routines
1273 // -----------------------------------------------------------------------
1275 // Returns list of wxVariant objects (non-categories and non-sub-properties only).
1276 // Never includes sub-properties (unless they are parented by wxParentProperty).
1277 wxVariant
wxPropertyGridPageState::DoGetPropertyValues( const wxString
& listname
,
1278 wxPGProperty
* baseparent
,
1281 wxPGProperty
* pwc
= (wxPGProperty
*) baseparent
;
1283 // Root is the default base-parent.
1287 wxVariantList tempList
;
1288 wxVariant
v( tempList
, listname
);
1290 if ( pwc
->GetChildCount() )
1292 if ( flags
& wxPG_KEEP_STRUCTURE
)
1294 wxASSERT( !pwc
->HasFlag(wxPG_PROP_AGGREGATE
) );
1297 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1299 wxPGProperty
* p
= pwc
->Item(i
);
1300 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1302 wxVariant variant
= p
->GetValue();
1303 variant
.SetName( p
->GetBaseName() );
1304 v
.Append( variant
);
1308 v
.Append( DoGetPropertyValues(p
->m_name
,p
,flags
|wxPG_KEEP_STRUCTURE
) );
1310 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1311 v
.Append( p
->GetAttributesAsList() );
1316 wxPropertyGridConstIterator
it( this, wxPG_ITERATE_DEFAULT
, pwc
->Item(0) );
1317 it
.SetBaseParent( pwc
);
1319 for ( ; !it
.AtEnd(); it
.Next() )
1321 const wxPGProperty
* p
= it
.GetProperty();
1323 // Use a trick to ignore wxParentProperty itself, but not its sub-properties.
1324 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1326 wxVariant variant
= p
->GetValue();
1327 variant
.SetName( p
->GetName() );
1328 v
.Append( variant
);
1329 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1330 v
.Append( p
->GetAttributesAsList() );
1339 // -----------------------------------------------------------------------
1341 void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList
& list
, wxPGProperty
* defaultCategory
)
1343 unsigned char origFrozen
= 1;
1345 if ( m_pPropGrid
->GetState() == this )
1347 origFrozen
= m_pPropGrid
->m_frozen
;
1348 if ( !origFrozen
) m_pPropGrid
->Freeze();
1351 wxPropertyCategory
* use_category
= (wxPropertyCategory
*)defaultCategory
;
1353 if ( !use_category
)
1354 use_category
= (wxPropertyCategory
*)m_properties
;
1356 // Let's iterate over the list of variants.
1357 wxVariantList::const_iterator node
;
1358 int numSpecialEntries
= 0;
1361 // Second pass for special entries
1362 for ( node
= list
.begin(); node
!= list
.end(); node
++ )
1364 wxVariant
*current
= (wxVariant
*)*node
;
1366 // Make sure it is wxVariant.
1367 wxASSERT( current
);
1368 wxASSERT( wxStrcmp(current
->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
1370 const wxString
& name
= current
->GetName();
1371 if ( name
.length() > 0 )
1374 // '@' signified a special entry
1375 if ( name
[0] == wxS('@') )
1377 numSpecialEntries
++;
1381 wxPGProperty
* foundProp
= BaseGetPropertyByName(name
);
1384 wxPGProperty
* p
= foundProp
;
1386 // If it was a list, we still have to go through it.
1387 if ( wxStrcmp(current
->GetType(), wxS("list")) == 0 )
1389 DoSetPropertyValues( current
->GetList(),
1390 p
->IsCategory()?p
:((wxPGProperty
*)NULL
)
1396 if ( wxStrcmp(current
->GetType(), p
->GetValue().GetType()) != 0)
1398 wxLogDebug(wxT("wxPropertyGridPageState::DoSetPropertyValues Warning: Setting value of property \"%s\" from variant"),
1399 p
->GetName().c_str());
1403 p
->SetValue(*current
);
1409 if ( current
->GetType() != wxS("list") )
1415 // Yes, it is; create a sub category and append contents there.
1416 wxPGProperty
* newCat
= DoInsert(use_category
,-1,new wxPropertyCategory(current
->GetName(),wxPG_LABEL
));
1417 DoSetPropertyValues( current
->GetList(), newCat
);
1424 if ( numSpecialEntries
)
1426 for ( node
= list
.begin(); node
!= list
.end(); node
++ )
1428 wxVariant
*current
= (wxVariant
*)*node
;
1430 const wxString
& name
= current
->GetName();
1431 if ( name
.length() > 0 )
1434 // '@' signified a special entry
1435 if ( name
[0] == wxS('@') )
1437 numSpecialEntries
--;
1439 size_t pos2
= name
.rfind(wxS('@'));
1440 if ( pos2
> 0 && pos2
< (name
.size()-1) )
1442 wxString propName
= name
.substr(1, pos2
-1);
1443 wxString entryType
= name
.substr(pos2
+1, wxString::npos
);
1445 if ( entryType
== wxS("attr") )
1448 // List of attributes
1449 wxPGProperty
* foundProp
= BaseGetPropertyByName(propName
);
1452 wxASSERT( wxPGIsVariantType(*current
, list
) );
1454 wxVariantList
& list2
= current
->GetList();
1455 wxVariantList::const_iterator node2
;
1457 for ( node2
= list2
.begin(); node2
!= list2
.end(); node2
++ )
1459 wxVariant
*attr
= (wxVariant
*)*node2
;
1460 foundProp
->SetAttribute( attr
->GetName(), *attr
);
1465 // ERROR: No such property: 'propName'
1471 // ERROR: Special entry requires name of format @<propname>@<entrytype>
1476 if ( !numSpecialEntries
)
1483 m_pPropGrid
->Thaw();
1485 if ( this == m_pPropGrid
->GetState() )
1487 m_selected
->UpdateControl(m_pPropGrid
->GetEditorControl());
1493 // -----------------------------------------------------------------------
1494 // wxPropertyGridPageState property adding and removal
1495 // -----------------------------------------------------------------------
1497 int wxPropertyGridPageState::PrepareToAddItem( wxPGProperty
* property
,
1498 wxPGProperty
* scheduledParent
)
1500 wxPropertyGrid
* propGrid
= m_pPropGrid
;
1502 // This will allow better behavior.
1503 if ( scheduledParent
== m_properties
)
1504 scheduledParent
= (wxPGProperty
*) NULL
;
1506 if ( scheduledParent
&& !scheduledParent
->IsCategory() )
1508 wxASSERT_MSG( property
->GetBaseName().length(),
1509 "Property's children must have unique, non-empty names within their scope" );
1512 property
->m_parentState
= this;
1514 if ( property
->IsCategory() )
1517 // Parent of a category must be either root or another category
1518 // (otherwise Bad Things might happen).
1519 wxASSERT_MSG( scheduledParent
== NULL
||
1520 scheduledParent
== m_properties
||
1521 scheduledParent
->IsCategory(),
1522 wxT("Parent of a category must be either root or another category."));
1524 // If we already have category with same name, delete given property
1525 // and use it instead as most recent caption item.
1526 wxPGProperty
* found_id
= BaseGetPropertyByName( property
->GetBaseName() );
1529 wxPropertyCategory
* pwc
= (wxPropertyCategory
*) found_id
;
1530 if ( pwc
->IsCategory() ) // Must be a category.
1533 m_currentCategory
= pwc
;
1534 return 2; // Tells the caller what we did.
1540 // Warn for identical names in debug mode.
1541 if ( BaseGetPropertyByName(property
->GetName()) &&
1542 (!scheduledParent
|| scheduledParent
->IsCategory()) )
1544 wxLogError(wxT("wxPropertyGrid: Warning - item with name \"%s\" already exists."),
1545 property
->GetName().c_str());
1546 wxPGGlobalVars
->m_warnings
++;
1550 // Make sure nothing is selected.
1551 if ( propGrid
&& propGrid
->m_selected
)
1553 bool selRes
= propGrid
->ClearSelection();
1554 wxPG_CHECK_MSG_DBG( selRes
,
1556 wxT("failed to deselect a property (editor probably had invalid value)") );
1559 if ( scheduledParent
)
1561 // Use parent's colours.
1562 property
->m_bgColIndex
= scheduledParent
->m_bgColIndex
;
1563 property
->m_fgColIndex
= scheduledParent
->m_fgColIndex
;
1565 // Fix no parent does not yet have parenting flag yet, set one now
1566 if ( !scheduledParent
->HasFlag(wxPG_PROP_PARENTAL_FLAGS
) )
1567 scheduledParent
->SetParentalType(wxPG_PROP_MISC_PARENT
);
1568 //scheduledParent->SetFlag(wxPG_PROP_MISC_PARENT);
1571 // If in hideable adding mode, or if assigned parent is hideable, then
1572 // make this one hideable.
1574 ( scheduledParent
&& (scheduledParent
->m_flags
& wxPG_PROP_HIDDEN
) ) ||
1575 ( propGrid
&& (propGrid
->m_iFlags
& wxPG_FL_ADDING_HIDEABLES
) )
1577 property
->SetFlag( wxPG_PROP_HIDDEN
);
1579 // Set custom image flag.
1580 int custImgHeight
= property
->OnMeasureImage().y
;
1581 if ( custImgHeight
< 0 /*|| custImgHeight > 1*/ )
1583 property
->m_flags
|= wxPG_PROP_CUSTOMIMAGE
;
1586 if ( propGrid
&& (propGrid
->GetWindowStyleFlag() & wxPG_LIMITED_EDITING
) )
1587 property
->m_flags
|= wxPG_PROP_NOEDITOR
;
1589 if ( !property
->IsCategory() )
1591 // This is not a category.
1593 //wxASSERT_MSG( property->GetEditorClass(), wxT("Editor class not initialized!") );
1597 unsigned char depth
= 1;
1598 if ( scheduledParent
)
1600 depth
= scheduledParent
->m_depth
;
1601 if ( !scheduledParent
->IsCategory() )
1604 property
->m_depth
= depth
;
1605 unsigned char greyDepth
= depth
;
1607 if ( scheduledParent
)
1609 wxPropertyCategory
* pc
;
1611 if ( scheduledParent
->IsCategory() || scheduledParent
->IsRoot() )
1612 pc
= (wxPropertyCategory
*)scheduledParent
;
1614 // This conditional compile is necessary to
1615 // bypass some compiler bug.
1616 pc
= GetPropertyCategory(scheduledParent
);
1619 greyDepth
= pc
->GetDepth();
1621 greyDepth
= scheduledParent
->m_depthBgCol
;
1624 property
->m_depthBgCol
= greyDepth
;
1626 // Prepare children pre-added children
1627 if ( property
->GetChildCount() )
1629 property
->SetParentalType(wxPG_PROP_AGGREGATE
);
1631 property
->SetExpanded(false); // Properties with children are not expanded by default.
1632 if ( propGrid
&& propGrid
->GetWindowStyleFlag() & wxPG_HIDE_MARGIN
)
1633 property
->SetExpanded(true); // ...unless it cannot be expanded.
1635 property
->PrepareSubProperties();
1640 if ( propGrid
&& (propGrid
->GetExtraStyle() & wxPG_EX_AUTO_UNSPECIFIED_VALUES
) )
1641 property
->SetFlagRecursively(wxPG_PROP_AUTO_UNSPECIFIED
, true);
1647 // This is a category.
1650 unsigned char depth
= 1;
1651 if ( scheduledParent
)
1653 depth
= scheduledParent
->m_depth
+ 1;
1655 property
->m_depth
= depth
;
1656 property
->m_depthBgCol
= depth
;
1658 m_currentCategory
= (wxPropertyCategory
*)property
;
1660 wxPropertyCategory
* pc
= (wxPropertyCategory
*)property
;
1662 // Calculate text extent for caption item.
1664 pc
->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
1670 // -----------------------------------------------------------------------
1672 wxPGProperty
* wxPropertyGridPageState::DoAppend( wxPGProperty
* property
)
1674 wxPropertyCategory
* cur_cat
= m_currentCategory
;
1675 if ( property
->IsCategory() )
1676 cur_cat
= (wxPropertyCategory
*) NULL
;
1678 return DoInsert( cur_cat
, -1, property
);
1681 // -----------------------------------------------------------------------
1683 wxPGProperty
* wxPropertyGridPageState::DoInsert( wxPGProperty
* parent
, int index
, wxPGProperty
* property
)
1686 parent
= m_properties
;
1688 wxCHECK_MSG( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1690 wxT("when adding properties to fixed parents, use BeginAddChildren and EndAddChildren.") );
1692 int parenting
= PrepareToAddItem( property
, (wxPropertyCategory
*)parent
);
1694 // This type of invalid parenting value indicates we should exit now, returning
1695 // id of most recent category.
1696 if ( parenting
> 1 )
1697 return m_currentCategory
;
1699 // Note that item must be added into current mode later.
1701 // If parent is wxParentProperty, just stick it in...
1702 // If parent is root (m_properties), then...
1703 // In categoric mode: Add as last item in m_abcArray (if not category).
1704 // Add to given index in m_regularArray.
1705 // In non-cat mode: Add as last item in m_regularArray.
1706 // Add to given index in m_abcArray.
1707 // If parent is category, then...
1708 // 1) Add to given category in given index.
1709 // 2) Add as last item in m_abcArray.
1711 if ( !parent
->IsCategory() && !parent
->IsRoot() )
1713 // Parent is wxParentingProperty: Just stick it in...
1714 parent
->AddChild2( property
, index
);
1718 // Parent is Category or Root.
1720 if ( m_properties
== &m_regularArray
)
1724 // Only add non-categories to m_abcArray.
1725 if ( m_abcArray
&& parenting
<= 0 )
1726 m_abcArray
->AddChild2( property
, -1, false );
1728 // Add to current mode.
1729 parent
->AddChild2( property
, index
);
1734 // Non-categorized mode.
1736 if ( parent
!= m_properties
)
1737 // Parent is category.
1738 parent
->AddChild2( property
, index
, false );
1741 m_regularArray
.AddChild2( property
, -1, false );
1743 // Add to current mode (no categories).
1744 if ( parenting
<= 0 )
1745 m_abcArray
->AddChild2( property
, index
);
1750 if ( property
->IsCategory() )
1752 // This is a category caption item.
1754 // Last caption is not the bottom one (this info required by append)
1755 m_lastCaptionBottomnest
= 0;
1758 // Only add name to hashmap if parent is root or category
1759 if ( (parent
->IsCategory() || parent
->IsRoot()) && property
->m_name
.length() )
1760 m_dictName
[property
->m_name
] = (void*) property
;
1762 VirtualHeightChanged();
1764 property
->UpdateParentValues();
1771 // -----------------------------------------------------------------------
1773 void wxPropertyGridPageState::DoDelete( wxPGProperty
* item
)
1775 wxCHECK_RET( item
->GetParent(),
1776 wxT("this property was already deleted") );
1778 wxCHECK_RET( item
!= &m_regularArray
&& item
!= m_abcArray
,
1779 wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
1782 unsigned int indinparent
= item
->GetIndexInParent();
1784 wxPGProperty
* pwc
= (wxPGProperty
*)item
;
1786 wxCHECK_RET( !item
->GetParent()->HasFlag(wxPG_PROP_AGGREGATE
),
1787 wxT("wxPropertyGrid: Do not attempt to remove sub-properties.") );
1789 if ( item
->IsCategory() )
1791 // deleting a category
1793 // erase category entries from the hash table
1794 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1796 wxPGProperty
* sp
= pwc
->Item( i
);
1797 if ( sp
->GetBaseName().Len() ) m_dictName
.erase(sp
->GetBaseName());
1800 if ( pwc
== m_currentCategory
)
1801 m_currentCategory
= (wxPropertyCategory
*) NULL
;
1805 // Remove children from non-categorized array.
1806 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1808 wxPGProperty
* p
= pwc
->Item( i
);
1809 wxASSERT( p
!= NULL
);
1810 if ( !p
->IsCategory() )
1811 m_abcArray
->m_children
.Remove( p
);
1814 if ( IsInNonCatMode() )
1815 m_abcArray
->FixIndexesOfChildren();
1819 if ( !IsInNonCatMode() )
1821 // categorized mode - non-categorized array
1823 // Remove from non-cat array, but only if parent is in it
1824 if ( !item
->IsCategory() && item
->GetParent()->IsCategory() )
1828 m_abcArray
->m_children
.Remove( item
);
1832 // categorized mode - categorized array
1833 item
->m_parent
->m_children
.RemoveAt(indinparent
);
1834 item
->m_parent
->FixIndexesOfChildren(/*indinparent*/);
1838 // non-categorized mode - categorized array
1840 // We need to find location of item.
1841 wxPGProperty
* cat_parent
= &m_regularArray
;
1842 int cat_index
= m_regularArray
.GetChildCount();
1844 for ( i
= 0; i
< m_regularArray
.GetChildCount(); i
++ )
1846 wxPGProperty
* p
= m_regularArray
.Item(i
);
1847 if ( p
== item
) { cat_index
= i
; break; }
1848 if ( p
->IsCategory() )
1850 int subind
= ((wxPGProperty
*)p
)->Index(item
);
1851 if ( subind
!= wxNOT_FOUND
)
1853 cat_parent
= ((wxPGProperty
*)p
);
1859 cat_parent
->m_children
.RemoveAt(cat_index
);
1861 // non-categorized mode - non-categorized array
1862 if ( !item
->IsCategory() )
1864 wxASSERT( item
->m_parent
== m_abcArray
);
1865 item
->m_parent
->m_children
.RemoveAt(indinparent
);
1866 item
->m_parent
->FixIndexesOfChildren(indinparent
);
1870 if ( item
->GetBaseName().Len() ) m_dictName
.erase(item
->GetBaseName());
1872 // We can actually delete it now
1875 m_itemsAdded
= 1; // Not a logical assignment (but required nonetheless).
1877 VirtualHeightChanged();
1880 // -----------------------------------------------------------------------