TextTool Class Reference

A template tool class. More...

#include <texttool.h>

Inheritance diagram for TextTool:

Tool_v1 List of all members.

Public Member Functions

 TextTool ()
 Default Constructor. Other initialisation is done in TextTool::Init which is called by the Tool Manager.
 ~TextTool ()
 Destructor (Virtual). Does nothing.
BOOL Init ()
 Used to check if the Tool was properly constructed.
void Describe (void *InfoPtr)
 Allows the tool manager to extract information about the tool.
UINT32 GetID ()
void SelectChange (BOOL isSelected)
 Starts up and closes down the Text tool.
void OnClick (DocCoord, ClickType, ClickModifiers, Spread *)
 To handle a Mouse Click event for the Text Tool.
void OnMouseMove (DocCoord PointerPos, Spread *pSpread, ClickModifiers ClickMods)
 To handle a Mouse Move event for the Text Tool.
void RenderToolBlobs (Spread *, DocRect *)
 Called to render the tool blobs for the text tool.
void GetRulerOrigin (Spread *, UserCoord *)
 Gives the current tool the chance to change the coordinates displayed on the ruler.
void RenderRulerBlobs (RulerBase *pRuler, UserRect &UpdateRect, BOOL IsBackground)
 Gives the current tool the chance to render additional blobs on the ruler Is called twice - once before the standard ruler graphics are rendered (to allow additional background to be drawn) and once afterwards.
BOOL OnRulerClick (UserCoord PointerPos, ClickType Click, ClickModifiers Mods, Spread *pSpread, RulerBase *pRuler)
 Called when the user has clicked on the ruler and we are the current tool.
BOOL GetRulerStatusLineText (String_256 *pText, UserCoord PointerPos, Spread *pSpread, RulerBase *pRuler)
 Allows the tool to set the status line text for the ruler.
BOOL OnKeyPress (KeyPress *pKeyPress)
 To handle a keypress event for the Text Tool.
BOOL GetStatusLineText (String_256 *ptext, Spread *pSpread, DocCoord DocPos, ClickModifiers ClickMods)
 Returns the current status line help string.
BOOL OnIdle ()
 Called on idle events. Used to update the infobar kern field after typing.
void LocaleChanged ()
 Called when the machines locale changes. Re-registers the dead keys as their virtual key code may have changed.
BOOL SelectionHasChanged ()
 Called when the selection has changed. Ensures tool blobs are up-to-date.
virtual BOOL AreToolBlobsRenderedOnSelection ()

Static Public Member Functions

static BOOL DelayingUpdate ()
 Let's the caller know if the text-tool has finished mucking about with the document's modified flag.
static TextInfoBarOpGetTextInfoBarOp ()
static BOOL IsCurrentTool ()

Protected Member Functions

void DisplayStatusBarHelp (DocCoord DocPos, Spread *pSpread, ClickModifiers ClickMods)
 Displays status help string for the given position in the status bar.
void GetCurrentStatusText (String_256 *ptext, Spread *pSpread, DocCoord DocPos, ClickModifiers ClickMods)
 Selects a suitable string for the status line based on the current location (as input via the parameters).
BOOL IsPointNearUnselectedTextStory (Spread *, DocCoord, TextStory **, Node **, BOOL)
 To see if a click at the current positon would select a TextStory.
BOOL IsPointNearNonStoryPath (Spread *, DocCoord, NodePath **, BOOL)
 To see if a click at the current positon should create a story on a path.
BOOL HandleSingleClick (Spread *, DocCoord, ClickModifiers)
 To handle single click events in the text tool.
BOOL HandleDoubleClick (Spread *, DocCoord, ClickModifiers)
 To handle double click events in the text tool.
BOOL HandleTripleClick (Spread *, DocCoord, ClickModifiers)
 To handle triple click events in the text tool.
BOOL HandleQuadClick (Spread *, DocCoord, ClickModifiers)
 To handle quad click events in the text tool.
BOOL HandleDragClick (Spread *, DocCoord, ClickModifiers)
 To handle drag events in the text tool.
BOOL RegisterDeadKeys ()
 Registers all the dead keys virtual codes with the keypress system.
BOOL RemoveDeadKeys ()
 Deregisters all the dead keys.
BOOL RegisterAdditionalVirtKey (KeyPress **pKey, TCHAR ch)
 Registers a requirement for a virtual key message with the KeyPress system.
BOOL HandleSpecialNonStoryKeys (KeyPress *pKeyPress)
 To deal with keys presses that work without a focus story.
BOOL HandleSpecialStoryAndNonStoryKeys (KeyPress *pKeyPress)
 To handle keypress events that wotk with and without a text focus story.
BOOL HandleDeadKeys (KeyPress *pKeyPress, WCHAR *pNewUnicode)
 Flags 'dead-keys'. Attempts to apply an accent onto the next character.
BOOL TestForDeadKey (KeyPress *pKeyPress, KeyPress *pDeadKeypress)
 Flags 'dead-keys'. Attempts to apply an accent onto the next character.
BOOL HandleSpecialStoryKeys (KeyPress *pKeyPress, TextStory *pStory, CaretNode *pCaret)
 To handle special keypress events that apply at a story and/or caret.
BOOL IsUsableUnicode (WCHAR CodeValue)
 Central place to filter out unicode greater than 255.
BOOL ApplyBold ()
 Applies or removes the bold attribute from the current selection or caret.
BOOL ApplyItalic ()
 Applies or removes the italic attribute from the current selection or caret.
BOOL IncreaseTrackKern ()
 If there is a text selection then the tracking applied to it is increased by 10/1000's of an em If there is no selection then a kern up of 50/1000 is inserted.
BOOL DecreaseTrackKern ()
 If there is a text selection then the tracking applied to it is decreased by 10/1000's of an em If there is no selection then a kern down of 50/1000 is inserted.
BOOL CommonApplyKern (MILLIPOINT ChangeAmmount)
 Applys/increases/descreases the horizontal kern at the caret.
BOOL CommonApplyTracking (MILLIPOINT ChangeAmmount)
 Applys/increases/descreases the tracking across the selected characters.
BOOL OnToolSelect ()
 Called to do processing required when text tool is selected.
BOOL OnToolDeselect ()
 Called to do processing required when text tool is deselected.
BOOL CreateCursors ()
 Creates all the Text tool cursors.
void DestroyCursors ()
 Destroys all the Text tool cursors.

Protected Attributes

CursorpcNormalTextCursor
CursorpcBlobTextCursor
CursorpcBlankCursor
CursorpcIndentCursor
CursorpcCurrentCursor
INT32 CurrentCursorID
BOOL IsBlankCursorUp
BOOL UpdateAfterTyping
TextStorypLastFocusStory
KeyPressPreviousDeadKey
KeyPressGraveVirtKey
KeyPressAcuteVirtKey
KeyPressHatVirtKey
KeyPressTildeVirtKey
KeyPressColonVirtKey
KeyPressAtVirtKey
KeyPressCommaVirtKey
KeyPressSlashVirtKey
TextToolBlobPosList m_BlobPosList

Static Protected Attributes

static BOOL CurrentTool = FALSE
static TextInfoBarOppTextInfoBarOp = NULL
static TCHARFamilyName = _T("Text Tools")
static TCHARToolName = _T("Text Tool")
static TCHARPurpose = _T("Text manipulation")
static TCHARAuthor = _T("TextToolTeam")
static BOOL UseDeadKeys = TRUE

Private Member Functions

 CC_DECLARE_MEMDUMP (TextTool)

Detailed Description

A template tool class.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94

Definition at line 189 of file texttool.h.


Constructor & Destructor Documentation

TextTool::TextTool  ) 
 

Default Constructor. Other initialisation is done in TextTool::Init which is called by the Tool Manager.

Author:
Mark_Goodall (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
See also:
TextTool::Init

Definition at line 259 of file texttool.cpp.

00260 {
00261     pcCurrentCursor = NULL;
00262     IsBlankCursorUp = FALSE;
00263     UpdateAfterTyping = FALSE;
00264 
00265     PreviousDeadKey = NULL;
00266     GraveVirtKey = NULL;
00267     AcuteVirtKey = NULL;
00268     HatVirtKey = NULL;
00269     TildeVirtKey = NULL;
00270     ColonVirtKey = NULL;
00271     AtVirtKey = NULL;
00272     CommaVirtKey = NULL;
00273     SlashVirtKey = NULL;
00274     pLastFocusStory = NULL;
00275 }

TextTool::~TextTool  ) 
 

Destructor (Virtual). Does nothing.

Author:
Mark_Goodall (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94

Definition at line 287 of file texttool.cpp.

00288 {
00289     pTextInfoBarOp->pTextTool = NULL;
00290     TextInfoBarOp::DeInit(); 
00291 
00292     RemoveDeadKeys();
00293 }


Member Function Documentation

BOOL TextTool::ApplyBold  )  [protected]
 

Applies or removes the bold attribute from the current selection or caret.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/04/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/failure

Definition at line 1709 of file texttool.cpp.

01710 {
01711     AttrTxtBold* ApplyBoldAttrib = new AttrTxtBold();
01712     BOOL Success = ApplyBoldAttrib != NULL;
01713 
01714     if (Success)
01715     {
01716         // See wether bold is currently on or off across the selection
01717         AttrTxtBold* CurrentBoldAttrib = NULL;
01718         SelRange::CommonAttribResult AttrRes = GetApplication()->FindSelection()->
01719                     FindCommonAttribute(CC_RUNTIME_CLASS(AttrTxtBold), (NodeAttribute **)&CurrentBoldAttrib);
01720         if (AttrRes == SelRange::ATTR_COMMON)
01721             ApplyBoldAttrib->Value.BoldOn = !(CurrentBoldAttrib->Value.BoldOn);
01722         else
01723             ApplyBoldAttrib->Value.BoldOn = TRUE;
01724 
01725         // Apply the new bold attribute to the selection
01726         AttributeManager::AttributeSelected(ApplyBoldAttrib, NULL);
01727     }
01728 
01729     return Success;
01730 }

BOOL TextTool::ApplyItalic  )  [protected]
 

Applies or removes the italic attribute from the current selection or caret.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/04/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/failure

Definition at line 1745 of file texttool.cpp.

01746 {
01747     AttrTxtItalic* ApplyItalicAttrib = new AttrTxtItalic();
01748     BOOL Success = ApplyItalicAttrib != NULL;
01749 
01750     if (Success)
01751     {
01752         // See wether italic is currently on or off across the selection
01753         AttrTxtItalic* CurrentItalicAttrib = NULL;
01754         SelRange::CommonAttribResult AttrRes = GetApplication()->FindSelection()->
01755                     FindCommonAttribute(CC_RUNTIME_CLASS(AttrTxtItalic), (NodeAttribute **)&CurrentItalicAttrib);
01756         if (AttrRes == SelRange::ATTR_COMMON)
01757             ApplyItalicAttrib->Value.ItalicOn = !(CurrentItalicAttrib->Value.ItalicOn);
01758         else
01759             ApplyItalicAttrib->Value.ItalicOn = TRUE;
01760 
01761         // Apply the new italic attribute to the selection
01762         AttributeManager::AttributeSelected(ApplyItalicAttrib, NULL);
01763     }
01764 
01765     return Success;
01766 }

virtual BOOL TextTool::AreToolBlobsRenderedOnSelection  )  [inline, virtual]
 

Reimplemented from Tool_v1.

Definition at line 233 of file texttool.h.

00233 {return TRUE;}

TextTool::CC_DECLARE_MEMDUMP TextTool   )  [private]
 

BOOL TextTool::CommonApplyKern MILLIPOINT  ChangeAmmount  )  [protected]
 

Applys/increases/descreases the horizontal kern at the caret.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/04/95
Parameters:
ChangeAmmount - ammount to increase/decrease the kern at the caret by [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/failure

Definition at line 1884 of file texttool.cpp.

01885 {
01886     MILLIPOINT NewKernVal = ChangeAmmount;
01887 
01888     // Get the current kern ammount - check the node to the left of the caret
01889     TextStory* pStory = TextStory::GetFocusStory();
01890     CaretNode* pCaret = NULL;
01891     if (pStory != NULL)
01892         pCaret = pStory->GetCaret();
01893     if (pCaret != NULL)
01894     {
01895         VisibleTextNode* LastNode = pCaret->FindPrevAbstractTextCharInStory();
01896         if ((LastNode != NULL) && IS_A(LastNode, KernCode))
01897             NewKernVal += (((KernCode*)LastNode)->GetValue()).x;
01898     }
01899 
01900     // Invoke an operation to apply the kern
01901     OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(OpTextKern));
01902     if (OpDesc != NULL)
01903     {
01904         OpParam param(NewKernVal,0);
01905         OpDesc->Invoke(&param);
01906     }
01907 
01908     return TRUE;
01909 }

BOOL TextTool::CommonApplyTracking MILLIPOINT  ChangeAmmount  )  [protected]
 

Applys/increases/descreases the tracking across the selected characters.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/04/95
Parameters:
ChangeAmmount - ammount to increase/decrease the tracking by [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/failure

Definition at line 1847 of file texttool.cpp.

01848 {
01849     // Create a new attribute to apply (will replace any existing)
01850     AttrTxtTracking* ApplyTrackingAttrib = new AttrTxtTracking();
01851     BOOL Success = (ApplyTrackingAttrib != NULL);
01852 
01853     if (Success)
01854     {
01855         // Get the current tracking ammount across the selection
01856         AttrTxtTracking* CurrentTrackingAttrib = NULL;
01857         SelRange::CommonAttribResult AttrRes = GetApplication()->FindSelection()->
01858                     FindCommonAttribute(CC_RUNTIME_CLASS(AttrTxtTracking), (NodeAttribute **)&CurrentTrackingAttrib);
01859         if (AttrRes == SelRange::ATTR_COMMON)
01860             ApplyTrackingAttrib->Value.Tracking = CurrentTrackingAttrib->Value.Tracking + ChangeAmmount;
01861         else
01862             ApplyTrackingAttrib->Value.Tracking = ChangeAmmount;
01863 
01864         // Apply the increased attribute to the selection
01865         AttributeManager::AttributeSelected(ApplyTrackingAttrib, NULL);
01866     }
01867 
01868     return Success;
01869 }

BOOL TextTool::CreateCursors  )  [protected]
 

Creates all the Text tool cursors.

Author:
Mark_Goodall (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if all the Text tool cursors have been successfully created
See also:
-

Definition at line 460 of file texttool.cpp.

00461 {
00462     // This tool has just been selected.  Create the cursors.
00463     pcNormalTextCursor = new Cursor(this, _R(IDC_TEXTTOOLBLOBCURSOR));
00464     pcBlobTextCursor = new Cursor(this, _R(IDC_TEXTTOOLCURSOR));
00465     pcIndentCursor = new Cursor(this, _R(IDC_TEXTTOOLINDENTCURSOR));
00466     pcBlankCursor = new Cursor(this, _R(IDC_TEXTTOOLBLANKCURSOR));
00467 
00468     if ( pcNormalTextCursor==NULL || !pcNormalTextCursor->IsValid() ||
00469          pcBlobTextCursor==NULL || !pcBlobTextCursor->IsValid() ||
00470          pcIndentCursor==NULL || !pcIndentCursor->IsValid() ||
00471          pcBlankCursor==NULL || !pcBlankCursor->IsValid() )
00472     {
00473         DestroyCursors();
00474         return FALSE;
00475     }
00476     else
00477         return TRUE;
00478 }

BOOL TextTool::DecreaseTrackKern  )  [protected]
 

If there is a text selection then the tracking applied to it is decreased by 10/1000's of an em If there is no selection then a kern down of 50/1000 is inserted.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/04/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/failure

Definition at line 1816 of file texttool.cpp.

01817 {
01818     // Get pointers to focus story and its caret
01819     TextStory* pStory = TextStory::GetFocusStory();
01820     ERROR3IF(pStory == NULL, "DecreaseTrackKern called without a focus story!");
01821     BOOL Success = TRUE;
01822 
01823     if (pStory != NULL)
01824     {
01825         if (pStory->GetSelectionEnd() == NULL)
01826             Success = CommonApplyKern(-50);
01827         else
01828             Success = CommonApplyTracking(-10);
01829     }
01830 
01831     return Success;
01832 }

BOOL TextTool::DelayingUpdate  )  [static]
 

Let's the caller know if the text-tool has finished mucking about with the document's modified flag.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/9/96
Returns:
TRUE if the text tool is saving up any updates to do when it is idle, FALSE if it isn't or if the text tool is not the current tool.
See also:
CCamSrvrItem::QueryTypeAhead

Definition at line 1950 of file texttool.cpp.

01951 {
01952     // Is the text tool the current tool?
01953     Tool* pTool = Tool::GetCurrent();
01954     if (!pTool || pTool->GetID() != TOOLID_TEXT) return FALSE;
01955 
01956     // Is it saving up some updates?
01957     return ((TextTool*) pTool)->UpdateAfterTyping;
01958 }

void TextTool::Describe void *  InfoPtr  )  [virtual]
 

Allows the tool manager to extract information about the tool.

Author:
Mark_Goodall (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
InfoPtr - A pointer to a tool info block. It is passed cast to void* as [INPUTS] the version of the tool is unknown at this point. Later versions of the Tool class may have more items in this block, that this tool will not use
InfoPtr - The structure pointed to by InfoPtr will have had all the info [OUTPUTS] that this version of the Tool knows about

Reimplemented from Tool_v1.

Definition at line 392 of file texttool.cpp.

00393 {
00394     // Cast structure into the latest one we understand.
00395     ToolInfo_v1 *Info = (ToolInfo_v1 *) InfoPtr;
00396 
00397     Info->InfoVersion = 1;
00398     
00399     Info->InterfaceVersion = GetToolInterfaceVersion();  // You should always have this line.
00400         
00401     // These are all arbitrary at present.
00402     Info->Version = 1;
00403     Info->ID      = GetID();
00404     Info->TextID  = _R(IDS_TEXT_TOOL);
00405 
00406     Info->Family  = FamilyName;
00407     Info->Name    = ToolName;
00408     Info->Purpose = Purpose;
00409     Info->Author  = Author;
00410 
00411     Info->BubbleID = _R(IDBBL_TEXT_TOOLBOX);
00412     // Text tool is associated with the BaseTextClass attribute group
00413     Info->CurrentAttributeGroup = CC_RUNTIME_CLASS(BaseTextClass); 
00414 }

void TextTool::DestroyCursors  )  [protected]
 

Destroys all the Text tool cursors.

Author:
Mark_Goodall (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 496 of file texttool.cpp.

00497 {
00498     if (pcNormalTextCursor != NULL) delete pcNormalTextCursor;
00499     if (pcBlobTextCursor != NULL) delete pcBlobTextCursor;
00500     if (pcIndentCursor != NULL) delete pcIndentCursor;
00501     if (pcBlankCursor != NULL) delete pcBlankCursor;
00502 }

void TextTool::DisplayStatusBarHelp DocCoord  DocPos,
Spread pSpread,
ClickModifiers  ClickMods
[protected]
 

Displays status help string for the given position in the status bar.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Parameters:
DocPos - the document coordinate of the point to display help on [INPUTS] pSpread - pointer to the spread containing DocPos ClickMods - the current click modifiers
- [OUTPUTS]
Returns:
-
See also:
TextTool::GetCurrentStatusText

Definition at line 1600 of file texttool.cpp.

01601 {
01602     String_256 StatusMsg("");
01603 
01604     // Get a string from the underlying help function and display it.
01605     GetCurrentStatusText(&StatusMsg, pSpread, DocPos, ClickMods);
01606     GetApplication()->UpdateStatusBarText(&StatusMsg);                           
01607 }

void TextTool::GetCurrentStatusText String_256 ptext,
Spread pSpread,
DocCoord  DocPos,
ClickModifiers  ClickMods
[protected]
 

Selects a suitable string for the status line based on the current location (as input via the parameters).

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Parameters:
pSpread points to a spread [INPUTS] DocPos points to a point in a document ClickMods are the current click modifiers
Updates the string in ptext [OUTPUTS]
Returns:
-
See also:
TextTool::GetStatusLineText, TextTool::DisplayStatusBarHelp

Definition at line 1654 of file texttool.cpp.

01655 {
01656     // If nothing is detected, we are over the document
01657     INT32 IDToUse = _R(IDS_TEXTTOOL_OVERDOCUMENT);
01658 
01659     // Is the caret in the focus story selected (ie, can the user type?)
01660     if (TextStory::GetFocusStory()!=NULL && TextStory::GetFocusStory()->GetCaret()!=NULL
01661             && TextStory::GetFocusStory()->GetCaret()->IsSelected())
01662     {
01663         IDToUse = _R(IDS_TEXTTOOL_OVERDOCUMENTC);
01664     }
01665     
01666     // Are we over a story or a path for a new story?
01667     TextStory* pTextStoryToSelect = NULL;
01668     if (IsPointNearUnselectedTextStory(pSpread, DocPos, &pTextStoryToSelect, NULL, TRUE))
01669     {
01670         if (pTextStoryToSelect != NULL)
01671             IDToUse = _R(IDS_TEXTTOOL_OVERTEXTSTORY);
01672     }
01673     else
01674     {
01675         NodePath* pPath = NULL;
01676         if (IsPointNearNonStoryPath(pSpread, DocPos, &pPath, TRUE))
01677             IDToUse = _R(IDS_TEXTTOOL_OVERNODEPATH);
01678     }
01679 
01680     // See if we are near any story path indent blobs
01681     BOOL LeftBlob = TRUE;
01682     TextStory* pFoundStory = NULL;
01683     if (!m_BlobPosList.FindBlobStory(pSpread, DocPos, &LeftBlob, &pFoundStory))
01684         InformError();
01685     else if (pFoundStory != NULL)
01686     {
01687         if (pFoundStory->GetTextPath() != NULL)
01688             IDToUse = _R(IDS_TEXTTOOL_DRAGPATHINDENT);
01689         else
01690             IDToUse = _R(IDS_TEXTTOOL_DRAGSTORYWIDTH);
01691     }
01692 
01693     ptext->Load(IDToUse);
01694 }

UINT32 TextTool::GetID void   )  [inline, virtual]
 

Reimplemented from Tool_v1.

Definition at line 200 of file texttool.h.

00200 { return TOOLID_TEXT; };

void TextTool::GetRulerOrigin Spread pSpread,
UserCoord pOrigin
[virtual]
 

Gives the current tool the chance to change the coordinates displayed on the ruler.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/Jun/2006
Parameters:
pSpread - the spread for which the ruler is displayed [INPUTS]
pOffsets - the desired origin shift in user space (is initialised to 0,0) [OUTPUTS]

Reimplemented from Tool_v1.

Definition at line 974 of file texttool.cpp.

00975 {
00976     if (TextInfoBarOp::IsRulerOriginClaimed())
00977     {
00978         pOrigin->x = TextInfoBarOp::GetRulerOrigin();
00979     }
00980 }

BOOL TextTool::GetRulerStatusLineText String_256 pText,
UserCoord  PointerPos,
Spread pSpread,
RulerBase pRuler
[virtual]
 

Allows the tool to set the status line text for the ruler.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
25/07/06
Parameters:
PointerPos - user coordinates of click on ruler (relative to origin set by tool) [INPUTS] pSpread - pointer to spread upon which click occurred pRuler - pointer to ruler which generated click
Status line text written to pText (if returning TRUE) [OUTPUTS]
Returns:
TRUE if the text has been set

Reimplemented from Tool_v1.

Definition at line 1038 of file texttool.cpp.

01040 {
01041     if (!TextInfoBarOp::IsRulerOriginClaimed()) return FALSE;
01042     return TextInfoBarOp::GetRulerStatusLineText(pText, PointerPos, pSpread, pRuler);
01043 }

BOOL TextTool::GetStatusLineText String_256 ptext,
Spread pSpread,
DocCoord  DocPos,
ClickModifiers  ClickMods
[virtual]
 

Returns the current status line help string.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/12/94
Parameters:
ptest - pointer to a string [INPUTS] pSpread points to a spread DocPos points to a point in a document ClickMods are the current click modifiers
Updates the string in ptext [OUTPUTS]
Returns:
TRUE if the string was updates (FALSE if not updated)
See also:
TextTool::GetCurrentStatusText, Tool_v1::GetStatusLineText

Reimplemented from Tool_v1.

Definition at line 1628 of file texttool.cpp.

01629 {
01630     // We can call the underlying help function to get a string and return the result.
01631     GetCurrentStatusText(ptext, pSpread, DocPos, ClickMods);
01632     return TRUE;
01633 }

static TextInfoBarOp* TextTool::GetTextInfoBarOp  )  [inline, static]
 

Definition at line 226 of file texttool.h.

00226 { return pTextInfoBarOp; }

BOOL TextTool::HandleDeadKeys KeyPress pKeyPress,
WCHAR pNewUnicode
[protected]
 

Flags 'dead-keys'. Attempts to apply an accent onto the next character.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/95
Parameters:
pKeyPress - points to the keypress object [INPUTS]
pNewUnicode contains the unicode value of the keypress, possibly changed to [OUTPUTS] an accented version of the pressed key.
Returns:
TRUE if keypress used, FALSE if not

Definition at line 2098 of file texttool.cpp.

02099 {
02100     BOOL UsedKey = FALSE;
02101     *pNewUnicode = pKeyPress->GetUnicode();
02102 //  WCHAR OldUnicode = *pNewUnicode;
02103 
02104     if (!UseDeadKeys)
02105         return FALSE;
02106 
02107     // Is this a dead key?
02108     if ( TestForDeadKey(pKeyPress, GraveVirtKey)    ||
02109          TestForDeadKey(pKeyPress, AcuteVirtKey)    ||
02110          TestForDeadKey(pKeyPress, HatVirtKey)      ||
02111          TestForDeadKey(pKeyPress, TildeVirtKey)    ||
02112          TestForDeadKey(pKeyPress, ColonVirtKey)    ||
02113          TestForDeadKey(pKeyPress, AtVirtKey)       ||
02114          TestForDeadKey(pKeyPress, SlashVirtKey)    ||
02115          TestForDeadKey(pKeyPress, CommaVirtKey) )
02116     {
02117         UsedKey = TRUE;
02118     }
02119 
02120     // This isn't a dead key, was the previous?
02121     if (!UsedKey && (PreviousDeadKey != NULL) && IsUsableUnicode(pKeyPress->GetUnicode()) )
02122     {
02123         // Get a pointer to the appropiate accent map
02124         UINT32* pMapArrays = NULL;
02125         if (PreviousDeadKey == GraveVirtKey)
02126             pMapArrays = GraveArray;
02127         else if (PreviousDeadKey == AcuteVirtKey)
02128             pMapArrays = AcuteArray;
02129         else if (PreviousDeadKey == HatVirtKey)
02130             pMapArrays = HatArray;
02131         else if (PreviousDeadKey == TildeVirtKey)
02132             pMapArrays = TildeArray;
02133         else if (PreviousDeadKey == ColonVirtKey)
02134             pMapArrays = ColonArray;
02135         else if (PreviousDeadKey == AtVirtKey)
02136             pMapArrays = AtArray;
02137         else if (PreviousDeadKey == SlashVirtKey)
02138             pMapArrays = SlashArray;
02139         else if (PreviousDeadKey == CommaVirtKey)
02140             pMapArrays = CommaArray;
02141         else
02142         {
02143             ERROR3("Unknown dead key");
02144             pMapArrays = NULL;
02145         }
02146 
02147         // See if the pressed key maps onto an accented version
02148         if (pMapArrays != NULL)
02149         {
02150             BOOL Found = FALSE;
02151             while (!Found && (*pMapArrays != 0))
02152             {
02153                 if (*pMapArrays == (UINT32)(*pNewUnicode))
02154                 {                                     
02155                     *pNewUnicode = *(pMapArrays+1);
02156                     Found = TRUE;
02157                 }
02158                 pMapArrays += 2;
02159             }
02160         }
02161 
02162         PreviousDeadKey = 0;
02163         UsedKey = FALSE;
02164     }
02165 
02166     return UsedKey;
02167 }

BOOL TextTool::HandleDoubleClick Spread pSpread,
DocCoord  ClickPos,
ClickModifiers  ClickMods
[protected]
 

To handle double click events in the text tool.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/02/95
Parameters:
pSpread - The spread in which the click occurred [INPUTS] ClickPos - The DocCoord of the point where the mouse was clicked ClickMods - The state of the various modifiers at the time of the click
Returns:
FALSE if an error occurs during processing
See also:
TextTool::OnClick

Definition at line 666 of file texttool.cpp.

00667 {
00668     BOOL Success = TRUE;
00669     // Select the word at the caret
00670     if ((TextStory::GetFocusStory() != NULL) && !ClickMods.Constrain && !ClickMods.Adjust)
00671     {
00672         OpTextCaret* pOp = new OpTextCaret();
00673         if (pOp != NULL)
00674             pOp->DoSelectWordAtCaret();
00675         else
00676             Success = FALSE;
00677     }
00678     return Success;
00679 }

BOOL TextTool::HandleDragClick Spread pSpread,
DocCoord  ClickPos,
ClickModifiers  ClickMods
[protected]
 

To handle drag events in the text tool.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/02/95
Parameters:
pSpread - The spread in which the click occurred [INPUTS] ClickPos - The DocCoord of the point where the mouse was clicked ClickMods - The state of the various modifiers at the time of the click
Returns:
FALSE if an error occurs during processing
See also:
TextTool::OnClick

Definition at line 746 of file texttool.cpp.

00747 {
00748     return TRUE;
00749 }

BOOL TextTool::HandleQuadClick Spread pSpread,
DocCoord  ClickPos,
ClickModifiers  ClickMods
[protected]
 

To handle quad click events in the text tool.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/12/95
Parameters:
pSpread - The spread in which the click occurred [INPUTS] ClickPos - The DocCoord of the point where the mouse was clicked ClickMods - The state of the various modifiers at the time of the click
Returns:
FALSE if an error occurs during processing
See also:
TextTool::OnClick

Definition at line 724 of file texttool.cpp.

00725 {
00726     return TRUE;
00727 }

BOOL TextTool::HandleSingleClick Spread pSpread,
DocCoord  ClickPos,
ClickModifiers  ClickMods
[protected]
 

To handle single click events in the text tool.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/02/95
Parameters:
pSpread - The spread in which the click occurred [INPUTS] ClickPos - The DocCoord of the point where the mouse was clicked ClickMods - The state of the various modifiers at the time of the click
Returns:
FALSE if an error occurs during processing
See also:
TextTool::OnClick

Definition at line 584 of file texttool.cpp.

00585 {
00586     Node* pHitObject = NULL;
00587     TextStory* pTextStoryToSelect = NULL;
00588 
00589     // Is the click over an indent blob?
00590     BOOL BlobIsLeft = TRUE;
00591     TextStory* pFoundStory = NULL;
00592     if (!m_BlobPosList.FindBlobStory(pSpread, ClickPos, &BlobIsLeft, &pFoundStory))
00593         return FALSE;
00594     
00595     if (pFoundStory != NULL)
00596     {
00597         if (!m_BlobPosList.RenderAndRemove(pFoundStory))
00598             return FALSE;
00599 
00600         // Invoke a operation to drag the indent position
00601         OpDragStoryIndent* pOp = NULL;
00602         if (BlobIsLeft)
00603         {
00604             if (pFoundStory->GetTextPath() != NULL)
00605                 pOp = new OpDragStoryPathLeftIndent;
00606             else
00607                 pOp = new OpDragStoryNonPathLeftIndent;
00608         }
00609         else
00610         {
00611             if (pFoundStory->GetTextPath() != NULL)
00612                 pOp = new OpDragStoryPathRightIndent;
00613             else
00614                 pOp = new OpDragStoryNonPathRightIndent;
00615         }
00616         if (pOp==NULL)
00617             return FALSE;
00618         else
00619             return pOp->DoDrag(ClickPos, pSpread, ClickMods, pFoundStory);
00620     }
00621     else if ( IsPointNearUnselectedTextStory(pSpread, ClickPos, &pTextStoryToSelect, &pHitObject, FALSE) )
00622     {
00623         // Position the caret with a story, and drag selection
00624         OpTextSelection* pOp = new OpTextSelection;
00625         if (pOp == NULL)
00626             return FALSE;
00627         else
00628             return pOp->DoDrag(ClickPos, pSpread, ClickMods, pHitObject);
00629     }
00630     else
00631     {
00632         // Create a new text story
00633         OpCreateTextObject* pOpCreateTextObject = new OpCreateTextObject;
00634         if (pOpCreateTextObject == NULL)
00635             return FALSE;
00636         else
00637         {
00638             NodePath* pPath = NULL;
00639             IsPointNearNonStoryPath(pSpread, ClickPos, &pPath, FALSE);
00640             if (pPath != NULL)
00641                 pOpCreateTextObject->DoImmediate(pSpread, ClickPos, pPath, ClickMods);
00642             else
00643                 pOpCreateTextObject->DoDrag(pSpread, ClickPos, ClickMods);
00644         }
00645     }
00646     return TRUE;
00647 }                                               

BOOL TextTool::HandleSpecialNonStoryKeys KeyPress pKeyPress  )  [protected]
 

To deal with keys presses that work without a focus story.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/08/95
Parameters:
pKeyPress - pointer to a keypress object [INPUTS]
Returns:
TRUE if it used the keypress, FALSE otherwise
See also:
TextTool::HandleSpecialStoryKeys, TextTool::HandleSpecialStoryAndNonStoryKeys

Definition at line 1297 of file texttool.cpp.

01298 {
01299     ERROR3IF(pKeyPress == NULL, "KeyPress pointer was NULL");
01300     if (pKeyPress == NULL)
01301         return FALSE;
01302 
01303     BOOL UsedTheKeypress = FALSE;
01304 
01305     switch (pKeyPress->GetVirtKey())
01306     {
01307         case CAMKEY(UP):
01308         case CAMKEY(DOWN):
01309         case CAMKEY(LEFT):
01310         case CAMKEY(RIGHT):
01311             UsedTheKeypress = TRUE;     // Just eat the keypress
01312             break;
01313     }
01314     TRACEUSER("wuerthne", _T("HandleSpecialNonStoryKeys returns %d"), UsedTheKeypress);
01315     return UsedTheKeypress;
01316 }

BOOL TextTool::HandleSpecialStoryAndNonStoryKeys KeyPress pKeyPress  )  [protected]
 

To handle keypress events that wotk with and without a text focus story.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/06/95
Parameters:
pKeyPress - pointer to a keypress object [INPUTS]
Returns:
TRUE if it handled the keypress, FALSE otherwise
See also:
TextTool::HandleSpecialStoryKeys, TextTool::HandleSpecialNonStoryKeys

Definition at line 1248 of file texttool.cpp.

01249 {
01250     ERROR3IF(pKeyPress == NULL, "KeyPress pointer was NULL");
01251     if (pKeyPress == NULL)
01252         return FALSE;
01253 
01254     if (pKeyPress->IsChar()) return FALSE;      // only use non-char events for hotkeys
01255 
01256     BOOL UsedTheKeypress = FALSE;
01257     BOOL Errored = FALSE;
01258 
01259     switch (pKeyPress->GetVirtKey())
01260     {
01261         case CAMKEY(B):
01262             // Apply/Remove bold to/from the selection
01263             if (pKeyPress->IsConstrain() && !pKeyPress->IsAdjust() )
01264             {
01265                 UsedTheKeypress = TRUE;
01266                 Errored = !ApplyBold();
01267             }
01268             break;
01269         case CAMKEY(I):
01270             // Apply/Remove italic to/from the selection
01271             if (pKeyPress->IsConstrain() && !pKeyPress->IsAdjust() )
01272             {
01273                 UsedTheKeypress = TRUE;
01274                 Errored = !ApplyItalic();
01275             }
01276             break;
01277     }
01278 
01279     if (Errored)
01280         InformError();
01281     TRACEUSER("wuerthne", _T("HandleSpecialStoryAndNonStoryKeys returns %d"), UsedTheKeypress);
01282     return UsedTheKeypress;
01283 }

BOOL TextTool::HandleSpecialStoryKeys KeyPress pKeyPress,
TextStory pStory,
CaretNode pCaret
[protected]
 

To handle special keypress events that apply at a story and/or caret.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/06/95
Parameters:
pKeyPress - pointer to a keypress object [INPUTS] pStory - points to the story with the caret pCaret - points to the caret
Returns:
TRUE if it handled the keypress, FALSE otherwise
See also:
TextTool::HandleSpecialNonStoryKeys

Definition at line 1333 of file texttool.cpp.

01334 {
01335     TRACEUSER("wuerthne", _T("HandleSpecialStoryKeys %d"), pKeyPress->GetVirtKey());
01336     ERROR3IF(pKeyPress == NULL, "KeyPress pointer was NULL");
01337     ERROR3IF(pStory == NULL, "Story pointer was NULL");
01338     ERROR3IF(pCaret == NULL, "Caret pointer was NULL");
01339     if ((pKeyPress == NULL) || (pStory == NULL) || (pCaret == NULL))
01340         return FALSE;
01341 
01342     BOOL IsNonCharEvent = !pKeyPress->IsChar(); // only use non-char events for hotkeys, but eat char events matching our hotkeys
01343     BOOL UsedTheKeypress = FALSE;
01344     BOOL Errored = FALSE;
01345 
01346     switch (pKeyPress->GetVirtKey())
01347     {
01348         case CAMKEY(HOME):
01349             // Move caret to start of line
01350             if (IsNonCharEvent)
01351             {
01352                 OpTextCaret* pOp = new OpTextCaret();
01353                 if (pOp != NULL)
01354                     pOp->DoMoveCaretHome(pKeyPress->IsAdjust(), pKeyPress->IsConstrain()); 
01355                 else
01356                     Errored = TRUE;
01357             }
01358             UsedTheKeypress = TRUE;
01359             break;
01360         case CAMKEY(END):
01361             // Move caret to end of line
01362             if (IsNonCharEvent)
01363             {
01364                 OpTextCaret* pOp = new OpTextCaret();
01365                 if (pOp != NULL)
01366                     pOp->DoMoveCaretEnd(pKeyPress->IsAdjust(), pKeyPress->IsConstrain()); 
01367                 else
01368                     Errored = TRUE;
01369             }
01370             UsedTheKeypress = TRUE;
01371             break;
01372         case CAMKEY(BACK):
01373             // delete character before caret, or selected chars if either exists
01374             if (IsNonCharEvent && (pStory->GetSelectionEnd() || pCaret->FindPrevVTNInStory() != NULL))
01375             {
01376                 OpTextFormat* pOp = new OpTextFormat();
01377                 if (pOp != NULL)
01378                     pOp->DoDeleteChar(OpTextFormat::BACKSPACE); 
01379                 else
01380                     Errored = TRUE;
01381             }
01382             UsedTheKeypress = TRUE;
01383             break;
01384         case CAMKEY(DELETE):
01385             // delete character before caret, or selected chars if either exists
01386             if (IsNonCharEvent && (pStory->GetSelectionEnd() || pCaret->FindNextVTNInStory() != pStory->FindLastVTN()))
01387             {
01388                 OpTextFormat* pOp = new OpTextFormat();
01389                 if (pOp != NULL)
01390                     pOp->DoDeleteChar(OpTextFormat::DEL); 
01391                 else
01392                     Errored = TRUE;
01393             }
01394             UsedTheKeypress = TRUE;
01395             break;
01396         case CAMKEY(LEFT):
01397             // Move/Select caret left one word/character
01398             if (IsNonCharEvent)
01399             {
01400                 TRACEUSER("wuerthne", _T("caret left"));
01401                 OpTextCaret* pOp = new OpTextCaret();
01402                 if (pOp != NULL)
01403                     pOp->DoMoveCaretLeft(pKeyPress->IsAdjust(), pKeyPress->IsConstrain());
01404                 else
01405                     Errored = TRUE;
01406             }
01407             UsedTheKeypress = TRUE;
01408             break;
01409         case CAMKEY(RIGHT):
01410             // Move/Select caret right one word/character
01411             if (IsNonCharEvent)
01412             {
01413                 OpTextCaret* pOp = new OpTextCaret();
01414                 if (pOp != NULL)
01415                     pOp->DoMoveCaretRight(pKeyPress->IsAdjust(), pKeyPress->IsConstrain());
01416                 else
01417                     Errored = TRUE;
01418             }
01419             UsedTheKeypress = TRUE;
01420             break;
01421         case CAMKEY(UP):
01422             // Move/Select caret up a line
01423             if (IsNonCharEvent)
01424             {
01425                 OpTextCaret* pOp = new OpTextCaret();
01426                 if (pOp != NULL)
01427                     pOp->DoMoveCaretUp(pKeyPress->IsAdjust());
01428                 else
01429                     Errored = TRUE;
01430             }
01431             UsedTheKeypress = TRUE;
01432             break;
01433         case CAMKEY(DOWN):
01434             // Move/Select caret down a line
01435             if (IsNonCharEvent)         
01436             {
01437                 OpTextCaret* pOp = new OpTextCaret();
01438                 if (pOp != NULL)
01439                     pOp->DoMoveCaretDown(pKeyPress->IsAdjust());
01440                 else
01441                     Errored = TRUE;
01442             }
01443             UsedTheKeypress = TRUE;
01444             break;
01445         case CAMKEY(C):
01446             // Swap case (was Control-W, now Control-Shift-C)
01447             if (pKeyPress->IsConstrain() && pKeyPress->IsAdjust() )
01448             {
01449                 if (IsNonCharEvent && TextStory::GetFocusStory()->GetCaret()->FindNextTextCharInStory() != NULL)
01450                 {
01451                     OpTextFormat* pOp = new OpTextFormat();
01452                     if (pOp != NULL)
01453                     {
01454                         pOp->DoSwapCase();
01455                     }
01456                     else
01457                         Errored = TRUE;
01458                 }
01459                 UsedTheKeypress = TRUE;
01460             }
01461             break;
01462         case CAMKEY(A):
01463             // Select all in the focus story, if there is one
01464             if (pKeyPress->IsConstrain() && !pKeyPress->IsAdjust())
01465             {
01466                 if (IsNonCharEvent)
01467                 {
01468                     OpTextSelection* pOp = new OpTextSelection();
01469                     if (pOp != NULL)
01470                         Errored = !pOp->DoSelectAllText(TextStory::GetFocusStory());
01471                     else
01472                         Errored = TRUE;
01473                 }
01474                 UsedTheKeypress = TRUE;
01475             }
01476             break;
01477 
01478         case CAMKEY(V):
01479             // Paste text from the clipboard into a selected text story
01480             if (pKeyPress->IsConstrain() && !pKeyPress->IsAdjust())
01481             {
01482                 if (IsNonCharEvent)
01483                 {
01484                     // is there a focus story?
01485                     OpTextPaste* pOp = new OpTextPaste();
01486                     if (pOp != NULL)
01487                         pOp->Do(NULL);
01488                 }
01489                 UsedTheKeypress = TRUE;
01490             }
01491             break;
01492 
01493         case CAMKEY(L):
01494             // Select all text on the line with the caret
01495             if (pKeyPress->IsConstrain() && !pKeyPress->IsAdjust())
01496             {
01497                 TextLine* pLine = (TextLine*)TextStory::GetFocusStory()->GetCaret()->FindParent(CC_RUNTIME_CLASS(TextLine));
01498                 if (pLine != NULL)
01499                 {
01500                     if (IsNonCharEvent)
01501                     {
01502                         OpTextSelection* pOp = new OpTextSelection();
01503                         if (pOp != NULL)
01504                             Errored = !pOp->DoSelectLineText();
01505                         else
01506                             Errored = TRUE;
01507                     }
01508                     UsedTheKeypress = TRUE;
01509                 }
01510             }
01511             break;
01512         case CAMKEY(EQUALS):
01513             // Increase kerning/tracking
01514             if (pKeyPress->IsConstrain() && !pKeyPress->IsAdjust() )
01515             {
01516                 UsedTheKeypress = TRUE;
01517                 Errored = IsNonCharEvent ? !IncreaseTrackKern() : FALSE;
01518             }
01519             break;
01520         case CAMKEY(MINUS):
01521             // Decrease kerning/tracking
01522             if (pKeyPress->IsConstrain() && !pKeyPress->IsAdjust() )
01523             {
01524                 UsedTheKeypress = TRUE;
01525                 Errored = IsNonCharEvent ? !DecreaseTrackKern() : FALSE;
01526             }
01527             break;
01528         case CAMKEY(RETURN):
01529             // Create a new TextLine and move the caret to it.
01530             if (!pKeyPress->IsAlternative() && !pKeyPress->IsConstrain())
01531             {
01532                 if (IsNonCharEvent)
01533                 {
01534                     OpTextFormat* pOp = new OpTextFormat();
01535                     if (pOp != NULL)
01536                         Errored = !pOp->DoReturn(OpTextFormat::INSERT);
01537                     else
01538                         Errored = TRUE;
01539                 }
01540                 UsedTheKeypress = TRUE;
01541             }
01542             break;
01543         case CAMKEY(TAB):
01544             if (!pKeyPress->IsAlternative() && !pKeyPress->IsConstrain())
01545             {
01546                 if (IsNonCharEvent)
01547                 {
01548                     /* Create a tab node */
01549                     OpTextFormat* pOp = new OpTextFormat();
01550                     if (pOp != NULL)
01551                         Errored = !pOp->DoTab();
01552                     else
01553                         Errored = TRUE;
01554                 }
01555                 UsedTheKeypress = TRUE;
01556             }
01557             break;
01558         case CAMKEY(ESCAPE):
01559             // Deselect the caret and select the text story
01560             if (!pKeyPress->IsAlternative() && !pKeyPress->IsConstrain())
01561             {
01562                 if (IsNonCharEvent)
01563                 {
01564                     pCaret->DeSelect(TRUE);
01565                     pStory->Select(TRUE);
01566                     GetApplication()->FindSelection()->Update(TRUE);
01567                 }
01568                 UsedTheKeypress = TRUE;
01569 
01570                 // Remove the focus story if it was empty
01571                 Errored = IsNonCharEvent ? !OpDeleteTextStory::RemoveEmptyFocusStory() : FALSE;
01572             }
01573             break;
01574     }
01575 
01576     if (Errored)
01577         InformError();
01578 
01579     return UsedTheKeypress;
01580 }

