#include <pen.h>
Inheritance diagram for CCPen:
Public Member Functions | |
CCPen () | |
CCPen constructor. | |
~CCPen () | |
CCPen destructor. | |
BOOL | IsRealPen () |
BOOL | IsPressureOn () |
UINT32 | GetPenPressure () |
UINT32 | GetPressureMax () |
void | SetPressureMode (PressureMode NewMode) |
PressureMode | GetPressureMode (void) |
void | SetPressureFromJoystick (WPARAM, LPARAM) |
Set the pretend Pen Pressure from the Joytick Position. | |
virtual void | CheckMouseMessage (UINT32 Message, wxPoint point) |
Checks a mouse message to see if it came from a pen, and if so sets the current pressure value. | |
virtual void | StartStroke (void) |
Informs the Pen class that you are starting a stroke (a drag operation for which you wish to record pressure information). | |
virtual void | EndStroke (void) |
Informs the Pen class that you are completing a stroke (a drag operation for which you recorded pressure information). | |
Static Public Member Functions | |
static CCPen * | Init () |
Application.LateInit calls this to obtain the default pen object. | |
Static Public Attributes | |
static PressureMode | DefaultPressureMode = PressureMode_None |
Protected Member Functions | |
virtual BOOL | ReadTabletPressureData (void) |
Records the latest pressure info from the pressure sensitive tablet Does nothing if this is not a "real" pen. | |
Protected Attributes | |
UINT32 | PenPressure |
UINT32 | PressureMax |
BOOL | PF_IsPressureOn |
BOOL | PressureAvailable |
PressureMode | CurrentPressureMode |
HWND | hMainframeWnd |
wxPoint | LastMousePoint |
Private Member Functions | |
CC_DECLARE_DYNAMIC (CCPen) |
Definition at line 143 of file pen.h.
|
CCPen constructor.
Definition at line 185 of file pen.cpp. 00186 { 00187 PORTNOTETRACE("other","CCPen::CCPen - do nothing"); 00188 #ifndef EXCLUDE_FROM_XARALX 00189 // See if it is likely that we'll be able to initialise as a "real" pen 00190 PressureAvailable = FALSE; 00191 00192 // Initalise member variables 00193 wxWindow *pMainFrame = GetMainFrame(); 00194 ERROR3IF(pMainFrame == NULL, "No main frame window when CCPen initialised"); 00195 hMainframeWnd = pMainFrame->m_hWnd; 00196 00197 PenPressure = 0; 00198 PressureMax = MAXPRESSURE; // Set the default Maximum Pressure Value 00199 00200 CurrentPressureMode = DefaultPressureMode; 00201 if (CurrentPressureMode == PressureMode_None) 00202 PenPressure = PressureMax; 00203 00204 LastMousePoint = CPoint(0,0); 00205 #endif 00206 }
|
|
CCPen destructor.
Definition at line 224 of file pen.cpp.
|
|
|
|
Checks a mouse message to see if it came from a pen, and if so sets the current pressure value.
Definition at line 328 of file pen.cpp. 00329 { 00330 PORTNOTETRACE("other","CCPen::CheckMouseMessage - do nothing"); 00331 #ifndef EXCLUDE_FROM_XARALX 00332 if (IsRealPen() && CurrentPressureMode == PressureMode_Pen) 00333 { 00334 // Go and check the tablet for new pressure data. If it fails, we will drop through 00335 // to the normal mouse handler - this means if a pen user puts down the pen and 00336 // uses the mouse, we automatically drop back to reading the mouse when we fail to 00337 // recieve pen packets. 00338 if (ReadTabletPressureData()) 00339 return; 00340 } 00341 00342 switch(CurrentPressureMode) 00343 { 00344 case PressureMode_None: 00345 PenPressure = PressureMax; 00346 break; 00347 00348 case PressureMode_Pen: 00349 // We want to read values from a real pen, but that is unavailable, 00350 // so we drop through to fake something up based on mouse speed. 00351 // NOBREAK 00352 00353 // 12/8/2000 This has changed, we no longer want to fake pressure at all 00354 PenPressure = PressureMax; 00355 break; 00356 case PressureMode_Speed: 00357 // We've got a fake pen. We use mouse travel speed to generate pressure info 00358 if (Message == WM_MOUSEMOVE) 00359 { 00360 // Diccon - disabled mouse speed pressure for now 00361 00362 PenPressure = PressureMax / 2 ;// - (INT32)(Speed * (double)PressureMax); 00363 // PenPressure = (INT32)(Speed * (double)PressureMax); 00364 } 00365 else 00366 PenPressure = 0; // Must be mouse down. Init pressure to 0 00367 break; 00368 00369 00370 case PressureMode_Direction: 00371 // We've got a fake pen. We use mouse travel direction to generate pressure info 00372 if (Message == WM_MOUSEMOVE) 00373 { 00374 // Work out direction of travel to do a calligraphic pen 00375 NormCoord TravelDir(point.x - LastMousePoint.x, point.y - LastMousePoint.y); 00376 00377 if (TravelDir.x != 0.0 && TravelDir.y != 0.0) 00378 { 00379 TravelDir.Normalise(); 00380 00381 NormCoord PenAngle(1.0, 1.0); 00382 PenAngle.Normalise(); 00383 00384 // Take the dot product of the travel direction and the brush angle (which gives 00385 // us cos(angle between them)), which makes an excellent pressure (width) value 00386 // This actually gives us a value between -1 and +1, which we scale into 0..1 range 00387 double DotProd = TravelDir.DotProduct(PenAngle); 00388 DotProd = (DotProd + 1.0) / 2.0; 00389 00390 PenPressure = (INT32) (DotProd * (double)PressureMax); 00391 } 00392 } 00393 else 00394 PenPressure = 0; // Must be mouse down. Init pressure to 0 00395 break; 00396 } 00397 00398 // And remember the last mouse position 00399 LastMousePoint = point; 00400 #endif 00401 }
|
|
Informs the Pen class that you are completing a stroke (a drag operation for which you recorded pressure information).
Reimplemented in WinTabPressurePen. Definition at line 272 of file pen.cpp.
|
|
Definition at line 157 of file pen.h. 00157 { return PenPressure; }
|
|
Definition at line 158 of file pen.h. 00158 { return PressureMax; }
|
|
Definition at line 164 of file pen.h. 00164 { return(CurrentPressureMode); }
|
|
Application.LateInit calls this to obtain the default pen object.
Reimplemented from SimpleCCObject. Definition at line 152 of file pen.cpp. 00153 { 00154 PORTNOTETRACE("other","CCPen::Init - do nothing"); 00155 #ifndef EXCLUDE_FROM_XARALX 00156 // Check the ini file to see what state we're in 00157 if (Camelot.DeclareSection("PenSupport", 4)) 00158 Camelot.DeclarePref("PenSupport", "PressureMode", (INT32 *)&DefaultPressureMode, PressureMode_None, PressureMode_MaxEnum); 00159 00160 // Create a pressure sensitive pen. We create a derived class WinTab pen 00161 // which will call back to the base class if a WinTab device is unavailable. 00162 return(new WinTabPressurePen); 00163 #else 00164 return NULL; 00165 #endif 00166 }
|
|
Definition at line 156 of file pen.h. 00156 { return DefaultPressureMode != PressureMode_None; }
|
|
Definition at line 155 of file pen.h. 00155 { return PressureAvailable; }
|
|
Records the latest pressure info from the pressure sensitive tablet Does nothing if this is not a "real" pen.
Reimplemented in WinTabPressurePen. Definition at line 299 of file pen.cpp. 00300 { 00301 if (!PressureAvailable) 00302 return(FALSE); 00303 00304 // Base class does nothing 00305 return(FALSE); 00306 }
|
|
Set the pretend Pen Pressure from the Joytick Position.
Definition at line 418 of file pen.cpp. 00419 { 00420 PORTNOTETRACE("other","CCPen::SetPressureFromJoystick - do nothing"); 00421 #ifndef EXCLUDE_FROM_XARALX 00422 if (this->IsRealPen()) 00423 return; // Ignore this call if we are a Real Pen 00424 00425 if (!(Buttons & JOY_BUTTON1)) 00426 return; // Button1 must be down for the Pressure to be valid 00427 00428 INT32 Ypos = HIWORD(JoyPos) - (JOYMAX/2); // Get Y Offset from Joystick Centre 00429 00430 // Convert the distance from the joystick centre pos, into a value between 00431 // 0 and PressureMax 00432 PenPressure = (Ypos<0 ? -Ypos : Ypos)*PressureMax/(JOYMAX/2); 00433 #endif 00434 }
|
|
Definition at line 163 of file pen.h. 00163 { CurrentPressureMode = DefaultPressureMode = NewMode; }
|
|
Informs the Pen class that you are starting a stroke (a drag operation for which you wish to record pressure information).
It should be called when you start your drag (on button down) When the stroke finishes, remember to call CCPen::EndStroke Reimplemented in WinTabPressurePen. Definition at line 249 of file pen.cpp. 00250 { 00251 CurrentPressureMode = DefaultPressureMode; 00252 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|