void InitSpin( HWND hDlg, LFIXED fSetX, LFIXED fSetY, int flag) /************************************************************************/ { LPIMAGE lpImage; LPFRAME lpFrame; LFIXED fMin, fMax; RECT iRect; int res; if( !( lpImage = GetActiveImage() ) ) return; lpFrame = ImgGetBaseEditFrame( lpImage ); ImgGetImageRect( lpImage, &iRect ); res = FrameResolution( lpFrame ); if (flag & 1) { fMax = FGET( iRect.right, res ); fMin = FGET( -iRect.right, res ); InitDlgItemSpinFixed( hDlg, IDC_POS_X, fSetX, YES, fMin, fMax ); } if (flag & 2) { fMax = FGET( iRect.bottom, res ); fMin = FGET( -iRect.bottom, res ); InitDlgItemSpinFixed( hDlg, IDC_POS_Y, fSetY, YES, fMin, fMax ); } SetUnitLabels(hDlg); }
LOCAL BOOL Pos_OnInitDialog(HWND hDlg, HWND hWndFocus, LPARAM lParam) /************************************************************************/ { RECT rSel; LPIMAGE lpImage; LPFRAME lpFrame; LFIXED XPos, YPos; int res; if(!(lpImage = GetActiveImage())) return(FALSE); lpFrame = ImgGetBaseEditFrame( lpImage ); res = FrameResolution( lpFrame ); ImgGetSelObjectRect(lpImage, &rSel, YES); XPos = FGET(rSel.left, res); YPos = FGET(rSel.top, res); CheckComboItem( hDlg, IDC_PREF_UNITS, IDC_PREF_UNITINCHES, IDC_PREF_UNITPIXELS, IDC_PREF_UNITINCHES ); lpPosParms = (LPPOSOBJECTS_PARMS)lParam; Edit.SaveUnits = Control.Units; SetUnitResolution( 0 ); InitSpin( hDlg, XPos, YPos,3); CenterPopup( hDlg ); return(TRUE); }
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); }
LPTR FAR EXPORT ExportDataPointer(int x, int y, BOOL bModify) { LPIMAGE lpImage = GetActiveImage(); int iPixelCount = iExportXSize - x; if (x <= iExportXSize || (y <= iExportYSize)) ImgGetLine( lpImage, NULL, x, y, iPixelCount, lpExportBuffer ); return(lpExportBuffer); }
LOCAL void TextureFill_HandleEnable(HWND hDlg, int fFlags) /************************************************************************/ { FRMDATATYPE Type = FDT_RGBCOLOR; ImgGetInfo(GetActiveImage(), NULL, NULL, NULL, &Type); HandleMergeCombo(hDlg, IDC_MERGEMODE, TRUE, Texture.TextureMergeMode, 0L); // The following code also goes below and into the shape accelerator ControlEnable( hDlg, IDC_TRANSPARENT_SCROLL, CANDOTRANSPARENCY(Type) ); ControlEnable( hDlg, IDC_TRANSPARENT, CANDOTRANSPARENCY(Type) ); }
LOCAL void Vignette_HandleEnable(HWND hDlg, int fFlags) /************************************************************************/ { FRMDATATYPE Type = FDT_RGBCOLOR; ImgGetInfo(GetActiveImage(), NULL, NULL, NULL, &Type); HandleMergeCombo(hDlg, IDC_MERGEMODE, TRUE, Vignette.VigMergeMode, 0L); // The following code also goes below and into the shape accelerator ControlEnableGroup( hDlg, IDC_FIRST_MODEL, IDC_LAST_MODEL, ISCOLOR(Type)); ControlEnable( hDlg, IDC_COLORMODEL, ISCOLOR(Type)); ControlEnable( hDlg, IDC_TRANSPARENT, CANDOTRANSPARENCY(Type) ); }
LOCAL void Flood_HandleEnable(HWND hDlg, int fFlags) /************************************************************************/ { FRMDATATYPE Type = FDT_RGBCOLOR; ImgGetInfo(GetActiveImage(), NULL, NULL, NULL, &Type); HandleMergeCombo(hDlg, IDC_MERGEMODE, TRUE, Fill.FloodMergeMode, 0L); ControlEnableGroup( hDlg, IDC_FIRST_MODEL, IDC_LAST_MODEL, ISCOLOR(Type)); ControlEnable( hDlg, IDC_COLORMODEL, ISCOLOR(Type)); ControlEnable( hDlg, IDC_FLOODRANGE, Type != FDT_LINEART); ControlEnable( hDlg, IDC_TRANSPARENT, CANDOTRANSPARENCY(Type)); ControlEnable( hDlg, IDC_FLOODFADE, CANDOTRANSPARENCY(Type)); }
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 ); }
void ESChildPreActionControl::OnPaintClient(_DC* pDC, Rect* pRectDC, Rect* pRectClient){ Image* pImage = m_bActiveState ? GetActiveImage() : GetDefaultImage(); COLORREF crText = m_bActiveState ? m_crTextActive : m_crTextDefault; float fZoomCX = 1.0f, fZoomCY = 1.0f; m_pOwner->GetZoom(fZoomCX, fZoomCY); if( fZoomCX == 1.0f ) m_nTextLeftOffsetScaled = m_nTextLeftOffset; Size szImage; Rect rcClient = GetClientRect(); if( pImage && !pImage->IsNull() ){ szImage.SetSize(pImage->GetWidth()*fZoomCX, pImage->GetHeight()*fZoomCY); if( m_bActiveState ){ if( fZoomCX == 1.0f && fZoomCY == 1.0f ) m_pOwner->DrawBackground(pDC, pRectDC, pRectClient, rcClient, FillMode::FillMode_OmitBorderedImage, RGB(0, 0, 0), pImage, m_rcOmitborder); else{ if( !m_imageActiveBg_Scaled.IsNull() && m_imageActiveBg_Scaled.GetWidth() == szImage.cx && m_imageActiveBg_Scaled.GetHeight() == szImage.cy ) m_pOwner->DrawBackground(pDC, pRectDC, pRectClient, rcClient, FillMode::FillMode_OmitBorderedImage, RGB(0, 0, 0), &m_imageActiveBg_Scaled, m_rcOmitborder_Scaled); else{ ImageDef hDestScaled = NULL; if( pImage->ScaleBitmap(ScaleMode::ScaleMode_Bilinier, szImage.cx, szImage.cy, Rect(0, 0, szImage.cx, szImage.cy), hDestScaled, true) ){ m_imageActiveBg_Scaled.Destroy(); m_imageActiveBg_Scaled.Attach(hDestScaled); m_rcOmitborder_Scaled = Rect(m_rcOmitborder.left*fZoomCX, m_rcOmitborder.top*fZoomCY, m_rcOmitborder.right*fZoomCX, m_rcOmitborder.bottom*fZoomCY); m_pOwner->DrawBackground(pDC, pRectDC, pRectClient, rcClient, FillMode::FillMode_OmitBorderedImage, RGB(0, 0, 0), &m_imageActiveBg_Scaled, m_rcOmitborder_Scaled); } } } } else{ if( fZoomCX == 1.0f && fZoomCY == 1.0f ) m_pOwner->DrawBackground(pDC, pRectDC, pRectClient, rcClient, FillMode::FillMode_OmitBorderedImage, RGB(0, 0, 0), pImage, m_rcOmitborder); else{ if( !m_imagDefaultBg_Scaled.IsNull() && m_imagDefaultBg_Scaled.GetWidth() == szImage.cx && m_imagDefaultBg_Scaled.GetHeight() == szImage.cy ) m_pOwner->DrawBackground(pDC, pRectDC, pRectClient, rcClient, FillMode::FillMode_OmitBorderedImage, RGB(0, 0, 0), &m_imagDefaultBg_Scaled, m_rcOmitborder_Scaled); else{ ImageDef hDestScaled = NULL; if( pImage->ScaleBitmap(ScaleMode::ScaleMode_Bilinier, szImage.cx, szImage.cy, Rect(0, 0, szImage.cx, szImage.cy), hDestScaled, true) ){ m_imagDefaultBg_Scaled.Destroy(); m_imagDefaultBg_Scaled.Attach(hDestScaled); m_rcOmitborder_Scaled = Rect(m_rcOmitborder.left*fZoomCX, m_rcOmitborder.top*fZoomCY, m_rcOmitborder.right*fZoomCX, m_rcOmitborder.bottom*fZoomCY); m_pOwner->DrawBackground(pDC, pRectDC, pRectClient, rcClient, FillMode::FillMode_OmitBorderedImage, RGB(0, 0, 0), &m_imagDefaultBg_Scaled, m_rcOmitborder_Scaled); } } } } } // Draw text. {{ Size szText; if( m_sLabelLocal.length() ){ Font fontText; m_fontText.StretchedTextFont(&fontText, fZoomCX, fZoomCY); fontText.GetTextSize(&m_sLabelLocal, szText); FONTDef pFontOld = pDC->SelectObject(fontText); // Translate from window pixel to DC pixel.{{ Point ptLabel; ptLabel.x = ((rcClient.left + m_nTextLeftOffsetScaled /*(rcClient.Width() - szText.cx)/2*/) - pRectClient->left) + pRectDC->left; ptLabel.y = ((rcClient.top + (rcClient.Height() - szText.cy)/2) - pRectClient->top) + pRectDC->top; //}} pDC->SetBkMode (TRANSPARENT); pDC->SetTextColor (crText); pDC->ExtTextOut (ptLabel.x, ptLabel.y, ETO_CLIPPED, pRectDC, m_sLabelLocal); pDC->SelectObject (pFontOld); } ESChildControl::OnPaintClient(pDC, pRectDC, pRectClient); }
LOCAL void Pos_OnCommand(HWND hDlg, int id, HWND hControl, UINT codeNotify) /************************************************************************/ { int idUnits; BOOL Bool; LFIXED fx, fy; LPIMAGE lpImage; int res; switch (id) { case IDC_PREF_UNITS: if ( !(idUnits = HandleCombo( hDlg, id, codeNotify )) ) break; fx = GetDlgItemSpinFixed( hDlg, IDC_POS_X, &Bool, YES); fy = GetDlgItemSpinFixed( hDlg, IDC_POS_Y, &Bool, YES); Control.Units = idUnits; SetUnitInfo((UNIT_TYPE)(Control.Units-IDC_PREF_UNITINCHES), Control.UnitRes, Control.Points); InitSpin( hDlg, fx, fy,3); break; case IDC_POS_X: if (codeNotify == EN_KILLFOCUS) { fx = GetDlgItemSpinFixed( hDlg, IDC_POS_X, &Bool, YES); InitSpin( hDlg, fx, 0,1); } else { if ( GetFocus() != GetDlgItem( hDlg, id ) ) break; if ( codeNotify != EN_CHANGE ) break; GetDlgItemSpinFixed( hDlg, IDC_POS_X, &Bool, YES ); } break; case IDC_POS_Y: if (codeNotify == EN_KILLFOCUS) { fy = GetDlgItemSpinFixed( hDlg, IDC_POS_Y, &Bool, YES); InitSpin( hDlg, 0, fy,2); } else { if ( GetFocus() != GetDlgItem( hDlg, id ) ) break; if ( codeNotify != EN_CHANGE ) break; GetDlgItemSpinFixed( hDlg, IDC_POS_Y, &Bool, YES ); } break; case IDOK: if(lpImage = GetActiveImage()) { fx = GetDlgItemSpinFixed( hDlg, IDC_POS_X, &Bool, YES ); fy = GetDlgItemSpinFixed( hDlg, IDC_POS_Y, &Bool, YES ); ImgGetInfoEx(lpImage, NULL, NULL, NULL, NULL, &res); Control.Units = Edit.SaveUnits; // get pixels lpPosParms->iBaseRes = res; lpPosParms->XOffset = FMUL(res,fx); lpPosParms->YOffset = FMUL(res,fy); AstralDlgEnd( hDlg, TRUE ); } break; case IDCANCEL: Control.Units = Edit.SaveUnits; AstralDlgEnd( hDlg, FALSE ); break; default: break; } }
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; } }
long DoCommand( HWND hWindow, UINT idCmd, HWND hControl, UINT codeNotify ) /***********************************************************************/ { FNAME szFileName; BOOL bPrint; LPTSTR lpszCmdLine; LPIMAGE lpImage; lpImage = GetActiveImage(); //if ( lpImage && idCmd >= PS_FIRST_PLUGIN && idCmd <= PS_LAST_PLUGIN ) if( idCmd >= PS_FIRST_PLUGIN && idCmd <= PS_LAST_PLUGIN ) { DeactivateTool(); return( HandlePluginCommand( lpImage, MDIFrame_wParam, MDIFrame_lParam )); } //if ( lpImage && idCmd >= PS_FIRST_ADOBEPLUGIN && idCmd <= PS_LAST_ADOBEPLUGIN ) if( idCmd >= PS_FIRST_ADOBEPLUGIN && idCmd <= PS_LAST_ADOBEPLUGIN ) { DeactivateTool(); return( HandleAdobePluginCommand( lpImage, idCmd )); } // handle messages which should be passed to the ribbons if (WITHIN(idCmd, IDM_FIRST_RIBBONMENU, IDM_LAST_RIBBONMENU)) { if(Tool.hRibbon) SEND_WM_COMMAND(Tool.hRibbon, idCmd, hControl, codeNotify); } switch (idCmd) { 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(); lstrcpy(szFileName, Control.RecallImage[idCmd - IDM_RECALLIMAGE0]); if( OPTION3 && Control.Retail ) DoLowResLoad( 0, szFileName ); else if( OPTION1 && Control.Retail ) PictPubApp.OpenDocumentFileImmediate( szFileName, OM_FASTBITS ); else AstralImageLoadBG( 0, szFileName, 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 = (LPTR)lParam) ) break; */ HandleCommandLine( hWindow, lpszCmdLine, &bPrint ); break; case PS_SERVICE_ABORT_BEGIN: case PS_SERVICE_ABORT_CHECK: case PS_SERVICE_ABORT_END: case PS_SERVICE_ABORT_BEGIN_NOESC: case PS_SERVICE_BUF_DELETE: case PS_SERVICE_GET_IMAGE_INFO: case PS_SERVICE_PRIVATE_INI: case PS_SERVICE_BUF_ALLOC: case PS_SERVICE_BUF_LOCK1: case PS_SERVICE_BUF_UNLOCK1: case PS_SERVICE_BUF_NEXTLINE: case PS_SERVICE_BUF_LINEPTR: case PS_SERVICE_BUF_LINE_TABLE: return( HandlePluginMessage( lpImage, MDIFrame_wParam, MDIFrame_lParam )); break; case IDM_RUN0: case IDM_RUN1: case IDM_RUN2: case IDM_RUN3: case IDM_RUN4: case IDM_RUN5: case IDM_RUN6: case IDM_RUN7: case IDM_RUN8: case IDM_RUN9: RunTask( hWindow, idCmd, IDS_RUNTASKLIST ); break; case IDM_CLOSEIT: DeactivateTool(); PictPubApp.CloseDocumentFile(lpImage); break; default: return( FALSE ); } return( TRUE ); }
BOOL PlayMacro(LPCMDLIST lpCmdList, LPTSTR lpFileName, int nRepeat, BOOL fSequenceAll, LPLIST lpMacroList, HWND hParent, int PhotoCDResOverride, LPTSTR lpMacroName) /***********************************************************************/ { LPIMAGE lpImage; LPCMDLIST lpNewList; int nActivates, iCount; ITEMID idCommand; STRING szString, szAppName; BOOL fError; BOOL fSequence, fCmdSequence, fCopyPackets; LIST MacroList; LPCMDPKT lpCmdPkt, lpNextPkt; MACROSETUP Setup; COMMAND_TYPE CommandType; HWND hDlg = NULL; lpAbortProc = NULL; if (!hParent) hParent = PictPubApp.Get_hWndAstral(); // see if we need to copy our packets fCopyPackets = nRepeat > 1; if (!lpMacroList) { // read in the entire macro file for faster processing if (!ReadMacro(lpFileName, &MacroList)) return(FALSE); lpMacroList = &MacroList; } // count the number of activates in the macro file // because it affects sequencing nActivates = CountType(lpMacroList, CT_ACTIVATE); // turn of macro play mode and tell the world MacroMode = MM_PLAY; if ( AstralStrEx( IDS_APPNAME, szAppName, sizeof(szAppName) ) ) { if ( AstralStrEx( IDS_MACROPLAY, szString, sizeof(szString) ) ) { lstrcat( szAppName, szString ); SetWindowText( PictPubApp.Get_hWndAstral(), szAppName ); } } // reset untitled number so that if a macro is played it // can deal with untitled images the same Control.UntitledNo = 0; // If no command list passed in to work on (Macro Batch Mode) // then get command list for active image if (!lpCmdList) { if (lpImage = GetActiveImage()) lpCmdList = lpImage->lpCmdList; else lpCmdList = NULL; } // See if the macro contains any low res loads and // if so ask to user if he'd like to convert them // to hi res loads and if so do the convert if (FindCommand(lpMacroList, IDS_CMD_LOWRESLOAD)) if (AstralAffirm(IDS_CONVERTLOWRES)) if (!ConvertLowResLoad(lpMacroList)) { DestroyPacketList(lpMacroList); return(FALSE); } // disable all mouse and keyboard input during macro play EnableWindow(hParent, FALSE); // if not in a threading environment and caller wants us // to display a progress dialog, then set it up and do it if (!Control.UseThreading) { iCount = ListGetCount(lpMacroList) - nActivates; iCount *= nRepeat; Setup.iTotal = iCount; Setup.idDialog = IDD_MACRO_STATUS; Setup.lpFileName = NULL; hDlg = AstralDlgParam( YES, PictPubApp.GetResourceHandle(), hParent, IDD_MACRO_STATUS, DlgMacroStatusProc, (LPARAM)(LPVOID)&Setup ); if (hDlg) { if (lpMacroName) { STRING szString; GetWindowText(hDlg, szString, sizeof(szString)); lstrcat(szString, _T(" - ")); lstrcat(szString, lpMacroName); SetWindowText(hDlg, szString); } UpdateWindow(hDlg); } } // Repeat macro nRepeat number of times fError = FALSE; while (--nRepeat >= 0 && !fError) { if (lpAbortProc && (*lpAbortProc)()) break; // back to beginning of macro file lpNextPkt = (LPCMDPKT)ListGetHead(lpMacroList); // initialize sequencing fSequence = fSequenceAll; while (!fError && lpNextPkt) { if (lpAbortProc && (*lpAbortProc)()) { fError = TRUE; break; } // get the packet to work on if (fCopyPackets) { lpCmdPkt = CopyPacket(lpNextPkt); if (!lpCmdPkt) { fError = TRUE; break; } } else { ListUnlink(lpMacroList, lpNextPkt); lpCmdPkt = lpNextPkt; } // get command id and parms for this command idCommand = lpCmdPkt->idCommand; // Find out whether this command requires sequencing // set it here, so command can change it if needed before // we actually set fSequence fCmdSequence = GetCommandSequence(idCommand); CommandType = GetCommandType(idCommand); // Handle the different types of commands switch (CommandType) { case CT_LOAD: // create new command list for load lpNewList = CreateCommandList(); if (lpNewList) { ListAddTail(&lpNewList->PacketList, lpCmdPkt); // if we already have a command list containing commands, // kick off the execution of those commands before we // switch to the new command list if (lpCmdList && !ListIsEmpty(&lpCmdList->PacketList)) { PlaybackCommands(lpCmdList); // if some command in the command list affects // sequencing force the whole command list to // be processed if (fSequence) { FlushCommands(lpCmdList); fSequence = fSequenceAll; } } // setup new command list for us to work with lpCmdList = lpNewList; lpCmdList->PhotoCDResOverride = PhotoCDResOverride; // If there are any activates in this macro make sure a // command that creates an image processes immediately if (nActivates) { PlaybackCommands(lpCmdList); FlushCommands(lpCmdList); fSequence = fSequenceAll; fCmdSequence = NO; // already sequenced } } break; case CT_COPY: // Make sure we have a command list to work with if (!lpCmdList) { Message(IDS_NOIMAGETOWORKON); fError = TRUE; break; } // Just add this command to the command list ListAddTail(&lpCmdList->PacketList, lpCmdPkt); // If there are any activates in this macro make sure a // command that creates an image processes immediately if (nActivates) { PlaybackCommands(lpCmdList); FlushCommands(lpCmdList); fSequence = fSequenceAll; fCmdSequence = NO; // already sequenced } break; case CT_SAVE: case CT_EDIT: case CT_MASK: case CT_MODE: case CT_EDITUNDO: case CT_MASKUNDO: case CT_EDITOBJ: case CT_CLOSE: // Make sure we have a command list to work with if (!lpCmdList) { Message(IDS_NOIMAGETOWORKON); fError = TRUE; break; } if (CommandType == CT_SAVE) { PlaybackCommands(lpCmdList); if (!lpCmdList->ThreadData.lpImage) { Message(IDS_NOIMAGETOWORKON); fError = TRUE; break; } } // Just add this command to the command list ListAddTail(&lpCmdList->PacketList, lpCmdPkt); if (CommandType != CT_CLOSE) break; case CT_ACTIVATE: // Program or commands that affect window activation // are processed here switch (idCommand) { case IDS_CMD_CLOSE: case IDS_CMD_ACTIVATEWINDOW: { // if we already have a command list containing commands, // kick of the execution of those commands before we // switch to the new command list if (lpCmdList && !ListIsEmpty(&lpCmdList->PacketList)) { PlaybackCommands(lpCmdList); // if some command in the command list affects // sequencing force the whole command list to // be processed if (fSequence) { FlushCommands(lpCmdList); fSequence = fSequenceAll; } } // if this was a close command, then wack the command list pointer if (idCommand == IDS_CMD_CLOSE) lpCmdList = NULL; else { // now process the activate and get a new command list lpNewList = ProgActivateWindow( (LPACTIVATEWINDOW_PARMS)lpCmdPkt->lpParms); // setup the new command list if we got one if (lpNewList) lpCmdList = lpNewList; else { CommandError(idCommand); fError = TRUE; } // activate don't go through command processing // so we have to free it up here FreeUpPacket(lpCmdPkt); } } break; default: break; } break; default: break; } // if command just handled requires sequencing // set sequencing flag if (fCmdSequence) fSequence = YES; if (fCopyPackets) // get next command packet in macro list lpNextPkt = (LPCMDPKT)ListGetNext(lpNextPkt); else // head of list will be next one if we're not copying lpNextPkt = (LPCMDPKT)ListGetHead(lpMacroList); } } // get rid of macro list DestroyPacketList(lpMacroList); // if we already have a command list containing commands, // kick off the execution of those commands if (lpCmdList && !ListIsEmpty(&lpCmdList->PacketList)) { PlaybackCommands(lpCmdList); if (fSequenceAll) FlushCommands(lpCmdList); } // turn off the macro mode EnableWindow(hParent, TRUE); if ( AstralStrEx( IDS_APPNAME, szAppName, sizeof(szAppName) ) ) SetWindowText( PictPubApp.Get_hWndAstral(), szAppName ); // if we have a progress dialog, nuke it if (hDlg) AstralDlgEnd(hDlg, TRUE); // if we are display the macro status for another modal dialog // make sure the main app stuff is still disabled if (hParent != PictPubApp.Get_hWndAstral()) { EnableOverlappedWindow( PictPubApp.Get_hWndAstral(), FALSE ); EnableWindow(PictPubApp.Get_hWndAstral(), FALSE); } MacroMode = MM_NONE; return(TRUE); }
void COlelistBox::OnLButtonDown(UINT nFlags, CPoint point) { FNAME *lpResult; CDataItem *pDataItem; LPIMAGE lpImage = GetActiveImage(); CServerDoc *pDoc = PictPubApp.GetDocument(lpImage); int num; CRect r,rr; BOOL bCreateDoc = (pDoc == NULL); CPoint p; CListBox::OnLButtonDown(nFlags, point); FORWARD_WM_LBUTTONUP(GetSafeHwnd(), point.x, point.y, nFlags, ::SendMessage); lpResult = ExtBsr_GetSelection(GetParent()->GetSafeHwnd(), &num); if (!lpResult || num != 1) return; lstrcpy(Names.Clipboard, lpResult[0]); if (LookupExtFileN(Names.Clipboard, Names.PasteImageFile, IDN_CLIPBOARD, NO)) { if (bCreateDoc) { LPFRAME lpFrame = FrameOpen(FDT_GRAYSCALE, 1, 1, 72); if (lpFrame) { POSITION Pos; lpImage = CreateImage(NULL,lpFrame,NULL,NULL, IDN_PP,IDC_SAVECT,IMG_DOCUMENT,NULL); if (!lpImage) { FrameClose(lpFrame); return; } pDoc = (CServerDoc*)PictPubApp.OpenDocumentFile( lpImage->CurFile, lpImage, FALSE); if (!pDoc) { DestroyImage(lpImage); return; } } else return; } if (pDoc) { pDataItem = new CDataItem(pDoc, Names.Clipboard, YES); GetParent()->GetWindowRect(&r); ClientToScreen(&point); GetItemRect(GetCurSel(), &rr); ClientToScreen(&rr); p.x = rr.Width() / 2; p.y = rr.Height() / 2; // NOTE!!the pDataItem will be internally destroyed once the drag/drop // operation is completed therefore we do not need to delete the pDataItem pDataItem->DoDragDrop(&rr, p, FALSE, DROPEFFECT_COPY, &r); if (bCreateDoc) pDoc->OnCloseDocument(); } } else if(Names.Clipboard[0]) { // deleted the file...notify the browser UpdatePasteFromFile(NULL); } }
void VignetteProc( HWND hWindow, UINT msg, int x, int y, UINT32 Option ) /************************************************************************/ { RECT Rect; BOOL fShift; POINT pt; static int Type, Style; static BOOL fConstrain; static RECT SelectRect; int res; FRMDATATYPE type; LPIMAGE lpImage; STRING szString; GRADIENT_PARMS parms; switch (msg) { case WM_CREATE: // The first mouse down message if (!IsOnImage(hWindow, x, y)) break; ImgGetInfo(GetActiveImage(), NULL, NULL, NULL, &type); if (type == FDT_LINEART) { AstralStrEx( IDC_TOOLNAMESTART+IDC_VIGNETTE, szString, sizeof(szString) ); Message(IDS_NOTWITHLINEART, (LPSTR)szString); break; } AstralUpdateWindow(hWindow); Tool.bActive = YES; // SetMaskingState( x, y ); break; case WM_LBUTTONDOWN: Type = Vignette.Gradient; fConstrain = ( Type == IDC_VIGSQUARE || Type == IDC_VIGCIRCLE ); AstralSetRectEmpty( &SelectRect ); if ( Type == IDC_VIGCIRCLE || Type == IDC_VIGELLIPSE ) Style = SL_ELLIPSE; else if ( Type == IDC_VIGRADIAL || Type == IDC_VIGLINEAR ) Style = SL_LINE; else Style = SL_BOX; pt.x = x; pt.y = y; StartSelection( hWindow, NULL, &SelectRect, Style | SL_SPECIAL, pt, 0L ); break; case WM_LBUTTONUP: Tool.bActive = NO; Rect = SelectRect; // make a copy before it gets ordered EndSelection( hWindow, NULL, &SelectRect, Style, YES ); lpImage = (LPIMAGE)GetImagePtr ( hWindow ); res = FrameResolution(ImgGetBaseEditFrame(lpImage)); type = FrameType(ImgGetBaseEditFrame(lpImage)); parms.VigOpacity = Vignette.VigOpacity; parms.VigMergeMode = Vignette.VigMergeMode; parms.iBaseRes = res; parms.x1 = Rect.left; parms.y1 = Rect.top; parms.x2 = Rect.right; parms.y2 = Rect.bottom; GetActiveColorFromType(type, &parms.StartColor); GetAlternateColorFromType(type, &parms.EndColor); parms.Gradient = Vignette.Gradient; parms.RepeatCount = Vignette.RepeatCount; parms.SoftTransition = Vignette.SoftTransition; parms.Midpoint = Vignette.Midpoint; parms.VigColorModel = Vignette.VigColorModel; ProcessCommand(lpImage->lpCmdList, IDS_CMD_GRADIENT, &parms); break; case WM_MOUSEMOVE: // sent when ToolActive is on fShift = SHIFT; pt.x = x; pt.y = y; UpdateSelection( hWindow, NULL, &SelectRect, Style, pt, fConstrain^CONSTRAINASPECT, 1L, 1L, MOVEKEY||Window.fRButtonDown, FROMCENTER); break; case WM_LBUTTONDBLCLK: break; case WM_DESTROY: // The cancel operation message if (!Tool.bActive) break; Tool.bActive = NO; EndSelection( hWindow, NULL, &SelectRect, Style, YES ); break; } }
BOOL ExportImageDLL( LPSTR lpExportFile ) { HMODULE hModule; FARPROC lpClockCursor = NULL; FARPROC lpDataPointer = NULL; EXPORTPROC lpStartProc; EXPORTPROC lpProcessProc; EXPORTPROC lpEndProc; LPFRAME lpFrame; EXPPARMS parms; BOOL fSuccess = FALSE; LPIMAGE lpImage; lpImage = GetActiveImage(); if (!lpImage) goto Exit; lpFrame = ImgGetBaseEditFrame(lpImage); if (!lpFrame) goto Exit; if (!(hModule = (HMODULE)AstralLoadLibrary(lpExportFile))) goto Exit; lpStartProc = (EXPORTPROC)GetProcAddress(hModule, "_ExportStart"); lpProcessProc = (EXPORTPROC)GetProcAddress(hModule, "_ExportProcess"); lpEndProc = (EXPORTPROC)GetProcAddress(hModule, "_ExportEnd"); if ( !lpStartProc || !lpProcessProc || !lpEndProc ) goto Exit; iExportXSize = FrameXSize( lpFrame ); iExportYSize = FrameYSize( lpFrame ); iExportDepth = FrameDepth( lpFrame ); iExportResolution = FrameResolution( lpFrame ); lpClockCursor = MakeProcInstance( (FARPROC)ExportClockCursor, PictPubApp.Get_hInstAstral() ); lpDataPointer = MakeProcInstance( (FARPROC)ExportDataPointer, PictPubApp.Get_hInstAstral() ); AllocLines( &lpExportBuffer, 1, iExportXSize, max(1, iExportDepth)); parms.hInstance = PictPubApp.Get_hInstAstral(); parms.hWnd = GetActiveWindow(); parms.lpszFileName = lpImage->CurFile; parms.XSize = iExportXSize; parms.YSize = iExportYSize; parms.Depth = iExportDepth; parms.Resolution = iExportResolution; parms.StatusCallback = (LPROC)lpClockCursor; parms.DataPointer = (LPTRPROC)lpDataPointer; if (!lpClockCursor || !lpDataPointer || !lpExportBuffer) goto Exit; if ((*lpStartProc)((LPEXPPARMS)&parms)) { MessageStatus( IDS_PLEASEWAIT ); if ((*lpProcessProc)((LPEXPPARMS)&parms)) { fSuccess = TRUE; (*lpEndProc)((LPEXPPARMS)&parms); } } Exit: if (lpClockCursor) FreeProcInstance((FARPROC)lpClockCursor); if (lpDataPointer) FreeProcInstance((FARPROC)lpDataPointer); if (lpExportBuffer) FreeUp(lpExportBuffer); lpExportBuffer = NULL; if (hModule) FreeLibrary(hModule); MessageStatus( 0 ); return(fSuccess); }
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 */ } } }
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); }