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 // -----------------------------------------------------------------------
595 static int wxPG_SortFunc(void **p1
, void **p2
)
597 wxPGProperty
*pp1
= *((wxPGProperty
**)p1
);
598 wxPGProperty
*pp2
= *((wxPGProperty
**)p2
);
599 return pp1
->GetLabel().compare( pp2
->GetLabel() );
602 void wxPropertyGridPageState::SortChildren( wxPGProperty
* p
)
605 p
= (wxPGProperty
*)m_properties
;
607 if ( !p
->GetChildCount() )
610 wxPGProperty
* pwc
= (wxPGProperty
*)p
;
612 // Can only sort items with children
613 if ( pwc
->GetChildCount() < 1 )
616 pwc
->m_children
.Sort( wxPG_SortFunc
);
619 pwc
->FixIndexesOfChildren();
623 // -----------------------------------------------------------------------
625 void wxPropertyGridPageState::Sort()
627 SortChildren( m_properties
);
629 // Sort categories as well
630 if ( !IsInNonCatMode() )
633 for ( i
=0;i
<m_properties
->GetChildCount();i
++)
635 wxPGProperty
* p
= m_properties
->Item(i
);
636 if ( p
->IsCategory() )
642 // -----------------------------------------------------------------------
643 // wxPropertyGridPageState splitter, column and hittest functions
644 // -----------------------------------------------------------------------
646 wxPGProperty
* wxPropertyGridPageState::DoGetItemAtY( int y
) const
650 return (wxPGProperty
*) NULL
;
653 return m_properties
->GetItemAtY(y
, GetGrid()->m_lineHeight
, &a
);
656 // -----------------------------------------------------------------------
658 wxPropertyGridHitTestResult
wxPropertyGridPageState::HitTest( const wxPoint
&pt
) const
660 wxPropertyGridHitTestResult result
;
661 result
.column
= HitTestH( pt
.x
, &result
.splitter
, &result
.splitterHitOffset
);
662 result
.property
= DoGetItemAtY( pt
.y
);
666 // -----------------------------------------------------------------------
668 // Used by SetSplitterLeft() and DotFitColumns()
669 int wxPropertyGridPageState::GetColumnFitWidth(wxClientDC
& dc
,
674 wxPropertyGrid
* pg
= m_pPropGrid
;
679 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
681 wxPGProperty
* p
= pwc
->Item(i
);
682 if ( !p
->IsCategory() )
684 dc
.GetTextExtent( p
->GetColumnText(col
), &w
, &h
);
686 w
+= ( ((int)p
->m_depth
-1) * pg
->m_subgroup_extramargin
);
689 // TODO: Add bitmap support.
691 w
+= (wxPG_XBEFORETEXT
*2);
697 if ( p
->GetChildCount() &&
698 ( subProps
|| p
->IsCategory() ) )
700 w
= GetColumnFitWidth( dc
, p
, col
, subProps
);
710 int wxPropertyGridPageState::DoGetSplitterPosition( int splitterColumn
) const
712 int n
= GetGrid()->m_marginWidth
;
714 for ( i
=0; i
<=splitterColumn
; i
++ )
719 int wxPropertyGridPageState::GetColumnMinWidth( int WXUNUSED(column
) ) const
721 return wxPG_DRAG_MARGIN
;
724 void wxPropertyGridPageState::PropagateColSizeDec( int column
, int decrease
, int dir
)
726 int origWidth
= m_colWidths
[column
];
727 m_colWidths
[column
] -= decrease
;
728 int min
= GetColumnMinWidth(column
);
730 if ( m_colWidths
[column
] < min
)
732 more
= decrease
- (origWidth
- min
);
733 m_colWidths
[column
] = min
;
737 // FIXME: Causes erratic splitter changing, so as a workaround
738 // disabled if two or less columns.
740 if ( m_colWidths
.size() <= 2 )
744 if ( more
&& column
< (int)m_colWidths
.size() && column
>= 0 )
745 PropagateColSizeDec( column
, more
, dir
);
748 void wxPropertyGridPageState::DoSetSplitterPosition( int newXPos
, int splitterColumn
, bool WXUNUSED(allPages
), bool fromAutoCenter
)
750 wxPropertyGrid
* pg
= GetGrid();
752 int adjust
= newXPos
- DoGetSplitterPosition(splitterColumn
);
754 if ( !pg
->HasVirtualWidth() )
760 otherColumn
= splitterColumn
+ 1;
761 if ( otherColumn
== (int)m_colWidths
.size() )
763 m_colWidths
[splitterColumn
] += adjust
;
764 PropagateColSizeDec( otherColumn
, adjust
, 1 );
768 otherColumn
= splitterColumn
+ 1;
769 if ( otherColumn
== (int)m_colWidths
.size() )
771 m_colWidths
[otherColumn
] -= adjust
;
772 PropagateColSizeDec( splitterColumn
, -adjust
, -1 );
777 m_colWidths
[splitterColumn
] += adjust
;
780 if ( splitterColumn
== 0 )
781 m_fSplitterX
= (double) newXPos
;
783 if ( !fromAutoCenter
)
785 // Don't allow initial splitter auto-positioning after this.
786 if ( pg
->GetState() == this )
787 pg
->SetInternalFlag(wxPG_FL_SPLITTER_PRE_SET
);
793 // Moves splitter so that all labels are visible, but just.
794 void wxPropertyGridPageState::SetSplitterLeft( bool subProps
)
796 wxPropertyGrid
* pg
= GetGrid();
798 dc
.SetFont(pg
->m_font
);
800 int maxW
= GetColumnFitWidth(dc
, m_properties
, 0, subProps
);
804 maxW
+= pg
->m_marginWidth
;
805 DoSetSplitterPosition( maxW
);
808 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
811 wxSize
wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize
) )
813 wxPropertyGrid
* pg
= GetGrid();
815 dc
.SetFont(pg
->m_font
);
817 int marginWidth
= pg
->m_marginWidth
;
818 int accWid
= marginWidth
;
819 int maxColWidth
= 500;
821 for ( unsigned int col
=0; col
< GetColumnCount(); col
++ )
823 int fitWid
= GetColumnFitWidth(dc
, m_properties
, col
, true);
824 int colMinWidth
= GetColumnMinWidth(col
);
825 if ( fitWid
< colMinWidth
)
826 fitWid
= colMinWidth
;
827 else if ( fitWid
> maxColWidth
)
828 fitWid
= maxColWidth
;
830 m_colWidths
[col
] = fitWid
;
835 // Expand last one to fill the width
836 int remaining
= m_width
- accWid
;
837 m_colWidths
[GetColumnCount()-1] += remaining
;
839 pg
->SetInternalFlag(wxPG_FL_DONT_CENTER_SPLITTER
);
841 int firstSplitterX
= marginWidth
+ m_colWidths
[0];
842 m_fSplitterX
= (double) firstSplitterX
;
844 // Don't allow initial splitter auto-positioning after this.
845 if ( pg
->GetState() == this )
847 pg
->SetSplitterPosition(firstSplitterX
, false);
852 pg
->GetVirtualSize(&x
, &y
);
854 return wxSize(accWid
, y
);
857 void wxPropertyGridPageState::CheckColumnWidths( int widthChange
)
862 wxPropertyGrid
* pg
= GetGrid();
865 const bool debug
= false;
869 unsigned int lastColumn
= m_colWidths
.size() - 1;
871 int clientWidth
= pg
->GetClientSize().x
;
874 // Column to reduce, if needed. Take last one that exceeds minimum width.
875 // Except if auto splitter centering is used, in which case use widest.
877 int highestColWidth
= 0;
879 bool minimizedCols
= false;
883 wxLogDebug(wxT("ColumnWidthCheck (virtualWidth: %i, clientWidth: %i)"), width
, clientWidth
);
888 for ( i
=0; i
<m_colWidths
.size(); i
++ )
890 int min
= GetColumnMinWidth(i
);
891 if ( m_colWidths
[i
] <= min
)
893 m_colWidths
[i
] = min
;
894 minimizedCols
= true;
898 if ( pg
->HasFlag(wxPG_SPLITTER_AUTO_CENTER
) )
900 if ( m_colWidths
[i
] >= highestColWidth
)
902 highestColWidth
= m_colWidths
[i
];
913 int colsWidth
= pg
->m_marginWidth
;
914 for ( i
=0; i
<m_colWidths
.size(); i
++ )
915 colsWidth
+= m_colWidths
[i
];
919 wxLogDebug(wxT(" HasVirtualWidth: %i colsWidth: %i"),(int)pg
->HasVirtualWidth(),colsWidth
);
922 // Then mode-based requirement
923 if ( !pg
->HasVirtualWidth() )
925 int widthHigher
= width
- colsWidth
;
927 // Adapt colsWidth to width
928 if ( colsWidth
< width
)
933 wxLogDebug(wxT(" Adjust last column to %i"), m_colWidths
[lastColumn
] + widthHigher
);
935 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + widthHigher
;
937 else if ( colsWidth
> width
)
940 if ( reduceCol
!= -1 )
944 wxLogDebug(wxT(" Reduce column %i (by %i)"), reduceCol
, -widthHigher
);
946 // Reduce widest column, and recheck
947 m_colWidths
[reduceCol
] = m_colWidths
[reduceCol
] + widthHigher
;
954 // Only check colsWidth against clientWidth
955 if ( colsWidth
< clientWidth
)
957 m_colWidths
[lastColumn
] = m_colWidths
[lastColumn
] + (clientWidth
-colsWidth
);
962 // If width changed, recalculate virtual size
963 if ( pg
->GetState() == this )
964 pg
->RecalculateVirtualSize();
969 for ( i
=0; i
<m_colWidths
.size(); i
++ )
970 wxLogDebug(wxT("col%i: %i"),i
,m_colWidths
[i
]);
973 // Auto center splitter
974 if ( !(pg
->GetInternalFlags() & wxPG_FL_DONT_CENTER_SPLITTER
) &&
975 m_colWidths
.size() == 2 )
977 float centerX
= (float)(pg
->m_width
/2);
980 if ( m_fSplitterX
< 0.0 )
984 else if ( widthChange
)
986 //float centerX = float(pg->GetSize().x) * 0.5;
989 splitterX
= m_fSplitterX
+ (float(widthChange
) * 0.5);
990 float deviation
= fabs(centerX
- splitterX
);
992 // If deviating from center, adjust towards it
993 if ( deviation
> 20.0 )
995 if ( splitterX
> centerX
)
1003 // No width change, just keep sure we keep splitter position intact
1004 splitterX
= m_fSplitterX
;
1005 float deviation
= fabs(centerX
- splitterX
);
1006 if ( deviation
> 50.0 )
1008 splitterX
= centerX
;
1012 DoSetSplitterPosition((int)splitterX
, 0, false, true);
1014 m_fSplitterX
= splitterX
; // needed to retain accuracy
1018 void wxPropertyGridPageState::SetColumnCount( int colCount
)
1020 wxASSERT( colCount
>= 2 );
1021 m_colWidths
.SetCount( colCount
, wxPG_DRAG_MARGIN
);
1022 if ( m_colWidths
.size() > (unsigned int)colCount
)
1023 m_colWidths
.RemoveAt( m_colWidths
.size(), m_colWidths
.size() - colCount
);
1025 if ( m_pPropGrid
->GetState() == this )
1026 m_pPropGrid
->RecalculateVirtualSize();
1028 CheckColumnWidths();
1031 // Returns column index, -1 for margin
1032 int wxPropertyGridPageState::HitTestH( int x
, int* pSplitterHit
, int* pSplitterHitOffset
) const
1034 int cx
= GetGrid()->m_marginWidth
;
1036 int prevSplitter
= -1;
1041 if ( col
>= (int)m_colWidths
.size() )
1047 cx
+= m_colWidths
[col
];
1050 // Near prev. splitter
1053 int diff
= x
- prevSplitter
;
1054 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1056 *pSplitterHit
= col
- 1;
1057 *pSplitterHitOffset
= diff
;
1062 // Near next splitter
1063 int nextSplitter
= cx
;
1064 if ( col
< (int)(m_colWidths
.size()-1) )
1066 int diff
= x
- nextSplitter
;
1067 if ( abs(diff
) < wxPG_SPLITTERX_DETECTMARGIN1
)
1069 *pSplitterHit
= col
;
1070 *pSplitterHitOffset
= diff
;
1079 // -----------------------------------------------------------------------
1080 // wxPropertyGridPageState property value setting and getting
1081 // -----------------------------------------------------------------------
1083 bool wxPropertyGridPageState::DoSetPropertyValueString( wxPGProperty
* p
, const wxString
& value
)
1087 int flags
= wxPG_REPORT_ERROR
|wxPG_FULL_VALUE
;
1089 wxVariant variant
= p
->GetValueRef();
1092 if ( p
->GetMaxLength() <= 0 )
1093 res
= p
->StringToValue( variant
, value
, flags
);
1095 res
= p
->StringToValue( variant
, value
.Mid(0,p
->GetMaxLength()), flags
);
1099 p
->SetValue(variant
);
1100 if ( m_selected
==p
&& this==m_pPropGrid
->GetState() )
1101 p
->UpdateControl(m_pPropGrid
->GetEditorControl());
1109 // -----------------------------------------------------------------------
1111 bool wxPropertyGridPageState::DoSetPropertyValue( wxPGProperty
* p
, wxVariant
& value
)
1116 if ( m_selected
==p
&& this==m_pPropGrid
->GetState() )
1117 p
->UpdateControl(m_pPropGrid
->GetEditorControl());
1124 // -----------------------------------------------------------------------
1126 bool wxPropertyGridPageState::DoSetPropertyValueWxObjectPtr( wxPGProperty
* p
, wxObject
* value
)
1130 // wnd_primary has to be given so the control can be updated as well.
1132 DoSetPropertyValue(p
, v
);
1138 // -----------------------------------------------------------------------
1140 void wxPropertyGridPageState::DoSetPropertyValueUnspecified( wxPGProperty
* p
)
1142 wxCHECK_RET( p
, wxT("invalid property id") );
1144 if ( !p
->IsValueUnspecified() )
1146 // Value should be set first - editor class methods may need it
1147 p
->m_value
.MakeNull();
1149 wxASSERT( m_pPropGrid
);
1151 if ( m_pPropGrid
->GetState() == this )
1153 if ( m_pPropGrid
->m_selected
== p
&& m_pPropGrid
->m_wndEditor
)
1155 p
->GetEditorClass()->SetValueToUnspecified(p
, m_pPropGrid
->GetEditorControl());
1160 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1161 DoSetPropertyValueUnspecified( p
->Item(i
) );
1165 // -----------------------------------------------------------------------
1166 // wxPropertyGridPageState property operations
1167 // -----------------------------------------------------------------------
1169 bool wxPropertyGridPageState::DoCollapse( wxPGProperty
* p
)
1171 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1173 if ( !p
->GetChildCount() ) return false;
1175 if ( !p
->IsExpanded() ) return false;
1177 p
->SetExpanded(false);
1179 VirtualHeightChanged();
1184 // -----------------------------------------------------------------------
1186 bool wxPropertyGridPageState::DoExpand( wxPGProperty
* p
)
1188 wxCHECK_MSG( p
, false, wxT("invalid property id") );
1190 if ( !p
->GetChildCount() ) return false;
1192 if ( p
->IsExpanded() ) return false;
1194 p
->SetExpanded(true);
1196 VirtualHeightChanged();
1201 // -----------------------------------------------------------------------
1203 bool wxPropertyGridPageState::DoSelectProperty( wxPGProperty
* p
, unsigned int flags
)
1205 if ( this == m_pPropGrid
->GetState() )
1206 return m_pPropGrid
->DoSelectProperty( p
, flags
);
1212 // -----------------------------------------------------------------------
1214 bool wxPropertyGridPageState::DoHideProperty( wxPGProperty
* p
, bool hide
, int flags
)
1217 p
->ClearFlag( wxPG_PROP_HIDDEN
);
1219 p
->SetFlag( wxPG_PROP_HIDDEN
);
1221 if ( flags
& wxPG_RECURSE
)
1224 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1225 DoHideProperty(p
->Item(i
), hide
, flags
| wxPG_RECURSE_STARTS
);
1228 VirtualHeightChanged();
1233 // -----------------------------------------------------------------------
1235 bool wxPropertyGridPageState::DoEnableProperty( wxPGProperty
* p
, bool enable
)
1241 if ( !(p
->m_flags
& wxPG_PROP_DISABLED
) )
1246 p
->m_flags
&= ~(wxPG_PROP_DISABLED
);
1250 if ( p
->m_flags
& wxPG_PROP_DISABLED
)
1255 p
->m_flags
|= wxPG_PROP_DISABLED
;
1259 // Apply same to sub-properties as well
1261 for ( i
= 0; i
< p
->GetChildCount(); i
++ )
1262 DoEnableProperty( p
->Item(i
), enable
);
1269 // -----------------------------------------------------------------------
1270 // wxPropertyGridPageState wxVariant related routines
1271 // -----------------------------------------------------------------------
1273 // Returns list of wxVariant objects (non-categories and non-sub-properties only).
1274 // Never includes sub-properties (unless they are parented by wxParentProperty).
1275 wxVariant
wxPropertyGridPageState::DoGetPropertyValues( const wxString
& listname
,
1276 wxPGProperty
* baseparent
,
1279 wxPGProperty
* pwc
= (wxPGProperty
*) baseparent
;
1281 // Root is the default base-parent.
1285 wxVariantList tempList
;
1286 wxVariant
v( tempList
, listname
);
1288 if ( pwc
->GetChildCount() )
1290 if ( flags
& wxPG_KEEP_STRUCTURE
)
1292 wxASSERT( !pwc
->HasFlag(wxPG_PROP_AGGREGATE
) );
1295 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1297 wxPGProperty
* p
= pwc
->Item(i
);
1298 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1300 wxVariant variant
= p
->GetValue();
1301 variant
.SetName( p
->GetBaseName() );
1302 v
.Append( variant
);
1306 v
.Append( DoGetPropertyValues(p
->m_name
,p
,flags
|wxPG_KEEP_STRUCTURE
) );
1308 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1309 v
.Append( p
->GetAttributesAsList() );
1314 wxPropertyGridConstIterator
it( this, wxPG_ITERATE_DEFAULT
, pwc
->Item(0) );
1315 it
.SetBaseParent( pwc
);
1317 for ( ; !it
.AtEnd(); it
.Next() )
1319 const wxPGProperty
* p
= it
.GetProperty();
1321 // Use a trick to ignore wxParentProperty itself, but not its sub-properties.
1322 if ( !p
->GetChildCount() || p
->HasFlag(wxPG_PROP_AGGREGATE
) )
1324 wxVariant variant
= p
->GetValue();
1325 variant
.SetName( p
->GetName() );
1326 v
.Append( variant
);
1327 if ( (flags
& wxPG_INC_ATTRIBUTES
) && p
->m_attributes
.GetCount() )
1328 v
.Append( p
->GetAttributesAsList() );
1337 // -----------------------------------------------------------------------
1339 void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList
& list
, wxPGProperty
* defaultCategory
)
1341 unsigned char origFrozen
= 1;
1343 if ( m_pPropGrid
->GetState() == this )
1345 origFrozen
= m_pPropGrid
->m_frozen
;
1346 if ( !origFrozen
) m_pPropGrid
->Freeze();
1349 wxPropertyCategory
* use_category
= (wxPropertyCategory
*)defaultCategory
;
1351 if ( !use_category
)
1352 use_category
= (wxPropertyCategory
*)m_properties
;
1354 // Let's iterate over the list of variants.
1355 wxVariantList::const_iterator node
;
1356 int numSpecialEntries
= 0;
1359 // Second pass for special entries
1360 for ( node
= list
.begin(); node
!= list
.end(); node
++ )
1362 wxVariant
*current
= (wxVariant
*)*node
;
1364 // Make sure it is wxVariant.
1365 wxASSERT( current
);
1366 wxASSERT( wxStrcmp(current
->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
1368 const wxString
& name
= current
->GetName();
1369 if ( name
.length() > 0 )
1372 // '@' signified a special entry
1373 if ( name
[0] == wxS('@') )
1375 numSpecialEntries
++;
1379 wxPGProperty
* foundProp
= BaseGetPropertyByName(name
);
1382 wxPGProperty
* p
= foundProp
;
1384 // If it was a list, we still have to go through it.
1385 if ( wxStrcmp(current
->GetType(), wxS("list")) == 0 )
1387 DoSetPropertyValues( current
->GetList(),
1388 p
->IsCategory()?p
:((wxPGProperty
*)NULL
)
1394 if ( wxStrcmp(current
->GetType(), p
->GetValue().GetType()) != 0)
1396 wxLogDebug(wxT("wxPropertyGridPageState::DoSetPropertyValues Warning: Setting value of property \"%s\" from variant"),
1397 p
->GetName().c_str());
1401 p
->SetValue(*current
);
1407 if ( current
->GetType() != wxS("list") )
1413 // Yes, it is; create a sub category and append contents there.
1414 wxPGProperty
* newCat
= DoInsert(use_category
,-1,new wxPropertyCategory(current
->GetName(),wxPG_LABEL
));
1415 DoSetPropertyValues( current
->GetList(), newCat
);
1422 if ( numSpecialEntries
)
1424 for ( node
= list
.begin(); node
!= list
.end(); node
++ )
1426 wxVariant
*current
= (wxVariant
*)*node
;
1428 const wxString
& name
= current
->GetName();
1429 if ( name
.length() > 0 )
1432 // '@' signified a special entry
1433 if ( name
[0] == wxS('@') )
1435 numSpecialEntries
--;
1437 size_t pos2
= name
.rfind(wxS('@'));
1438 if ( pos2
> 0 && pos2
< (name
.size()-1) )
1440 wxString propName
= name
.substr(1, pos2
-1);
1441 wxString entryType
= name
.substr(pos2
+1, wxString::npos
);
1443 if ( entryType
== wxS("attr") )
1446 // List of attributes
1447 wxPGProperty
* foundProp
= BaseGetPropertyByName(propName
);
1450 wxASSERT( current
->GetType() == wxPG_VARIANT_TYPE_LIST
);
1452 wxVariantList
& list2
= current
->GetList();
1453 wxVariantList::const_iterator node2
;
1455 for ( node2
= list2
.begin(); node2
!= list2
.end(); node2
++ )
1457 wxVariant
*attr
= (wxVariant
*)*node2
;
1458 foundProp
->SetAttribute( attr
->GetName(), *attr
);
1463 // ERROR: No such property: 'propName'
1469 // ERROR: Special entry requires name of format @<propname>@<entrytype>
1474 if ( !numSpecialEntries
)
1481 m_pPropGrid
->Thaw();
1483 if ( this == m_pPropGrid
->GetState() )
1485 m_selected
->UpdateControl(m_pPropGrid
->GetEditorControl());
1491 // -----------------------------------------------------------------------
1492 // wxPropertyGridPageState property adding and removal
1493 // -----------------------------------------------------------------------
1495 int wxPropertyGridPageState::PrepareToAddItem( wxPGProperty
* property
,
1496 wxPGProperty
* scheduledParent
)
1498 wxPropertyGrid
* propGrid
= m_pPropGrid
;
1500 // This will allow better behavior.
1501 if ( scheduledParent
== m_properties
)
1502 scheduledParent
= (wxPGProperty
*) NULL
;
1504 if ( scheduledParent
&& !scheduledParent
->IsCategory() )
1506 wxASSERT_MSG( property
->GetBaseName().length(),
1507 "Property's children must have unique, non-empty names within their scope" );
1510 property
->m_parentState
= this;
1512 if ( property
->IsCategory() )
1515 // Parent of a category must be either root or another category
1516 // (otherwise Bad Things might happen).
1517 wxASSERT_MSG( scheduledParent
== NULL
||
1518 scheduledParent
== m_properties
||
1519 scheduledParent
->IsCategory(),
1520 wxT("Parent of a category must be either root or another category."));
1522 // If we already have category with same name, delete given property
1523 // and use it instead as most recent caption item.
1524 wxPGProperty
* found_id
= BaseGetPropertyByName( property
->GetBaseName() );
1527 wxPropertyCategory
* pwc
= (wxPropertyCategory
*) found_id
;
1528 if ( pwc
->IsCategory() ) // Must be a category.
1531 m_currentCategory
= pwc
;
1532 return 2; // Tells the caller what we did.
1538 // Warn for identical names in debug mode.
1539 if ( BaseGetPropertyByName(property
->GetName()) &&
1540 (!scheduledParent
|| scheduledParent
->IsCategory()) )
1542 wxLogError(wxT("wxPropertyGrid: Warning - item with name \"%s\" already exists."),
1543 property
->GetName().c_str());
1544 wxPGGlobalVars
->m_warnings
++;
1548 // Make sure nothing is selected.
1549 if ( propGrid
&& propGrid
->m_selected
)
1551 bool selRes
= propGrid
->ClearSelection();
1552 wxPG_CHECK_MSG_DBG( selRes
,
1554 wxT("failed to deselect a property (editor probably had invalid value)") );
1557 if ( scheduledParent
)
1559 // Use parent's colours.
1560 property
->m_bgColIndex
= scheduledParent
->m_bgColIndex
;
1561 property
->m_fgColIndex
= scheduledParent
->m_fgColIndex
;
1563 // Fix no parent does not yet have parenting flag yet, set one now
1564 if ( !scheduledParent
->HasFlag(wxPG_PROP_PARENTAL_FLAGS
) )
1565 scheduledParent
->SetParentalType(wxPG_PROP_MISC_PARENT
);
1566 //scheduledParent->SetFlag(wxPG_PROP_MISC_PARENT);
1569 // If in hideable adding mode, or if assigned parent is hideable, then
1570 // make this one hideable.
1572 ( scheduledParent
&& (scheduledParent
->m_flags
& wxPG_PROP_HIDDEN
) ) ||
1573 ( propGrid
&& (propGrid
->m_iFlags
& wxPG_FL_ADDING_HIDEABLES
) )
1575 property
->SetFlag( wxPG_PROP_HIDDEN
);
1577 // Set custom image flag.
1578 int custImgHeight
= property
->OnMeasureImage().y
;
1579 if ( custImgHeight
< 0 /*|| custImgHeight > 1*/ )
1581 property
->m_flags
|= wxPG_PROP_CUSTOMIMAGE
;
1584 if ( propGrid
&& (propGrid
->GetWindowStyleFlag() & wxPG_LIMITED_EDITING
) )
1585 property
->m_flags
|= wxPG_PROP_NOEDITOR
;
1587 if ( !property
->IsCategory() )
1589 // This is not a category.
1591 //wxASSERT_MSG( property->GetEditorClass(), wxT("Editor class not initialized!") );
1595 unsigned char depth
= 1;
1596 if ( scheduledParent
)
1598 depth
= scheduledParent
->m_depth
;
1599 if ( !scheduledParent
->IsCategory() )
1602 property
->m_depth
= depth
;
1603 unsigned char greyDepth
= depth
;
1605 if ( scheduledParent
)
1607 wxPropertyCategory
* pc
;
1609 if ( scheduledParent
->IsCategory() || scheduledParent
->IsRoot() )
1610 pc
= (wxPropertyCategory
*)scheduledParent
;
1612 // This conditional compile is necessary to
1613 // bypass some compiler bug.
1614 pc
= GetPropertyCategory(scheduledParent
);
1617 greyDepth
= pc
->GetDepth();
1619 greyDepth
= scheduledParent
->m_depthBgCol
;
1622 property
->m_depthBgCol
= greyDepth
;
1624 // Prepare children pre-added children
1625 if ( property
->GetChildCount() )
1627 property
->SetParentalType(wxPG_PROP_AGGREGATE
);
1629 property
->SetExpanded(false); // Properties with children are not expanded by default.
1630 if ( propGrid
&& propGrid
->GetWindowStyleFlag() & wxPG_HIDE_MARGIN
)
1631 property
->SetExpanded(true); // ...unless it cannot be expanded.
1633 property
->PrepareSubProperties();
1638 if ( propGrid
&& (propGrid
->GetExtraStyle() & wxPG_EX_AUTO_UNSPECIFIED_VALUES
) )
1639 property
->SetFlagRecursively(wxPG_PROP_AUTO_UNSPECIFIED
, true);
1645 // This is a category.
1648 unsigned char depth
= 1;
1649 if ( scheduledParent
)
1651 depth
= scheduledParent
->m_depth
+ 1;
1653 property
->m_depth
= depth
;
1654 property
->m_depthBgCol
= depth
;
1656 m_currentCategory
= (wxPropertyCategory
*)property
;
1658 wxPropertyCategory
* pc
= (wxPropertyCategory
*)property
;
1660 // Calculate text extent for caption item.
1662 pc
->CalculateTextExtent(propGrid
, propGrid
->GetCaptionFont());
1668 // -----------------------------------------------------------------------
1670 wxPGProperty
* wxPropertyGridPageState::DoAppend( wxPGProperty
* property
)
1672 wxPropertyCategory
* cur_cat
= m_currentCategory
;
1673 if ( property
->IsCategory() )
1674 cur_cat
= (wxPropertyCategory
*) NULL
;
1676 return DoInsert( cur_cat
, -1, property
);
1679 // -----------------------------------------------------------------------
1681 wxPGProperty
* wxPropertyGridPageState::DoInsert( wxPGProperty
* parent
, int index
, wxPGProperty
* property
)
1684 parent
= m_properties
;
1686 wxCHECK_MSG( !parent
->HasFlag(wxPG_PROP_AGGREGATE
),
1688 wxT("when adding properties to fixed parents, use BeginAddChildren and EndAddChildren.") );
1690 int parenting
= PrepareToAddItem( property
, (wxPropertyCategory
*)parent
);
1692 // This type of invalid parenting value indicates we should exit now, returning
1693 // id of most recent category.
1694 if ( parenting
> 1 )
1695 return m_currentCategory
;
1697 // Note that item must be added into current mode later.
1699 // If parent is wxParentProperty, just stick it in...
1700 // If parent is root (m_properties), then...
1701 // In categoric mode: Add as last item in m_abcArray (if not category).
1702 // Add to given index in m_regularArray.
1703 // In non-cat mode: Add as last item in m_regularArray.
1704 // Add to given index in m_abcArray.
1705 // If parent is category, then...
1706 // 1) Add to given category in given index.
1707 // 2) Add as last item in m_abcArray.
1709 if ( !parent
->IsCategory() && !parent
->IsRoot() )
1711 // Parent is wxParentingProperty: Just stick it in...
1712 parent
->AddChild2( property
, index
);
1716 // Parent is Category or Root.
1718 if ( m_properties
== &m_regularArray
)
1722 // Only add non-categories to m_abcArray.
1723 if ( m_abcArray
&& parenting
<= 0 )
1724 m_abcArray
->AddChild2( property
, -1, false );
1726 // Add to current mode.
1727 parent
->AddChild2( property
, index
);
1732 // Non-categorized mode.
1734 if ( parent
!= m_properties
)
1735 // Parent is category.
1736 parent
->AddChild2( property
, index
, false );
1739 m_regularArray
.AddChild2( property
, -1, false );
1741 // Add to current mode (no categories).
1742 if ( parenting
<= 0 )
1743 m_abcArray
->AddChild2( property
, index
);
1748 if ( property
->IsCategory() )
1750 // This is a category caption item.
1752 // Last caption is not the bottom one (this info required by append)
1753 m_lastCaptionBottomnest
= 0;
1756 // Only add name to hashmap if parent is root or category
1757 if ( (parent
->IsCategory() || parent
->IsRoot()) && property
->m_name
.length() )
1758 m_dictName
[property
->m_name
] = (void*) property
;
1760 VirtualHeightChanged();
1762 property
->UpdateParentValues();
1769 // -----------------------------------------------------------------------
1771 void wxPropertyGridPageState::DoDelete( wxPGProperty
* item
)
1773 wxCHECK_RET( item
->GetParent(),
1774 wxT("this property was already deleted") );
1776 wxCHECK_RET( item
!= &m_regularArray
&& item
!= m_abcArray
,
1777 wxT("wxPropertyGrid: Do not attempt to remove the root item.") );
1780 unsigned int indinparent
= item
->GetIndexInParent();
1782 wxPGProperty
* pwc
= (wxPGProperty
*)item
;
1784 wxCHECK_RET( !item
->GetParent()->HasFlag(wxPG_PROP_AGGREGATE
),
1785 wxT("wxPropertyGrid: Do not attempt to remove sub-properties.") );
1787 if ( item
->IsCategory() )
1789 // deleting a category
1791 // erase category entries from the hash table
1792 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1794 wxPGProperty
* sp
= pwc
->Item( i
);
1795 if ( sp
->GetBaseName().Len() ) m_dictName
.erase(sp
->GetBaseName());
1798 if ( pwc
== m_currentCategory
)
1799 m_currentCategory
= (wxPropertyCategory
*) NULL
;
1803 // Remove children from non-categorized array.
1804 for ( i
=0; i
<pwc
->GetChildCount(); i
++ )
1806 wxPGProperty
* p
= pwc
->Item( i
);
1807 wxASSERT( p
!= NULL
);
1808 if ( !p
->IsCategory() )
1809 m_abcArray
->m_children
.Remove( p
);
1812 if ( IsInNonCatMode() )
1813 m_abcArray
->FixIndexesOfChildren();
1817 if ( !IsInNonCatMode() )
1819 // categorized mode - non-categorized array
1821 // Remove from non-cat array, but only if parent is in it
1822 if ( !item
->IsCategory() && item
->GetParent()->IsCategory() )
1826 m_abcArray
->m_children
.Remove( item
);
1830 // categorized mode - categorized array
1831 item
->m_parent
->m_children
.RemoveAt(indinparent
);
1832 item
->m_parent
->FixIndexesOfChildren(/*indinparent*/);
1836 // non-categorized mode - categorized array
1838 // We need to find location of item.
1839 wxPGProperty
* cat_parent
= &m_regularArray
;
1840 int cat_index
= m_regularArray
.GetChildCount();
1842 for ( i
= 0; i
< m_regularArray
.GetChildCount(); i
++ )
1844 wxPGProperty
* p
= m_regularArray
.Item(i
);
1845 if ( p
== item
) { cat_index
= i
; break; }
1846 if ( p
->IsCategory() )
1848 int subind
= ((wxPGProperty
*)p
)->Index(item
);
1849 if ( subind
!= wxNOT_FOUND
)
1851 cat_parent
= ((wxPGProperty
*)p
);
1857 cat_parent
->m_children
.RemoveAt(cat_index
);
1859 // non-categorized mode - non-categorized array
1860 if ( !item
->IsCategory() )
1862 wxASSERT( item
->m_parent
== m_abcArray
);
1863 item
->m_parent
->m_children
.RemoveAt(indinparent
);
1864 item
->m_parent
->FixIndexesOfChildren(indinparent
);
1868 if ( item
->GetBaseName().Len() ) m_dictName
.erase(item
->GetBaseName());
1870 // We can actually delete it now
1873 m_itemsAdded
= 1; // Not a logical assignment (but required nonetheless).
1875 VirtualHeightChanged();
1878 // -----------------------------------------------------------------------
1880 #endif // wxUSE_PROPGRID