InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CTool.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: EricM
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //
23 // Updated: Frits - Rewrite for widget architecture
24 //
25 // Helper class for implementing the ITool interface.
26 //
27 //========================================================================================
28 
29 #ifndef __CTool__
30 #define __CTool__
31 
32 #include "ITool.h"
33 #include "HelperInterface.h"
34 #include "PMString.h"
35 #include "PMRect.h"
36 #include "ScriptingDefs.h"
37 #include "IControlView.h"
38 
39 #ifdef WIDGET_BUILD
40 #endif
41 const PMReal kOneToolIconWidth = 30.0;
42 const PMReal koneToolIconHeight = 24.0;
43 const PMRect kStandardToolRect(0,0,kOneToolIconWidth,koneToolIconHeight);
44 const PMRect kMiniToolRect(0,0, 20,20);
45 const PMRect kMiddleMiniToolRect(0,0,20,20);
46 
47 
51 class CTool: public ITool
52 {
53  public:
54  CTool(IPMUnknown *boss);
55  CTool(IPMUnknown *boss, int32 toolInfo, bool16 isCreation, bool16 isSelection);
56  ~CTool();
57 
58  virtual void ReadWrite(IPMStream* s, ImplementationID prop);
59 
62  virtual void Init(RsrcID iconID, const PluginID& pluginID);
63 
66  virtual void InitWidget(const WidgetID& widgetId, RsrcID iconID, const PluginID& pluginID, PMRect toolRect = kStandardToolRect);
67 
70  virtual void Select();
71 
74  virtual void Deselect();
75 
78  virtual bool IsSelected();
79 
82  virtual ICursorProvider* GetCursorProvider() const;
83 
86  virtual void SetCursorProvider(ICursorProvider* newProvider);
87 
90  virtual bool16 IsCreationTool() const;
91 
94  virtual bool16 IsSelectionTool() const;
95 
98  virtual bool16 IsTextTool() const;
99 
102  virtual const PMString& GetName() const;
103 
106  virtual void SetName(const PMString& newName);
107 
110  virtual const PMString& GetToolHint() const;
111 
114  virtual void SetToolHint(const PMString& newHint);
115 
118  virtual const IDFile& GetToolIconFile() const;
119 
124  virtual const ClassID& GetToolType() const;
125 
130  virtual void SetToolType(const ClassID& newToolType);
131 
135  virtual ActionID GetActionID() const;
136 
140  virtual void SetActionID(ActionID action);
141 
145  virtual void DisplayOptions();
146 
150  virtual void DisplayAltOptions();
151 
154  virtual bool16 IsToolOfType(ITool::ToolType toolInformation) const;
155 
162  virtual ScriptID GetScriptID() const { ASSERT_UNIMPLEMENTED(); return en_None; }
163 
167  virtual bool16 IsToolNone() const;
168 
169  protected:
170  ICursorProvider* fCursorProvider;
171  bool16 fIsCreation;
172  bool16 fIsSelection;
173  ClassID fToolType;
174  int32 fToolInformation; // bit field containing the information about what tool type this is
175  bool fSelected;
176  virtual PMString BuildHintString(PMString& theDescriptionString, PMString& theShiftHint, PMString& theCommandCtrlHint, PMString& theOptionAltHint, PMString& theArrowsHint, PMString& extrasString);
177  virtual PMString BuildHintString(PMString& theDescriptionString, PMString& theShiftHint, PMString& theCommandCtrlHint, PMString& theOptionAltHint, PMString& theArrowsHint, K2Vector<PMString>& theExtraModifiersHint, PMString& extrasString);
178 
179  private:
180  ActionID fActionID;
181  PMString fName;
182  PMString fToolHint;
183  IDFile fToolIconFile;
184  int32 fIconID;
185 
186 
187 };
188 
189 
190 #endif