Use new draw API but same bitmap as always (large in tile, small in

cell.)  In cases where bitmap and text provided, prefer bitmap.
This commit is contained in:
ehouse 2009-01-13 13:02:17 +00:00
parent bf0d27388a
commit 77381a1d5d
3 changed files with 55 additions and 52 deletions

View file

@ -304,7 +304,8 @@ curses_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
static XP_Bool static XP_Bool
curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letter, XP_Bitmap XP_UNUSED(bitmap), const XP_UCHAR* letter,
const XP_Bitmaps* XP_UNUSED(bitmaps),
Tile XP_UNUSED(tile), XP_S16 XP_UNUSED(owner), Tile XP_UNUSED(tile), XP_S16 XP_UNUSED(owner),
XWBonusType bonus, HintAtts XP_UNUSED(hintAtts), XWBonusType bonus, HintAtts XP_UNUSED(hintAtts),
CellFlags flags ) CellFlags flags )
@ -391,7 +392,7 @@ curses_stringInTile( CursesDrawCtx* dctx, const XP_Rect* rect,
static void static void
curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* textP, XP_Bitmap XP_UNUSED(bitmap), const XP_UCHAR* textP, const XP_Bitmaps* XP_UNUSED(bitmaps),
XP_U16 val, CellFlags flags ) XP_U16 val, CellFlags flags )
{ {
char numbuf[5]; char numbuf[5];

View file

@ -230,7 +230,7 @@ draw_string_at( GtkDrawCtx* dctx, PangoLayout* layout,
} /* draw_string_at */ } /* draw_string_at */
static void static void
drawBitmapFromLBS( GtkDrawCtx* dctx, XP_Bitmap bm, const XP_Rect* rect ) drawBitmapFromLBS( GtkDrawCtx* dctx, const XP_Bitmap bm, const XP_Rect* rect )
{ {
GdkPixmap* pm; GdkPixmap* pm;
LinuxBMStruct* lbs = (LinuxBMStruct*)bm; LinuxBMStruct* lbs = (LinuxBMStruct*)bm;
@ -422,8 +422,9 @@ drawHintBorders( GtkDrawCtx* dctx, const XP_Rect* rect, HintAtts hintAtts)
static XP_Bool static XP_Bool
gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter, gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
XP_Bitmap bitmap, Tile XP_UNUSED(tile), XP_S16 owner, const XP_Bitmaps* bitmaps, Tile XP_UNUSED(tile),
XWBonusType bonus, HintAtts hintAtts, CellFlags flags ) XP_S16 owner, XWBonusType bonus, HintAtts hintAtts,
CellFlags flags )
{ {
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
XP_Rect rectInset = *rect; XP_Rect rectInset = *rect;
@ -468,6 +469,8 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
draw_string_at( dctx, NULL, "*", rect->height, rect, draw_string_at( dctx, NULL, "*", rect->height, rect,
XP_GTK_JUST_CENTER, &dctx->black, NULL ); XP_GTK_JUST_CENTER, &dctx->black, NULL );
} }
} else if ( !!bitmaps ) {
drawBitmapFromLBS( dctx, bitmaps->bmps[0], rect );
} else if ( !!letter ) { } else if ( !!letter ) {
GdkColor* foreground; GdkColor* foreground;
if ( cursor ) { if ( cursor ) {
@ -492,8 +495,6 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
rect->height,/*width, */ rect->height,/*width, */
0, 360*64 ); 0, 360*64 );
} }
} else if ( !!bitmap ) {
drawBitmapFromLBS( dctx, bitmap, rect );
} }
drawHintBorders( dctx, rect, hintAtts ); drawHintBorders( dctx, rect, hintAtts );
@ -534,7 +535,7 @@ gtk_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* XP_UNUSED(rect),
static void static void
gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP, gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
XP_Bitmap bitmap, XP_U16 val, CellFlags flags, const XP_Bitmaps* bitmaps, XP_U16 val, CellFlags flags,
XP_Bool clearBack ) XP_Bool clearBack )
{ {
XP_UCHAR numbuf[3]; XP_UCHAR numbuf[3];
@ -564,15 +565,15 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
formatRect.width -= 6; formatRect.width -= 6;
if ( notEmpty ) { if ( notEmpty ) {
if ( !!textP ) { if ( !!bitmaps ) {
drawBitmapFromLBS( dctx, bitmaps->bmps[1], &insetR );
} else if ( !!textP ) {
if ( *textP != LETTER_NONE ) { /* blank */ if ( *textP != LETTER_NONE ) { /* blank */
draw_string_at( dctx, NULL, textP, formatRect.height>>1, draw_string_at( dctx, NULL, textP, formatRect.height>>1,
&formatRect, XP_GTK_JUST_TOPLEFT, &formatRect, XP_GTK_JUST_TOPLEFT,
foreground, NULL ); foreground, NULL );
} }
} else if ( !!bitmap ) {
drawBitmapFromLBS( dctx, bitmap, &insetR );
} }
if ( !valHidden ) { if ( !valHidden ) {
@ -605,21 +606,20 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
static void static void
gtk_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP, gtk_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
XP_Bitmap bitmap, XP_U16 val, CellFlags flags ) const XP_Bitmaps* bitmaps, XP_U16 val, CellFlags flags )
{ {
gtkDrawTileImpl( p_dctx, rect, textP, bitmap, val, flags, XP_TRUE ); gtkDrawTileImpl( p_dctx, rect, textP, bitmaps, val, flags, XP_TRUE );
} }
#ifdef POINTER_SUPPORT #ifdef POINTER_SUPPORT
static void static void
gtk_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect, gtk_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* textP, XP_Bitmap bitmap, const XP_UCHAR* textP, const XP_Bitmaps* bitmaps,
XP_U16 val, XP_U16 owner, CellFlags flags ) XP_U16 val, XP_U16 owner, CellFlags flags )
{ {
gtk_draw_trayBegin( p_dctx, rect, owner, DFS_NONE ); gtk_draw_trayBegin( p_dctx, rect, owner, DFS_NONE );
gtkDrawTileImpl( p_dctx, rect, textP, bitmap, val, gtkDrawTileImpl( p_dctx, rect, textP, bitmaps, val,
flags | CELL_HIGHLIGHT, flags | CELL_HIGHLIGHT, XP_FALSE );
XP_FALSE );
} }
#endif #endif

View file

@ -53,7 +53,7 @@
static XP_Bool palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, static XP_Bool palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letters, const XP_UCHAR* letters,
XP_Bitmap bitmap, Tile tile, const XP_Bitmaps* bitmaps, Tile tile,
XP_S16 owner, XWBonusType bonus, XP_S16 owner, XWBonusType bonus,
HintAtts hintAtts, CellFlags flags ); HintAtts hintAtts, CellFlags flags );
static void palm_bnw_draw_score_drawPlayer( DrawCtx* p_dctx, static void palm_bnw_draw_score_drawPlayer( DrawCtx* p_dctx,
@ -321,7 +321,7 @@ palm_draw_objFinished( DrawCtx* p_dctx, BoardObjectType typ,
static XP_Bool static XP_Bool
palm_clr_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, palm_clr_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letters, XP_Bitmap bitmap, const XP_UCHAR* letters, const XP_Bitmaps* bitmaps,
Tile tile, XP_S16 owner, XWBonusType bonus, Tile tile, XP_S16 owner, XWBonusType bonus,
HintAtts hintAtts, CellFlags flags ) HintAtts hintAtts, CellFlags flags )
{ {
@ -337,7 +337,7 @@ palm_clr_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
} else if ( isPending && !dragSrc ) { } else if ( isPending && !dragSrc ) {
/* don't color background if will invert */ /* don't color background if will invert */
index = COLOR_WHITE; index = COLOR_WHITE;
} else if ( (!!bitmap || !!letters) && !dragSrc ) { } else if ( (!!bitmaps || !!letters) && !dragSrc ) {
index = COLOR_TILE; index = COLOR_TILE;
} else if ( bonus == BONUS_NONE ) { } else if ( bonus == BONUS_NONE ) {
index = COLOR_EMPTY; index = COLOR_EMPTY;
@ -358,7 +358,7 @@ palm_clr_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
WinSetTextColor( color ); WinSetTextColor( color );
} }
return palm_common_draw_drawCell( p_dctx, rect, letters, bitmap, return palm_common_draw_drawCell( p_dctx, rect, letters, bitmaps,
tile, owner, bonus, hintAtts, flags ); tile, owner, bonus, hintAtts, flags );
} /* palm_clr_draw_drawCell */ } /* palm_clr_draw_drawCell */
@ -445,7 +445,7 @@ palmDrawHintBorders( PalmDrawCtx* dctx, const XP_Rect* rect,
static XP_Bool static XP_Bool
palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letters, XP_Bitmap bitmap, const XP_UCHAR* letters, const XP_Bitmaps* bitmaps,
Tile tile, XP_S16 owner, XWBonusType bonus, Tile tile, XP_S16 owner, XWBonusType bonus,
HintAtts hintAtts, CellFlags flags ) HintAtts hintAtts, CellFlags flags )
{ {
@ -496,6 +496,28 @@ palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
if ( showEmpty ) { if ( showEmpty ) {
/* do nothing */ /* do nothing */
} else if ( !!bitmaps ) {
XP_Bool doColor = (able == COLOR) && (owner >= 0);
XP_U16 x = localR.left+1;
XP_U16 y = localR.top+1;
/* cheating again; this belongs in a palm_clr method. But the
special bitmaps are rare enough that we shouldn't change the palm
draw state every time. */
if ( doColor ) {
WinSetForeColor(
dctx->drawingPrefs->drawColors[COLOR_PLAYER1+owner] );
}
if ( dctx->doHiRes ) {
++x;
++y;
}
XP_ASSERT( bitmaps->nBitmaps > 0 );
WinDrawBitmap( bitmaps->bmps[0], x, y );
if ( doColor ) {
WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] );
}
showBonus = doColor; /* skip bonus in B&W case; can't draw both! */
} else if ( !!letters ) { } else if ( !!letters ) {
len = XP_STRLEN( (const char*)letters ); len = XP_STRLEN( (const char*)letters );
XP_ASSERT( len > 0 ); XP_ASSERT( len > 0 );
@ -516,28 +538,6 @@ palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
showBonus = XP_FALSE; showBonus = XP_FALSE;
} }
} else if ( !!bitmap ) {
XP_Bool doColor = (able == COLOR) && (owner >= 0);
XP_U16 x = localR.left+1;
XP_U16 y = localR.top+1;
/* cheating again; this belongs in a palm_clr method. But the
special bitmaps are rare enough that we shouldn't change the palm
draw state every time. */
if ( doColor ) {
WinSetForeColor(
dctx->drawingPrefs->drawColors[COLOR_PLAYER1+owner] );
}
if ( dctx->doHiRes ) {
++x;
++y;
}
WinDrawBitmap( (BitmapPtr)bitmap, x, y );
if ( doColor ) {
WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] );
}
showBonus = doColor; /* skip bonus in B&W case; can't draw both! */
} }
if ( ((flags & CELL_ISSTAR) != 0) && showEmpty ) { if ( ((flags & CELL_ISSTAR) != 0) && showEmpty ) {
@ -570,7 +570,7 @@ palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
if ( !showEmpty && (flags & CELL_HIGHLIGHT) != 0 ) { if ( !showEmpty && (flags & CELL_HIGHLIGHT) != 0 ) {
if ( !TREAT_AS_CURSOR( dctx, flags ) ) { if ( !TREAT_AS_CURSOR( dctx, flags ) ) {
XP_ASSERT( !!bitmap || XP_ASSERT( !!bitmaps ||
(!!letters && XP_STRLEN((const char*)letters)>0)); (!!letters && XP_STRLEN((const char*)letters)>0));
WinInvertRectangle( (RectangleType*)&localR, 0 ); WinInvertRectangle( (RectangleType*)&localR, 0 );
} }
@ -676,7 +676,7 @@ smallBoldStringAt( const char* str, XP_U16 len, XP_S16 x, XP_U16 y )
static void static void
palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letters, XP_Bitmap bitmap, const XP_UCHAR* letters, const XP_Bitmaps* bitmaps,
XP_U16 val, CellFlags flags ) XP_U16 val, CellFlags flags )
{ {
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
@ -732,7 +732,12 @@ palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
} }
} }
if ( !!letters ) { if ( !!bitmaps ) {
XP_ASSERT( bitmaps->nBitmaps > 1 );
WinDrawBitmap( (BitmapPtr)(bitmaps->bmps[1]),
localR.left+(2*doubler),
localR.top+(2*doubler) );
} else if ( !!letters ) {
if ( *letters != LETTER_NONE ) { /* blank */ if ( *letters != LETTER_NONE ) { /* blank */
FontID curFont = FntSetFont( largeFont ); FontID curFont = FntSetFont( largeFont );
@ -746,9 +751,6 @@ palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
FntSetFont( curFont ); FntSetFont( curFont );
} }
} else if ( !!bitmap ) {
WinDrawBitmap( (BitmapPtr)bitmap, localR.left+(2*doubler),
localR.top+(2*doubler) );
} }
WinDrawRectangleFrame( rectangleFrame, (RectangleType*)&localR ); WinDrawRectangleFrame( rectangleFrame, (RectangleType*)&localR );
@ -768,12 +770,12 @@ palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
#ifdef POINTER_SUPPORT #ifdef POINTER_SUPPORT
static void static void
palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect, palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letters, XP_Bitmap bitmap, const XP_UCHAR* letters, const XP_Bitmaps* bitmaps,
XP_U16 val, XP_U16 owner, CellFlags flags ) XP_U16 val, XP_U16 owner, CellFlags flags )
{ {
/* let trayBegin code take care of pushing color env changes. */ /* let trayBegin code take care of pushing color env changes. */
draw_trayBegin( p_dctx, rect, owner, DFS_NONE ); draw_trayBegin( p_dctx, rect, owner, DFS_NONE );
palm_draw_drawTile( p_dctx, rect, letters, bitmap, val, flags ); palm_draw_drawTile( p_dctx, rect, letters, bitmaps, val, flags );
draw_objFinished( p_dctx, OBJ_TRAY, rect, DFS_NONE ); draw_objFinished( p_dctx, OBJ_TRAY, rect, DFS_NONE );
} }
#endif #endif