Add wxAuiToolBar::DestroyTool() and DestroyToolByIndex()
These new functions destroy the associated window too, unlike the existing DeleteTool() and DeleteByIndex(). Closes #16552.
This commit is contained in:
parent
95b1f7b7ea
commit
700eaff131
@ -525,6 +525,12 @@ public:
|
||||
|
||||
void ClearTools() { Clear() ; }
|
||||
void Clear();
|
||||
|
||||
bool DestroyTool(int toolId);
|
||||
bool DestroyToolByIndex(int idx);
|
||||
|
||||
// Note that these methods do _not_ delete the associated control, if any.
|
||||
// Use DestroyTool() or DestroyToolByIndex() if this is wanted.
|
||||
bool DeleteTool(int toolId);
|
||||
bool DeleteByIndex(int toolId);
|
||||
|
||||
|
@ -724,11 +724,33 @@ public:
|
||||
void Clear();
|
||||
|
||||
/**
|
||||
Removes the tool with the given ID from the tool bar.
|
||||
Destroys the tool with the given ID and its associated window, if any.
|
||||
|
||||
@param tool_id ID of a previously added tool.
|
||||
@return @true if the tool was destroyed or @false otherwise, e.g. if
|
||||
the tool with the given ID was not found.
|
||||
|
||||
@since 3.1.4
|
||||
*/
|
||||
bool DestroyTool(int tool_id);
|
||||
|
||||
/**
|
||||
Destroys the tool at the given position and its associated window, if
|
||||
any.
|
||||
|
||||
@param idx The index, or position, of a previously added tool.
|
||||
@return @true if the tool was destroyed or @false otherwise, e.g. if
|
||||
the provided index is out of range.
|
||||
*/
|
||||
bool DestroyToolByIndex(int idx);
|
||||
|
||||
/**
|
||||
Removes the tool with the given ID from the toolbar.
|
||||
|
||||
Note that if this tool was added by AddControl(), the associated
|
||||
control is @e not deleted and must either be reused (e.g. by
|
||||
reparenting it under a different window) or destroyed by caller.
|
||||
If this behaviour is unwanted, prefer using DestroyTool() instead.
|
||||
|
||||
@param tool_id ID of a previously added tool.
|
||||
@return @true if the tool was removed or @false otherwise, e.g. if the
|
||||
@ -737,11 +759,13 @@ public:
|
||||
bool DeleteTool(int tool_id);
|
||||
|
||||
/**
|
||||
Removes the tool at the given position from the tool bar.
|
||||
Removes the tool at the given position from the toolbar.
|
||||
|
||||
Note that if this tool was added by AddControl(), the associated
|
||||
control is @e not deleted and must either be reused (e.g. by
|
||||
reparenting it under a different window) or destroyed by caller.
|
||||
If this behaviour is unwanted, prefer using DestroyToolByIndex()
|
||||
instead.
|
||||
|
||||
@param idx The index, or position, of a previously added tool.
|
||||
@return @true if the tool was removed or @false otherwise, e.g. if the
|
||||
|
@ -1180,6 +1180,22 @@ bool wxAuiToolBar::DeleteByIndex(int idx)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxAuiToolBar::DestroyTool(int tool_id)
|
||||
{
|
||||
return DestroyToolByIndex(GetToolIndex(tool_id));
|
||||
}
|
||||
|
||||
bool wxAuiToolBar::DestroyToolByIndex(int idx)
|
||||
{
|
||||
if ( idx < 0 || static_cast<unsigned>(idx) >= m_items.GetCount() )
|
||||
return false;
|
||||
|
||||
if ( wxWindow* window = m_items[idx].GetWindow() )
|
||||
window->Destroy();
|
||||
|
||||
return DeleteByIndex(idx);
|
||||
}
|
||||
|
||||
|
||||
wxControl* wxAuiToolBar::FindControl(int id)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user