//---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- SizeToFitOperation::SizeToFitOperation (UISelection* selection) : BaseSelectionOperation<std::pair<SharedPointer<CView>, CRect> > (selection) { FOREACH_IN_SELECTION(selection, view) push_back (std::make_pair (view, view->getViewSize ())); FOREACH_IN_SELECTION_END }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- ViewSizeChangeOperation::ViewSizeChangeOperation (UISelection* selection, bool sizing, bool autosizingEnabled) : BaseSelectionOperation<std::pair<SharedPointer<CView>, CRect> > (selection) , first (true) , sizing (sizing) , autosizing (autosizingEnabled) { FOREACH_IN_SELECTION(selection, view) push_back (std::make_pair (view, view->getViewSize ())); FOREACH_IN_SELECTION_END }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- AttributeChangeAction::AttributeChangeAction (UIDescription* desc, UISelection* selection, const std::string& attrName, const std::string& attrValue) : desc (desc) , attrName (attrName) , attrValue (attrValue) , selection (selection) { const UIViewFactory* viewFactory = dynamic_cast<const UIViewFactory*> (desc->getViewFactory ()); std::string attrOldValue; FOREACH_IN_SELECTION(selection, view) viewFactory->getAttributeValue (view, attrName, attrOldValue, desc); insert (std::make_pair (view, attrOldValue)); FOREACH_IN_SELECTION_END name = "'" + attrName + "' change"; }
//---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------- DeleteOperation::DeleteOperation (UISelection* selection) : selection (selection) { FOREACH_IN_SELECTION(selection, view) CViewContainer* container = dynamic_cast<CViewContainer*> (view->getParentView ()); if (dynamic_cast<UIEditView*>(container) == 0) { CView* nextView = 0; ViewIterator it (container); while (*it) { if (*it == view) { nextView = *++it; break; } ++it; } insert (std::make_pair (container, new DeleteOperationViewAndNext (view, nextView))); } FOREACH_IN_SELECTION_END }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- ViewCopyOperation::ViewCopyOperation (UISelection* copySelection, UISelection* workingSelection, CViewContainer* parent, const CPoint& offset, IUIDescription* desc) : parent (parent) , copySelection (copySelection) , workingSelection (workingSelection) { CRect selectionBounds = copySelection->getBounds (); FOREACH_IN_SELECTION(copySelection, view) if (!copySelection->containsParent (view)) { CRect viewSize = UISelection::getGlobalViewCoordinates (view); CRect newSize (0, 0, view->getWidth (), view->getHeight ()); newSize.offset (offset.x, offset.y); newSize.offset (viewSize.left - selectionBounds.left, viewSize.top - selectionBounds.top); view->setViewSize (newSize); view->setMouseableArea (newSize); push_back (view); } FOREACH_IN_SELECTION_END FOREACH_IN_SELECTION(workingSelection, view) oldSelectedViews.push_back (view); FOREACH_IN_SELECTION_END }
//---------------------------------------------------------------------------------------------------- void UIEditView::drawRect (CDrawContext *pContext, const CRect& updateRect) { // disable focus drawing bool focusDrawing = getFrame ()->focusDrawingEnabled (); if (!editing && focusDrawing) getFrame ()->setFocusDrawingEnabled (false); CViewContainer::drawRect (pContext, updateRect); if (!editing && focusDrawing) getFrame ()->setFocusDrawingEnabled (focusDrawing); CRect oldClip = pContext->getClipRect (oldClip); CRect newClip (updateRect); newClip.offset (-getViewSize ().left, -getViewSize ().top); pContext->setClipRect (updateRect); CCoord save[4]; modifyDrawContext (save, pContext); const CCoord dashLength[] = {5, 5}; const CLineStyle lineDash (CLineStyle::kLineCapButt, CLineStyle::kLineJoinMiter, 0, 2, dashLength); pContext->setLineStyle (lineDash); pContext->setLineWidth (1); pContext->setDrawMode (kAliasing); pContext->setFrameColor (kBlueCColor); pContext->drawRect (CRect (0, 0, getWidth(), getHeight()), kDrawStroked); if (editing) { if (lines) lines->draw (pContext); pContext->setDrawMode (kAntiAliasing); if (highlightView) { CRect r = UISelection::getGlobalViewCoordinates (highlightView); CPoint p; frameToLocal (p); r.offset (p.x, p.y); r.inset (2, 2); pContext->setFrameColor (viewHighlightColor); pContext->setLineStyle (kLineSolid); pContext->setLineWidth (3); pContext->drawRect (r); } if (getSelection ()->total () > 0) { pContext->setDrawMode (kAliasing); pContext->setFrameColor (viewSelectionColor); pContext->setLineStyle (kLineSolid); pContext->setLineWidth (1); FOREACH_IN_SELECTION(getSelection (), view) CRect vs = getSelection ()->getGlobalViewCoordinates (view); CPoint p; frameToLocal (p); vs.offset (p.x, p.y); pContext->drawRect (vs); FOREACH_IN_SELECTION_END } }