draw_trayBegin returns bool

This commit is contained in:
ehouse 2004-03-02 03:26:10 +00:00
parent 7d403f1ae5
commit d48ae1a216
3 changed files with 77 additions and 70 deletions

View file

@ -61,7 +61,7 @@ typedef struct DrawCtxVTable {
XP_Bool (*m_draw_vertScrollBoard)(DrawCtx* dctx, XP_Rect* rect, XP_Bool (*m_draw_vertScrollBoard)(DrawCtx* dctx, XP_Rect* rect,
XP_S16 dist ); XP_S16 dist );
void (*m_draw_trayBegin)( DrawCtx* dctx, XP_Rect* rect, XP_Bool (*m_draw_trayBegin)( DrawCtx* dctx, XP_Rect* rect,
XP_U16 owner, XP_Bool hasfocus ); XP_U16 owner, XP_Bool hasfocus );
void (*m_draw_trayFinished)( DrawCtx* dctx ); void (*m_draw_trayFinished)( DrawCtx* dctx );

View file

@ -100,17 +100,15 @@ figureTrayTileRect( BoardCtxt* board, XP_U16 index, XP_Rect* rect )
void void
drawTray( BoardCtxt* board, XP_Bool focussed ) drawTray( BoardCtxt* board, XP_Bool focussed )
{ {
DictionaryCtxt* dictionary;
XP_Rect tileRect; XP_Rect tileRect;
short i; short i;
if ( (board->trayInvalBits != 0) || board->dividerInvalid ) { if ( (board->trayInvalBits != 0) || board->dividerInvalid ) {
XP_S16 turn = board->selPlayer; XP_S16 turn = board->selPlayer;
dictionary = model_getDictionary( board->model ); if ( draw_trayBegin( board->draw, &board->trayBounds, turn,
focussed ) ) {
draw_trayBegin( board->draw, &board->trayBounds, turn, DictionaryCtxt* dictionary = model_getDictionary( board->model );
focussed );
if ( board->eraseTray ) { if ( board->eraseTray ) {
draw_clearRect( board->draw, &board->trayBounds ); draw_clearRect( board->draw, &board->trayBounds );
@ -125,7 +123,8 @@ drawTray( BoardCtxt* board, XP_Bool focussed )
model_getNumTilesInTray( board->model, turn ): model_getNumTilesInTray( board->model, turn ):
model_getNumTilesTotal( board->model, turn ); model_getNumTilesTotal( board->model, turn );
/* draw in reverse order so drawing happens after erasing */ /* draw in reverse order so drawing happens after
erasing */
for ( i = MAX_TRAY_TILES - 1; i >= 0; --i ) { for ( i = MAX_TRAY_TILES - 1; i >= 0; --i ) {
if ( (board->trayInvalBits & (1 << i)) == 0 ) { if ( (board->trayInvalBits & (1 << i)) == 0 ) {
@ -151,12 +150,13 @@ drawTray( BoardCtxt* board, XP_Bool focussed )
XP_TRUE ); XP_TRUE );
} else { } else {
textP = buf; textP = buf;
dict_tilesToString( dictionary, &tile, 1, textP ); dict_tilesToString( dictionary, &tile, 1,
textP );
} }
value = dict_getTileValue( dictionary, tile ); value = dict_getTileValue( dictionary, tile );
draw_drawTile( board->draw, &tileRect, textP, bitmap, draw_drawTile( board->draw, &tileRect, textP,
value, highlighted ); bitmap, value, highlighted );
} else { } else {
draw_drawTileBack( board->draw, &tileRect ); draw_drawTileBack( board->draw, &tileRect );
} }
@ -187,6 +187,7 @@ drawTray( BoardCtxt* board, XP_Bool focussed )
board->trayInvalBits = 0; board->trayInvalBits = 0;
} }
}
drawPendingScore( board ); drawPendingScore( board );
} /* drawTray */ } /* drawTray */

View file

@ -228,12 +228,18 @@ logClipResult( int icrResult )
} /* logClipResult */ } /* logClipResult */
#endif #endif
static void static XP_Bool
ce_draw_trayBegin( DrawCtx* p_dctx, XP_Rect* rect, XP_U16 owner, ce_draw_trayBegin( DrawCtx* p_dctx, XP_Rect* rect, XP_U16 owner,
XP_Bool hasfocus ) XP_Bool hasfocus )
{ {
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx; CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
CEAppGlobals* globals = dctx->globals;
HDC hdc = globals->hdc;
XP_Bool canDraw = !!hdc;
if ( canDraw ) {
dctx->trayOwner = owner; dctx->trayOwner = owner;
}
return canDraw;
} /* ce_draw_trayBegin */ } /* ce_draw_trayBegin */
static void static void
@ -389,7 +395,7 @@ ce_draw_drawBoardArrow( DrawCtx* p_dctx, XP_Rect* xprect,
if ( cursorBonus == BONUS_NONE ) { if ( cursorBonus == BONUS_NONE ) {
bkIndex = BKG_COLOR; bkIndex = BKG_COLOR;
} else { } else {
bkIndex = cursorBonus+BONUS1_COLOR; bkIndex = cursorBonus - BONUS_DOUBLE_LETTER + BONUS1_COLOR;
} }
FillRect( hdc, &rt, dctx->brushes[bkIndex] ); FillRect( hdc, &rt, dctx->brushes[bkIndex] );
SetBkColor( hdc, dctx->colors[bkIndex] ); SetBkColor( hdc, dctx->colors[bkIndex] );