OpMouldLibSel Class Reference

Provides a library of undoable functions for moulding objects. More...

#include <moldedit.h>

Inheritance diagram for OpMouldLibSel:

SelOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject OpCopyMouldShape OpCreateNewMould OpPasteMouldShape OpRectangularEnvelope OpRectangularPerspective OpRemoveMould OpPasteEnvelope OpPastePerspective List of all members.

Public Member Functions

 OpMouldLibSel ()
 OpMouldLibSel() constructor.

Protected Member Functions

BOOL CreateNewMould (Path *pShape, MouldSpace m_space, BOOL FitSelection, BOOL LockAspect)
 Creates a complete mould object from the selected objects. Certain rules are used for creating moulds when moulds are already selected. If the selection contains mould objects only, then each mould will have its geometry changed to that of m_space. If however there are a selection of unlike objects, they will all be placed in a new mould whose geometry is specified in this function call.
BOOL AllMouldObjects (List *pNodeList)
 Scans the list of nodes provided. If any objects which are not node moulds are found, false is returned.
NodeMouldDoCreateMould (Path *pShape, MouldSpace mSpace, List *NodeList, DocRect *pBounds, BOOL ScaleToFit, BOOL LockAspect)
 Creates a complete mould object positioned on the next pointer of the last node in the list. All nodes in the list will move inside this new mould object.
BOOL DoRemoveAllMoulds (List *pNodeList)
 Removes the mould from around an object. To do this it.
BOOL DoRemoveMould (NodeMould *pMould, BOOL PutOnClip)
 Removes the mould from around an object. To do this it.
BOOL DoReplaceAllMoulds (List *pNodeList, Path *pShape, MouldSpace mSpace, BOOL ScaleToFit, BOOL LockAspect)
BOOL DoReplaceMould (NodeMould *pMould, Path *pShape, MouldSpace mSpace, BOOL ScaleToFit, BOOL LockAspect)
BOOL DoRecordGeometry (NodeMould *pMould)
 Asks the geometry to record its own internal data and then records the type of geometry on the undo, ready to be replaced.
BOOL DoCreateOrReplaceMould (SelRange *pSelected, Path *pShape, MouldSpace m_space, BOOL ScaleToFit, BOOL LockAspect)

Static Protected Member Functions

static BOOL IsAMouldSelected (NodeMould **pNodeMould)
 Scans the selection hunting for a selected mould object. It will return a pointer to the object if found and if the return pointer is none null. Hopefully this will be replaced at some point by Selection->FindObject(type).

Private Member Functions

DocRectFindScaleRect (DocRect *pSRect, DocRect *pDRect, BOOL ScaleToFit, BOOL LockAspect)
 Internal scaling rectangle calculator. Using the flags scaletofit, lock a destination rectangle is build from the souce. If both flags are false a null pointer will be returned else a pointer to pDRect.
BOOL LocaliseMouldAttributes (NodeMould *pMould)
BOOL LocaliseObjectAttrs (NodeRenderableInk *pParent, NodeRenderableInk *pInkNode)
BOOL HideAllMouldAttrs (NodeMould *pMould)

Detailed Description

Provides a library of undoable functions for moulding objects.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/01/95

Definition at line 123 of file moldedit.h.


Constructor & Destructor Documentation

OpMouldLibSel::OpMouldLibSel  ) 
 

OpMouldLibSel() constructor.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/01/95
See also:
-

Definition at line 154 of file moldedit.cpp.

00155 {
00156     // Dummy constructor
00157 }


Member Function Documentation

BOOL OpMouldLibSel::AllMouldObjects List pNodeList  )  [protected]
 

Scans the list of nodes provided. If any objects which are not node moulds are found, false is returned.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/03/95
Parameters:
pNodeList = a list of object pointers to objects to mould. [INPUTS]
Returns:
TRUE if the list contains mould objects only, at the top level. FALSE if there are other object types.