BOOL TextTool::HandleTripleClick Spread pSpread,
DocCoord  ClickPos,
ClickModifiers  ClickMods
[protected]
 

To handle triple click events in the text tool.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/02/95
Parameters:
pSpread - The spread in which the click occurred [INPUTS] ClickPos - The DocCoord of the point where the mouse was clicked ClickMods - The state of the various modifiers at the time of the click
Returns:
FALSE if an error occurs during processing
See also:
TextTool::OnClick

Definition at line 695 of file texttool.cpp.

00696 {
00697     ERROR2IF(TextStory::GetFocusStory()==NULL, FALSE, "No focus story");
00698     ERROR2IF(TextStory::GetFocusStory()->GetCaret()==NULL, FALSE, "No caret in focus story");
00699     
00700     TextLine* pLine = (TextLine*)TextStory::GetFocusStory()->GetCaret()->FindParent(CC_RUNTIME_CLASS(TextLine));
00701     ERROR2IF(pLine==NULL, FALSE, "Caret didn't have a parent TextLine");
00702 
00703     OpTextSelection* pOp = new OpTextSelection();
00704     if (pOp != NULL)
00705         return pOp->DoSelectLineText();
00706     else
00707         return FALSE;
00708 }

BOOL TextTool::IncreaseTrackKern  )  [protected]
 

If there is a text selection then the tracking applied to it is increased by 10/1000's of an em If there is no selection then a kern up of 50/1000 is inserted.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/04/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/failure

Definition at line 1783 of file texttool.cpp.

01784 {
01785     // Get pointers to focus story and its caret
01786     TextStory* pStory = TextStory::GetFocusStory();
01787     ERROR3IF(pStory == NULL, "IncreaseTrackKern called without a focus story!");
01788     BOOL Success = TRUE;
01789 
01790     if (pStory != NULL)
01791     {
01792         if (pStory->GetSelectionEnd() == NULL)
01793             Success = CommonApplyKern(50);
01794         else
01795             Success = CommonApplyTracking(10);
01796     }
01797 
01798     return Success;
01799 }

BOOL TextTool::Init void   )  [virtual]
 

Used to check if the Tool was properly constructed.

Author:
Mark_Goodall (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Returns:
FALSE if it does not want to be created, TRUE otherwise
See also:
TextTool::TextTool

Reimplemented from Tool_v1.

Definition at line 309 of file texttool.cpp.

00310 {
00311     // Declare all your ops here and only succeed if all declarations succeed
00312 
00313     BOOL ok = TRUE;
00314 
00315     // Register CreateTextObjectOp 
00316     ok = ok && OpCreateTextObject::Init(); 
00317     ok = ok && OpTextSelection::Init(); 
00318     ok = ok && OpDeleteTextStory::Init(); 
00319     ok = ok && OpReverseStoryPath::Init(); 
00320     ok = ok && OpApplyJustificationToStory::Init(); 
00321     ok = ok && OpTextPaste::Init();
00322     ok = ok && OpTogglePrintTextAsShapes::Init();
00323     ok = ok && OpDragStoryNonPathLeftIndent::Init();
00324     ok = ok && OpDragStoryNonPathRightIndent::Init();
00325     ok = ok && OpDragStoryPathLeftIndent::Init();
00326     ok = ok && OpDragStoryPathRightIndent::Init();
00327     ok = ok && OpAffectFontChange::Init();
00328     ok = ok && TextInfoBarOp::Init(); // static initialisation
00329 
00330     // This section reads in the infobar definition and creates an instance of
00331     // TextInfoBarOp.  Also pTextInfoBarOp, the ptr to the tool's infobar, is set up
00332     // after the infobar is successfully read and created.
00333     if (ok)
00334     {
00335 #if 0
00336         CCResTextFile       file;               // Resource File
00337         TextInfoBarOpCreate BarCreate;          // Object that creates TextInfoBarOp objects
00338 
00339                 ok = file.open(_R(IDM_TEXT_BAR), _R(IDT_INFO_BAR_RES));     // Open resource
00340         if (ok) ok = DialogBarOp::ReadBarsFromFile(file,BarCreate); // Read and create info bar
00341         if (ok) file.close();                                       // Close resource
00342 
00343         ENSURE(ok,"Unable to load Textbar.ini from resource\n"); 
00344 
00345         if (ok)
00346         {
00347             // Info bar now exists.  Now get a pointer to it
00348             String_32 str = String_32(_R(IDS_TEXTTOOL_INFOBARNAME));
00349             DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(str);
00350 
00351                     ok = (pDialogBarOp != NULL);
00352             if (ok) ok = pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(TextInfoBarOp));
00353             if (ok) pTextInfoBarOp = (TextInfoBarOp*)pDialogBarOp;
00354 
00355             ENSURE(ok,"Error finding the Text tool info bar");
00356         }
00357 #endif
00358         pTextInfoBarOp = new TextInfoBarOp();
00359         ok = (pTextInfoBarOp != NULL);
00360         ENSURE(ok,"Error finding the Text tool info bar");
00361     }
00362 
00363     // Read preference settings
00364     GetApplication()->DeclareSection(_T("TextTool"),1);
00365     GetApplication()->DeclarePref(_T("TextTool"),_T("UseDeadKeys"), &UseDeadKeys, 0, 1);
00366 
00367     // Read deadkey virtual key codes for the current driver
00368     if (ok)
00369         ok = RegisterDeadKeys();
00370 
00371     return (ok);
00372 }

static BOOL TextTool::IsCurrentTool  )  [inline, static]
 

Definition at line 228 of file texttool.h.

00228 { return CurrentTool; }

BOOL TextTool::IsPointNearNonStoryPath Spread pSpread,
DocCoord  PointerPos,
NodePath **  pHitPath,
BOOL  AllowInterrupts
[protected]
 

To see if a click at the current positon should create a story on a path.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/02/95
Parameters:
pSpread - The spread in which the point is in [INPUTS] PointerPos - The DocCoord of the point where the mouse has moved to AllowInterrupts - TRUE to stop the hit detection if the mouse moves
pHitPath will point to the NodePath the pointer is over, or NULL [OUTPUTS]
Returns:
TRUE if the pointer is over an NodePath, FALSE if not
See also:
TextTool::IsPointNearUnselectedTextStory

Definition at line 893 of file texttool.cpp.

00894 {
00895     Node* pInterrupt;
00896     NodeRenderableInk* pObject = NULL;
00897     *pHitPath = NULL;
00898 
00899     if (AllowInterrupts)
00900         pObject = NodeRenderableInk::FindSimpleAtPoint(pSpread, PointerPos, NULL, &pInterrupt);
00901     else
00902         pObject = NodeRenderableInk::FindSimpleAtPoint(pSpread, PointerPos);
00903 
00904     // If its a NodePath that isn't already a story path
00905     if (pObject != NULL)
00906     {
00907         Node* pParent = pObject->FindParent();
00908         ObjChangeParam ChangeData(OBJCHANGE_STARTING, ObjChangeFlags(TRUE), pObject, NULL);
00909         if (IS_A(pObject, NodePath) && pObject->IsSelected() &&     /* It must be a selected path */
00910             (pParent != NULL) && !IS_A(pParent, TextStory) &&       /* It's not already in a story */
00911             pObject->AllowOp(&ChangeData, FALSE) )                  /* And the path is happy with being deleted */
00912         {
00913             // Only allows clicks on the edge of the path (not the inside of filled shapes)
00914             NodePath* pPath = (NodePath*)pObject;
00915             INT32 PathSlot = 0;
00916             if (pPath->InkPath.PointCloseToLine(PointerPos, &PathSlot))
00917             {
00918                 *pHitPath = (NodePath*)pObject;
00919                 return TRUE;
00920             }
00921         }
00922     }
00923 
00924     return FALSE;
00925 }                                                                                 

BOOL TextTool::IsPointNearUnselectedTextStory Spread pSpread,
DocCoord  ClickPos,
TextStory **  pTS,
Node **  pHitObject,
BOOL  AllowInterrupts
[protected]
 

To see if a click at the current positon would select a TextStory.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/02/95
Parameters:
PointerPos - The DocCoord of the point where the mouse has moved to [INPUTS] pSpread - The spread in which the move occurred AllowInterrupts - TRUE to stop the hit detection if the mouse moves
pTS will point to the TextStory to select, or NULL [OUTPUTS] pHitObject will point the the object under the pointer, or NULL (Set to NULL if not interested about objects)
Returns:
TRUE if the pointer is over an text story. FALSE if not
See also:
TextTool::IsPointNearNonStoryPath

Definition at line 776 of file texttool.cpp.

00777 {
00778     Node* pInterrupt;
00779     NodeRenderableInk* pObject = NULL;
00780 
00781     if (AllowInterrupts)
00782         pObject = NodeRenderableInk::FindSimpleAtPoint(pSpread, ClickPos, NULL, &pInterrupt);
00783     else
00784         pObject = NodeRenderableInk::FindSimpleAtPoint(pSpread, ClickPos);
00785 
00786     // The text tool has always ignored the compound node structure of the document
00787     // and allowed a text object to be selected inside any amount of nested nodes.
00788     // This is actually useful most of the time but we can't allow /anything/ to be
00789     // edited inside a locked effect because the changes will not be seen while
00790     // the locked effect's own bitmap is being rendered...
00791     NodeRenderableInk* pCompound = NodeRenderableInk::FindCompoundFromSimple(pObject);
00792     if (pCompound && pCompound->IsEffect() && ((NodeEffect*)pCompound)->IsLockedEffect())
00793         return FALSE;
00794 
00795     *pTS = NULL;
00796     if (pHitObject!=NULL)
00797         *pHitObject = NULL;
00798 
00799     // BODGE - lets assume the char is a child of the line of the story
00800     if (pObject != NULL)
00801     {
00802         if (pObject->IsAVisibleTextNode())
00803         {
00804             if (pHitObject!=NULL)
00805                 *pHitObject = pObject;
00806             *pTS = (TextStory*)(pObject->FindParent()->FindParent());
00807             return TRUE;
00808         }
00809     }
00810 
00811     // We didn't find anything via hittesting.  Now scan the stories on this spread to see
00812     // if we are over blank areas of the story.
00813     Node* pNode = pSpread->FindFirstDepthFirst();
00814     while (pNode != NULL)
00815     {
00816         if (pNode->IsABaseTextClass() && IS_A(pNode, TextStory))
00817         {
00818             // Check to see if the point is within the bounds of the story
00819             TextStory* pStory = (TextStory*)pNode;
00820             DocRect StoryBounds = pStory->GetBoundingRect(TRUE);
00821             if (StoryBounds.ContainsCoord(ClickPos))
00822             {
00823                 // Story must not be on a path and must be on an unlocked layer, and not in a mould
00824                 Layer* pLayer = (Layer*)pStory->FindParent(CC_RUNTIME_CLASS(Layer));
00825                 NodeMould* pMould = (NodeMould*)pStory->FindParent(CC_RUNTIME_CLASS(NodeMould));
00826                 if (pLayer!=NULL && pMould==NULL && pStory->GetTextPath()==NULL && !pLayer->IsLocked())
00827                 {
00828                     // If the client wants the object then we have to do more work
00829                     if (pHitObject!=NULL)
00830                     {
00831                         VisibleTextNode* pNearObject = NULL;
00832                         BOOL ToLeft = FALSE;
00833                         if (!pStory->GetCharacterAtPoint(TRUE, ClickPos, &pNearObject, &ToLeft))
00834                         {
00835                             InformError();
00836                             return FALSE;
00837                         }
00838                         else
00839                         {
00840                             if (pNearObject != NULL)
00841                             {
00842                                 *pHitObject = pNearObject;
00843                                 *pTS = pStory;
00844                                 return TRUE;
00845                             }
00846                         }
00847                     }
00848                     else
00849                     {
00850                         // Get untransformed story bounds and point
00851                         DocRect UTStory = pStory->GetUTStoryBounds();
00852                         DocCoord UTPoint = ClickPos;
00853                         Matrix StoryMat = pStory->GetStoryMatrix();
00854                         StoryMat=StoryMat.Inverse();
00855                         StoryMat.transform(&UTPoint);
00856 
00857                         if (UTStory.ContainsCoord(UTPoint))
00858                         {
00859                             *pTS=pStory;
00860                             return TRUE;
00861                         }
00862                     }
00863                 }
00864             }
00865         }
00866         pNode = pNode->FindNextDepthFirst(pSpread);
00867     }
00868 
00869     return FALSE;
00870 }

