00001 // $Id: tool.h 1535 2006-07-25 16:50:32Z 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 00099 00100 #ifndef INC_TOOL 00101 #define INC_TOOL 00102 00103 #include "doccoord.h" 00104 #include "binds.h" 00105 #include "clikmods.h" 00106 #include "ccobject.h" 00107 #include "dlgtypes.h" 00108 #include "list.h" 00109 00110 00111 class OILTool; // #include "oiltool.h" 00112 class DocRect; 00113 00114 // Forward decls of ToolList and ToolListItem for use by Tool_v1/Tool classes. 00115 class ToolList; 00116 class ToolListItem; 00117 class Spread; 00118 class KeyPress; 00119 class RulerBase; 00120 00121 // Everyone tool needs a valid Tool ID. They get allocated here. Camelot 00122 // tools written by us should have an ID in the range 2 - 49. The range 00123 // 49-99 incl are reserved for third-party tools, while the range 0 - 1 00124 // is reserved for special cases! 00125 00126 // these used to be const UINTs, which was fine, except that they are now used in 00127 // .rc files which needs #defines 00128 00129 #define TOOLID_INVALID 0 00130 00131 #define TOOLID_TEST 2 00132 #define TOOLID_PUSH 3 00133 #define TOOLID_ZOOM 4 00134 #define TOOLID_RECTANGLE 5 00135 #define TOOLID_FREEHAND 6 00136 #define TOOLID_SELECTOR 7 00137 #define TOOLID_RECT 8 00138 #define TOOLID_ROTATE 9 00139 #define TOOLID_GRID 10 00140 #define TOOLID_BEZTOOL 11 00141 #define TOOLID_ELLIPSE 12 00142 #define TOOLID_GRADFILL 13 00143 #define TOOLID_PEN 14 00144 #define TOOLID_BLANK 15 00145 #define TOOLID_BLEND 16 00146 #define TOOLID_TRANSP 17 00147 #define TOOLID_REGSHAPE 18 00148 #define TOOLID_MOULD 19 00149 #define TOOLID_ACCUSOFT 20 00150 #define TOOLID_TEXT 21 00151 #define TOOLID_SOFTSHADOW 22 00152 #define TOOLID_BEVELTOOL 23 00153 #define TOOLID_CONTOURTOOL 24 00154 #define TOOLID_SLICETOOL 25 00155 #define TOOLID_LIVEEFFECT 26 00156 00157 00158 // The op tokens for each of the tools 00159 // A tool's op token is "TOOL" with the tool ID appended on the end 00160 00161 #define TOOL_OPTOKEN_PUSH _T("TOOL3") 00162 #define TOOL_OPTOKEN_ZOOM _T("TOOL4") 00163 #define TOOL_OPTOKEN_RECTANGLE _T("TOOL5") 00164 #define TOOL_OPTOKEN_FREEHAND _T("TOOL6") 00165 #define TOOL_OPTOKEN_SELECTOR _T("TOOL7") 00166 #define TOOL_OPTOKEN_RECT _T("TOOL8") 00167 #define TOOL_OPTOKEN_ROTATE _T("TOOL9") 00168 #define TOOL_OPTOKEN_GRID _T("TOOL10") 00169 #define TOOL_OPTOKEN_BEZTOOL _T("TOOL11") 00170 #define TOOL_OPTOKEN_ELLIPSE _T("TOOL12") 00171 #define TOOL_OPTOKEN_GRADFILL _T("TOOL13") 00172 #define TOOL_OPTOKEN_PEN _T("TOOL14") 00173 #define TOOL_OPTOKEN_BLANK _T("TOOL15") 00174 #define TOOL_OPTOKEN_BLEND _T("TOOL16") 00175 #define TOOL_OPTOKEN_TRANSP _T("TOOL17") 00176 #define TOOL_OPTOKEN_REGSHAPE _T("TOOL18") 00177 #define TOOL_OPTOKEN_MOULD _T("TOOL19") 00178 #define TOOL_OPTOKEN_TEXT _T("TOOL21") 00179 #define TOOL_OPTOKEN_SOFTSHADOW _T("TOOL22") 00180 #define TOOL_OPTOKEN_BEVEL _T("TOOL23") 00181 #define TOOL_OPTOKEN_CONTOUR _T("TOOL24") 00182 #define TOOL_OPTOKEN_SLICE _T("TOOL25") 00183 #define TOOL_OPTOKEN_LIVEEFFECT _T("TOOL26") 00184 00185 const UINT32 TOOLID_MAX = 99; 00186 00187 00188 /******************************************************************************************** 00189 00190 > class ToolInfo_v1 : SimpleCCObject 00191 00192 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00193 Created: 19/7/93 00194 Purpose: Provide information on a tool. 00195 SeeAlso: ToolInfo; Tool 00196 00197 ********************************************************************************************/ 00198 00199 class ToolInfo_v1 : public CC_CLASS_MEMDUMP 00200 { 00201 CC_DECLARE_MEMDUMP(ToolInfo_v1); 00202 00203 public: 00204 ToolInfo_v1(); // Default constructor - sets up ToolInfo default values 00205 00206 UINT32 InfoVersion; // Determines how many of the remaining fields are filled in. 00207 UINT32 InterfaceVersion; 00208 UINT32 Version; 00209 UINT32 ID; 00210 UINT32 ParentModuleID; 00211 UINT32 TextID; 00212 TCHAR* Family; 00213 TCHAR* Name; 00214 TCHAR* Purpose; 00215 TCHAR* Author; 00216 UINT32 BubbleID; // The bubble help resource ID, to be displayed when the 00217 // cursor moves over the tool button. 00218 UINT32 StatusID; // The status bar resource ID, to be displayed when cursor 00219 // moves over the tool button. 00220 CDlgResID InfoBarDialog; 00221 00222 // In Camelot there are different CurrentAttribute groups for different types of object. 00223 // For example Text will have a different set of attributes (its attribute group) to path 00224 // objects. When specifying a current attribute the selected tool determines which current 00225 // attribute group to add the attribute to. 00226 00227 CCRuntimeClass* CurrentAttributeGroup; // Default = NodeRenderableInk 00228 }; 00229 00230 /******************************************************************************************** 00231 00232 > class ToolInfo : public ToolInfo_v1 00233 00234 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00235 Created: 19/7/93 00236 Purpose: Provide information on a tool. The fields are as follows: 00237 MonoOn 00238 InfoVersion Indicates how much of this stucture is understood by the 00239 tool. 00240 InterfaceVersion The version of the kernel<->tool interface understood by 00241 the tool. 00242 Version The tool's own version number. 00243 ID The unique ID of this tool (allocated by Computer 00244 Concepts Ltd). 00245 ParentModuleID The unique ID of the module that provides this tool 00246 (allocated by Computer Concepts Ltd). 00247 Family A string describing the tool family this tool belongs 00248 to - e.g. "Path tools". 00249 Name A string describing the tool - e.g. "Rectangle tool". 00250 Purpose A string decribing what the tool is used for, e.g. 00251 "For drawing rectangles". 00252 Author A string naming the author(s) of the tool, e.g. 00253 "Computer Concepts Ltd". 00254 InfoBarDialog Resource ID of the dialog used in the infobar for this 00255 tool. 00256 MonoOff 00257 00258 SeeAlso: Tool 00259 00260 ********************************************************************************************/ 00261 00262 class ToolInfo : public ToolInfo_v1 00263 { 00264 CC_DECLARE_MEMDUMP(ToolInfo); 00265 // No extra members needed. 00266 }; 00267 00268 00269 00270 /******************************************************************************************** 00271 00272 < DragEndType 00273 00274 Comment: Describes how a drag was ended. Dragging operations can call the tools 00275 virtual function DragFinished() with a var of this type so that the 00276 tool can take appropriate action. NB. the tool can cancel the effects 00277 of a drag by returning FALSE from the DragFinished() function. THERE IS 00278 *NO* NEED TO DO THIS IF YOU RECEIVE A CALL TO DragFinished() WITH THE 00279 DT_CANCELLED PARAMETER! 00280 MonoOn 00281 DT_CANCELLED, // the drag was cancelled by the user (eg. ESC pressed) 00282 DT_DIDNOTMOVE, // The Drag did not move at all 00283 DT_MOVEDTOSAME, // The Drag moved but ended up in the same place 00284 DT_MOVEDTODIFF // The drag moved & ended up in a different place 00285 MonoOff 00286 00287 ********************************************************************************************/ 00288 00289 enum DragEndType 00290 { 00291 DT_CANCELLED, // the drag was cancelled by the user (eg. ESC pressed) 00292 DT_DIDNOTMOVE, // The Drag did not move at all 00293 DT_MOVEDTOSAME, // The Drag moved but ended up in the same place 00294 DT_MOVEDTODIFF // The drag moved & ended up in a different place 00295 }; 00296 00297 00298 00299 /******************************************************************************************** 00300 00301 > class Tool_v1 : SimpleCCObject 00302 00303 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00304 Created: 19/7/93 00305 Purpose: Specifies the interface between tools and the Kernel/OIL. 00306 SeeAlso: Tool 00307 00308 ********************************************************************************************/ 00309 00310 class CCAPI Tool_v1 : public CC_CLASS_MEMDUMP 00311 { 00312 CC_DECLARE_MEMDUMP(Tool_v1); 00313 00314 public: 00315 // Initialise Parent member 00316 Tool_v1() { Parent = NULL; }; 00317 00318 virtual ~Tool_v1(); 00319 00320 // Initialise the tool 00321 virtual BOOL Init(); 00322 00323 // What version of the Tool interface does this tool understand? 00324 virtual UINT32 GetToolInterfaceVersion() { return 1; } ; 00325 00326 // Efficient access to the Tool's ID 00327 virtual UINT32 GetID() { return 0; } ; 00328 00329 // Get info on the tool. 00330 virtual void Describe(void* Info); 00331 00332 // Example handlers - change these to have sensible names and parameters once 00333 // real tool work starts (i.e. when we know what sort of handlers we need). 00334 00335 // Notify the current tool that the mouse has moved. 00336 virtual void OnMouseMove(DocCoord, Spread*, ClickModifiers); 00337 00338 // Notify the current tool of click events on the document... 00339 virtual void OnClick(DocCoord, ClickType, ClickModifiers, Spread*); 00340 00341 // Notify the current tool of a key press event... 00342 virtual BOOL OnKeyPress(KeyPress* pKeyPress); 00343 00344 // Notify the current tool of an idle event... 00345 virtual BOOL OnIdle(); 00346 00347 // Interogate the current tool for status line text 00348 virtual BOOL GetStatusLineText(String_256* ptext, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods); 00349 00350 // Allows tools to register a key combination for switching to the tool temporarily 00351 virtual BOOL RegisterToolSwitch(KeyPress* pKeyPress, BOOL FromFile = FALSE); 00352 00353 // Notify the tool when a drag ends 00354 virtual BOOL DragFinished(DragEndType HowEnded); 00355 00356 // Notify the Current Tool that it has to render its blobs 00357 virtual void RenderToolBlobs(Spread*, DocRect*); 00358 00359 // Allow the selection and deselection of a tool 00360 virtual void SelectChange(BOOL IsSelected); 00361 00362 // Allow the Current Tool to modify coordinates displayed on the Ruler 00363 virtual void GetRulerOrigin(Spread* pSpread, UserCoord*); 00364 00365 // Allow the current tool to render additional blobs on the Ruler 00366 virtual void RenderRulerBlobs(RulerBase* pRuler, UserRect& UpdateRect, BOOL IsBackground); 00367 00368 // Allow the current tool to change the ruler help text 00369 virtual BOOL GetRulerStatusLineText(String_256* pText, UserCoord PointerPos, 00370 Spread* pSpread, RulerBase* pRuler); 00371 00372 // Allow the Current Tool to handle Ruler clicks 00373 virtual BOOL OnRulerClick( UserCoord PointerPos, 00374 ClickType Click, 00375 ClickModifiers Mods, 00376 Spread* pSpread, 00377 RulerBase* pRuler 00378 ); 00379 00380 // Easy access to the tool's info structure 00381 ToolListItem *Parent; 00382 00383 // are we the current tool or not. Note NOT virtual 00384 BOOL IsCurrent() const; 00385 00386 // this is so we can quickly go from a tool ID to a module ID 00387 // if 0 is in here then it means the resources are in the .exe, not in any .DLLs 00388 static UINT32 GetOwnerModule( UINT32 ); 00389 static BOOL SetOwnerModule( UINT32, UINT32 ); 00390 00391 // Return TRUE if you render tool blobs on selection change messages 00392 virtual BOOL AreToolBlobsRenderedOnSelection() {return FALSE;} 00393 00394 protected: 00395 static UINT32 OwnerModuleList[ TOOLID_MAX + 1 ]; 00396 }; 00397 00398 00399 00400 00401 /******************************************************************************************** 00402 00403 > class Tool : public Tool_v1 00404 00405 Author: Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com> 00406 Created: 21/6/93 00407 Purpose: The Tool type reflects the latest Tool specification. Do NOT subclass from 00408 Tool, but use the latest Tool revision (e.g. Tool_v42). The Tool type should 00409 only be used by the Kernel and OIL layers, never by tools themselves. 00410 SeeAlso: ToolInfo 00411 00412 ********************************************************************************************/ 00413 00414 // This should always inherit from the most modern definition of the Tool_vnn class 00415 00416 class CCAPI Tool : public Tool_v1 00417 { 00418 CC_DECLARE_MEMDUMP(Tool); 00419 00420 public: 00421 static BOOL InitToolList(); 00422 static BOOL InitTools(); 00423 static void SelectFirstTool(); 00424 static void DeinitTools(); 00425 static OILTool *GetOILTool(UINT32 ToolID); 00426 00427 // Making and Finding out which tool is current 00428 static Tool *GetCurrent(); 00429 static UINT32 GetCurrentID(); 00430 void SetCurrent(); 00431 static void SetNoCurrent(); 00432 void SetButtons(BOOL State); 00433 // ToolList Manipulation Functions 00434 static UINT32 GetNumTools(); 00435 // initial tool id 00436 static UINT32 InitTool; 00437 static ToolListItem *Find(UINT32 ToolID); 00438 static ToolListItem *Declare(Tool *, UINT32 ParentID); 00439 static ToolListItem *GetFirstTool(); 00440 static ToolListItem *GetNextTool( ToolListItem* CurrTool ); 00441 static UINT32 GetModuleID(UINT32 ToolID); 00442 static BOOL SelectATool(); 00443 static Tool* FindTool(UINT32 ToolID); 00444 00445 // Handle temporary tool activation via hot-keys. 00446 static void ActivateTemporaryTool(Tool*); 00447 static void DeactivateTemporaryTool(); 00448 //static BOOL IsCurrentToolTemporary(); 00449 static BOOL SwitchTool(KeyPress* pKeyPress); // Switches tool on a key press 00450 static void RemoveDirectRegToolSwitches(Tool* pThisTool); // Delete directly registered tool switches for this tool 00451 static void DeleteTempToolList(); // Deletes the list of temporary tools 00452 00453 static void SetToolChangingState(BOOL state); 00454 static BOOL IsToolChanging(); 00455 00456 static void OnActivateApp(BOOL bActive); // Tell the tool the app's active state has changed 00457 static void EndDrag(); // Tell the tool when the drag has ended 00458 static void ServicePendingToolChange(); // Changes too if needed. 00459 00460 00461 // operator Tool_v1 *() { return (Tool_v1*) this; } 00462 00463 private: 00464 00465 static ToolList *Tools; 00466 static Tool* Current; // Pointer to the current tool 00467 // static Tool* PrevTool; 00468 00469 static BOOL ToolChanging; 00470 static BOOL PendingDeactivateTempTool; 00471 static List TempToolList; 00472 }; 00473 00474 00475 #endif // INC_TOOL