change draw api so all available bitmaps (only 2 in current format)

can be passed for tile and cell drawing
This commit is contained in:
ehouse 2009-01-13 12:57:56 +00:00
parent eb1e667c17
commit 6d7a81fce6
6 changed files with 38 additions and 27 deletions

View file

@ -346,7 +346,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
XP_UCHAR ch[4] = {'\0'};
XP_S16 owner = -1;
XP_Bool invert = XP_FALSE;
XP_Bitmap bitmap = NULL;
XP_Bitmaps bitmaps;
XP_UCHAR* textP = NULL;
HintAtts hintAtts;
CellFlags flags = CELL_NONE;
@ -385,8 +385,7 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
textP = ch;
} else {
if ( dict_faceIsBitmap( dict, tile ) ) {
bitmap = dict_getFaceBitmap( dict, tile, XP_FALSE );
XP_ASSERT( !!bitmap );
dict_getFaceBitmaps( dict, tile, &bitmaps );
}
(void)dict_tilesToString( dict, &tile, 1, ch, sizeof(ch) );
textP = ch;
@ -410,7 +409,8 @@ drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
}
#endif
success = draw_drawCell( board->draw, &cellRect, textP, bitmap,
success = draw_drawCell( board->draw, &cellRect, textP,
bitmaps.nBitmaps > 0? &bitmaps : NULL,
tile, owner, bonus, hintAtts, flags );
break;
}
@ -473,7 +473,7 @@ drawDragTileIf( BoardCtxt* board )
XP_Bool isBlank;
XP_UCHAR buf[4];
XP_UCHAR* face;
XP_Bitmap bitmap = NULL;
XP_Bitmaps bitmaps;
XP_S16 value;
CellFlags flags;
@ -481,7 +481,7 @@ drawDragTileIf( BoardCtxt* board )
dragDropTileInfo( board, &tile, &isBlank );
face = getTileDrawInfo( board, tile, isBlank, &bitmap,
face = getTileDrawInfo( board, tile, isBlank, &bitmaps,
&value, buf, sizeof(buf) );
flags = CELL_DRAGCUR;
@ -491,8 +491,9 @@ drawDragTileIf( BoardCtxt* board )
if ( board->hideValsInTray && !board->showCellValues ) {
flags |= CELL_VALHIDDEN;
}
draw_drawTileMidDrag( board->draw, &rect, face, bitmap, value,
board->selPlayer, flags );
draw_drawTileMidDrag( board->draw, &rect, face,
bitmaps.nBitmaps > 0 ? &bitmaps : NULL,
value, board->selPlayer, flags );
}
}
} /* drawDragTileIf */

View file

@ -270,7 +270,7 @@ void moveTileInTray( BoardCtxt* board, XP_U16 moveTo, XP_U16 moveFrom );
XP_Bool handleTrayDuringTrade( BoardCtxt* board, XP_S16 index );
XP_UCHAR* getTileDrawInfo( const BoardCtxt* board, Tile tile, XP_Bool isBlank,
XP_Bitmap* bitmap, XP_S16* value,
XP_Bitmaps* bitmaps, XP_S16* value,
XP_UCHAR* buf, XP_U16 len );
XP_Bool dividerMoved( BoardCtxt* board, XP_U8 newLoc );

View file

@ -368,11 +368,11 @@ XP_Bool
dict_faceIsBitmap( const DictionaryCtxt* dict, Tile tile )
{
XP_UCHAR face = dict_getTileChar( dict, tile );
return /* face != 0 && */IS_SPECIAL(face);
return IS_SPECIAL(face);
} /* dict_faceIsBitmap */
XP_Bitmap
dict_getFaceBitmap( const DictionaryCtxt* dict, Tile tile, XP_Bool isLarge )
void
dict_getFaceBitmaps( const DictionaryCtxt* dict, Tile tile, XP_Bitmaps* bmps )
{
SpecialBitmaps* bitmaps;
XP_UCHAR face = dict_getTileChar( dict, tile );
@ -381,7 +381,9 @@ dict_getFaceBitmap( const DictionaryCtxt* dict, Tile tile, XP_Bool isLarge )
XP_ASSERT( !!dict->bitmaps );
bitmaps = &dict->bitmaps[(XP_U16)face];
return isLarge? bitmaps->largeBM:bitmaps->smallBM;
bmps->nBitmaps = 2;
bmps->bmps[0] = bitmaps->smallBM;
bmps->bmps[1] = bitmaps->largeBM;
} /* dict_getFaceBitmap */
#ifdef TALL_FONTS

View file

