//---------------------------------------------------------------------------------------------------- void UnembedViewOperation::undo () { CRect containerViewSize = containerView->getViewSize (); const_iterator it = begin (); while (it != end ()) { CView* view = (*it); parent->removeView (view, false); CRect viewSize = view->getViewSize (); CRect mouseSize = view->getMouseableArea (); viewSize.offset (-containerViewSize.left, -containerViewSize.top); mouseSize.offset (-containerViewSize.left, -containerViewSize.top); view->setViewSize (viewSize); view->setMouseableArea (mouseSize); containerView->addView (view); it++; } parent->addView (containerView); selection->setExclusive (containerView); }
//---------------------------------------------------------------------------------------------------- void UnembedViewOperation::perform () { IDependency::DeferChanges dc (selection); selection->remove (containerView); CRect containerViewSize = containerView->getViewSize (); const_reverse_iterator it = rbegin (); while (it != rend ()) { CView* view = (*it); CRect viewSize = view->getViewSize (); CRect mouseSize = view->getMouseableArea (); containerView->removeView (view, false); viewSize.offset (containerViewSize.left, containerViewSize.top); mouseSize.offset (containerViewSize.left, containerViewSize.top); view->setViewSize (viewSize); view->setMouseableArea (mouseSize); if (parent->addView (view)) selection->add (view); it++; } parent->removeView (containerView, false); }
//----------------------------------------------------------------------------- void CTabView::setViewSize (const CRect &rect, bool invalid) { if (rect == getViewSize ()) return; CRect oldSize (getViewSize ()); CCoord widthDelta = rect.getWidth () - oldSize.getWidth (); CCoord heightDelta = rect.getHeight () - oldSize.getHeight (); if (widthDelta != 0 || heightDelta != 0) { uint32_t numSubviews = getNbViews(); int32_t counter = 1; bool treatAsColumn = (getAutosizeFlags () & kAutosizeColumn) ? true : false; bool treatAsRow = (getAutosizeFlags () & kAutosizeRow) ? true : false; CTabChildView* v = firstChild; while (v) { if (v != currentChild) { CView* pV = v->view; int32_t autosize = pV->getAutosizeFlags (); CRect viewSize (pV->getViewSize ()); CRect mouseSize (pV->getMouseableArea ()); if (treatAsColumn) { if (counter) { viewSize.offset (counter * (widthDelta / (numSubviews)), 0); mouseSize.offset (counter * (widthDelta / (numSubviews)), 0); } viewSize.setWidth (viewSize.getWidth () + (widthDelta / (numSubviews))); mouseSize.setWidth (mouseSize.getWidth () + (widthDelta / (numSubviews))); } else if (widthDelta != 0 && autosize & kAutosizeRight) { viewSize.right += widthDelta; mouseSize.right += widthDelta; if (!(autosize & kAutosizeLeft)) { viewSize.left += widthDelta; mouseSize.left += widthDelta; } } if (treatAsRow) { if (counter) { viewSize.offset (0, counter * (heightDelta / (numSubviews))); mouseSize.offset (0, counter * (heightDelta / (numSubviews))); } viewSize.setHeight (viewSize.getHeight () + (heightDelta / (numSubviews))); mouseSize.setHeight (mouseSize.getHeight () + (heightDelta / (numSubviews))); } else if (heightDelta != 0 && autosize & kAutosizeBottom) { viewSize.bottom += heightDelta; mouseSize.bottom += heightDelta; if (!(autosize & kAutosizeTop)) { viewSize.top += heightDelta; mouseSize.top += heightDelta; } } if (viewSize != pV->getViewSize ()) { pV->setViewSize (viewSize); pV->setMouseableArea (mouseSize); } } v = v->next; // counter++; } } CViewContainer::setViewSize (rect, invalid); }