mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +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
|
# MYDEFS_COMMON += -DXWFEATURE_RELAY
|
||||||
|
|
||||||
# turn on bluetooth comms option for 68K and ARM -- which won't work yet
|
# turn on bluetooth comms option for 68K and ARM -- which won't work yet
|
||||||
BLUETOOTH = -DXWFEATURE_BLUETOOTH
|
#BLUETOOTH = -DXWFEATURE_BLUETOOTH
|
||||||
#MYDEFS_COMMON += $(BLUETOOTH)
|
#MYDEFS_COMMON += $(BLUETOOTH)
|
||||||
|
|
||||||
# Add menu allowing to choose to run 68K or ARM
|
# Add menu allowing to choose to run 68K or ARM
|
||||||
|
|
|
@ -170,10 +170,10 @@ END /* XW_MAIN_FORM */
|
||||||
#ifdef XWFEATURE_FIVEWAY
|
#ifdef XWFEATURE_FIVEWAY
|
||||||
NAVIGATION ID XW_MAIN_FORM
|
NAVIGATION ID XW_MAIN_FORM
|
||||||
INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState
|
INITIALSTATE kFrmNavHeaderFlagsObjectFocusStartState
|
||||||
/* INITIALOBJECTID: I don't like this, but without it the OS sets the focus to
|
/* INITIALOBJECTID: the OS arbitrarily sends a focusTake event for some button
|
||||||
* one of the buttons below. Need to figure out how to control that -- want
|
* on opening the form if this isn't set, otherwise it sends for this. That's
|
||||||
* nothing focussed to start, or to save/restore it myself. */
|
* easier to test for and drop, so set it is. */
|
||||||
/* INITIALOBJECTID XW_SCOREBOARD_GADGET_ID */
|
INITIALOBJECTID XW_SCOREBOARD_GADGET_ID
|
||||||
NAVIGATIONMAP
|
NAVIGATIONMAP
|
||||||
ROW XW_SCOREBOARD_GADGET_ID
|
ROW XW_SCOREBOARD_GADGET_ID
|
||||||
ROW XW_BOARD_GADGET_ID
|
ROW XW_BOARD_GADGET_ID
|
||||||
|
|
|
@ -160,6 +160,9 @@ static void palm_util_engineStopping( XW_UtilCtxt* uc );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame );
|
static void initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame );
|
||||||
|
#ifdef XWFEATURE_FIVEWAY
|
||||||
|
static XP_Bool isBoardObject( XP_U16 id );
|
||||||
|
#endif
|
||||||
|
|
||||||
/*-------------------------------- Globals ---------------------------------*/
|
/*-------------------------------- Globals ---------------------------------*/
|
||||||
/* NONE!!! */
|
/* NONE!!! */
|
||||||
|
@ -1121,6 +1124,7 @@ startApplication( PalmAppGlobals** globalsP )
|
||||||
if ( prefsFound ) {
|
if ( prefsFound ) {
|
||||||
prefs.versionNum = XP_NTOHS( prefs.versionNum );
|
prefs.versionNum = XP_NTOHS( prefs.versionNum );
|
||||||
prefs.curGameIndex = XP_NTOHS( prefs.curGameIndex );
|
prefs.curGameIndex = XP_NTOHS( prefs.curGameIndex );
|
||||||
|
prefs.focusItem = XP_NTOHS( prefs.focusItem );
|
||||||
|
|
||||||
MemMove( &globals->gState, &prefs, sizeof(prefs) );
|
MemMove( &globals->gState, &prefs, sizeof(prefs) );
|
||||||
}
|
}
|
||||||
|
@ -1238,6 +1242,7 @@ static void
|
||||||
stopApplication( PalmAppGlobals* globals )
|
stopApplication( PalmAppGlobals* globals )
|
||||||
{
|
{
|
||||||
if ( globals != NULL ) {
|
if ( globals != NULL ) {
|
||||||
|
Int16 focusItem = getFocusOwner();
|
||||||
MPSLOT;
|
MPSLOT;
|
||||||
|
|
||||||
saveOpenGame( globals );
|
saveOpenGame( globals );
|
||||||
|
@ -1260,6 +1265,8 @@ stopApplication( PalmAppGlobals* globals )
|
||||||
prefs.versionNum = XP_HTONS( prefs.versionNum );
|
prefs.versionNum = XP_HTONS( prefs.versionNum );
|
||||||
prefs.curGameIndex = XP_HTONS( prefs.curGameIndex );
|
prefs.curGameIndex = XP_HTONS( prefs.curGameIndex );
|
||||||
|
|
||||||
|
prefs.focusItem = XP_HTONS(focusItem);
|
||||||
|
|
||||||
PrefSetAppPreferences( AppType, PrefID, VERSION_NUM,
|
PrefSetAppPreferences( AppType, PrefID, VERSION_NUM,
|
||||||
&prefs, sizeof(prefs), true );
|
&prefs, sizeof(prefs), true );
|
||||||
}
|
}
|
||||||
|
@ -1762,6 +1769,7 @@ drawBitmapButton( PalmAppGlobals* globals, UInt16 ctrlID, UInt16 resID,
|
||||||
static void
|
static void
|
||||||
drawFormButtons( PalmAppGlobals* globals )
|
drawFormButtons( PalmAppGlobals* globals )
|
||||||
{
|
{
|
||||||
|
Int16 focusItem;
|
||||||
XP_U16 pairs[] = {
|
XP_U16 pairs[] = {
|
||||||
XW_MAIN_FLIP_BUTTON_ID, FLIP_BUTTON_BMP_RES_ID, XP_TRUE,
|
XW_MAIN_FLIP_BUTTON_ID, FLIP_BUTTON_BMP_RES_ID, XP_TRUE,
|
||||||
XW_MAIN_VALUE_BUTTON_ID, VALUE_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
|
#ifdef XWFEATURE_FIVEWAY
|
||||||
if ( globals->hasTreoFiveWay ) {
|
if ( globals->hasTreoFiveWay ) {
|
||||||
drawFocusRingOnGadget( XW_MAIN_DONE_BUTTON_ID,
|
focusItem = globals->gState.focusItem;
|
||||||
XW_MAIN_HIDE_BUTTON_ID );
|
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
|
#endif
|
||||||
} /* drawFormButtons */
|
} /* drawFormButtons */
|
||||||
|
@ -2147,31 +2166,36 @@ handleFocusEvent( PalmAppGlobals* globals, const EventType* event,
|
||||||
/* XP_LOGF( "%s(%s,%s)", __FUNCTION__, frmObjId_2str(objectID), */
|
/* XP_LOGF( "%s(%s,%s)", __FUNCTION__, frmObjId_2str(objectID), */
|
||||||
/* (take? "take":"lost") ); */
|
/* (take? "take":"lost") ); */
|
||||||
|
|
||||||
/* Need to invalidate the neighborhood of buttons on which palm draws the
|
if ( take && !globals->initialTakeDropped &&
|
||||||
focus ring when they lose focus -- to redraw where the focus ring may
|
(objectID == XW_SCOREBOARD_GADGET_ID) ) {
|
||||||
have been. No need unless we have the focus now, however, since we'll
|
/* Work around OS's insistence on sending initial take event. */
|
||||||
otherwise have drawn the object correctly (unfocussed). */
|
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() ) ) {
|
if ( (!take) && (!isBoardObj) && isBoardObject( getFocusOwner() ) ) {
|
||||||
EventType event;
|
EventType event;
|
||||||
event.eType = updateAfterFocusEvent;
|
event.eType = updateAfterFocusEvent;
|
||||||
event.data.generic.datum[0] = objectID;
|
event.data.generic.datum[0] = objectID;
|
||||||
EvtAddEventToQueue( &event );
|
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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
LOG_RETURNF( "%d", (int)isBoardObj );
|
||||||
/* 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 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return isBoardObj;
|
return isBoardObj;
|
||||||
} /* handleFocusEvent */
|
} /* handleFocusEvent */
|
||||||
#endif
|
#endif
|
||||||
|
@ -2403,6 +2427,8 @@ mainViewHandleEvent( EventPtr event )
|
||||||
|
|
||||||
globals = getFormRefcon();
|
globals = getFormRefcon();
|
||||||
|
|
||||||
|
/* XP_LOGF( "%s(%s)", __func__, eType_2str(event->eType) ); */
|
||||||
|
|
||||||
switch ( event->eType ) {
|
switch ( event->eType ) {
|
||||||
|
|
||||||
case nilEvent:
|
case nilEvent:
|
||||||
|
@ -3293,7 +3319,7 @@ askPassword( const XP_UCHAR* name, Boolean isNew, XP_UCHAR* retbuf,
|
||||||
FldDrawField( field );
|
FldDrawField( field );
|
||||||
}
|
}
|
||||||
|
|
||||||
FrmSetFocus( form, FrmGetObjectIndex( form, XW_PASSWORD_PASS_FIELD ) );
|
setFormFocus( form, XW_PASSWORD_PASS_FIELD );
|
||||||
field = getActiveObjectPtr( XW_PASSWORD_PASS_FIELD );
|
field = getActiveObjectPtr( XW_PASSWORD_PASS_FIELD );
|
||||||
|
|
||||||
if ( FrmDoDialog( form ) == XW_PASSWORD_OK_BUTTON ) {
|
if ( FrmDoDialog( form ) == XW_PASSWORD_OK_BUTTON ) {
|
||||||
|
|
|
@ -134,7 +134,8 @@ typedef struct XWords4PreferenceType {
|
||||||
#endif
|
#endif
|
||||||
/* New for 0x0405 */
|
/* New for 0x0405 */
|
||||||
CommonPrefs cp;
|
CommonPrefs cp;
|
||||||
|
|
||||||
|
Int16 focusItem;
|
||||||
} XWords4PreferenceType;
|
} XWords4PreferenceType;
|
||||||
|
|
||||||
typedef struct MyIrConnect {
|
typedef struct MyIrConnect {
|
||||||
|
@ -299,6 +300,7 @@ struct PalmAppGlobals {
|
||||||
XP_Bool generatesKeyUp;
|
XP_Bool generatesKeyUp;
|
||||||
XP_Bool isZodiac;
|
XP_Bool isZodiac;
|
||||||
XP_Bool keyDownReceived;
|
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
|
/* 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
|
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. */
|
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) );
|
FldInsert( field, name, XP_STRLEN(name) );
|
||||||
FldSetSelection( field, 0, FldGetTextLength(field) );
|
FldSetSelection( field, 0, FldGetTextLength(field) );
|
||||||
FrmSetFocus( state->form, FrmGetObjectIndex(state->form,
|
setFormFocus( state->form, XW_SAVEDGAMES_NAME_FIELD );
|
||||||
XW_SAVEDGAMES_NAME_FIELD) );
|
|
||||||
FldDrawField( field );
|
FldDrawField( field );
|
||||||
} /* setFieldToSelText */
|
} /* setFieldToSelText */
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "palmutil.h"
|
#include "palmutil.h"
|
||||||
#include "xwords4defines.h"
|
#include "xwords4defines.h"
|
||||||
#include "palmmain.h"
|
#include "palmmain.h"
|
||||||
|
#include "palmdbg.h"
|
||||||
#include "comtypes.h"
|
#include "comtypes.h"
|
||||||
|
|
||||||
#define MEMO "MemoDB"
|
#define MEMO "MemoDB"
|
||||||
|
@ -404,6 +405,12 @@ getFocusOwner( void )
|
||||||
return ownerID;
|
return ownerID;
|
||||||
} /* getFocusOwner */
|
} /* getFocusOwner */
|
||||||
|
|
||||||
|
void
|
||||||
|
setFormFocus( FormPtr form, XP_U16 objectID )
|
||||||
|
{
|
||||||
|
FrmSetFocus( form, FrmGetObjectIndex( form, objectID ) );
|
||||||
|
} /* setFormFocus */
|
||||||
|
|
||||||
void
|
void
|
||||||
drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh )
|
drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh )
|
||||||
{
|
{
|
||||||
|
@ -452,7 +459,7 @@ considerGadgetFocus( const EventType* event, XP_U16 idLow, XP_U16 idHigh )
|
||||||
if ( handled ) {
|
if ( handled ) {
|
||||||
if ( event->eType == frmObjectFocusTakeEvent ) {
|
if ( event->eType == frmObjectFocusTakeEvent ) {
|
||||||
FormPtr form = FrmGetActiveForm();
|
FormPtr form = FrmGetActiveForm();
|
||||||
FrmSetFocus( form, FrmGetObjectIndex(form, objectID) );
|
setFormFocus( form, objectID );
|
||||||
drawFocusRingOnGadget( idLow, idHigh );
|
drawFocusRingOnGadget( idLow, idHigh );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ XP_Bool penInGadget( const EventType* event, UInt16* whichGadget );
|
||||||
void drawOneGadget( UInt16 id, const char* text, Boolean hilite );
|
void drawOneGadget( UInt16 id, const char* text, Boolean hilite );
|
||||||
# ifdef XWFEATURE_FIVEWAY
|
# ifdef XWFEATURE_FIVEWAY
|
||||||
XP_S16 getFocusOwner( void );
|
XP_S16 getFocusOwner( void );
|
||||||
|
void setFormFocus( FormPtr form, XP_U16 objectID );
|
||||||
void drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh );
|
void drawFocusRingOnGadget( XP_U16 idLow, XP_U16 idHigh );
|
||||||
XP_Bool considerGadgetFocus( const EventType* event, XP_U16 idLow,
|
XP_Bool considerGadgetFocus( const EventType* event, XP_U16 idLow,
|
||||||
XP_U16 idHigh );
|
XP_U16 idHigh );
|
||||||
|
|
|
@ -434,9 +434,9 @@
|
||||||
|
|
||||||
/* versioning stuff */
|
/* versioning stuff */
|
||||||
#ifdef XWFEATURE_BLUETOOTH
|
#ifdef XWFEATURE_BLUETOOTH
|
||||||
# define XW_PALM_VERSION_STRING "4.3a5"
|
# define XW_PALM_VERSION_STRING "4.3a6"
|
||||||
#else
|
#else
|
||||||
# define XW_PALM_VERSION_STRING "4.2b5"
|
# define XW_PALM_VERSION_STRING "4.2b6"
|
||||||
#endif
|
#endif
|
||||||
#define CUR_PREFS_VERS 0x0405
|
#define CUR_PREFS_VERS 0x0405
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue