Пример #1
0
void OpFillNudge::Do(OpDescriptor* pOpDesc)
{

	//	Get scaled pixel size 
	FIXED16 ScaledPixelWidth, ScaledPixelHeight;
	GetWorkingView()->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight) ;
	PixelNudge=ScaledPixelWidth.MakeDouble() ;

	// Determine the nudge factors based on the OpDescriptor used to invoke the nudge operation
	String OpToken = pOpDesc->Token; 

	if		(OpToken == String(OPTOKEN_NUDGEUPPIXEL1))		{ IsPixelNudgeClass = TRUE; }
	else if	(OpToken == String(OPTOKEN_NUDGEUPPIXEL10))		{ IsPixelNudgeClass = TRUE; }

	else if	(OpToken == String(OPTOKEN_NUDGEDOWNPIXEL1))	{ IsPixelNudgeClass = TRUE; }
	else if	(OpToken == String(OPTOKEN_NUDGEDOWNPIXEL10))	{ IsPixelNudgeClass = TRUE; }

	else if	(OpToken == String(OPTOKEN_NUDGELEFTPIXEL1))	{ IsPixelNudgeClass = TRUE; }
	else if	(OpToken == String(OPTOKEN_NUDGELEFTPIXEL10))	{ IsPixelNudgeClass = TRUE; }

	else if	(OpToken == String(OPTOKEN_NUDGERIGHTPIXEL1))	{ IsPixelNudgeClass = TRUE; }
	else if	(OpToken == String(OPTOKEN_NUDGERIGHTPIXEL10))	{ IsPixelNudgeClass = TRUE; }

	else if	(OpToken == String(OPTOKEN_NUDGEUP1))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEUP5))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEUP10))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEUPFIFTH))		{ IsPixelNudgeClass = FALSE; }

	else if	(OpToken == String(OPTOKEN_NUDGEDOWN1))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEDOWN5))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEDOWN10))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGEDOWNFIFTH))		{ IsPixelNudgeClass = FALSE; }

	else if	(OpToken == String(OPTOKEN_NUDGELEFT1))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGELEFT5))			{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGELEFT10))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGELEFTFIFTH))		{ IsPixelNudgeClass = FALSE; }

	else if	(OpToken == String(OPTOKEN_NUDGERIGHT1))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGERIGHT5))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGERIGHT10))		{ IsPixelNudgeClass = FALSE; }
	else if	(OpToken == String(OPTOKEN_NUDGERIGHTFIFTH))	{ IsPixelNudgeClass = FALSE; }

	// Setup the Offset DocCoord to contain the X and Y translation values	
	DocCoord Offset;

	if (IsPixelNudgeClass)
	{
		Offset.x=(INT32)GetXPixelDisplacement();
		Offset.y=(INT32)GetYPixelDisplacement();
	}
	else if (!IsPixelNudgeClass)
	{
		//TypeCast from double to INT32
		Offset.x=(INT32) GetXNudgeDisplacement();
		Offset.y=(INT32) GetYNudgeDisplacement();
	}

	if (AttrFillGeometry::SelectionCount == 0)
	{
			// Nothing to Nudge !!
		FailAndExecute();
		End();
		return;
	}

	FillGeometryNudger* FillNudger = new FillGeometryNudger();

	if (FillNudger == NULL)
	{
		FailAndExecute();
		End();
		return;
	}

	FillNudger->MutateColourFills(NudgeCols);
	FillNudger->SetNudgeDistance(Offset.x, Offset.y);

	AttributeManager::AttributeSelected(NULL, FillNudger);

	LastNudgeType 	= NULL;
	LastNudgeStart 	= DocCoord(0,0);
	LastNudgeEnd 	= DocCoord(0,0);
	LastNudgeEnd2 	= DocCoord(0,0);
	
	End();
}
Пример #2
0
/********************************************************************************************

>	void OpNudge::Do(OpDescriptor* pOpDesc)

	Author:		Mark_Neves (Xara Group Ltd) <*****@*****.**>
	Created:	7/9/94
	Inputs:		pOpDesc = ptr to the op descriptor
	Outputs:	-
	Returns:	-
	Purpose:	The nudge op's Do() function.
	Errors:		-
	SeeAlso:	-

********************************************************************************************/
void OpNudge::Do(OpDescriptor* pOpDesc)
{
// Determine the nudge factors based on the OpDescriptor used to invoke the nudge operation
    String OpToken = pOpDesc->Token;

//Get scaled pixel size
    FIXED16 ScaledPixelWidth, ScaledPixelHeight;
    GetWorkingView()->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight) ;
    PixelNudge=ScaledPixelWidth.MakeDouble() ;


    if		(OpToken == String(OPTOKEN_NUDGEUP1))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 1;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUP5))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 5;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUP10))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 10;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUPFIFTH))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 0.2;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWN1))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -1;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWN5))				{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -5;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWN10))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -10;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWNFIFTH))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -0.2;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFT1))				{
        X_NudgeFactor = -1;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFT5))				{
        X_NudgeFactor = -5;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFT10))			{
        X_NudgeFactor = -10;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFTFIFTH))			{
        X_NudgeFactor = -0.2;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHT1))			{
        X_NudgeFactor = 1;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHT5))	 		{
        X_NudgeFactor = 5;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHT10))			{
        X_NudgeFactor = 10;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHTFIFTH))		{
        X_NudgeFactor = 0.2;
        Y_NudgeFactor = 0;
        flag=TRUE;
    }

    else if (OpToken == String(OPTOKEN_NUDGEUPPIXEL1)) 			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 1;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEUPPIXEL10))			{
        X_NudgeFactor = 0;
        Y_NudgeFactor = 10;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL1))		{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -1;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL10))		{
        X_NudgeFactor = 0;
        Y_NudgeFactor = -10;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL1))		{
        X_NudgeFactor = -1;
        Y_NudgeFactor = 0;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL10))		{
        X_NudgeFactor = -10;
        Y_NudgeFactor =	0;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL1))		{
        X_NudgeFactor = 1;
        Y_NudgeFactor = 0;
        flag=FALSE;
    }
    else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL10))		{
        X_NudgeFactor = 10;
        Y_NudgeFactor = 0;
        flag=FALSE;
    }

    else
    {
        ERROR3("Unknown type of nudge");
    }



    Range* Selection = GetApplication()->FindSelection();
    RangeControl TransFlags = Selection->GetRangeControlFlags();
    TransFlags.IgnoreNoneRenderable=TRUE;
    TransFlags.IgnoreInvisibleLayers = TRUE;
    Selection->SetRangeControl(TransFlags);
    SliceHelper::ModifySelectionToContainWholeButtonElements();