@ -56,6 +56,10 @@ typedef struct SpecialBitmaps {
XP_Bitmap smallBM;
} SpecialBitmaps;
typedef struct _XP_Bitmaps {
XP_U16 nBitmaps;
XP_Bitmap bmps[2]; /* 2 is private, may change */
} XP_Bitmaps;
struct DictionaryCtxt {
void (*destructor)( DictionaryCtxt* dict );
@ -139,8 +143,8 @@ const XP_UCHAR* dict_getName( const DictionaryCtxt* ctxt );
Tile dict_tileForString( const DictionaryCtxt* dict, const XP_UCHAR* key );
XP_Bool dict_faceIsBitmap( const DictionaryCtxt* dict, Tile tile );
XP_Bitmap dict_getFaceBitmap( const DictionaryCtxt* dict, Tile tile,
XP_Bool isLarge );
void dict_getFaceBitmaps( const DictionaryCtxt* dict, Tile tile,
XP_Bitmaps* bmps );
#ifdef TALL_FONTS
XP_LangCode dict_getLangCode( const DictionaryCtxt* dict );

View file

@ -159,7 +159,7 @@ typedef struct DrawCtxVTable {
/* at least one of these two will be
null */
const XP_UCHAR* text,
const XP_Bitmap bitmap,
const XP_Bitmaps* bitmaps,
Tile tile,
XP_S16 owner, /* -1 means don't use */
XWBonusType bonus, HintAtts hintAtts,
@ -170,13 +170,13 @@ typedef struct DrawCtxVTable {
void DRAW_VTABLE_NAME(drawTile) ( DrawCtx* dctx, const XP_Rect* rect,
/* at least 1 of these two will be null*/
const XP_UCHAR* text,
const XP_Bitmap bitmap,
const XP_Bitmaps* bitmaps,
XP_U16 val, CellFlags flags );
#ifdef POINTER_SUPPORT
void DRAW_VTABLE_NAME(drawTileMidDrag) ( DrawCtx* dctx, const XP_Rect* rect,
/* at least 1 of these two will be null*/
const XP_UCHAR* text,
const XP_Bitmap bitmap,
const XP_Bitmaps* bitmaps,
XP_U16 val, XP_U16 owner,
CellFlags flags );
#endif

View file

@ -1,6 +1,7 @@
/* -*-mode: C; fill-column: 78; compile-command: "cd ../linux && make MEMDEBUG=TRUE"; -*- */
/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE"; -*- */
/*
* Copyright 1997 - 2008 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 1997 - 2009 by Eric House (xwords@eehouse.org). All rights
* reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -186,7 +187,7 @@ drawTray( BoardCtxt* board )
NULL, -1, flags | CELL_ISEMPTY );
} else if ( showFaces ) {
XP_UCHAR buf[4];
XP_Bitmap bitmap = NULL;
XP_Bitmaps bitmaps;
XP_UCHAR* textP = (XP_UCHAR*)NULL;
XP_U8 traySelBits = pti->traySelBits;
XP_S16 value;
@ -210,7 +211,7 @@ drawTray( BoardCtxt* board )
}
textP = getTileDrawInfo( board, tile, isBlank,
&bitmap, &value,
&bitmaps, &value,
buf, sizeof(buf) );
if ( isADrag ) {
if ( ddAddedIndx == ii ) {
@ -224,7 +225,8 @@ drawTray( BoardCtxt* board )
}
draw_drawTile( board->draw, &tileRect, textP,
bitmap, value, flags );
bitmaps.nBitmaps > 0? &bitmaps:NULL,
value, flags );
} else {
draw_drawTileBack( board->draw, &tileRect, flags );
}
@ -232,7 +234,7 @@ drawTray( BoardCtxt* board )
}
if ( (board->dividerWidth > 0) && board->dividerInvalid ) {
CellFlags flags = cursorOnDivider? CELL_ISCURSOR : CELL_NONE;
CellFlags flags = cursorOnDivider? CELL_ISCURSOR:CELL_NONE;
XP_Rect divider;
figureDividerRect( board, &divider );
if ( pti->dividerSelected
@ -258,7 +260,7 @@ drawTray( BoardCtxt* board )
XP_UCHAR*
getTileDrawInfo( const BoardCtxt* board, Tile tile, XP_Bool isBlank,
XP_Bitmap* bitmap, XP_S16* value, XP_UCHAR* buf, XP_U16 len )
XP_Bitmaps* bitmaps, XP_S16* value, XP_UCHAR* buf, XP_U16 len )
{
XP_UCHAR* face = NULL;
DictionaryCtxt* dict = model_getDictionary( board->model );
@ -271,8 +273,10 @@ getTileDrawInfo( const BoardCtxt* board, Tile tile, XP_Bool isBlank,
*value = dict_getTileValue( dict, tile );
if ( dict_faceIsBitmap( dict, tile ) ) {
*bitmap = dict_getFaceBitmap( dict, tile, XP_TRUE );
}
dict_getFaceBitmaps( dict, tile, bitmaps );
} else {
bitmaps->nBitmaps = 0;
}
return face;
}