Beispiel #1
0
BOOL ImgEditRecover( LPIMAGE lpImage )
/***********************************************************************/
{
LPOBJECT lpObject;

lpObject = NULL;
while ( lpObject = ImgGetSelObject(lpImage, lpObject) )
	{
	}

return( TRUE );
}
Beispiel #2
0
BOOL PosObjects( LPIMAGE lpImage, LPPOSOBJECTS_PARMS lpPosParms )
/************************************************************************/
{
RECT		bRect, uRect;
LPOBJECT	lpObject;
int      res;
int      x,y;

if( !( lpImage ) )
	return( FALSE );

if( !( lpObject = ImgGetBase( lpImage ) )	)
   return( FALSE );

ImgEditInit( lpImage, ET_SELOBJECTS, UT_OBJECTRECT, lpObject );

ImgGetInfoEx(lpImage, NULL, NULL, NULL, NULL, &res);
x = lpPosParms->XOffset;
y = lpPosParms->YOffset;
ResConvertUL(lpPosParms->iBaseRes, res, &x, &y);

ImgGetSelObjectRect( lpImage, &bRect, YES );
x -= bRect.left;
y -= bRect.top;

while ( lpObject = ImgGetSelObject(lpImage, lpObject) )
   {
	if( lpObject->wGroupID )
		{
		if( !( IsGroupLocked( lpObject->wGroupID ) ) )
			{
  			ImgEditedObject( lpImage, lpObject, IDS_UNDOOBJPOS, NULL );
			OffsetRect( &lpObject->rObject, x, y);
			}
		}
	else if (!lpObject->bLocked)
		{
  		ImgEditedObject( lpImage, lpObject, IDS_UNDOOBJPOS, NULL );
		OffsetRect( &lpObject->rObject, x, y);
		}

   }
ImgGetSelObjectRect( lpImage, &uRect, YES );
AstralUnionRect( &uRect, &uRect, &bRect );
UpdateImage( lpImage, &uRect, YES );
return( TRUE );
}
Beispiel #3
0
void DoReset(HWND hDlg, LPALIGNOBJECTS_PARMS lpAlignParms)
{
RECT		               uRect;
LPIMAGE                 lpImage = GetActiveImage();
LPRECT						pRect;
LPOBJECT						lpObject;

if(!lpImage)
   return;

HWND                    hWnd = GetDlgItem(hDlg, IDC_ALIGN_GRID);
int                     x,y,i, wind;
RECT		               cRect;
for( i = 0, wind = GW_CHILD; i < ALIGN_NUM_OBJECTS; i++, wind = GW_HWNDNEXT )
   {
	hWnd = GetWindow( hWnd, wind );
	GetClientRect( hWnd, &cRect );
	cRect.right -= 1;
	cRect.bottom -= 1;
	ShowWindow( hWnd, SW_HIDE );
   x = InitPos[i].x - cRect.left;
   y = InitPos[i].y - cRect.top;
	OffsetRect( &cRect, x, y);
	MoveWindow( hWnd, cRect.left, cRect.top, RectWidth( &cRect ),
		RectHeight( &cRect ), TRUE );
	UpdateWindow( GetDlgItem( hDlg, IDC_ALIGN_GRID ) );
	ShowWindow( hWnd, SW_SHOWNA );
   }

lpAlignParms->HorzAlign = HA_NONE;
lpAlignParms->VertAlign = VA_NONE;
if( lpAlignParms->bPreview )
	{
	pRect = lpAlignParms->lpRect;
	if( !( lpObject = ImgGetBase(lpImage)))
		return;
	while ( lpObject = ImgGetSelObject( lpImage, lpObject) )
      {
      AstralUnionRect(&uRect, &uRect, &lpObject->rObject);
		lpObject->rObject = *pRect++;
      }
	AlignObjects( GetActiveImage(), lpAlignParms );
	}
EnableWindow( GetDlgItem( hDlg, IDC_PREVIEW ), TRUE );
lpAlignParms->bPreview  = FALSE;
UpdateImage(lpImage, &uRect, YES);
}
Beispiel #4
0
BOOL IsGroupLocked( WORD wGroupID )
/************************************************************************/
{
LPOBJECT	lpObject;
LPIMAGE	lpImage;

lpImage = GetActiveImage();
lpObject = ImgGetBase( lpImage );

while( lpObject = ImgGetSelObject( lpImage, lpObject ) )
	{
	if( lpObject->wGroupID == wGroupID && lpObject->bLocked )
		return( TRUE );
	}
return( FALSE );

}
Beispiel #5
0
BOOL UnGroupObjects(LPIMAGE lpImage, LPCMD_PARMS lpCmdParms)
   {
   LPOBJECT lpObject = NULL;

   if( !( lpImage ) )
	   return( FALSE );

   if( !( lpObject = ImgGetBase( lpImage ) )	)
      return( FALSE );

   ImgEditInit(lpImage, ET_SELOBJECTS, UT_GROUPOBJECTS, lpObject );
   while (lpObject = ImgGetSelObject(lpImage, lpObject))
      {
	   ImgEditedObject( lpImage, lpObject, IDS_UNDOUNGROUPOBJ, NULL );
      lpObject->wGroupID = 0;
      }
   return(TRUE);
   }
