mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
Save and restore focus owner across app restarts (includes working around
OS's insistence on sending focusTake event on formOpen); up version numbers; turn off BT prior to beta release.
This commit is contained in:
parent
5d867cd81c
commit
971bfc280f
8 changed files with 72 additions and 37 deletions
|
@ -119,7 +119,7 @@ MYDEFS_COMMON += -DXWFEATURE_SEARCHLIMIT
|
|||
# MYDEFS_COMMON += -DXWFEATURE_RELAY
|
||||
|
||||
# turn on bluetooth comms option for 68K and ARM -- which won't work yet
|
||||
BLUETOOTH = -DXWFEATURE_BLUETOOTH
|
||||
#BLUETOOTH = -DXWFEATURE_BLUETOOTH
|
||||
#MYDEFS_COMMON += $(BLUETOOTH)
|
||||
|
||||
# Add menu allowing to choose to run 68K or ARM
|
||||
|
|
|
@ -170,10 +170,10 @@ END /* XW_MAIN_FORM */
|
|||
#ifdef XWFEATURE_FIVEWAY
|
||||
NAVIGATION ID XW_MAIN_FORM
|
||||
INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState
|
||||
/* INITIALOBJECTID: I don't like this, but without it the OS sets the focus to
|
||||
* one of the buttons below. Need to figure out how to control that -- want
|
||||
* nothing focussed to start, or to save/restore it myself. */
|
||||
/* INITIALOBJECTID XW_SCOREBOARD_GADGET_ID */
|
||||
/* INITIALOBJECTID: the OS arbitrarily sends a focusTake event for some button
|
||||
* on opening the form if this isn't set, otherwise it sends for this. That's
|
||||
* easier to test for and drop, so set it is. */
|
||||
INITIALOBJECTID XW_SCOREBOARD_GADGET_ID
|
||||
NAVIGATIONMAP
|
||||
ROW XW_SCOREBOARD_GADGET_ID
|
||||
ROW XW_BOARD_GADGET_ID
|
||||
|
|
|
@ -160,6 +160,9 @@ static void palm_util_engineStopping( XW_UtilCtxt* uc );
|
|||
#endif
|
||||
|
||||
static void initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame );
|
||||
#ifdef XWFEATURE_FIVEWAY
|
||||
static XP_Bool isBoardObject( XP_U16 id );
|
||||
#endif
|
||||
|
||||
/*-------------------------------- Globals ---------------------------------*/
|
||||
/* NONE!!! */
|
||||
|
@ -1121,6 +1124,7 @@ startApplication( PalmAppGlobals** globalsP )
|
|||
if ( prefsFound ) {
|
||||
prefs.versionNum = XP_NTOHS( prefs.versionNum );
|
||||
prefs.curGameIndex = XP_NTOHS( prefs.curGameIndex );
|
||||
prefs.focusItem = XP_NTOHS( prefs.focusItem );
|
||||
|
||||
MemMove( &globals->gState, &prefs, sizeof(prefs) );
|
||||
}
|
||||
|
@ -1238,6 +1242,7 @@ static void
|
|||
stopApplication( PalmAppGlobals* globals )
|
||||
{
|
||||
if ( globals != NULL ) {
|
||||
Int16 focusItem = getFocusOwner();
|
||||
MPSLOT;
|
||||
|
||||
saveOpenGame( globals );
|
||||
|
@ -1260,6 +1265,8 @@ stopApplication( PalmAppGlobals* globals )
|
|||
prefs.versionNum = XP_HTONS( prefs.versionNum );
|
||||
prefs.curGameIndex = XP_HTONS( prefs.curGameIndex );
|
||||
|
||||
prefs.focusItem = XP_HTONS(focusItem);
|
||||
|
||||
PrefSetAppPreferences( AppType, PrefID, VERSION_NUM,
|
||||
&prefs, sizeof(prefs), true );
|
||||
}
|
||||
|
@ -1762,6 +1769,7 @@ drawBitmapButton( PalmAppGlobals* globals, UInt16 ctrlID, UInt16 resID,
|
|||
static void
|
||||
drawFormButtons( PalmAppGlobals* globals )
|
||||
{
|
||||
Int16 focusItem;
|
||||
XP_U16 pairs[] = {
|
||||
XW_MAIN_FLIP_BUTTON_ID, FLIP_BUTTON_BMP_RES_ID, XP_TRUE,
|
||||
XW_MAIN_VALUE_BUTTON_ID, VALUE_BUTTON_BMP_RES_ID, XP_TRUE,
|
||||
|
@ -1783,8 +1791,19 @@ drawFormButtons( PalmAppGlobals* globals )
|
|||
|
||||
#ifdef XWFEATURE_FIVEWAY
|
||||
if ( globals->hasTreoFiveWay ) {
|
||||
drawFocusRingOnGadget( XW_MAIN_DONE_BUTTON_ID,
|
||||
XW_MAIN_HIDE_BUTTON_ID );
|
||||
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( focusItem, focusItem );
|
||||
}
|
||||
globals->gState.focusItem = -1;
|
||||
} else {
|
||||
drawFocusRingOnGadget( XW_MAIN_DONE_BUTTON_ID,
|
||||
XW_MAIN_HIDE_BUTTON_ID );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} /* drawFormButtons */
|
||||
|
@ -2147,31 +2166,36 @@ handleFocusEvent( PalmAppGlobals* globals, const EventType* event,
|
|||
/* XP_LOGF( "%s(%s,%s)", __FUNCTION__, frmObjId_2str(objectID), */
|
||||
/* (take? "take":"lost") ); */
|
||||
|
||||
/* Need to invalidate the neighborhood of buttons on which palm draws the
|
||||
focus ring when they lose focus -- to redraw where the focus ring may
|
||||
have been. No need unless we have the focus now, however, since we'll
|
||||
otherwise have drawn the object correctly (unfocussed). */
|
||||
if ( take && !globals->initialTakeDropped &&
|
||||
(objectID == XW_SCOREBOARD_GADGET_ID) ) {
|
||||
/* Work around OS's insistence on sending initial take event. */
|
||||
globals->initialTakeDropped = XP_TRUE;
|
||||
} else {
|
||||
/* Need to invalidate the neighborhood of buttons on which palm draws the
|
||||
focus ring when they lose focus -- to redraw where the focus ring may
|
||||
have been. No need unless we have the focus now, however, since we'll
|
||||
otherwise have drawn the object correctly (unfocussed). */
|
||||
|
||||
if ( (!take) && (!isBoardObj) && isBoardObject( getFocusOwner() ) ) {
|
||||
EventType event;
|
||||
event.eType = updateAfterFocusEvent;
|
||||
event.data.generic.datum[0] = objectID;
|
||||
EvtAddEventToQueue( &event );
|
||||
if ( (!take) && (!isBoardObj) && isBoardObject( getFocusOwner() ) ) {
|
||||
EventType event;
|
||||
event.eType = updateAfterFocusEvent;
|
||||
event.data.generic.datum[0] = objectID;
|
||||
EvtAddEventToQueue( &event );
|
||||
}
|
||||
|
||||
/* Board needs to know about any change involving it, including something
|
||||
else taking the focus it may think it has. Why? Because takes
|
||||
preceed losses, yet the board must draw itself without focus before
|
||||
some button draws itself with focus and snags as part of the
|
||||
background the board in focussed state. */
|
||||
|
||||
typ = isBoardObj? OBJ_BOARD + (objectID - XW_BOARD_GADGET_ID) : OBJ_NONE;
|
||||
*drawP = board_focusChanged( globals->game.board, typ, take );
|
||||
if ( isBoardObj && take ) {
|
||||
setFormFocus( globals->mainForm, objectID );
|
||||
}
|
||||
}
|
||||
|
||||
/* Board needs to know about any change involving it, including something
|
||||
else taking the focus it may think it has. Why? Because takes
|
||||
preceed losses, yet the board must draw itself without focus before
|
||||
some button draws itself with focus and snags as part of the
|
||||
background the board in focussed state. */
|
||||
|
||||
typ = isBoardObj? OBJ_BOARD + (objectID - XW_BOARD_GADGET_ID) : OBJ_NONE;
|
||||
*drawP = board_focusChanged( globals->game.board, typ, take );
|
||||
if ( isBoardObj && take ) {
|
||||
FrmSetFocus( globals->mainForm,
|
||||
FrmGetObjectIndex( globals->mainForm, objectID ) );
|
||||
}
|
||||
|
||||
LOG_RETURNF( "%d", (int)isBoardObj );
|
||||
return isBoardObj;
|
||||
} /* handleFocusEvent */
|
||||
#endif
|
||||
|
@ -2403,6 +2427,8 @@ mainViewHandleEvent( EventPtr event )
|
|||
|
||||
globals = getFormRefcon();
|
||||
|
||||
/* XP_LOGF( "%s(%s)", __func__, eType_2str(event->eType) ); */
|
||||
|
||||
switch ( event->eType ) {
|
||||
|
||||
case nilEvent:
|
||||
|
@ -3293,7 +3319,7 @@ askPassword( const XP_UCHAR* name, Boolean isNew, XP_UCHAR* retbuf,
|
|||
FldDrawField( field );
|
||||
}
|
||||
|
||||
FrmSetFocus( form, FrmGetObjectIndex( form, XW_PASSWORD_PASS_FIELD ) );
|
||||
setFormFocus( form, XW_PASSWORD_PASS_FIELD );
|
||||
field = getActiveObjectPtr( XW_PASSWORD_PASS_FIELD );
|
||||
|
||||
if ( FrmDoDialog( form ) == XW_PASSWORD_OK_BUTTON ) {
|
||||
|
|
|
@ -134,7 +134,8 @@ typedef struct XWords4PreferenceType {
|
|||
#endif
|
||||
/* New for 0x0405 */
|
||||
CommonPrefs cp;
|
||||
|
||||
|
||||
Int16 focusItem;
|
||||
} XWords4PreferenceType;
|
||||
|
||||
typedef struct MyIrConnect {
|
||||
|
@ -299,6 +300,7 @@ struct PalmAppGlobals {
|
|||
XP_Bool generatesKeyUp;
|
||||
XP_Bool isZodiac;
|
||||
XP_Bool keyDownReceived;
|
||||
XP_Bool initialTakeDropped; /* work around apparent OS bug */
|
||||
/* PalmOS seems pretty broken w.r.t. key events. If I put up a modal
|
||||
dialog while in the process of handling a keyUp, that form gets a
|
||||
keyDown (and not with the repeat bit set either.) Hack around it. */
|
||||
|
|
|
@ -220,8 +220,7 @@ setFieldToSelText( SavedGamesState* state )
|
|||
|
||||
FldInsert( field, name, XP_STRLEN(name) );
|
||||
FldSetSelection( field, 0, FldGetTextLength(field) );
|
||||
FrmSetFocus( state->form, FrmGetObjectIndex(state->form,
|
||||
XW_SAVEDGAMES_NAME_FIELD) );
|
||||
setFormFocus( state->form, XW_SAVEDGAMES_NAME_FIELD );
|
||||
FldDrawField( field );
|
||||
} /* setFieldToSelText */
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "palmutil.h"
|
||||
#include "xwords4defines.h"
|
||||
#include "palmmain.h"
|
||||
#include "palmdbg.h"
|
||||
#include "comtypes.h"
|
||||
|
||||
#define MEMO "MemoDB"
|
||||
|
@ -404,6 +405,12 @@ getFocusOwner( void )
|
|||
return ownerID;
|
||||
} /* getFocusOwner */
|
||||
|
||||
void
|
||||
setFormFocus( FormPtr form, XP_U16 objectID )
|
||||
{
|
||||
FrmSetFocus( form, FrmGetObjectIndex( form, objectID ) );
|
||||
} /* setFormFocus */
|
||||
|
||||
void
|
||||
drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh )
|
||||
{
|
||||
|
@ -452,7 +459,7 @@ considerGadgetFocus( const EventType* event, XP_U16 idLow, XP_U16 idHigh )
|
|||
if ( handled ) {
|
||||
if ( event->eType == frmObjectFocusTakeEvent ) {
|
||||
FormPtr form = FrmGetActiveForm();
|
||||
FrmSetFocus( form, FrmGetObjectIndex(form, objectID) );
|
||||
setFormFocus( form, objectID );
|
||||
drawFocusRingOnGadget( idLow, idHigh );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ XP_Bool penInGadget( const EventType* event, UInt16* whichGadget );
|
|||
void drawOneGadget( UInt16 id, const char* text, Boolean hilite );
|
||||
# ifdef XWFEATURE_FIVEWAY
|
||||
XP_S16 getFocusOwner( void );
|
||||
void setFormFocus( FormPtr form, XP_U16 objectID );
|
||||
void drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh );
|
||||
XP_Bool considerGadgetFocus( const EventType* event, XP_U16 idLow,
|
||||
XP_U16 idHigh );
|
||||
|
|
|
@ -434,9 +434,9 @@
|
|||
|
||||
/* versioning stuff */
|
||||
#ifdef XWFEATURE_BLUETOOTH
|
||||
# define XW_PALM_VERSION_STRING "4.3a5"
|
||||
# define XW_PALM_VERSION_STRING "4.3a6"
|
||||
#else
|
||||
# define XW_PALM_VERSION_STRING "4.2b5"
|
||||
# define XW_PALM_VERSION_STRING "4.2b6"
|
||||
#endif
|
||||
#define CUR_PREFS_VERS 0x0405
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue