#include <textops.h>
Inheritance diagram for PositionCaretAction:
Public Member Functions | |
PositionCaretAction () | |
Constructor for PositionCaretAction. Initialises the member variables. | |
~PositionCaretAction () | |
Destructor for PositionCaretAction. | |
virtual ActionCode | Execute () |
This action inserts the opposite PositionCaretAction for redo purposes, then moves the CaretNode within the TextStory. | |
Static Public Member Functions | |
static ActionCode | Init (Operation *pOp, ActionList *pActionList, TextStory *pStory, BaseTextClass *pAttachNode, AttachNodeDirection Direction) |
Call this function to cause the move of caret a TextStory during an undo/redo set of operations. In your Do function move the caret, then call this function to insert an undo record for that deletion. | |
static BOOL | DoStoreCaretPosition (Operation *pOp, TextStory *pStory) |
Call this function to restore the position of the caret in an undo list. | |
Static Protected Member Functions | |
static BOOL | GetCaretNeighbour (TextStory *pStory, BaseTextClass **pNeighbour, AttachNodeDirection *pDirection) |
Gets a pointer to the node that execute function should attach the caret to. | |
Protected Attributes | |
TextStory * | pTextStory |
BaseTextClass * | pNearNode |
AttachNodeDirection | AttachDirection |
Definition at line 570 of file textops.h.
|
Constructor for PositionCaretAction. Initialises the member variables.
Definition at line 1141 of file textops.cpp. 01142 { 01143 pTextStory = NULL; 01144 pNearNode = NULL; 01145 AttachDirection = NEXT; 01146 }
|
|
Destructor for PositionCaretAction.
Definition at line 1157 of file textops.cpp.
|
|
Call this function to restore the position of the caret in an undo list.
Definition at line 1264 of file textops.cpp. 01265 { 01266 ERROR2IF(pStory==NULL,FALSE,"PositionCaretAction::DoStoreCaretPosition() - pStory==NULL"); 01267 ERROR2IF(pOp ==NULL,FALSE,"PositionCaretAction::DoStoreCaretPosition() - pOp==NULL"); 01268 01269 // Get a pointer to the node to reattach the caret to 01270 CaretNode* pCaret = pStory->GetCaret(); 01271 ERROR2IF(pCaret==NULL,FALSE,"PositionCaretAction::DoStoreCaretPosition() - pCaret==NULL"); 01272 01273 ActionList* pActionList = pOp->GetUndoActionList(); 01274 ERROR2IF(pActionList==NULL,FALSE,"PositionCaretAction::DoStoreCaretPosition() - pActionList==NULL"); 01275 01276 // get a neighbour for the caret, and its direction 01277 BaseTextClass* pReattachNode = NULL; 01278 AttachNodeDirection AttachDir = NEXT; 01279 if (GetCaretNeighbour(pStory, &pReattachNode, &AttachDir)==FALSE) 01280 return FALSE; 01281 01282 // Create an action for this 01283 if (PositionCaretAction::Init(pOp, pActionList, pStory, pReattachNode, AttachDir)==AC_FAIL) 01284 return FALSE; 01285 01286 return TRUE; 01287 }
|
|
This action inserts the opposite PositionCaretAction for redo purposes, then moves the CaretNode within the TextStory.
Reimplemented from Action. Definition at line 1172 of file textops.cpp. 01173 { 01174 ERROR2IF(pTextStory==NULL,AC_FAIL,"PositionCaretAction::Execute() - pTextStory==NULL"); 01175 ERROR2IF( pNearNode==NULL,AC_FAIL,"PositionCaretAction::Execute() - pNearNode==NULL"); 01176 CaretNode* pCaret = pTextStory->GetCaret(); 01177 ERROR2IF( pCaret==NULL,AC_FAIL,"PositionCaretAction::Execute() - pCaret==NULL"); 01178 01179 // create redo action to position caret where it is currently 01180 BaseTextClass* pReDoAttachNode = NULL; 01181 AttachNodeDirection ReDoAttachDir = NEXT; 01182 if (!GetCaretNeighbour(pTextStory, &pReDoAttachNode, &ReDoAttachDir)) 01183 return AC_FAIL; 01184 if (PositionCaretAction::Init(pOperation,pOppositeActLst,pTextStory,pReDoAttachNode,ReDoAttachDir)==AC_FAIL) 01185 return AC_FAIL; 01186 01187 // ensure FIRSTCHILD actually means first child object 01188 Node* pAttachNode = pNearNode; 01189 AttachNodeDirection AttachDir = AttachDirection; 01190 if (AttachDirection==FIRSTCHILD) 01191 pNearNode->GetAttachNodeAndDirectionToAttachFirstChildObject(&pAttachNode,&AttachDir); 01192 01193 // Move caret, deselect in old pos and reselect in new pos to maintain ParentOfSelected 01194 BOOL CaretWasSelected = pCaret->IsSelected(); 01195 if (CaretWasSelected) 01196 pCaret->SetSelected(FALSE); 01197 pCaret->MoveNode(pAttachNode, AttachDir); 01198 if (CaretWasSelected) 01199 pCaret->SetSelected(TRUE); 01200 01201 pTextStory->AttachCaretAttributes(); // ensure caret has attrs of its context 01202 pCaret->ScrollToShow(); // ensure caret on screen 01203 01204 return AC_OK; 01205 }
|
|
Gets a pointer to the node that execute function should attach the caret to.
Definition at line 1303 of file textops.cpp. 01305 { 01306 ERROR2IF( pStory== NULL,FALSE,"PositionCaretAction::GetCaretNeighbour() - pStory==NULL"); 01307 ERROR2IF(ppNeighbour== NULL,FALSE,"PositionCaretAction::GetCaretNeighbour() - ppNeighbour==NULL"); 01308 ERROR2IF( pDirection== NULL,FALSE,"PositionCaretAction::GetCaretNeighbour() - pDirection==NULL"); 01309 01310 // Get a pointer to the node to reattach the caret to 01311 CaretNode* pCaret = pStory->GetCaret(); 01312 ERROR2IF(pCaret==NULL,FALSE,"PositionCaretAction::GetCaretNeighbour() - story has no caret"); 01313 *ppNeighbour = pCaret->FindPrevVTNInLine(); 01314 *pDirection = NEXT; 01315 if (*ppNeighbour==NULL) 01316 { 01317 *ppNeighbour = pCaret->FindNextVTNInLine(); 01318 *pDirection = PREV; 01319 } 01320 if (*ppNeighbour==NULL) 01321 { 01322 *ppNeighbour = pCaret->FindParentLine(); 01323 ERROR2IF(*ppNeighbour==NULL,FALSE,"PositionCaretAction::GetCaretNeighbour() - caret has no parent TExtLine"); 01324 *pDirection = FIRSTCHILD; 01325 } 01326 01327 return TRUE; 01328 }
|
|
Call this function to cause the move of caret a TextStory during an undo/redo set of operations. In your Do function move the caret, then call this function to insert an undo record for that deletion.
Definition at line 1229 of file textops.cpp. 01234 { 01235 UINT32 ActSize = sizeof(PositionCaretAction); 01236 01237 PositionCaretAction* pNewAction = NULL; 01238 01239 ActionCode Ac = Action::Init( pOp, pActionList, ActSize, CC_RUNTIME_CLASS(PositionCaretAction), (Action**)&pNewAction); 01240 if ((Ac == AC_OK) && (pNewAction != NULL)) 01241 { 01242 ERROR2IF(pStory == NULL, AC_FAIL, "TextStory pointer was NULL"); 01243 ERROR2IF(pAttachNode == NULL, AC_FAIL, "Attachment node pointer was NULL"); 01244 pNewAction->pTextStory = pStory; 01245 pNewAction->pNearNode = pAttachNode; 01246 pNewAction->AttachDirection = Direction; 01247 } 01248 01249 return Ac; 01250 }
|
|
|
|
|
|
|