示例#1
0
BOOL CImage::IfSelObjectsGrouped()
{
LPOBJECT lpObject;
WORD wGroupID;

lpObject = GetSelObject(NULL);
wGroupID = lpObject->wGroupID;
while (lpObject = GetSelObject(lpObject))
    {
    if (lpObject->wGroupID != wGroupID)
        return(FALSE);
    }
return(wGroupID != 0);
}
示例#2
0
LPOBJECT CImage::FindSelObject(int x, int y, BOOL fBottomUp)
{
	POINT pt;
	LPOBJECT lpObject = NULL;
	LPOBJECT lpBase;

	pt.x = x;
	pt.y = y;
	lpBase = GetBase();
	while (lpObject = GetSelObject(lpObject, fBottomUp))
   	{
    	if (AstralPtInRect(&lpObject->rObject, pt))
       	{
        	if (lpObject == lpBase)
            	return(lpObject);
        	if (!lpObject->lpAlpha)
            	return(lpObject);
        	if (IsMasked(lpObject->lpAlpha,
                    	x-lpObject->rObject.left,
                    	y-lpObject->rObject.top))
            	return(lpObject);
       	}
   	}
	return(NULL);
}
示例#3
0
int CImage::CountSelObjects(LPOBJECT lpObject)
{			  
	int nCount = 0;

    while (lpObject = GetSelObject(lpObject))
        ++nCount;
	return(nCount);
}
示例#4
0
BOOL CImage::DuplicateSelObjects()
{
LPOBJECT lpDupObject;
OBJECTLIST DupList;
LPOBJECT lpObject;
RECT rUpdate;
WORD wGroupID, wOldGroupID, wLastGroupID;

if (!ImgEditInit( this, ET_OBJECT, UT_DELETEOBJECTS, GetBase() ))
    return(FALSE);

DupList.lpHead = DupList.lpTail = NULL;
lpObject = NULL;
while (lpObject = GetSelObject(lpObject))
    {
    if (!(lpDupObject = ObjDuplicateObject(lpObject)))
        {
        ObjDeleteObjects(&DupList, ST_ALL);
        return(FALSE);
        }
    ObjAddTail(&DupList, (LPPRIMOBJECT)lpDupObject);
    }
wLastGroupID = wGroupID = GetNextGroupID();
lpDupObject = NULL;
while (lpDupObject = (LPOBJECT)ObjGetNextObject(&DupList,
                    (LPPRIMOBJECT)lpDupObject, YES))
    {
    if (!lpDupObject->wGroupID || lpDupObject->wGroupID >= wLastGroupID)
        continue;
    wOldGroupID = lpDupObject->wGroupID;
    lpDupObject->wGroupID = wGroupID;
    lpObject = lpDupObject;
    while (lpObject = (LPOBJECT)ObjGetNextObject(&DupList,
                    (LPPRIMOBJECT)lpObject, YES))
        {
        if (lpObject->wGroupID == wOldGroupID)
            lpObject->wGroupID = wGroupID;
        }
    ++wGroupID;
    }

RemoveObjectMarquee(this);
ObjDeselectAll(&ObjList);
while (lpObject = (LPOBJECT)ObjGetNextObject(&DupList, NULL, YES))
    {
    ObjUnlinkObject(&DupList, (LPPRIMOBJECT)lpObject);
    ObjSelectObject( (LPPRIMOBJECT)lpObject, YES ); // Select the new object
    ObjAddTail( &ObjList, (LPPRIMOBJECT)lpObject ); // Add to the image's list
    lpObject->fUndoDeleted = YES;
    }
ImgEditedObject(this, GetBase(), IDS_UNDODUPLICATE, NULL);

GetSelObjectRect(&rUpdate, NO);
UpdateImage(this, &rUpdate, YES);
SetupMiniViews(NULL, NO);
return(TRUE);
}
示例#5
0
BOOL CImage::IsSelectedObject(LPOBJECT lpObject)
{
	LPOBJECT lpNext = NULL;

	while (lpNext = GetSelObject(lpNext))
   	{
    	if (lpNext == lpObject)
        	return(TRUE);
   	}
	return(FALSE);
}
示例#6
0
void CImage::GetGroupRect(LPOBJECT lpObject, LPRECT lpRect)
{
	LPOBJECT	lpNextObject;

	AstralSetRectEmpty( lpRect );

	lpNextObject = GetBase();
	while( lpNextObject = GetSelObject( lpNextObject ) )
	{
		if( lpObject->wGroupID == lpNextObject->wGroupID )
    	   	AstralUnionRect( lpRect, lpRect, &lpNextObject->rObject );
	}
}
示例#7
0
LPOBJECT CImage::GetObjectMarqueeObject()
{
LPOBJECT lpObject = NULL;

if (!UseObjectMarquee)
    return(NULL);

if ((Control.UseMaskAndObjects || !GetMask()) &&
    MultipleObjects())
    {
    lpObject = GetSelObject(NULL);
    }
return(lpObject);
}
示例#8
0
void CImage::GroupSelObjects(BOOL fGroup)
{
WORD wGroupID;
LPOBJECT lpObject = NULL;

if (fGroup)
    wGroupID = GetNextGroupID();
while (lpObject = GetSelObject(lpObject))
    {
    if (fGroup)
        lpObject->wGroupID = wGroupID;
    else
        lpObject->wGroupID = 0;
    }
}
示例#9
0
BOOL CImage::GetSelObjectRect( LPRECT lpRect, BOOL bExcludeBase )
{
	LPOBJECT lpObject;
	BOOL bFoundOne;

	AstralSetRectEmpty( lpRect );

	bFoundOne = NO;
	lpObject = ( bExcludeBase ? GetBase() : NULL );
	while ( lpObject = GetSelObject(lpObject) )
   	{
    	AstralUnionRect( lpRect, lpRect, &lpObject->rObject );
    	bFoundOne = YES;
   	}

	return( bFoundOne );
}
示例#10
0
BOOL CImage::EditRecoverSelObj( BOOL fEditUndo, BOOL fMaskUndo)
{
	LPOBJECT lpObject;

	// if manual apply we can't do anything to recover
	if (Control.UseApply)
		return(FALSE);

	lpObject = NULL;
	while ( lpObject = GetSelObject(lpObject) )
	{
		if (fEditUndo)
			lpObject->DataDirty = TRUE;
		if (fMaskUndo)
			lpObject->AlphaDirty = TRUE;
		ObjEditUndo(lpObject, fEditUndo, fMaskUndo);
		ObjEditApply(lpObject, fEditUndo, fMaskUndo, FALSE);
	}
	return( TRUE );
}
示例#11
0
void CImage::EditUndo( BOOL fEditUndo, BOOL fMaskUndo,
					LPUPDATE_TYPE lpUpdateType, LPRECT lpUpdateRect)
{
RECT rUndo, rUndoMask, rTemp;
LPOBJECT lpBase, lpObject, lpNext;
BOOL fNewSize, fSetupMiniViews, fRemoveMarquee, fUndoDelete, fColorMapChanged;
BOOL fUndoAlpha, fUndoData;
int nDeleted;
LPMASK lpMask;
EDIT_TARGET Target;

AstralSetRectEmpty(lpUpdateRect);

// Initialize things for updating the display
fNewSize = fSetupMiniViews = fUndoDelete = fColorMapChanged = NO;
AstralSetRectEmpty(&rUndo);
AstralSetRectEmpty(&rUndoMask);

// loop through objects doing undo
lpBase = GetBase();
lpObject = NULL;
// get the target of the last edit
Target = EditTarget;
while (lpObject = GetNextObject(lpObject, NO, NO, fEditUndo))
	{
	// See if this is an object we are undoing
	if (fEditUndo)
		{
		// check for special undo processing of a deleted object
		if (lpObject->fDeleted) 
			continue; // do no undo processing for a deleted object
//			{
//			if (Control.UndoObjects && !IsSelectedObject(lpBase))
//				continue;
//			}
		else
		// if target is not the entire image and we are in undo
		// object mode and the object is not selected then
		// skip this object
		if (Target != ET_ALLOBJECTS && Control.UndoObjects && !IsSelectedObject(lpObject))
			continue;
		}
	// Only handle mask undo for the base object
	if (fMaskUndo)
		{
		if (lpObject != lpBase || lpObject->fBothDirty ||
			!lpObject->AlphaDirty)
		continue;
		}

	fUndoData = fUndoAlpha = NO;

	// Do preprocess for doing a data undo
	if (fEditUndo)
		{
		if (lpObject->DataDirty)
			fUndoData = YES;
		// See if we need to undo the alpha for this object
		if ((lpObject != lpBase) && lpObject->lpAlpha && lpObject->AlphaDirty)
			fUndoAlpha = YES;
		if (!fUndoData && !fUndoAlpha)
			continue;
	
		// check to see and undoing/redoing deleted objects will change
		// the select state, if so undraw the object marquee
		if (lpObject == lpBase &&
			lpObject->DataUndoType & UT_DELETEOBJECTS)
			{
			fUndoDelete = YES;
			fRemoveMarquee = NO;
			nDeleted = 0;
			lpNext = lpObject;
			while (lpNext = GetNextObject(lpNext, YES, NO, YES))
				{
				if (lpNext->fUndoDeleted)
					++nDeleted;
				else
				if (lpNext->fDeleted && lpNext->fSelected)
					{
					fRemoveMarquee = YES;
					break;
					}
				}
			if (GetSelObject(NULL) == lpBase && !fRemoveMarquee)
				{
				if (CountObjects() - nDeleted <= 1)
					fRemoveMarquee = YES;
				}
			if (fRemoveMarquee)
				{
				GetObjectMarqueeRect(this, &rTemp);
				AstralUnionRect(lpUpdateRect, lpUpdateRect, &rTemp);
				}
			}
		}
	else // fMaskUndo
	if (!lpObject->AlphaDirty)
		continue;
	else
		fUndoAlpha = YES;

	// do a preprocess for undoing the mask caused either by
	// a mask undo or by an edit function that also edits the mask
	if (((lpObject == lpBase) && fEditUndo && lpObject->fBothDirty) ||
		fMaskUndo)
		{
		if ( lpObject->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) )
			{
			// if the undo is going to delete the mask,
			// we need to undraw the mask
			if (GetMask())
				{
				GetMaskMarqueeRect(this, &rTemp);
				AstralUnionRect(lpUpdateRect, lpUpdateRect, &rTemp);
				if (GetMaskUpdateRect(YES, NO, &rTemp))
					AstralUnionRect(&rUndoMask, &rUndoMask, &rTemp);
				}
			// if the undo is going to create the mask,
			// we need to undraw the object marquees if
			// not in mask and object marquee mode
			else
				{
				if (!Control.UseMaskAndObjects)
					{
					GetObjectMarqueeRect(this, &rTemp);
					AstralUnionRect(lpUpdateRect, lpUpdateRect, &rTemp);
					}
				}
			}
		}

	// Actually do the undo
	ObjEditUndo(lpObject, fUndoData, fUndoAlpha);

	// do a postprocess for undoing the mask
	if ((lpMask = GetMask()) &&
		(((lpObject == lpBase) && fEditUndo && lpObject->fBothDirty) ||
		fMaskUndo))
		{
		// if the undo is going to add the mask, we need to redraw the mask
		if (lpObject->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) )
			{
			if (GetMaskUpdateRect(YES, NO, &rTemp))
				AstralUnionRect(&rUndoMask, &rUndoMask, &rTemp);
			}
		else
			// just redraw the undo area for the mask
			AstralUnionRect(&rUndoMask, &rUndoMask, &lpMask->Pixmap.UndoRect);
		}

	// Setup rectangle for undoing deletion of objects
	// Handled specially so that moved objects will still undo
	// and redo properly
	if (fEditUndo)
		{
		if (lpObject == lpBase &&
			lpObject->DataUndoType & UT_DELETEOBJECTS)
			{
			lpNext = lpObject;
			while (lpNext = GetNextObject(lpNext, YES, NO, YES))
				{
				if (lpNext->fDeleted || lpNext->fUndoDeleted)
					AstralUnionRect(&rUndo, &rUndo, &lpNext->rObject);
				}
			fSetupMiniViews = YES;
			}
		if (lpObject->DataUndoType & UT_COLORMAP)
			fColorMapChanged = YES;

		if (lpObject->Pixmap.fNewFrame)
			{
			/* if new frame, cause window to be redisplayed */
			if (lpObject == lpBase)
				fNewSize = YES;
			else
				{
				if (!fNewSize)
					{
					AstralUnionRect(&rUndo, &rUndo, &lpObject->rObject);
					AstralUnionRect(&rUndo, &rUndo, &lpObject->rUndoObject);
					}
				}
			}
		else
			{
			AstralSetRectEmpty(&rTemp);
			if (fUndoData)
				AstralUnionRect(&rTemp, &rTemp, &lpObject->Pixmap.UndoRect);
			if (fUndoAlpha)
				AstralUnionRect(&rTemp, &rTemp,
						&lpObject->lpAlpha->Pixmap.UndoRect);
			if (rTemp.right >= rTemp.left)
				{
				if (!fNewSize)
					{
					OffsetRect(&rTemp, lpObject->rObject.left,
							lpObject->rObject.top);
					AstralUnionRect(&rUndo, &rUndo, &rTemp);
					}
				}
			if( lpObject->DataUndoType & UT_OBJECTRECT )
				{
				AstralUnionRect( &rUndo, &rUndo,	&lpObject->rObject );
				AstralUnionRect( &rUndo, &rUndo,	&lpObject->rUndoObject );
				}
			}
		}
	}

