canvas::Layout: add clear method to remove all items.
This commit is contained in:
@@ -121,6 +121,13 @@ namespace canvas
|
||||
return item;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void BoxLayout::clear()
|
||||
{
|
||||
_layout_items.clear();
|
||||
invalidate();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void BoxLayout::setStretch(size_t index, int stretch)
|
||||
{
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace canvas
|
||||
virtual size_t count() const;
|
||||
virtual LayoutItemRef itemAt(size_t index);
|
||||
virtual LayoutItemRef takeAt(size_t index);
|
||||
virtual void clear();
|
||||
|
||||
/**
|
||||
* Set the stretch factor of the item at position @a index to @a stretch.
|
||||
|
||||
@@ -67,6 +67,13 @@ namespace canvas
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void Layout::clear()
|
||||
{
|
||||
while( itemAt(0) )
|
||||
takeAt(0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void Layout::ItemData::reset()
|
||||
{
|
||||
|
||||
@@ -66,6 +66,11 @@ namespace canvas
|
||||
*/
|
||||
void removeItem(const LayoutItemRef& item);
|
||||
|
||||
/**
|
||||
* Remove all items.
|
||||
*/
|
||||
virtual void clear();
|
||||
|
||||
protected:
|
||||
enum LayoutFlags
|
||||
{
|
||||
|
||||
@@ -309,6 +309,12 @@ BOOST_AUTO_TEST_CASE( boxlayout_insert_remove )
|
||||
hbox.removeItem(w2);
|
||||
BOOST_CHECK_EQUAL(hbox.count(), 1);
|
||||
BOOST_CHECK_EQUAL(hbox.itemAt(0), w1);
|
||||
|
||||
hbox.addItem(w2);
|
||||
BOOST_CHECK_EQUAL(hbox.count(), 2);
|
||||
|
||||
hbox.clear();
|
||||
BOOST_CHECK_EQUAL(hbox.count(), 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user