BOOL CImage::DuplicateSelObjects() { LPOBJECT lpDupObject; OBJECTLIST DupList; LPOBJECT lpObject; RECT rUpdate; WORD wGroupID, wOldGroupID, wLastGroupID; if (!ImgEditInit( this, ET_OBJECT, UT_DELETEOBJECTS, GetBase() )) return(FALSE); DupList.lpHead = DupList.lpTail = NULL; lpObject = NULL; while (lpObject = GetSelObject(lpObject)) { if (!(lpDupObject = ObjDuplicateObject(lpObject))) { ObjDeleteObjects(&DupList, ST_ALL); return(FALSE); } ObjAddTail(&DupList, (LPPRIMOBJECT)lpDupObject); } wLastGroupID = wGroupID = GetNextGroupID(); lpDupObject = NULL; while (lpDupObject = (LPOBJECT)ObjGetNextObject(&DupList, (LPPRIMOBJECT)lpDupObject, YES)) { if (!lpDupObject->wGroupID || lpDupObject->wGroupID >= wLastGroupID) continue; wOldGroupID = lpDupObject->wGroupID; lpDupObject->wGroupID = wGroupID; lpObject = lpDupObject; while (lpObject = (LPOBJECT)ObjGetNextObject(&DupList, (LPPRIMOBJECT)lpObject, YES)) { if (lpObject->wGroupID == wOldGroupID) lpObject->wGroupID = wGroupID; } ++wGroupID; } RemoveObjectMarquee(this); ObjDeselectAll(&ObjList); while (lpObject = (LPOBJECT)ObjGetNextObject(&DupList, NULL, YES)) { ObjUnlinkObject(&DupList, (LPPRIMOBJECT)lpObject); ObjSelectObject( (LPPRIMOBJECT)lpObject, YES ); // Select the new object ObjAddTail( &ObjList, (LPPRIMOBJECT)lpObject ); // Add to the image's list lpObject->fUndoDeleted = YES; } ImgEditedObject(this, GetBase(), IDS_UNDODUPLICATE, NULL); GetSelObjectRect(&rUpdate, NO); UpdateImage(this, &rUpdate, YES); SetupMiniViews(NULL, NO); return(TRUE); }
afx_msg void CServerView::OnHideObjMarquee() { if (!Control.Retail ) return; if (STOP) return; CServerDoc* pDoc = GetDocument(); LPIMAGE lpImage = pDoc->GetImage(); RemoveObjectMarquee(lpImage); lpImage->UseObjectMarquee = !lpImage->UseObjectMarquee; }
void CServerView::init_paste( LPOBJECT lpObject, CPoint *pt) { RECT rImage, rObjects; CServerDoc* pDoc = GetDocument(); ASSERT(pDoc); LPIMAGE lpImage = pDoc->m_lpImage; ASSERT(lpImage); int xData = RectWidth(&lpObject->rObject); int yData = RectHeight(&lpObject->rObject); // get location rect to center to object on rImage = m_lpDisplay->FileRect; int x, y; // center the object around point if (pt) { x = pt->x; y = pt->y; Display2File(GetSafeHwnd(), (LPINT)&x, (LPINT)&y); x = x - (xData/2); y = y - (yData/2); } // center the object in the location rectangle else { x = ( rImage.left + rImage.right - xData ) / 2; y = ( rImage.top + rImage.bottom - yData ) / 2; } if (x < rImage.left) x = rImage.left; if (y < rImage.top) y = rImage.top; OffsetRect(&lpObject->rObject, x, y); RemoveObjectMarquee(lpImage); // make this object temporary, so it will go away if // the paste is cancelled lpObject->StorageType = ST_TEMPORARY; // save the selection state in case of cancel SaveSelectedObjects(lpImage); ImgAddNewObject(lpImage, lpObject); ImgGetSelObjectRect(lpImage, &rObjects, YES); UpdateImage(lpImage, &rObjects, YES); }
void CObjectsPrefPage::HandleOK() { HWND hActiveWnd; if (Control.MultipleObjects != m_bObjects) PictPubApp.EnableObjectMenu(AfxGetMainWnd()->GetMenu()); LPIMAGE lpImage = NULL; if (hActiveWnd = GetActiveDoc()) lpImage = GetImagePtr(hActiveWnd); if (!Control.UseMaskAndObjects && Control.UseMaskAndObjects != m_bObjectMasks) { Control.UseMaskAndObjects = YES; RemoveObjectMarquee(lpImage); Control.UseMaskAndObjects = NO; } CPPPropertyPage::HandleOK(); }