00001 // $Id: pen.h 1282 2006-06-09 09:46:49Z alex $ 00003 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00004 ================================XARAHEADERSTART=========================== 00005 00006 Xara LX, a vector drawing and manipulation program. 00007 Copyright (C) 1993-2006 Xara Group Ltd. 00008 Copyright on certain contributions may be held in joint with their 00009 respective authors. See AUTHORS file for details. 00010 00011 LICENSE TO USE AND MODIFY SOFTWARE 00012 ---------------------------------- 00013 00014 This file is part of Xara LX. 00015 00016 Xara LX is free software; you can redistribute it and/or modify it 00017 under the terms of the GNU General Public License version 2 as published 00018 by the Free Software Foundation. 00019 00020 Xara LX and its component source files are distributed in the hope 00021 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00022 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00023 See the GNU General Public License for more details. 00024 00025 You should have received a copy of the GNU General Public License along 00026 with Xara LX (see the file GPL in the root directory of the 00027 distribution); if not, write to the Free Software Foundation, Inc., 51 00028 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00029 00030 00031 ADDITIONAL RIGHTS 00032 ----------------- 00033 00034 Conditional upon your continuing compliance with the GNU General Public 00035 License described above, Xara Group Ltd grants to you certain additional 00036 rights. 00037 00038 The additional rights are to use, modify, and distribute the software 00039 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00040 library and any other such library that any version of Xara LX relased 00041 by Xara Group Ltd requires in order to compile and execute, including 00042 the static linking of that library to XaraLX. In the case of the 00043 "CDraw" library, you may satisfy obligation under the GNU General Public 00044 License to provide source code by providing a binary copy of the library 00045 concerned and a copy of the license accompanying it. 00046 00047 Nothing in this section restricts any of the rights you have under 00048 the GNU General Public License. 00049 00050 00051 SCOPE OF LICENSE 00052 ---------------- 00053 00054 This license applies to this program (XaraLX) and its constituent source 00055 files only, and does not necessarily apply to other Xara products which may 00056 in part share the same code base, and are subject to their own licensing 00057 terms. 00058 00059 This license does not apply to files in the wxXtra directory, which 00060 are built into a separate library, and are subject to the wxWindows 00061 license contained within that directory in the file "WXXTRA-LICENSE". 00062 00063 This license does not apply to the binary libraries (if any) within 00064 the "libs" directory, which are subject to a separate license contained 00065 within that directory in the file "LIBS-LICENSE". 00066 00067 00068 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00069 ---------------------------------------------- 00070 00071 Subject to the terms of the GNU Public License (see above), you are 00072 free to do whatever you like with your modifications. However, you may 00073 (at your option) wish contribute them to Xara's source tree. You can 00074 find details of how to do this at: 00075 http://www.xaraxtreme.org/developers/ 00076 00077 Prior to contributing your modifications, you will need to complete our 00078 contributor agreement. This can be found at: 00079 http://www.xaraxtreme.org/developers/contribute/ 00080 00081 Please note that Xara will not accept modifications which modify any of 00082 the text between the start and end of this header (marked 00083 XARAHEADERSTART and XARAHEADEREND). 00084 00085 00086 MARKS 00087 ----- 00088 00089 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00090 designs are registered or unregistered trademarks, design-marks, and/or 00091 service marks of Xara Group Ltd. All rights in these marks are reserved. 00092 00093 00094 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00095 http://www.xara.com/ 00096 00097 =================================XARAHEADEREND============================ 00098 */ 00099 00100 // Support for Graphics Tablets with Pressure Sensitive Pens 00101 00102 // WEBSTER - markn 25/4/97 00103 // No pen stuff required in Webster 00104 #ifdef WEBSTER 00105 #define INC_PEN 00106 #endif // WEBSTER 00107 00108 #ifndef INC_PEN 00109 #define INC_PEN 00110 00111 //#include "ops.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00112 00113 #define MAXPRESSURE 1023 00114 #define JOYMAX 65536 00115 00116 typedef enum 00117 { 00118 PressureMode_None, // Pressure not being recorded (always returns max pressure) 00119 PressureMode_Pen, // Pressure is recorded from a real pressure pen 00120 PressureMode_Speed, // Pressure is simulated from mouse speed 00121 PressureMode_Direction, // Pressure is simulated from mouse direction 00122 00123 PressureMode_MaxEnum // Placeholder so we know how many modes there are 00124 } PressureMode; 00125 00126 00127 /******************************************************************************************** 00128 00129 > class CCPen : public CCObject 00130 00131 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00132 Created: 23/5/94 00133 Purpose: This provides support for Pressure Sensitive Pen devices. 00134 Its job is to keep track of the current pressure of a pen. 00135 It will automatically mutate itself into either a Real or Pretend pen, 00136 depending on what is availble when it is created. 00137 If it is a real pen, then it gets it's pressure from mouse messages. 00138 If it is a pretend pen, then the pressure is adjusted using either the 00139 keyboard (temporarily Keypad +/-) or by using a joystick. 00140 00141 ********************************************************************************************/ 00142 00143 class CCPen : public CCObject 00144 { 00145 CC_DECLARE_DYNAMIC(CCPen); 00146 00147 public: 00148 CCPen(); // Don't construct one. Use GetApplication()->GetPressurePen() instead. 00149 ~CCPen(); 00150 00151 // Initialisation function 00152 static CCPen *Init(); 00153 00154 public: // General Info about the Pen 00155 BOOL IsRealPen() { return PressureAvailable; } 00156 BOOL IsPressureOn() { return DefaultPressureMode != PressureMode_None; } 00157 UINT32 GetPenPressure() { return PenPressure; } 00158 UINT32 GetPressureMax() { return PressureMax; } 00159 00160 00161 public: // Pen control interfaces 00162 // Switch the pressure on or off 00163 void SetPressureMode(PressureMode NewMode) { CurrentPressureMode = DefaultPressureMode = NewMode; } 00164 PressureMode GetPressureMode(void) { return(CurrentPressureMode); } 00165 00166 // Function called by CCamView, when the Joystick moves 00167 void SetPressureFromJoystick(WPARAM, LPARAM); 00168 00169 00170 public: // Internal calls to update the pen when mouse events occur (see scrvw.cpp) 00171 virtual void CheckMouseMessage(UINT32 Message, wxPoint point); 00172 // Check for pen information whenever we get a mouse message 00173 00174 virtual void StartStroke(void); 00175 virtual void EndStroke(void); 00176 // Called by pen-using tools when they start/end a drag operation 00177 // This allows the pen to be disabled while not in use, and also 00178 // lets us detect when the user swaps between their pen and mouse 00179 00180 00181 protected: // Upcalls to derived classes. If they don't handle this they should call the base class 00182 virtual BOOL ReadTabletPressureData(void); 00183 00184 00185 protected: 00186 UINT32 PenPressure; // Last "pressure" value we read/calculated 00187 UINT32 PressureMax; // The maximum pressure value 00188 00189 BOOL PF_IsPressureOn; // Are we bothering with pressure data? 00190 00191 BOOL PressureAvailable; // Is this a real or pretend pen? 00192 PressureMode CurrentPressureMode; // The type of pressure recording used for this stroke 00193 00194 PORTNOTE("other","Removed HWND usage") 00195 #ifndef EXCLUDE_FROM_XARALX 00196 HWND hMainframeWnd; // A handle to the camelot main frame window 00197 #endif 00198 00199 wxPoint LastMousePoint; // Last recorded mouse position when faking pressure with mouse 00200 00201 public: 00202 static PressureMode DefaultPressureMode; 00203 // The type of pressure recording we'll do by default 00204 }; 00205 00206 00207 00208 00209 00210 /******************************************************************************************** 00211 00212 > class OpTogglePressure : public Operation 00213 00214 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00215 Created: 20/6/94 00216 Purpose: This class represents the TogglePressure operation. 00217 Creating an instance of this class and calling its "Do" function will toggle 00218 the state of the flag controlling whether Pressure Information is stored 00219 within paths. 00220 00221 ********************************************************************************************/ 00222 00223 #define OPTOKEN_TOGGLEPRESSURE TEXT("TogglePressure") 00224 00225 class OpTogglePressure: public Operation 00226 { 00227 CC_DECLARE_DYNCREATE( OpTogglePressure ) 00228 00229 public: 00230 OpTogglePressure(); // Constructor 00231 ~OpTogglePressure(); // Destructor 00232 00233 static BOOL Init(); // Register an OpDescriptor 00234 void Do(OpDescriptor*); // "Do" function 00235 static OpState GetState(String_256*, OpDescriptor*); // Read the state of an operation 00236 }; 00237 00238 #endif // INC_PEN