diff --git a/common/draw.h b/common/draw.h index 0f6ad4ea0..d3321fc59 100644 --- a/common/draw.h +++ b/common/draw.h @@ -61,8 +61,8 @@ typedef struct DrawCtxVTable { XP_Bool (*m_draw_vertScrollBoard)(DrawCtx* dctx, XP_Rect* rect, XP_S16 dist ); - void (*m_draw_trayBegin)( DrawCtx* dctx, XP_Rect* rect, - XP_U16 owner, XP_Bool hasfocus ); + XP_Bool (*m_draw_trayBegin)( DrawCtx* dctx, XP_Rect* rect, + XP_U16 owner, XP_Bool hasfocus ); void (*m_draw_trayFinished)( DrawCtx* dctx ); void (*m_draw_measureRemText)( DrawCtx* dctx, XP_Rect* r, diff --git a/common/tray.c b/common/tray.c index b965a1c10..678d2e55e 100644 --- a/common/tray.c +++ b/common/tray.c @@ -100,92 +100,93 @@ figureTrayTileRect( BoardCtxt* board, XP_U16 index, XP_Rect* rect ) void drawTray( BoardCtxt* board, XP_Bool focussed ) { - DictionaryCtxt* dictionary; XP_Rect tileRect; short i; if ( (board->trayInvalBits != 0) || board->dividerInvalid ) { 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, - focussed ); + if ( board->eraseTray ) { + draw_clearRect( board->draw, &board->trayBounds ); + board->eraseTray = XP_FALSE; + } - if ( board->eraseTray ) { - draw_clearRect( board->draw, &board->trayBounds ); - board->eraseTray = XP_FALSE; - } + if ( (board->trayVisState != TRAY_HIDDEN) && dictionary != NULL ) { + XP_Bool showFaces = board->trayVisState == TRAY_REVEALED; - if ( (board->trayVisState != TRAY_HIDDEN) && dictionary != NULL ) { - XP_Bool showFaces = board->trayVisState == TRAY_REVEALED; + if ( turn >= 0 ) { + XP_U16 numInTray = showFaces? + model_getNumTilesInTray( board->model, turn ): + model_getNumTilesTotal( board->model, turn ); - if ( turn >= 0 ) { - XP_U16 numInTray = showFaces? - model_getNumTilesInTray( board->model, turn ): - model_getNumTilesTotal( board->model, turn ); + /* draw in reverse order so drawing happens after + erasing */ + for ( i = MAX_TRAY_TILES - 1; i >= 0; --i ) { - /* draw in reverse order so drawing happens after erasing */ - for ( i = MAX_TRAY_TILES - 1; i >= 0; --i ) { - - 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<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 ); + if ( (board->trayInvalBits & (1 << i)) == 0 ) { + continue; } - value = dict_getTileValue( dictionary, tile ); - draw_drawTile( board->draw, &tileRect, textP, bitmap, - value, highlighted ); - } else { - draw_drawTileBack( board->draw, &tileRect ); + 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<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 ) { - XP_Rect divider; - figureDividerRect( board, ÷r ); - draw_drawTrayDivider( board->draw, ÷r, - board->divDragState.dragInProgress ); - board->dividerInvalid = XP_FALSE; - } + if ( (board->dividerWidth > 0) && board->dividerInvalid ) { + XP_Rect divider; + figureDividerRect( board, ÷r ); + draw_drawTrayDivider( board->draw, ÷r, + board->divDragState.dragInProgress ); + board->dividerInvalid = XP_FALSE; + } #ifdef KEYBOARD_NAV - if ( showFaces ) { - TileBit cursorLoc = board->trayCursorLoc[turn]; - if ( !!cursorLoc ) { - XP_U16 index = indexForBits( cursorLoc ); - figureTrayTileRect( board, index, &tileRect ); - draw_drawTrayCursor( board->draw, &tileRect ); + if ( showFaces ) { + TileBit cursorLoc = board->trayCursorLoc[turn]; + if ( !!cursorLoc ) { + XP_U16 index = indexForBits( cursorLoc ); + figureTrayTileRect( board, index, &tileRect ); + draw_drawTrayCursor( board->draw, &tileRect ); + } } - } #endif + } + + draw_trayFinished(board->draw); + + board->trayInvalBits = 0; } - - draw_trayFinished(board->draw); - - board->trayInvalBits = 0; } drawPendingScore( board ); diff --git a/wince/cedraw.c b/wince/cedraw.c index 15d2fef76..3da9a02a4 100755 --- a/wince/cedraw.c +++ b/wince/cedraw.c @@ -228,12 +228,18 @@ logClipResult( int icrResult ) } /* logClipResult */ #endif -static void +static XP_Bool ce_draw_trayBegin( DrawCtx* p_dctx, XP_Rect* rect, XP_U16 owner, XP_Bool hasfocus ) { 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 */ static void @@ -389,7 +395,7 @@ ce_draw_drawBoardArrow( DrawCtx* p_dctx, XP_Rect* xprect, if ( cursorBonus == BONUS_NONE ) { bkIndex = BKG_COLOR; } else { - bkIndex = cursorBonus+BONUS1_COLOR; + bkIndex = cursorBonus - BONUS_DOUBLE_LETTER + BONUS1_COLOR; } FillRect( hdc, &rt, dctx->brushes[bkIndex] ); SetBkColor( hdc, dctx->colors[bkIndex] );