BOOL NativePrefsDlg::InitDialog () { ERROR2IF ( mpParams == NULL, FALSE, "NativePrefsDlg::InitDialog called after duff initialisation?!" ); //First, do we have a selection? Application *pApp = GetApplication(); ERROR2IF(pApp == NULL, FALSE,"NativePrefsDlg::InitDialog - no application!"); SelRange *pRange = pApp->FindSelection(); ERROR2IF(pRange == NULL, FALSE,"NativePrefsDlg::InitDialog - no selection range!"); DocRect ClipRect = pRange->GetBoundingRect(); BOOL fThereIsASelection=!ClipRect.IsEmpty(); //Now, is there a selection? if (fThereIsASelection) { // Yes. So ungrey both the buttons for selecting the nodes to export. EnableGadget(_R(IDC_NATIVEOPTS_SELECT), TRUE); EnableGadget(_R(IDC_NATIVEOPTS_DRAWING), TRUE); //Now, which of those buttons should be selected? switch ( mpParams->GetExportSel () ) { case SELECTION: // Choose the export pair of buttons. SetLongGadgetValue(_R(IDC_NATIVEOPTS_SELECT), FALSE); SetLongGadgetValue(_R(IDC_NATIVEOPTS_DRAWING), TRUE); break; default: case DRAWING: // Choose the export pair of buttons. SetLongGadgetValue(_R(IDC_NATIVEOPTS_SELECT), TRUE); SetLongGadgetValue(_R(IDC_NATIVEOPTS_DRAWING), FALSE); break; } } else { //No. So grey the SELECTION button and ungrey //the DRAWING button EnableGadget(_R(IDC_NATIVEOPTS_SELECT), FALSE); EnableGadget(_R(IDC_NATIVEOPTS_DRAWING), TRUE); // And we must select the DRAWING button for the export area controls. SetLongGadgetValue(_R(IDC_NATIVEOPTS_SELECT), TRUE); SetLongGadgetValue(_R(IDC_NATIVEOPTS_DRAWING), FALSE); } return TRUE; }
BOOL OpNudge::IsNudgeOK(BOOL dx,BOOL dy) { // Get the selection SelRange* pSel = GetApplication()->FindSelection(); ERROR2IF(pSel == NULL,FALSE,"Awooga, NULL sel range"); // Find out the bounding rectangle of the selection DocRect BoundingRect = pSel->GetBoundingRect(); // Find out the Pasteboard rect DocRect PasteRect; Spread* pSpread = pOurDoc->GetSelectedSpread(); if (pSpread==NULL) PasteRect = BoundingRect; else { // Try to make the pasteboard grow if necessary to include the new object position // This is very quick if the pasteboard is large enough already. pSpread->ExpandPasteboardToInclude(BoundingRect); // And re-read the bounding rectangle of the selection, as the pasteboard resize may have // caused the origin of our entire coordinate space to have moved! Argh! BoundingRect = pSel->GetBoundingRect(); // BoundingRect.Translate(dx,dy); // This is in Document Coords, so we need to convert it PasteRect = pSpread->GetPasteboardRect(); pSpread->DocCoordToSpreadCoord(&PasteRect); } // Assume the nudge will be OK. BOOL NudgeOK = TRUE; if (PasteRect.ContainsRect(BoundingRect)) { // Untranslated bounds fit inside pasteboard rect, so we must complain if the bounds // do not fit *after* translation // Translate the bounds by the nudge values BoundingRect.Translate(dx,dy); // Do the translated bounds still fit entirely in the pasteboard rect? NudgeOK = PasteRect.ContainsRect(BoundingRect); } else { // The original bounds overlap the pasteboard rect, so we must complain if the user // nudges the bounds completely out of sight if (PasteRect.IsIntersectedWith(BoundingRect)) { // The original bounds intersect with the pasteboard rect BoundingRect.Translate(dx,dy); // Only allow the nudge if the translated bounds still overlap with the spread. NudgeOK = PasteRect.IsIntersectedWith(BoundingRect); } } // If the nudge is OK, we may need to scroll the DocView? /* Jim, 12/9/96 - removed this because we don't want to scroll to show opn nudges if (NudgeOK) { DocCoord Coord(0,0); // If nudging left or right, pick the min or max X coord if (dx != 0) { if (dx < 0) Coord.x = BoundingRect.lox; else Coord.x = BoundingRect.hix; } // If nudging up or down, pick the max or min Y coord if (dy != 0) { if (dy < 0) Coord.y = BoundingRect.loy; else Coord.y = BoundingRect.hiy; } // If we have picked a coord, ensure that this coord is visible in the selected spread // of the selected DocView if (Coord != DocCoord(0,0)) { DocView* pDocView = DocView::GetSelected(); if (pDocView != NULL) pDocView->ScrollToShow(&Coord); } } */ return NudgeOK; }