OpFitTextToCurve Class Reference

This class is the operation used to fit a line of text to a path. More...

#include <textops.h>

Inheritance diagram for OpFitTextToCurve:

OpTextUndoable SelOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpFitTextToCurve ()
 OpFitTextToCurve constructor.
void Do (OpDescriptor *)
 move selected path into selected text story or remove the path from the story

Static Public Member Functions

static BOOL Init ()
 OpFitTextToCurve initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding OpFitTextToCurve's state. It is greyed unless there is just one path and one text line selected.

Static Private Member Functions

static BOOL FindPathAndText (NodeRenderableInk **pPath, TextStory **pStory, UndoableOperation *pOp, UINT32 *ID)
 Gets the text story and path to fit. Used by the Do and the GetState functions.

Detailed Description

This class is the operation used to fit a line of text to a path.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/03/95

Definition at line 266 of file textops.h.


Constructor & Destructor Documentation

OpFitTextToCurve::OpFitTextToCurve  ) 
 

OpFitTextToCurve constructor.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/03/95

Definition at line 1735 of file textops.cpp.

01735                                   : OpTextUndoable()                                
01736 {                              
01737 }


Member Function Documentation

void OpFitTextToCurve::Do OpDescriptor  )  [virtual]
 

move selected path into selected text story or remove the path from the story

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/03/95
Parameters:
OpDescriptor (unused) [INPUTS]

Reimplemented from Operation.

Definition at line 1822 of file textops.cpp.

BOOL OpFitTextToCurve::FindPathAndText NodeRenderableInk **  pPath,
TextStory **  pStory,
UndoableOperation pOp,
UINT32 ID
[static, private]
 

Gets the text story and path to fit. Used by the Do and the GetState functions.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/03/95
Parameters:
pPath,: (See below) [INPUTS] pStory: (See below) pOp: the paramater to pass to ObjChangeParam
pPath points to the path to fit the text to (is NULL is pStory has a path) [OUTPUTS] pStory points to the text story to use (is NULL if no stories found)
Returns:
TRUE if there is a selected path and text story OR a selected story with a path FALSE if there isn't
See also:
OpFitTextToCurve::Do, OpFitTextToCurve::GetState

Definition at line 2004 of file textops.cpp.

02005 {
02006     OpState OpSt;
02007 
02008 //  Range* pSelRange = GetApplication()->FindSelection(); 
02009     *pStory = NULL;
02010     *pPath= NULL;
02011 
02012     // Set up the ObjChangeParam so we can ask the selected nodes if they mind being deleted
02013     ObjChangeParam ObjDeleteChange(OBJCHANGE_STARTING,ObjChangeFlags(TRUE),NULL,pOp);
02014     ObjChangeParam ObjNotChange(OBJCHANGE_STARTING,ObjChangeFlags(FALSE),NULL,pOp);
02015 
02016     BOOL FoundOnePath = FALSE;
02017     BOOL FoundOneTextStory = FALSE;
02018     BOOL FoundMultiple = FALSE;
02019     BOOL StoryHadPath = FALSE;
02020 
02021     SelRange* Selected = GetApplication()->FindSelection();
02022     Node* pNode = Selected->FindFirst();
02023 
02024     BOOL bFoundTextStoryWithController = FALSE;
02025     BOOL bFoundPathWithController = FALSE;
02026     
02027     BecomeA TestBecomeAPath(BECOMEA_TEST, CC_RUNTIME_CLASS(NodePath));
02028 
02029     while (pNode && !FoundMultiple)
02030     {
02031         // check for needs parent nodes too
02032         if (pNode->NeedsParent(NULL))
02033         {
02034             // find out if we have a base text class node here, in this hierarchy
02035             *pStory = (TextStory *)pNode->FindNext(CC_RUNTIME_CLASS(BaseTextClass));
02036 
02037             if ((*pStory) == NULL)
02038             {
02039                 *pStory = (TextStory *)pNode->FindPrevious(CC_RUNTIME_CLASS(BaseTextClass));
02040             }
02041 
02042             // have we found the text story ? then dont bother trying to find it again
02043             if ((*pStory) != NULL)
02044                 bFoundTextStoryWithController = TRUE;
02045 
02046             // have we found an object though ?
02047             if (!bFoundTextStoryWithController)
02048             {
02049                 *pPath = (NodeRenderableInk *)pNode->FindNext(CC_RUNTIME_CLASS(NodeRenderableInk));
02050 
02051                 if ((*pPath) == NULL)
02052                 {
02053                     *pPath = (NodeRenderableInk *)pNode->FindPrevious(CC_RUNTIME_CLASS(NodeRenderableInk));
02054                 }
02055 
02056                 if ((*pPath) != NULL && (*pPath)->NeedsParent(NULL))
02057                 {
02058                     *pPath = NULL;
02059                 }
02060             }
02061 
02062             if ((*pPath) != NULL)
02063             {
02064                 bFoundPathWithController = TRUE;
02065             }
02066         }
02067 
02068         // check for controller nodes selected with text children
02069         if (pNode->IsCompound())
02070         {
02071             if (pNode->IsController())
02072             {
02073                 // try to find the text node
02074                 *pStory = (TextStory *)pNode->FindFirstChild(CC_RUNTIME_CLASS(BaseTextClass));
02075                 
02076                 if ((*pStory) != NULL)              
02077                     bFoundTextStoryWithController = TRUE;
02078 
02079                 if (!bFoundTextStoryWithController)
02080                 {
02081                     // try to find the shape node
02082                     *pPath = (NodeRenderableInk *)pNode->FindFirstChild(CC_RUNTIME_CLASS(NodeRenderableInk));
02083 
02084                     while (*pPath && (*pPath)->NeedsParent(NULL))
02085                     {
02086                         *pPath = (NodeRenderableInk *)(*pPath)->FindNext(CC_RUNTIME_CLASS(NodeRenderableInk));
02087                     }
02088                 }
02089             }
02090 
02091             if ((*pPath) != NULL)
02092             {
02093                 bFoundPathWithController = TRUE;
02094             }
02095         }
02096 
02097         if ((pNode->IS_KIND_OF(BaseTextClass) || bFoundTextStoryWithController)
02098             && (*pStory) != pNode) // make sure we won't discount a node we've already found
02099         {
02100             // only do this once
02101             bFoundTextStoryWithController = FALSE;
02102             
02103             TextStory* pTS = NULL;
02104             
02105             if (*(pStory) == NULL)
02106             {
02107                 if (IS_A(pNode,TextStory))
02108                     pTS = (TextStory*)pNode;
02109                 else
02110                     pTS = (TextStory*)pNode->FindParent(CC_RUNTIME_CLASS(TextStory));
02111             }
02112             else
02113             {
02114                 pTS = *pStory;
02115             }
02116 
02117             if (pTS != NULL)
02118             {
02119                 if (FoundOneTextStory && (pTS != *pStory))
02120                     FoundMultiple = TRUE;
02121                 else
02122                 {
02123                     // We should check here to see if the TextStory is already on a path
02124                     if (pTS->AllowOp(&ObjNotChange,FALSE))
02125                     {
02126                         FoundOneTextStory = TRUE;
02127                         *pStory = pTS;
02128                         if ((*pStory)->GetTextPath() != NULL)
02129                         {
02130                             FoundOnePath = TRUE;
02131                             StoryHadPath = TRUE;
02132                         }
02133                     }
02134                 }
02135             }
02136         }
02137         else if (pNode->IsAnObject() &&
02138                 !pNode->IsCompound() &&
02139                 ((NodeRenderableInk*)pNode)->CanBecomeA(&TestBecomeAPath) ||
02140                 bFoundPathWithController && (*pPath) != pNode
02141                 )
02142         {
02143             if (FoundOnePath)
02144                 FoundMultiple = TRUE;
02145             else
02146             {
02147                 if (bFoundPathWithController)
02148                 {
02149                     if (!(*pPath)->AllowOp(&ObjDeleteChange, FALSE))
02150                     {
02151                         *pPath = NULL;
02152                     }
02153                     else
02154                     {
02155                         FoundOnePath = TRUE;
02156                     }
02157                 }
02158                 else if (pNode->AllowOp(&ObjDeleteChange,FALSE))
02159                 {
02160                     FoundOnePath = TRUE;
02161                     *pPath = (NodePath*)pNode;
02162                 }
02163             }
02164         }
02165 
02166         pNode = Selected->FindNext(pNode);
02167     }
02168 
02169     // If there's a sub-selection the use the focus story
02170     if (!FoundOneTextStory && (TextStory::GetFocusStory() != NULL))
02171         FoundOneTextStory = TRUE;
02172 
02173     *ID = ObjDeleteChange.GetReasonForDenial();
02174 
02175     if (StoryHadPath)
02176         *pPath = NULL;
02177 
02178     return !FoundMultiple && ((FoundOnePath && FoundOneTextStory) || (StoryHadPath && FoundOneTextStory));
02179 }