// now redisplay whatever changes are necessary for the undo
if (fColorMapChanged)
	{
	ImgColorMapChanged(this);
	*lpUpdateType |= UT_DATATYPE;
	}

if (fNewSize)
	{
	*lpUpdateType |= UT_DATATYPE;
	if (lpBase->Pixmap.UndoFrame)
		{
		if ((FrameXSize(lpBase->Pixmap.UndoFrame) ==
			FrameXSize(lpBase->Pixmap.EditFrame)) &&
			(FrameYSize(lpBase->Pixmap.UndoFrame) ==
			FrameYSize(lpBase->Pixmap.EditFrame)))
			fNewSize = NO;
		}
	if (fNewSize)
		*lpUpdateType |= UT_SIZE;
	else
		{
		int dx, dy;

		GetInfo(&dx, &dy, NULL, NULL);
		SetRect(lpUpdateRect, 0, 0, dx-1, dy-1);
		}
	}
else
	{
	if (!AstralIsRectEmpty(lpUpdateRect))
		*lpUpdateType |= UT_ACTIVEAREA;
	if (rUndoMask.right >= rUndoMask.left)
		{
		*lpUpdateType |= UT_ACTIVEAREA;
		AstralUnionRect(lpUpdateRect, lpUpdateRect, &rUndoMask);
		}
	if (rUndo.right >= rUndo.left)
		{
		*lpUpdateType |= UT_AREA;
		AstralUnionRect(lpUpdateRect, lpUpdateRect, &rUndo);
		}
	}
}
示例#12
0
BOOL CImage::CombineSelObjects(BOOL fNoUndo, BOOL fCreateMask,
                        BOOL fForceIt, ITEMID idDirty, LPRECT lpUpdateRect)
{
LPOBJECT lpBase, lpObject;
int      iWidth, iHeight, depth, y, iImageWidth, iImageHeight, oWidth;
LPTR     lpDataBuf, lpMaskPtr;
RECT     rSelected, rMask, rTemp;
BOOL     fNewMask;
LPMASK   lpMask;
UNDO_TYPE UndoType;

AstralSetRectEmpty(lpUpdateRect);

// get rectangle for all floating objects
if (!GetSelObjectRect(&rSelected, YES))
    return(FALSE);

// Get base object
lpBase = lpObject = GetBase();

// get pixmap information
PixmapGetInfo(&lpBase->Pixmap, PMT_EDIT, &iImageWidth, &iImageHeight, &depth, NULL);
BoundRect(&rSelected, 0, 0, iImageWidth-1, iImageHeight-1);

iWidth = RectWidth(&rSelected);
iHeight = RectHeight(&rSelected);

// allocate buffer for alpha channel combining
if (!(lpDataBuf = Alloc((long)iWidth*depth)))
    {
    Message(IDS_EMEMALLOC);
    return(FALSE);
    }

lpMask = NULL;
if (fCreateMask)
    {
    lpMask = GetMaskEx(OFF, Control.NoUndo, &fNewMask, &rTemp);
    AstralUnionRect(lpUpdateRect, lpUpdateRect, &rTemp);
    }


// do it to it
ProgressBegin(lpMask != NULL ? 2 : 1, idDirty-IDS_UNDOFIRST+IDS_PROGFIRST);

if (!fNoUndo)
    {
    UndoType = UT_DATA|UT_DELETEOBJECTS;
    if (lpMask)
        {
        if (fNewMask)
            UndoType |= UT_CREATEMASK;
        else
            UndoType |= UT_ALPHA;
        }
    if (!ImgEditInit(this, ET_OBJECT, UndoType, lpBase))
        {
        if (!fForceIt)
            {
            ProgressEnd();
            FreeUp(lpDataBuf);
            return(FALSE);
            }
        }
    }

// do it to it
ProgressBegin(1, 0);
while( lpObject = GetSelObject( lpObject ) )
	{
   rTemp = lpObject->rObject;
   BoundRect(&rTemp, 0, 0, iImageWidth-1, iImageHeight-1);
	oWidth = RectWidth( &rTemp );
	for (y = rTemp.top; y <= rTemp.bottom; ++y)
    	{
    	AstralClockCursor(y-rTemp.top, rTemp.bottom, NO);
      	ImgGetLine(this, NULL, rTemp.left, y, oWidth,
                lpDataBuf, NULL, TRUE);
    	PixmapWrite(&lpBase->Pixmap, PMT_EDIT, rTemp.left, y,
			oWidth, lpDataBuf, oWidth);
    	ImgEditedObject(this, lpObject, idDirty, &rTemp);
    	}
	}
ProgressEnd();

lpObject = lpBase;

if (lpMask && (lpObject = GetSelObject(lpObject)))
    {
    ProgressBegin(1, 0);
    for (y = rSelected.top; y <= rSelected.bottom; ++y)
        {
        AstralClockCursor(y-rSelected.top, iHeight, NO);
        lpMaskPtr = PixmapPtr(&lpMask->Pixmap, PMT_EDIT, rSelected.left,
                            y, YES);
        if (!lpMaskPtr)
            continue;
        ImgMaskLoad(this, lpObject, NULL,
                rSelected.left, y, iWidth, lpDataBuf, YES,
                CR_OR, 0, 0);
        CombineData(lpDataBuf, lpMaskPtr, iWidth, NO, CR_OR);
        }
    MaskRectUpdate(lpMask, &rMask); 
    ProgressEnd();
    }

FreeUp(lpDataBuf);

GetObjectMarqueeRect(this, &rTemp);
AstralUnionRect(lpUpdateRect, lpUpdateRect, &rTemp);
lpObject = lpBase;
while (lpObject = GetSelObject(lpObject))
    {
// always let undo stuff initialize this
//  lpObject->fUndoDeleted = NO;
    lpObject->fDeleted = YES;
    }
//DeleteObjects((LPOBJECT)lpBase->lpNext, NO);

if (!fNoUndo)
    ImgEditedObject(this, lpBase, idDirty, &rSelected);
else
    fChanged = YES;

//if ( Tool.hRibbon )
//  SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
ProgressEnd();
//SetupMiniViews(NULL, NO);
return(TRUE);
}