// Setup the Offset DocCoord to contain the X and Y translation values
    DocCoord Offset;

    if	(flag)
    {
        (Offset.x) = (INT32) GetXNudgeDisplacement();
        (Offset.y) = (INT32) GetYNudgeDisplacement();
    }
    else if	(!flag)
    {
        (Offset.x) = (INT32)GetXPixelDisplacement();
        (Offset.y) = (INT32)GetYPixelDisplacement();
    }

    // Will the nudge send the selection beyond the spread bounds?
    // If so, fail and return now
    if (!IsNudgeOK(Offset.x,Offset.y))
    {
        SliceHelper::RestoreSelection();
        InformWarning(_R(IDS_NUDGE_OUTOFBOUNDS));
        FailAndExecute();
        End();
        return;
    }

    TransformData 	TransData;

    // Set up the transform data
    TransData.CentreOfTrans.x 	= 0;
    TransData.CentreOfTrans.y 	= 0;
    TransData.StartBlob 	  	= 0;
    TransData.LockAspect 		= TRUE;
    TransData.LeaveCopy  		= FALSE;
    TransData.ScaleLines 		= FALSE;
    TransData.TransFills 		= TRUE;
    TransData.pRange = 0;

    // Call OpTranslateTrans::DoWithParams() with a ptr to the transform data and a ptr to a DocCoord
    // that specs the X and Y offsets of the translation
    OpParam param( &TransData, &Offset );
    DoWithParam( pOpDesc, &param );

    SliceHelper::RestoreSelection();
}