void WFitLayout::removeItem(WLayoutItem *item) { if (item == grid_.items_[0][0].item_) { grid_.items_[0][0].item_ = 0; updateRemoveItem(item); } }
void WGridLayout::removeItem(WLayoutItem *item) { int index = indexOf(item); if (index != -1) { int row = index / columnCount(); int col = index % columnCount(); grid_.items_[row][col].item_ = 0; updateRemoveItem(item); } }
void WBoxLayout::removeItem(WLayoutItem *item) { int index = indexOf(item); if (index != -1) { switch (direction_) { case RightToLeft: index = grid_.columns_.size() - 1 - index; case LeftToRight: grid_.columns_.erase(grid_.columns_.begin() + index); grid_.items_[0].erase(grid_.items_[0].begin() + index); break; case BottomToTop: index = grid_.rows_.size() - 1 - index; case TopToBottom: grid_.rows_.erase(grid_.rows_.begin() + index); grid_.items_.erase(grid_.items_.begin() + index); } updateRemoveItem(item); } }
void WGridLayout::addItem(WLayoutItem *item, int row, int column, int rowSpan, int columnSpan, WFlags<AlignmentFlag> alignment) { columnSpan = std::max(1, columnSpan); rowSpan = std::max(1, rowSpan); expand(row, column, rowSpan, columnSpan); Impl::Grid::Item& gridItem = grid_.items_[row][column]; if (gridItem.item_) { WLayoutItem *oldItem = gridItem.item_; gridItem.item_ = 0; updateRemoveItem(oldItem); } gridItem.item_ = item; gridItem.rowSpan_ = rowSpan; gridItem.colSpan_ = columnSpan; gridItem.alignment_ = alignment; updateAddItem(item); }