Reimplemented in OpCreateNewMould.

Definition at line 312 of file moldedit.cpp.

00313 {
00314     NodeListItem* CurItem = (NodeListItem*)(pNodeList->GetHead());
00315     if (!CurItem) return FALSE;
00316 
00317     while (CurItem)
00318     {
00319         if (CurItem->pNode->GetRuntimeClass() != CC_RUNTIME_CLASS(NodeMould))
00320             return FALSE;
00321         CurItem = (NodeListItem*)(pNodeList->GetNext(CurItem));
00322     }
00323     return TRUE;
00324 }

BOOL OpMouldLibSel::CreateNewMould Path pShape,
MouldSpace  m_space,
BOOL  FitSelection,
BOOL  LockAspect
[protected]
 

Creates a complete mould object from the selected objects. Certain rules are used for creating moulds when moulds are already selected. If the selection contains mould objects only, then each mould will have its geometry changed to that of m_space. If however there are a selection of unlike objects, they will all be placed in a new mould whose geometry is specified in this function call.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/12/94
Parameters:
pShape = A path to use as a mould shape [INPUTS] mSpace = The mould space to create, currently only envelope and perspective spaces are defined ScaleToFit = If TRUE then the shape will be scaled to fit over the bounds of the objects. LockAspect = If TRUE then the paths current dimensions are scaled so that the minor dimension fits over pBounds
- [OUTPUTS]
Returns:
TRUE if CreateNewMould has successfully created the mould object and children FALSE if failed.

Definition at line 188 of file moldedit.cpp.

00189 {
00190     ERROR3IF(pShape==NULL,"CreateNewMould called with a NULL shape pointer");
00191 
00192     // Obtain the current selections 
00193     SelRange* Selected = GetApplication()->FindSelection();
00194     if (!Selected)
00195         return FALSE;
00196 
00197     // Trash the old selection bounds
00198     Range Rnge = (*Selected);
00199     if (!DoInvalidateNodesRegions(Rnge,FALSE,FALSE))
00200         return FALSE;
00201 
00202     // Remember the selection before the operation
00203     if (!DoStartSelOp(FALSE,TRUE))
00204         return FALSE;
00205 
00206     // Check that we are actually allowed to do this operation
00207     ObjChangeFlags cFlags;
00208     cFlags.MultiReplaceNode=TRUE;
00209     ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
00210 
00211     // Mark nodes that will allow this to happen, and error if no nodes will let it happen
00212     if (!Selected->AllowOp(&ObjChange))
00213     {
00214         ERROR3("AllowOp() returned FALSE, i.e. op should have been greyed out");
00215         return FALSE;
00216     }
00217 
00218     // using this list create or replace the mould bits
00219     BOOL ok = DoCreateOrReplaceMould(Selected, pShape, m_space, FitSelection, LockAspect);
00220     if (!ok)
00221         return FALSE;
00222 
00223     // Update all the changed nodes, i.e. tell all the parents of the children that have been effected
00224     ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
00225     return UpdateChangedNodes(&ObjChange);
00226 }

NodeMould * OpMouldLibSel::DoCreateMould Path pShape,
MouldSpace  mSpace,
List NodeList,
DocRect pBounds,
BOOL  ScaleToFit,
BOOL  LockAspect
[protected]
 

Creates a complete mould object positioned on the next pointer of the last node in the list. All nodes in the list will move inside this new mould object.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/12/94
Parameters:
pShape = A path to use as a mould shape [INPUTS] mSpace = The mould space to create, currently only envelope and perspective spaces are defined NodeList = A list of tree object nodes to place in the Mould pBounds = The bounding box of the objects in the node list ScaleToFit = If TRUE then the shape will be scaled to fit over the bounds of the objects. LockAspect = If TRUE then the paths current dimensions are scaled so that the minor dimension fits over pBounds
Returns:
TRUE if DoCreateMould has successfully created the mould object and children FALSE if failed.

Definition at line 356 of file moldedit.cpp.

00362 {
00363     ERROR2IF(pShape==NULL, NULL, "OpMouldLibSel::DoCreateMould() called with a NULL shape pointer");
00364     ERROR2IF(mSpace==MOULDSPACE_UNDEFINED, NULL, "pMouldLib::DoCreateMould() called with an undefined space type");
00365     ERROR2IF(NodeList==NULL, NULL, "OpMouldLibSel::DoCreateMould() called with a NULL list pointer");
00366 
00367     // initialise various locals
00368     BOOL ok;
00369 
00370     NodeListItem* CurItem = (NodeListItem*)(NodeList->GetTail());
00371     if (!CurItem)
00372         return NULL;
00373 
00374     Node* Context = CurItem->pNode;
00375     if (!Context)
00376         return NULL; 
00377 
00378     // create a mould parent and insert it in the tree
00379     NodeMould* pMouldParent;
00380     ALLOC_WITH_FAIL( pMouldParent, new NodeMould, this);
00381     if (!pMouldParent)
00382         return NULL;
00383 
00384     // give the parent mould object a shape and mould space to work with and stick it
00385     // in the tree
00386             CALL_WITH_FAIL(pMouldParent->CreateGeometry(mSpace), this, ok);
00387     if (ok) CALL_WITH_FAIL(DoInsertNewNode(pMouldParent, Context, NEXT, FALSE, TRUE, TRUE, FALSE), this, ok);
00388     if (!ok)
00389     {   
00390         delete pMouldParent;
00391         return NULL;
00392     }
00393 
00394     // check the shape we've been given is fine and lovely  
00395     UINT32 errID;
00396     if (!pMouldParent->GetGeometry()->Validate(pShape, errID))
00397     {
00398         SetNextMsgHelpContext(errID);
00399         ERROR1(NULL, errID);
00400     }
00401 
00402     // build a destination scale rectangle
00403     DocRect DRect, *pRect;
00404     pRect = FindScaleRect(pBounds, &DRect, ScaleToFit, LockAspect);
00405 
00406     // Create and add a mould shape object
00407     NodeMouldPath* pNodeMPath = pMouldParent->AddNewMouldShape(pShape,pRect,this);
00408     if (!pNodeMPath)
00409         return NULL;
00410 
00411     // set the geometry using this new mould shape
00412     ok = pMouldParent->GetGeometry()->Define(&pNodeMPath->InkPath, pBounds);
00413     if (!ok)
00414         return NULL;
00415 
00416     // now create the mould group object
00417     NodeMouldGroup* pMouldGroup = pMouldParent->AddNewMouldGroup(this);
00418     if (!pMouldGroup)
00419         return NULL;
00420 
00421     // and fill it with our object list
00422     if (!pMouldParent->FillMouldGroup(pMouldGroup, NodeList, this))
00423         return NULL;
00424 
00425     // Now build the moulder object and its list structure
00426     NodeMoulder* pMoulder = pMouldParent->AddNewMoulder(pMouldParent, LASTCHILD, this);
00427     if (!pMoulder)
00428         return NULL;
00429 
00430     // create all the moulded objects inside the moulder
00431     if (!pMoulder->CreateMouldedObjects(pMouldGroup, pMouldParent->GetGeometry(), this)) 
00432         return NULL;
00433 
00434     return pMouldParent; 
00435 }

BOOL OpMouldLibSel::DoCreateOrReplaceMould SelRange pSelected,
Path pShape,
MouldSpace  m_space,
BOOL  FitSelection,
BOOL  LockAspect
[protected]
 

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/03/95
Parameters:
pShape = A path to use as a mould shape [INPUTS] mSpace = The mould space to create, currently only envelope and perspective spaces are defined ScaleToFit = If TRUE then the shape will be scaled to fit over the bounds of the objects. LockAspect = If TRUE then the paths current dimensions are scaled so that the minor dimension fits over pBounds
Returns:
TRUE if the job has been done FALSE if not

