finish rem: changes and fix crash: show Remaining tiles dialog and draw focussed

This commit is contained in:
ehouse 2008-11-19 05:08:57 +00:00
parent 0652a85acd
commit e20d57e6fb
2 changed files with 38 additions and 10 deletions

View file

@ -1043,7 +1043,8 @@ palmMeasureDrawText( PalmDrawCtx* dctx, XP_Rect* bounds, XP_UCHAR* txt,
static void
palmFormatRemText( PalmDrawCtx* dctx, XP_UCHAR* buf, XP_S16 nTilesLeft )
{
const XP_UCHAR* remStr = (*dctx->getResStrFunc)(dctx->globals, STR_REMTILES);
const XP_UCHAR* remStr = (*dctx->getResStrFunc)(dctx->globals,
STR_REMTILES);
if ( nTilesLeft < 0 ) {
nTilesLeft = 0;
}
@ -1051,8 +1052,8 @@ palmFormatRemText( PalmDrawCtx* dctx, XP_UCHAR* buf, XP_S16 nTilesLeft )
} /* palmFormatRemText */
static void
palm_draw_measureRemText( DrawCtx* p_dctx, const XP_Rect* rect, XP_S16 nTilesLeft,
XP_U16* widthP, XP_U16* heightP )
palm_draw_measureRemText( DrawCtx* p_dctx, const XP_Rect* rect,
XP_S16 nTilesLeft, XP_U16* widthP, XP_U16* heightP )
{
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
PalmAppGlobals* globals = dctx->globals;
@ -1072,7 +1073,8 @@ palm_draw_measureRemText( DrawCtx* p_dctx, const XP_Rect* rect, XP_S16 nTilesLef
static void
palm_draw_drawRemText( DrawCtx* p_dctx, const XP_Rect* rInner,
const XP_Rect* XP_UNUSED(rOuter), XP_S16 nTilesLeft )
const XP_Rect* rOuter, XP_S16 nTilesLeft,
XP_Bool focussed )
{
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
PalmAppGlobals* globals = dctx->globals;
@ -1080,10 +1082,20 @@ palm_draw_drawRemText( DrawCtx* p_dctx, const XP_Rect* rInner,
XP_Bool isVertical = !globals->gState.showGrid;
if ( focussed ) {
WinPushDrawState();
WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] );
pmEraseRect( rOuter );
}
palmFormatRemText( dctx, buf, nTilesLeft );
palmMeasureDrawText( dctx, (XP_Rect*)rInner, buf, isVertical, XP_FALSE,
':', XP_TRUE );
if ( focussed ) {
WinPopDrawState();
}
} /* palm_draw_drawRemText */
/* Measure text that'll be drawn for player. If vertical, it'll often get
@ -1151,7 +1163,7 @@ doDrawPlayer( PalmDrawCtx* dctx, const DrawScoreInfo* dsi,
XP_UCHAR scoreBuf[20];
palmFormatScore( (char*)scoreBuf, dsi, vertical );
palmMeasureDrawText( dctx, (XP_Rect*)rInner, (XP_UCHAR*)scoreBuf, vertical,
palmMeasureDrawText( dctx, (XP_Rect*)rInner, (XP_UCHAR*)scoreBuf, vertical,
dsi->isTurn, SCORE_SEP, XP_TRUE );
if ( vertical && dsi->isTurn ) {

View file

@ -135,6 +135,8 @@ static const XP_UCHAR* palm_util_getUserString( XW_UtilCtxt* uc,
XP_U16 stringCode );
static XP_Bool palm_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
XP_U16 turn, XP_Bool turnLost );
static void palm_util_remSelected(XW_UtilCtxt* uc);
#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY
static void palm_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr,
const CommsAddrRec* newAddr );
@ -657,6 +659,7 @@ initUtilFuncs( PalmAppGlobals* globals )
#endif
vtable->m_util_getUserString = palm_util_getUserString;
vtable->m_util_warnIllegalWord = palm_util_warnIllegalWord;
vtable->m_util_remSelected = palm_util_remSelected;
#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY
vtable->m_util_addrChange = palm_util_addrChange;
#endif
@ -2501,6 +2504,16 @@ handleKeyEvent( PalmAppGlobals* globals, const EventType* event,
return draw;
} /* handleKeyEvent */
static void
showRemaining( PalmAppGlobals* globals )
{
if ( !!globals->game.board ) {
XWStreamCtxt* stream = makeSimpleStream( globals, NULL );
board_formatRemainingTiles( globals->game.board, stream );
(void)askFromStream( globals, stream, STR_REMAINS_TITLE, true );
}
}
/*****************************************************************************
*
****************************************************************************/
@ -2714,11 +2727,7 @@ mainViewHandleEvent( EventPtr event )
break;
case XW_TILESLEFT_PULLDOWN_ID:
if ( !!globals->game.board ) {
stream = makeSimpleStream( globals, NULL );
board_formatRemainingTiles( globals->game.board, stream );
(void)askFromStream( globals, stream, STR_REMAINS_TITLE, true );
}
showRemaining( globals );
break;
case XW_HISTORY_PULLDOWN_ID:
@ -4073,6 +4082,13 @@ palm_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
return result;
} /* palm_util_warnIllegalWord */
static void
palm_util_remSelected(XW_UtilCtxt* uc)
{
PalmAppGlobals* globals = (PalmAppGlobals*)uc->closure;
showRemaining( globals );
}
#if defined XWFEATURE_BLUETOOTH || defined XWFEATURE_RELAY
static void
palm_util_addrChange( XW_UtilCtxt* uc,