What device are you doing this on?  For my stuff, it doesn't work well on
POSE at all - its very jumpy, but works fine on any device from Palm V
through Tungsten C.  Here's a snipet of my code - it uses a gadget control
as the input area.  I do nothing special in the app event loop.  AddPoint()
just records the points into an array to be saved at the end.

objIndex = FrmGetObjectIndex (frmP, GadgetID);
FrmGetObjectBounds (frmP, objIndex, &r);
do {
    PenGetPoint (&x, &y, &penDown);

    // Check array bounds
    if (ptCnt1 >= (MAX_STROKES - 10)
        break;

    if (y != y1 || x != x1) {  // Throw away all of the repeat events with
the same coordinates
        // If all points are in the bounds of the gadget and this isn't the
first point
        if (RctPtInRectangle (x, y, &r) && RctPtInRectangle (x1, y1, &r) &&
x1 && y1) {
            WinDrawLine (x, y, x1, y1);  // Draw a line on the Palm from the
previous pen point to the new point
            AddPoint (x - x1, y - y1, false);
        } else if (RctPtInRectangle (x, y, &r)) { // add a starter point
            AddPoint (x - r.topLeft.x, y - r.topLeft.y, true);
        }
        x1 = x;
        y1 = y;
    }
} while (penDown);


-Dave



"kcorey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 2004-04-01 at 02:45, Eddie Gomez wrote:
> > Given the following code snippet:
> >
> >     // track the pen
> >      do
> >     {
> >             EvtGetPen(&x, &y, &penDown);
> >           // Don't do anything if no pen movement
> >           if ((x != prevX || y != prevY))
> >           {
> >                WinDrawLine(prevX, prevY, x, y);
> >                prevX = x;
> >                prevY = y;
> >           }
> >
> >    } while (penDown);
>
> The Palm is concatenating mouse move events so that your application
> isn't overwhelmed...but this leads to clunky lines.
>
> Try something like this instead, inside your main event loop:
> (This is off the top of my head, and so is likely horribly broken.  It's
> just meant as a hint.)
>
> int MainEventLoop()
> {
> EventType e;
> Int16 x,y;
> Boolean pendown;
>
> while (e.eType != appStopEvent) {
> // bTrackingMouse is a boolean you set elsewhere
> // to indicate you're interested in tracking the
> // mouse ptr.
> if (bTrackingMouse) {
> // hard on batteries, but this gives you
> // the best response.  Increase the '0'
> // if you can.
> EvtGetEvent(&e,0);
> EvtGetPen(&x,&y,&pendown);
>
> if (pendown) {
> // if first time, draw from x,y to x,y
> // if not first time, draw a line from
> // the old x,y to this new x,y.
> }
>
> // The pen has been lifted.  Fall out
> // of this action.
> if (!pendown) {
> bTrackingMouse=false;
> }
> } else {
> EvtGetEvent(&e,evtWaitForever);
> }
> if (e.eType == penDownEvent) {
> bTrackingMouse=true;
> }
>
> }
> }
>
> -Ken
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to