BOOL TextTool::IsUsableUnicode WCHAR  CodeValue  )  [protected]
 

Central place to filter out unicode greater than 255.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/95
Parameters:
CodeValue - a number representing a unicode character [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the text tool accepts the character, FALSE if it dosen't

Definition at line 2212 of file texttool.cpp.

02213 {
02214     return ( ((CodeValue>=32) && (CodeValue<=126)) || ((CodeValue>=128) && (CodeValue<=255)) );
02215 }

void TextTool::LocaleChanged  ) 
 

Called when the machines locale changes. Re-registers the dead keys as their virtual key code may have changed.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 2230 of file texttool.cpp.

02231 {
02232     RemoveDeadKeys();
02233     if (!RegisterDeadKeys())
02234         InformError();
02235 }

void TextTool::OnClick DocCoord  PointerPos,
ClickType  Click,
ClickModifiers  ClickMods,
Spread pSpread
[virtual]
 

To handle a Mouse Click event for the Text Tool.

Author:
Mark_Goodall (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
PointerPos - The DocCoord of the point where the mouse button was clicked [INPUTS] Click - Describes the type of click that was detected. ClickMods - Indicates which buttons caused the click and which modifers were pressed at the same time pSpread - The spread in which the click happened
Returns:
-
See also:
Tool::MouseClick; ClickType; ClickModifiers; TextTool::HandleSingleClick; TextTool::HandleDoubleClick; TextTool::HandleDragClick

Reimplemented from Tool_v1.

Definition at line 525 of file texttool.cpp.

00526 {
00527     if (ClickMods.Menu) return;                         // Don't do anything if the user clicked the Menu button
00528 
00529     if (IsBlankCursorUp)
00530         return;
00531 
00532     DocView* pDocView = DocView::GetSelected();
00533     if (pDocView == NULL)
00534     {
00535         ERROR3("No selected doc view!");
00536     }
00537     else
00538     {
00539         BOOL Success = TRUE;
00540     
00541         switch (Click)
00542         {
00543             case CLICKTYPE_SINGLE:
00544                 if (pDocView->IsSingleClickReallyTriple())
00545                     Success = HandleTripleClick(pSpread, PointerPos, ClickMods);
00546                 else
00547                     Success = HandleSingleClick(pSpread, PointerPos, ClickMods);
00548                 break;
00549             case CLICKTYPE_DOUBLE:
00550                 if (pDocView->IsSingleClickReallyQuad())
00551                     Success = HandleQuadClick(pSpread, PointerPos, ClickMods);
00552                 else
00553                     Success = HandleDoubleClick(pSpread, PointerPos, ClickMods);
00554                 break;
00555             case CLICKTYPE_DRAG:
00556                 Success = HandleDragClick(pSpread, PointerPos, ClickMods);
00557                 break;
00558             default:
00559                 break;
00560         }
00561 
00562         if (!Success)
00563             InformError();
00564     }
00565 }

BOOL TextTool::OnIdle  )  [virtual]
 

Called on idle events. Used to update the infobar kern field after typing.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/08/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for more/no more idles needed

Reimplemented from Tool_v1.

Definition at line 1924 of file texttool.cpp.

01925 {
01926     if (UpdateAfterTyping)
01927     {
01928         if (!pTextInfoBarOp->UpdateFieldsAfterTyping())
01929             InformError();
01930         UpdateAfterTyping = FALSE;
01931     }
01932 
01933     return FALSE;
01934 }

BOOL TextTool::OnKeyPress KeyPress pKeyPress  )  [virtual]
 

To handle a keypress event for the Text Tool.

> BOOL TextTool::OnKeyPress(KeyPress* pKeyPress)

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/02/95
Parameters:
pKeyPress - pointer to a keypress object [INPUTS]
Returns:
TRUE if it handled the keypress, FALSE otherwise
See also:
-

Reimplemented from Tool_v1.

Definition at line 1058 of file texttool.cpp.

01059 {
01060     TRACEUSER( "wuerthne", _T("TextTool::OnKeyPress, IsChar=%d IsRelease=%d VirtKey=%d\n"),
01061                pKeyPress->IsChar(), pKeyPress->IsRelease(), pKeyPress->GetVirtKey() );
01062 
01063     // NB - each keypress casues three events:
01064     //      (1) a key down event (IsChar() = FALSE, IsRelease() = FALSE) - which may not have the
01065     //          correct Unicode char value because it has not been through the IM yet
01066     //      (2) a char event (IsChar() = TRUE, IsRelease() = FALSE) - with the correct Unicode
01067     //          char but with different values for GetVirtKey (e.g., Ctrl+char is reported as
01068     //          a ctrl code)
01069     //      (3) a release event (IsChar() = FALSE, IsRelease() = TRUE)
01070 
01071     // Our strategy is to use the key down event for shortcuts, to use the char events for
01072     // actual input and to ignore the release events. Care must be taken to swallow enough
01073     // events, e.g., though cursor movement is handled using the key down event, the
01074     // corresponding char event must be swallowed, too, otherwise the reported Unicode
01075     // character ends up being inserted in the text object. Finally, all non-char events
01076     // we do not swallow here will be processed by the hotkey system.
01077 
01078     // Filter out all key release events 
01079     if (pKeyPress->IsRelease())
01080     {
01081         TRACEUSER( "wuerthne", _T("Release\n") );
01082 
01083         if (GetApplication()->FindSelection()->IsSelRangeGagged())
01084         {
01085             GetApplication()->FindSelection()->SetGag(FALSE);
01086             GetApplication()->FindSelection()->Update(TRUE);
01087         }
01088         return FALSE;
01089     }
01090 
01091     // Deal with keypresses that don't dosen't depend on a focus story
01092     if (HandleSpecialStoryAndNonStoryKeys(pKeyPress))
01093     {
01094         TRACEUSER( "wuerthne", _T("SpecialStoryAndNonStoryKeys\n") );
01095 
01096         return TRUE;
01097     }
01098 
01099     // See if a caret has been selected without updating the focus story
01100     if (TextStory::GetFocusStory() == NULL)
01101     {
01102         SelRange* pSelection = GetApplication()->FindSelection();       
01103         Node* pNode = pSelection->FindFirst();
01104         while (pNode != NULL)
01105         {
01106             if (IS_A(pNode,CaretNode))
01107             {
01108                 TextStory::SetFocusStory((TextStory*)pNode->FindParent(CC_RUNTIME_CLASS(TextStory)));
01109                 break;
01110             }
01111                 
01112             pNode = pSelection->FindNext(pNode);
01113         }
01114     }
01115 
01116     // We need a focus story do handle a keypress
01117     if (TextStory::GetFocusStory() == NULL) 
01118     {
01119         TRACEUSER( "wuerthne", _T("GetFocusStory\n") );
01120 
01121         return HandleSpecialNonStoryKeys(pKeyPress);
01122     }
01123 
01124     // Just to be safe let's see if the TextStory has a selected caret or selected region
01125     if ( !(TextStory::GetFocusStory()->GetCaret()->IsSelected()) &&
01126          (TextStory::GetFocusStory()->GetSelectionEnd() == NULL) )
01127     {
01128         TextStory::SetFocusStory(NULL);
01129         return HandleSpecialNonStoryKeys(pKeyPress);
01130     }
01131 
01132     // Now clear out all selections from other stories/objects
01133     SelRange* Selection = GetApplication()->FindSelection();
01134     Node* pNode = Selection->FindFirst();
01135     while (pNode != NULL)
01136     {
01137         if (pNode->IsAnObject())
01138         {
01139             if (!pNode->IsABaseTextClass())
01140                 ((NodeRenderableInk*)pNode)->DeSelect(TRUE);
01141             else
01142             {
01143                 if (!IS_A(pNode,TextStory))
01144                 {
01145                     TextStory* pParentStory = (TextStory*)pNode->FindParent(CC_RUNTIME_CLASS(TextStory));
01146                     if (pParentStory != TextStory::GetFocusStory())
01147                         ((NodeRenderableInk*)pNode)->DeSelect(TRUE);
01148                 }
01149             }
01150         }
01151 
01152         pNode = Selection->FindNext(pNode);
01153     }
01154     
01155     // First see if this is a special meaning key
01156     if (HandleSpecialStoryKeys(pKeyPress, TextStory::GetFocusStory(), TextStory::GetFocusStory()->GetCaret()))
01157     {
01158         TRACEUSER( "wuerthne", _T("HandleSpecialStoryKeys\n") );
01159 
01160         return TRUE;
01161     }
01162 
01163     // finally, only proper text input remaining, so we only want Char events
01164     if( !pKeyPress->IsChar() )
01165     {
01166         TRACEUSER("wuerthne", _T("not char"));
01167 
01168         // We own all keys that don't have constrain or alt pressed and aren't extended chars
01169         if( !pKeyPress->IsConstrain() && !pKeyPress->IsAlternative() && !pKeyPress->IsExtended() )
01170             return true;
01171 
01172         return pKeyPress->GetUnicode() == _T(' ');          // always claim the Space key (tool switch)
01173     }
01174 
01175     // temporary fix: do not allow function keys to insert funny Unicode characters
01176     // (e.g., F8 to select text tool inserts an s circumflex character
01177     if (pKeyPress->GetVirtKey() >= CAMKEY(F1) && pKeyPress->GetVirtKey() <= CAMKEY(F12))
01178         return FALSE;
01179 
01180     if ( (!pKeyPress->IsAlternative()) ||                   // Alt not down
01181          (pKeyPress->IsAlternative() && pKeyPress->IsExtended()) || // Right alt down
01182          (pKeyPress->IsAlternative() && pKeyPress->IsConstrain()) ) // Ctrl & left alt down
01183     {
01184         WCHAR UnicodeValue = pKeyPress->GetUnicode();
01185         TRACEUSER("wuerthne", _T("UnicodeValue from keypress event = %04x %d"), UnicodeValue, pKeyPress->IsExtended() );
01186 
01187         // Extanded keys shouldn't produce a character
01188         if (HandleDeadKeys(pKeyPress, &UnicodeValue) || pKeyPress->IsExtended())
01189             return TRUE;
01190         else
01191         {
01192             if ( (UnicodeValue>=32) && ((UnicodeValue < CAMELOT_UNICODE_BASE) || (UnicodeValue > CAMELOT_UNICODE_LAST)))
01193             {
01194 #ifndef EXCLUDE_FROM_XARALX
01195                 if ((UnicodeValue < 256) /*&& !TextManager::IsUnicodeCompleteOS()*/)
01196                     UnicodeValue = UnicodeManager::MultiByteToUnicode(UnicodeValue);
01197 #endif
01198                 
01199                 // Display a blank cursor (thus hiding the pointer), but only if the pointer
01200                 // is over the current document window
01201                 if (!IsBlankCursorUp)
01202                 {   
01203                     DocView* pDocView = DocView::GetSelected();
01204                     if (pDocView != NULL)
01205                     {
01206                         OilCoord DummyPos;
01207                         CCamView* pCCamView = pDocView->GetConnectionToOilView();
01208                         if (pCCamView && pCCamView->GetCurrentMousePos(&DummyPos))
01209                         {
01210                             // mouse is over document window
01211                             pcCurrentCursor = pcBlankCursor;
01212                             CursorStack::GSetTop(pcCurrentCursor, CurrentCursorID);
01213                             IsBlankCursorUp = TRUE;
01214                         }       
01215                     }
01216                 }
01217                 
01218                 // Create EditTextOp
01219                 OpTextFormat* pOp = new OpTextFormat();
01220                 if (pOp != NULL)
01221                 {
01222                     TRACEUSER("jlh92", _T("inserting Unicode char %04x"), UnicodeValue);
01223                     pOp->DoInsertChar(UnicodeValue, OpTextFormat::INSERT);
01224                     UpdateAfterTyping = TRUE;
01225                     return TRUE;
01226                 } 
01227             }
01228             else
01229                 TRACEUSER( "jlh92", _T("Rejected\n" ) );
01230         }
01231     }
01232     TRACEUSER("wuerthne", _T("TextTool::OnKeyPress returns FALSE"));
01233     return FALSE;
01234 }

void TextTool::OnMouseMove DocCoord  PointerPos,
Spread pSpread,
ClickModifiers  ClickMods
[virtual]
 

To handle a Mouse Move event for the Text Tool.

Author:
Mark_Goodall (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
PointerPos - The DocCoord of the point where the mouse has moved to [INPUTS] pSpread - The spread in which the move occurred ClickMods - The state of the various modifiers at the time of the mouse move
Returns:
TRUE if it handled the Click, FALSE otherwise
See also:
Tool::MouseClick; ClickType; ClickModifiers

Reimplemented from Tool_v1.

Definition at line 941 of file texttool.cpp.

00942 {
00943     // Display status bar text for the current position
00944     DisplayStatusBarHelp(PointerPos, pSpread, ClickMods);
00945     IsBlankCursorUp = FALSE;
00946 
00947     // Cursor changing over characters
00948     NodePath* pPath = NULL;
00949     TextStory* pTextStoryToSelect = NULL;
00950     Cursor* DisplayCur = pcNormalTextCursor;
00951 
00952     // Are we over text to put a caret in OR near a path to click to start a story on?
00953     if ( IsPointNearUnselectedTextStory(pSpread, PointerPos, &pTextStoryToSelect, NULL, TRUE) ||
00954         IsPointNearNonStoryPath(pSpread, PointerPos, &pPath, TRUE) )
00955     {
00956         DisplayCur = pcBlobTextCursor;  
00957     }
00958 
00959     // See if we are near any story path indent blobs
00960     TextStory* pFoundStory = NULL;
00961     if (!m_BlobPosList.FindBlobStory(pSpread, PointerPos, NULL, &pFoundStory))
00962         InformError();
00963     else if (pFoundStory != NULL)
00964         DisplayCur = pcIndentCursor;
00965 
00966     // Display that cursor!
00967     if ( (DisplayCur != pcCurrentCursor) && (DisplayCur != NULL) )
00968     {
00969         pcCurrentCursor = DisplayCur;
00970         CursorStack::GSetTop(pcCurrentCursor, CurrentCursorID);
00971     }
00972 }

BOOL TextTool::OnRulerClick UserCoord  PointerPos,
ClickType  Click,
ClickModifiers  Mods,
Spread pSpread,
RulerBase pRuler
[virtual]
 

Called when the user has clicked on the ruler and we are the current tool.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
07/07/06
Parameters:
PointerPos - user coordinates of click on ruler (relative to origin set by tool) [INPUTS] Click - Type of click enum Mods - Modifier flags struct pSpread - pointer to spread upon which click occurred pRuler - pointer to ruler which generated click
Returns:
TRUE to claim the click

Reimplemented from Tool_v1.

Definition at line 1015 of file texttool.cpp.

01017 {
01018     if (!TextInfoBarOp::IsRulerOriginClaimed()) return FALSE;
01019     return TextInfoBarOp::OnRulerClick(PointerPos, Click, Mods, pSpread, pRuler);
01020 }

BOOL TextTool::OnToolDeselect  )  [protected]
 

Called to do processing required when text tool is deselected.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/1/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
FALSE if an error occured, TRUE if tool deselected ok

Definition at line 2371 of file texttool.cpp.

02372 {
02373     BOOL ok = TRUE;
02374 
02375     // Remove the info bar from view by deleting the actual underlying window
02376     pTextInfoBarOp->Delete();   
02377 
02378     // Destroy the tool's cursors, if they exist, having stopped displaying them
02379     if (pcCurrentCursor != NULL)
02380     {
02381         CursorStack::GPop(CurrentCursorID);
02382         pcCurrentCursor = NULL;
02383         CurrentCursorID = 0;
02384     }
02385     DestroyCursors();
02386 
02387     // If a caret is selected alone then select its parent text story instead
02388     GetApplication()->FindSelection()->SetGag(FALSE);
02389     TextStory* pTS = TextStory::GetFocusStory();
02390     if (pTS != NULL)
02391     {
02392         // Move the selection up
02393         // If the caret is selected and there is no other selection
02394         CaretNode* pCaret = pTS->GetCaret();
02395         VisibleTextNode* pSel = pTS->GetSelectionEnd();
02396         if (pCaret->IsSelected() && pSel==NULL)
02397         {
02398             pCaret->DeSelect(TRUE);
02399             pTS->Select(TRUE);
02400             GetApplication()->FindSelection()->Update(TRUE);
02401         }
02402 
02403         ok = OpDeleteTextStory::RemoveEmptyFocusStory();
02404     }
02405 
02406     // render off the tool blobs
02407     if (m_BlobPosList.GetBlobSpread()!=NULL)
02408         m_BlobPosList.RenderAndRemoveAll();
02409 
02410     // ensure any tool object blobs are removed.
02411     BlobManager* BlobMgr = GetApplication()->GetBlobManager();
02412     if (BlobMgr != NULL)
02413     {
02414         BlobStyle bsRemoves;
02415         bsRemoves.ToolObject = TRUE;
02416         BlobMgr->RemoveInterest(bsRemoves);
02417     }
02418 
02419     // Clear the focus, remembering what it was for possible later reselection
02420     pLastFocusStory = TextStory::GetFocusStory();
02421     TextStory::SetFocusStory(NULL);
02422 
02423     // make sure the ruler is redrawn if we had claimed it
02424     TextInfoBarOp::ReleaseRuler();
02425     CurrentTool = FALSE;
02426 
02427     return ok;
02428 }

BOOL TextTool::OnToolSelect  )  [protected]
 

Called to do processing required when text tool is selected.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/1/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
FALSE if an error occured, TRUE if tool selected ok

Definition at line 2249 of file texttool.cpp.

02250 {
02251     BOOL ok = TRUE;
02252     
02253     // Create the tools cursors
02254     ok = CreateCursors();
02255     if (ok)
02256     {
02257         CurrentCursorID = CursorStack::GPush(pcNormalTextCursor, FALSE);
02258         pcCurrentCursor = pcNormalTextCursor;
02259         IsBlankCursorUp = FALSE;
02260     }
02261     else
02262         pcCurrentCursor = NULL;
02263 
02264     // This tool is now the current one
02265     CurrentTool = TRUE;
02266     UpdateAfterTyping = FALSE;
02267     PreviousDeadKey = 0;
02268 
02269     // Say which blobs should be displayed
02270     BlobManager* BlobMgr = GetApplication()->GetBlobManager();
02271     if (BlobMgr != NULL)
02272     {
02273         // Decide which blobs we will display
02274         BlobStyle MyBlobs;
02275         MyBlobs.Object = TRUE;
02276         
02277         // Tell the blob manager
02278         BlobMgr->ToolInterest(MyBlobs);
02279     }
02280 
02281     // Render on the tool blobs
02282     if (ok)
02283         ok = m_BlobPosList.BuildFromSelection();
02284     if (ok && m_BlobPosList.GetBlobSpread()!=NULL)
02285         BlobMgr->RenderToolBlobsOn(this, m_BlobPosList.GetBlobSpread(), NULL);
02286     
02287     // Create and display the tool's info bar
02288     if (ok)
02289         ok = pTextInfoBarOp->Create();
02290     pTextInfoBarOp->pTextTool = this;
02291 
02292     // Alias the paste operation
02293     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_PASTE);  
02294     pOpDesc->AliasOperation(CC_RUNTIME_CLASS(OpTextPaste),NULL,0);
02295 
02296     // Ensure the dead key mappings are correct
02297     LocaleChanged();
02298 
02299     // Give the input focus to the story with a subselection, as long as it is the only sub-selected story
02300     SelRange* pSelRange = GetApplication()->FindSelection();
02301     Node* pSel = pSelRange->FindFirst();
02302 //  BOOL SelectedVTN = FALSE;
02303     TextStory* pSelStory = NULL;
02304     while (pSel != NULL)
02305     {
02306         // if it's a text object get the story it is in
02307         TextStory* pParentStory = NULL;
02308         if (pSel->IsABaseTextClass())
02309         {
02310             if (IS_A(pSel,TextStory))
02311                 pParentStory = (TextStory*)pSel;
02312             else                
02313                 pParentStory = (TextStory*)pSel->FindParent(CC_RUNTIME_CLASS(TextStory));
02314         }
02315 
02316         if (pSelStory==NULL)
02317         {
02318             // Set the selected story pointer
02319             if (pSel->IsAVisibleTextNode())
02320                 pSelStory = pParentStory;
02321         }
02322         else
02323         {
02324             // See if we have found two selected stories
02325             if (pSelStory!=pParentStory)
02326             {
02327                 pSelStory = NULL;
02328                 break;
02329             }
02330         }
02331 
02332         pSel = pSelRange->FindNext(pSel);
02333     }
02334     if (pSelStory != NULL)
02335         TextStory::SetFocusStory(pSelStory);
02336 
02337     // See if there is just one selected TextStory and give it the focus
02338     // if it had the focus when we left the tool last time.  Also selected the caret within it 
02339     if ((pLastFocusStory!= NULL) && (pSelStory==NULL) && (GetApplication()->FindSelection()->Count()==1))
02340     {
02341         Node* pSelected = GetApplication()->FindSelection()->FindFirst();
02342         if (IS_A(pSelected,TextStory) && (pSelected == pLastFocusStory))
02343         {
02344             TextStory* pTS = (TextStory*)pSelected;
02345             CaretNode* pCaret = pTS->GetCaret();
02346             if (pCaret != NULL)
02347             {
02348                 pTS->DeSelect(TRUE);
02349                 pCaret->Select(TRUE);
02350                 TextStory::SetFocusStory(pTS);
02351                 GetApplication()->FindSelection()->Update(TRUE);
02352             }
02353         }
02354     }
02355 
02356     return ok;
02357 }

BOOL TextTool::RegisterAdditionalVirtKey KeyPress **  pKey,
TCHAR  ch
[protected]
 

Registers a requirement for a virtual key message with the KeyPress system.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/95
Parameters:
pKey - pointer to a KeyPress object [INPUTS] ch - Unicode value of the required Virtual Key
pKey is the KeyPress object representing the virtual key [OUTPUTS]