Definition at line 253 of file moldedit.cpp.

00258 {
00259     BOOL ok;
00260 
00261     // Create a list of all the selected nodes
00262     List* pNodeList = pSelected->MakeListOfNodes();
00263     if (pNodeList==NULL)
00264         return FALSE;
00265 
00266     // Get the bounds of the selection
00267     DocRect Bounds = pSelected->GetBoundingRect();
00268 
00269     if (AllMouldObjects(pNodeList))
00270     {
00271         // Ohh arr, we need to replace all selected mould shapes, here goes!!
00272         ok = DoReplaceAllMoulds(pNodeList, pShape, m_space, FitSelection, LockAspect);
00273     }
00274     else
00275     {       
00276         // call the mould builder
00277         NodeMould* pMould = DoCreateMould(pShape, m_space, pNodeList, &Bounds, FitSelection, LockAspect);
00278         ok = (pMould!=NULL);
00279 
00280         if (ok)
00281         {
00282             // Recalculate the mould's bounding box
00283             pMould->InvalidateBoundingRect();
00284             GetApplication()->UpdateSelection();
00285             ok = DoInvalidateNodeRegion(pMould, TRUE);
00286         }
00287     }
00288 
00289     // delete all elements in our compiled list
00290     while (!pNodeList->IsEmpty())
00291         delete (NodeListItem*)(pNodeList->RemoveHead());
00292     delete pNodeList;
00293 
00294     return ok;
00295 }

BOOL OpMouldLibSel::DoRecordGeometry NodeMould pMould  )  [protected]
 

Asks the geometry to record its own internal data and then records the type of geometry on the undo, ready to be replaced.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/01/95
Parameters:
pMould = pointer to a mould object [INPUTS]
Returns:
TRUE if successfully recorded the mould geometry FALSE if failed.

Definition at line 991 of file moldedit.cpp.

00992 {
00993     ActionCode Act;
00994 
00995     // call the actions static init function to get the action going.
00996     Act = RecordGeometryAction::DoRecord(this,pMould);
00997     if (Act==AC_FAIL)
00998         return FALSE;
00999 
01000     return TRUE;
01001 }

BOOL OpMouldLibSel::DoRemoveAllMoulds List pNodeList  )  [protected]
 

Removes the mould from around an object. To do this it.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/01/95
Parameters:
pNodeList = pointer to a list of selected nodes to process [INPUTS]
Returns:
TRUE if successfully removed all the mould objects FALSE if failed.

Definition at line 545 of file moldedit.cpp.

00546 {
00547     BOOL ok, constrain, putonclip;
00548     INT32 count = 0;
00549 
00550     NodeListItem* CurItem = (NodeListItem*)(pNodeList->GetHead());
00551     if (!CurItem) 
00552         return FALSE;
00553 
00554     constrain=KeyPress::IsConstrainPressed();
00555 
00556     while (CurItem)
00557     {
00558         if (CurItem->pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeMould))
00559         {
00560             NodeMould* pMould = (NodeMould*)(CurItem->pNode);
00561 
00562             count++;
00563             putonclip = (constrain && (count==1));
00564 
00565             CALL_WITH_FAIL(DoRemoveMould(pMould, putonclip),this,ok);
00566             if (!ok) 
00567                 return FALSE;
00568         }
00569         CurItem = (NodeListItem*)(pNodeList->GetNext(CurItem));
00570     }
00571     return TRUE;
00572 }

BOOL OpMouldLibSel::DoRemoveMould NodeMould pMould,
BOOL  PutOnClip
[protected]
 

Removes the mould from around an object. To do this it.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/01/95
Parameters:
pMould = pointer to a mould object [INPUTS]
Returns:
TRUE if successfully removed the mould object FALSE if failed.

Definition at line 591 of file moldedit.cpp.

