Added wxPropertyGridInterface::RemoveProperty()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57254 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -245,6 +245,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
void DeleteProperty( wxPGPropArg id );
|
void DeleteProperty( wxPGPropArg id );
|
||||||
|
|
||||||
|
/**
|
||||||
|
Removes and returns a property.
|
||||||
|
|
||||||
|
@param id
|
||||||
|
Pointer or name of a property.
|
||||||
|
|
||||||
|
@remarks Removed property cannot have any children.
|
||||||
|
*/
|
||||||
|
wxPGProperty* RemoveProperty( wxPGPropArg id );
|
||||||
|
|
||||||
/** Disables property. */
|
/** Disables property. */
|
||||||
bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); }
|
bool DisableProperty( wxPGPropArg id ) { return EnableProperty(id,false); }
|
||||||
|
|
||||||
|
@@ -421,7 +421,7 @@ public:
|
|||||||
Override this member function to add custom behavior on property
|
Override this member function to add custom behavior on property
|
||||||
deletion.
|
deletion.
|
||||||
*/
|
*/
|
||||||
virtual void DoDelete( wxPGProperty* item );
|
virtual void DoDelete( wxPGProperty* item, bool doDelete = true );
|
||||||
|
|
||||||
wxSize DoFitColumns( bool allowGridResize = false );
|
wxSize DoFitColumns( bool allowGridResize = false );
|
||||||
|
|
||||||
|
@@ -547,6 +547,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
static void RegisterAdditionalEditors();
|
static void RegisterAdditionalEditors();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Removes and returns a property.
|
||||||
|
|
||||||
|
@param id
|
||||||
|
Pointer or name of a property.
|
||||||
|
|
||||||
|
@remarks Removed property cannot have any children.
|
||||||
|
*/
|
||||||
|
wxPGProperty* RemoveProperty( wxPGPropArg id );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Replaces property with id with newly created one. For example,
|
Replaces property with id with newly created one. For example,
|
||||||
this code replaces existing property named "Flags" with one that
|
this code replaces existing property named "Flags" with one that
|
||||||
|
@@ -918,6 +918,23 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
|
|||||||
pgman->EnsureVisible(wxT("Cell Colour"));
|
pgman->EnsureVisible(wxT("Cell Colour"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
RT_START_TEST(RemoveProperty)
|
||||||
|
|
||||||
|
wxPGProperty* p;
|
||||||
|
|
||||||
|
wxPGProperty* origParent =
|
||||||
|
pgman->GetProperty(wxT("Window Styles"))->GetParent();
|
||||||
|
|
||||||
|
p = pgman->RemoveProperty(wxT("Window Styles"));
|
||||||
|
pgman->Refresh();
|
||||||
|
pgman->Update();
|
||||||
|
|
||||||
|
pgman->AppendIn(origParent, p);
|
||||||
|
pgman->Refresh();
|
||||||
|
pgman->Update();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
RT_START_TEST(SetPropertyBackgroundColour)
|
RT_START_TEST(SetPropertyBackgroundColour)
|
||||||
wxCommandEvent evt;
|
wxCommandEvent evt;
|
||||||
|
@@ -317,13 +317,42 @@ void wxPropertyGridInterface::DeleteProperty( wxPGPropArg id )
|
|||||||
if ( grid->GetState() == state )
|
if ( grid->GetState() == state )
|
||||||
grid->DoSelectProperty(NULL, wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);
|
grid->DoSelectProperty(NULL, wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);
|
||||||
|
|
||||||
state->DoDelete( p );
|
state->DoDelete( p, true );
|
||||||
|
|
||||||
RefreshGrid(state);
|
RefreshGrid(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxPGProperty* wxPropertyGridInterface::RemoveProperty( wxPGPropArg id )
|
||||||
|
{
|
||||||
|
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
|
||||||
|
|
||||||
|
wxCHECK( !p->GetChildCount() || p->HasFlag(wxPG_PROP_AGGREGATE),
|
||||||
|
wxNullProperty);
|
||||||
|
|
||||||
|
wxPropertyGridPageState* state = p->GetParentState();
|
||||||
|
wxPropertyGrid* grid = state->GetGrid();
|
||||||
|
|
||||||
|
if ( grid->GetState() == state )
|
||||||
|
{
|
||||||
|
grid->DoSelectProperty(NULL,
|
||||||
|
wxPG_SEL_DELETING|wxPG_SEL_NOVALIDATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
state->DoDelete( p, false );
|
||||||
|
|
||||||
|
// Mark the property as 'unattached'
|
||||||
|
p->m_parentState = NULL;
|
||||||
|
p->m_parent = NULL;
|
||||||
|
|
||||||
|
RefreshGrid(state);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
wxPGProperty* wxPropertyGridInterface::ReplaceProperty( wxPGPropArg id, wxPGProperty* property )
|
wxPGProperty* wxPropertyGridInterface::ReplaceProperty( wxPGPropArg id, wxPGProperty* property )
|
||||||
{
|
{
|
||||||
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
|
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(wxNullProperty)
|
||||||
|
@@ -1690,7 +1690,7 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index
|
|||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
void wxPropertyGridPageState::DoDelete( wxPGProperty* item )
|
void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( item->GetParent(),
|
wxCHECK_RET( item->GetParent(),
|
||||||
wxT("this property was already deleted") );
|
wxT("this property was already deleted") );
|
||||||
@@ -1790,6 +1790,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item )
|
|||||||
if ( item->GetBaseName().Len() ) m_dictName.erase(item->GetBaseName());
|
if ( item->GetBaseName().Len() ) m_dictName.erase(item->GetBaseName());
|
||||||
|
|
||||||
// We can actually delete it now
|
// We can actually delete it now
|
||||||
|
if ( doDelete )
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
m_itemsAdded = 1; // Not a logical assignment (but required nonetheless).
|
m_itemsAdded = 1; // Not a logical assignment (but required nonetheless).
|
||||||
|
Reference in New Issue
Block a user