void CMiscPrefPage::HandleOK() { HWND hActiveWnd; LPIMAGE lpImage = NULL; if (hActiveWnd = GetActiveDoc()) lpImage = GetImagePtr(hActiveWnd); if (lpImage && m_MaskTint != Control.MaskTint && ImgGetViewMode(lpImage) == VM_SLIME) { RECT rRect; rRect = GetDisplayPtr(hActiveWnd)->DispRect; AstralToWindowsRect(&rRect); ::InvalidateRect( hActiveWnd, &rRect, FALSE ); } if (!Control.IndependentSettings && Control.IndependentSettings != m_IndependentSettings) SetCommonSettings(); if (Control.UseTablet) { Control.UseTablet = TabletStart(); if (!Control.UseTablet) { LPSTR lp; AstralStr(IDS_NOTABLET, &lp); ::MessageBox(PictPubApp.Get_hWndAstral(), lp, szAppName, MB_ICONHAND | MB_OK | MB_TASKMODAL); } } CPPPropertyPage::HandleOK(); }
void ImgEditMaskUndo( LPIMAGE lpImage ) /***********************************************************************/ { LPOBJECT lpBase; LPMASK lpMask; RECT rUndo; lpBase = ImgGetBase(lpImage); if (!lpBase->AlphaDirty) return; if (lpBase->fBothDirty) return; AstralSetRectEmpty(&rUndo); if (ImgGetMask(lpImage) && lpBase->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) ) { RemoveMaskMarquee(lpImage); ImgGetMaskUpdateRect(lpImage, YES, NO, &rUndo); } ObjEditUndo(lpImage, lpBase, NO, YES); if (lpMask = ImgGetMask(lpImage)) { if (lpBase->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) ) { RemoveMaskMarquee(lpImage); ImgGetMaskUpdateRect(lpImage, YES, NO, &rUndo); } else rUndo = lpMask->Pixmap.UndoRect; } if (rUndo.right >= rUndo.left) { OffsetRect(&rUndo, lpBase->rObject.left, lpBase->rObject.top); File2DispRect(&rUndo, &rUndo); AstralToWindowsRect(&rUndo); InvalidateRect(lpImage->hWnd, NULL, NO); } }
void CImage::EditMaskUndo() { LPOBJECT lpBase; LPMASK lpMask; RECT rUndo; lpBase = GetBase(); if (!lpBase->AlphaDirty) return; if (lpBase->fBothDirty) return; AstralSetRectEmpty(&rUndo); if (GetMask() && lpBase->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) ) { RemoveMaskMarquee(this); GetMaskUpdateRect(YES, NO, &rUndo); } ObjEditUndo(lpBase, NO, YES); if (lpMask = GetMask()) { if (lpBase->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) ) { RemoveMaskMarquee(this); GetMaskUpdateRect(YES, NO, &rUndo); } else rUndo = lpMask->Pixmap.UndoRect; } if (rUndo.right >= rUndo.left) { OffsetRect(&rUndo, lpBase->rObject.left, lpBase->rObject.top); File2DispRect(GetActiveDoc(), &rUndo, &rUndo); AstralToWindowsRect(&rUndo); InvalidateRect(GetActiveDoc(), NULL, NO); } }
BOOL ZoomPaint( HWND hWnd ) /************************************************************************/ { PAINTSTRUCT ps; HDC hDC; RECT rPaint; LPDISPLAY lpDisplay; LPIMAGE lpImage; hDC = BeginPaint(hWnd, &ps); lpDisplay = (LPDISPLAY)GetDisplayPtr(hWnd); lpImage = (LPIMAGE)GetImagePtr (hWnd); if (lpImage && lpDisplay) { rPaint = ps.rcPaint; AstralToWindowsRect(&rPaint); lpImage->Paint(hWnd,hDC,&rPaint,NULL); // will paint the invert box AstralSetRectEmpty(&lpDisplay->UpdateRect); } EndPaint(hWnd, &ps); return (TRUE); }
void ImgEditUndo( LPIMAGE lpImage, BOOL fEditUndo, BOOL fMaskUndo ) /***********************************************************************/ { RECT rUndo, rUndoMask, rTemp; LPOBJECT lpBase, lpObject, lpNext; BOOL fNewSize, fSetupMiniViews, fRemoveMarquee, fUndoDelete; BOOL fUndoAlpha, fUndoData; int nDeleted; LPMASK lpMask; if (!lpImage) return; // Initialize things for updating the display fNewSize = fSetupMiniViews = fUndoDelete = NO; AstralSetRectEmpty(&rUndo); AstralSetRectEmpty(&rUndoMask); // loop through objects doing undo lpBase = ImgGetBase(lpImage); lpObject = NULL; while (lpObject = ImgGetNextObjectEx(lpImage, lpObject, NO, NO, fEditUndo)) { // See if this is an object we are undoing if (fEditUndo) { // check for special undo processing of a deleted object if (lpObject->fDeleted) { if (Control.UndoObjects && !ImgIsSelectedObject(lpImage, lpBase)) continue; } else if (Control.UndoObjects && !ImgIsSelectedObject(lpImage, lpObject)) continue; } // Only handle mask undo for the base object if (fMaskUndo) { if (lpObject != lpBase || lpObject->fBothDirty || !lpObject->AlphaDirty) continue; } fUndoData = fUndoAlpha = NO; // Do preprocess for doing a data undo if (fEditUndo) { if (lpObject->DataDirty) fUndoData = YES; // See if we need to undo the alpha for this object if ((lpObject != lpBase) && lpObject->lpAlpha && lpObject->AlphaDirty) fUndoAlpha = YES; if (!fUndoData && !fUndoAlpha) continue; // check to see and undoing/redoing deleted objects will change // the select state, if so undraw the object marquee if (lpObject == lpBase && lpObject->DataUndoType & UT_DELETEOBJECTS) { fUndoDelete = YES; fRemoveMarquee = NO; nDeleted = 0; lpNext = lpObject; while (lpNext = ImgGetNextObjectEx(lpImage, lpNext, YES, NO, YES)) { if (lpNext->fUndoDeleted) ++nDeleted; else if (lpNext->fDeleted && lpNext->fSelected) { fRemoveMarquee = YES; break; } } if (ImgGetSelObject(lpImage, NULL) == lpBase && !fRemoveMarquee) { if (ImgCountObjects(lpImage) - nDeleted <= 1) fRemoveMarquee = YES; } if (fRemoveMarquee) RemoveObjectMarqueeEx(lpImage, NO); } } else // fMaskUndo if (!lpObject->AlphaDirty) continue; else fUndoAlpha = YES; // do a preprocess for undoing the mask caused either by // a mask undo or by an edit function that also edits the mask if (((lpObject == lpBase) && fEditUndo && lpObject->fBothDirty) || fMaskUndo) { if ( lpObject->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) ) { // if the undo is going to delete the mask, // we need to undraw the mask if (ImgGetMask(lpImage)) { RemoveMaskMarquee(lpImage); if (ImgGetMaskUpdateRect(lpImage, YES, NO, &rTemp)) AstralUnionRect(&rUndoMask, &rUndoMask, &rTemp); } // if the undo is going to create the mask, // we need to undraw the object marquees if // not in mask and object marquee mode else { if (!Control.UseMaskAndObjects) RemoveObjectMarqueeEx(lpImage, NO); } } } // Actually do the undo ObjEditUndo(lpImage, lpObject, fUndoData, fUndoAlpha); // do a postprocess for undoing the mask if ((lpMask = ImgGetMask(lpImage)) && (((lpObject == lpBase) && fEditUndo && lpObject->fBothDirty) || fMaskUndo)) { // if the undo is going to add the mask, we need to redraw the mask if (lpObject->AlphaUndoType & (UT_CREATEMASK|UT_DELETEMASK) ) { if (ImgGetMaskUpdateRect(lpImage, YES, NO, &rTemp)) AstralUnionRect(&rUndoMask, &rUndoMask, &rTemp); } else // just redraw the undo area for the mask AstralUnionRect(&rUndoMask, &rUndoMask, &lpMask->Pixmap.UndoRect); } // Setup rectangle for undoing deletion of objects // Handled specially so that moved objects will still undo // and redo properly if (fEditUndo) { if (lpObject == lpBase && lpObject->DataUndoType & UT_DELETEOBJECTS) { lpNext = lpObject; while (lpNext = ImgGetNextObjectEx(lpImage, lpNext, YES, NO, YES)) { if (lpNext->fDeleted || lpNext->fUndoDeleted) AstralUnionRect(&rUndo, &rUndo, &lpNext->rObject); } fSetupMiniViews = YES; } if (lpObject->Pixmap.fNewFrame) { /* if new frame, cause window to be redisplayed */ if (lpObject == lpBase) fNewSize = YES; else { if (!fNewSize) { AstralUnionRect(&rUndo, &rUndo, &lpObject->rObject); AstralUnionRect(&rUndo, &rUndo, &lpObject->rUndoObject); } } } else { AstralSetRectEmpty(&rTemp); if (fUndoData) AstralUnionRect(&rTemp, &rTemp, &lpObject->Pixmap.UndoRect); if (fUndoAlpha) AstralUnionRect(&rTemp, &rTemp, &lpObject->lpAlpha->Pixmap.UndoRect); if (rTemp.right >= rTemp.left) { if (!fNewSize) { OffsetRect(&rTemp, lpObject->rObject.left, lpObject->rObject.top); AstralUnionRect(&rUndo, &rUndo, &rTemp); } } } } } // now redisplay whatever changes are necessary for the undo if (fNewSize) { SetupImagePalette(lpImage, NO, YES); if (lpBase->Pixmap.UndoFrame) { if ((FrameXSize(lpBase->Pixmap.UndoFrame) == FrameXSize(lpBase->Pixmap.EditFrame)) && (FrameYSize(lpBase->Pixmap.UndoFrame) == FrameYSize(lpBase->Pixmap.EditFrame))) fNewSize = NO; } if (fNewSize) UpdateImageSize(); else UpdateImageEx(lpImage, NULL, YES, YES, YES); if ( Tool.hRibbon ) SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L ); } else { if (rUndoMask.right >= rUndoMask.left) { File2DispRect(&rUndoMask, &rUndoMask); AstralToWindowsRect(&rUndoMask); InvalidateRect(lpImage->hWnd, NULL, NO); } if (rUndo.right >= rUndo.left) AnimateUndo( &rUndo ); } if (fUndoDelete) if ( Tool.hRibbon ) SendMessage( Tool.hRibbon, WM_CONTROLENABLE, 0, 0L ); if (fSetupMiniViews) SetupMiniViews(NULL, NO); }