00592 {
00593     ERROR2IF(pMould==NULL, FALSE, "OpMouldBuild::DoCreateMould() called with a NULL shape pointer");
00594 
00595     // Ask the mould if it's OK to do the op.
00596     // If not, pretend that everything went OK, because we wouldn't have got called unless at least
00597     // one selected mould could be removed.  This is ensured by OpRemoveMould::GetState
00598     ObjChangeFlags cFlags;
00599     cFlags.MultiReplaceNode = TRUE;
00600     ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,pMould,this);
00601     if (!pMould->AllowOp(&ObjChange))
00602         return TRUE;
00603 
00604     // Make sure each child contains the correct attributes.
00605     //if (!DoLocaliseCommonAttributes(pMould))
00606 //      return FALSE;
00607 
00608     if (PutOnClip)
00609     {
00610         NodeMouldPath* pMouldPath = pMould->GetPathShape();
00611         if (pMouldPath!=NULL)
00612         {
00613             // RangeControl Cntrl = Selected + Unselected + don't cross layers  
00614             Range CopyRange(pMouldPath,pMouldPath,RangeControl(TRUE,TRUE,FALSE));
00615             if (!DoCopyNodesToClipboard(CopyRange))
00616                 return FALSE;
00617         }
00618     }
00619 
00620     NodeMouldGroup* pNodeMouldGroup = pMould->FindMouldGroup();
00621     if (!pNodeMouldGroup) 
00622         return FALSE;
00623 
00624     // now make sure the nodemouldgroups kids have localised attributes
00625     if (!DoLocaliseCommonAttributes(pNodeMouldGroup))
00626         return FALSE;
00627 
00628     // Now localise all those unsafe attributes at the top.
00629     if (!LocaliseMouldAttributes(pMould))
00630         return FALSE;
00631 
00632     if (!HideAllMouldAttrs(pMould))
00633         return FALSE;
00634 
00635     Spread* pSpread = pMould->FindParentSpread();
00636 
00637     Node* pNode = pNodeMouldGroup->FindLastChild();
00638     while (pNode!=NULL)
00639     {
00640         Node* pPrevNode = pNode->FindPrevious();
00641 
00642         if (pNode->IS_KIND_OF(NodeRenderableInk))
00643         {
00644             if (!DoSelectNode((NodeRenderableInk*)pNode,pSpread))
00645                 return FALSE;
00646 
00647             if (!DoInvalidateNodeRegion((NodeRenderableInk*)pNode,TRUE))
00648                 return FALSE;
00649         }
00650 
00651         if (pNode->IsAnObject())
00652         {
00653             if (!DoMoveNode(pNode, pMould, NEXT))
00654                 return FALSE;
00655         }
00656         
00657         pNode = pPrevNode;  
00658     }
00659 
00660     if (!DoDeselectNode(pMould, pSpread))
00661         return FALSE;
00662 
00663     if (!DoInvalidateNodeRegion(pMould, TRUE))
00664         return FALSE;
00665 
00666     // Hide the mould node
00667     if (!DoHideNode(pMould, FALSE, NULL))
00668         return FALSE;                
00669 
00670     // inform the selection something has changed?
00671     GetApplication()->UpdateSelection();
00672 
00673     return TRUE;
00674 }

BOOL OpMouldLibSel::DoReplaceAllMoulds List pNodeList,
Path pShape,
MouldSpace  mSpace,
BOOL  ScaleToFit,
BOOL  LockAspect
[protected]
 

Definition at line 843 of file moldedit.cpp.

