mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
(rough) changes to make toggling work for 320x480 Clie with silkscreen
This commit is contained in:
parent
bab5cc07f1
commit
7008125ec7
4 changed files with 171 additions and 42 deletions
|
@ -134,19 +134,19 @@ BEGIN
|
|||
PAGESIZE SBAR_PAGESIZE
|
||||
|
||||
BUTTON "" XW_MAIN_SHOWTRAY_BUTTON_ID
|
||||
AT (PALM_FLIP_LEFT 160-FLIP_BUTTON_HEIGHT-5
|
||||
FLIP_BUTTON_WIDTH FLIP_BUTTON_WIDTH+4) NOFRAME
|
||||
AT (PALM_FLIP_LEFT SHOWTRAY_BUTTON_Y
|
||||
FLIP_BUTTON_WIDTH FLIP_BUTTON_WIDTH+4) NOFRAME
|
||||
#ifndef EIGHT_TILES
|
||||
BUTTON "" XW_MAIN_HIDE_BUTTON_ID
|
||||
AT(PALM_TRAY_BUTTON_LEFT 160-TRAY_HEIGHT TRAY_BUTTON_WIDTH
|
||||
AT(PALM_TRAY_BUTTON_LEFT TRAY_BUTTONS_Y TRAY_BUTTON_WIDTH
|
||||
TRAY_BUTTON_HEIGHT) NOFRAME
|
||||
BUTTON "" XW_MAIN_JUGGLE_BUTTON_ID
|
||||
AT(PREVRIGHT PREVTOP TRAY_BUTTON_WIDTH TRAY_BUTTON_HEIGHT) NOFRAME
|
||||
AT(PREVRIGHT PREVTOP TRAY_BUTTON_WIDTH TRAY_BUTTON_HEIGHT) NOFRAME
|
||||
BUTTON "" XW_MAIN_TRADE_BUTTON_ID
|
||||
AT(PALM_TRAY_BUTTON_LEFT PREVBOTTOM TRAY_BUTTON_WIDTH
|
||||
TRAY_BUTTON_HEIGHT) NOFRAME
|
||||
AT(PALM_TRAY_BUTTON_LEFT PREVBOTTOM TRAY_BUTTON_WIDTH
|
||||
TRAY_BUTTON_HEIGHT) NOFRAME
|
||||
BUTTON "" XW_MAIN_DONE_BUTTON_ID
|
||||
AT(PREVRIGHT PREVTOP TRAY_BUTTON_WIDTH TRAY_BUTTON_HEIGHT) NOFRAME
|
||||
AT(PREVRIGHT PREVTOP TRAY_BUTTON_WIDTH TRAY_BUTTON_HEIGHT) NOFRAME
|
||||
#endif
|
||||
#ifdef FOR_GREMLINS
|
||||
GADGET GREMLIN_BOARD_GADGET_IDAUTOID AT ( 0 5 152 135 )
|
||||
|
@ -327,6 +327,8 @@ USABLE MODAL SAVEBEHIND DEFAULTBTNID XW_PREFS_CANCEL_BUTTON_ID
|
|||
BEGIN
|
||||
TITLE "Preferences"
|
||||
|
||||
GRAFFITISTATEINDICATOR 0 0
|
||||
|
||||
GADGET ID XW_PREFS_APPWIDE_CHECKBX_ID
|
||||
AT (LEFTCOL+8 PREFS_MODE_TOP 75 SERVER_HEIGHT) USABLE
|
||||
GADGET ID XW_PREFS_ONEGAME_CHECKBX_ID
|
||||
|
|
187
palm/palmmain.c
187
palm/palmmain.c
|
@ -26,17 +26,15 @@
|
|||
#include <Form.h>
|
||||
#include <Menu.h>
|
||||
#include <IrLib.h>
|
||||
/* #include <TextMgr.h> */
|
||||
/* #include <UIControls.h> */
|
||||
/* #include <KeyMgr.h> */
|
||||
#include <Chars.h>
|
||||
#include <TimeMgr.h>
|
||||
/* #include <UIResources.h> */
|
||||
/* #include <ExgMgr.h> */
|
||||
#include <FeatureMgr.h>
|
||||
#include <NotifyMgr.h>
|
||||
/* #include <StringMgr.h> */
|
||||
#include <unix_stdarg.h>
|
||||
#ifdef FEATURE_HIGHRES
|
||||
# include <FileStream.h>
|
||||
# include <SonyCLIE.h>
|
||||
#endif
|
||||
|
||||
#include "comtypes.h"
|
||||
#include "comms.h"
|
||||
|
@ -235,6 +233,86 @@ cur_screen_depth( void )
|
|||
} /* cur_screen_depth */
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_HIGHRES
|
||||
static void
|
||||
getSizes( PalmAppGlobals* globals )
|
||||
{
|
||||
XP_U16 width, height;
|
||||
width = 160;
|
||||
height = 160;
|
||||
|
||||
if ( globals->hasHiRes ) {
|
||||
XP_U32 tmp;
|
||||
|
||||
if ( WinScreenGetAttribute( winScreenWidth, &tmp ) == errNone ) {
|
||||
width = tmp;
|
||||
}
|
||||
if ( WinScreenGetAttribute( winScreenHeight, &tmp ) == errNone ) {
|
||||
height = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if ( width == 320 ) {
|
||||
FormPtr form = FrmGetActiveForm();
|
||||
WinGetDisplayExtent( &width, &height );
|
||||
|
||||
if ( !!form ) {
|
||||
RectangleType r;
|
||||
r.topLeft.x = 0;
|
||||
r.topLeft.y = 0;
|
||||
r.extent.x = width;
|
||||
r.extent.y = height;
|
||||
|
||||
WinSetBounds( FrmGetWindowHandle(FrmGetActiveForm()), &r );
|
||||
}
|
||||
|
||||
width *= 2;
|
||||
height *= 2;
|
||||
}
|
||||
|
||||
globals->width = width;
|
||||
globals->height = height;
|
||||
} /* getSizes */
|
||||
#else
|
||||
# define getSizes(g)
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_HIGHRES
|
||||
static void
|
||||
locateTrayButtons( PalmAppGlobals* globals, XP_U16 trayTop, XP_U16 trayHt )
|
||||
{
|
||||
RectangleType rect;
|
||||
XP_Bool buttonsAtTop, trayAtTop;
|
||||
XP_S16 diff;
|
||||
|
||||
if ( FrmGetActiveForm() == NULL ) {
|
||||
return XP_FALSE;
|
||||
}
|
||||
|
||||
trayTop /= 2; /* get out of highres coords */
|
||||
getObjectBounds( XW_MAIN_HIDE_BUTTON_ID, &rect );
|
||||
diff = trayTop - rect.topLeft.y;
|
||||
|
||||
if ( diff != 0 ) {
|
||||
XP_U16 i;
|
||||
XP_U16 ids[] = {XW_MAIN_SHOWTRAY_BUTTON_ID,
|
||||
XW_MAIN_HIDE_BUTTON_ID,
|
||||
XW_MAIN_DONE_BUTTON_ID,
|
||||
XW_MAIN_TRADE_BUTTON_ID,
|
||||
XW_MAIN_JUGGLE_BUTTON_ID
|
||||
};
|
||||
|
||||
for ( i = 0; i < sizeof(ids)/sizeof(ids[0]); ++i ) {
|
||||
getObjectBounds( ids[i], &rect );
|
||||
rect.topLeft.y += diff;
|
||||
setObjectBounds( ids[i], &rect );
|
||||
}
|
||||
}
|
||||
} /* locateTrayButtons */
|
||||
#else
|
||||
# define locateTrayButtons(g,t,h)
|
||||
#endif
|
||||
|
||||
static XP_Bool
|
||||
positionBoard( PalmAppGlobals* globals )
|
||||
{
|
||||
|
@ -283,7 +361,6 @@ positionBoard( PalmAppGlobals* globals )
|
|||
--scale;
|
||||
}
|
||||
|
||||
|
||||
freeSpace = ((PALM_MAX_ROWS-nCols)/2) * scale;
|
||||
if ( isLefty ) {
|
||||
leftEdge = bWidth - (nCols * scale) - freeSpace - 1;
|
||||
|
@ -353,14 +430,20 @@ positionBoard( PalmAppGlobals* globals )
|
|||
if ( trayTop < PALM_TRAY_TOP ) {
|
||||
trayTop = PALM_TRAY_TOP;/* we want it this low even if not
|
||||
necessary */
|
||||
} else if ( bHeight >= 450) {
|
||||
++trayTop; /* just for grins */
|
||||
/* hack: leave it */
|
||||
} else {
|
||||
while ( trayTop > (PALM_TRAY_TOP_MAX*doubler) ) {
|
||||
trayTop -= scale;
|
||||
globals->needsScrollbar = true;
|
||||
}
|
||||
}
|
||||
trayScaleV = bHeight - trayTop;
|
||||
trayScaleH = PALM_TRAY_SCALEH * doubler;
|
||||
trayScaleV = bHeight - trayTop;
|
||||
if ( trayScaleV > trayScaleH ) {
|
||||
trayScaleV = trayScaleH;
|
||||
}
|
||||
board_setTrayLoc( globals->game.board,
|
||||
(isLefty? PALM_TRAY_LEFT_LH:PALM_TRAY_LEFT_RH) * doubler,
|
||||
trayTop,
|
||||
|
@ -369,6 +452,8 @@ positionBoard( PalmAppGlobals* globals )
|
|||
|
||||
board_prefsChanged( globals->game.board, &globals->gState.cp );
|
||||
|
||||
locateTrayButtons( globals, trayTop, trayScaleV );
|
||||
|
||||
#ifdef SHOW_PROGRESS
|
||||
if ( showGrid ) {
|
||||
getObjectBounds( XW_MAIN_SCROLLBAR_ID, &bounds );
|
||||
|
@ -812,9 +897,8 @@ getResString( PalmAppGlobals* globals, XP_U16 strID )
|
|||
static Err
|
||||
volChangeEventProc( SysNotifyParamType* notifyParamsP )
|
||||
{
|
||||
#ifdef REALLY_HANDLE_MEDIA
|
||||
PalmAppGlobals* globals = (PalmAppGlobals*)notifyParamsP->userDataP;
|
||||
#else
|
||||
#ifndef REALLY_HANDLE_MEDIA
|
||||
EventType eventToPost;
|
||||
#endif
|
||||
|
||||
|
@ -835,7 +919,8 @@ volChangeEventProc( SysNotifyParamType* notifyParamsP )
|
|||
|
||||
#ifdef FEATURE_HIGHRES
|
||||
if ( notifyParamsP->notifyType == sysNotifyDisplayChangeEvent ) {
|
||||
XP_LOGF( "got sysNotifyDisplayChangeEvent" );
|
||||
eventToPost.eType = doResizeWinEvent;
|
||||
EvtAddEventToQueue( &eventToPost );
|
||||
return errNone;
|
||||
}
|
||||
#endif
|
||||
|
@ -880,15 +965,17 @@ doCallbackReg( PalmAppGlobals* globals, XP_Bool reg )
|
|||
}
|
||||
} /* doCallbackReg */
|
||||
|
||||
static void
|
||||
initGlobals( PalmAppGlobals* globals )
|
||||
{
|
||||
#ifdef FEATURE_HIGHRES
|
||||
/* temp workarounds for some sony include file trouble */
|
||||
extern Err SilkLibEnableResizeFoo(UInt16 refNum)
|
||||
SILK_LIB_TRAP(sysLibTrapCustom+1);
|
||||
extern Err VskSetStateFoo(UInt16 refNum, UInt16 stateType, UInt16 state)
|
||||
SILK_LIB_TRAP(sysLibTrapCustom+3+3);
|
||||
static void
|
||||
initHighResGlobals( PalmAppGlobals* globals )
|
||||
{
|
||||
Err err;
|
||||
XP_U32 vers;
|
||||
XP_U16 width, height;
|
||||
|
||||
width = height = 160;
|
||||
|
||||
err = FtrGet( sysFtrCreator, sysFtrNumWinVersion, &vers );
|
||||
globals->hasHiRes = ( err == errNone && vers >= 4 );
|
||||
|
@ -896,25 +983,46 @@ initGlobals( PalmAppGlobals* globals )
|
|||
XP_LOGF( "hasHiRes = %d", globals->hasHiRes );
|
||||
|
||||
if ( globals->hasHiRes ) {
|
||||
XP_U32 tmp;
|
||||
XP_U16 ref;
|
||||
|
||||
if ( WinScreenGetAttribute( winScreenWidth, &tmp ) == errNone ) {
|
||||
width = tmp;
|
||||
err = SysLibFind(sonySysLibNameSilk, &ref );
|
||||
if ( err == sysErrLibNotFound ) {
|
||||
err = SysLibLoad( 'libr', sonySysFileCSilkLib, &ref );
|
||||
}
|
||||
|
||||
if ( WinScreenGetAttribute( winScreenHeight, &tmp ) == errNone ) {
|
||||
height = tmp;
|
||||
}
|
||||
if ( err == errNone ) {
|
||||
XP_U32 tmp;
|
||||
globals->sonyLibRef = ref;
|
||||
|
||||
err = FtrGet( sonySysFtrCreator, sonySysFtrNumVskVersion, &tmp );
|
||||
if ( err == errNone ) {
|
||||
globals->doVSK = XP_TRUE;
|
||||
if ( VskOpen( ref ) == errNone ) {
|
||||
VskSetStateFoo( ref, vskStateEnable, 1 );
|
||||
}
|
||||
} else {
|
||||
if ( SilkLibOpen( ref ) == errNone ) {
|
||||
SilkLibEnableResizeFoo( ref );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* initHighResGlobals */
|
||||
|
||||
globals->width = width;
|
||||
globals->height = height;
|
||||
|
||||
XP_LOGF( "using width=%d, height=%d",
|
||||
globals->width, globals->height );
|
||||
static void
|
||||
uninitHighResGlobals( PalmAppGlobals* globals )
|
||||
{
|
||||
if ( globals->hasHiRes && globals->sonyLibRef != 0 ) {
|
||||
if ( globals->doVSK ) {
|
||||
VskClose( globals->sonyLibRef );
|
||||
} else {
|
||||
SilkLibClose( globals->sonyLibRef );
|
||||
}
|
||||
}
|
||||
} /* uninitHighResGlobals */
|
||||
#else
|
||||
# define initHighResGlobals(g)
|
||||
#endif
|
||||
} /* initGlobals */
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
|
@ -944,7 +1052,8 @@ startApplication( PalmAppGlobals** globalsP )
|
|||
XP_MEMSET( globals, 0, sizeof(PalmAppGlobals) );
|
||||
MPASSIGN( globals->mpool, mpool );
|
||||
|
||||
initGlobals( globals );
|
||||
initHighResGlobals( globals );
|
||||
getSizes( globals );
|
||||
|
||||
globals->vtMgr = make_vtablemgr( MPPARM_NOCOMMA(globals->mpool) );
|
||||
|
||||
|
@ -1167,6 +1276,8 @@ stopApplication( PalmAppGlobals* globals )
|
|||
}
|
||||
#endif
|
||||
|
||||
uninitHighResGlobals( globals );
|
||||
|
||||
XP_ASSERT( !!globals->gamesDBP );
|
||||
DmCloseDatabase( globals->gamesDBP );
|
||||
|
||||
|
@ -1709,6 +1820,7 @@ initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame )
|
|||
}
|
||||
|
||||
XP_ASSERT( !!globals->game.board );
|
||||
getSizes( globals );
|
||||
(void)positionBoard( globals );
|
||||
|
||||
#ifdef IR_SUPPORT
|
||||
|
@ -1865,7 +1977,7 @@ tryLoadSavedGame( PalmAppGlobals* globals, XP_U16 newIndex )
|
|||
static XP_U16
|
||||
hresX( PalmAppGlobals* globals, XP_U16 screenX )
|
||||
{
|
||||
if ( globals->width == 320 ) {
|
||||
if ( globals->hasHiRes && globals->width >= 320 ) {
|
||||
screenX *= 2;
|
||||
}
|
||||
return screenX;
|
||||
|
@ -1874,15 +1986,15 @@ hresX( PalmAppGlobals* globals, XP_U16 screenX )
|
|||
static XP_U16
|
||||
hresY( PalmAppGlobals* globals, XP_U16 screenY )
|
||||
{
|
||||
if ( globals->width == 320 ) {
|
||||
if ( globals->hasHiRes && globals->width >= 320 ) {
|
||||
screenY *= 2;
|
||||
}
|
||||
return screenY;
|
||||
}
|
||||
|
||||
#else
|
||||
# define hresX( g, n ) n
|
||||
# define hresY( g, n ) n
|
||||
# define hresX( g, n ) (n)
|
||||
# define hresY( g, n ) (n)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -1961,6 +2073,13 @@ mainViewHandleEvent( EventPtr event )
|
|||
draw = true;
|
||||
break;
|
||||
|
||||
case doResizeWinEvent:
|
||||
getSizes( globals );
|
||||
positionBoard( globals );
|
||||
board_invalAll( globals->game.board );
|
||||
FrmUpdateForm( 0, frmRedrawUpdateCode );
|
||||
break;
|
||||
|
||||
case prefsChangedEvent:
|
||||
erase = LocalPrefsToGlobal( globals );
|
||||
draw = board_prefsChanged( globals->game.board, &globals->gState.cp );
|
||||
|
|
|
@ -275,8 +275,10 @@ struct PalmAppGlobals {
|
|||
#endif
|
||||
|
||||
#ifdef FEATURE_HIGHRES
|
||||
XP_Bool hasHiRes;
|
||||
XP_U16 width, height;
|
||||
XP_U16 sonyLibRef;
|
||||
XP_Bool doVSK;
|
||||
XP_Bool hasHiRes;
|
||||
#endif
|
||||
|
||||
CurGameInfo gameInfo; /* for the currently open, or new, game */
|
||||
|
@ -312,6 +314,9 @@ enum { dictSelectedEvent = firstUserEvent /* 0x6000 */
|
|||
#ifdef BEYOND_IR
|
||||
,connsSettingChgEvent
|
||||
#endif
|
||||
#ifdef FEATURE_HIGHRES
|
||||
,doResizeWinEvent
|
||||
#endif
|
||||
};
|
||||
|
||||
DrawCtx* palm_drawctxt_make( MPFORMAL GraphicsAbility able,
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
#define FLIP_BUTTON_HEIGHT FLIP_BUTTON_WIDTH
|
||||
#define BOARD_TOP 8
|
||||
|
||||
#define TRAY_BUTTONS_Y (160-TRAY_HEIGHT)
|
||||
#define SHOWTRAY_BUTTON_Y (160-FLIP_BUTTON_HEIGHT-5)
|
||||
|
||||
#define IR_STATUS_HEIGHT 12
|
||||
|
||||
#define PALM_FLIP_LEFT 160-FLIP_BUTTON_WIDTH
|
||||
|
|
Loading…
Reference in a new issue