Definition at line 2074 of file texttool.cpp.

02075 {
02076     BOOL ok = TRUE;
02077 
02078     *pKey = KeyPress::ConstructVK(ch);
02079     ok = (*pKey != NULL);
02080     if (ok)
02081         ok = KeyPress::AddVirtualKeyCode((*pKey)->GetVirtKey(), (*pKey)->GetUnicode());
02082 
02083     return ok;
02084 }

BOOL TextTool::RegisterDeadKeys  )  [protected]
 

Registers all the dead keys virtual codes with the keypress system.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/failure
See also:
TextTool::RemoveDeadKeys

Definition at line 1973 of file texttool.cpp.

01974 {
01975     BOOL ok = TRUE;
01976     
01977     if (UseDeadKeys)
01978     {
01979         if (ok)
01980             ok = RegisterAdditionalVirtKey(&GraveVirtKey, (TCHAR)('`'));
01981         if (ok)
01982             ok = RegisterAdditionalVirtKey(&AcuteVirtKey, (TCHAR)0x27); // Single Quote
01983         if (ok)
01984             ok = RegisterAdditionalVirtKey(&TildeVirtKey, (TCHAR)('~'));
01985         if (ok)
01986             ok = RegisterAdditionalVirtKey(&HatVirtKey, (TCHAR)('^'));
01987         if (ok)
01988             ok = RegisterAdditionalVirtKey(&ColonVirtKey, (TCHAR)(':'));
01989         if (ok)
01990             ok = RegisterAdditionalVirtKey(&AtVirtKey, (TCHAR)('@'));
01991         if (ok)
01992             ok = RegisterAdditionalVirtKey(&CommaVirtKey, (TCHAR)(','));
01993         if (ok)
01994             ok = RegisterAdditionalVirtKey(&SlashVirtKey, (TCHAR)('/'));
01995     }
01996 
01997     return ok;
01998 }

BOOL TextTool::RemoveDeadKeys  )  [protected]
 

Deregisters all the dead keys.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE
See also:
TextTool::RegisterDeadKeys

Definition at line 2013 of file texttool.cpp.

02014 {
02015     if (GraveVirtKey != NULL)
02016     {
02017         KeyPress::RemoveVirtualKeyCode(GraveVirtKey->GetVirtKey(), GraveVirtKey->GetUnicode());
02018         delete GraveVirtKey;
02019     }
02020     if (AcuteVirtKey != NULL)
02021     {
02022         KeyPress::RemoveVirtualKeyCode(AcuteVirtKey->GetVirtKey(), AcuteVirtKey->GetUnicode());
02023         delete AcuteVirtKey;
02024     }
02025     if (TildeVirtKey != NULL)
02026     {
02027         KeyPress::RemoveVirtualKeyCode(TildeVirtKey->GetVirtKey(), TildeVirtKey->GetUnicode());
02028         delete TildeVirtKey;
02029     }
02030     if (HatVirtKey != NULL)
02031     {
02032         KeyPress::RemoveVirtualKeyCode(HatVirtKey->GetVirtKey(), HatVirtKey->GetUnicode());
02033         delete HatVirtKey;
02034     }
02035     if (ColonVirtKey != NULL)
02036     {
02037         KeyPress::RemoveVirtualKeyCode(ColonVirtKey->GetVirtKey(), ColonVirtKey->GetUnicode());
02038         delete ColonVirtKey;
02039     }
02040     if (AtVirtKey != NULL)
02041     {
02042         KeyPress::RemoveVirtualKeyCode(AtVirtKey->GetVirtKey(), AtVirtKey->GetUnicode());
02043         delete AtVirtKey;
02044     }
02045     if (CommaVirtKey != NULL)
02046     {
02047         KeyPress::RemoveVirtualKeyCode(CommaVirtKey->GetVirtKey(), CommaVirtKey->GetUnicode());
02048         delete CommaVirtKey;
02049     }
02050     if (SlashVirtKey != NULL)
02051     {
02052         KeyPress::RemoveVirtualKeyCode(SlashVirtKey->GetVirtKey(), SlashVirtKey->GetUnicode());
02053         delete SlashVirtKey;
02054     }
02055 
02056     return TRUE;
02057 }

void TextTool::RenderRulerBlobs RulerBase pRuler,
UserRect UpdateRect,
BOOL  IsBackground
[virtual]
 

Gives the current tool the chance to render additional blobs on the ruler Is called twice - once before the standard ruler graphics are rendered (to allow additional background to be drawn) and once afterwards.

Author:
Martin Wuerthner <xara@mw-software.com>
Date:
07/07/06
Parameters:
pRuler - the ruler that is currently being redrawn [INPUTS] UpdateRect - the rectangle to be updated in user coordinates (with the tool origin applied) IsBackground - whether this is the call before drawing the main blobs or the call after rendering the main blobs

Reimplemented from Tool_v1.

Definition at line 982 of file texttool.cpp.

00983 {
00984     // we only draw onto the horizontal ruler and only if we have claimed it
00985     if (!TextInfoBarOp::IsRulerOriginClaimed()) return;
00986 
00987     // draw the highlighted background or the blobs
00988     if (IsBackground)
00989     {
00990         TextInfoBarOp::HighlightRulerSection(pRuler, UpdateRect);
00991     }
00992     else
00993     {
00994         TextInfoBarOp::RenderRulerBlobs(pRuler, UpdateRect);
00995     }
00996 }

void TextTool::RenderToolBlobs Spread pSpread,
DocRect pClipRect
[virtual]
 

Called to render the tool blobs for the text tool.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/2/96
Parameters:
pSpread - the spread to render blobs on [INPUTS] pClipRect - blob rendering clipping rectangle, NULL for no clipping
- [OUTPUTS]
Returns:
-

Reimplemented from Tool_v1.

Definition at line 2443 of file texttool.cpp.

02444 {
02445     m_BlobPosList.RenderAllBlobs(pSpread, pClipRect);
02446 
02447 // ARGH! We may need to do this! Phil (15/12/2003)
02448 // See old implementation of RenderToolBlobsOff below.
02449 //  if (!bRenderingOn)
02450 //      m_BlobPosList.DeleteAll();
02451 }

void TextTool::SelectChange BOOL  isSelected  )  [virtual]
 

Starts up and closes down the Text tool.

Author:
Mark_Goodall (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
isSelected - TRUE = tool has been selected [INPUTS]
  • FALSE = tool has been deselected
- [OUTPUTS]
Returns:
-

Errors: Debug warning if creating the cursor fails.

See also:
-

Reimplemented from Tool_v1.

Definition at line 431 of file texttool.cpp.

00432 {
00433     BOOL ok = TRUE;
00434 
00435     if (isSelected)
00436         ok = OnToolSelect();
00437     else
00438         ok = OnToolDeselect();
00439 
00440     if (!ok)
00441         InformError();
00442 }

BOOL TextTool::SelectionHasChanged void   ) 
 

Called when the selection has changed. Ensures tool blobs are up-to-date.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/2/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if all ok, FALSE if error occured

Definition at line 2465 of file texttool.cpp.

02466 {
02467     BOOL ok = TRUE;
02468     
02469     // Render the old blobs off
02470     if (ok)
02471         ok = m_BlobPosList.RenderAllBlobs();
02472 
02473     // Reconstruct the list of blobs
02474     if (ok)
02475         ok = m_BlobPosList.BuildFromSelection();
02476 
02477     // Render the new blobs on
02478     if (ok)
02479         ok = m_BlobPosList.RenderAllBlobs();
02480 
02481     return ok;
02482 }

BOOL TextTool::TestForDeadKey KeyPress pKeyPress,
KeyPress pDeadKeyPress
[protected]
 

Flags 'dead-keys'. Attempts to apply an accent onto the next character.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/95
Parameters:
pKeyPress - points to the current keypress object [INPUTS] pDeadKeyPress - points to a know dead key to test against
[OUTPUTS] 
Returns:
TRUE if keypress used, FALSE if not

Definition at line 2182 of file texttool.cpp.

02183 {
02184     if (    pDeadKeyPress != NULL && 
02185             pDeadKeyPress->GetVirtKey() != CAMKEY(CC_NONE) &&
02186             !pDeadKeyPress->IsConstrain() &&
02187             pKeyPress->IsConstrain() &&
02188             pDeadKeyPress->IsAdjust() == pKeyPress->IsAdjust() &&
02189             pDeadKeyPress->IsAlternative() == pKeyPress->IsAlternative() &&
02190             pDeadKeyPress->GetVirtKey() == pKeyPress->GetVirtKey()
02191         )
02192     {
02193         PreviousDeadKey = pDeadKeyPress;
02194         return TRUE;
02195     }
02196     else
02197         return FALSE;
02198 }


Member Data Documentation

KeyPress* TextTool::AcuteVirtKey [protected]
 

Definition at line 302 of file texttool.h.

KeyPress* TextTool::AtVirtKey [protected]
 

Definition at line 306 of file texttool.h.

TCHAR * TextTool::Author = _T("TextToolTeam") [static, protected]
 

Definition at line 290 of file texttool.h.

KeyPress* TextTool::ColonVirtKey [protected]
 

Definition at line 305 of file texttool.h.

KeyPress* TextTool::CommaVirtKey [protected]
 

Definition at line 307 of file texttool.h.

INT32 TextTool::CurrentCursorID [protected]
 

Definition at line 283 of file texttool.h.

BOOL TextTool::CurrentTool = FALSE [static, protected]
 

Definition at line 272 of file texttool.h.

TCHAR * TextTool::FamilyName = _T("Text Tools") [static, protected]
 

Definition at line 287 of file texttool.h.

KeyPress* TextTool::GraveVirtKey [protected]
 

Definition at line 301 of file texttool.h.

KeyPress* TextTool::HatVirtKey [protected]
 

Definition at line 303 of file texttool.h.

BOOL TextTool::IsBlankCursorUp [protected]
 

Definition at line 284 of file texttool.h.

TextToolBlobPosList TextTool::m_BlobPosList [protected]
 

Definition at line 311 of file texttool.h.

Cursor* TextTool::pcBlankCursor [protected]
 

Definition at line 279 of file texttool.h.

Cursor* TextTool::pcBlobTextCursor [protected]
 

Definition at line 278 of file texttool.h.

Cursor* TextTool::pcCurrentCursor [protected]
 

Definition at line 281 of file texttool.h.

Cursor* TextTool::pcIndentCursor [protected]
 

Definition at line 280 of file texttool.h.

Cursor* TextTool::pcNormalTextCursor [protected]
 

Definition at line 277 of file texttool.h.

TextStory* TextTool::pLastFocusStory [protected]
 

Definition at line 294 of file texttool.h.

KeyPress* TextTool::PreviousDeadKey [protected]
 

Definition at line 300 of file texttool.h.

TextInfoBarOp * TextTool::pTextInfoBarOp = NULL [static, protected]
 

Definition at line 274 of file texttool.h.

TCHAR * TextTool::Purpose = _T("Text manipulation") [static, protected]
 

Definition at line 289 of file texttool.h.

KeyPress* TextTool::SlashVirtKey [protected]
 

Definition at line 308 of file texttool.h.

KeyPress* TextTool::TildeVirtKey [protected]
 

Definition at line 304 of file texttool.h.

TCHAR * TextTool::ToolName = _T("Text Tool") [static, protected]
 

Definition at line 288 of file texttool.h.

BOOL TextTool::UpdateAfterTyping [protected]
 

Definition at line 292 of file texttool.h.

BOOL TextTool::UseDeadKeys = TRUE [static, protected]
 

Definition at line 297 of file texttool.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:01:52 2007 for Camelot by  doxygen 1.4.4