00848 {
00849     ERROR2IF(pNodeList==NULL, FALSE, "DoReplaceAllMoulds() given a null nodelist pointer");
00850     
00851     NodeListItem* CurItem = (NodeListItem*)(pNodeList->GetHead());
00852     if (!CurItem)
00853         return FALSE;
00854 
00855     while (CurItem)
00856     {
00857         if (CurItem->pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeMould))
00858         {
00859             NodeMould* pMould = (NodeMould*)(CurItem->pNode);
00860             if (!DoInvalidateNodeRegion(pMould, TRUE))
00861                 return FALSE;
00862 
00863             if (!DoReplaceMould(pMould, pShape, mSpace, ScaleToFit, LockAspect))
00864                 return FALSE;
00865 
00866             // Recalculate the mould's bounding box
00867             pMould->InvalidateBoundingRect();
00868 
00869             if (!DoInvalidateNodeRegion(pMould, TRUE))
00870                 return FALSE;
00871         }
00872         CurItem = (NodeListItem*)(pNodeList->GetNext(CurItem));
00873     }
00874 
00875     GetApplication()->UpdateSelection();
00876 
00877     return TRUE;
00878 }

BOOL OpMouldLibSel::DoReplaceMould NodeMould pMould,
Path pShape,
MouldSpace  mSpace,
BOOL  ScaleToFit,
BOOL  LockAspect
[protected]
 

Definition at line 900 of file moldedit.cpp.

00905 {
00906     ERROR2IF(pMould==NULL, FALSE, "DoReplaceMould() called with no mould pointer");
00907     ERROR2IF(pNewShape==NULL, FALSE, "DoReplaceMould() called with a NULL shape pointer");
00908 
00909     // cache the old geometry
00910     MouldGeometry* pGeometry=pMould->GetGeometry();
00911     if (!pGeometry)
00912         return FALSE;
00913 
00914     DocRect Bounds, DRect, *pRect;
00915     Bounds = pGeometry->GetSourceRect();
00916 
00917     if ((pMould->StartSaveContext(this, REC_REBUILD | REC_GEOMETRY)) == CC_FAIL)
00918         return FALSE;
00919 
00920     // create a new one (will automatically delete the old)
00921     if (!pMould->CreateGeometry(mSpace))
00922         return FALSE;
00923 
00924     // cache a pointer to the new geometry
00925     pGeometry=pMould->GetGeometry();
00926     if (!pGeometry)
00927         return FALSE;
00928 
00929     // check the shape we've been given is fine and lovely  
00930     UINT32 errID;
00931     if (!pGeometry->Validate(pNewShape,errID))
00932     {
00933         ERROR1(FALSE, errID);
00934     }
00935 
00936     // build a destination scale rectangle
00937     pRect = FindScaleRect(&Bounds, &DRect, ScaleToFit, LockAspect);
00938 
00939     // Find the current mould path object
00940     NodeMouldPath* pNodeMPath = pMould->GetPathShape(); 
00941     if (!pNodeMPath)
00942         return FALSE;
00943 
00944     // Hide the mould path node
00945     if (!DoHideNode(pNodeMPath, FALSE, NULL))
00946         return FALSE;                
00947 
00948     // Create and add a mould shape object
00949     pNodeMPath = pMould->AddNewMouldShape(pNewShape,pRect,this);
00950     if (!pNodeMPath)
00951         return FALSE;
00952 
00953     // set the geometry using this new mould shape
00954     if (!pGeometry->Define(&(pNodeMPath->InkPath), &Bounds))
00955         return FALSE;
00956 
00957     // finally generate some new mould shapes.
00958     if (pMould->RemouldAll(this)==CC_FAIL)
00959         return FALSE;
00960 
00961     // Ilan 7/5/00
00962     // Inform geom linked attrs of the change. Nb outside the normal AllowOp mechanism
00963     NodeAttribute* pNA = pMould->FindFirstGeometryLinkedAttr();
00964     while(pNA)
00965     {
00966         pNA->LinkedNodeGeometryHasChanged(this);
00967         pNA = pNA->FindNextGeometryLinkedAttr();
00968     }
00969 
00970     if ((pMould->EndSaveContext(this, REC_REBUILD | REC_GEOMETRY)) == CC_FAIL)
00971         return FALSE;
00972 
00973     return TRUE;
00974 }

