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,8 +61,8 @@ 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 );
void (*m_draw_measureRemText)( DrawCtx* dctx, XP_Rect* r, void (*m_draw_measureRemText)( DrawCtx* dctx, XP_Rect* r,

View file

@ -100,92 +100,93 @@ 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 ) ) {
DictionaryCtxt* dictionary = model_getDictionary( board->model );
draw_trayBegin( board->draw, &board->trayBounds, turn, if ( board->eraseTray ) {
focussed ); draw_clearRect( board->draw, &board->trayBounds );
board->eraseTray = XP_FALSE;
}
if ( board->eraseTray ) { if ( (board->trayVisState != TRAY_HIDDEN) && dictionary != NULL ) {
draw_clearRect( board->draw, &board->trayBounds ); XP_Bool showFaces = board->trayVisState == TRAY_REVEALED;
board->eraseTray = XP_FALSE;
}
if ( (board->trayVisState != TRAY_HIDDEN) && dictionary != NULL ) { if ( turn >= 0 ) {
XP_Bool showFaces = board->trayVisState == TRAY_REVEALED; XP_U16 numInTray = showFaces?
model_getNumTilesInTray( board->model, turn ):
model_getNumTilesTotal( board->model, turn );
if ( turn >= 0 ) { /* draw in reverse order so drawing happens after
XP_U16 numInTray = showFaces? erasing */
model_getNumTilesInTray( board->model, turn ): for ( i = MAX_TRAY_TILES - 1; i >= 0; --i ) {
model_getNumTilesTotal( board->model, turn );
/* draw in reverse order so drawing happens after erasing */ if ( (board->trayInvalBits & (1 << i)) == 0 ) {
for ( i = MAX_TRAY_TILES - 1; i >= 0; --i ) { continue;
if ( (board->trayInvalBits & (1 << i)) == 0 ) {
continue;
}
figureTrayTileRect( board, i, &tileRect );
if ( i >= numInTray/* && showFace */ ) {
draw_clearRect( board->draw, &tileRect );
} else if ( showFaces ) {
XP_UCHAR buf[4];
XP_Bitmap bitmap = NULL;
XP_UCHAR* textP = (XP_UCHAR*)NULL;
XP_U8 flags = board->traySelBits[turn];
XP_Bool highlighted = (flags & (1<<i)) != 0;
Tile tile = model_getPlayerTile( board->model,
turn, i );
XP_S16 value;
if ( dict_faceIsBitmap( dictionary, tile ) ) {
bitmap = dict_getFaceBitmap( dictionary, tile,
XP_TRUE );
} else {
textP = buf;
dict_tilesToString( dictionary, &tile, 1, textP );
} }
value = dict_getTileValue( dictionary, tile );
draw_drawTile( board->draw, &tileRect, textP, bitmap, figureTrayTileRect( board, i, &tileRect );
value, highlighted );
} else { if ( i >= numInTray/* && showFace */ ) {
draw_drawTileBack( board->draw, &tileRect ); draw_clearRect( board->draw, &tileRect );
} else if ( showFaces ) {
XP_UCHAR buf[4];
XP_Bitmap bitmap = NULL;
XP_UCHAR* textP = (XP_UCHAR*)NULL;
XP_U8 flags = board->traySelBits[turn];
XP_Bool highlighted = (flags & (1<<i)) != 0;
Tile tile = model_getPlayerTile( board->model,
turn, i );
XP_S16 value;
if ( dict_faceIsBitmap( dictionary, tile ) ) {
bitmap = dict_getFaceBitmap( dictionary, tile,
XP_TRUE );
} else {
textP = buf;
dict_tilesToString( dictionary, &tile, 1,
textP );
}
value = dict_getTileValue( dictionary, tile );
draw_drawTile( board->draw, &tileRect, textP,
bitmap, value, highlighted );
} else {
draw_drawTileBack( board->draw, &tileRect );
}
} }
} }
}
if ( (board->dividerWidth > 0) && board->dividerInvalid ) { if ( (board->dividerWidth > 0) && board->dividerInvalid ) {
XP_Rect divider; XP_Rect divider;
figureDividerRect( board, &divider ); figureDividerRect( board, &divider );
draw_drawTrayDivider( board->draw, &divider, draw_drawTrayDivider( board->draw, &divider,
board->divDragState.dragInProgress ); board->divDragState.dragInProgress );
board->dividerInvalid = XP_FALSE; board->dividerInvalid = XP_FALSE;
} }
#ifdef KEYBOARD_NAV #ifdef KEYBOARD_NAV
if ( showFaces ) { if ( showFaces ) {
TileBit cursorLoc = board->trayCursorLoc[turn]; TileBit cursorLoc = board->trayCursorLoc[turn];
if ( !!cursorLoc ) { if ( !!cursorLoc ) {
XP_U16 index = indexForBits( cursorLoc ); XP_U16 index = indexForBits( cursorLoc );
figureTrayTileRect( board, index, &tileRect ); figureTrayTileRect( board, index, &tileRect );
draw_drawTrayCursor( board->draw, &tileRect ); draw_drawTrayCursor( board->draw, &tileRect );
}
} }
}
#endif #endif
}
draw_trayFinished(board->draw);
board->trayInvalBits = 0;
} }
draw_trayFinished(board->draw);
board->trayInvalBits = 0;
} }
drawPendingScore( board ); drawPendingScore( board );

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;
dctx->trayOwner = owner; CEAppGlobals* globals = dctx->globals;
HDC hdc = globals->hdc;
XP_Bool canDraw = !!hdc;
if ( canDraw ) {
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] );