blnktool.cpp

Go to the documentation of this file.
00001 // $Id: blnktool.cpp 1282 2006-06-09 09:46:49Z alex $
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 // Implementation of the blank tool
00099 
00100 /*
00101 */
00102 
00103 #include "camtypes.h"
00104 #include "oilfiles.h"
00105 #include "csrstack.h"
00106 //#include "viewrc.h"
00107 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "markn.h"
00110 #include "blobs.h"          // for blob rendering.
00111 //#include "mike.h"         // <******* Remember to include your own personal .h file
00112 
00113 #include "blnktool.h"       // <******* Remember to change to include the tool's header file
00114 
00115 DECLARE_SOURCE( "$Revision: 1282 $" );
00116 
00117 CC_IMPLEMENT_MEMDUMP(BlankTool,Tool_v1)
00118 CC_IMPLEMENT_DYNCREATE(BlankInfoBarOp,InformationBarOp)
00119 
00120 // Must come after the last CC_IMPLEMENT.. macro
00121 #define new CAM_DEBUG_NEW     
00122 
00123 // These are still char* while we wait for resource technology to be developed for modules
00124 LPTSTR BlankTool::FamilyName    = _T("Blank Tools");
00125 LPTSTR BlankTool::ToolName  = _T("Blank Tool");
00126 LPTSTR BlankTool::Purpose   = _T("Blank manipulation");
00127 LPTSTR BlankTool::Author    = _T("Buster");
00128 
00129 // Init those other useful static vars
00130 BOOL            BlankTool::s_bCurrentTool           = FALSE;
00131 BlankInfoBarOp* BlankTool::s_pBlankInfoBarOp        = NULL;
00132 
00133 /********************************************************************************************
00134 
00135 >   BlankTool::BlankTool()
00136 
00137     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00138     Created:    3/10/94
00139     Purpose:    Default Constructor.
00140                 Other initialisation is done in BlankTool::Init which is called by the Tool Manager
00141     SeeAlso:    BlankTool::Init
00142 
00143 ********************************************************************************************/
00144 
00145 BlankTool::BlankTool()
00146 {
00147     m_pcCurrentCursor = NULL;
00148     m_pcNormalBlankCursor = NULL;
00149 }
00150 
00151 /********************************************************************************************
00152 
00153 >   BlankTool::~BlankTool()
00154 
00155     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00156     Created:    3/10/94
00157     Purpose:    Destructor (Virtual). Does nothing.
00158 
00159 ********************************************************************************************/
00160 
00161 BlankTool::~BlankTool()
00162 {
00163 }
00164 
00165 
00166 /********************************************************************************************
00167 
00168 >   BOOL BlankTool::Init( INT32 Pass )
00169 
00170     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00171     Created:    3/10/94
00172     Returns:    FALSE if it does not want to be created, TRUE otherwise
00173     Purpose:    Used to check if the Tool was properly constructed
00174     SeeAlso:    BlankTool::BlankTool
00175 
00176 ********************************************************************************************/
00177 
00178 BOOL BlankTool::Init()
00179 {
00180     // Declare all your ops here and only succeed if all declarations succeed
00181 
00182     BOOL ok = TRUE;
00183 
00184     // This section reads in the infobar definition and creates an instance of
00185     // BlankInfoBarOp.  Also pBlankInfoBarOp, the ptr to the tool's infobar, is set up
00186     // after the infobar is successfully read and created.
00187     if (ok)
00188     {
00189         s_pBlankInfoBarOp = new BlankInfoBarOp(this);
00190         ERROR2IF(s_pBlankInfoBarOp==NULL, FALSE, "Can't create Blank tool Infobar");
00191     }
00192 
00193     return (ok);
00194 }
00195 
00196 
00197 /********************************************************************************************
00198 
00199 >   void BlankTool::Describe(void *InfoPtr)
00200 
00201     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00202     Created:    3/10/94
00203     Inputs:     InfoPtr -   A pointer to a tool info block. It is passed cast to void* as
00204                             the version of the tool is unknown at this point. Later versions 
00205                             of the Tool class may have more items in this block, that this 
00206                             tool will not use
00207     Outputs:    InfoPtr -   The structure pointed to by InfoPtr will have had all the info
00208                             that this version of the Tool knows about
00209     Purpose:    Allows the tool manager to extract information about the tool
00210 
00211 ********************************************************************************************/
00212 
00213 void BlankTool::Describe(void* InfoPtr)
00214 {
00215     // Cast structure into the latest one we understand.
00216     ToolInfo_v1* Info = (ToolInfo_v1*) InfoPtr;
00217 
00218     Info->InfoVersion = 1;
00219     
00220     Info->InterfaceVersion = GetToolInterfaceVersion();  // You should always have this line.
00221         
00222     // These are all arbitrary at present.
00223     Info->Version = 1;
00224     Info->ID      = GetID();
00225     Info->TextID  = _R(IDS_BLANK_TOOL);
00226 
00227     Info->Family  = FamilyName;
00228     Info->Name    = ToolName;
00229     Info->Purpose = Purpose;
00230     Info->Author  = Author;
00231 
00232     Info->BubbleID = _R(IDBBL_BLANK_TOOLBOX);
00233 }
00234 
00235 /********************************************************************************************
00236 
00237 >   virtual void BlankTool::SelectChange(BOOL isSelected)
00238 
00239     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00240     Created:    3/10/94
00241     Inputs:     isSelected  - TRUE  = tool has been selected
00242                             - FALSE = tool has been deselected
00243     Outputs:    -
00244     Returns:    -
00245     Purpose:    Starts up and closes down the blank tool
00246     Errors:     Debug warning if creating the cursor fails.
00247     SeeAlso:    -
00248 
00249 ********************************************************************************************/
00250 
00251 void BlankTool::SelectChange(BOOL isSelected)
00252 {
00253     if (isSelected)
00254     {
00255         if (!CreateCursors()) return;
00256         m_CurrentCursorID = CursorStack::GPush(m_pcNormalBlankCursor, FALSE);       // Push cursor but don't display now
00257         m_pcCurrentCursor = m_pcNormalBlankCursor;
00258 
00259         // This tool is now the current one
00260         s_bCurrentTool = TRUE;
00261 
00262         // Create and display the tool's info bar
00263         s_pBlankInfoBarOp->Create();
00264     }
00265     else
00266     {
00267         // Deselection - destroy the tool's cursors, if they exist.
00268         if (m_pcCurrentCursor != NULL)
00269         {
00270             CursorStack::GPop(m_CurrentCursorID);
00271             m_pcCurrentCursor = NULL;
00272             m_CurrentCursorID = 0;
00273         }
00274         DestroyCursors();
00275 
00276         // Remove the info bar from view by deleting the actual underlying window
00277         s_pBlankInfoBarOp->Delete();
00278 
00279         // ensure any tool object blobs are removed.
00280         BlobManager* BlobMgr = GetApplication()->GetBlobManager();
00281         if (BlobMgr != NULL)
00282         {
00283             BlobStyle bsRemoves;
00284             bsRemoves.ToolObject = TRUE;
00285             BlobMgr->RemoveInterest(bsRemoves);
00286         }
00287 
00288         // No longer the current tool
00289         s_bCurrentTool = FALSE;
00290     }
00291 }
00292 
00293 /********************************************************************************************
00294 
00295 >   BOOL BlankTool::CreateCursors()
00296 
00297     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00298     Created:    3/10/94
00299     Inputs:     -
00300     Outputs:    -
00301     Returns:    TRUE if all the blank tool cursors have been successfully created
00302     Purpose:    Creates all the blank tool cursors
00303     SeeAlso:    -
00304 
00305 ********************************************************************************************/
00306 
00307 BOOL BlankTool::CreateCursors()
00308 {
00309     // This tool has just been selected.  Create the cursors.
00310     m_pcNormalBlankCursor = new Cursor(this, _R(IDCSR_BLANKTOOLDEFAULT));
00311 
00312     if ( m_pcNormalBlankCursor==NULL || !m_pcNormalBlankCursor->IsValid())
00313     {
00314         DestroyCursors();
00315         return FALSE;
00316     }
00317     else
00318         return TRUE;
00319 }
00320 
00321 /********************************************************************************************
00322 
00323 >   void BlankTool::DestroyCursors()
00324 
00325     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00326     Created:    3/10/94
00327     Inputs:     -
00328     Outputs:    -
00329     Returns:    -
00330     Purpose:    Destroys all the blank tool cursors
00331     SeeAlso:    -
00332 
00333 ********************************************************************************************/
00334 
00335 void BlankTool::DestroyCursors()
00336 {
00337     if (m_pcNormalBlankCursor != NULL) delete m_pcNormalBlankCursor;
00338 }
00339 
00340 /********************************************************************************************
00341 
00342 >   void BlankTool::OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods,
00343                         Spread* pSpread )
00344 
00345     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00346     Created:    3/10/94
00347     Inputs:     PointerPos  -   The DocCoord of the point where the mouse button was clicked
00348                 Click       -   Describes the type of click that was detected. 
00349                 ClickMods   -   Indicates which buttons caused the click and which modifers were
00350                                 pressed at the same time
00351                 pSpread     -   The spread in which the click happened
00352     Returns:    -
00353     Purpose:    To handle a Mouse Click event for the Blank Tool.
00354     SeeAlso:    Tool::MouseClick; ClickType; ClickModifiers
00355 
00356 ********************************************************************************************/
00357 
00358 void BlankTool::OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods,
00359                         Spread* pSpread )
00360 {
00361     if (ClickMods.Menu) return;                         // Don't do anything if the user clicked the Menu button
00362 
00363     // Make sure this click is one that we want
00364     if ( Click == CLICKTYPE_SINGLE || Click == CLICKTYPE_DOUBLE)
00365     {
00366     }
00367 
00368     if ( Click == CLICKTYPE_DRAG )
00369     {
00370     }
00371 }
00372 
00373 /********************************************************************************************
00374 
00375 >   void BlankTool::OnMouseMove( DocCoord PointerPos,Spread* pSpread, ClickModifiers ClickMod )
00376 
00377     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00378     Created:    3/10/94
00379     Inputs:     PointerPos  -   The DocCoord of the point where the mouse has moved to
00380                 pSpread     -   The spread in which the move occurred
00381                 ClickMods   -   The state of the various modifiers at the time of the mouse move
00382     Returns:    TRUE if it handled the Click, FALSE otherwise
00383     Purpose:    To handle a Mouse Move event for the Blank Tool.
00384     SeeAlso:    Tool::MouseClick; ClickType; ClickModifiers
00385 
00386 ********************************************************************************************/
00387 
00388 void BlankTool::OnMouseMove(DocCoord PointerPos,Spread* pSpread,ClickModifiers ClickMods)
00389 {
00390     // You can use this func to do things like change the pointer shape, or
00391     // alter the text in the status bar
00392 
00393     // Use this func to change your curor
00394     //      CursorStack::GSetTop(Cursor* pCursor, CurrentCursorID)
00395 
00396     // Display status bar text for the current position
00397     DisplayStatusBarHelp(PointerPos, pSpread, ClickMods);
00398 }
00399 
00400 /********************************************************************************************
00401 
00402 >   void BlankTool::RenderToolBlobs(Spread* pSpread,DocRect* pDocRect)
00403 
00404     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00405     Created:    3/10/94
00406     Inputs:     pSpread  = ptr to a spread
00407                 pDocRect = ptr to DocRect of spread to render in
00408     Returns:    -
00409     Purpose:    Handles the RenderToolBlobs method.
00410                 Renders the tool's blobs into the selected doc view.
00411     SeeAlso:    
00412 
00413 ********************************************************************************************/
00414 
00415 void BlankTool::RenderToolBlobs(Spread* pSpread,DocRect* pDocRect)
00416 {
00417     // Render into the selected doc view
00418     DocView* pDocView = DocView::GetSelected();
00419     if (pDocView != NULL)
00420     {
00421         // render you tool's blobs (if any) here
00422     }
00423 }
00424 
00425 /********************************************************************************************
00426 
00427 >   void BlankTool::DisplayStatusBarHelp(DocCoord DocPos, Spread* pSpread, ClickModifiers ClickMods)
00428 
00429     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00430     Created:    12/12/94
00431     Inputs:     DocPos - the document coordinate of the point to display help on
00432                 pSpread - pointer to the spread containing DocPos
00433                 ClickMods - the current click modifiers
00434     Outputs:    -
00435     Returns:    -
00436     Purpose:    Displays status help string for the given position in the status bar.
00437     SeeAlso:    BlankTool::GetCurrentStatusText
00438 
00439 ********************************************************************************************/
00440 
00441 void BlankTool::DisplayStatusBarHelp(DocCoord DocPos, Spread* pSpread, ClickModifiers ClickMods)
00442 {
00443     String_256 StatusMsg(_T(""));
00444 
00445     // Get a string from the underlying help function and display it.
00446     GetCurrentStatusText(&StatusMsg, pSpread, DocPos, ClickMods);
00447     GetApplication()->UpdateStatusBarText(&StatusMsg);                           
00448 }
00449 
00450 /********************************************************************************************
00451 
00452 >   virtual BOOL BlankTool::GetStatusLineText(String_256* ptext, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods)
00453 
00454     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00455     Created:    12/12/94
00456     Inputs:     ptest - pointer to a string
00457                 pSpread points to a spread
00458                 DocPos points to a point in a document
00459                 ClickMods are the current click modifiers
00460     Outputs:    Updates the string in ptext
00461     Returns:    TRUE if the string was updates (FALSE if not updated)
00462     Purpose:    Returns the current status line help string
00463     SeeAlso:    BlankTool::GetCurrentStatusText, Tool_v1::GetStatusLineText
00464 
00465 ********************************************************************************************/
00466 
00467 BOOL BlankTool::GetStatusLineText(String_256* ptext, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods)
00468 {
00469     // We can call the underlying help function to get a string and return the result.
00470     GetCurrentStatusText(ptext, pSpread, DocPos, ClickMods);
00471     return TRUE;
00472 }
00473 
00474 /********************************************************************************************
00475 
00476 >   void BlankTool::GetCurrentStatusText(String_256* ptext, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods)
00477 
00478     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00479     Created:    12/12/94
00480     Inputs:     pSpread points to a spread
00481                 DocPos points to a point in a document
00482                 ClickMods are the current click modifiers
00483     Outputs:    Updates the string in ptext
00484     Returns:    -
00485     Purpose:    Selects a suitable string for the status line based on the current location
00486                 (as input via the parameters).
00487     SeeAlso:    BlankTool::GetStatusLineText, BlankTool::DisplayStatusBarHelp
00488 
00489 ********************************************************************************************/
00490 
00491 void BlankTool::GetCurrentStatusText(String_256* ptext, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods)
00492 {
00493     // You must use the Spread, DocCoord and ClickModifiers to select a suitable string to be 
00494     // displaied in the status bar.  This is usually done via some sort of switch statement.
00495     // Having selected a suitable string you should do a statement like 
00496     //  ptext->Load(<#Insert your string ID here #>);
00497 
00498     // Delete this line when you display useful strings!
00499     ptext->Empty(); 
00500 }
00501 
00502 //----------------------------------------------
00503 //----------------------------------------------
00504 //----------------------------------------------
00505 //----------------------------------------------
00506 
00507 /********************************************************************************************
00508 
00509 >   MsgResult BlankInfoBarOp::Message(Msg* Message) 
00510 
00511     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00512     Created:    3/10/94
00513     Inputs:     Message = The message to handle
00514     Outputs:    -
00515     Returns:    -
00516     Purpose:    Blank info bar dialog message handler
00517     Errors:     -
00518     SeeAlso:    -
00519 
00520 ********************************************************************************************/
00521 
00522 MsgResult BlankInfoBarOp::Message(Msg* Message) 
00523 {
00524     if (IS_OUR_DIALOG_MSG(Message))
00525     {
00526         DialogMsg* Msg = (DialogMsg*)Message;
00527 
00528         // Check if the message is a CANCEL
00529         if (Msg->DlgMsg == DIM_CANCEL)
00530         {
00531             Close(); // Close the dialog 
00532         }
00533         else if (Msg->DlgMsg == DIM_CREATE)
00534         {
00535             // Initialise the infobar controls here
00536             // This is sent when you create the infobar in your tool startup code
00537         }
00538         else
00539         {
00540             // Switch statement allows you to do things when receiving messages
00541             // for specific gadgets
00542             //
00543             // Just uncomment the next 3 lines to get started
00544             //
00545             //      switch (Msg->GadgetID)
00546             //      {
00547             //      }
00548         }
00549     }
00550 
00551     // Pass the message on to the immediate blank class
00552     return (InformationBarOp::Message(Message));
00553 }    

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