示例#1
0
BOOL CImage::EditInit( EDIT_TARGET Target, UNDO_TYPE UndoType,
				LPOBJECT lpTargetObject)
{
LPOBJECT lpObject, lpBase;
int retc;
BOOL fDiscardUndo = NO;
BOOL fUndoFailed;
BOOL fMaskEdit;
EDIT_TARGET OldTarget;

lpBase = GetBase();

// the InitUndoType flag is kept separately from the
// DataUndoType and AlphaUndoType so that if the initialization
// of the undo fails we still know what was edited when
// EditedObject and EditedObjectFrame are called
lpObject = NULL;
while (lpObject = GetNextObject(lpObject, YES, NO))
	lpObject->InitUndoType = 0;

// No mask undo's are allowed - so apply any that we have now
if (!Control.UndoMasks)
	ObjEditApply(lpBase, NO, YES, NO);

// No undo's are allowed - so apply any that we have now
if (Control.NoUndo || fDisableUndos)
	{
	lpObject = NULL;
	while (lpObject = GetNextObject(lpObject, YES, NO))
		ObjEditApply(lpObject, YES, lpObject != lpBase, NO);
	}

// if we have don't have multiple objects, strip off the delete objects flag
if (!Control.MultipleObjects)
	UndoType &= ~UT_DELETEOBJECTS;

// find out whether we are in mask edit mode
fMaskEdit = (Target == ET_OBJECT) && (lpTargetObject == lpBase) &&
			((UndoType & UT_ALPHAUNDO) != 0);

// see if any objects cannot have their undos freed without
// asking the user first, if so ask the user and get the response
// This is only a manual apply thing
if (UndoType & (UT_NEWDATA|UT_NEWALPHA) && Control.UseApply)
	{
	lpObject = NULL;
	fDiscardUndo = YES;
	while (lpObject = GetNextObject(lpObject, YES, NO))
		{
		// see if this is an object we are not editing
		if ((Target == ET_SELOBJECTS &&
			!IsSelectedObject(lpObject)) ||
			(Target == ET_OBJECT && lpObject != lpTargetObject))
			continue;
		if (!ObjEditUndoDiscardable(lpObject, (UndoType & UT_NEWDATA) != 0,
											(UndoType & UT_NEWALPHA) != 0))
			{
			if (lpCmdList->fPlayback)
				{
				fDiscardUndo = fDiscardUndo;
				}
			else
				{
				DISCARDUNDO_PARMS parms;

				retc = AstralConfirm( IDS_OKTOAPPLY );
				if (retc == IDCANCEL)
					return(FALSE);
				fDiscardUndo = retc == IDYES;
				parms.fDiscardUndo = fDiscardUndo;

				PostCommand(lpCmdList, IDS_CMD_DISCARDUNDO, &parms);
				}
			break;
			}
		}
	}

OldTarget = EditTarget;
EditTarget = Target;

// now loop through the objects initializing their undos
lpObject = NULL;
while (lpObject = GetNextObject(lpObject, YES, NO))
	{
	// if our last edit involved editing all objects then
	// make sure we apply for all objects
	if (OldTarget == ET_ALLOBJECTS)
		{
		ObjEditApply(lpObject, !fMaskEdit,
 				(lpObject != lpBase) && !fMaskEdit, NO);
		}

	// see if this is an object we are not editing
	if ((Target == ET_SELOBJECTS && !IsSelectedObject(lpObject)) ||
		(Target == ET_OBJECT && lpObject != lpTargetObject))
		{
		// if no individual undo's, wack any undo buffers
		// if in auto apply or in manual apply and state is redo
		// Objects that are not the base need to also have
		// their alphas wacked if this is not a mask edit 
		if (!Control.UndoObjects && (!Control.UseApply ||
				( Control.UseApply && !lpObject->DataUndoNotRedo ) ) )
			ObjEditApply(lpObject, !fMaskEdit,
 				(lpObject != lpBase) && !fMaskEdit, NO);
		continue;
		}

	// Discard it's undo if possible
	if (fDiscardUndo)
		ObjEditFreeUndo(lpObject, (UndoType & UT_NEWDATA) != 0,
						(UndoType & UT_NEWALPHA) != 0);

	// save state of undo failed flag
	fUndoFailed = lpObject->fUndoFailed;

	// Initialize the undo for this object
	if (!ObjEditInit(lpObject, UndoType))
		{
		// Undo initialization failed, so apply all objects that
		// were going to be initialized
		lpObject = NULL;
		while (lpObject = GetNextObject(lpObject, YES, NO))
			{
			// see if this is an object we are not editing
			if ((Target == ET_SELOBJECTS &&
				!IsSelectedObject(lpObject)) ||
				(Target == ET_OBJECT && lpObject != lpTargetObject))
				{
				continue;
				}
			lpObject->fUndoFailed = YES;
			lpObject->InitUndoType = 0;
			if (lpObject == lpBase)
				ObjEditApply(lpObject,
							(UndoType & UT_DATAUNDO) != 0,
							(UndoType & UT_ALPHAUNDO) != 0, NO);
			else
				ObjEditApply(lpObject, YES, YES, NO);
			}
		// if we have failed before
		if (fUndoFailed)
			return(TRUE);
		else
			{
			Message(IDS_NOUNDO);
			return(FALSE);
			}
		}
	lpObject->fUndoFailed = NO;
	lpObject->InitUndoType = UndoType;
	}
return( TRUE );
}
示例#2
0
BOOL ImgEditInit( LPIMAGE lpImage, EDIT_TARGET Target, UNDO_TYPE UndoType,
				LPOBJECT lpTargetObject)
