Beispiel #1
0
LRESULT Dialog_OnSizeParent(HWND hwnd, AFX_SIZEPARENTPARAMS* lpLayout)
{
	// align the control bar
	CRect 	rect, r;
	CSize 	size;
	BOOL	Ribbon = hwnd == AstralDlgGet(Tool.idRibbon);
	BOOL	Status = hwnd == AstralDlgGet(IDD_STATUS);

	rect.CopyRect(&lpLayout->rect);
	CSize sizeAvail = rect.Size();  // maximum size available

	// get maximum requested size, size of ribbon
   	GetClientRect(GetParent(hwnd), &r);
	size.cx = r.Width();
	if (Ribbon)
		size.cy = 42;
	else if (Status)
		size.cy = 22;

	size.cx = min(size.cx, sizeAvail.cx);
	size.cy = min(size.cy, sizeAvail.cy);

	lpLayout->sizeTotal.cy += size.cy;
	lpLayout->sizeTotal.cx = max(lpLayout->sizeTotal.cx, size.cx);
	if (Ribbon)
		lpLayout->rect.top += size.cy;
	else if (Status)
	{
		rect.top = rect.bottom - size.cy;
		lpLayout->rect.bottom -= size.cy;
	}
	rect.right = rect.left + size.cx;
	rect.bottom = rect.top + size.cy;
	// only resize the window if doing layout and not just rect query
	if (lpLayout->hDWP != NULL)
		AfxRepositionWindow(lpLayout, hwnd, &rect);
return 0;
}
Beispiel #2
0
VOID back_to_windows( int flag )
{
	/* Don't go back to windows if we never left! */
	if (flag) {
		/* We're coming back from the picture window */
#ifndef WIN32
		PicwinOff((LPSTR)palette1,0,NULL,NULL,NULL); /* restore windows disp */
#endif
		ReleaseCapture( );

		AstralDlgHide( IDD_GRAB ); /* Force a windows redisplay */

		ShowCursor( TRUE );

		AstralDlgEnd( AstralDlgGet( IDD_GRAB ), TRUE );
	}
}
Beispiel #3
0
BOOL Status( HWND hWnd, LPSTR lpString )
/***********************************************************************/
{
    static HBITMAP hBubble,hMask,hSaveBits;
    BOOL bBubble = FALSE;

    if (hWnd == (HWND)-1)
    {
        // remove bubble from screen, then clean up
        Status (0,NULL);
        if (hBubble)
        {
            DeleteObject (hBubble);
            hBubble = 0;
        }
        if (hMask)
        {
            DeleteObject (hMask);
            hMask = 0;
        }
        if (hSaveBits)
        {
            DeleteObject (hSaveBits);
            hSaveBits = 0;
        }
    }
    else
    {
        static char szPrevString[256];
        static RECT rBubble,rText;
        static POINT ptBubble,ptLimit;
        HBITMAP hBitmap;
        HDC hDC,hMemDC;

        hDC = GetDC (HWND_DESKTOP);
        if (lpString && *lpString)
        {
            if (!hBubble)
            {
                BITMAP bmBubble;

                // load bubble bitmap
                hBubble = DibResource2Bitmap (hInstAstral,IDC_STATUSBUBBLE);
                GetObject (hBubble,sizeof bmBubble,(LPVOID)&bmBubble);

                // get bubble rect
                rBubble.left   = 0;
                rBubble.right  = bmBubble.bmWidth;
                rBubble.top    = 0;
                rBubble.bottom = bmBubble.bmHeight;

                // get text rect
                rText = rBubble;
                InflateRect (&rText,-50,-50);
                OffsetRect (&rText,8,0);

                // get screen limits
                ptLimit.x = ptLimit.y = 0;
                MapWindowPoints (AstralDlgGet (IDD_MAIN),HWND_DESKTOP,
                    &ptLimit,1);
                ptLimit.x += 640;
                ptLimit.y += 480;
            }
            if (hBubble)
            {
                if (!hSaveBits)
                {
                    #define XFUDGE 40
                    #define YFUDGE 20

                    // get bubble position
                    GetCursorPos (&ptBubble);
                    if ((ptBubble.x + rBubble.right + XFUDGE) > ptLimit.x)
                        ptBubble.x -= rBubble.right + XFUDGE;
                    else
                        ptBubble.x += XFUDGE;
                    if ((ptBubble.y + rBubble.bottom + YFUDGE) > ptLimit.y)
                        ptBubble.y -= rBubble.bottom + YFUDGE;
                    else
                        ptBubble.y += YFUDGE;

                    // save background
                    hMemDC = CreateCompatibleDC (hDC);
                    hSaveBits = CreateCompatibleBitmap (hDC,
                        rBubble.right,rBubble.bottom);
                    hBitmap = (HBITMAP)SelectObject (hMemDC,hSaveBits);
                    BitBlt (hMemDC,0,0,rBubble.right,rBubble.bottom,
                        hDC,ptBubble.x,ptBubble.y,SRCCOPY);
                    SelectObject (hMemDC,hBitmap);
                    DeleteDC (hMemDC);
                }
                if (!*szPrevString || lstrcmp (lpString,szPrevString) != 0)
                {
                    HBITMAP hTemp;
                    RECT rTemp;

                    // draw bubble on screen
                    hTemp = DrawTransDIB (hDC,hBubble,hMask,
                        ptBubble.x + rBubble.right / 2,
                        ptBubble.y + rBubble.bottom / 2);
                    if (!hMask)
                        hMask = hTemp;

                    // draw text in bubble
                    rTemp = rText;
                    OffsetRect (&rTemp,ptBubble.x,ptBubble.y);
                    DrawText (hDC,lpString,-1,&rTemp,DT_CENTER | DT_WORDBREAK);
                    lstrcpy (szPrevString,lpString);

                    // indicate that bubble was actually drawn, not skipped
                    bBubble = TRUE;
                }
			}
        }
        else
        {
            if (hSaveBits)
            {
                // Restore background
                hMemDC = CreateCompatibleDC (hDC);
                hBitmap = (HBITMAP)SelectObject (hMemDC,hSaveBits);
                BitBlt (hDC,ptBubble.x,ptBubble.y,
                    rBubble.right,rBubble.bottom,hMemDC,0,0,SRCCOPY);
                SelectObject (hMemDC,hBitmap);
                DeleteObject (hSaveBits);
                DeleteDC (hMemDC);
                hSaveBits = 0;
            }
            *szPrevString = 0;
        }
        ReleaseDC (HWND_DESKTOP,hDC);
    }
    return bBubble;
}
Beispiel #4
0
void grabber( LPSTR lpExtName, int port, HINSTANCE hInstance, HWND hWindow )
{

	HWND hWnd;
/*
	special conditions:
		hand scan interface --	
			with hand scanners the dialog box has a scan
			frame which gets filled with image data.  the
			dialog box must remain up during reads, so we
			use the exported frame_open, cacheptr, and
			frame_close to create the frame instead of 
			device reads.  Devopen just returns devcaps,
			devstart does everything else.
	
		special willow gs --	
			the gs board has 4 different buffers, which
			contain the following: 0-even pix/even lines,
			1-odd pix/even lines, 2-even pix/odd lines,
			3-odd pix/odd lines.
			each call to devread will layer the data so
			that the buffers will be combined correctly.
	
	Device Requirements Byte Decoding:

		XXXXXXX1b =  need to take over display
		XXXXXXX0b =  no need to take over display
		XXXXXX1Xb =  special willow gs read
		XXXXXX0Xb =  no special read 
		XXXX00XXb =  image depth, special case palette color 8-bit
		XXXX01XXb =  depth == 1
		XXXX10XXb =  depth == 2
		XXXX11XXb =  depth == 3
		X1XXXXXXb = special hand scan i/f 
		X0XXXXXXb = standard grab i/f
		XX1XXXXXb = don't free DLL after exit
		XX0XXXXXb = free DLL after exit 
		1XXXXXXXb = putting data from cache to external device
		0XXXXXXXb = putting data from external device into cache
		*/

	BYTE devreq; // device requirements
	LPFRAME lpFrame, lpOldFrame;
	BYTE depth;
	int lncnt,Datatype;
	HMODULE hDLL;
	LPIMAGE lpImage;

	if ( !(hDLL = (HMODULE)LoadGrabberLibrary(lpExtName)) ) {
		Message( IDS_EBADDRIVER, NULL );
		return;
	}

	if ( !(lpImage = GetActiveImage()))
		lpFrame = NULL;
	else
		lpFrame = ImgGetBaseEditFrame(lpImage);

   lpfnDevName     = (DEVNAMEPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(301));
   lpfnDevOpen     = (DEVOPENPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(302));
   lpfnDevCall     = (DEVCALLPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(303));
   lpfnDevClose    = (DEVCLOSEPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(304));
   lpfnAcquireProc = (DLGPROC)GetProcAddress(hDLL, MAKEINTRESOURCE(305));

	/* get device's intentions -- is this a put to or read from cache */
	DevInfo.hInst = hInstance;  /* set the data structures */
	DevInfo.hPw = hWindow;
	DevInfo.bFile_is_open = ( lpFrame != NULL );

	if(DevInfo.bFile_is_open)
		{
		DevInfo.bImg_type = (lpImage->DataType==IDC_SAVECT ? TRUE : FALSE);
		/* pass the current filename */
		lstrcpy(DevInfo.cfname, lpImage->CurFile); 
		}

	if(!DevOpen(&DevInfo)) {
		DevCall(DEV_MSG, (LPTR)&DevMsg);
		
		/* if MsgNo == 0, then user cancelled */
		if(DevMsg.MsgNo) {
			if(DevMsg.MsgNo > 0) {
				Message( DevMsg.MsgNo );
			} else {
				/* print the driver's message */
				Print("%ls", (LPTR)DevMsg.szMsg);
			}
		}
		return; 
	}

	bKeepDLL = (DevInfo.device_caps & 0x20);
	devreq = DevInfo.device_caps;
	
	/* doing a put cache to an external device */
	if(!(devreq & 0x80)) {
		/* fill up the device info data structure */
		DevInfo.npix = FrameXSize( lpFrame );
		DevInfo.nlin = FrameYSize( lpFrame );
		DevInfo.bpl =  FrameXSize( lpFrame );
		DevInfo.xres = DevInfo.yres = FrameResolution( lpFrame );
		DevInfo.bpp = 8;
	} else {
		DevInfo.port = port; /* set the port for devices which require it */
#ifndef WIN32
		DevInfo.vgaaddr = GetA000H(); /* set the VGA buffer address */
#endif
	}

	/* see if we need to take over display */
	if(devreq & 1) {
		/* Hide the Cursor */
		ShowCursor( FALSE );

		/* Create the acquire window: it doesn't have the visable bit set */
		AstralDlg( YES, hInstance, hWindow, IDD_GRAB, AcquireProc);
		AstralDlgShow( IDD_GRAB );

		/* Enter the picture window command processor */
		SetCapture( AstralDlgGet( IDD_GRAB ) );

		/* set the data structures */
		DevInfo.hInst = hInstance;  
		DevInfo.hPw   = AstralDlgGet( IDD_GRAB );

		/* call display driver disable */
#ifndef WIN32
		PicwinOn((LPSTR)palette1);
#endif
	}

	if(devreq & 0x40) { // devstart does everything
		DevInfo.FpPtr = (LPTRPROC)MakeProcInstance(
			(FARPROC)grabber_frame_ptr, DevInfo.hInst);

		DevInfo.FoPtr = (LPTRPROC)MakeProcInstance(
			(FARPROC)grabber_frame_open, DevInfo.hInst);

		DevInfo.FsPtr = (LPTRPROC)MakeProcInstance(
			(FARPROC)grabber_frame_set, DevInfo.hInst);

		DevInfo.FcPtr = (LPROC)MakeProcInstance(
			(FARPROC)grabber_frame_close, DevInfo.hInst);

		DevInfo.CcPtr = (LPROC)MakeProcInstance(
			(FARPROC)grabber_AstralClockCursor, DevInfo.hInst);
	}

	DevInfo.bLineArtAsGray = Control.LineArtAsGray;
 
	if(!DevCall(DEV_START, (LPTR)&DevInfo)) { /* if get, fill struct */
		back_to_windows(devreq & 1); /* restore if true */

		DevCall(DEV_MSG, (LPTR)&DevMsg);

		/* if MsgNo == 0, then user cancelled */
		if(DevMsg.MsgNo) {
			if(DevMsg.MsgNo > 0) {
				Message( DevMsg.MsgNo );
			} else {
				/* print the driver's message */
				Print("%ls", (LPTR)DevMsg.szMsg);
			}
		}

		if(devreq & 0x40) { // devstart does everything
			FreeProcInstance((FARPROC)DevInfo.FpPtr);
			FreeProcInstance((FARPROC)DevInfo.FoPtr);
			FreeProcInstance((FARPROC)DevInfo.FsPtr);
			FreeProcInstance((FARPROC)DevInfo.FcPtr);
			FreeProcInstance((FARPROC)DevInfo.CcPtr);
		}

		DevClose(); /* close the device */
		return;
	}

	/* DEV_START returned ok, now get or put image data if not done */

	if((devreq & 0xc0) == 0x80) { // putting data into the cache with devreads
		if(((devreq & 4) == 4) || ((devreq & 0x0c) == 0)) {
			depth = 1;
		} else {
			if((devreq & 8) == 8) {
				depth = 2;
			} else {
				if((devreq & 0x0c) == 0x0c) {
					depth = 3;
				}
			}
		}

		lpOldFrame = frame_set( NULL );
	
		if(!(lpFrame = FrameOpen(
				(FRMDATATYPE)depth,DevInfo.npix,DevInfo.nlin,DevInfo.xres))) {

			back_to_windows(devreq & 1); /* Restore if true */
	
			FrameError(IDS_EIMAGEOPEN);
			return;
		}
	
		frame_set(lpFrame);
	
		if(!(devreq & 2))	{
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt++ ) {
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES);
				if(!DevCall(DEV_READ, (LPTR)&DevData)) {
		         back_to_windows(devreq & 1); /* Restore if true */
					DevCall(DEV_MSG, (LPTR)&DevMsg);
	
					/* if MsgNo == 0, then user cancelled */
					if(DevMsg.MsgNo) {
						Print("Unable to get data from device");
					} else {
						DevInfo.nlin = lncnt;  // hand scanner, get total lines
					}
					return;
				}
			}
		} else { /* special willow gs reader */
	
			/* read even bytes, even lines */
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES);
				if(!DevCall(DEV_READ0, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
	
			/* read odd bytes, even lines */
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 1, lncnt, YES);
				if(!DevCall(DEV_READ1, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
	
			/* read even bytes, odd lines */
			for ( lncnt=1; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, YES);
				if(!DevCall(DEV_READ2, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
	
			/* read odd bytes, odd lines */
			for ( lncnt=1; lncnt<DevInfo.nlin; lncnt+=2 ) {
				DevData.ImageAddress = FramePointer(lpFrame, 1, lncnt, YES);
				if(!DevCall(DEV_READ3, (LPTR)&DevData)) {
					back_to_windows(devreq & 1); /* Restore if true */
					Print("Unable to get data from device");
					return;
				}
			}
		}
		
		FrameClose( lpOldFrame );
	
		back_to_windows(devreq & 1); /* Restore if true */
	
		if(DevInfo.bpp == 1) {
			Datatype = IDC_SAVELA;
		} else {
			if(DevInfo.bpp == 8) {
				Datatype = IDC_SAVECT;
			} else {
				Datatype = IDC_SAVE24BITCOLOR;
			}
		}
	
		/* Setup the new image and bring up the new image window */
        LPIMAGE lpNewImage = CreateImage(NULL, lpFrame, NULL, 
           NULL, Control.DefaultFileType, Datatype, 
           IMG_DOCUMENT, NULL);
        if (lpNewImage)
        {
            if (PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile,
               lpNewImage))         
            {
               	/* only version of image is in the cache */
            	/* so insure user is asked about saving when done */
                lpNewImage->fChanged = TRUE;
            }
            else
                DestroyImage(lpNewImage);
        }
	
		DevClose(); /* close the device */
	} else {
        LPIMAGE lpNewImage = NULL;

		/* enable the frame created by DevStart */
		lpFrame = frame_set(NULL);

		/* putting data to external device with DevWrites */
		if((devreq & 0xc0) == 0) {
			for ( lncnt=0; lncnt<DevInfo.nlin; lncnt++ ) {
				AstralClockCursor( lncnt, DevInfo.nlin, NO );
				DevData.ImageAddress = FramePointer(lpFrame, 0, lncnt, NO);
				if(!DevCall(DEV_WRITE, (LPTR)&DevData)) {
					Print("Unable to put data to device");
					return;
				}
			}
		} else {
			/* devstart has created a frame with image data */
			FreeProcInstance((FARPROC)DevInfo.FpPtr);
			FreeProcInstance((FARPROC)DevInfo.FoPtr);
			FreeProcInstance((FARPROC)DevInfo.FsPtr);
			FreeProcInstance((FARPROC)DevInfo.FcPtr);

			if(DevInfo.bpp == 1) {
				Datatype = IDC_SAVELA;
			} else {
				if(DevInfo.bpp == 8) {
					Datatype = IDC_SAVECT;
				} else {
					Datatype = IDC_SAVE24BITCOLOR;
				}
			}

			back_to_windows(devreq & 1); /* Restore if true */

			/* enable the frame created by DevStart */
			lpFrame = frame_set(NULL);

			/* DevInfo.nlin returns the actual line count */
			if(FrameYSize(lpFrame) <= DevInfo.nlin) {
				/* Setup the new image and bring up the new image window */
            {
                lpNewImage = CreateImage(NULL, lpFrame, NULL, 
                   NULL, Control.DefaultFileType, Datatype, 
                   IMG_DOCUMENT, NULL);
                if (lpNewImage)
                {
                    if (!PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile,
                       lpNewImage))         
                    {
                        DestroyImage(lpNewImage);
                        lpNewImage = NULL;
                    }
                }
            }

			} else {
				/* create a new frame of the right size and copy  */
				/* the right number of lines to it */

				lpOldFrame = FrameOpen(
					FrameType(lpFrame),
					FrameXSize(lpFrame), 
					DevInfo.nlin,
					FrameResolution(lpFrame));

				AstralCursor( IDC_WAIT );

				for(lncnt=0; lncnt<DevInfo.nlin; lncnt++) {
					FrameCopyLine(lpFrame, lpOldFrame, lncnt);
				}

				FrameClose(lpFrame);
				lpFrame = lpOldFrame;
				AstralCursor( NULL );
				/* Setup the new image and bring up the new image window */
                lpNewImage = CreateImage(NULL, lpFrame, NULL, 
                   NULL, Control.DefaultFileType, Datatype, 
                   IMG_DOCUMENT, NULL);
                if (lpNewImage)
                {
                    if (!PictPubApp.OpenDocumentFile((LPSTR)lpNewImage->CurFile,
                       lpNewImage))         
                    {
                        DestroyImage(lpNewImage);
                        lpNewImage = NULL;
                    }
                }

			}
			/* only version of image is in the cache */
			/* so insure user is asked about saving when done */
            if (lpNewImage)    
                lpNewImage->fChanged = TRUE;

			DevClose(); /* close the device */
		}
	}
}
Beispiel #5
0
BOOL HandleCommandLine(
/***********************************************************************/
HWND 	hWindow,
LPSTR 	lpszCmdLine,
LPINT 	lpPrint)
{
FNAME szFileName;
LPSTR lp;
BOOL bPassedByClient, bGotImage;
LPIMAGE lpImageDoc;
HWND hWnd;
int i;

bPaintAppActive = TRUE;

*lpPrint = NO;
if ( !lpszCmdLine )
	{ // If no command line, bring up an empty image
	SendMessage( hWindow, WM_COMMAND, IDM_NEW, 0L );
	if ( (hWnd = AstralDlgGet(IDD_MAIN)) && !IsWindowVisible( hWnd ) )
		ShowWindow( hWnd, SW_SHOW );
	return( TRUE );
	}

// Check if we have "[/ | -]embedding" and a possible filename.
// usage: PP ["[-/]embedding"] file1 file2 ...

// See if the command line is being passed by a client
bPassedByClient = NO;
if ( (lp = lstrfind( lpszCmdLine, "embedding" )) &&
	 (lp == lpszCmdLine || lp == (lpszCmdLine+1)) )
	{ // Command line passed by a client
	bPassedByClient = YES;
	lpszCmdLine = SkipSpaces( lp + 9 ); // skip over "embedding"
	}

bGotImage = NO;
while ( *lpszCmdLine )
	{ // Process any files and switches on the command line

	// Skip white space and see if we're done...
	lpszCmdLine = SkipSpaces( lpszCmdLine );
	if ( !(*lpszCmdLine ) )
		break; // If NULL get out

	// Check for any switches preceeding the file name: only /p for now
	while ( *lpszCmdLine == '/' )
		{ // a switch...
		lpszCmdLine++; // Skip over the slash
		if ( !*lpszCmdLine )
			break; // If NULL get out
		if ( *lpszCmdLine == 'p' || *lpszCmdLine == 'P' )
			*lpPrint = YES;
		lpszCmdLine++; // Skip the option character
		lpszCmdLine = SkipSpaces( lpszCmdLine );
		}

	// Skip white space and see if we're done...
	lpszCmdLine = SkipSpaces( lpszCmdLine );
	if ( !(*lpszCmdLine ) )
		break; // If NULL get out

	// Try to zap the space after a single file name
	if ( (lp = lstrfind( lpszCmdLine, " " )) )
		*lp = '\0'; // If we found a space, zap it

	// Copy the full path name into szFileName
#ifdef _MAC
	lstrcpy( szFileName, lpszCmdLine );
#else	
	if ( lstrchr( lpszCmdLine, '\\' ) )
		lstrcpy( szFileName, lpszCmdLine );
	else
		{ // If not a full path name...
		GetCurrentDir( szFileName, sizeof(FNAME) );
		FixPath( szFileName );
		lstrcat( szFileName, lpszCmdLine );
		}
#endif

	// Now we're done with lpszCmdLine, so set it up for the next loop
	if ( lp ) // If we had found a space, there might be more file names
			lpszCmdLine = lp + 1;
	else	lpszCmdLine += lstrlen(lpszCmdLine); // Point to nothing

	// Special handling of documents passed by a client
////if ( bPassedByClient )
////	{ // Loop through documents to see if it's already open
		for ( i=0; i<NumDocs(); i++ )
			{
			hWnd = GetDoc(i);
			if ( !(lpImageDoc = (LPIMAGE)GetWindowLong( hWnd, GWL_IMAGEPTR )))
				continue;
			if ( !StringsEqual( lpImageDoc->CurFile, szFileName ) )
				continue;
			// It's already open....
			SendMessage( hClientAstral, WM_MDIACTIVATE, (WPARAM)hWnd, 0L );
			if ( bPassedByClient )
				lpImageDoc->fOwnedByClient = YES;
			szFileName[0] = '\0'; // Zap it
			bGotImage = YES;
			break;
			}
////	}

	// If we have a file name, open it...
	if ( *szFileName )
		{
		if ( AstralImageLoad( NULL, szFileName, MAYBE, YES ) )
			bGotImage = YES;
		}

	// If the printing option was passed, print it and close it
	if ( *lpPrint && lpImage )
		{
		SendMessage(hWndAstral, WM_COMMAND, IDM_PRINT, 0L );
		CloseImage( NO, NULL );
		}
	}

if ( !bGotImage )
	{
	if ( !idCurrentRoom )
		{
	    GoRoom (hInstAstral, -1, FALSE);
		return( FALSE );
		}
	// If no image was opened via the command line, go to the opening screen
	SendMessage( hWindow, WM_COMMAND, IDM_NEW, 0L );
	}

if ( (hWnd = AstralDlgGet(IDD_MAIN)) && !IsWindowVisible( hWnd ) )
	ShowWindow( hWnd, SW_SHOW );

return( TRUE );
}
Beispiel #6
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 );
}