Beispiel #6
0
BOOL UnLockObjects( LPIMAGE lpImage, LPCMD_PARMS lpCmdParms )
/************************************************************************/
{
LPOBJECT	lpObject;

if( !( lpImage ) )
	return( FALSE );

if( !( lpObject = ImgGetBase( lpImage ) )	)
   return( FALSE );

ImgEditInit( lpImage, ET_SELOBJECTS, UT_LOCKOBJECTS, lpObject );

while ( lpObject = ImgGetSelObject(lpImage, lpObject) )
   {
	ImgEditedObject( lpImage, lpObject, IDS_UNDOOBJUNLOCK, NULL );
	lpObject->bLocked = NO;
	}
return( TRUE );
}
Beispiel #7
0
BOOL CombineObjObjects( LPIMAGE lpImage, LPCMD_PARMS lpCmdParms )
/************************************************************************/
{
RECT		rCombine,r;
LPOBJECT	lpBase, lpObj;
LPALPHA	lpAlpha, lpMask;
LPFRAME	lpDFrame, lpSFrame;
LPTR		lpDF, lpDM, *lpSM, *lpSF;
int		x, y, yy, depth;
int      N, H, W, i;
double  *lpAlphaTable, *AiXOi;
double   red,blue,green,k;
POINT    pt;
double   Oi, Ai, Mi, Mc;
LPOBJECT *lpObject;
FRMTYPEINFO TypeInfo;
BOOL	fCanDoOpacity;
FRMDATATYPE MaskType = FDT_GRAYSCALE;

if (!(lpImage))
	return( FALSE );

ImgGetTypeInfo(lpImage, &TypeInfo);
if (TypeInfo.DataType == FDT_LINEART && Mask.OneBitMask)
   MaskType = FDT_LINEART;
fCanDoOpacity = CANDOTRANSPARENCY(TypeInfo.DataType);

lpObj = lpBase = ImgGetBase(lpImage);
if (!(depth = FrameDepth(ObjGetEditFrame(lpBase))))
   depth = 1; // never worry about lineart
N = ImgCountSelObjects(lpImage, NULL);
ImgGetSelObjectRect(lpImage, &rCombine, YES);
H = RectHeight(&rCombine);
W = RectWidth (&rCombine);

lpObject = NULL;
AiXOi = lpAlphaTable = NULL;

lpAlphaTable = (double *)Alloc((N+1) * sizeof(double));
AiXOi        = (double *)Alloc(N * sizeof(double));
lpSM         = (LPTR *)Alloc(N * sizeof(LPTR));
lpSF         = (LPTR *)Alloc(N * sizeof(LPTR));
lpObject     = (LPOBJECT *)Alloc(N * sizeof(LPOBJECT));
lpAlpha = MaskCreate(NULL, W, H, YES, Control.NoUndo, MaskType);
lpDFrame = ImgGetBaseEditFrame(lpImage);
lpDFrame = FrameOpen(FrameType(lpDFrame), W, H, FrameResolution(lpDFrame));

if (!lpAlphaTable || !lpObject || !AiXOi || !lpAlpha || !lpDFrame || !lpSM || !lpSF)
    {
    if (lpAlphaTable)
      FreeUp(lpAlphaTable);
    if (lpObject)
      FreeUp(lpObject);
    if (AiXOi)
      FreeUp(AiXOi);
    if (lpDFrame)
      FreeUp(lpDFrame);
    if (lpSF)
      FreeUp(lpSF);
    if (lpSM)
      FreeUp(lpSM);
      
    Message(IDS_EMEMALLOC);
    return(FALSE);
    }

for (i=0; i < N; i++)
   lpObj = lpObject[i] = ImgGetSelObject(lpImage, lpObj);

ImgEditInit(lpImage, ET_OBJECT, UT_DELETEOBJECTS, lpBase);

ProgressBegin(1, PROGRESS_ID(IDS_UNDOOBJCOMBOBJS));
for (y = 0; y <= H; y++)
   {
 	AstralClockCursor(y, H, NO);

   lpDF = FramePointer(lpDFrame, 0, y, YES);
   lpDM = PixmapPtr(&lpAlpha->Pixmap, PMT_EDIT, 0, y, YES);
   pt.y = y + rCombine.top;

   for (i=0; i < N; i++)
      {
      yy = pt.y - lpObject[i]->rObject.top;
      lpSFrame = ObjGetEditFrame(lpObject[i]);
      lpSF[i] = FramePointer(lpSFrame, 0, yy, NO);
      lpMask   = ObjGetAlpha(lpObject[i]);
      lpSM[i] = PixmapPtr(&lpMask->Pixmap, PMT_EDIT, 0, yy, NO);
      }
   
	for (x = 0; x < W; x++)
      {
      lpAlphaTable[N] = 1.0;
      pt.x = x + rCombine.left;

      for (i=N-1; i >= 0; i--)
         {
         r = lpObject[i]->rObject;
         r.bottom++;
         r.right++;
         if (PtInRect(&r, pt))
            {
			   if (fCanDoOpacity)
	           	Oi = lpObject[i]->Opacity / 255.0;
            else
					Oi = 1;
			   if (fCanDoOpacity)
	            Ai = *lpSM[i]++ / 255.0;
			   else if (*lpSM[i] < 128)
               {
               Ai = 0;
				   lpSM[i]++;
               }
			   else
			      {
				   Ai = 1;
				   lpSM[i]++;
			      }
            AiXOi[i] = Oi * Ai;
            lpAlphaTable[i] = lpAlphaTable[i+1] * (1.0 - AiXOi[i]);
            }
         else
            {
            AiXOi[i] = 1.0;
            lpAlphaTable[i] = lpAlphaTable[i+1];
            }
         }
      Mc = 1.0 - lpAlphaTable[0];
      lpDM[x] = (BYTE)(Mc * 255);

      red = blue = green = k = 0;
      for (i=0; i < N; i++)
         {
         r = lpObject[i]->rObject;
         r.bottom++;
         r.right++;
         if (PtInRect(&r, pt))
            {
            Mi = AiXOi[i] * lpAlphaTable[i+1];
            switch(depth)
               {
               case 1:
                  red     += *lpSF[i]++ * Mi;
                  break;
               case 3:
                  red     += *lpSF[i]++ * Mi;
                  green   += *lpSF[i]++ * Mi;
                  blue    += *lpSF[i]++ * Mi;
                  break;
               case 4:
                  red     += *lpSF[i]++ * Mi;
                  green   += *lpSF[i]++ * Mi;
                  blue    += *lpSF[i]++ * Mi;
                  k       += *lpSF[i]++ * Mi;
                  break;
               }
            }
         }

      if (Mc == 0.0)
         Mc = 1.0;
      switch(depth)
         {
         case 1:
            *lpDF++ = (BYTE)(red / Mc);
            break;
         case 3:
            *lpDF++ = (BYTE)(red   / Mc);
            *lpDF++ = (BYTE)(green / Mc);
            *lpDF++ = (BYTE)(blue  / Mc);
            break;
         case 4:
            *lpDF++ = (BYTE)(red   / Mc);
            *lpDF++ = (BYTE)(green / Mc);
            *lpDF++ = (BYTE)(blue  / Mc);
            *lpDF++ = (BYTE)(k     / Mc); 
            break;
         }
      }
   }

lpObj = ObjCreateFromFrame(ST_PERMANENT, lpDFrame, lpAlpha, &rCombine,
	Control.NoUndo );
lpObj->fSelected = YES;
lpObj->fUndoDeleted = YES;
ImgAddNewObject(lpImage, lpObj);
for (i=0; i < N; i++)
   lpObject[i]->fDeleted = YES;
ImgEditedObject(lpImage, lpBase, IDS_UNDOOBJCOMBOBJS, NULL);
UpdateImage(lpImage, &rCombine, YES);

FreeUp(lpSM);
FreeUp(lpSF);
FreeUp(AiXOi);
FreeUp(lpAlphaTable);
FreeUp(lpObject);
ProgressEnd();
return( TRUE );
}
Beispiel #8
0
LOCAL BOOL Align_OnInitDialog(HWND hDlg, HWND hWndFocus, LPARAM lParam)
/************************************************************************/
{
int                  i, nCount;
LPRECT					pRect;
LPOBJECT					lpObject;
LPIMAGE					lpImage;
HWND  					hWnd, hWndChild;
RECT					   gRect;
LPALIGNOBJECTS_PARMS	lpAlignParms;
int                  arObjects[] = { IDC_ALIGN_SQUARE, IDC_ALIGN_TRIANGLE,
                                    IDC_ALIGN_CIRCLE };

lpAlignParms = ( LPALIGNOBJECTS_PARMS )lParam;
lpAlignParms->HorzAlign = HA_NONE;
lpAlignParms->VertAlign = VA_NONE;
lpAlignParms->RectAlign = RA_OBJECT;
lpAlignParms->bPreview  = FALSE;

if( !( lpImage = GetActiveImage() ) )
	return( FALSE );

if( !( ImgGetMask( lpImage ) ) )
	ControlEnable( hDlg, IDC_ALIGN_MASK, NO );
if( !( ImgMultipleObjects( lpImage ) ) )
	ControlEnable( hDlg, IDC_ALIGN_OBJECT, NO );
	
CheckComboItem( hDlg, IDC_ALIGN_COMBO, IDC_ALIGN_IMAGE,	IDC_ALIGN_MASK,
	IDC_ALIGN_IMAGE );

SendDlgItemMessage( hDlg, IDC_ALIGN_COMBO, CB_SETITEMDATA, PARMS_INDEX,
	lParam );

nCount = 0;

if( !( lpObject = ImgGetBase( lpImage ) )	)
	return( FALSE );
while ( lpObject = ImgGetSelObject(lpImage, lpObject) )
	++nCount;
if( !( pRect = lpAlignParms->lpRect = ( LPRECT )Alloc( sizeof( RECT ) * nCount ) ) )
	return( FALSE );
while ( lpObject = ImgGetSelObject(lpImage, lpObject) )
	*(pRect)++ = lpObject->rObject;

hWnd = GetDlgItem( hDlg, IDC_ALIGN_GRID );
GetClientRect( hWnd, &gRect );

for( i = 0; i < ALIGN_NUM_OBJECTS; i++ )
   {
   InitPos[i].x = gRect.left + ( ( gRect.right / ( ALIGN_NUM_OBJECTS + 1 ) ) * ( i + 1 ) ) - 16;
   InitPos[i].y = gRect.top + ( ( gRect.bottom / ( ALIGN_NUM_OBJECTS + 1 ) ) * ( i + 1 ) ) - 16;
   hWndChild = CreateWindowEx( 
       WS_EX_TRANSPARENT, 
       "icon",
	   "", 
       WS_CHILD | WS_VISIBLE | WS_NOSHADOWS | WS_NOTENABLED | WS_NOBGND,
	   InitPos[i].x, 
       InitPos[i].y, 
       32, 
       32,
	   hWnd, 
       ( HMENU )arObjects[i], 
       PictPubApp.GetResourceHandle(),
       NULL );
   ShowWindow( hWndChild, SW_SHOWNORMAL );
   UpdateWindow( hWndChild );
   }

CenterPopup( hDlg );
return(TRUE);
}
Beispiel #9
0
BOOL AlignObjects( LPIMAGE lpImage, LPALIGNOBJECTS_PARMS lpAlignParms )
/************************************************************************/
{
RECT		bRect, gRect, uRect;
LPOBJECT	lpObject, lpGroupObject;
int		xOffset, yOffset, gXOffset, gYOffset, nWidth, nHeight, nCount;
LFIXED	hSpace, vSpace, fx, fy;
WORD		wGroupIDs[NUM_GROUPS];

if( !( lpImage ) )
	return( FALSE );

if( !( lpObject = ImgGetBase( lpImage ) )	)
   return( FALSE );

if( !( lpAlignParms->bPreview ) )
	{
	if( !( ImgEditInit( lpImage, ET_SELOBJECTS, UT_OBJECTRECT, lpObject ) ) )
		return( FALSE );
	}

if( lpAlignParms->RectAlign == RA_IMAGE )
	{	
	ImgGetImageRect( lpImage, &bRect );
	}
else
	{	
	if( lpAlignParms->RectAlign == RA_MASK )
  		ImgGetMaskRect( lpImage, &bRect );
	else
		ImgGetSelObjectRect( lpImage, &bRect, YES );
	}

ImgGetSelObjectRect( lpImage, &uRect, YES );


nWidth = RectWidth( &bRect );
nHeight = RectHeight( &bRect );

nCount = 0;

InitGroupList( wGroupIDs );

while ( lpObject = ImgGetSelObject(lpImage, lpObject) )
   {
	if( lpObject->wGroupID )
		{
		if( !( IsPrevGroup( lpObject->wGroupID, wGroupIDs ) ) &&
			!( IsGroupLocked( lpObject->wGroupID ) ) )
			{
			SetGroupList( lpObject->wGroupID, wGroupIDs );
			lpImage->GetGroupRect( lpObject, &gRect );
			nWidth -= RectWidth( &gRect );
			nHeight -= RectHeight( &gRect );
			++nCount;
			}
		}
	else if (!lpObject->bLocked)
		{
		nWidth -= RectWidth( &lpObject->rObject );
		nHeight -= RectHeight( &lpObject->rObject );
		++nCount;
		}
	}

if( nCount == 0 )
	return( FALSE );

hSpace = FGET( nWidth, nCount - 1 );
vSpace = FGET( nHeight, nCount - 1 );

fx = fy = 0;

InitGroupList( wGroupIDs );

lpObject = ImgGetBase( lpImage );

while ( lpObject = ImgGetSelObject(lpImage, lpObject) )
   {
	if( lpObject->wGroupID )
		{
		if( !( IsPrevGroup( lpObject->wGroupID, wGroupIDs ) ) &&
			!( IsGroupLocked( lpObject->wGroupID ) ) )
			{
			SetGroupList( lpObject->wGroupID, wGroupIDs );
			lpImage->GetGroupRect( lpObject, &gRect );
			ObjAlign( &bRect, &gRect, lpAlignParms, vSpace, hSpace,
				&gXOffset, &gYOffset, &fx, &fy );
			lpGroupObject = ImgGetBase( lpImage );
			while( lpGroupObject = ImgGetSelObject( lpImage, lpGroupObject ) )
				{
				if( lpObject->wGroupID == lpGroupObject->wGroupID )
					{
					if( !( lpAlignParms->bPreview ) )
						ImgEditedObject( lpImage, lpGroupObject, IDS_UNDOOBJALIGN,
							NULL );
					OffsetRect( &lpGroupObject->rObject, gXOffset, gYOffset );
					}
				}
			}
		}
	else if (!lpObject->bLocked)
		{
		ObjAlign( &bRect, &lpObject->rObject, lpAlignParms, vSpace, hSpace,
			&xOffset, &yOffset, &fx, &fy ); 
		if( !( lpAlignParms->bPreview ) )
			ImgEditedObject( lpImage, lpObject, IDS_UNDOOBJALIGN, NULL );
		OffsetRect( &lpObject->rObject, xOffset, yOffset );
		}
   }
ImgGetSelObjectRect( lpImage, &bRect, YES );
AstralUnionRect( &uRect, &uRect, &bRect );
UpdateImage( lpImage, &uRect, YES );
return( TRUE );
}
Beispiel #10
0
LOCAL void Align_OnCommand(HWND hDlg, int id, HWND hControl, UINT codeNotify)
/************************************************************************/
{
LPRECT						pRect;
LPALIGNOBJECTS_PARMS		lpAlignParms;
int                  	nType;
LPOBJECT						lpObject;
LPIMAGE						lpImage;

lpAlignParms = ( LPALIGNOBJECTS_PARMS )SendDlgItemMessage( hDlg,
	IDC_ALIGN_COMBO, CB_GETITEMDATA,	PARMS_INDEX, 0 );
switch (id)
	{
	case IDC_ALIGN_RIGHT:
      if (lpAlignParms->bPreview)
         DoReset(hDlg, lpAlignParms);
		lpAlignParms->HorzAlign = HA_RIGHT;
		AlignIcons( hDlg, lpAlignParms );
	break;

	case IDC_ALIGN_CENTER:
      if (lpAlignParms->bPreview)
         DoReset(hDlg, lpAlignParms);
		lpAlignParms->HorzAlign = HA_CENTER;
		AlignIcons( hDlg, lpAlignParms );
	break;

	case IDC_ALIGN_LEFT:
      if (lpAlignParms->bPreview)
         DoReset(hDlg, lpAlignParms);
		lpAlignParms->HorzAlign = HA_LEFT;
		AlignIcons( hDlg, lpAlignParms );
	break;

	case IDC_ALIGN_HSPACE:
      if (lpAlignParms->bPreview)
         DoReset(hDlg, lpAlignParms);
		lpAlignParms->HorzAlign = HA_EQUAL;
		AlignIcons( hDlg, lpAlignParms );
	break;
	
	
	case IDC_ALIGN_UP:
      if (lpAlignParms->bPreview)
         DoReset(hDlg, lpAlignParms);
		lpAlignParms->VertAlign = VA_TOP;
		AlignIcons( hDlg, lpAlignParms );
	break;

	case IDC_ALIGN_MID:
      if (lpAlignParms->bPreview)
         DoReset(hDlg, lpAlignParms);
		lpAlignParms->VertAlign = VA_MID;
		AlignIcons( hDlg, lpAlignParms );
	break;

	case IDC_ALIGN_DOWN:
      if (lpAlignParms->bPreview)
         DoReset(hDlg, lpAlignParms);
		lpAlignParms->VertAlign = VA_BOTTOM;
		AlignIcons( hDlg, lpAlignParms );
	break;
	
	case IDC_ALIGN_VSPACE:
      if (lpAlignParms->bPreview)
         DoReset(hDlg, lpAlignParms);
		lpAlignParms->VertAlign = VA_EQUAL;
		AlignIcons( hDlg, lpAlignParms );
	break;
	
	case IDC_PREVIEW:
      nType = ( int )SendDlgItemMessage( hDlg, IDC_ALIGN_COMBO,
         CB_GETCURSEL, 0, 0 );
      if( nType == 0 )
         lpAlignParms->RectAlign = RA_IMAGE;
      else if( nType == 1 )
         lpAlignParms->RectAlign = RA_OBJECT;
      else
         lpAlignParms->RectAlign = RA_MASK;
		lpAlignParms->bPreview  = TRUE;
		AlignObjects( GetActiveImage(), lpAlignParms );
		EnableWindow( GetDlgItem( hDlg, IDC_PREVIEW ), FALSE );
	break;
	
	case IDOK:
		ALIGNOBJECTS_PARMS	AlignParms;

		if( lpAlignParms->bPreview )
			{
			AlignParms = *lpAlignParms;
			lpAlignParms->HorzAlign = HA_NONE;
			lpAlignParms->VertAlign = VA_NONE;
			pRect = lpAlignParms->lpRect;
			if( !( lpImage = GetActiveImage() ) )
				break;
			if( !( lpObject = ImgGetBase( lpImage ) ) )
				break;
			while ( lpObject = ImgGetSelObject( lpImage, lpObject) )
				lpObject->rObject = *pRect++;
			AlignObjects( GetActiveImage(), lpAlignParms );
			*lpAlignParms = AlignParms;
			}
      nType = ( int )SendDlgItemMessage( hDlg, IDC_ALIGN_COMBO,
         CB_GETCURSEL, 0, 0 );
      if( nType == 0 )
         lpAlignParms->RectAlign = RA_IMAGE;
      else if( nType == 1 )
         lpAlignParms->RectAlign = RA_OBJECT;
      else
         lpAlignParms->RectAlign = RA_MASK;
		lpAlignParms->bPreview  = FALSE;
		AstralDlgEnd( hDlg, TRUE );
	break;
	
	case IDC_RESET:
      DoReset(hDlg, lpAlignParms);
	break;
	
	case IDCANCEL:
      DoReset(hDlg, lpAlignParms);
		AstralDlgEnd( hDlg, FALSE );
	break;
	
   default:
	break;
   }
}
Beispiel #11
0
void ImgEditUndo( LPIMAGE lpImage, BOOL fEditUndo, BOOL fMaskUndo )
/***********************************************************************/
{
RECT rUndo, rUndoMask, rTemp;
LPOBJECT lpBase, lpObject, lpNext;
BOOL fNewSize, fSetupMiniViews, fRemoveMarquee, fUndoDelete;
BOOL fUndoAlpha, fUndoData;
int nDeleted;
LPMASK lpMask;

if (!lpImage)
	return;

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

// loop through objects doing undo
lpBase = ImgGetBase(lpImage);
lpObject = NULL;
while (lpObject = ImgGetNextObjectEx(lpImage, 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) 
			{
			if (Control.UndoObjects && !ImgIsSelectedObject(lpImage, lpBase))
				continue;
			}
		else
		if (Control.UndoObjects && !ImgIsSelectedObject(lpImage, 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 = ImgGetNextObjectEx(lpImage, lpNext, YES, NO, YES))
				{
				if (lpNext->fUndoDeleted)
					++nDeleted;
				else
				if (lpNext->fDeleted && lpNext->fSelected)
					{
					fRemoveMarquee = YES;
					break;
					}
				}
			if (ImgGetSelObject(lpImage, NULL) == lpBase && !fRemoveMarquee)
				{
				if (ImgCountObjects(lpImage) - nDeleted <= 1)
					fRemoveMarquee = YES;
				}
			if (fRemoveMarquee)
				RemoveObjectMarqueeEx(lpImage, NO);
			}
		}
	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 (ImgGetMask(lpImage))
				{
				RemoveMaskMarquee(lpImage);
				if (ImgGetMaskUpdateRect(lpImage, 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)
 					RemoveObjectMarqueeEx(lpImage, NO);
				}
			}
		}

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

	// do a postprocess for undoing the mask
	if ((lpMask = ImgGetMask(lpImage)) &&
		(((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 (ImgGetMaskUpdateRect(lpImage, 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 = ImgGetNextObjectEx(lpImage, lpNext, YES, NO, YES))
				{
				if (lpNext->fDeleted || lpNext->fUndoDeleted)
					AstralUnionRect(&rUndo, &rUndo, &lpNext->rObject);
				}
			fSetupMiniViews = 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);
					}
				}
			}
		}
	}