/***********************************************************************/
{
LPOBJECT lpObject, lpBase;
int retc;
BOOL fDiscardUndo = NO;
BOOL fUndoFailed;
BOOL fMaskEdit;

lpBase = ImgGetBase(lpImage);

lpObject = NULL;
while (lpObject = ImgGetNextObject(lpImage, lpObject, YES, NO))
	lpObject->InitUndoType = 0;

// No mask undo's are allowed - so apply any that we have now
if (!Control.UndoMasks)
	ObjEditApply(lpImage, lpBase, NO, YES, NO);

// No undo's are allowed - so apply any that we have now
if (Control.NoUndo)
	{
	lpObject = NULL;
	while (lpObject = ImgGetNextObject(lpImage, lpObject, YES, NO))
		ObjEditApply(lpImage, lpObject, YES, lpObject != lpBase, NO);
	}

if (!Control.MultipleObjects)
	UndoType &= ~UT_DELETEOBJECTS;

fMaskEdit = (Target == ET_OBJECT) && (lpTargetObject == lpBase) &&
			((UndoType & UT_ALPHAUNDO) != 0);

// see if any objects cannot have their undos freed without
// asking the user first, if so ask the user and get the response
// This is only a manual apply thing
if (UndoType & (UT_NEWDATA|UT_NEWALPHA) && Control.UseApply)
	{
	lpObject = NULL;
	fDiscardUndo = YES;
	while (lpObject = ImgGetNextObject(lpImage, lpObject, YES, NO))
		{
		// see if this is an object we are not editing
		if ((Target == ET_SELOBJECTS &&
			!ImgIsSelectedObject(lpImage, lpObject)) ||
			(Target == ET_OBJECT && lpObject != lpTargetObject))
			continue;
		if (!ObjEditUndoDiscardable(lpObject, (UndoType & UT_NEWDATA) != 0,
											(UndoType & UT_NEWALPHA) != 0))
			{
			retc = AstralConfirm( IDS_OKTOAPPLY );
			if (retc == IDCANCEL)
				return(FALSE);
			fDiscardUndo = retc == IDYES;
			break;
			}
		}
	}

// now loop through the objects initializing their undos
lpObject = NULL;
while (lpObject = ImgGetNextObject(lpImage, lpObject, YES, NO))
	{
	// see if this is an object we are not editing
	if ((Target == ET_SELOBJECTS && !ImgIsSelectedObject(lpImage, lpObject)) ||
		(Target == ET_OBJECT && lpObject != lpTargetObject))
		{
		// if no individual undo's, wack any undo buffers
		// if in auto apply or in manual apply and state is redo
		// Objects that are not the base need to also have
		// their alphas wacked if this is not a mask edit 
		if (!Control.UndoObjects && (!Control.UseApply ||
				( Control.UseApply && !lpObject->DataUndoNotRedo ) ) )
			ObjEditApply(lpImage, lpObject, !fMaskEdit,
 				(lpObject != lpBase) && !fMaskEdit, NO);
		continue;
		}

	// Discard it's undo if possible
	if (fDiscardUndo)
		ObjEditFreeUndo(lpObject, (UndoType & UT_NEWDATA) != 0,
						(UndoType & UT_NEWALPHA) != 0);

	// save state of undo failed flag
	fUndoFailed = lpObject->fUndoFailed;

	// Initialize the undo for this object
	if (!ObjEditInit(lpImage, lpObject, UndoType))
		{
		// Undo initialization failed, so apply all objects that
		// were going to be initialized
		lpObject = NULL;
		while (lpObject = ImgGetNextObject(lpImage, lpObject, YES, NO))
			{
			// see if this is an object we are not editing
			if ((Target == ET_SELOBJECTS &&
				!ImgIsSelectedObject(lpImage, lpObject)) ||
				(Target == ET_OBJECT && lpObject != lpTargetObject))
				{
				continue;
				}
			lpObject->fUndoFailed = YES;
			lpObject->InitUndoType = 0;
			if (lpObject == lpBase)
				ObjEditApply(lpImage, lpObject,
							(UndoType & UT_DATAUNDO) != 0,
							(UndoType & UT_ALPHAUNDO) != 0, NO);
			else
				ObjEditApply(lpImage, lpObject, YES, YES, NO);
			}
		// if we have failed before
		if (fUndoFailed)
			return(TRUE);
		else
			{
			Message(IDS_NOUNDO);
			return(FALSE);
			}
		}
	lpObject->fUndoFailed = NO;
	lpObject->InitUndoType = UndoType;
	}
return( TRUE );
}