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"
32 #include "wx/button.h"
35 #include "wx/cursor.h"
36 #include "wx/dialog.h"
37 #include "wx/settings.h"
38 #include "wx/msgdlg.h"
39 #include "wx/choice.h"
40 #include "wx/stattext.h"
41 #include "wx/scrolwin.h"
42 #include "wx/dirdlg.h"
43 #include "wx/layout.h"
45 #include "wx/textdlg.h"
46 #include "wx/filedlg.h"
47 #include "wx/statusbr.h"
50 #include "wx/stopwatch.h"
53 // This define is necessary to prevent macro clearing
54 #define __wxPG_SOURCE_FILE__
56 #include <wx/propgrid/propgridpagestate.h>
57 #include <wx/propgrid/propgrid.h>
58 #include <wx/propgrid/editors.h>
62 #define wxPG_DEFAULT_SPLITTERX 110
65 // -----------------------------------------------------------------------
66 // wxPropertyGridIterator
67 // -----------------------------------------------------------------------
69 void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState
* state
, int flags
, wxPGProperty
* property
, int dir
)
71 wxASSERT( dir
== 1 || dir
== -1 );
74 m_baseParent
= state
->DoGetRoot();
75 if ( !property
&& m_baseParent
->GetChildCount() )
76 property
= m_baseParent
->Item(0);
78 m_property
= property
;
80 wxPG_ITERATOR_CREATE_MASKS(flags
, m_itemExMask
, m_parentExMask
)
82 // Need to skip first?
83 if ( property
&& (property
->GetFlags() & m_itemExMask
) )
92 void wxPropertyGridIteratorBase::Init( wxPropertyGridPageState
* state
, int flags
, int startPos
, int dir
)
94 wxPGProperty
* property
;
96 if ( startPos
== wxTOP
)
102 else if ( startPos
== wxBOTTOM
)
104 property
= state
->GetLastItem(flags
);
110 wxASSERT_MSG( false, wxT("Only supported stating positions are wxTOP and wxBOTTOM") );
114 Init( state
, flags
, property
, dir
);
117 void wxPropertyGridIteratorBase::Assign( const wxPropertyGridIteratorBase
& it
)
119 m_property
= it
.m_property
;
120 m_state
= it
.m_state
;
121 m_baseParent
= it
.m_baseParent
;
122 m_itemExMask
= it
.m_itemExMask
;
123 m_parentExMask
= it
.m_parentExMask
;
126 void wxPropertyGridIteratorBase::Prev()
128 wxPGProperty
* property
= m_property
;
129 wxASSERT( property
);
131 wxPGProperty
* parent
= property
->GetParent();
133 unsigned int index
= property
->GetIndexInParent();
140 property
= parent
->Item(index
);
142 // Go to last children?
143 if ( property
->GetChildCount() &&
144 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) )
147 property
= property
->Last();
153 if ( parent
== m_baseParent
)
164 m_property
= property
;
166 // If property does not match our criteria, skip it
167 if ( property
->GetFlags() & m_itemExMask
)
171 void wxPropertyGridIteratorBase::Next( bool iterateChildren
)
173 wxPGProperty
* property
= m_property
;
174 wxASSERT( property
);
176 if ( property
->GetChildCount() &&
177 wxPG_ITERATOR_PARENTEXMASK_TEST(property
, m_parentExMask
) &&
181 property
= property
->Item(0);
185 wxPGProperty
* parent
= property
->GetParent();
187 unsigned int index
= property
->GetIndexInParent() + 1;
189 if ( index
< parent
->GetChildCount() )
192 property
= parent
->Item(index
);
196 // Next sibling of parent
197 if ( parent
== m_baseParent
)
210 m_property
= property
;
212 // If property does not match our criteria, skip it
213 if ( property
->GetFlags() & m_itemExMask
)
217 // -----------------------------------------------------------------------
218 // wxPropertyGridPageState
219 // -----------------------------------------------------------------------
221 wxPropertyGridPageState::wxPropertyGridPageState()
223 m_pPropGrid
= (wxPropertyGrid
*) NULL
;
224 m_regularArray
.SetParentState(this);
225 m_properties
= &m_regularArray
;
226 m_abcArray
= (wxPGRootProperty
*) NULL
;
227 m_currentCategory
= (wxPropertyCategory
*) NULL
;
228 m_selected
= (wxPGProperty
*) NULL
;
231 m_lastCaptionBottomnest
= 1;
235 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
236 m_colWidths
.push_back( wxPG_DEFAULT_SPLITTERX
);
237 m_fSplitterX
= wxPG_DEFAULT_SPLITTERX
;
240 // -----------------------------------------------------------------------
242 wxPropertyGridPageState::~wxPropertyGridPageState()
247 // -----------------------------------------------------------------------
249 void wxPropertyGridPageState::InitNonCatMode()
253 m_abcArray
= new wxPGRootProperty();
254 m_abcArray
->SetParentState(this);
255 m_abcArray
->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES
);
258 // Must be called when state::m_properties still points to regularArray.
259 wxPGProperty
* oldProperties
= m_properties
;
261 // Must use temp value in state::m_properties for item iteration loop
262 // to run as expected.
263 m_properties
= &m_regularArray
;
265 if ( m_properties
->GetChildCount() )
268 wxPropertyGridIterator
it( this, wxPG_ITERATE_DEFAULT
|wxPG_ITERATE_CATEGORIES
);
270 for ( ; !it
.AtEnd(); it
.Next() )
272 wxPGProperty
* p
= it
.GetProperty();
273 wxPGProperty
* parent
= p
->GetParent();
274 if ( p
->HasFlag(wxPG_PROP_MISC_PARENT
) &&
275 ( parent
== m_properties
|| (parent
->IsCategory() || parent
->IsRoot()) ) )
277 m_abcArray
->AddChild2( p
);
278 p
->m_parent
= &m_regularArray
;
283 m_properties
= oldProperties
;
286 // -----------------------------------------------------------------------
288 void wxPropertyGridPageState::DoClear()
290 m_regularArray
.Empty();
296 m_currentCategory
= (wxPropertyCategory
*) NULL
;
297 m_lastCaptionBottomnest
= 1;
303 m_selected
= (wxPGProperty
*) NULL
;
306 // -----------------------------------------------------------------------
308 void wxPropertyGridPageState::CalculateFontAndBitmapStuff( int WXUNUSED(vspacing
) )
310 wxPropertyGrid
* propGrid
= GetGrid();
312 VirtualHeightChanged();
314 // Recalculate caption text extents.
317 for ( i
=0;i
<m_regularArray
.GetChildCount();i
++ )
319 wxPGProperty
* p
=m_regularArray
.Item(i
);
321 if ( p
->IsCategory() )
322 ((wxPropertyCategory
*)p
)->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
326 // -----------------------------------------------------------------------
328 void wxPropertyGridPageState::SetVirtualWidth( int width
)
330 wxASSERT( width
>= 0 );
331 wxPropertyGrid
* pg
= GetGrid();
332 int gw
= pg
->GetClientSize().x
;
339 // -----------------------------------------------------------------------
341 void wxPropertyGridPageState::OnClientWidthChange( int newWidth
, int widthChange
, bool fromOnResize
)
343 wxPropertyGrid
* pg
= GetGrid();
345 if ( pg
->HasVirtualWidth() )
347 if ( m_width
< newWidth
)
348 SetVirtualWidth( newWidth
);
350 CheckColumnWidths(widthChange
);
354 SetVirtualWidth( newWidth
);
356 // This should be done before splitter auto centering
357 // NOTE: Splitter auto-centering is done in this function.
360 CheckColumnWidths(widthChange
);
362 if ( !(GetGrid()->GetInternalFlags() & wxPG_FL_SPLITTER_PRE_SET
) &&
363 (GetGrid()->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER
) )
365 long timeSinceCreation
= (::wxGetLocalTimeMillis() - GetGrid()->m_timeCreated
).ToLong();
367 // If too long, don't set splitter
368 if ( timeSinceCreation
< 3000 )
370 if ( m_properties
->GetChildCount() || timeSinceCreation
> 750 )
372 SetSplitterLeft( false );
376 DoSetSplitterPosition( newWidth
/ 2 );
377 GetGrid()->ClearInternalFlag(wxPG_FL_SPLITTER_PRE_SET
);
384 // -----------------------------------------------------------------------
385 // wxPropertyGridPageState item iteration methods
386 // -----------------------------------------------------------------------
388 wxPGProperty
* wxPropertyGridPageState::GetLastItem( int flags
)
390 if ( !m_properties
->GetChildCount() )
391 return (wxPGProperty
*) NULL
;
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
);
425 return (wxPropertyCategory
*) NULL
;
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
;
465 return (wxPGProperty
*) NULL
;
468 // -----------------------------------------------------------------------
469 // wxPropertyGridPageState global operations
470 // -----------------------------------------------------------------------
472 // -----------------------------------------------------------------------
473 // Item iteration macros
474 // NB: Nowadays only needed for alphabetic/categoric mode switching.
475 // -----------------------------------------------------------------------
477 #define II_INVALID_I 0x00FFFFFF
479 #define ITEM_ITERATION_VARIABLES \
480 wxPGProperty* parent; \
484 #define ITEM_ITERATION_INIT_FROM_THE_TOP \
485 parent = m_properties; \
488 #define ITEM_ITERATION_INIT(startparent, startindex, state) \
489 parent = startparent; \
490 i = (unsigned int)startindex; \
491 if ( parent == (wxPGProperty*) NULL ) \
493 parent = state->m_properties; \
497 #define ITEM_ITERATION_LOOP_BEGIN \
500 iMax = parent->GetChildCount(); \
503 wxPGProperty* p = parent->Item(i);
505 #define ITEM_ITERATION_LOOP_END \
506 if ( p->GetChildCount() ) \
509 parent = (wxPGProperty*)p; \
510 iMax = parent->GetChildCount(); \
515 i = parent->m_arrIndex + 1; \
516 parent = parent->m_parent; \
518 while ( parent != NULL );
520 bool wxPropertyGridPageState::EnableCategories( bool enable
)
523 // NB: We can't use wxPropertyGridIterator in this
524 // function, since it depends on m_arrIndexes,
525 // which, among other things, is being fixed here.
527 ITEM_ITERATION_VARIABLES
535 if ( !IsInNonCatMode() )
538 m_properties
= &m_regularArray
;
540 // fix parents, indexes, and depths
541 ITEM_ITERATION_INIT_FROM_THE_TOP
543 ITEM_ITERATION_LOOP_BEGIN
547 p
->m_parent
= parent
;
549 // If parent was category, and this is not,
550 // then the depth stays the same.
551 if ( parent
->IsCategory() &&
553 p
->m_depth
= parent
->m_depth
;
555 p
->m_depth
= parent
->m_depth
+ 1;
557 ITEM_ITERATION_LOOP_END
563 // Disable categories
566 if ( IsInNonCatMode() )
569 // Create array, if necessary.
573 m_properties
= m_abcArray
;
575 // fix parents, indexes, and depths
576 ITEM_ITERATION_INIT_FROM_THE_TOP
578 ITEM_ITERATION_LOOP_BEGIN
582 p
->m_parent
= parent
;
584 p
->m_depth
= parent
->m_depth
+ 1;
586 ITEM_ITERATION_LOOP_END
589 VirtualHeightChanged();
591 if ( m_pPropGrid
->GetState() == this )
592 m_pPropGrid
->RecalculateVirtualSize();
597 // -----------------------------------------------------------------------
599 static int wxPG_SortFunc(void **p1
, void **p2
)
601 wxPGProperty
*pp1
= *((wxPGProperty
**)p1
);
602 wxPGProperty
*pp2
= *((wxPGProperty
**)p2
);
603 return pp1
->GetLabel().compare( pp2
->GetLabel() );
606 void wxPropertyGridPageState::SortChildren( wxPGProperty
* p
)
609 p
= (wxPGProperty
*)m_properties
;
611 if ( !p
->GetChildCount() )
614 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
616 // Can only sort items with children
617 if ( pwc
->GetChildCount() < 1 )
620 pwc
->m_children
.Sort( wxPG_SortFunc
);
623 pwc
->FixIndexesOfChildren();
627 // -----------------------------------------------------------------------
629 void wxPropertyGridPageState::Sort()
631 SortChildren( m_properties
);
633 // Sort categories as well
634 if ( !IsInNonCatMode() )
637 for ( i
=0;i
<m_properties
->GetChildCount();i
++)
639 wxPGProperty
* p
= m_properties
->Item(i
);
640 if ( p
->IsCategory() )
646 // -----------------------------------------------------------------------
647 // wxPropertyGridPageState splitter, column and hittest functions
648 // -----------------------------------------------------------------------
650 wxPGProperty
* wxPropertyGridPageState::DoGetItemAtY( int y
) const
654 return (wxPGProperty
*) NULL
;
657 return m_properties
->GetItemAtY(y
, GetGrid()->m_lineHeight
, &a
);
660 // -----------------------------------------------------------------------
662 wxPropertyGridHitTestResult
wxPropertyGridPageState::HitTest( const wxPoint
&pt
) const
664 wxPropertyGridHitTestResult result
;
665 result
.column
= HitTestH( pt
.x
, &result
.splitter
, &result
.splitterHitOffset
);
666 result
.property
= DoGetItemAtY( pt
.y
);
670 // -----------------------------------------------------------------------
672 // Used by SetSplitterLeft() and DotFitColumns()
673 int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC
& dc
,
678 wxPropertyGrid
* pg
= m_pPropGrid
;
683 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
685 wxPGProperty
* p
= pwc
->Item(i
);
686 if ( !p
->IsCategory() )
688 dc
.GetTextExtent( p
->GetColumnText(col
), &w
, &h
);
690 w
+= ( ((int)p
->m_depth
-1) * pg
->m_subgroup_extramargin
);
693 // TODO: Add bitmap support.
695 w
+= (wxPG_XBEFORETEXT
*2);
701 if ( p
->GetChildCount() &&
702 ( subProps
|| p
->IsCategory() ) )
704 w
= GetColumnFitWidth( dc
, p
, col
, subProps
);
714 int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn
) const
716 int n
= GetGrid()->m_marginWidth
;
718 for ( i
=0; i
<=splitterColumn
; i
++ )
723 int wxPropertyGridPageState::GetColumnMinWidth( int WXUNUSED(column
) ) const
725 return wxPG_DRAG_MARGIN
;
728 void wxPropertyGridPageState::PropagateColSizeDec( int column
, int decrease
, int dir
)
730 int origWidth
= m_colWidths
[column
];
731 m_colWidths
[column
] -= decrease
;
732 int min
= GetColumnMinWidth(column
);
734 if ( m_colWidths
[column
] < min
)
736 more
= decrease
- (origWidth
- min
);
737 m_colWidths
[column
] = min
;
741 // FIXME: Causes erratic splitter changing, so as a workaround
742 // disabled if two or less columns.
744 if ( m_colWidths
.size() <= 2 )
748 if ( more
&& column
< (int)m_colWidths
.size() && column
>= 0 )
749 PropagateColSizeDec( column
, more
, dir
);
752 void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos
, int splitterColumn
, bool WXUNUSED(allPages
), bool fromAutoCenter
)
754 wxPropertyGrid
* pg
= GetGrid();
756 int adjust
= newXPos
- DoGetSplitterPosition(splitterColumn
);
758 if ( !pg
->HasVirtualWidth() )
764 otherColumn
= splitterColumn
+ 1;
765 if ( otherColumn
== (int)m_colWidths
.size() )
767 m_colWidths
[splitterColumn
] += adjust
;
768 PropagateColSizeDec( otherColumn
, adjust
, 1 );
772 otherColumn
= splitterColumn
+ 1;
773 if ( otherColumn
== (int)m_colWidths
.size() )
775 m_colWidths
[otherColumn
] -= adjust
;
776 PropagateColSizeDec( splitterColumn
, -adjust
, -1 );
781 m_colWidths
[splitterColumn
] += adjust
;
784 if ( splitterColumn
== 0 )
785 m_fSplitterX
= (double) newXPos
;
787 if ( !fromAutoCenter
)
789 // Don't allow initial splitter auto-positioning after this.
790 if ( pg
->GetState() == this )
791 pg
->SetInternalFlag(wxPG_FL_SPLITTER_PRE_SET
);
797 // Moves splitter so that all labels are visible, but just.
798 void wxPropertyGridPageState::SetSplitterLeft( bool subProps
)
800 wxPropertyGrid
* pg
= GetGrid();
802 dc
.SetFont(pg
->m_font
);
804 int maxW
= GetColumnFitWidth(dc
, m_properties
, 0, subProps
);
808 maxW
+= pg
->m_marginWidth
;
809 DoSetSplitterPosition( maxW
);
812 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
815 wxSize
wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize
) )
817 wxPropertyGrid
* pg
= GetGrid();
819 dc
.SetFont(pg
->m_font
);
821 int marginWidth
= pg
->m_marginWidth
;
822 int accWid
= marginWidth
;
823 int maxColWidth
= 500;
825 for ( unsigned int col
=0; col
< GetColumnCount(); col
++ )
827 int fitWid
= GetColumnFitWidth(dc
, m_properties
, col
, true);
828 int colMinWidth
= GetColumnMinWidth(col
);
829 if ( fitWid
< colMinWidth
)
830 fitWid
= colMinWidth
;
831 else if ( fitWid
> maxColWidth
)
832 fitWid
= maxColWidth
;
834 m_colWidths
[col
] = fitWid
;
839 // Expand last one to fill the width
840 int remaining
= m_width
- accWid
;
841 m_colWidths
[GetColumnCount()-1] += remaining
;
843 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
845 int firstSplitterX
= marginWidth
+ m_colWidths
[0];
846 m_fSplitterX
= (double) firstSplitterX
;
848 // Don't allow initial splitter auto-positioning after this.
849 if ( pg
->GetState() == this )
851 pg
->SetSplitterPosition(firstSplitterX
, false);
856 pg
->GetVirtualSize(&x
, &y
);
858 return wxSize(accWid
, y
);
861 void wxPropertyGridPageState::CheckColumnWidths( int widthChange
)
866 wxPropertyGrid
* pg
= GetGrid();
869 const bool debug
= false;
873 unsigned int lastColumn
= m_colWidths
.size() - 1;
875 int clientWidth
= pg
->GetClientSize().x
;
878 // Column to reduce, if needed. Take last one that exceeds minimum width.
879 // Except if auto splitter centering is used, in which case use widest.
881 int highestColWidth
= 0;
883 bool minimizedCols
= false;
887 wxLogDebug(wxT("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"), width
, clientWidth
);
892 for ( i
=0; i
<m_colWidths
.size(); i
++ )
894 int min
= GetColumnMinWidth(i
);
895 if ( m_colWidths
[i
] <= min
)
897 m_colWidths
[i
] = min
;
898 minimizedCols
= true;
902 if ( pg
->HasFlag(wxPG_SPLITTER_AUTO_CENTER
) )
904 if ( m_colWidths
[i
] >= highestColWidth
)
906 highestColWidth
= m_colWidths
[i
];
917 int colsWidth
= pg
->m_marginWidth
;
918 for ( i
=0; i
<m_colWidths
.size(); i
++ )
919 colsWidth
+= m_colWidths
[i
];
923 wxLogDebug(wxT(" HasVirtualWidth: %i colsWidth: %i"),(int)pg
->HasVirtualWidth(),colsWidth
);
926 // Then mode-based requirement
927 if ( !pg
->HasVirtualWidth() )
929 int widthHigher
= width
- colsWidth
;
931 // Adapt colsWidth to width
932 if ( colsWidth
< width
)
937 wxLogDebug(wxT(" Adjust last column to %i"), m_colWidths
[lastColumn
] + widthHigher
);
939 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + widthHigher
;
941 else if ( colsWidth
> width
)
944 if ( reduceCol
!= -1 )
948 wxLogDebug(wxT(" Reduce column %i (by %i)"), reduceCol
, -widthHigher
);
950 // Reduce widest column, and recheck
951 m_colWidths
[reduceCol
] = m_colWidths
[reduceCol
] + widthHigher
;
958 // Only check colsWidth against clientWidth
959 if ( colsWidth
< clientWidth
)
961 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + (clientWidth
-colsWidth
);
966 // If width changed, recalculate virtual size
967 if ( pg
->GetState() == this )
968 pg
->RecalculateVirtualSize();
973 for ( i
=0; i
<m_colWidths
.size(); i
++ )
974 wxLogDebug(wxT("col%i: %i"),i
,m_colWidths
[i
]);
977 // Auto center splitter
978 if ( !(pg
->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER
) &&
979 m_colWidths
.size() == 2 )
981 float centerX
= (float)(pg
->m_width
/2);
984 if ( m_fSplitterX
< 0.0 )
988 else if ( widthChange
)
990 //float centerX = float(pg->GetSize().x) * 0.5;
993 splitterX
= m_fSplitterX
+ (float(widthChange
) * 0.5);
994 float deviation
= fabs(centerX
- splitterX
);
996 // If deviating from center, adjust towards it
997 if ( deviation
> 20.0 )
999 if ( splitterX
> centerX
)
1007 // No width change, just keep sure we keep splitter position intact
1008 splitterX
= m_fSplitterX
;
1009 float deviation
= fabs(centerX
- splitterX
);
1010 if ( deviation
> 50.0 )
1012 splitterX
= centerX
;
1016 DoSetSplitterPosition((int)splitterX
, 0, false, true);
1018 m_fSplitterX
= splitterX
; // needed to retain accuracy
1022 void wxPropertyGridPageState::SetColumnCount( int colCount
)
1024 wxASSERT( colCount
>= 2 );
1025 m_colWidths
.SetCount( colCount
, wxPG_DRAG_MARGIN
);
1026 if ( m_colWidths
.size() > (unsigned int)colCount
)
1027 m_colWidths
.RemoveAt( m_colWidths
.size(), m_colWidths
.size() - colCount
);
1029 if ( m_pPropGrid
->GetState() == this )
1030 m_pPropGrid
->RecalculateVirtualSize();
1032 CheckColumnWidths();
1035 // Returns column index, -1 for margin
1036 int wxPropertyGridPageState::HitTestH( int x
, int* pSplitterHit
, int* pSplitterHitOffset
) const
1038 int cx
= GetGrid()->m_marginWidth
;
1040 int prevSplitter
= -1;
1045 if ( col
>= (int)m_colWidths
.size() )
1051 cx
+= m_colWidths
[col
];
1054 // Near prev. splitter
1057 int diff
= x
- prevSplitter
;
1058 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1060 *pSplitterHit
= col
- 1;
1061 *pSplitterHitOffset
= diff
;
1066 // Near next splitter
1067 int nextSplitter
= cx
;
1068 if ( col
< (int)(m_colWidths
.size()-1) )
1070 int diff
= x
- nextSplitter
;
1071 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1073 *pSplitterHit
= col
;
1074 *pSplitterHitOffset
= diff
;
1083 // -----------------------------------------------------------------------
1084 // wxPropertyGridPageState property value setting and getting
1085 // -----------------------------------------------------------------------
1087 bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty
* p
, const wxString
& value
)
1091 int flags
= wxPG_REPORT_ERROR
|wxPG_FULL_VALUE
;
1093 wxVariant variant
= p
->GetValueRef();
1096 if ( p
->GetMaxLength() <= 0 )
1097 res
= p
->StringToValue( variant
, value
, flags
);
1099 res
= p
->StringToValue( variant
, value
.Mid(0,p
->GetMaxLength()), flags
);
1103 p
->SetValue(variant
);
1104 if ( m_selected
==p
&& this==m_pPropGrid
->GetState() )
1105 p
->UpdateControl(m_pPropGrid
->GetEditorControl());
1113 // -----------------------------------------------------------------------
1115 bool wxPropertyGridPageState::DoSetPropertyValue( wxPGProperty
* p
, wxVariant
& value
)
1120 if ( m_selected
==p
&& this==m_pPropGrid
->GetState() )
1121 p
->UpdateControl(m_pPropGrid
->GetEditorControl());
1128 // -----------------------------------------------------------------------
1130 bool wxPropertyGridPageState::DoSetPropertyValueWxObjectPtr( wxPGProperty
* p
, wxObject
* value
)
1134 // wnd_primary has to be given so the control can be updated as well.
1136 DoSetPropertyValue(p
, v
);
1142 // -----------------------------------------------------------------------
1144 void wxPropertyGridPageState::DoSetPropertyValueUnspecified( wxPGProperty
* p
)
1146 wxCHECK_RET( p
, wxT("invalid property id") );
1148 if ( !p
->IsValueUnspecified() )
1150 // Value should be set first - editor class methods may need it
1151 p
->m_value
.MakeNull();
1153 wxASSERT( m_pPropGrid
);
1155 if ( m_pPropGrid
->GetState() == this )
1157 if ( m_pPropGrid
->m_selected
== p
&& m_pPropGrid
->m_wndEditor
)
1159 p
->GetEditorClass()->SetValueToUnspecified(p
, m_pPropGrid
->GetEditorControl());
1164 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1165 DoSetPropertyValueUnspecified( p
->Item(i
) );
1169 // -----------------------------------------------------------------------
1170 // wxPropertyGridPageState property operations
1171 // -----------------------------------------------------------------------
1173 bool wxPropertyGridPageState::DoCollapse( wxPGProperty
* p
)
1175 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1177 if ( !p
->GetChildCount() ) return false;
1179 if ( !p
->IsExpanded() ) return false;
1181 p
->SetExpanded(false);
1183 VirtualHeightChanged();
1188 // -----------------------------------------------------------------------
1190 bool wxPropertyGridPageState::DoExpand( wxPGProperty
* p
)
1192 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1194 if ( !p
->GetChildCount() ) return false;
1196 if ( p
->IsExpanded() ) return false;
1198 p
->SetExpanded(true);
1200 VirtualHeightChanged();
1205 // -----------------------------------------------------------------------
1207 bool wxPropertyGridPageState::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
1209 if ( this == m_pPropGrid
->GetState() )
1210 return m_pPropGrid
->DoSelectProperty( p
, flags
);
1216 // -----------------------------------------------------------------------
1218 bool wxPropertyGridPageState::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
1221 p
->ClearFlag( wxPG_PROP_HIDDEN
);
1223 p
->SetFlag( wxPG_PROP_HIDDEN
);
1225 if ( flags
& wxPG_RECURSE
)
1228 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1229 DoHideProperty(p
->Item(i
), hide
, flags
| wxPG_RECURSE_STARTS
);
1232 VirtualHeightChanged();
1237 // -----------------------------------------------------------------------
1239 bool wxPropertyGridPageState::DoEnableProperty( wxPGProperty
* p
, bool enable
)
1245 if ( !(p
->m_flags
& wxPG_PROP_DISABLED
) )
1250 p
->m_flags
&= ~(wxPG_PROP_DISABLED
);
1254 if ( p
->m_flags
& wxPG_PROP_DISABLED
)
1259 p
->m_flags
|= wxPG_PROP_DISABLED
;
1263 // Apply same to sub-properties as well
1265 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1266 DoEnableProperty( p
->Item(i
), enable
);
1273 // -----------------------------------------------------------------------
1274 // wxPropertyGridPageState wxVariant related routines
1275 // -----------------------------------------------------------------------
1277 // Returns list of wxVariant objects (non-categories and non-sub-properties only).
1278 // Never includes sub-properties (unless they are parented by wxParentProperty).
1279 wxVariant
wxPropertyGridPageState::DoGetPropertyValues( const wxString
& listname
,
1280 wxPGProperty
* baseparent
,
1283 wxPGProperty
* pwc
= (wxPGProperty
*) baseparent
;
1285 // Root is the default base-parent.
1289 wxVariantList tempList
;
1290 wxVariant
v( tempList
, listname
);
1292 if ( pwc
->GetChildCount() )
1294 if ( flags
& wxPG_KEEP_STRUCTURE
)
1296 wxASSERT( !pwc
->HasFlag(wxPG_PROP_AGGREGATE
) );
1299 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1301 wxPGProperty
* p
= pwc
->Item(i
);
1302 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1304 wxVariant variant
= p
->GetValue();
1305 variant
.SetName( p
->GetBaseName() );
1306 v
.Append( variant
);
1310 v
.Append( DoGetPropertyValues(p
->m_name
,p
,flags
|wxPG_KEEP_STRUCTURE
) );
1312 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1313 v
.Append( p
->GetAttributesAsList() );
1318 wxPropertyGridConstIterator
it( this, wxPG_ITERATE_DEFAULT
, pwc
->Item(0) );
1319 it
.SetBaseParent( pwc
);
1321 for ( ; !it
.AtEnd(); it
.Next() )
1323 const wxPGProperty
* p
= it
.GetProperty();
1325 // Use a trick to ignore wxParentProperty itself, but not its sub-properties.
1326 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1328 wxVariant variant
= p
->GetValue();
1329 variant
.SetName( p
->GetName() );
1330 v
.Append( variant
);
1331 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1332 v
.Append( p
->GetAttributesAsList() );
1341 // -----------------------------------------------------------------------
1343 void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList
& list
, wxPGProperty
* defaultCategory
)
1345 unsigned char origFrozen
= 1;
1347 if ( m_pPropGrid
->GetState() == this )
1349 origFrozen
= m_pPropGrid
->m_frozen
;
1350 if ( !origFrozen
) m_pPropGrid
->Freeze();
1353 wxPropertyCategory
* use_category
= (wxPropertyCategory
*)defaultCategory
;
1355 if ( !use_category
)
1356 use_category
= (wxPropertyCategory
*)m_properties
;
1358 // Let's iterate over the list of variants.
1359 wxVariantList::const_iterator node
;
1360 int numSpecialEntries
= 0;
1363 // Second pass for special entries
1364 for ( node
= list
.begin(); node
!= list
.end(); node
++ )
1366 wxVariant
*current
= (wxVariant
*)*node
;
1368 // Make sure it is wxVariant.
1369 wxASSERT( current
);
1370 wxASSERT( wxStrcmp(current
->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
1372 const wxString
& name
= current
->GetName();
1373 if ( name
.length() > 0 )
1376 // '@' signified a special entry
1377 if ( name
[0] == wxS('@') )
1379 numSpecialEntries
++;
1383 wxPGProperty
* foundProp
= BaseGetPropertyByName(name
);
1386 wxPGProperty
* p
= foundProp
;
1388 // If it was a list, we still have to go through it.
1389 if ( wxStrcmp(current
->GetType(), wxS("list")) == 0 )
1391 DoSetPropertyValues( current
->GetList(),
1392 p
->IsCategory()?p
:((wxPGProperty
*)NULL
)
1398 if ( wxStrcmp(current
->GetType(), p
->GetValue().GetType()) != 0)
1400 wxLogDebug(wxT("wxPropertyGridPageState::DoSetPropertyValues Warning: Setting value of property \"%s\" from variant"),
1401 p
->GetName().c_str());
1405 p
->SetValue(*current
);
1411 if ( current
->GetType() != wxS("list") )
1417 // Yes, it is; create a sub category and append contents there.
1418 wxPGProperty
* newCat
= DoInsert(use_category
,-1,new wxPropertyCategory(current
->GetName(),wxPG_LABEL
));
1419 DoSetPropertyValues( current
->GetList(), newCat
);
1426 if ( numSpecialEntries
)
1428 for ( node
= list
.begin(); node
!= list
.end(); node
++ )
1430 wxVariant
*current
= (wxVariant
*)*node
;
1432 const wxString
& name
= current
->GetName();
1433 if ( name
.length() > 0 )
1436 // '@' signified a special entry
1437 if ( name
[0] == wxS('@') )
1439 numSpecialEntries
--;
1441 size_t pos2
= name
.rfind(wxS('@'));
1442 if ( pos2
> 0 && pos2
< (name
.size()-1) )
1444 wxString propName
= name
.substr(1, pos2
-1);
1445 wxString entryType
= name
.substr(pos2
+1, wxString::npos
);
1447 if ( entryType
== wxS("attr") )
1450 // List of attributes
1451 wxPGProperty
* foundProp
= BaseGetPropertyByName(propName
);
1454 wxASSERT( current
->GetType() == wxPG_VARIANT_TYPE_LIST
);
1456 wxVariantList
& list2
= current
->GetList();
1457 wxVariantList::const_iterator node2
;
1459 for ( node2
= list2
.begin(); node2
!= list2
.end(); node2
++ )
1461 wxVariant
*attr
= (wxVariant
*)*node2
;
1462 foundProp
->SetAttribute( attr
->GetName(), *attr
);
1467 // ERROR: No such property: 'propName'
1473 // ERROR: Special entry requires name of format @<propname>@<entrytype>
1478 if ( !numSpecialEntries
)
1485 m_pPropGrid
->Thaw();
1487 if ( this == m_pPropGrid
->GetState() )
1489 m_selected
->UpdateControl(m_pPropGrid
->GetEditorControl());
1495 // -----------------------------------------------------------------------
1496 // wxPropertyGridPageState property adding and removal
1497 // -----------------------------------------------------------------------
1499 int wxPropertyGridPageState::PrepareToAddItem( wxPGProperty
* property
,
1500 wxPGProperty
* scheduledParent
)
1502 wxPropertyGrid
* propGrid
= m_pPropGrid
;
1504 // This will allow better behavior.
1505 if ( scheduledParent
== m_properties
)
1506 scheduledParent
= (wxPGProperty
*) NULL
;
1508 if ( scheduledParent
&& !scheduledParent
->IsCategory() )
1510 wxASSERT_MSG( property
->GetBaseName().length(),
1511 "Property's children must have unique, non-empty names within their scope" );
1514 property
->m_parentState
= this;
1516 if ( property
->IsCategory() )
1519 // Parent of a category must be either root or another category
1520 // (otherwise Bad Things might happen).
1521 wxASSERT_MSG( scheduledParent
== NULL
||
1522 scheduledParent
== m_properties
||
1523 scheduledParent
->IsCategory(),
1524 wxT("Parent of a category must be either root or another category."));
1526 // If we already have category with same name, delete given property
1527 // and use it instead as most recent caption item.
1528 wxPGProperty
* found_id
= BaseGetPropertyByName( property
->GetBaseName() );
1531 wxPropertyCategory
* pwc
= (wxPropertyCategory
*) found_id
;
1532 if ( pwc
->IsCategory() ) // Must be a category.
1535 m_currentCategory
= pwc
;
1536 return 2; // Tells the caller what we did.
1542 // Warn for identical names in debug mode.
1543 if ( BaseGetPropertyByName(property
->GetName()) &&
1544 (!scheduledParent
|| scheduledParent
->IsCategory()) )
1546 wxLogError(wxT("wxPropertyGrid: Warning - item with name \"%s\" already exists."),
1547 property
->GetName().c_str());
1548 wxPGGlobalVars
->m_warnings
++;
1552 // Make sure nothing is selected.
1553 if ( propGrid
&& propGrid
->m_selected
)
1555 bool selRes
= propGrid
->ClearSelection();
1556 wxPG_CHECK_MSG_DBG( selRes
,
1558 wxT("failed to deselect a property (editor probably had invalid value)") );
1561 if ( scheduledParent
)
1563 // Use parent's colours.
1564 property
->m_bgColIndex
= scheduledParent
->m_bgColIndex
;
1565 property
->m_fgColIndex
= scheduledParent
->m_fgColIndex
;
1567 // Fix no parent does not yet have parenting flag yet, set one now
1568 if ( !scheduledParent
->HasFlag(wxPG_PROP_PARENTAL_FLAGS
) )
1569 scheduledParent
->SetParentalType(wxPG_PROP_MISC_PARENT
);
1570 //scheduledParent->SetFlag(wxPG_PROP_MISC_PARENT);
1573 // If in hideable adding mode, or if assigned parent is hideable, then
1574 // make this one hideable.
1576 ( scheduledParent
&& (scheduledParent
->m_flags
& wxPG_PROP_HIDDEN
) ) ||
1577 ( propGrid
&& (propGrid
->m_iFlags
& wxPG_FL_ADDING_HIDEABLES
) )
1579 property
->SetFlag( wxPG_PROP_HIDDEN
);
1581 // Set custom image flag.
1582 int custImgHeight
= property
->OnMeasureImage().y
;
1583 if ( custImgHeight
< 0 /*|| custImgHeight > 1*/ )
1585 property
->m_flags
|= wxPG_PROP_CUSTOMIMAGE
;
1588 if ( propGrid
&& (propGrid
->GetWindowStyleFlag() & wxPG_LIMITED_EDITING
) )
1589 property
->m_flags
|= wxPG_PROP_NOEDITOR
;
1591 if ( !property
->IsCategory() )
1593 // This is not a category.
1595 //wxASSERT_MSG( property->GetEditorClass(), wxT("Editor class not initialized!") );
1599 unsigned char depth
= 1;
1600 if ( scheduledParent
)
1602 depth
= scheduledParent
->m_depth
;
1603 if ( !scheduledParent
->IsCategory() )
1606 property
->m_depth
= depth
;
1607 unsigned char greyDepth
= depth
;
1609 if ( scheduledParent
)
1611 wxPropertyCategory
* pc
;
1613 if ( scheduledParent
->IsCategory() || scheduledParent
->IsRoot() )
1614 pc
= (wxPropertyCategory
*)scheduledParent
;
1616 // This conditional compile is necessary to
1617 // bypass some compiler bug.
1618 pc
= GetPropertyCategory(scheduledParent
);
1621 greyDepth
= pc
->GetDepth();
1623 greyDepth
= scheduledParent
->m_depthBgCol
;
1626 property
->m_depthBgCol
= greyDepth
;
1628 // Prepare children pre-added children
1629 if ( property
->GetChildCount() )
1631 property
->SetParentalType(wxPG_PROP_AGGREGATE
);
1633 property
->SetExpanded(false); // Properties with children are not expanded by default.
1634 if ( propGrid
&& propGrid
->GetWindowStyleFlag() & wxPG_HIDE_MARGIN
)
1635 property
->SetExpanded(true); // ...unless it cannot be expanded.
1637 property
->PrepareSubProperties();
1642 if ( propGrid
&& (propGrid
->GetExtraStyle() & wxPG_EX_AUTO_UNSPECIFIED_VALUES
) )
1643 property
->SetFlagRecursively(wxPG_PROP_AUTO_UNSPECIFIED
, true);
1649 // This is a category.
1652 unsigned char depth
= 1;
1653 if ( scheduledParent
)
1655 depth
= scheduledParent
->m_depth
+ 1;
1657 property
->m_depth
= depth
;
1658 property
->m_depthBgCol
= depth
;
1660 m_currentCategory
= (wxPropertyCategory
*)property
;
1662 wxPropertyCategory
* pc
= (wxPropertyCategory
*)property
;
1664 // Calculate text extent for caption item.
1666 pc
->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
1672 // -----------------------------------------------------------------------
1674 wxPGProperty
* wxPropertyGridPageState::DoAppend( wxPGProperty
* property
)
1676 wxPropertyCategory
* cur_cat
= m_currentCategory
;
1677 if ( property
->IsCategory() )
1678 cur_cat
= (wxPropertyCategory
*) NULL
;
1680 return DoInsert( cur_cat
, -1, property
);
1683 // -----------------------------------------------------------------------
1685 wxPGProperty
* wxPropertyGridPageState::DoInsert( wxPGProperty
* parent
, int index
, wxPGProperty
* property
)
1688 parent
= m_properties
;
1690 wxCHECK_MSG( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1692 wxT("when adding properties to fixed parents, use BeginAddChildren and EndAddChildren.") );
1694 int parenting
= PrepareToAddItem( property
, (wxPropertyCategory
*)parent
);
1696 // This type of invalid parenting value indicates we should exit now, returning
1697 // id of most recent category.
1698 if ( parenting
> 1 )
1699 return m_currentCategory
;
1701 // Note that item must be added into current mode later.
1703 // If parent is wxParentProperty, just stick it in...
1704 // If parent is root (m_properties), then...
1705 // In categoric mode: Add as last item in m_abcArray (if not category).
1706 // Add to given index in m_regularArray.
1707 // In non-cat mode: Add as last item in m_regularArray.
1708 // Add to given index in m_abcArray.
1709 // If parent is category, then...
1710 // 1) Add to given category in given index.
1711 // 2) Add as last item in m_abcArray.
1713 if ( !parent
->IsCategory() && !parent
->IsRoot() )
1715 // Parent is wxParentingProperty: Just stick it in...
1716 parent
->AddChild2( property
, index
);
1720 // Parent is Category or Root.
1722 if ( m_properties
== &m_regularArray
)
1726 // Only add non-categories to m_abcArray.
1727 if ( m_abcArray
&& parenting
<= 0 )
1728 m_abcArray
->AddChild2( property
, -1, false );
1730 // Add to current mode.
1731 parent
->AddChild2( property
, index
);
1736 // Non-categorized mode.
1738 if ( parent
!= m_properties
)
1739 // Parent is category.
1740 parent
->AddChild2( property
, index
, false );
1743 m_regularArray
.AddChild2( property
, -1, false );
1745 // Add to current mode (no categories).
1746 if ( parenting
<= 0 )
1747 m_abcArray
->AddChild2( property
, index
);
1752 if ( property
->IsCategory() )
1754 // This is a category caption item.
1756 // Last caption is not the bottom one (this info required by append)
1757 m_lastCaptionBottomnest
= 0;
1760 // Only add name to hashmap if parent is root or category
1761 if ( (parent
->IsCategory() || parent
->IsRoot()) && property
->m_name
.length() )
1762 m_dictName
[property
->m_name
] = (void*) property
;
1764 VirtualHeightChanged();
1766 property
->UpdateParentValues();
1773 // -----------------------------------------------------------------------
1775 void wxPropertyGridPageState::DoDelete( wxPGProperty
* item
)
1777 wxCHECK_RET( item
->GetParent(),
1778 wxT("this property was already deleted") );
1780 wxCHECK_RET( item
!= &m_regularArray
&& item
!= m_abcArray
,
1781 wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
1784 unsigned int indinparent
= item
->GetIndexInParent();
1786 wxPGProperty
* pwc
= (wxPGProperty
*)item
;
1788 wxCHECK_RET( !item
->GetParent()->HasFlag(wxPG_PROP_AGGREGATE
),
1789 wxT("wxPropertyGrid: Do not attempt to remove sub-properties.") );
1791 if ( item
->IsCategory() )
1793 // deleting a category
1795 // erase category entries from the hash table
1796 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1798 wxPGProperty
* sp
= pwc
->Item( i
);
1799 if ( sp
->GetBaseName().Len() ) m_dictName
.erase(sp
->GetBaseName());
1802 if ( pwc
== m_currentCategory
)
1803 m_currentCategory
= (wxPropertyCategory
*) NULL
;
1807 // Remove children from non-categorized array.
1808 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1810 wxPGProperty
* p
= pwc
->Item( i
);
1811 wxASSERT( p
!= NULL
);
1812 if ( !p
->IsCategory() )
1813 m_abcArray
->m_children
.Remove( p
);
1816 if ( IsInNonCatMode() )
1817 m_abcArray
->FixIndexesOfChildren();
1821 if ( !IsInNonCatMode() )
1823 // categorized mode - non-categorized array
1825 // Remove from non-cat array, but only if parent is in it
1826 if ( !item
->IsCategory() && item
->GetParent()->IsCategory() )
1830 m_abcArray
->m_children
.Remove( item
);
1834 // categorized mode - categorized array
1835 item
->m_parent
->m_children
.RemoveAt(indinparent
);
1836 item
->m_parent
->FixIndexesOfChildren(/*indinparent*/);
1840 // non-categorized mode - categorized array
1842 // We need to find location of item.
1843 wxPGProperty
* cat_parent
= &m_regularArray
;
1844 int cat_index
= m_regularArray
.GetChildCount();
1846 for ( i
= 0; i
< m_regularArray
.GetChildCount(); i
++ )
1848 wxPGProperty
* p
= m_regularArray
.Item(i
);
1849 if ( p
== item
) { cat_index
= i
; break; }
1850 if ( p
->IsCategory() )
1852 int subind
= ((wxPGProperty
*)p
)->Index(item
);
1853 if ( subind
!= wxNOT_FOUND
)
1855 cat_parent
= ((wxPGProperty
*)p
);
1861 cat_parent
->m_children
.RemoveAt(cat_index
);
1863 // non-categorized mode - non-categorized array
1864 if ( !item
->IsCategory() )
1866 wxASSERT( item
->m_parent
== m_abcArray
);
1867 item
->m_parent
->m_children
.RemoveAt(indinparent
);
1868 item
->m_parent
->FixIndexesOfChildren(indinparent
);
1872 if ( item
->GetBaseName().Len() ) m_dictName
.erase(item
->GetBaseName());
1874 // We can actually delete it now
1877 m_itemsAdded
= 1; // Not a logical assignment (but required nonetheless).
1879 VirtualHeightChanged();
1882 // -----------------------------------------------------------------------
1884 #endif // wxUSE_PROPGRID