X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3b9f782ef3949f583e8ac53795d36787f044fc3..b822bdc032e508858596a36cf5f344d60bf26f34:/src/propgrid/propgridpagestate.cpp diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index 51959e3362..0c6ed468cb 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -231,7 +231,7 @@ void wxPropertyGridPageState::InitNonCatMode() { if ( !m_abcArray ) { - m_abcArray = new wxPGRootProperty(); + m_abcArray = new wxPGRootProperty(wxS("")); m_abcArray->SetParentState(this); m_abcArray->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES); } @@ -255,7 +255,7 @@ void wxPropertyGridPageState::InitNonCatMode() wxPGProperty* parent = p->GetParent(); if ( parent->IsCategory() || parent->IsRoot() ) { - m_abcArray->AddChild2(p); + m_abcArray->DoAddChild(p); p->m_parent = &m_regularArray; } } @@ -268,6 +268,15 @@ void wxPropertyGridPageState::InitNonCatMode() void wxPropertyGridPageState::DoClear() { + if ( m_pPropGrid && m_pPropGrid->GetState() == this ) + { + m_pPropGrid->ClearSelection(false); + } + else + { + m_selected = NULL; + } + m_regularArray.Empty(); if ( m_abcArray ) m_abcArray->Empty(); @@ -280,8 +289,6 @@ void wxPropertyGridPageState::DoClear() m_virtualHeight = 0; m_vhCalcPending = 0; - - m_selected = NULL; } // ----------------------------------------------------------------------- @@ -683,17 +690,9 @@ void wxPropertyGridPageState::DoSort( int flags ) { DoSortChildren( m_properties, flags | wxPG_RECURSE ); - // Sort categories as well (but we need not do it recursively) - if ( IsInNonCatMode() ) - { - size_t i; - for ( i=0;iIsCategory() ) - DoSortChildren( p, 0 ); - } - } + // We used to sort categories as well here also if in non-categorized + // mode, but doing would naturally cause child indices to become + // corrupted. } // ----------------------------------------------------------------------- @@ -871,7 +870,7 @@ void wxPropertyGridPageState::SetSplitterLeft( bool subProps ) { wxPropertyGrid* pg = GetGrid(); wxClientDC dc(pg); - dc.SetFont(pg->m_font); + dc.SetFont(pg->GetFont()); int maxW = GetColumnFitWidth(dc, m_properties, 0, subProps); @@ -888,7 +887,7 @@ wxSize wxPropertyGridPageState::DoFitColumns( bool WXUNUSED(allowGridResize) ) { wxPropertyGrid* pg = GetGrid(); wxClientDC dc(pg); - dc.SetFont(pg->m_font); + dc.SetFont(pg->GetFont()); int marginWidth = pg->m_marginWidth; int accWid = marginWidth; @@ -948,9 +947,7 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange ) // // Column to reduce, if needed. Take last one that exceeds minimum width. - // Except if auto splitter centering is used, in which case use widest. int reduceCol = -1; - int highestColWidth = 0; #ifdef __WXDEBUG__ if ( debug ) @@ -968,18 +965,9 @@ void wxPropertyGridPageState::CheckColumnWidths( int widthChange ) } else { - if ( pg->HasFlag(wxPG_SPLITTER_AUTO_CENTER) ) - { - if ( m_colWidths[i] >= highestColWidth ) - { - highestColWidth = m_colWidths[i]; - reduceCol = i; - } - } - else - { - reduceCol = i; - } + // Always reduce the last column that is larger than minimum size + // (looks nicer, even with auto-centering enabled). + reduceCol = i; } } @@ -1644,6 +1632,9 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index if ( !res ) return m_currentCategory; + bool parentIsRoot = parent->IsRoot(); + bool parentIsCategory = parent->IsCategory(); + // Note that item must be added into current mode later. // If parent is wxParentProperty, just stick it in... @@ -1656,42 +1647,34 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index // 1) Add to given category in given index. // 2) Add as last item in m_abcArray. - if ( !parent->IsCategory() && !parent->IsRoot() ) + if ( m_properties == &m_regularArray ) { - // Parent is wxParentingProperty: Just stick it in... - parent->AddChild2( property, index ); - } - else - { - // Parent is Category or Root. + // We are currently in Categorized mode - if ( m_properties == &m_regularArray ) + // Only add non-categories to m_abcArray. + if ( m_abcArray && !property->IsCategory() && + (parentIsCategory || parentIsRoot) ) { - // Categorized mode - - // Only add non-categories to m_abcArray. - if ( m_abcArray && !property->IsCategory() ) - m_abcArray->AddChild2( property, -1, false ); - - // Add to current mode. - parent->AddChild2( property, index ); - + m_abcArray->DoAddChild( property, -1, false ); } - else - { - // Non-categorized mode. - - if ( parent != m_properties ) - // Parent is category. - parent->AddChild2( property, index, false ); - else - // Parent is root. - m_regularArray.AddChild2( property, -1, false ); - // Add to current mode (no categories). - if ( !property->IsCategory() ) - m_abcArray->AddChild2( property, index ); - } + // Add to current mode. + parent->DoAddChild( property, index, true ); + } + else + { + // We are currently in Non-categorized/Alphabetic mode + + if ( parentIsCategory ) + // Parent is category. + parent->DoAddChild( property, index, false ); + else if ( parentIsRoot ) + // Parent is root. + m_regularArray.DoAddChild( property, -1, false ); + + // Add to current mode + if ( !property->IsCategory() ) + m_abcArray->DoAddChild( property, index, true ); } // category stuff @@ -1705,7 +1688,7 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index // Only add name to hashmap if parent is root or category if ( property->m_name.length() && - (parent->IsCategory() || parent->IsRoot()) ) + (parentIsCategory || parentIsRoot) ) m_dictName[property->m_name] = (void*) property; VirtualHeightChanged();