// now redisplay whatever changes are necessary for the undo
if (fNewSize)
	{
	SetupImagePalette(lpImage, NO, YES);
	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)
		UpdateImageSize();
	else
		UpdateImageEx(lpImage, NULL, YES, YES, YES);
	if ( Tool.hRibbon )
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
	}
else
	{
	if (rUndoMask.right >= rUndoMask.left)
		{
		File2DispRect(&rUndoMask, &rUndoMask);
		AstralToWindowsRect(&rUndoMask);
		InvalidateRect(lpImage->hWnd, NULL, NO);
		}
	if (rUndo.right >= rUndo.left)
		AnimateUndo( &rUndo );
	}
if (fUndoDelete)
	if ( Tool.hRibbon )
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
	
if (fSetupMiniViews)
	SetupMiniViews(NULL, NO);
}
Beispiel #12
0
long DoCommand( HWND hWindow, WPARAM wParam, LPARAM lParam )
/***********************************************************************/
{
FNAME szFileName;
LPFRAME lpFrame;
LPOBJECT lpObject, lpBase;
RECT rect, rMask, rTemp, rAll;
HWND hWnd;
STRING szString;
int i, idFileType, x, y, dx, dy;
BOOL fDoZoom, bPrint, fHasZoom;
LPSTR lpszCmdLine;
HGLOBAL hMem;
ITEMID idDataType;
DWORD dwReturn;
int NewShape;
UINT wID;

SoundStartID( wParam, NO/*bLoop*/, NULL/*hInstance*/ );
/*
	WIN16:	ID          = wParam
			ctrl handle = LOWORD(lParam)
			notify code = HIWORD(lParam)

	WIN32:	ID          = LOWORD(wParam)
			ctrl handle = lParam
			notify code = HIWORD(wParam)
*/

#ifdef WIN32
	wID = LOWORD(wParam);
#else
	wID = wParam;
#endif

switch (wID)
	{
	case IDM_EXIT:
	DeactivateTool();
	PostMessage( hWndAstral, WM_CLOSE, 0, 0L);
    Delay (750);
	break;

	case IDM_CLOSE:
	DeactivateTool();
	/* Check to see if the image needs to be saved */
	if ( !ConfirmClose(NO,NO) )
		break;
	CloseImage( NO, lpImage ); // Close the active image
	break;

	case IDM_ABOUT:
	/* Bring up the modal 'About' dialog box */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_ABOUT, DlgAboutProc);
	break;

	case IDM_NEXTPAGE:
	if ( !lpImage )
		break;
	DeactivateTool();
	SendMessage( lpImage->hWnd, WM_SYSCOMMAND, SC_NEXTWINDOW, 0L );
	break;

	case IDM_NEW:
	DeactivateTool();
	SoundStartResource( "magic01", NO, NULL );
	AstralCursor( IDC_WAIT );
	New( Control.NewWidth, Control.NewHeight, Control.NewResolution,
		Control.NewDepth );
	AstralCursor( NULL );
	break;

	case IDM_OPEN:
	DeactivateTool();
	/* Bring up the modal 'File Open' box */
	if ( !(dwReturn = DoOpenDlg( hWindow, IDD_OPEN,
		Save.FileType, szFileName, NO )) )
		break;
	idFileType = LOWORD( dwReturn );
	Save.FileType = idFileType;
	PutDefaultInt( "FileType", idFileType - IDN_TIFF );
	AstralImageLoad( idFileType, szFileName, MAYBE, YES );
	break;

	case IDM_ALTOPEN:
	DeactivateTool();
	// Command line sent from a second instance prior to it closing
	/* If the caller passed in a file name, try to load it or print it */
	if ( !(lpszCmdLine = (LPSTR)lParam) )
		break;
	HandleCommandLine( hWindow, lpszCmdLine, &bPrint );
	break;

	case IDM_SAVE:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEAS:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVESPECIAL:
	DeactivateTool();
	HandleSaveCommand(hWindow, wID, YES);
	break;

	case IDM_SAVEWALLPAPER:
	DeactivateTool();
	SaveWallpaper( "CRAYOLA", NO/*fTiled*/ );
	break;

	case IDM_REVERT:
	if ( !lpImage )
		break;
	DeactivateTool();
	if ( lpImage->fUntitled ) // If the picture doesn't have a name, get out
		break;
	if ( ImgChanged(lpImage) )
		{
		/* Check to see if its OK to trash changes */
		if ( AstralOKCancel(IDS_OKTOREVERT,
				(LPSTR)lpImage->CurFile) == IDCANCEL )
			break;
		}
	lstrcpy( szFileName, lpImage->CurFile );
	idFileType = lpImage->FileType;
	fDoZoom = IsZoomed(lpImage->hWnd);
	fHasZoom = Window.fHasZoom;
	CloseImage( NO, lpImage ); // Close the active image
	if ( !AstralImageLoad( idFileType, szFileName, fDoZoom, YES ) )
		break;
	break;

	case IDM_RECALLIMAGE0:
	case IDM_RECALLIMAGE1:
	case IDM_RECALLIMAGE2:
	case IDM_RECALLIMAGE3:
	case IDM_RECALLIMAGE4:
	case IDM_RECALLIMAGE5:
	case IDM_RECALLIMAGE6:
	case IDM_RECALLIMAGE7:
	case IDM_RECALLIMAGE8:
	case IDM_RECALLIMAGE9:
	DeactivateTool();
	GetMenuString( GetMenu(hWindow), wID,
		szFileName, sizeof(szFileName), MF_BYCOMMAND );
	i = 0;
	while ( szFileName[i] && szFileName[i] != ' ' )
		i++; // Skip over the numeric id in the string (3. junk.tif)
	lstrcpy(szString, &szFileName[i+1]);
	GetRecallFileName(szString);
	AstralImageLoad( NULL, szString, MAYBE, YES );
	break;

	case IDM_PRINT:
	if ( !lpImage )
		break;
	DeactivateTool();
	AstralCursor( IDC_WAIT );
	DoPrintSizeInits();
	SoundStartResource( "print", YES, NULL );
	PrintFile( hWindow, filename(lpImage->CurFile), YES, lpImage, NULL );
	SoundStop();
	AstralCursor( NULL );
	break;

	case IDM_PRINTSETUP:
	/* Bring up the setup dialog box for the active printer */
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PRINTSETUP,
		DlgPrintSetupProc);
	break;

	case IDC_SOUND:
	SoundToggle();
	break;

	case IDM_UNDO:
	if ( !lpImage )
		break;
	DeactivateTool();
	ImgEditUndo(lpImage, YES, NO);
	break;

	case IDM_CUT:
	case IDM_COPY:
	if ( !lpImage )
		break;
	DeactivateTool();

	// Create the clipboard files from the image
	ProgressBegin(1, IDS_PROGCOPY);
	if ( !ImgWriteClipOut( lpImage, NULL, NULL, &rMask, lpImage->DataType ) )
		{
		ProgressEnd();
		Message(IDS_EMEMALLOC);
		break;
		}
	ProgressEnd();

	OpenClipboard(hWindow);
	EmptyClipboard();

	// Passing a NULL data handle in SetClipboardData() means that
	// the data will be requested in a WM_RENDERFORMAT message
	hMem = ConstructObject( lpImage,
		IsRectEmpty(&rMask)? (LPRECT)NULL : (LPRECT)&rMask );
	if ( pOLE )
		{ // Any data put on before Native will become staticly copied
		SetClipboardData( pOLE->cfNative, NULL );
		SetClipboardData( pOLE->cfOwnerLink, hMem );
		}
	SetClipboardData( CF_DIB, NULL );
	if ( Control.DoPicture )
		SetClipboardData( CF_METAFILEPICT, NULL );
	if ( Control.DoBitmap )
		SetClipboardData( CF_BITMAP, NULL );
	SetClipboardData( CF_PALETTE, NULL );
	SetClipboardData( Control.cfImage, NULL );
	if ( pOLE && wID == IDM_COPY && !lpImage->fUntitled )
		{ // ObjectLink is retrieved during a Paste Link...
		SetClipboardData( pOLE->cfObjectLink, hMem );
		}
	CloseClipboard();
	if ( wID == IDM_COPY )
		break;

	// else fall through to IDM_DELETE

	case IDM_DELETE:
	if ( !lpImage )
		break;
	{
	COLORINFO ColorInfo;

	DeactivateTool();
	ColorInfo.gray   = 255;
	SetColorInfo( &ColorInfo, &ColorInfo, CS_GRAY );
	TintFill( lpImage, &ColorInfo, 255, MM_NORMAL,
		wID == IDM_CUT ? IDS_UNDOCUT : IDS_UNDODELETE );
	}
	break;

	case IDM_PASTE:
	if ( !lpImage )
		break;

	case IDM_PASTEASNEW:
	if ( !OpenClipboard(hWndAstral) )
		{
		Message( IDS_ECLIPOPEN );
		break;
		}
	if ( !IsClipboardFormatAvailable(CF_DIB) &&
	     !IsClipboardFormatAvailable(CF_BITMAP) &&
	     !IsClipboardFormatAvailable(Control.cfImage) )
		{
		Message( IDS_ECLIPOPEN );
		CloseClipboard();
		break;
		}
	CloseClipboard();

	DeactivateTool();
	// First put clipboard contents into a file(s)
	AstralCursor(IDC_WAIT);
	if ( !PasteFromClipboard( hWindow, (wID == IDM_PASTE) /*fNeedMask*/ ) )
		{
		AstralCursor(NULL);
		Message(IDS_EMEMALLOC);
		break;
		}
	if ( wID == IDM_PASTE )
		{
		ProgressBegin(1, IDS_PROGPASTECLIP);
		TransformObjectsStart( YES/*fNewObject*/ );
        if ( ImgCreateClipInObject( lpImage, NO ) )
			;
		ProgressEnd();
		}
	else
	if ( wID == IDM_PASTEASNEW )
		{
		if ( lpFrame = AstralFrameLoad( Names.PasteImageFile, -1,
			 &idDataType, &idFileType) )
			{
			if ( NewImageWindow(
				NULL,			// lpOldFrame
				NULL,			// Name
				lpFrame, 		// lpNewFrame
				idFileType,		// lpImage->FileType
				idDataType,		// lpImage->DataType
				FALSE,			// New view?
				IMG_DOCUMENT,	// lpImage->DocumentType
				NULL,			// lpImage->ImageName
				MAYBE
				) )
					lpImage->fChanged = YES;
			}
		}
	break;

	case IDM_ESCAPE:
	if (!lpImage)
		break;
	if (lpImage->hWnd == hZoomWindow)
		break;
	if ( Tool.bActive && Tool.lpToolProc )
		DestroyProc( lpImage->hWnd, 1L );
	break;

	case IDM_SIZEUP:
	case IDM_SIZEDOWN:
	if (!Retouch.hBrush)
		break;				 
	SetFocus( hWindow ); // Take focus away from any controls
	if ( Retouch.BrushShape == IDC_BRUSHCUSTOM )
		break;
	if ( wID == IDM_SIZEUP )
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 ))
    		Retouch.BrushSize += 2;
        else        
    		Retouch.BrushSize++;
    }
	else	
    {
    	if( bHexBrush && ( Retouch.BrushSize % 2 == 0 ) && ( Retouch.BrushSize > 6 )) 
    		Retouch.BrushSize -= 2;
        else        
    		Retouch.BrushSize--;
    }
	if ( Retouch.BrushSize < 1 || Retouch.BrushSize > MAX_BRUSH_SIZE )
		{
		Retouch.BrushSize = bound( Retouch.BrushSize, 1,MAX_BRUSH_SIZE);
		MessageBeep(0);
		break;
		}
	if (lpImage)
		DisplayBrush(0, 0, 0, OFF);
	SetMgxBrushSize(Retouch.hBrush, Retouch.BrushSize);
	if (lpImage && Window.hCursor == Window.hNullCursor)
		DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		SetSlide( Tool.hRibbon, IDC_BRUSHSIZE, Retouch.BrushSize );
	break;

	case IDM_SHAPEUP:
	case IDM_SHAPEDOWN:
	if (!Retouch.hBrush)
		break;
	SetFocus( hWindow ); // Take focus away from any controls
	NewShape = Retouch.BrushShape;
	if ( wID == IDM_SHAPEUP )
		NewShape++;
	else	NewShape--;
	if ( NewShape > IDC_BRUSHCUSTOM )
		NewShape = IDC_BRUSHCIRCLE;
	if ( NewShape < IDC_BRUSHCIRCLE )
		NewShape = IDC_BRUSHCUSTOM;
	if (lpImage)
	 	DisplayBrush(0, 0, 0, OFF);
	if (!SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush))
		{
		NewShape = IDC_BRUSHCIRCLE;
		SetMgxBrushShape(Retouch.hBrush, NewShape, Names.CustomBrush);
		}
	Retouch.BrushShape = NewShape;
	if (lpImage && Window.hCursor == Window.hNullCursor)
	 	DisplayBrush(lpImage->hWnd, 32767, 32767, ON);
	if ( Tool.hRibbon )
		{
		CheckComboItem( Tool.hRibbon, IDC_BRUSHSHAPE, IDC_BRUSHCIRCLE,
			IDC_BRUSHCUSTOMNEW, Retouch.BrushShape );
		SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L );
		}
	break;

	case IDM_MOVEUP:
	case IDM_MOVEDOWN:
	case IDM_MOVELEFT:
	case IDM_MOVERIGHT:
	if (!lpImage)
		break;
	lpBase = ImgGetBase(lpImage);
	if (ImgGetSelObject(lpImage, NULL) == lpBase)
		break;
	dx = dy = 0;
	if (wID == IDM_MOVEUP)
		--dy;
	if (wID == IDM_MOVEDOWN)
		++dy;
	if (wID == IDM_MOVELEFT)
		--dx;
	if (wID == IDM_MOVERIGHT)
		++dx;
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&rect, dx, dy);
		if (!AstralIntersectRect(&rTemp, &lpBase->rObject, &rect))
			break;
		}
	if (lpObject)
		break;
	AstralSetRectEmpty(&rAll);
	lpObject = NULL;
	while (lpObject = ImgGetSelObject(lpImage, lpObject))
		{
		rect = lpObject->rObject;
		OffsetRect(&lpObject->rObject, dx, dy);
		AstralUnionRect(&rAll, &rAll, &lpObject->rObject);
		if (!lpObject->Pixmap.fNewFrame &&
				EqualRect(&rect, &lpObject->rUndoObject))
			lpObject->rUndoObject = lpObject->rObject;
		UpdateImage(&rect, TRUE);
		UpdateImage(&lpObject->rObject, TRUE);
		}
	if (wID == IDM_MOVEUP)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.top;
		}
	else
	if (wID == IDM_MOVEDOWN)
		{
		x = (rAll.left + rAll.right)/2;
		y = rAll.bottom;
		}
	else
	if (wID == IDM_MOVELEFT)
		{
		x = rAll.left;
		y = (rAll.top + rAll.bottom)/2;
		}
	else
	if (wID == IDM_MOVERIGHT)
		{
		x = rAll.right;
		y = (rAll.top + rAll.bottom)/2;
		}
	File2Display(&x, &y);
	AutoScroll(lpImage->hWnd, x, y);
	AstralUpdateWindow(lpImage->hWnd);
	DisplayInfo(-1, &rAll);
	break;

	case IDM_LASTTOOL:
	DeactivateTool();
	if ( Tool.idLast && (hWnd = AstralDlgGet(IDD_MAIN)) )
		SendMessage( hWnd, WM_COMMAND, Tool.idLast, 2L);
	break;

	case IDM_PREF:
	// prevent problems if running animations and they change
	// the wave mix dll setting in preferences
	StopAnimation();
	AstralDlg( NO|2, hInstAstral, hWindow, IDD_PREF, DlgPrefProc );
	break;

	case IDC_VIEWLAST: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	RevertLastView();
	break;

//	case IDC_VIEWFULL: // duplicate of function in the view ribbon
//	if ( !lpImage )
//		break;
//	AstralDlg( NO, hInstAstral, hWindow, IDD_VIEWFULL, DlgFullScreenViewProc );
//	break;

	case IDC_VIEWALL: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;
	ViewAll();
	break;

	case IDC_ZOOMIN: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, +100, YES, ( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDC_ZOOMOUT: // duplicate of function in the view ribbon
	if ( !lpImage )
		break;

	if (!lpImage->lpDisplay)
		break;

	if (!lpImage->lpDisplay->ViewPercentage)
		break;

	x = ( lpImage->lpDisplay->FileRect.left
			+ lpImage->lpDisplay->FileRect.right ) / 2;
	y = ( lpImage->lpDisplay->FileRect.top
			+ lpImage->lpDisplay->FileRect.bottom ) / 2;
	SaveLastView();
	Zoom(x,y, -100, YES,( View.ZoomWindow ^ CONTROL ) );
	break;

	case IDM_HELP:
	Control.Hints = !Control.Hints;
	PutDefInt (Control.Hints,Control.Hints);
	break;

	default:
	return( FALSE );
	}

return( TRUE );
}
Beispiel #13
0
int LinesProc( HWND hWindow, LPARAM lParam, UINT msg )
/************************************************************************/
{
int x, y, fx, fy;
LPOBJECT lpObject;
RGBS rgb;
LPFRAME lpFrame;
STRING szOptions;
static RGBS rgbLast;

x = LOWORD(lParam);
y = HIWORD(lParam);
switch (msg)
    {
    case WM_CREATE:	// The first mouse down message
	if (!ONIMAGE(x, y))
		break;
	Display2File(&x, &y);
	if ( !ImgSelectObjectType( lpImage, x, y,
		YES/*bAllowBase*/, YES/*bAllowMovable*/, NO/*bAllowPlayable*/ ) )
			break;
	if (!Retouch.hBrush)
		break;
	GetActiveRGB( &rgb );
	if ( rgb.red != rgbLast.red || rgb.green != rgbLast.green ||
		 rgb.blue != rgbLast.blue )
		{ // if a color change, restuff the brush source
		OptionGetString( hOptions, iTool+1, szOptions );
		lpFrame = TiffResource2Frame( hOptions, (LPSTR)MAKEINTRESOURCE(iTool+1) );
		SetSimpleBrushSource( Retouch.hBrush, lpFrame, szOptions );
		rgbLast = rgb;
		}
	Tool.bActive = YES;
	break;

	case WM_SETCURSOR:
	return( SetToolCursor( hWindow, NULL/*idMoveObject*/, ID_PLAY_OBJECT ) );

	case WM_ACTIVATE:
	if (!lParam) // a deactivate
		{
		if (Retouch.hBrush)
			DestroySimpleBrush(Retouch.hBrush);
		Retouch.hBrush = NULL;
		}
	else
		{ // an activate ( to re-create brush)
		if ( Tool.hRibbon )
			SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 1, 0L );
		}
	break;

    case WM_LBUTTONDOWN:
	Tool.bActive = NO;
	if (ImgCountSelObjects(lpImage, NULL) == 1)
		lpObject = ImgGetSelObject(lpImage, NULL);
	else
		{
		fx = x;
		fy = y;
		Display2File( &fx, &fy );
		lpObject = ImgFindSelObject(lpImage, fx, fy, NO);
		}
	if (!lpObject)
		break;
	if (!ImgEditInit(lpImage, ET_OBJECT, UT_DATA, lpObject))
		break;

	if (!SimpleBrushBegin(hWindow, &lpObject->Pixmap,
		lpObject->rObject.left, lpObject->rObject.top, Retouch.hBrush))
	    break;
	ImgEditedObject(lpImage, lpObject, IDS_UNDOCHANGE, NULL);
	Tool.bActive = SimpleBrushActive();

	/* fall through to WM_MOUSEMOVE */

    case WM_MOUSEMOVE:	// sent when ToolActive is on
	fx = x;
	fy = y;
	Display2File( &fx, &fy );
	SimpleBrushStroke(fx, fy, x, y);
	break;

    case WM_LBUTTONUP:
	SimpleBrushEnd(NO);
	Tool.bActive = NO;
	break;

    case WM_LBUTTONDBLCLK:
	break;

    case WM_DESTROY:	// The cancel operation message
	SimpleBrushEnd(NO);
	Tool.bActive = NO;
	break;
    }

return(TRUE);
}