mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
checkin from personal archive
This commit is contained in:
parent
685de6afc5
commit
d5331d97e4
5 changed files with 936 additions and 0 deletions
372
xwords4/palm/prefsdlg.c
Normal file
372
xwords4/palm/prefsdlg.c
Normal file
|
@ -0,0 +1,372 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 1999 - 2001 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "prefsdlg.h"
|
||||
#include "callback.h"
|
||||
#include "palmutil.h"
|
||||
#include "xwords4defines.h"
|
||||
#include "newgame.h" /* for drawOneGadget */
|
||||
|
||||
void localPrefsToGlobal( PalmAppGlobals* globals );
|
||||
static void localPrefsToControls( PalmAppGlobals* globals,
|
||||
PrefsDlgState* state );
|
||||
static void drawPrefsTypeGadgets( PalmAppGlobals* globals );
|
||||
static void showHidePrefsWidgets( PalmAppGlobals* globals, FormPtr form );
|
||||
static Boolean checkPrefsHiliteGadget( PalmAppGlobals* globals, FormPtr form,
|
||||
EventType* event );
|
||||
static void controlsToLocalPrefs( PalmAppGlobals* globals,
|
||||
PrefsDlgState* state );
|
||||
static Boolean dropCtlUnlessNewGame( PalmAppGlobals* globals, XP_U16 id );
|
||||
|
||||
Boolean
|
||||
PrefsFormHandleEvent( EventPtr event )
|
||||
{
|
||||
Boolean result = false;
|
||||
PalmAppGlobals* globals;
|
||||
PrefsDlgState* state;
|
||||
FormPtr form;
|
||||
EventType eventToPost;
|
||||
Int16 chosen;
|
||||
|
||||
CALLBACK_PROLOGUE();
|
||||
globals = getFormRefcon();
|
||||
state = globals->prefsDlgState;
|
||||
|
||||
switch ( event->eType ) {
|
||||
|
||||
case frmOpenEvent:
|
||||
|
||||
if ( !state ) {
|
||||
GlobalPrefsToLocal( globals );
|
||||
state = globals->prefsDlgState;
|
||||
}
|
||||
|
||||
sizeGadgetsForStrings( FrmGetActiveForm(),
|
||||
getActiveObjectPtr( XW_PREFS_TYPES_LIST_ID ),
|
||||
XW_PREFS_APPWIDE_CHECKBX_ID );
|
||||
|
||||
state->playerBdSizeList =
|
||||
getActiveObjectPtr( XW_PREFS_BDSIZE_LIST_ID );
|
||||
state->phoniesList =
|
||||
getActiveObjectPtr( XW_PREFS_PHONIES_LIST_ID );
|
||||
|
||||
case frmUpdateEvent:
|
||||
form = FrmGetActiveForm();
|
||||
|
||||
localPrefsToControls( globals, state );
|
||||
|
||||
showHidePrefsWidgets( globals, form );
|
||||
|
||||
FrmDrawForm( form );
|
||||
|
||||
drawPrefsTypeGadgets( globals );
|
||||
break;
|
||||
|
||||
case penDownEvent:
|
||||
form = FrmGetActiveForm();
|
||||
result = checkPrefsHiliteGadget( globals, form, event );
|
||||
break;
|
||||
|
||||
case fldEnterEvent:
|
||||
result = dropCtlUnlessNewGame( globals,
|
||||
event->data.fldEnter.fieldID );
|
||||
break;
|
||||
case ctlEnterEvent:
|
||||
result = dropCtlUnlessNewGame( globals,
|
||||
event->data.ctlSelect.controlID );
|
||||
break;
|
||||
|
||||
case ctlSelectEvent:
|
||||
result = true;
|
||||
switch ( event->data.ctlSelect.controlID ) {
|
||||
|
||||
case XW_PREFS_PHONIES_TRIGGER_ID:
|
||||
chosen = LstPopupList( state->phoniesList );
|
||||
if ( chosen >= 0 ) {
|
||||
setSelectorFromList( XW_PREFS_PHONIES_TRIGGER_ID,
|
||||
state->phoniesList, chosen );
|
||||
state->phoniesAction = chosen;
|
||||
}
|
||||
break;
|
||||
|
||||
case XW_PREFS_BDSIZE_SELECTOR_ID:
|
||||
XP_ASSERT( globals->isNewGame ); /* above disables otherwise */
|
||||
chosen = LstPopupList( state->playerBdSizeList );
|
||||
if ( chosen >= 0 ) {
|
||||
setSelectorFromList( XW_PREFS_BDSIZE_SELECTOR_ID,
|
||||
state->playerBdSizeList, chosen );
|
||||
state->curBdSize = PALM_MAX_ROWS - (chosen*2);
|
||||
}
|
||||
break;
|
||||
|
||||
case XW_PREFS_TIMERON_CHECKBOX_ID:
|
||||
XP_ASSERT( globals->isNewGame );
|
||||
form = FrmGetActiveForm();
|
||||
showHidePrefsWidgets( globals, form );
|
||||
break;
|
||||
|
||||
case XW_PREFS_OK_BUTTON_ID:
|
||||
controlsToLocalPrefs( globals, state );
|
||||
eventToPost.eType = prefsChangedEvent;
|
||||
EvtAddEventToQueue( &eventToPost );
|
||||
globals->postponeDraw = true;
|
||||
|
||||
case XW_PREFS_CANCEL_BUTTON_ID:
|
||||
FrmReturnToForm( 0 );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
CALLBACK_EPILOGUE();
|
||||
return result;
|
||||
} /* prefsFormHandleEvent */
|
||||
|
||||
static Boolean
|
||||
dropCtlUnlessNewGame( PalmAppGlobals* globals, XP_U16 id )
|
||||
{
|
||||
Boolean result = false;
|
||||
|
||||
switch ( id ) {
|
||||
|
||||
case XW_PREFS_NOHINTS_CHECKBOX_ID:
|
||||
case XW_PREFS_BDSIZE_SELECTOR_ID:
|
||||
case XW_PREFS_TIMERON_CHECKBOX_ID:
|
||||
case XW_PREFS_TIMER_FIELD_ID:
|
||||
if ( globals->isNewGame ) {
|
||||
break;
|
||||
}
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( result ) {
|
||||
beep();
|
||||
}
|
||||
|
||||
return result;
|
||||
} /* dropCtlUnlessNewGame */
|
||||
|
||||
void
|
||||
GlobalPrefsToLocal( PalmAppGlobals* globals )
|
||||
{
|
||||
PrefsDlgState* state = globals->prefsDlgState;
|
||||
|
||||
if ( !state ) {
|
||||
state = globals->prefsDlgState = XP_MALLOC( globals->mpool,
|
||||
sizeof(*state) );
|
||||
}
|
||||
|
||||
state->curBdSize = !!globals->game.model?
|
||||
model_numRows( globals->game.model ) : PALM_MAX_ROWS;
|
||||
|
||||
state->showColors = globals->gState.showColors;
|
||||
state->smartRobot = globals->util.gameInfo->robotSmartness == SMART_ROBOT;
|
||||
state->showGrid = globals->gState.showGrid;
|
||||
state->showProgress = globals->gState.showProgress;
|
||||
XP_MEMCPY( &state->cp, &globals->gState.cp, sizeof(state->cp) );
|
||||
XP_ASSERT( !!globals->game.server );
|
||||
|
||||
state->phoniesAction = globals->util.gameInfo->phoniesAction;
|
||||
state->hintsNotAllowed = globals->gameInfo.hintsNotAllowed;
|
||||
state->timerEnabled = globals->util.gameInfo->timerEnabled;
|
||||
state->gameSeconds = globals->util.gameInfo->gameSeconds;
|
||||
|
||||
state->stateTypeIsGlobal = globals->stateTypeIsGlobal;
|
||||
} /* GlobalPrefsToLocal */
|
||||
|
||||
XP_Bool
|
||||
LocalPrefsToGlobal( PalmAppGlobals* globals )
|
||||
{
|
||||
PrefsDlgState* state = globals->prefsDlgState;
|
||||
XP_Bool erase = XP_FALSE;
|
||||
|
||||
/* curBdSize handled elsewhere */
|
||||
|
||||
globals->gState.showColors = state->showColors;
|
||||
|
||||
globals->util.gameInfo->robotSmartness =
|
||||
state->smartRobot? SMART_ROBOT:DUMB_ROBOT;
|
||||
|
||||
erase = globals->gState.showGrid != state->showGrid;
|
||||
globals->gState.showGrid = state->showGrid;
|
||||
|
||||
XP_MEMCPY( &globals->gState.cp, &state->cp, sizeof(globals->gState.cp) );
|
||||
|
||||
globals->gState.showProgress = state->showProgress;
|
||||
|
||||
globals->util.gameInfo->phoniesAction = state->phoniesAction;
|
||||
|
||||
globals->gameInfo.hintsNotAllowed = state->hintsNotAllowed;
|
||||
|
||||
globals->util.gameInfo->timerEnabled = state->timerEnabled;
|
||||
globals->util.gameInfo->gameSeconds = state->gameSeconds;
|
||||
return erase;
|
||||
} /* LocalPrefsToGlobal */
|
||||
|
||||
static void
|
||||
numToField( UInt16 id, XP_S16 num )
|
||||
{
|
||||
FieldPtr field;
|
||||
char buf[16];
|
||||
|
||||
StrIToA( buf, num );
|
||||
field = getActiveObjectPtr( id );
|
||||
FldInsert( field, buf, StrLen(buf) );
|
||||
} /* numToField */
|
||||
|
||||
static void
|
||||
localPrefsToControls( PalmAppGlobals* globals, PrefsDlgState* state )
|
||||
{
|
||||
setSelectorFromList( XW_PREFS_BDSIZE_SELECTOR_ID,
|
||||
state->playerBdSizeList,
|
||||
(PALM_MAX_ROWS - state->curBdSize) / 2 );
|
||||
|
||||
setSelectorFromList( XW_PREFS_PHONIES_TRIGGER_ID, state->phoniesList,
|
||||
state->phoniesAction );
|
||||
|
||||
setBooleanCtrl( XW_PREFS_PLAYERCOLORS_CHECKBOX_ID, state->showColors );
|
||||
setBooleanCtrl( XW_PREFS_PROGRESSBAR_CHECKBOX_ID, state->showProgress );
|
||||
setBooleanCtrl( XW_PREFS_NOHINTS_CHECKBOX_ID, state->hintsNotAllowed );
|
||||
setBooleanCtrl( XW_PREFS_ROBOTSMART_CHECKBOX_ID, state->smartRobot );
|
||||
setBooleanCtrl( XW_PREFS_SHOWGRID_CHECKBOX_ID, state->showGrid );
|
||||
setBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID, state->cp.showBoardArrow );
|
||||
setBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID,
|
||||
state->cp.showRobotScores );
|
||||
setBooleanCtrl( XW_PREFS_TIMERON_CHECKBOX_ID, state->timerEnabled );
|
||||
|
||||
numToField( XW_PREFS_TIMER_FIELD_ID, state->gameSeconds/60 );
|
||||
} /* localPrefsToControls */
|
||||
|
||||
static XP_S16
|
||||
fieldToNum( UInt16 id )
|
||||
{
|
||||
FieldPtr field;
|
||||
char* txt;
|
||||
|
||||
field = getActiveObjectPtr( id );
|
||||
txt = FldGetTextPtr( field );
|
||||
return StrAToI( txt );
|
||||
} /* fieldToNum */
|
||||
|
||||
static void
|
||||
controlsToLocalPrefs( PalmAppGlobals* globals, PrefsDlgState* state )
|
||||
{
|
||||
state->showColors = getBooleanCtrl( XW_PREFS_PLAYERCOLORS_CHECKBOX_ID );
|
||||
state->smartRobot = getBooleanCtrl( XW_PREFS_ROBOTSMART_CHECKBOX_ID );
|
||||
state->showGrid = getBooleanCtrl( XW_PREFS_SHOWGRID_CHECKBOX_ID );
|
||||
state->cp.showBoardArrow =
|
||||
getBooleanCtrl( XW_PREFS_SHOWARROW_CHECKBOX_ID );
|
||||
state->cp.showRobotScores =
|
||||
getBooleanCtrl( XW_PREFS_ROBOTSCORE_CHECKBOX_ID );
|
||||
state->showProgress = getBooleanCtrl( XW_PREFS_PROGRESSBAR_CHECKBOX_ID );
|
||||
|
||||
/* trapping ctlEnterEvent should mean it can't have changed, so no need
|
||||
to test before grabbing the value. */
|
||||
XP_ASSERT( globals->isNewGame ||
|
||||
(state->hintsNotAllowed ==
|
||||
getBooleanCtrl( XW_PREFS_NOHINTS_CHECKBOX_ID) ) );
|
||||
state->hintsNotAllowed = getBooleanCtrl( XW_PREFS_NOHINTS_CHECKBOX_ID );
|
||||
|
||||
state->timerEnabled = getBooleanCtrl( XW_PREFS_TIMERON_CHECKBOX_ID );
|
||||
state->gameSeconds = fieldToNum( XW_PREFS_TIMER_FIELD_ID ) * 60;
|
||||
} /* controlsToLocalPrefs */
|
||||
|
||||
static void
|
||||
drawPrefsTypeGadgets( PalmAppGlobals* globals )
|
||||
{
|
||||
UInt16 i;
|
||||
ListPtr list = getActiveObjectPtr( XW_PREFS_TYPES_LIST_ID );
|
||||
UInt16 active = globals->prefsDlgState->stateTypeIsGlobal? 0:1;
|
||||
|
||||
XP_ASSERT( !!list );
|
||||
|
||||
for ( i = 0; i < 2; ++i ) {
|
||||
char* text = LstGetSelectionText( list, i );
|
||||
drawOneGadget( i + XW_PREFS_APPWIDE_CHECKBX_ID, text, i==active );
|
||||
}
|
||||
} /* drawPrefsTypeGadgets */
|
||||
|
||||
static void
|
||||
doOneSet( FormPtr form, XP_U16 first, XP_U16 last, XP_Bool enable )
|
||||
{
|
||||
while ( first <= last ) {
|
||||
disOrEnable( form, first, enable );
|
||||
++first;
|
||||
}
|
||||
} /* doOneSet */
|
||||
|
||||
/* Which set of controls is supposed to be visible changes depending on which
|
||||
* gadget is selected.
|
||||
*/
|
||||
static void
|
||||
showHidePrefsWidgets( PalmAppGlobals* globals, FormPtr form )
|
||||
{
|
||||
XP_Bool global = globals->prefsDlgState->stateTypeIsGlobal;
|
||||
|
||||
XP_U16 firstToEnable, lastToEnable, firstToDisable, lastToDisable;
|
||||
|
||||
/* Need to do the disabling first */
|
||||
if ( global ) {
|
||||
firstToEnable = XW_PREFS_FIRST_GLOBAL_ID;
|
||||
lastToEnable = XW_PREFS_LAST_GLOBAL_ID;
|
||||
firstToDisable = XW_PREFS_FIRST_PERGAME_ID;
|
||||
lastToDisable = XW_PREFS_LAST_PERGAME_ID;
|
||||
} else {
|
||||
firstToDisable = XW_PREFS_FIRST_GLOBAL_ID;
|
||||
lastToDisable = XW_PREFS_LAST_GLOBAL_ID;
|
||||
firstToEnable = XW_PREFS_FIRST_PERGAME_ID;
|
||||
lastToEnable = XW_PREFS_LAST_PERGAME_ID;
|
||||
}
|
||||
|
||||
doOneSet( form, firstToDisable, lastToDisable, XP_FALSE );
|
||||
doOneSet( form, firstToEnable, lastToEnable, XP_TRUE );
|
||||
|
||||
if ( !global ) {
|
||||
Boolean on = getBooleanCtrl( XW_PREFS_TIMERON_CHECKBOX_ID );
|
||||
disOrEnable( form, XW_PREFS_TIMER_FIELD_ID, on );
|
||||
}
|
||||
} /* showHidePrefsWidgets */
|
||||
|
||||
static Boolean
|
||||
checkPrefsHiliteGadget( PalmAppGlobals* globals, FormPtr form,
|
||||
EventType* event )
|
||||
{
|
||||
Boolean result = false;
|
||||
UInt16 selGadget;
|
||||
|
||||
result = penInGadget( event, &selGadget );
|
||||
if ( result ) {
|
||||
XP_Bool globalChosen = selGadget == XW_PREFS_APPWIDE_CHECKBX_ID;
|
||||
|
||||
result = globalChosen != globals->prefsDlgState->stateTypeIsGlobal;
|
||||
|
||||
if ( result ) {
|
||||
globals->prefsDlgState->stateTypeIsGlobal = globalChosen;
|
||||
|
||||
showHidePrefsWidgets( globals, form );
|
||||
drawPrefsTypeGadgets( globals );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
} /* checkPrefsHiliteGadget */
|
43
xwords4/palm/prefsdlg.h
Normal file
43
xwords4/palm/prefsdlg.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2001 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _PREFSDLG_H_
|
||||
#define _PREFSDLG_H_
|
||||
|
||||
#include <Event.h>
|
||||
|
||||
#include "palmmain.h"
|
||||
|
||||
/* How prefs work.
|
||||
*
|
||||
* Prefs can be called either directly from the main form or from the new
|
||||
* game form. If it's called directly, it creates and initializes a
|
||||
* PrefsDlgState instance. If it's called indirectly, the caller does that
|
||||
* for it (or in the newGame case may do it anyway so it has defaults to use
|
||||
* if it's never called). If the user cancels the direct call, any changes
|
||||
* are ignored. If the user cancels when called from the newGame form we'll
|
||||
* re-init the structure.
|
||||
*/
|
||||
|
||||
/* both newgame and prefs need to know about this */
|
||||
Boolean PrefsFormHandleEvent( EventPtr event );
|
||||
void GlobalPrefsToLocal( PalmAppGlobals* globals );
|
||||
XP_Bool LocalPrefsToGlobal( PalmAppGlobals* globals );
|
||||
|
||||
#endif
|
115
xwords4/palm/xptypes.h
Normal file
115
xwords4/palm/xptypes.h
Normal file
|
@ -0,0 +1,115 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 1999-2000 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _XPTYPES_H_
|
||||
#define _XPTYPES_H_
|
||||
|
||||
|
||||
#include <PalmTypes.h>
|
||||
#include <MemoryMgr.h>
|
||||
#include <StringMgr.h>
|
||||
#include <SysUtils.h>
|
||||
|
||||
#define XP_TRUE ((XP_Bool)(1==1))
|
||||
#define XP_FALSE ((XP_Bool)(1==0))
|
||||
|
||||
typedef unsigned char XP_U8;
|
||||
typedef signed char XP_S8;
|
||||
typedef unsigned char XP_UCHAR;
|
||||
|
||||
typedef UInt16 XP_U16;
|
||||
typedef Int16 XP_S16;
|
||||
|
||||
typedef unsigned long XP_U32;
|
||||
typedef signed long XP_S32;
|
||||
|
||||
typedef signed short XP_FontCode; /* not sure how I'm using this yet */
|
||||
typedef Boolean XP_Bool;
|
||||
typedef XP_U32 XP_Time;
|
||||
|
||||
void palm_debugf(char*, ...);
|
||||
void p_ignore(char*, ...);
|
||||
void palm_assert(Boolean b, int line, char* fileName );
|
||||
void palm_warnf( char* format, ... );
|
||||
void palm_logf( char* format, ... );
|
||||
XP_U16 palm_snprintf( XP_UCHAR* buf, XP_U16 len, XP_UCHAR* format, ... );
|
||||
XP_S16 palm_memcmp( XP_U8* p1, XP_U8* p2, XP_U16 nBytes );
|
||||
XP_U8* palm_realloc(XP_U8* in, XP_U16 size);
|
||||
|
||||
#define XP_CR "\n"
|
||||
|
||||
#define XP_RANDOM() SysRandom(0)
|
||||
|
||||
#ifdef MEM_DEBUG
|
||||
# define XP_PLATMALLOC(nbytes) MemPtrNew(nbytes)
|
||||
# define XP_PLATREALLOC(p,s) palm_realloc((p),(s))
|
||||
# define XP_PLATFREE(p) MemPtrFree(p)
|
||||
#else
|
||||
# define XP_MALLOC(p,nbytes) MemPtrNew(nbytes)
|
||||
# define XP_REALLOC(p,ptr,nbytes) palm_realloc((ptr),(nbytes))
|
||||
# define XP_FREE(pool,p) MemPtrFree(p)
|
||||
#endif
|
||||
|
||||
|
||||
#define XP_MEMSET(src, val, nbytes) MemSet( (src), (nbytes), (val) )
|
||||
#define XP_MEMCPY(d,s,l) MemMove((d),(s),(l))
|
||||
#define XP_MEMCMP( a1, a2, l ) palm_memcmp((XP_U8*)(a1),(XP_U8*)(a2),(l))
|
||||
/* MemCmp is reputed not to work on some versions of PalmOS */
|
||||
/* #define XP_MEMCMP( a1, a2, l ) MemCmp((a1),(a2),(l)) */
|
||||
#define XP_STRLEN(s) StrLen((const char*)s)
|
||||
#define XP_STRNCMP(s1,s2,l) StrNCompare((const char*)(s1), \
|
||||
(const char*)(s2),(l))
|
||||
#define XP_STRCMP(s1,s2) StrCompare((s1),(s2))
|
||||
#define XP_SNPRINTF palm_snprintf
|
||||
|
||||
#define XP_MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#define XP_MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#define XP_ABS(a) ((a)>=0?(a):-(a))
|
||||
|
||||
#ifdef DEBUG
|
||||
#define XP_ASSERT(b) palm_assert(b, __LINE__, __FILE__)
|
||||
#else
|
||||
#define XP_ASSERT(b)
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
# define XP_DEBUGF palm_debugf
|
||||
#else
|
||||
# define XP_DEBUGF if(0)p_ignore
|
||||
#endif
|
||||
|
||||
//#define XP_STATUSF if(0)p_ignore
|
||||
#define XP_STATUSF XP_LOGF /* for now */
|
||||
|
||||
#ifdef DEBUG
|
||||
#define XP_LOGF palm_logf
|
||||
#define XP_WARNF palm_warnf
|
||||
#else
|
||||
#define XP_WARNF if(0)p_ignore
|
||||
#define XP_LOGF if(0)p_ignore
|
||||
#endif
|
||||
|
||||
/* Assumes big-endian, of course */
|
||||
#define XP_NTOHL(l) (l)
|
||||
#define XP_NTOHS(s) (s)
|
||||
#define XP_HTONL(l) (l)
|
||||
#define XP_HTONS(s) (s)
|
||||
|
||||
#endif
|
||||
|
49
xwords4/palm/xwcolors.h
Normal file
49
xwords4/palm/xwcolors.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2000-2001 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _XWCOLORS_H_
|
||||
#define _XWCOLORS_H_
|
||||
|
||||
#include <Window.h>
|
||||
|
||||
enum {
|
||||
COLOR_BLACK,
|
||||
COLOR_WHITE,
|
||||
|
||||
COLOR_PLAYER1,
|
||||
COLOR_PLAYER2,
|
||||
COLOR_PLAYER3,
|
||||
COLOR_PLAYER4,
|
||||
|
||||
COLOR_DBL_LTTR,
|
||||
COLOR_DBL_WORD,
|
||||
COLOR_TRPL_LTTR,
|
||||
COLOR_TRPL_WORD,
|
||||
|
||||
COLOR_EMPTY,
|
||||
COLOR_TILE,
|
||||
|
||||
COLOR_NCOLORS /* 12 */
|
||||
};
|
||||
|
||||
typedef struct DrawingPrefs {
|
||||
IndexedColorType drawColors[COLOR_NCOLORS];
|
||||
} DrawingPrefs;
|
||||
|
||||
#endif
|
357
xwords4/palm/xwords4defines.h
Normal file
357
xwords4/palm/xwords4defines.h
Normal file
|
@ -0,0 +1,357 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 1999 - 2003 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _XWORDS4DEFINES_H_
|
||||
#define _XWORDS4DEFINES_H_
|
||||
|
||||
|
||||
|
||||
#define RECOMMENDED_SBAR_WIDTH 7
|
||||
#define SBAR_MIN 13
|
||||
#define SBAR_MAX 15
|
||||
#define SBAR_PAGESIZE 13
|
||||
#define SBAR_START_VALUE SBAR_MIN
|
||||
|
||||
#define TRAY_HEIGHT 21
|
||||
#define TRAY_BUTTON_HEIGHT 10
|
||||
#define TRAY_BUTTON_WIDTH 9
|
||||
|
||||
#define FLIP_BUTTON_WIDTH 8
|
||||
#define FLIP_BUTTON_HEIGHT FLIP_BUTTON_WIDTH
|
||||
#define BOARD_TOP 8
|
||||
|
||||
#define IR_STATUS_HEIGHT 12
|
||||
|
||||
#define PALM_FLIP_LEFT 160-FLIP_BUTTON_WIDTH
|
||||
#define PALM_TRAY_BUTTON_LEFT 142
|
||||
|
||||
#define XW_MAIN_FORM 1000
|
||||
#define XW_NEWGAMES_FORM 1001
|
||||
#define XW_ERROR_ALERT_ID 1002
|
||||
#define XW_DICTINFO_FORM 1003
|
||||
#define XW_ASK_FORM_ID 1004
|
||||
#define XW_PASSWORD_DIALOG_ID 1005
|
||||
#define XW_BLANK_DIALOG_ID 1006
|
||||
#define XW_COLORPREF_DIALOG_ID 1007
|
||||
#define XW_PREFS_FORM 1008
|
||||
#define XW_SAVEDGAMES_DIALOG_ID 1009
|
||||
#define XW_CONNS_FORM 1010
|
||||
#ifdef FOR_GREMLINS
|
||||
# define XW_GREMLIN_WARN_FORM_ID 1011
|
||||
#endif
|
||||
|
||||
#define XW_ASK_MENU_ID 1001
|
||||
#define ASK_COPY_PULLDOWN_ID 1000
|
||||
#define ASK_SELECTALL_PULLDOWN_ID 1001
|
||||
|
||||
#define XW_MAIN_MENU_ID 1000
|
||||
#define XW_MAIN_FLIP_BUTTON_ID 1016
|
||||
#define XW_MAIN_VALUE_BUTTON_ID 1017
|
||||
#define XW_MAIN_TRAY_BUTTON_ID 1018
|
||||
#define XW_MAIN_SCROLLBAR_ID 1019
|
||||
#ifndef EIGHT_TILES
|
||||
#define XW_MAIN_DONE_BUTTON_ID 1020
|
||||
#define XW_MAIN_JUGGLE_BUTTON_ID 1021
|
||||
#define XW_MAIN_TRADE_BUTTON_ID 1022
|
||||
#define XW_MAIN_HIDE_BUTTON_ID 1023
|
||||
#endif
|
||||
#define XW_MAIN_HINT_BUTTON_ID 1024
|
||||
#define XW_MAIN_SHOWTRAY_BUTTON_ID 1025
|
||||
//#define XW_MAIN_OK_BUTTON_ID 1026
|
||||
|
||||
#ifdef FOR_GREMLINS
|
||||
# define GREMLIN_BOARD_GADGET_IDAUTOID 1026
|
||||
# define GREMLIN_TRAY_GADGET_IDAUTOID 1027
|
||||
#endif
|
||||
|
||||
/* File menu */
|
||||
#define XW_NEWGAME_PULLDOWN_ID 1050
|
||||
#define XW_SAVEDGAMES_PULLDOWN_ID 1051
|
||||
#define XW_BEAMDICT_PULLDOWN_ID 1052
|
||||
#define XW_BEAMBOARD_PULLDOWN_ID 1053
|
||||
#define XW_PREFS_PULLDOWN_ID 1054
|
||||
#define XW_ABOUT_PULLDOWN_ID 1055
|
||||
|
||||
/* Game menu */
|
||||
#define XW_TILEVALUES_PULLDOWN_ID 1056
|
||||
#define XW_PASSWORDS_PULLDOWN_ID 1057
|
||||
#define XW_HISTORY_PULLDOWN_ID 1058
|
||||
#define XW_FINISH_PULLDOWN_ID 1059
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
# define XW_RESENDIR_PULLDOWN_ID 1060
|
||||
#endif
|
||||
|
||||
/* Move menu */
|
||||
#define XW_HINT_PULLDOWN_ID 1061
|
||||
#define XW_NEXTHINT_PULLDOWN_ID 1062
|
||||
#define XW_UNDOCUR_PULLDOWN_ID 1063
|
||||
#define XW_UNDOLAST_PULLDOWN_ID 1064
|
||||
#define XW_DONE_PULLDOWN_ID 1065
|
||||
#define XW_JUGGLE_PULLDOWN_ID 1066
|
||||
#define XW_TRADEIN_PULLDOWN_ID 1067
|
||||
#define XW_HIDETRAY_PULLDOWN_ID 1068
|
||||
|
||||
/* debug menu */
|
||||
#ifdef DEBUG
|
||||
# define XW_DEBUGSHOW_PULLDOWN_ID 2001
|
||||
# define XW_DEBUGHIDE_PULLDOWN_ID 2002
|
||||
# define XW_NETSTATS_PULLDOWN_ID 2003
|
||||
# define XW_MEMSTATS_PULLDOWN_ID 2004
|
||||
# define XW_DEBUGMEMO_PULLDOWN_ID 2005
|
||||
# define XW_DEBUGSCREEN_PULLDOWN_ID 2006
|
||||
#endif
|
||||
|
||||
#ifdef FOR_GREMLINS
|
||||
#define XW_GREMLIN_DIVIDER_RIGHT 2010
|
||||
#define XW_GREMLIN_DIVIDER_LEFT 2011
|
||||
#endif
|
||||
|
||||
#define XW_DICT_SELECTOR_ID 1038
|
||||
#define XW_OK_BUTTON_ID 1039
|
||||
#define XW_CANCEL_BUTTON_ID 1040
|
||||
/* #define XW_DICT_BUTTON_ID 1040 */
|
||||
|
||||
#define MAX_GAMENAME_LENGTH 32
|
||||
#define MAX_PLAYERNAME_LENGTH 32
|
||||
|
||||
#define NUM_PLAYER_COLS 4 /* name, local, robot and passwd */
|
||||
#define PALM_MAX_ROWS 15 /* max is a 15x15 grid on palm */
|
||||
#define PALM_MAX_COLS 15 /* max is a 15x15 grid on palm */
|
||||
|
||||
#define NUM_BOARD_SIZES 3 /* 15x15, 13x13 and 11x11 */
|
||||
|
||||
#define XW_PLAYERNAME_1_FIELD_ID 2100
|
||||
#define XW_ROBOT_1_CHECKBOX_ID 2101
|
||||
#define XW_REMOTE_1_CHECKBOX_ID 2102
|
||||
#define XW_PLAYERPASSWD_1_TRIGGER_ID 2103
|
||||
|
||||
#define XW_PLAYERNAME_2_FIELD_ID 2104
|
||||
#define XW_ROBOT_2_CHECKBOX_ID 2105
|
||||
#define XW_REMOTE_2_CHECKBOX_ID 2106
|
||||
#define XW_PLAYERPASSWD_2_TRIGGER_ID 2107
|
||||
|
||||
#define XW_PLAYERNAME_3_FIELD_ID 2108
|
||||
#define XW_ROBOT_3_CHECKBOX_ID 2109
|
||||
#define XW_REMOTE_3_CHECKBOX_ID 2110
|
||||
#define XW_PLAYERPASSWD_3_TRIGGER_ID 2111
|
||||
|
||||
#define XW_PLAYERNAME_4_FIELD_ID 2112
|
||||
#define XW_ROBOT_4_CHECKBOX_ID 2113
|
||||
#define XW_REMOTE_4_CHECKBOX_ID 2114
|
||||
#define XW_PLAYERPASSWD_4_TRIGGER_ID 2115
|
||||
|
||||
#define XW_NPLAYERS_LIST_ID 2121
|
||||
#define XW_NPLAYERS_SELECTOR_ID 2122
|
||||
#define XW_PREFS_BUTTON_ID 2123
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
#define XW_SOLO_GADGET_ID 2125
|
||||
#define XW_SERVER_GADGET_ID 2126
|
||||
#define XW_CLIENT_GADGET_ID 2127
|
||||
#define XW_SERVERTYPES_LIST_ID 2128
|
||||
#endif
|
||||
|
||||
#ifdef FOR_GREMLINS
|
||||
# define XW_GREMLIN_WARN_FIELD_ID 2129
|
||||
#endif
|
||||
|
||||
|
||||
/* we need to hide these labels, so no AUTOID */
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
# define XW_LOCAL_LABEL_ID 2130
|
||||
# define XW_TOTALP_LABEL_ID 2131
|
||||
# define XW_LOCALP_LABEL_ID 2132
|
||||
#endif
|
||||
|
||||
#define REFCON_GADGET_ID 3000
|
||||
|
||||
#define XW_ASK_TXT_FIELD_ID 2200
|
||||
#define XW_ASK_OK_BUTTON_ID 2201
|
||||
#define XW_ASK_CANCEL_BUTTON_ID 2202
|
||||
#define XW_ASK_SCROLLBAR_ID 2203
|
||||
|
||||
#define MAX_PASSWORD_LENGTH 4 /* server.c has no limit */
|
||||
#define XW_PASSWORD_CANCEL_BUTTON 2300
|
||||
#define XW_PASSWORD_NAME_LABEL 2301
|
||||
#define XW_PASSWORD_NEWNAME_LABEL 2302
|
||||
#define XW_PASSWORD_NAME_FIELD 2303
|
||||
#define XW_PASSWORD_PASS_FIELD 2304
|
||||
#define XW_PASSWORD_OK_BUTTON 2305
|
||||
|
||||
#define XW_BLANK_LIST_ID 2401
|
||||
#define XW_BLANK_LABEL_FIELD_ID 2402
|
||||
#define XW_BLANK_OK_BUTTON_ID 2403
|
||||
#define XW_BLANK_PICK_BUTTON_ID 2404
|
||||
|
||||
#define XW_COLORS_FACTORY_BUTTON_ID 2520
|
||||
#define XW_COLORS_OK_BUTTON_ID 2521
|
||||
#define XW_COLORS_CANCEL_BUTTON_ID 2522
|
||||
|
||||
#define STRL_RES_TYPE 'StrL'
|
||||
#define XW_STRL_RESOURCE_ID 1000
|
||||
|
||||
#define BOARD_RES_TYPE 'Xbrd'
|
||||
#define BOARD_RES_ID 1000
|
||||
|
||||
#define COLORS_RES_TYPE 'Clrs'
|
||||
#define COLORS_RES_ID 1000
|
||||
|
||||
#define CARD_0 0
|
||||
#define XW_GAMES_DBNAME "xw4games"
|
||||
#define XWORDS_GAMES_TYPE 'Xwgm'
|
||||
#define XW_PREFS_DBNAME "xw4prefs"
|
||||
#define XWORDS_PREFS_TYPE 'Xwpr'
|
||||
|
||||
#define XW_DICTINFO_LIST_ID 2601
|
||||
#define XW_DICTINFO_TRIGGER_ID 2602
|
||||
#define XW_PHONIES_TRIGGER_ID 2603
|
||||
#define XW_PHONIES_LABLE_ID 2604
|
||||
#define XW_PHONIES_LIST_ID 2605
|
||||
#define XW_DICTINFO_DONE_BUTTON_ID 2606
|
||||
#define XW_DICTINFO_BEAM_BUTTON_ID 2607
|
||||
#define XW_DICTINFO_CANCEL_BUTTON_ID 2608
|
||||
|
||||
/*
|
||||
* prefs dialog
|
||||
*/
|
||||
#define XW_PREFS_APPWIDE_CHECKBX_ID 2700
|
||||
#define XW_PREFS_ONEGAME_CHECKBX_ID 2701
|
||||
#define XW_PREFS_TYPES_LIST_ID 2702
|
||||
|
||||
/* global */
|
||||
#define XW_PREFS_PLAYERCOLORS_CHECKBOX_ID 2708
|
||||
#define XW_PREFS_PROGRESSBAR_CHECKBOX_ID 2709
|
||||
#define XW_PREFS_SHOWGRID_CHECKBOX_ID 2710
|
||||
#define XW_PREFS_SHOWARROW_CHECKBOX_ID 2711
|
||||
#define XW_PREFS_ROBOTSCORE_CHECKBOX_ID 2712
|
||||
|
||||
/* per-game */
|
||||
#define XW_PREFS_ROBOTSMART_CHECKBOX_ID 2715
|
||||
#define XW_PREFS_PHONIES_LABEL_ID 2716
|
||||
#define XW_PREFS_PHONIES_TRIGGER_ID 2717
|
||||
#define XW_PREFS_BDSIZE_LABEL_ID 2718
|
||||
#define XW_PREFS_BDSIZE_SELECTOR_ID 2719
|
||||
#define XW_PREFS_NOHINTS_CHECKBOX_ID 2720
|
||||
#define XW_PREFS_TIMERON_CHECKBOX_ID 2721
|
||||
#define XW_PREFS_TIMER_FIELD_ID 2722
|
||||
|
||||
/* These aren't part of the hide/show thing as they're displayed only
|
||||
* explicitly byother controls */
|
||||
#define XW_PREFS_PHONIES_LIST_ID 2750
|
||||
#define XW_PREFS_BDSIZE_LIST_ID 2751
|
||||
|
||||
/* These are used to set/clear the "pages" of the prefs dialog. */
|
||||
#define XW_PREFS_FIRST_GLOBAL_ID XW_PREFS_PLAYERCOLORS_CHECKBOX_ID
|
||||
#define XW_PREFS_LAST_GLOBAL_ID XW_PREFS_ROBOTSCORE_CHECKBOX_ID
|
||||
#define XW_PREFS_FIRST_PERGAME_ID XW_PREFS_ROBOTSMART_CHECKBOX_ID
|
||||
#define XW_PREFS_LAST_PERGAME_ID XW_PREFS_TIMER_FIELD_ID
|
||||
|
||||
#define XW_PREFS_CANCEL_BUTTON_ID 2725
|
||||
#define XW_PREFS_OK_BUTTON_ID 2726
|
||||
|
||||
/*
|
||||
* saved games dialog
|
||||
*/
|
||||
#define XW_SAVEDGAMES_LIST_ID 2800
|
||||
#define XW_SAVEDGAMES_NAME_FIELD 2801
|
||||
#define XW_SAVEDGAMES_USE_BUTTON 2802
|
||||
#define XW_SAVEDGAMES_DUPE_BUTTON 2803
|
||||
#define XW_SAVEDGAMES_DELETE_BUTTON 2804
|
||||
#define XW_SAVEDGAMES_OPEN_BUTTON 2805
|
||||
#define XW_SAVEDGAMES_DONE_BUTTON 2806
|
||||
#define MAX_GAME_NAME_LENGTH 31
|
||||
|
||||
/*
|
||||
* Connections dlg (XW_CONNS_FORM)
|
||||
*/
|
||||
#define XW_CONNS_CANCEL_BUTTON_ID 2900
|
||||
#define XW_CONNS_OK_BUTTON_ID 2901
|
||||
#define XW_CONNS_TYPE_TRIGGER_ID 2902
|
||||
#define XW_CONNS_TYPE_LIST_ID 2903
|
||||
#define XW_CONNS_TARGET_LABEL_ID 2904
|
||||
#define XW_CONNS_TARGET_FIELD_ID 2905
|
||||
#define XW_CONNS_TPORT_LABEL_ID 2906
|
||||
#define XW_CONNS_TPORT_FIELD_ID 2907
|
||||
#define XW_CONNS_MYPORT_LABEL_ID 2908
|
||||
#define XW_CONNS_MYPORT_FIELD_ID 2909
|
||||
#define XW_CONNS_HOSTIP_LABEL_ID 2910
|
||||
#define XW_CONNS_HOSTIP_FIELD_ID 2911
|
||||
|
||||
#define PALM_BOARD_TOP 8
|
||||
#define PALM_GRIDLESS_BOARD_TOP 2
|
||||
|
||||
#define PALM_BOARD_SCALE 10
|
||||
#define PALM_SCORE_LEFT 0
|
||||
#define PALM_SCORE_TOP 0
|
||||
#define PALM_SCORE_HEIGHT BOARD_TOP
|
||||
|
||||
#define PALM_GRIDLESS_SCORE_WIDTH 22
|
||||
#define PALM_GRIDLESS_SCORE_LEFT (160-PALM_GRIDLESS_SCORE_WIDTH)
|
||||
#define PALM_GRIDLESS_SCORE_TOP 42
|
||||
|
||||
#define PALM_TIMER_TOP 0
|
||||
#define PALM_TIMER_HEIGHT PALM_SCORE_HEIGHT
|
||||
|
||||
/* #define PALM_TRAY_LEFT 0 */
|
||||
#define PALM_TRAY_TOP (160-PALM_TRAY_SCALEV-1)
|
||||
#define PALM_TRAY_TOP_MAX 144 /* the lowest we can put the top */
|
||||
#ifdef EIGHT_TILES
|
||||
#define PALM_TRAY_SCALEH 18
|
||||
#else
|
||||
#define PALM_TRAY_SCALEH 20
|
||||
#endif
|
||||
#define PALM_TRAY_SCALEV PALM_TRAY_SCALEH
|
||||
#define PALM_DIVIDER_WIDTH 3
|
||||
|
||||
#define PALM_BOARD_LEFT_LH 9
|
||||
#define PALM_BOARD_LEFT_RH 0
|
||||
#define PALM_TRAY_LEFT_LH 17
|
||||
#define PALM_TRAY_LEFT_RH 0
|
||||
|
||||
|
||||
/* resource IDs */
|
||||
#define DOWN_ARROW_RESID 1001
|
||||
#define RIGHT_ARROW_RESID 1002
|
||||
#define FLIP_BUTTON_BMP_RES_ID 1003
|
||||
#define VALUE_BUTTON_BMP_RES_ID 1004
|
||||
#define HINT_BUTTON_BMP_RES_ID 1005
|
||||
#define TRAY_BUTTONS_BMP_RES_ID 1006
|
||||
#define SHOWTRAY_BUTTON_BMP_RES_ID 1007
|
||||
#define STAR_BMP_RES_ID 1008
|
||||
|
||||
#define STRL_RES_TYPE 'StrL'
|
||||
#define STRL_RES_ID 0x03e8
|
||||
|
||||
#if 0
|
||||
# define DMFINDDATABASE(g,c,n) DmFindDatabase( (c),(n) )
|
||||
# define DMOPENDATABASE(g,c,i,m) DmOpenDatabase( (c),(i),(m))
|
||||
# define DMCLOSEDATABASE(d) DmCloseDatabase( d )
|
||||
#else
|
||||
# define DMFINDDATABASE(g,c,n) (g)->gamesDBID
|
||||
# define DMOPENDATABASE(g,c,i,m) (g)->gamesDBP
|
||||
# define DMCLOSEDATABASE(d)
|
||||
#endif
|
||||
|
||||
/* versioning stuff */
|
||||
#define XW_PALM_VERSION_STRING "4.0.6a4"
|
||||
#define CUR_PREFS_VERS 0x0405
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue