void Path::Stroke(Shape *dest, bool doClose, double width, JoinType join, ButtType butt, double miter, bool justAdd) { if (dest == NULL) { return; } if (justAdd == false) { dest->Reset(3 * pts.size(), 3 * pts.size()); } dest->MakeBackData(false); int lastM = 0; while (lastM < int(pts.size())) { int lastP = lastM + 1; while (lastP < int(pts.size()) // select one subpath && (pts[lastP].isMoveTo == polyline_lineto || pts[lastP].isMoveTo == polyline_forced)) { lastP++; } if ( lastP > lastM+1 ) { Geom::Point sbStart = pts[lastM].p; Geom::Point sbEnd = pts[lastP - 1].p; if ( pts[lastP - 1].closed /*Geom::LInfty(sbEnd-sbStart) < 0.00001 */ ) { // why close lines that shouldn't be closed? // ah I see, because close is defined here for // a whole path and should be defined per subpath. // debut==fin => ferme (on devrait garder un element pour les close(), mais tant pis) DoStroke(lastM, lastP - lastM, dest, true, width, join, butt, miter, true); } else { DoStroke(lastM, lastP - lastM, dest, doClose, width, join, butt, miter, true); } } else if (butt == butt_round) { // special case: zero length round butt is a circle int last[2] = { -1, -1 }; Geom::Point dir; dir[0] = 1; dir[1] = 0; Geom::Point pos = pts[lastM].p; DoButt(dest, width, butt, pos, dir, last[RIGHT], last[LEFT]); int end[2]; dir = -dir; DoButt(dest, width, butt, pos, dir, end[LEFT], end[RIGHT]); dest->AddEdge (end[LEFT], last[LEFT]); dest->AddEdge (last[RIGHT], end[RIGHT]); } lastM = lastP; } }
VOID KeyEventProc(PCONSOLE_INFO pdp, KEY_EVENT_RECORD event) { #ifdef USE_OLD_CODE // this must here gather keystrokes and pass them forward into the // opened sentience... // PTEXT temp; int bOutput = FALSE; lprintf( "Entering handle a key event..." ); Lock( pdp ); lprintf( "Got the lock, waiting for collection buffer..." ); if( event.bKeyDown ) { PTEXT key; // here is where we evaluate the curent keystroke.... for( ; event.wRepeatCount; event.wRepeatCount-- ) { int mod = KEYMOD_NORMAL; extern PSIKEYDEFINE KeyDefs[]; if(event.dwControlKeyState& (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED)) mod |= KEYMOD_CTRL; if(event.dwControlKeyState& (RIGHT_ALT_PRESSED|LEFT_ALT_PRESSED)) mod |= KEYMOD_ALT; if( KeyDefs[event.wVirtualKeyCode].flags & KDF_CAPSKEY ) { if( event.dwControlKeyState & CAPSLOCK_ON ) { if( !(event.dwControlKeyState& SHIFT_PRESSED) ) mod |= KEYMOD_SHIFT; } else { if( event.dwControlKeyState& SHIFT_PRESSED ) mod |= KEYMOD_SHIFT; } } else if( event.dwControlKeyState& SHIFT_PRESSED ) mod |= KEYMOD_SHIFT; if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bStroke || pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bMacro ) { if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bStroke ) { bOutput |= DoStroke(pdp, pdp->Keyboard[event.wVirtualKeyCode][mod].data.stroke); } else if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bMacro ) { if( pdp->common.Owner->pRecord != pdp->Keyboard[event.wVirtualKeyCode][mod].data.macro ) InvokeMacro( pdp->common.Owner , pdp->Keyboard[event.wVirtualKeyCode][mod].data.macro , NULL ); // do macro!!!!! } } else { if( key = KeyDefs[event.wVirtualKeyCode].op[mod].data.pStroke ) { if( KeyDefs[event.wVirtualKeyCode].op[mod].bFunction ) bOutput |= ((KeyFunc)key)(pdp); else { bOutput |= DoStroke( pdp, key ); } } } } // call to clear and re-write the current buffer.... //if( bOutput ) // so we don't output on shift, control, etc... //RenderCommandLine( pdp ); } else { // key up's don't matter like ever... } Unlock( pdp ); #else // this must here gather keystrokes and pass them forward into the // opened sentience... // PTEXT temp; int bOutput = FALSE; int mod = KEYMOD_NORMAL; if( !pdp ) // not a valid window handle/device path return; //Log( "Entering keyproc..." ); EnterCriticalSec( &pdp->Lock ); //while( LockedExchange( &pdp->common.CommandInfo->CollectionBufferLock, 1 ) ) // Sleep(0); Log1( "mod = %x", pdp->dwControlKeyState ); mod = pdp->dwControlKeyState; if( KeyDefs[event.wVirtualKeyCode].flags & KDF_CAPSKEY ) { if( event.dwControlKeyState & CAPSLOCK_ON ) { mod ^= KEYMOD_SHIFT; } } if( event.bKeyDown ) { for( ; event.wRepeatCount; event.wRepeatCount-- ) { unsigned char KeyState[256]; DECLTEXT( key, " " ); GetKeyboardState( KeyState ); SetTextSize( &key, ToAscii( event.wVirtualKeyCode , event.wVirtualScanCode , KeyState , (unsigned short*)key.data.data , 0 ) ); KeyPressHandler( pdp, event.wVirtualKeyCode, mod, (PTEXT)&key ); } #if 0 // here is where we evaluate the curent keystroke.... for( ; event.wRepeatCount; event.wRepeatCount-- ) { // check current keyboard override... if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bStroke || pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bMacro ) { if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bStroke ) { bOutput |= DoStroke(pdp, pdp->Keyboard[event.wVirtualKeyCode][mod].data.stroke); } else if( pdp->Keyboard[event.wVirtualKeyCode][mod].flags.bMacro ) { if( pdp->common.Owner->pRecord != pdp->Keyboard[event.wVirtualKeyCode][mod].data.macro ) InvokeMacro( pdp->common.Owner , pdp->Keyboard[event.wVirtualKeyCode][mod].data.macro , NULL ); } } else // key was not overridden { int result; Log1( "Keyfunc = %d", KeyDefs[event.wVirtualKeyCode].op[mod].bFunction ); switch( KeyDefs[event.wVirtualKeyCode].op[mod].bFunction ) { case KEYDATA_DEFINED: Log( "Key data_defined" ); bOutput |= DoStroke( pdp, (PTEXT)&KeyDefs[event.wVirtualKeyCode].op[mod].data.pStroke ); result = UPDATE_NOTHING; // unsure about this - recently added. // well it would appear that the stroke results in whether to update // the command prompt or not. break; case KEYDATA: { char KeyState[256]; DECLTEXT( key, " " ); GetKeyboardState( KeyState ); SetTextSize( &key, ToAscii( event.wVirtualKeyCode , event.wVirtualScanCode , KeyState , (void*)key.data.data , 0 ) ); if( GetTextSize( (PTEXT)&key ) ) bOutput |= DoStroke( pdp, (PTEXT)&key ); result = UPDATE_NOTHING; // already taken care of?! } break; case COMMANDKEY: result = KeyDefs[event.wVirtualKeyCode].op[mod].data.CommandKey( pdp->common.CommandInfo ); break; case HISTORYKEY: result = KeyDefs[event.wVirtualKeyCode].op[mod].data.HistoryKey( pdp->pHistoryDisplay ); break; case CONTROLKEY: KeyDefs[event.wVirtualKeyCode].op[mod].data.ControlKey( &pdp->dwControlKeyState, TRUE ); result = UPDATE_NOTHING; break; case SPECIALKEY: result = KeyDefs[event.wVirtualKeyCode].op[mod].data.SpecialKey( pdp ); break; } switch( result ) { case UPDATE_COMMAND: bOutput = TRUE; break; case UPDATE_HISTORY: if( UpdateHistory( pdp ) ) DoRenderHistory(pdp, TRUE); DoRenderHistory(pdp, FALSE); break; case UPDATE_DISPLAY: ChildCalculate( pdp ); break; } } } //if( bOutput ) // RenderCommandLine( pdp ); #endif } else { // flag is redundant for CONTOLKEY type... // key up's only matter if key is upaction flaged... switch( KeyDefs[event.wVirtualKeyCode].op[mod].bFunction ) { case CONTROLKEY: KeyDefs[event.wVirtualKeyCode].op[mod].data.ControlKey( &pdp->dwControlKeyState, FALSE ); break; } } LeaveCriticalSec( &pdp->Lock ); //lprintf( "Left critical section on wincon." ); #endif }
static void Input (Widget W, StrokeStatePtr State, XEvent *event) { /* fprintf(stderr, "Input(%s,%i) - %s %i %i %i %i\n", XtName(State->widget), event->xany.type, XtName(W), event->xbutton.x, event->xbutton.y, event->xbutton.x_root, event->xbutton.y_root); */ switch (event->xany.type) { case KeyRelease: case ButtonRelease: if (State->InStroke) { int i; if (!State->Debug) { for (i = 1; i < State->npoints; i++) { XDrawLine(XtDisplay(W), event->xbutton.root, State->gc, State->points[i - 1].x, State->points[i - 1].y, State->points[i].x, State->points[i].y); /* XDrawRectangle(XtDisplay(State->widget), XtWindow(State->widget), State->gc, State->points[State->npoints].x - 2, State->points[State->npoints].y - 2, 4, 4); */ } } XtUngrabPointer(W, event->xbutton.time); XUngrabServer(XtDisplay(W)); DoStroke(event, State); State->InStroke = False; State->npoints = 0; } break; case KeyPress: case ButtonPress: if (!State->InStroke) { State->widget = W; State->npoints = 0; AllocatePoints(State); /* TranslateCoords(W, State->widget, &((XButtonPressedEvent *)event)->x, &((XButtonPressedEvent *)event)->y); */ State->points[State->npoints].x = event->xbutton.x_root; State->points[State->npoints].y = event->xbutton.y_root; State->xmin = State->points[State->npoints].x; State->ymin = State->points[State->npoints].y; State->xmax = State->points[State->npoints].x; State->ymax = State->points[State->npoints].y; State->npoints++; State->InStroke = True; XGrabServer(XtDisplay(W)); XtGrabPointer(W, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None, event->xbutton.time); } break; case MotionNotify: if (State->gc == (GC)NULL) { Pixel Background; State->gc = XCreateGC(XtDisplay(State->widget), XtWindow(State->widget), 0, NULL); XtVaGetValues(State->widget, XtNbackground, &Background, NULL); XSetForeground(XtDisplay(State->widget), State->gc, Background); XSetFunction(XtDisplay(State->widget), State->gc, GXxor); XSetSubwindowMode(XtDisplay(State->widget), State->gc, IncludeInferiors); } if (State->InStroke) { int dx = State->points[State->npoints - 1].x - event->xmotion.x_root; int dy = State->points[State->npoints - 1].y - event->xmotion.y_root; if (dx * dx + dy * dy > State->slop) { AllocatePoints(State); State->points[State->npoints].x = event->xmotion.x_root; State->points[State->npoints].y = event->xmotion.y_root; XDrawLine(XtDisplay(State->widget), event->xmotion.root, State->gc, State->points[State->npoints - 1].x, State->points[State->npoints - 1].y, State->points[State->npoints].x, State->points[State->npoints].y); State->xmin = State->xmin < State->points[State->npoints].x ? State->xmin : State->points[State->npoints].x; State->xmax = State->xmax > State->points[State->npoints].x ? State->xmax : State->points[State->npoints].x; State->ymin = State->ymin < State->points[State->npoints].y ? State->ymin : State->points[State->npoints].y; State->ymax = State->ymax > State->points[State->npoints].y ? State->ymax : State->points[State->npoints].y; State->npoints++; } } break; default: fprintf(stderr, "%s(%i): Input(%s) - %s Unknown event type %i\n", __FILE__, __LINE__, XtName(State->widget), XtName(W), event->type); } }