DocRect * OpMouldLibSel::FindScaleRect DocRect pSRect,
DocRect pDRect,
BOOL  ScaleToFit,
BOOL  KeepSquare
[private]
 

Internal scaling rectangle calculator. Using the flags scaletofit, lock a destination rectangle is build from the souce. If both flags are false a null pointer will be returned else a pointer to pDRect.

DocRect* OpMouldLibSel::FindScaleRect( DocRect* pSRect, DocRect* pDRect, BOOL ScaleToFit, BOOL KeepSquare)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/01/95
Parameters:
pSRect = a pointer to a source rectangle [INPUTS] pDRect = a pointer to a destination rectangle ScaleToFit = If TRUE then pDRect will contain pSRect KeepSquare = If TRUE then pDRect is converted to have equal width and height using its max dimension
Returns:
a pointer to pDRect or null if pDRect has not been affected

Definition at line 461 of file moldedit.cpp.

00462 {
00463     if (ScaleToFit)
00464     {
00465         (*pDRect)=(*pSRect);
00466 
00467         // form a square rectangle if lock aspect is on.
00468         if (KeepSquare)
00469         {
00470             INT32 wid = pDRect->Width();
00471             INT32 hgt = pDRect->Height();
00472             INT32 max = (hgt>wid) ? hgt : wid;
00473 
00474             INT32 cx = (pDRect->lo.x + pDRect->hi.x)/2;
00475             INT32 cy = (pDRect->lo.y + pDRect->hi.y)/2;
00476 
00477             pDRect->lo.x = cx-max/2;
00478             pDRect->lo.y = cy-max/2;
00479             pDRect->hi.x = cx+max/2;
00480             pDRect->hi.y = cy+max/2;
00481         }
00482         
00483         return pDRect;
00484     }
00485     return NULL;
00486 }

BOOL OpMouldLibSel::HideAllMouldAttrs NodeMould pMould  )  [private]
 

BOOL OpMouldLibSel::HideAllMouldAttrs(NodeMould* pMould)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/01/95
Parameters:
pMould = pointer to a mould object [INPUTS]
Returns:
TRUE if successfully hidden all the mould attributes FALSE if failed.

Definition at line 802 of file moldedit.cpp.

00803 {
00804     ERROR2IF(pMould==NULL, FALSE, "HideAllMouldAttrs() given a null mould pointer");
00805 
00806     Node* pNode = pMould->FindFirstChild();
00807     while (pNode)
00808     {
00809         if (pNode->IsAnAttribute())
00810         {
00811             NodeAttribute* pAttr = (NodeAttribute*)pNode;
00812             if (!DoHideNode(pAttr, TRUE))
00813                 return FALSE;
00814         }
00815         pNode=pNode->FindNext();
00816     }
00817     return TRUE;
00818 }

BOOL OpMouldLibSel::IsAMouldSelected NodeMould **  pNodeMould  )  [static, protected]
 

Scans the selection hunting for a selected mould object. It will return a pointer to the object if found and if the return pointer is none null. Hopefully this will be replaced at some point by Selection->FindObject(type).

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/01/95
Parameters:
pNodeMould,a return pointer (can be null) [INPUTS]
pNodeMould points to the selected mould object if one exists [OUTPUTS]
Returns:
TRUE if there is a selected mould object FALSE if not

Definition at line 506 of file moldedit.cpp.

00507 {
00508     BOOL Sel = FALSE;
00509     Node* pNode =NULL;
00510     if (Document::GetCurrent() != NULL)
00511     {
00512         SelRange* Selected = GetApplication()->FindSelection();
00513         pNode = Selected->FindFirst();
00514         while ((pNode!=NULL) && (!Sel))
00515         {
00516             if (pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeMould))
00517                 Sel=TRUE;
00518             else
00519                 pNode = Selected->FindNext(pNode);
00520         }
00521     }
00522     if (Sel && pNodeMould)
00523         *pNodeMould = (NodeMould*)pNode;
00524 
00525     return Sel;
00526 }

