Fixed broken 'hidden categories' mode (aka. alphabetic mode); Added distinct names and labels for the two root properties (to help with debugging); Refactored wxPropertyGridState::DoInsert()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58543 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli
2009-01-31 11:48:28 +00:00
parent 3f8cdda485
commit 94b8ecf1cd
4 changed files with 40 additions and 49 deletions

View File

@@ -2358,7 +2358,7 @@ public:
public: public:
/** Constructor. */ /** Constructor. */
wxPGRootProperty(); wxPGRootProperty( const wxString& name = wxS("<Root>") );
virtual ~wxPGRootProperty(); virtual ~wxPGRootProperty();
virtual bool StringToValue( wxVariant&, const wxString&, int ) const virtual bool StringToValue( wxVariant&, const wxString&, int ) const

View File

@@ -569,9 +569,6 @@ public:
bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); } bool IsInNonCatMode() const { return (bool)(m_properties == m_abcArray); }
/** Only inits arrays, doesn't migrate things or such. */
void InitNonCatMode ();
void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true ) void DoLimitPropertyEditing( wxPGProperty* p, bool limit = true )
{ {
p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit); p->SetFlagRecursively(wxPG_PROP_NOEDITOR, limit);
@@ -707,6 +704,10 @@ protected:
unsigned char m_anyModified; unsigned char m_anyModified;
unsigned char m_vhCalcPending; unsigned char m_vhCalcPending;
private:
/** Only inits arrays, doesn't migrate things or such. */
void InitNonCatMode();
}; };
#endif // #ifndef SWIG #endif // #ifndef SWIG

View File

@@ -2430,11 +2430,14 @@ WX_PG_IMPLEMENT_PROPERTY_CLASS_PLAIN(wxPGRootProperty,none,TextCtrl)
IMPLEMENT_DYNAMIC_CLASS(wxPGRootProperty, wxPGProperty) IMPLEMENT_DYNAMIC_CLASS(wxPGRootProperty, wxPGProperty)
wxPGRootProperty::wxPGRootProperty() wxPGRootProperty::wxPGRootProperty( const wxString& name )
: wxPGProperty() : wxPGProperty()
{ {
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
m_name = wxS("<root>"); m_name = name;
m_label = m_name;
#else
wxUnusedVar(name);
#endif #endif
SetParentalType(0); SetParentalType(0);
m_depth = 0; m_depth = 0;

View File

@@ -231,7 +231,7 @@ void wxPropertyGridPageState::InitNonCatMode()
{ {
if ( !m_abcArray ) if ( !m_abcArray )
{ {
m_abcArray = new wxPGRootProperty(); m_abcArray = new wxPGRootProperty(wxS("<Root_NonCat>"));
m_abcArray->SetParentState(this); m_abcArray->SetParentState(this);
m_abcArray->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES); m_abcArray->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES);
} }
@@ -683,17 +683,9 @@ void wxPropertyGridPageState::DoSort( int flags )
{ {
DoSortChildren( m_properties, flags | wxPG_RECURSE ); DoSortChildren( m_properties, flags | wxPG_RECURSE );
// Sort categories as well (but we need not do it recursively) // We used to sort categories as well here also if in non-categorized
if ( IsInNonCatMode() ) // mode, but doing would naturally cause child indices to become
{ // corrupted.
size_t i;
for ( i=0;i<m_regularArray.GetChildCount();i++)
{
wxPGProperty* p = m_regularArray.Item(i);
if ( p->IsCategory() )
DoSortChildren( p, 0 );
}
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -1644,6 +1636,9 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index
if ( !res ) if ( !res )
return m_currentCategory; return m_currentCategory;
bool parentIsRoot = parent->IsRoot();
bool parentIsCategory = parent->IsCategory();
// Note that item must be added into current mode later. // Note that item must be added into current mode later.
// If parent is wxParentProperty, just stick it in... // If parent is wxParentProperty, just stick it in...
@@ -1656,42 +1651,34 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index
// 1) Add to given category in given index. // 1) Add to given category in given index.
// 2) Add as last item in m_abcArray. // 2) Add as last item in m_abcArray.
if ( !parent->IsCategory() && !parent->IsRoot() )
{
// Parent is wxParentingProperty: Just stick it in...
parent->AddChild2( property, index );
}
else
{
// Parent is Category or Root.
if ( m_properties == &m_regularArray ) if ( m_properties == &m_regularArray )
{ {
// Categorized mode // We are currently in Categorized mode
// Only add non-categories to m_abcArray. // Only add non-categories to m_abcArray.
if ( m_abcArray && !property->IsCategory() ) if ( m_abcArray && !property->IsCategory() &&
(parentIsCategory || parentIsRoot) )
{
m_abcArray->AddChild2( property, -1, false ); m_abcArray->AddChild2( property, -1, false );
}
// Add to current mode. // Add to current mode.
parent->AddChild2( property, index ); parent->AddChild2( property, index, true );
} }
else else
{ {
// Non-categorized mode. // We are currently in Non-categorized/Alphabetic mode
if ( parent != m_properties ) if ( parentIsCategory )
// Parent is category. // Parent is category.
parent->AddChild2( property, index, false ); parent->AddChild2( property, index, false );
else else if ( parentIsRoot )
// Parent is root. // Parent is root.
m_regularArray.AddChild2( property, -1, false ); m_regularArray.AddChild2( property, -1, false );
// Add to current mode (no categories). // Add to current mode
if ( !property->IsCategory() ) if ( !property->IsCategory() )
m_abcArray->AddChild2( property, index ); m_abcArray->AddChild2( property, index, true );
}
} }
// category stuff // category stuff
@@ -1705,7 +1692,7 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index
// Only add name to hashmap if parent is root or category // Only add name to hashmap if parent is root or category
if ( property->m_name.length() && if ( property->m_name.length() &&
(parent->IsCategory() || parent->IsRoot()) ) (parentIsCategory || parentIsRoot) )
m_dictName[property->m_name] = (void*) property; m_dictName[property->m_name] = (void*) property;
VirtualHeightChanged(); VirtualHeightChanged();