diff --git a/palm/palmmain.c b/palm/palmmain.c index 6008584d0..fa224bf54 100644 --- a/palm/palmmain.c +++ b/palm/palmmain.c @@ -466,7 +466,8 @@ positionBoard( PalmAppGlobals* globals ) PALM_GRIDLESS_SCORE_LEFT+2) * doubler; bounds.extent.x = (RECOMMENDED_SBAR_WIDTH + 2) * doubler; - bounds.extent.y = (PALM_GRIDLESS_SCORE_TOP - bounds.topLeft.y - 2) * doubler; + bounds.extent.y = (PALM_GRIDLESS_SCORE_TOP - bounds.topLeft.y - 2) + * doubler; } globals->progress.boundsRect = bounds; #endif @@ -1887,11 +1888,13 @@ drawFormButtons( PalmAppGlobals* globals ) if ( globals->hasTreoFiveWay ) { focusItem = globals->gState.focusItem; if ( focusItem > 0 ) { -/* XP_WARNF( "setting focus: %s", frmObjId_2str(focusItem) ); */ - setFormFocus( globals->mainForm, focusItem ); - if ( !isBoardObject( focusItem ) - && buttonIsUsable( getActiveObjectPtr(focusItem) ) ) { - drawFocusRingOnGadget( globals, focusItem, focusItem ); + if ( isFormObject( globals->mainForm, focusItem ) ) { +/* XP_WARNF( "setting focus: %s", frmObjId_2str(focusItem) ); */ + setFormFocus( globals->mainForm, focusItem ); + if ( !isBoardObject( focusItem ) + && buttonIsUsable( getActiveObjectPtr(focusItem) ) ) { + drawFocusRingOnGadget( globals, focusItem, focusItem ); + } } globals->gState.focusItem = -1; } else { diff --git a/palm/palmutil.c b/palm/palmutil.c index b9278519a..60b3ad0f9 100644 --- a/palm/palmutil.c +++ b/palm/palmutil.c @@ -55,9 +55,10 @@ MemPtr getActiveObjectPtr( UInt16 objectID ) { FormPtr form = FrmGetActiveForm(); - XP_ASSERT( FrmGetObjectPtr( - form, FrmGetObjectIndex( form, objectID ) )!= NULL ); - return FrmGetObjectPtr( form, FrmGetObjectIndex( form, objectID ) ); + Int16 index = FrmGetObjectIndex( form, objectID ); + XP_ASSERT( index >= 0 ); + XP_ASSERT( FrmGetObjectPtr( form, index )!= NULL ); + return FrmGetObjectPtr( form, index ); } /* getActiveObjectPtr */ /***************************************************************************** @@ -66,8 +67,10 @@ getActiveObjectPtr( UInt16 objectID ) void getObjectBounds( UInt16 objectID, RectangleType* rectP ) { - FormPtr form = FrmGetActiveForm(); - FrmGetObjectBounds( form, FrmGetObjectIndex( form, objectID ), rectP ); + FormPtr form = FrmGetActiveForm(); + Int16 index = FrmGetObjectIndex( form, objectID ); + XP_ASSERT( index >= 0 ); + FrmGetObjectBounds( form, index, rectP ); } /* getObjectBounds */ #if defined XW_FEATURE_UTILS @@ -77,8 +80,10 @@ getObjectBounds( UInt16 objectID, RectangleType* rectP ) void setObjectBounds( UInt16 objectID, RectangleType* rectP ) { - FormPtr form = FrmGetActiveForm(); - FrmSetObjectBounds( form, FrmGetObjectIndex( form, objectID ), rectP ); + FormPtr form = FrmGetActiveForm(); + Int16 index = FrmGetObjectIndex( form, objectID ); + XP_ASSERT( index >= 0 ); + FrmSetObjectBounds( form, index, rectP ); } /* getObjectBounds */ /***************************************************************************** @@ -172,7 +177,8 @@ void centerControl( FormPtr form, UInt16 id ) { RectangleType cBounds, fBounds; - UInt16 index = FrmGetObjectIndex( form, id ); + Int16 index = FrmGetObjectIndex( form, id ); + XP_ASSERT( index >= 0 ); FrmGetObjectBounds( form, index, &cBounds ); FrmGetFormBounds( form, &fBounds ); @@ -423,9 +429,18 @@ getFocusOwner( void ) void setFormFocus( FormPtr form, XP_U16 objectID ) { - FrmSetFocus( form, FrmGetObjectIndex( form, objectID ) ); + Int16 index = FrmGetObjectIndex( form, objectID ); + XP_ASSERT( index >= 0 ); + FrmSetFocus( form, index ); } /* setFormFocus */ +XP_Bool +isFormObject( FormPtr form, XP_U16 objectID ) +{ + Int16 index = FrmGetObjectIndex( form, objectID ); + return index >= 0; +} + #ifndef XW_TARGET_PNO /* Warning: gross hack. HsNavDrawFocusRing doesn't work on newer Palms, e.g. Tungsten T. It's been replaced by FrmNavDrawFocusRing. But that diff --git a/palm/palmutil.h b/palm/palmutil.h index a692f5fd6..e6a3d333a 100644 --- a/palm/palmutil.h +++ b/palm/palmutil.h @@ -81,6 +81,7 @@ void drawOneGadget( UInt16 id, const char* text, Boolean hilite ); # ifdef XWFEATURE_FIVEWAY XP_S16 getFocusOwner( void ); void setFormFocus( FormPtr form, XP_U16 objectID ); +XP_Bool isFormObject( FormPtr form, XP_U16 objectID ); void drawFocusRingOnGadget( PalmAppGlobals* globals, XP_U16 idLow, XP_U16 idHigh ); XP_Bool considerGadgetFocus( PalmAppGlobals* globals, const EventType* event,