BOOL OpMouldLibSel::LocaliseMouldAttributes NodeMould pMould  )  [private]
 

BOOL OpMouldLibSel::LocaliseMouldAttributes(NodeMould* pMould)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/01/95
Parameters:
pMould = pointer to a mould object [INPUTS]
Returns:
TRUE if successfully localised the mould attributes FALSE if failed.

Definition at line 690 of file moldedit.cpp.

00691 {
00692     ERROR2IF(pMould==NULL, FALSE, "LocaliseMouldAttributes() given a null mould pointer");
00693 
00694     NodeMouldGroup* pNodeMouldGroup = pMould->FindMouldGroup();
00695     if (!pNodeMouldGroup) 
00696         return FALSE;
00697 
00698     Node* pNode = pNodeMouldGroup->FindFirstChild();
00699     while (pNode)
00700     {
00701         if (pNode->IsAnObject())
00702         {
00703             NodeRenderableInk* pInkNode = (NodeRenderableInk*)pNode;
00704             if (!LocaliseObjectAttrs(pMould, pInkNode))
00705                 return FALSE;
00706         }
00707         pNode=pNode->FindNext();
00708     }
00709     return TRUE;
00710 }

BOOL OpMouldLibSel::LocaliseObjectAttrs NodeRenderableInk pParent,
NodeRenderableInk pInkNode
[private]
 

BOOL OpMouldLibSel::LocaliseObjectAttrs(NodeRenderableInk* pParent, NodeRenderableInk* pInkNode)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/01/95
Parameters:
pMould = pointer to a mould object [INPUTS]
Returns:
TRUE if successfully localised the mould attributes FALSE if failed.

Definition at line 727 of file moldedit.cpp.

00728 {
00729     CCRuntimeClass* AttrType;
00730     BOOL Exists; 
00731     NodeAttribute* pCurAttr;
00732     Node* pCloneAttr;
00733     Node* Current;
00734 
00735     ERROR2IF(pInkNode==NULL, FALSE, "LocaliseObjectAttrs() given a null object pointer");
00736 
00737     Current = pParent->FindFirstChild();
00738     while (Current)
00739     {
00740         if (Current->IsAnAttribute())
00741         {
00742             pCurAttr = (NodeAttribute*)Current;
00743             // Some attributes cannot be applied to objects
00744             if (pCurAttr->CanBeAppliedToObject())
00745             {
00746                 AttrType = pCurAttr->GetAttributeType();
00747 
00748                 if (pInkNode->RequiresAttrib(pCurAttr))
00749                 {
00750                     // Does the node already have this child attribute?
00751                     Exists = (pInkNode->GetChildAttrOfType(AttrType) != NULL);
00752                     ERROR3IF(Exists, "LocaliseMouldAttributes: Duplicate attr found !"); 
00753 
00754                     if (!Exists)
00755                     {
00756                         pCloneAttr = pCurAttr->SimpleCopy();
00757                         if (pCloneAttr)
00758                         {
00759                             pCloneAttr->AttachNode(pInkNode, FIRSTCHILD, TRUE, FALSE);
00760 
00761                             HideNodeAction* UndoHideNodeAction; 
00762 
00763                             if (HideNodeAction::Init(this,  
00764                                                      GetUndoActionList(),
00765                                                      pCloneAttr, 
00766                                                      TRUE,
00767                                                      (Action**)(&UndoHideNodeAction)
00768                                                      ) == AC_FAIL)
00769                             {   
00770                                 pCloneAttr->UnlinkNodeFromTree();
00771                                 delete pCloneAttr;
00772                                 pCloneAttr=NULL;
00773                                 return FALSE; 
00774                             }
00775 
00776                         }
00777                     }
00778                 }
00779             }
00780         }
00781         Current = Current->FindNext();
00782     }
00783     return TRUE;
00784 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:58:27 2007 for Camelot by  doxygen 1.4.4