BOOL PopupWindow( HWND hParent, ITEMID idControl, ITEMID idDlg, DLGPROC lpDlgControl) /***********************************************************************/ { HWND hControl, hPopup; RECT Rect; hControl = GetDlgItem(hParent, idControl); if (!hControl) return(FALSE); GetWindowRect(hControl, &Rect); if (!LBUTTON) return(FALSE); hPopup = (HWND)AstralDlg( YES, hInstAstral, hParent, idDlg, lpDlgControl ); if (!hPopup) return(FALSE); SetWindowPos(hPopup, NULL, Rect.right, Rect.top, 0, 0, SWP_NOSIZE|SWP_NOZORDER); SetWindowPos(hPopup, NULL, Rect.right, Rect.top, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW|SWP_NOZORDER); UpdateWindow(hPopup); while (LBUTTON) ; AstralDlgEnd( hPopup, TRUE ); return(TRUE); }
LOCAL void About_OnCommand( HWND hDlg, int id, HWND hControl, UINT codeNotify ) /************************************************************************/ { switch (id) { case IDC_ABOUTAPP: PopupWindow(hDlg, id, id, DlgDriversProc); break; case IDC_MGX: case IDC_PICTPUB: case IDC_PHOTOMAGIC: case IDC_DESIGNER: case IDC_CHARISMA: case IDC_DRAWPLUS: case IDC_ORGCHART: case IDC_ABCFLOWCHART: case IDC_SNAPGRAFX: case IDC_CLIPART: case IDC_TECHSUPT: case IDC_PHOTOCREDITS: if ( bTrack ) KillTimer( hDlg, bTrack ); bTrack = NO; EnableWindow(hDlg, FALSE); AstralDlg( NO, PictPubApp.GetResourceHandle(), hDlg, id, DlgWarningProc ); EnableWindow(hDlg, TRUE); bScroll = NO; SetTimer( hDlg, bTrack = TRUE, 2, NULL ); break; case IDOK: case IDCANCEL: if ( bTrack ) KillTimer( hDlg, bTrack ); bTrack = NO; AstralDlgEnd( hDlg, FALSE ); break; default: break; } }
afx_msg void CInPlaceFrame::OnPalette() { BOOL bCreate = FALSE; if (m_hPaletteDlg == NULL) { if (m_hPaletteDlg = AstralDlg(DLG_MODELESS_MULTIPLE, PictPubApp.GetResourceHandle(), this->GetSafeHwnd(), IDD_PALETTE, DlgPaletteProc)) { bCreate = TRUE; ShowHidePalette(TRUE); return; } } if (m_hPaletteDlg && !bCreate) { if ( ::IsWindowVisible( m_hPaletteDlg ) ) ShowHidePalette(FALSE); else ShowHidePalette(TRUE); } }
afx_msg void CServerView::OnViewFull() { if (STOP) return; AstralDlg( NO, PictPubApp.GetResourceHandle(), GetSafeHwnd(), IDD_VIEWFULL, DlgFullScreenViewProc ); }
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 */ } } }
BOOL WINPROC EXPORT DlgGalleryProc( /***********************************************************************/ HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { FNAME szTitleSave; BOOL bUntitledSave; switch (msg) { case WM_INITDIALOG: SetControlFont (hDlg, IDC_GALLERY_T1); SetControlFont (hDlg, IDC_GALLERY_T2); SetControlFont (hDlg, IDC_GALLERY_T3); SetControlFont (hDlg, IDC_GALLERY_T4); RibbonInit( hDlg ); // fall thru... case WM_CONTROLENABLE: case WM_DOCACTIVATED: break; case WM_SETCURSOR: return( SetupCursor( wParam, lParam, IDD_FILL ) ); case WM_ERASEBKGND: break; // handle ERASEBKGND and do nothing; PAINT covers everything case WM_PAINT: LayoutPaint( hDlg ); break; case WM_CLOSE: AstralDlgEnd( hDlg, NO|2); break; case WM_MEASUREITEM: case WM_DRAWITEM: return( OwnerDraw( hDlg, msg, lParam, NO ) ); case WM_CTLCOLOR: return( (BOOL)SetControlColors( (HDC)wParam, hDlg, (HWND)LOWORD(lParam), HIWORD(lParam) ) ); case WM_COMMAND: switch (wParam) { case IDC_GALLERY_T1: // Save to Disk SendMessage( hWndAstral, WM_COMMAND, IDM_SAVESPECIAL, 0L ); break; case IDC_GALLERY_T2: // Print SendMessage( hWndAstral, WM_COMMAND, IDM_PRINT, 0L ); break; case IDC_GALLERY_T3: // To Floppy bSaving = TRUE; AstralDlg (NO|2, hInstAstral, hDlg, IDD_SAVEFLOPPY, (DLGPROC)DlgFloppyProc); if (szFileSpec[0] != 0) { bUntitledSave = lpImage->fUntitled; lpImage->fUntitled = FALSE; lstrcpy (szTitleSave, lpImage->CurFile); lstrcpy (lpImage->CurFile, szFileSpec); SendMessage (hWndAstral, WM_COMMAND, IDM_SAVESPECIAL, 0L); lstrcpy (lpImage->CurFile, szTitleSave); lpImage->fUntitled = bUntitledSave; } break; case IDC_GALLERY_T4: // From Floppy bSaving = FALSE; AstralDlg (NO|2, hInstAstral, hDlg, IDD_LOADFLOPPY, (DLGPROC)DlgFloppyProc); if (szFileSpec[0] != 0) { AstralImageLoad (IDN_ART, szFileSpec, MAYBE, NO); } break; default: return( FALSE ); } default: return( FALSE ); } return( TRUE ); }
BOOL ConvertTo(LPIMAGE lpImage, int iFunction) /***********************************************************************/ { CONVERT_PARMS parms; DITHER_TYPE DitherType = DT_NONE; if (ImgInMaskEditMode(lpImage)) return(FALSE); ImgGetTypeInfo(lpImage, &parms.cmsInfo.src); switch (iFunction) { case IDM_CONVLA: FrameSetTypeInfo(&parms.cmsInfo.dst, FDT_LINEART); break; case IDM_CONVSP: FrameSetTypeInfo(&parms.cmsInfo.dst, FDT_LINEART); DitherType = DT_SCATTER; break; case IDM_CONVCT: FrameSetTypeInfo(&parms.cmsInfo.dst, FDT_GRAYSCALE); break; case IDM_CONVPALETTE: FrameSetTypeInfo(&parms.cmsInfo.dst, FDT_PALETTECOLOR); if ( !AstralDlg( NO, PictPubApp.GetResourceHandle(), PictPubApp.Get_hWndAstral(), IDD_CONVERTTO, DlgConvertProc )) return( NO ); DitherType = Convert.ConvertDitherType; break; case IDM_CONVRGBCOLOR: if (Control.CMSEnabled && IsSrcPTSelected(&parms.cmsInfo.src.ptInfo)) { CMSINFO CmsInfo; CmsInfo.src.DataType = FDT_CMYKCOLOR; if (!CmsGetDstPT(&CmsInfo)) return(FALSE); else parms.cmsInfo.dst = CmsInfo.dst; } else { FrameSetTypeInfo(&parms.cmsInfo.dst, FDT_RGBCOLOR); } break; case IDM_CONVCMYKCOLOR: if (Control.CMSEnabled && IsSrcPTSelected(&parms.cmsInfo.src.ptInfo)) { CMSINFO CmsInfo; CmsInfo.src.DataType = FDT_RGBCOLOR; if (!CmsGetDstPT(&CmsInfo)) return(FALSE); else parms.cmsInfo.dst = CmsInfo.dst; } else { FrameSetTypeInfo(&parms.cmsInfo.dst, FDT_CMYKCOLOR); } break; case IDM_COLORMANAGED: if (!CmsGetSrcDstPT(&parms.cmsInfo)) return(TRUE); break; } parms.DitherType = DitherType; parms.ConvertType = Convert.ConvertType; parms.iLevels = Convert.ConvertColors; lstrcpy(parms.szPalette, Convert.ConvertPalette); ProcessCommand(lpImage->lpCmdList, IDS_CMD_CONVERT, &parms); return(TRUE); }
bool AskRegistrationCode( void ) /****************************************************************************/ { HWND hWnd = GetActiveWindow(); return AstralDlg( NO, hInstAstral, hWnd, idDialog[iType], (DLGPROC)DlgRegisterProc ); }
long DoOpenDlg( /************************************************************************/ HWND hDlg, int idDlg, WORD idType, LPSTR pFileNameOut, BOOL fSavingIn) { int iReturn; FNAME szExtension, szStartDir; int iStartDrive; fSaving = fSavingIn; idDataType = NULL; bImageOpen = idDlg == IDD_OPEN || idDlg == IDD_SAVEAS; idFileType = idType; if (bImageOpen) { idFileType = bound(idFileType, IDN_ART, IDN_BMP); if (fSaving) { if (!Readers[idFileType-IDN_ART].bSave[FrameDepth(ImgGetBaseEditFrame(lpImage))]) idFileType = IDN_ART; } else { if (!Readers[idFileType-IDN_ART].bOpen) idFileType = IDN_ART; } } fUntitled = lpImage && lpImage->fUntitled; if (bImageOpen && fSaving && !fUntitled) { lstrcpy( szSaveName, pFileNameOut ); lstrcpy( szFileSpec, pFileNameOut ); stripfile( szFileSpec ); FixPath( szFileSpec ); LookupExtension( idFileType, szExtension ); lstrcat( szFileSpec, szExtension ); } else { GetFileLocation( idFileType, szFileSpec ); } /* Initialize some values used in DlgOpenProc */ wFileAttr = 0; iStartDrive = CURRENTDRIVE; CURRENTDIR( szStartDir, sizeof(FNAME) ); idOpen = 0; do { if (idOpen) idDlg = idOpen; else idOpen = idDlg; iReturn = AstralDlg( NO|2, hInstAstral, hDlg, idDlg, DlgOpenProc ); } while (idOpen != idDlg); CHDRIVE( iStartDrive ); //CHDIR( szStartDir ); if ( !iReturn ) { pFileNameOut[0] = '\0'; return( NULL ); } lstrcpy( pFileNameOut, szFileSpec ); SetFileLocation( idFileType, szFileSpec ); return( MAKELONG( idFileType, idDataType ) ); }
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 ); }