OpState OpFitTextToCurve::GetState String_256 UIDescription,
OpDescriptor
[static]
 

For finding OpFitTextToCurve's state. It is greyed unless there is just one path and one text line selected.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/03/95
Returns:
The state of the OpFitTextToCurve

Definition at line 1783 of file textops.cpp.

01784 {
01785     OpState OpSt;
01786 
01787     NodeRenderableInk* pPath = NULL;
01788     TextStory* pStory = NULL;
01789     UINT32 IDS = 0;
01790 
01791     // BODGE TEXT remove should work with a story with a caret on a path
01792     // Grey the op if we can't do it
01793     if (!FindPathAndText(&pPath, &pStory, NULL, &IDS))
01794     {
01795         OpSt.Greyed = TRUE;
01796         if (IDS == 0)
01797             IDS = _R(IDS_NOTPATHANDTEXTSEL);    
01798     }
01799     else
01800     {
01801         // Set the UI string for fit text / remove text
01802         if (pPath == NULL)
01803             IDS = _R(IDS_REMOVETEXTFROMPATHOP);
01804     }
01805 
01806     if (IDS != 0)
01807         *UIDescription = String_256(IDS);           
01808 
01809     return(OpSt);   
01810 }

BOOL OpFitTextToCurve::Init void   )  [static]
 

OpFitTextToCurve initialiser method.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/03/95
Returns:
TRUE if the operation could be successfully initialised FALSE if no more memory could be allocated

Errors: ERROR will be called if there was insufficient memory to allocate the operation.

Reimplemented from SimpleCCObject.

Definition at line 1752 of file textops.cpp.

01753 {
01754     return (RegisterOpDescriptor(0,
01755                             _R(IDS_FITTEXTTOPATHOP),
01756                             CC_RUNTIME_CLASS(OpFitTextToCurve),
01757                             OPTOKEN_FITTEXTTOPATH,
01758                             OpFitTextToCurve::GetState,
01759                             0,                          // help ID 
01760                             _R(IDBBL_FITTEXTTOCURVE),       // Bubble help
01761                             _R(IDD_BARCONTROLSTORE),
01762                             _R(IDC_FITTEXTTOCURVE),
01763                             SYSTEMBAR_EDIT,             // Bar ID
01764                             TRUE,                       // Receive messages
01765                             FALSE,
01766                             FALSE,
01767                             0,
01768                             GREY_WHEN_NO_CURRENT_DOC | GREY_WHEN_NO_SELECTION | DONT_GREY_WHEN_SELECT_INSIDE
01769            )); 
01770 }               


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