pushtool.cpp

Go to the documentation of this file.
00001 // $Id: pushtool.cpp 1464 2006-07-18 12:32:26Z gerry $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // The Push Tool
00099 
00100 /*
00101 */
00102 
00103 
00104 #include "camtypes.h"
00105 
00106 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 #include "toollist.h"
00109 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "oiltool.h"
00111 //#include "viewrc.h"
00112 //#include "resource.h"
00113 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 #include "pushtool.h"
00115 //#include "mario.h"
00116 #include "csrstack.h"
00117 //#include "oilkeys.h"
00118 //#include "justin.h"
00119 //#include "markn.h"
00120 #include "oilfiles.h"
00121 #include "blobs.h"
00122 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00123 #include "progress.h"
00124 #include "zoomops.h"
00125 
00126 //#include "will2.h"
00127 //#include "hotlink.h"
00128 #include "ralphdoc.h"
00129 #include "userattr.h"
00130 #include "bubbleid.h"
00131 #include "brushmsg.h"
00132 
00133 // These are still char* while we wait for resource technology to be developed for modules
00134 TCHAR*  PushTool::FamilyName    = _T("View Tools");
00135 TCHAR*  PushTool::ToolName      = _T("Push Tool");
00136 TCHAR*  PushTool::Purpose       = _T("To push the document around");
00137 TCHAR*  PushTool::Author        = _T("Rik");
00138 
00139 DECLARE_SOURCE("$Revision: 1464 $");
00140 
00141 
00142 CC_IMPLEMENT_MEMDUMP(PushTool, Tool_v1)
00143 CC_IMPLEMENT_DYNCREATE( OpPush, Operation )
00144 
00145 // Declare smart memory handling in Debug builds
00146 #define new CAM_DEBUG_NEW
00147 
00148 /********************************************************************************************
00149 
00150 >   PushTool::PushTool()
00151 
00152     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00153     Created:    21/6/93
00154     Purpose:    Dummp Constructor - It does nothing. All the real initialisation is done
00155                 in PushTool::Init which is called by the Tool Manager
00156     SeeAlso:    PushTool::Init
00157 
00158 ********************************************************************************************/
00159 
00160 PushTool::PushTool()
00161   : pcPushCursor(NULL),
00162     pPushInfoBarOp(NULL)
00163 {
00164     // Dummy constructor
00165 }
00166 
00167 
00168 
00169 
00170 
00171 /********************************************************************************************
00172 
00173 >   virtual PushTool::~PushTool()
00174 
00175     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00176     Created:    21/6/93
00177     Purpose:    Destructor. Does nothing.
00178 
00179 ********************************************************************************************/
00180 
00181 PushTool::~PushTool()
00182 {
00183     // Dummy destructor
00184 }
00185 
00186 
00187 
00188 /********************************************************************************************
00189 
00190 >   virtual BOOL PushTool::Init()
00191 
00192     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00193     Created:    21/6/93
00194     Returns:    FALSE if it does not want to be created, TRUE otherwise
00195     Purpose:    Used to check if the Tool was properly constructed
00196     SeeAlso:    PushTool::PushTool
00197 
00198 ********************************************************************************************/
00199 
00200 BOOL PushTool::Init()
00201 {
00202 /*  // Claim right-alt for our tool.
00203     ToolKeyClaimDetails Mods;
00204     Mods.Value = 0;
00205     Mods.Keys.Alternative2 = TRUE;
00206     ClaimToolKey((Tool*) this, Mods);
00207 */
00208     // Initially, no cursor.
00209     pcPushCursor = 0;
00210 
00211     // RALPH don't need no sissy infobar
00212 #if defined(EXCLUDE_FROM_RALPH)
00213     return OpPush::Declare();
00214 #else
00215 
00216     pPushInfoBarOp = new ZoomInfoBarOp(_R(IDD_PUSHINFO)); // Push tool uses a zoom info bar
00217     BOOL ok=(pPushInfoBarOp!=NULL);
00218 
00219 #if 0
00220     // Load in the info-bar stuff.
00221     CCResTextFile       file;               // Resource File
00222     ZoomInfoBarOpCreate BarCreate;          // Object that creates PushInfoBarOp objects
00223 
00224     BOOL    ok = file.open(_R(IDM_PUSH_BAR), _R(IDT_INFO_BAR_RES));       // Open resource
00225     if (ok) ok = DialogBarOp::ReadBarsFromFile(file, BarCreate);  // Read & create bar
00226     if (ok) file.close();                                         // Close resource
00227 
00228     ENSURE(ok,"Unable to load PUSHBAR.INI from resource\n"); 
00229 
00230     if (ok)
00231     {
00232             // Info bar now exists.  Now get a pointer to it.
00233         String_32 str(_R(IDS_PUSHTOOL_INFOBARNAME));
00234         DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(str);
00235 
00236                 ok = (pDialogBarOp != NULL);
00237         if (ok) ok = pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(ZoomInfoBarOp));
00238         if (ok) pPushInfoBarOp = (ZoomInfoBarOp*) pDialogBarOp;
00239 
00240         ENSURE(ok,"Couldn't find push tool info bar");
00241     }
00242 #endif
00243 
00244     // Register our push operation.
00245     return ok && OpPush::Declare();
00246 #endif
00247 }
00248 
00249 
00250 
00251 
00252 
00253 /********************************************************************************************
00254 
00255 >   void PushTool::Describe(void *InfoPtr)
00256 
00257     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00258     Created:    21/6/93
00259     Inputs:     InfoPtr - A pointer to a tool info block. It is passed cast to void* as
00260                 the version of the tool is unknown at this point. Later versions of the
00261                 Tool class may have more items in this block, that this tool will not use
00262     Outputs:    InfoPtr - The structure pointed to by InfoPtr will have had all the info
00263                 that this version of the Tool knows about
00264     Purpose:    Allows the tool manager to extract information about the tool
00265 
00266 ********************************************************************************************/
00267 
00268 void PushTool::Describe(void *InfoPtr)
00269 {
00270     // Cast structure into the latest one we understand.
00271     ToolInfo_v1 *Info = (ToolInfo_v1 *) InfoPtr;
00272 
00273     Info -> InfoVersion = 1;
00274     
00275     Info -> InterfaceVersion = GetToolInterfaceVersion();  // You should always have this line.
00276         
00277     // These are all arbitrary at present.
00278     Info -> Version = 1;
00279     Info -> ID      = GetID();
00280     Info -> TextID  = _R(IDS_PUSH_TOOL);
00281 
00282     Info -> Family  = FamilyName;
00283     Info -> Name    = ToolName;
00284     Info -> Purpose = Purpose;
00285     Info -> Author  = Author;
00286     
00287     Info -> InfoBarDialog = 0;
00288     Info->BubbleID = _R(IDBBL_PUSH_TOOLICON);
00289 }
00290 
00291 
00292 
00293 // The Push Tools EventHandlers
00294 
00295 
00296 /********************************************************************************************
00297 
00298 >   void PushTool::OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods,
00299                             Spread* pSpread )
00300 
00301     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00302     Created:    21/6/93
00303     Inputs:     PointerPos - The Coords (in DocCoords) of the point where the mouse button
00304                 was clicked
00305                 Click - Describes the type of click that was detected. 
00306                 ClickMods - Indicates which buttons caused the click and which modifers were
00307                 pressed at the same time
00308                 pSpread - Pointer to the spread that the click was on
00309     Returns:    TRUE if it handled the Click, FALSE otherwise
00310     Purpose:    To handle a Mouse Click event for the Push Tool. It starts up a Push 
00311                 Operation.
00312     SeeAlso:    Tool::MouseClick; ClickType; ClickModifiers
00313 
00314 ********************************************************************************************/
00315 
00316 void PushTool::OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods,
00317                         Spread* pSpread )
00318 {
00319     if (ClickMods.Menu) return;                         // Don't do anything if the user clicked the Menu button
00320 
00321     // Make sure this click is one that we want
00322     if ( Click == CLICKTYPE_SINGLE )
00323     {
00324 
00325 #ifdef RALPH
00326         //Graham 20/9/96: If we're in Ralph, clicking on a Hot Link activates it.
00327         //The one exception to this rule is if CTRL is pressed, in which case
00328         //the tool acts as normal.
00329 
00330         //So, is CTRL pressed?
00331         if (!(ClickMods.Constrain))
00332         {
00333             //No. Are we on a Hot Link? Let's try and find one.
00334 
00335             //First, find a Hot Link
00336     
00337             Node* pHotLinkNode= DocView::FindHotLinkNode(PointerPos);
00338 
00339             //If we've found one, go to that Hot Link
00340             if (pHotLinkNode)
00341             {
00342                 DocView::GoToHotLink((AttrUser*) pHotLinkNode);
00343                 return;
00344             }
00345         }
00346 
00347         //If CTRL was pressed, or if we weren't over a Hot Link, we treat
00348         //the click as a normal Push drag. Read on...
00349 
00350 #endif //Ralph
00351 
00352         // Just what we wanted - Someone is dragging the mouse about
00353         // We need to make an operation to perform the drag with
00354         OpPush* pOpPush = new OpPush;
00355         if (pOpPush == NULL)
00356         {
00357             // Failed to get the memory to do the job
00358             // I guess we should just ignore the click, though the user is going to
00359             // wonder just what is happening!
00360 //          TRACE( _T("The Push Operation could not start due to lack of memory\n") );
00361 
00362             // Inform the person doing the clicking that life is not looking so good
00363             InformError( _R(IDS_OUT_OF_MEMORY), _R(IDS_OK) );
00364         }
00365         else
00366         {
00367             // Start the drag operation and pass in the Anchor Point to the push operation
00368             pOpPush -> DoDrag( PointerPos );
00369         }
00370     }
00371 }
00372 
00373 
00374 
00375 
00376 
00377 /********************************************************************************************
00378 >   virtual void PushTool::SelectChange(BOOL isSelected)
00379 
00380     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00381     Created:    17/11/93
00382     Inputs:     A flag which if TRUE means the tool has just been selected, if FALSE that
00383                 the tool is being deselected.
00384     Outputs:    -
00385     Returns:    -
00386     Purpose:    When selected, creates a push-tool cursor object and pushes it on the
00387                 cursor stack; when deselected pops the cursor from the stack and deletes
00388                 it.
00389     Errors:     -
00390     SeeAlso:    Tool_v1::SelectChange
00391 ********************************************************************************************/
00392 
00393 void PushTool::SelectChange(BOOL isSelected)
00394 {
00395     if (isSelected)
00396     {
00397         // This tool has just been selected.  Create our cursor and push it on the cursor
00398         // stack.
00399         pcPushCursor = new Cursor(this, _R(IDC_PUSHTOOLCURSOR));
00400 
00401 #ifdef RALPH
00402         //Graham 20/9/96. This cursor is needed to activate
00403         //HotLinks (TM) in Ralph (TM). The cursor is a static member of
00404         //the Cursor class and so we don't need to delete it.
00405         pcHotLinkCursor = Cursor::PointingHand;
00406 #endif //Ralph
00407 
00408         if (!pcPushCursor)
00409         {
00410             TRACE( _T("Couldn't create push-tool cursor!\n"));
00411             return;
00412         }
00413 
00414         CurrentCursorID = CursorStack::GPush(pcPushCursor, FALSE);          // don't display just yet
00415 #if !defined(EXCLUDE_FROM_RALPH)
00416         pPushInfoBarOp->Create();
00417 #endif
00418         // good to see Neville's back into his old habits of leaving huge swathes of redundant code all over the place
00419         // Which blobs do I want displayed
00420         // Used to declare an interest in no blobs which meant that all blobs disappeared
00421         // when this tool is selected. Now try not to affect this by not declaring an
00422         // interest.
00423         // Changed by Neville 16/8/94
00424         //  BlobManager* BlobMgr = GetApplication()->GetBlobManager();
00425         //  if ((BlobMgr != NULL) && (Document::GetCurrent() != NULL))
00426         //  {
00427         //      // Decide which blobs to display
00428         //      BlobStyle MyBlobs;
00429         //      // We want them all off, which is the default
00430 
00431         //      // tell the blob manager
00432         //      BlobMgr->ToolInterest(MyBlobs);
00433         //  }
00434     }
00435     else
00436     {
00437         // This tool is being deselected, so pop our cursor from the stack and deallocate it.
00438         if (pcPushCursor)
00439         {
00440             CursorStack::GPop(CurrentCursorID);
00441             delete pcPushCursor;
00442             CurrentCursorID = 0;
00443         }
00444 #if !defined(EXCLUDE_FROM_RALPH)
00445             pPushInfoBarOp->Delete();
00446 #endif
00447 
00448     }
00449 }
00450 
00451 
00452 /********************************************************************************************
00453 >   BOOL PushTool::GetStatusLineText(String_256* pText, Spread*, DocCoord, ClickModifiers);
00454 
00455     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00456     Created:    26/1/95
00457     Inputs:     Spread*, DocCoords, ClickModifiers - unused
00458     Outputs:    pText -
00459     Returns:    TRUE if pText holds valid text
00460     Purpose:    Get status line help text for push tool when over doc
00461     Errors:     this==NULL
00462 ********************************************************************************************/
00463 
00464 BOOL PushTool::GetStatusLineText(String_256* pText, Spread*, DocCoord, ClickModifiers)
00465 {
00466     ERROR2IF(this==NULL, FALSE,"PushTool::GetStatusLineText() - this==NULL");
00467     ERROR2IF(pText==NULL,FALSE,"PushTool::GetStatusLineText() - pText==NULL");
00468 
00469     return pText->Load(_R(IDS_PUSHTOOL_STATUSHELP));
00470 }
00471 
00472 
00473 /********************************************************************************************
00474 >   void PushTool::OnMouseMove(DocCoord, Spread*, ClickModifiers)
00475 
00476     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00477     Created:    26/1/95
00478     Inputs:     DocCoord, Spread* ClickModifiers - only used in Ralph
00479     Purpose:    immediately updates status line text
00480 
00481                 In Ralph, updates status line text and changes the cursor.
00482 ********************************************************************************************/
00483 
00484 void PushTool::OnMouseMove(DocCoord dcPoint, Spread* pSpread, ClickModifiers mods)
00485 {
00486 #ifdef RALPH
00487     //Graham 20/9/96.
00488     //We need to check if the zoom tool's over a Hot Link. If it is, the cursor changes
00489     //to a pointing hand.
00490 
00491     //The one exception is if CTRL is pressed, in which case the cursor is the
00492     //normal Push tool cursor (Disabled at the moment)
00493 
00494     //First, try and find a node with a Hot Link
00495 
00496     AttrUser* pHotLinkNode= (AttrUser*) DocView::FindHotLinkNode(dcPoint);
00497 
00498     if (pHotLinkNode && !(mods.Constrain))
00499     {
00500         //Yes. So change the cursor to a pointing hand
00501         ChangeCursor(Cursor::PointingHand);
00502 
00503         //And now to update the status bar of the browser
00504 
00505         //So first get a pointer to the document
00506                 
00507         //And a pointer to the Ralph document...
00508         Document* ThisDoc=Document::GetSelected();
00509         RalphDocument* ThisRalphDoc=ThisDoc->GetRalphDoc();
00510 
00511         ERROR3IF(ThisRalphDoc==NULL, "DocView::OnMouseMoveWithNoTool has no Ralph Doc");
00512 
00513         //Then get the base URL of this Ralph document as a Web Address
00514         WebAddress wBase(ThisRalphDoc->GetBaseURL());
00515 
00516         //And get the URL of this node as a Web Address
00517         WebAddress wEmbedded(pHotLinkNode->GetWebAddress());
00518 
00519         //This function makes wEmbedded into an absolute URL (if necessary)
00520         wEmbedded.Combine(wBase);
00521 
00522         //Make the Web Address into a normal string
00523         String_256 strEmbedded=wEmbedded.GetWebAddress();
00524 
00525         //And put that URL into the status bar string
00526         String_256 sPushTool;
00527 
00528         sPushTool.MakeMsg(_R(IDS_PUSHTOOL_HOTLINK), (TCHAR*) strEmbedded);
00529         
00530         //And tell the Ralph document to show the string in the browser's status
00531         //bar
00532         ThisRalphDoc->SetStatusBar(&sPushTool);
00533 
00534     }
00535     else
00536     {
00537         //No, the cursor is not over a Hot Link or CTRL is pressed
00538         //Change the cursor to the standard Push tool cursor
00539         //and display a standard message in the browser status bar
00540         ChangeCursor(pcPushCursor);
00541 
00542         String_256 StringToPass(_R(IDS_RALPH_PUSHTOOLSTR));
00543 
00544         DocView::SetBrowserStatusBar(&StringToPass);
00545     }
00546 
00547 #endif //RALPH
00548 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00549     if (this!=NULL)
00550     {
00551         String_256 text("");
00552         if (text.Load(_R(IDS_PUSHTOOL_STATUSHELP)))
00553             GetApplication()->UpdateStatusBarText(&text);
00554     }
00555     else
00556         ERROR3("PushTool::OnMouseMove() - this==NULL");
00557 #endif
00558 }
00559 
00560 
00562 //  The Push Operation
00563 
00564 
00565 
00566 /********************************************************************************************
00567 
00568 >   OpPush::OpPush()
00569 
00570     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00571     Created:    20/7/93
00572     Purpose:    Constructor. This simply sets a few of the operation flags to say that
00573                 it can not be added to the undo system and that it should be deleted
00574                 when it ends.
00575 
00576 ********************************************************************************************/
00577 
00578 OpPush::OpPush()
00579 {
00580 }
00581 
00582 
00583 
00584 /********************************************************************************************
00585 
00586 >   void OpPush::DoDrag( DocCoord Anchor )
00587 
00588     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00589     Created:    5/7/93
00590     Inputs:     Anchor - The position of the mouse at the start of the Drag
00591     Purpose:    To start up the dragging of the document around. It records the
00592                 starting point of the drag as this is used to calculate the offsets
00593                 that are needed as the mouse moves about
00594 
00595 ********************************************************************************************/
00596 
00597 void OpPush::DoDrag( DocCoord Anchor )
00598 {
00599     // Find out the selected Document View
00600     DocView* pDocView = DocView::GetSelected(); 
00601     ENSURE( pDocView != NULL, "OpPush::DoDrag - No selected DocView" );
00602     if (pDocView==NULL)
00603         return;
00604 
00605     // Get the mouse position in work coords
00606     AnchorPoint = pDocView -> GetClickWorkCoord();
00607     
00608     // and start a drag (pass in FALSE for KeepAccuracy, because we want this drag to
00609     // reflect the cursor position at all times - we're not really interested in the
00610     // intermediate mouse movements when there are lots of them).
00611     StartDrag( DRAGTYPE_NOSCROLL, NULL, NULL, FALSE );
00612 
00613 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00614     String_256 text("");
00615     if (text.Load(_R(IDS_PUSHOP_STATUSHELP)))
00616         GetApplication()->UpdateStatusBarText(&text);
00617 #endif
00618 }
00619 
00620 
00621 
00622 
00623 /********************************************************************************************
00624 
00625 >   void OpPush::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, BOOL bSolidDrag)
00626 
00627     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00628     Created:    5/7/93
00629     Inputs:     PointerPos - The current position of the mouse in Doc Coords
00630                 ClickMods - Which key modifiers are being pressed
00631     Purpose:    This function will change the scroll offsets of the current view
00632                 to track the mouse moving about. This will give the effect of sliding the
00633                 document around with the mouse
00634     SeeAlso:    ClickModifiers
00635 
00636 ********************************************************************************************/
00637 
00638 void OpPush::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL bSolidDrag)
00639 {
00640     DocView* pDocView = DocView::GetSelected();
00641     ENSURE( pDocView != NULL, "OpPush::DragPointerMove - DocView was NULL" );
00642     if (pDocView==NULL)
00643         return;
00644 
00645     // Declare a few WorkCoords we will need
00646     WorkCoord ScrollOffsets;
00647     WorkCoord Change;   
00648     WorkCoord MoveClick = pDocView->GetClickWorkCoord();
00649     
00650     // How Much has it changed
00651     Change.x = AnchorPoint.x - MoveClick.x;
00652     Change.y = AnchorPoint.y - MoveClick.y;
00653     
00654     // Find the Scroll Offsets and change them
00655     ScrollOffsets = pDocView->GetScrollOffsets(); 
00656     ScrollOffsets.x += Change.x;
00657     ScrollOffsets.y += Change.y;
00658     
00659     // Make sure the ScrollOffsets are valid and then set them
00660     if ( ScrollOffsets.x < 0 ) ScrollOffsets.x = 0;
00661     if ( ScrollOffsets.y > 0 ) ScrollOffsets.y = 0;
00662     pDocView->SetScrollOffsets( ScrollOffsets, TRUE );
00663 }
00664 
00665 
00666 
00667 /********************************************************************************************
00668 
00669 >   void OpPush::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods, BOOL Success, BOOL bSolidDrag)
00670 
00671     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00672     Created:    5/7/93
00673     Inputs:     PointerPos - The position of the mouse at the end of the drag
00674                 ClickMods - the key modifiers being pressed
00675                 Success - TRUE if the drag was terminated properly, FALSE if it
00676                 was ended with the escape key being pressed
00677     Purpose:    Finishes the scrolling around the document and ends the drag operation
00678     SeeAlso:    ClickModifiers
00679 
00680 ********************************************************************************************/
00681 
00682 void OpPush::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL Success, BOOL bSolidDrag)
00683 {
00684     // Put up the hourglass as we have to
00685     BeginSlowJob();
00686 
00687     // End the Drag
00688     EndDrag();
00689     
00690     // If the drag failed, then fail the operation
00691     if (!Success) FailAndExecute();
00692 
00693     // End the operation
00694     End();
00695 
00696     // Send a message saying that the screen has changed, so that the brush tool can update
00697     BROADCAST_TO_ALL(ScreenChangeMsg());
00698 
00699 }
00700 
00701 
00702 /********************************************************************************************
00703 
00704 >   BOOL OpPush::Declare()
00705 
00706     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00707     Created:    5/7/93
00708     Returns:    TRUE if all went OK, False otherwise
00709     Purpose:    Adds the operation to the list of all known operations
00710 
00711 ********************************************************************************************/
00712 
00713 BOOL OpPush::Declare()
00714 {
00715     return (RegisterOpDescriptor(
00716                                 0, 
00717                                 _R(IDS_PUSH_TOOL),
00718                                 CC_RUNTIME_CLASS(OpPush), 
00719                                 OPTOKEN_PUSH,
00720                                 OpPush::GetState,
00721                                 0,  /* help ID */
00722                                 _R(IDBBL_PUSHTOOLOP),
00723                                 0   /* bitmap ID */));
00724 
00725 }
00726 
00727 
00728 /********************************************************************************************
00729 
00730 >   OpState OpPush::GetState(String_256* Description, OpDescriptor*)
00731 
00732     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00733     Created:    5/7/93
00734     Outputs:    Description - GetState fills this string with an approriate description
00735                 of the current state of the push tool
00736     Returns:    The state of the operation, so that menu items (ticks and greying can be
00737                 done properly
00738     Purpose:    Find out the state of the operation at the specific time
00739 
00740 ********************************************************************************************/
00741 
00742 OpState OpPush::GetState(String_256*, OpDescriptor*)
00743 {
00744     OpState Blobby;
00745     return Blobby;
00746 }
00747 
00748 
00749 
00750 /********************************************************************************************
00751 >   BOOL OpPush::GetStatusLineText(String_256* pText, Spread*, DocCoord, ClickModifiers);
00752 
00753     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00754     Created:    26/1/95
00755     Inputs:     Spread*, DocCoords, ClickModifiers - unused
00756     Outputs:    pText -
00757     Returns:    TRUE if pText holds valid text
00758     Purpose:    Get status line help text for push tool when dragging
00759     Errors:     this==NULL
00760 ********************************************************************************************/
00761 
00762 BOOL OpPush::GetStatusLineText(String_256* pText, Spread*, DocCoord, ClickModifiers)
00763 {
00764     ERROR2IF(this==NULL,FALSE,"OpPush::GetStatusLineText() - this==NULL");
00765 
00766     return pText->Load(_R(IDS_PUSHOP_STATUSHELP));
00767 }
00768 
00769 #ifdef RALPH
00770 /********************************************************************************************
00771 
00772 >   void ZoomTool::ChangeCursor(Cursor* cursor)
00773 
00774     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>, from Jim's code
00775     Created:    20/9/96
00776     Inputs:     ID of the cursor you want to flip to
00777     Outputs:    -
00778     Returns:    -
00779     Purpose:    We only need this in Ralph (at present), where the push tool cursor
00780                 sometimes changes to a pointing hand, which is used to activate Hot Links.
00781     
00782                 Changes to the specified cursor. Will only change the cursor if it isn't already
00783                 this cursor, so it doesn't flicker.
00784 
00785 
00786     Errors:     can fail if the cursor cannot be created - the cursor code will fail.
00787     SeeAlso:    -
00788 
00789 ********************************************************************************************/
00790 
00791 void PushTool::ChangeCursor(Cursor* cursor)
00792 {
00793     // only change if this cursor is different from the current cursor
00794     if (cursor != MyCurrentCursor)
00795     {
00796         // set this cursor as the current cursor and immediately display it
00797         CursorStack::GSetTop(cursor, CurrentCursorID);
00798         // remember this is our current cursor
00799         MyCurrentCursor = cursor;
00800     }
00801 }
00802 
00803 
00804 /********************************************************************************************
00805 
00806 >   void PushTool::OnKeyPress(KeyPress* pKey)
00807 
00808     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00809     Created:    20/9/96
00810     Inputs:     Keypress object
00811     Outputs:    -
00812     Returns:    -
00813     Purpose:    When a key is pressed, we call the Mouse Move function to update the
00814                 cursor and status bar text.
00815 
00816                 Disabled at the moment, but if Ralph ever handles Key Presses this should
00817                 go in.
00818 
00819 
00820 ********************************************************************************************/
00821 /*
00822 BOOL PushTool::OnKeyPress(KeyPress* pKey)
00823 {
00824     //First get the current click modifiers, pointer position and spread
00825     ClickModifiers ClickMods = ClickModifiers::GetClickModifiers();
00826 
00827     Spread*  pSpread;
00828     DocCoord dcMousePos;
00829     if (DocView::GetCurrentMousePos(&pSpread, &dcMousePos))
00830         OnMouseMove(dcMousePos, pSpread, ClickMods);
00831     
00832     return TRUE;
00833 }
00834 */
00835 #endif //Ralph

Generated on Sat Nov 10 03:47:52 2007 for Camelot by  doxygen 1.4.4