Ejemplo n.º 1
0
void LibraryFile::DoScrollRedraw(void)
{
	// Scroll / redraw the newly added groups...
	if(FirstLibraryAdded != NULL && LastLibraryAdded != NULL)
	{
		SGLibGroup *FirstGroup = FirstLibraryAdded->ParentGroup;
		SGLibGroup *SecondGroup = LastLibraryAdded->ParentGroup;
	
		if(FirstGroup != NULL && SecondGroup != NULL)
		{
			// Redraw whatever we need to and reformat the gallery ready for poking...
			ParentGallery->ReformatAndRedrawIfNecessary();

			// Calculate where the new folders are...
			DocRect ScrollToRect;
			FirstGroup->GetFormatRect(&ScrollToRect);
			if(SecondGroup != FirstGroup)
			{
				DocRect TempRect;
				FirstGroup->GetFormatRect(&TempRect);				
				ScrollToRect = ScrollToRect.Union(TempRect);
			}

			// Actually do the scroll...
			ParentGallery->ScrollToShow(&ScrollToRect, TRUE);
		}
	}
}
Ejemplo n.º 2
0
DocRect NodeSimpleShape::GetBlobBoundingRect()
{
#if !defined(EXCLUDE_FROM_RALPH)
	// Find the Shapes bounding rectangle
	DocRect Rect = GetBoundingRect();

	// Find the blob manager
	BlobManager* pBlobMgr = GetApplication()->GetBlobManager();

	// And if we can find the current view, add on the size of a selection blob
	if (pBlobMgr!= NULL)
	{
		// Wee need to add in each of the blobs. there is a blob on each corner
		// of the parallelogram
		DocRect BlobSize;
		pBlobMgr->GetBlobRect(Parallel[0], &BlobSize);
		Rect = Rect.Union(BlobSize);
		
		// Next corner of the parallelogram
		pBlobMgr->GetBlobRect(Parallel[1], &BlobSize);
		Rect = Rect.Union(BlobSize);

		// and the next
		pBlobMgr->GetBlobRect(Parallel[2], &BlobSize);
		Rect = Rect.Union(BlobSize);

		// and the last one
		pBlobMgr->GetBlobRect(Parallel[3], &BlobSize);
		Rect = Rect.Union(BlobSize);
	}

	// Make sure we include the Bounds of our children
	IncludeChildrensBoundingRects(&Rect);

	// return the rectangle with the blobs included
	return Rect;
#else
	return DocRect(0,0,0,0);
#endif
}
Ejemplo n.º 3
0
AttrFillGeometry* FillGeometryNudger::MutateFill(AttrFillGeometry* FillToMutate)
{
	if (!FillToMutate->IsVisible() ||
		FillToMutate->GetSelectionCount() == 0)
		return NULL;

	// Make a copy of this Fill to change
	AttrFillGeometry* NewFill = (AttrFillGeometry*)FillToMutate->SimpleCopy();
	if (NewFill == NULL)
		return NULL;

	// Construct the translation matrix
	Trans2DMatrix TransMat(X_NudgeDistance, Y_NudgeDistance);
	
	BOOL isARampBlob = FALSE;

	// And apply it to the fill
	
	NewFill->TransformSelectedControlPoints(TransMat, &isARampBlob);

	if (LastNudgeType == FillToMutate->GetRuntimeClass())
	{
		BOOL IsSame = TRUE;

		if (FillToMutate->GetStartPoint() && 
			*FillToMutate->GetStartPoint() != LastNudgeStart)
			IsSame = FALSE;	

		if (FillToMutate->GetEndPoint() && 
			*FillToMutate->GetEndPoint() != LastNudgeEnd)
			IsSame = FALSE;	

		if (FillToMutate->GetEndPoint2() && 
			*FillToMutate->GetEndPoint2() != LastNudgeEnd2)
			IsSame = FALSE;	

		if (IsSame)
			return NewFill;
	}

	Node *pNode = FillToMutate;
	while ((pNode != NULL) && !pNode->IsSpread())
		pNode = pNode->FindParent();

	if (pNode == NULL)
		return NewFill;			// We're not really in the tree

	Spread* pSpread = (Spread*)pNode;

	DocRect OldBounds = FillToMutate->GetBlobBoundingRect();
	DocRect NewBounds = NewFill->GetBlobBoundingRect();

	DocRect Bounds = OldBounds.Union(NewBounds);

	RenderRegion* pRegion = DocView::RenderOnTop(&Bounds, pSpread, UnclippedEOR);
	while (pRegion)
	{
		if (!isARampBlob)
		{
			// MUST do a full redraw of the fill blobs
			FillToMutate->RenderFillBlobs(pRegion);
			NewFill->RenderFillBlobs(pRegion);
		}
		else
		{
			FillToMutate->DisableRampRedraw ();
			FillToMutate->RenderFillBlobs(pRegion);
			FillToMutate->EnableRampRedraw ();
			NewFill->DisableRampRedraw ();
			NewFill->RenderFillBlobs(pRegion);
			NewFill->EnableRampRedraw ();
		}

		// Get the Next render region
		pRegion = DocView::GetNextOnTop(&Bounds);
	}

	AttrFillGeometry::LastRenderedMesh = NULL;

	LastNudgeType 	= FillToMutate->GetRuntimeClass();

	if (FillToMutate->GetStartPoint())
		LastNudgeStart 	= *FillToMutate->GetStartPoint();

	if (FillToMutate->GetEndPoint())
		LastNudgeEnd 	= *FillToMutate->GetEndPoint();

	if (FillToMutate->GetEndPoint2())
		LastNudgeEnd2 	= *FillToMutate->GetEndPoint2();

	return NewFill; 
}
Ejemplo n.º 4
0
void OpAlign::DoWithParam(OpDescriptor* pOp, OpParam* pAlignParam)
{
	// DMc alterations so that this works with compound nodes	
	SelRange   Selection(*(GetApplication()->FindSelection()));

	RangeControl rg = Selection.GetRangeControlFlags();
	rg.PromoteToParent = TRUE;
	Selection.Range::SetRangeControl(rg);

	DocRect		SelRect   = Selection.GetBoundingRect();
	DocRect		TargetRect;
	TargetRect.MakeEmpty();
	INT32        NumObjs   = Selection.Count();
	AlignParam* pAlign    =(AlignParam*)pAlignParam;

	BOOL moved=FALSE;					// set to TRUE if any object is moved
	BeginSlowJob(-1,FALSE);
	BOOL OK=DoStartTransOp(FALSE);

	// find parent spread of first object in selection
	Node*   pFirstNode=NULL;
	Spread* pSpread   =NULL;
	if (OK)
	{
		pFirstNode=Selection.FindFirst();
		if (pFirstNode!=NULL)
			pSpread=pFirstNode->FindParentSpread();
		OK=(pSpread!=NULL);
		if (!OK)
			ERROR2RAW("OpAlign::DoWithParam() - could not find parent spread");
	}

	// Find the size of the target rectangle
	if (pAlign->target==ToSelection)
		TargetRect=SelRect;
	else
	{
		Page* pPage=pSpread->FindFirstPageInSpread();
		while (pPage)
		{
			DocRect PageRect=pPage->GetPageRect();
			if (pAlign->target==ToSpread || SelRect.IsIntersectedWith(PageRect))
				TargetRect=TargetRect.Union(PageRect);
			pPage=pPage->FindNextPage();
		}
	}

	// allocate all dynamic memory required
	Node**	 pObj=NULL;
	ObjInfo* x   =NULL;
	ObjInfo* y   =NULL;
	INT32*    dx  =NULL;
	INT32*    dy  =NULL;
	if (OK)			ALLOC_WITH_FAIL(pObj,(Node**)  CCMalloc(NumObjs*sizeof(Node*)),  this);
	if (pObj!=NULL)	ALLOC_WITH_FAIL(x,   (ObjInfo*)CCMalloc(NumObjs*sizeof(ObjInfo)),this);
	if (   x!=NULL) ALLOC_WITH_FAIL(y,   (ObjInfo*)CCMalloc(NumObjs*sizeof(ObjInfo)),this);
	if (   y!=NULL) ALLOC_WITH_FAIL(dx,  (INT32*)   CCMalloc(NumObjs*sizeof(INT32)),   this);
	if (  dx!=NULL) ALLOC_WITH_FAIL(dy,  (INT32*)   CCMalloc(NumObjs*sizeof(INT32)),   this);
	OK=(dy!=NULL);

	// if memory claimed OK and target rect not empty proceed with op
	// (ie. do nothing if 'within page(s)' when no object on a page)
	DocRect EmptyRect;
	if (OK && TargetRect!=EmptyRect)
	{
		// create an array of pointers to objects (nodes) to be affected
		Node* pNode=Selection.FindFirst();
		INT32  i=0;
		while (pNode!=NULL)
		{
			if (pNode->IsBounded() && !((NodeRenderableBounded*)pNode)->GetBoundingRect(TRUE).IsEmpty())
				pObj[i++]=pNode;
			pNode=Selection.FindNext(pNode);
		}
		NumObjs=i;

		// cache x & y info in separate arrays so they can be sorted separately
		XLONG SumObjWidths =0;
		XLONG SumObjHeights=0;
		for (i=0; i<NumObjs; i++)
		{
			DocRect ObjRect=((NodeRenderableBounded*)pObj[i])->GetBoundingRect();
			x[i].i=i;
			x[i].lo=ObjRect.lo.x;
			x[i].hi=ObjRect.hi.x;
			SumObjWidths+=ObjRect.hi.x-ObjRect.lo.x;
			y[i].i=i;
			y[i].lo=ObjRect.lo.y;
			y[i].hi=ObjRect.hi.y;
			SumObjHeights+=ObjRect.hi.y-ObjRect.lo.y;
		}

		// for each object, calculate the x and y displacements independently
		AlignOneAxis(pAlign->h,NumObjs,SumObjWidths, TargetRect.lo.x,TargetRect.hi.x,x,dx);
		AlignOneAxis(pAlign->v,NumObjs,SumObjHeights,TargetRect.lo.y,TargetRect.hi.y,y,dy);

		// apply the x and y displacements simultaneously to each object
		for (i=0; i<NumObjs; i++)
			if (dx[i]!=0 || dy[i]!=0)
			{
				moved=TRUE;
				Trans2DMatrix* pMatrix=new Trans2DMatrix(dx[i],dy[i]);
				DoTransformNode((NodeRenderableInk*)pObj[i],pMatrix);
			}
	}

	// free up any memory which was allocated
	CCFree(dx);
	CCFree(dy);
	CCFree(x);
	CCFree(y);
	CCFree(pObj);

	if (moved)
	{
		Document::GetSelected()->ForceRedraw(pSpread, TargetRect);
		GetApplication()->UpdateSelection();
	}
	else
		FailAndExecute();
	End();
	EndSlowJob();
}