mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-26 09:58:20 +01:00
apply diffs for revisions 2362 2379 2384 2386 2387 2392 2393 2394 2395 2397 2398 2400 2402 2403 2405 2407 and 2408 using script (no typos in this list.) Nothing but those diffs is included here. Only test was that wince compiles.
This commit is contained in:
parent
886340c2e8
commit
60975be1b5
21 changed files with 369 additions and 172 deletions
|
@ -346,7 +346,8 @@ 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_Bitmaps* bptr = NULL;
|
||||
XP_UCHAR* textP = NULL;
|
||||
HintAtts hintAtts;
|
||||
CellFlags flags = CELL_NONE;
|
||||
|
@ -385,8 +386,8 @@ 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 );
|
||||
bptr = &bitmaps;
|
||||
}
|
||||
(void)dict_tilesToString( dict, &tile, 1, ch, sizeof(ch) );
|
||||
textP = ch;
|
||||
|
@ -410,7 +411,7 @@ 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, bptr,
|
||||
tile, owner, bonus, hintAtts, flags );
|
||||
break;
|
||||
}
|
||||
|
@ -473,7 +474,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 +482,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 +492,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 */
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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,14 +170,14 @@ 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,
|
||||
XP_S16 val, CellFlags flags );
|
||||
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,
|
||||
XP_S16 val, XP_U16 owner,
|
||||
const XP_Bitmaps* bitmaps,
|
||||
XP_U16 val, XP_U16 owner,
|
||||
CellFlags flags );
|
||||
#endif
|
||||
void DRAW_VTABLE_NAME(drawTileBack) ( DrawCtx* dctx, const XP_Rect* rect,
|
||||
|
|
|
@ -274,7 +274,7 @@ model_setDictionary( ModelCtxt* model, DictionaryCtxt* dict )
|
|||
DictionaryCtxt*
|
||||
model_getDictionary( ModelCtxt* model )
|
||||
{
|
||||
XP_ASSERT( !!model->vol.dict );
|
||||
/* XP_ASSERT( !!model->vol.dict ); */
|
||||
return model->vol.dict;
|
||||
} /* model_getDictionary */
|
||||
|
||||
|
|
|
@ -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, ÷r );
|
||||
if ( pti->dividerSelected
|
||||
|
@ -258,7 +260,8 @@ 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 );
|
||||
|
@ -270,9 +273,11 @@ 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 );
|
||||
}
|
||||
if ( !isBlank && dict_faceIsBitmap( dict, tile ) ) {
|
||||
dict_getFaceBitmaps( dict, tile, bitmaps );
|
||||
} else {
|
||||
bitmaps->nBitmaps = 0;
|
||||
}
|
||||
|
||||
return face;
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ curses_stringInTile( CursesDrawCtx* dctx, const XP_Rect* rect,
|
|||
static void
|
||||
curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||
const XP_UCHAR* textP, XP_Bitmap XP_UNUSED(bitmap),
|
||||
XP_S16 val, CellFlags flags )
|
||||
XP_U16 val, CellFlags flags )
|
||||
{
|
||||
char numbuf[5];
|
||||
char letterbuf[5];
|
||||
|
@ -403,7 +403,7 @@ curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
|
|||
if ( (flags&CELL_ISEMPTY) == 0 ) {
|
||||
letterbuf[0] = !!textP? *textP: '_'; /* BLANK or bitmap */
|
||||
letterbuf[1] = '\0';
|
||||
if ( val >= 0 ) {
|
||||
if ( (flags&CELL_VALHIDDEN) == 0 ) {
|
||||
sprintf( numbuf, "%.2d", val );
|
||||
if ( numbuf[0] == '0' ) {
|
||||
numbuf[0] = ' ';
|
||||
|
|
|
@ -1349,6 +1349,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
|||
|
||||
g_globals.cp.showBoardArrow = XP_TRUE;
|
||||
g_globals.cp.showRobotScores = params->showRobotScores;
|
||||
g_globals.cp.hideTileValues = params->hideValues;
|
||||
|
||||
dict = params->dict;
|
||||
|
||||
|
|
|
@ -534,7 +534,7 @@ gtk_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* XP_UNUSED(rect),
|
|||
|
||||
static void
|
||||
gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
||||
XP_Bitmap bitmap, XP_S16 val, CellFlags flags,
|
||||
XP_Bitmap bitmap, XP_U16 val, CellFlags flags,
|
||||
XP_Bool clearBack )
|
||||
{
|
||||
XP_UCHAR numbuf[3];
|
||||
|
@ -542,25 +542,28 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
|||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||
XP_Rect insetR = *rect;
|
||||
XP_Bool isCursor = (flags & CELL_ISCURSOR) != 0;
|
||||
XP_Bool valHidden = (flags & CELL_VALHIDDEN) != 0;
|
||||
XP_Bool notEmpty = (flags & CELL_ISEMPTY) == 0;
|
||||
|
||||
if ( clearBack ) {
|
||||
gtkEraseRect( dctx, &insetR );
|
||||
}
|
||||
|
||||
if ( isCursor || (val >= 0) ) {
|
||||
if ( isCursor || notEmpty ) {
|
||||
GdkColor* foreground = &dctx->playerColors[dctx->trayOwner];
|
||||
XP_Rect formatRect = insetR;
|
||||
|
||||
gtkInsetRect( &insetR, 1 );
|
||||
|
||||
if ( clearBack ) {
|
||||
gtkFillRect( dctx, &insetR, isCursor? &dctx->cursor:&dctx->tileBack );
|
||||
gtkFillRect( dctx, &insetR,
|
||||
isCursor ? &dctx->cursor : &dctx->tileBack );
|
||||
}
|
||||
|
||||
if ( val >= 0 ) {
|
||||
formatRect.left += 3;
|
||||
formatRect.width -= 6;
|
||||
formatRect.left += 3;
|
||||
formatRect.width -= 6;
|
||||
|
||||
if ( notEmpty ) {
|
||||
if ( !!textP ) {
|
||||
if ( *textP != LETTER_NONE ) { /* blank */
|
||||
draw_string_at( dctx, NULL, textP, formatRect.height>>1,
|
||||
|
@ -572,35 +575,37 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
|||
drawBitmapFromLBS( dctx, bitmap, &insetR );
|
||||
}
|
||||
|
||||
sprintf( numbuf, "%d", val );
|
||||
len = strlen( numbuf );
|
||||
if ( !valHidden ) {
|
||||
sprintf( numbuf, "%d", val );
|
||||
len = strlen( numbuf );
|
||||
|
||||
draw_string_at( dctx, NULL, numbuf, formatRect.height>>2,
|
||||
&formatRect, XP_GTK_JUST_BOTTOMRIGHT,
|
||||
foreground, NULL );
|
||||
|
||||
/* frame the tile */
|
||||
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
|
||||
draw_string_at( dctx, NULL, numbuf, formatRect.height>>2,
|
||||
&formatRect, XP_GTK_JUST_BOTTOMRIGHT,
|
||||
foreground, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
/* frame the tile */
|
||||
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
|
||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
||||
dctx->drawGC,
|
||||
FALSE,
|
||||
insetR.left, insetR.top, insetR.width,
|
||||
insetR.height );
|
||||
|
||||
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
|
||||
gtkInsetRect( &insetR, 1 );
|
||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
||||
dctx->drawGC,
|
||||
FALSE,
|
||||
insetR.left, insetR.top, insetR.width,
|
||||
insetR.height );
|
||||
|
||||
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
|
||||
gtkInsetRect( &insetR, 1 );
|
||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
||||
dctx->drawGC,
|
||||
FALSE, insetR.left, insetR.top,
|
||||
insetR.width, insetR.height);
|
||||
}
|
||||
FALSE, insetR.left, insetR.top,
|
||||
insetR.width, insetR.height);
|
||||
}
|
||||
}
|
||||
} /* gtkDrawTileImpl */
|
||||
|
||||
static void
|
||||
gtk_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
||||
XP_Bitmap bitmap, XP_S16 val, CellFlags flags )
|
||||
XP_Bitmap bitmap, XP_U16 val, CellFlags flags )
|
||||
{
|
||||
gtkDrawTileImpl( p_dctx, rect, textP, bitmap, val, flags, XP_TRUE );
|
||||
}
|
||||
|
@ -609,7 +614,7 @@ gtk_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
|||
static void
|
||||
gtk_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||
const XP_UCHAR* textP, XP_Bitmap bitmap,
|
||||
XP_S16 val, XP_U16 owner, CellFlags flags )
|
||||
XP_U16 val, XP_U16 owner, CellFlags flags )
|
||||
{
|
||||
gtk_draw_trayBegin( p_dctx, rect, owner, DFS_NONE );
|
||||
gtkDrawTileImpl( p_dctx, rect, textP, bitmap, val,
|
||||
|
|
|
@ -1827,6 +1827,7 @@ gtkmain( LaunchParams* params, int argc, char *argv[] )
|
|||
#endif
|
||||
|
||||
globals.cp.showBoardArrow = XP_TRUE;
|
||||
globals.cp.hideTileValues = params->hideValues;
|
||||
globals.cp.showRobotScores = params->showRobotScores;
|
||||
|
||||
setupGtkUtilCallbacks( &globals, params->util );
|
||||
|
|
|
@ -191,6 +191,7 @@ usage( char* appName, char* msg )
|
|||
"\t [-n name]* # same-process player (no network used)\n"
|
||||
"\t [-w pwd]* # passwd for matching local player\n"
|
||||
"\t [-v] # put scoreboard in vertical mode\n"
|
||||
"\t [-V] # hide values in tray\n"
|
||||
"\t [-m] # make the robot duMb (smart is default)\n"
|
||||
"\t [-l] # disallow hints\n"
|
||||
"\t [-c] # explain robot scores after each move\n"
|
||||
|
@ -707,7 +708,7 @@ main( int argc, char** argv )
|
|||
#if defined PLATFORM_GTK
|
||||
"h:I"
|
||||
#endif
|
||||
"kKf:ln:Nsd:e:r:b:q:w:Sit:Umvc"
|
||||
"kKf:ln:Nsd:e:r:b:q:w:Sit:UmvcV"
|
||||
#ifdef XWFEATURE_RELAY
|
||||
"a:p:C:H"
|
||||
#endif
|
||||
|
@ -836,6 +837,9 @@ main( int argc, char** argv )
|
|||
btaddr = optarg;
|
||||
break;
|
||||
#endif
|
||||
case 'V':
|
||||
mainParams.hideValues = XP_TRUE;
|
||||
break;
|
||||
case 'v':
|
||||
mainParams.verticalScore = XP_TRUE;
|
||||
break;
|
||||
|
|
|
@ -57,6 +57,7 @@ typedef struct LaunchParams {
|
|||
XP_Bool printHistory;
|
||||
XP_Bool undoWhenDone;
|
||||
XP_Bool verticalScore;
|
||||
XP_Bool hideValues;
|
||||
// XP_Bool mainParams;
|
||||
XP_Bool skipWarnings;
|
||||
XP_Bool showRobotScores;
|
||||
|
|
|
@ -677,7 +677,7 @@ smallBoldStringAt( const char* str, XP_U16 len, XP_S16 x, XP_U16 y )
|
|||
static void
|
||||
palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||
const XP_UCHAR* letters, XP_Bitmap bitmap,
|
||||
XP_S16 val, CellFlags flags )
|
||||
XP_U16 val, CellFlags flags )
|
||||
{
|
||||
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
||||
char valBuf[3];
|
||||
|
@ -716,7 +716,7 @@ palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
|
|||
/* Draw the number before the letter. Some PalmOS version don't
|
||||
honor the winOverlay flag and erase. Better to erase the value
|
||||
than the letter. */
|
||||
if ( val >= 0 ) {
|
||||
if ( (flags & CELL_VALHIDDEN) == 0 ) {
|
||||
(void)StrPrintF( valBuf, "%d", val );
|
||||
len = XP_STRLEN((const char*)valBuf);
|
||||
|
||||
|
@ -769,7 +769,7 @@ palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
|
|||
static void
|
||||
palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||
const XP_UCHAR* letters, XP_Bitmap bitmap,
|
||||
XP_S16 val, XP_U16 owner, CellFlags flags )
|
||||
XP_U16 val, XP_U16 owner, CellFlags flags )
|
||||
{
|
||||
/* let trayBegin code take care of pushing color env changes. */
|
||||
draw_trayBegin( p_dctx, rect, owner, DFS_NONE );
|
||||
|
@ -781,8 +781,8 @@ palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
|
|||
static void
|
||||
palm_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect, CellFlags flags )
|
||||
{
|
||||
palm_draw_drawTile( p_dctx, rect, (unsigned char*)"?", (XP_Bitmap)NULL,
|
||||
-1, flags & CELL_ISCURSOR );
|
||||
palm_draw_drawTile( p_dctx, rect, "?", (XP_Bitmap)NULL,
|
||||
0, (flags & CELL_ISCURSOR) | CELL_VALHIDDEN );
|
||||
} /* palm_draw_drawTileBack */
|
||||
|
||||
static void
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2002,2008 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 2002-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
|
||||
|
@ -91,6 +92,7 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
{
|
||||
BlankDialogState* bState;
|
||||
XP_U16 id;
|
||||
LRESULT result = FALSE; /* default */
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLongPtr( hDlg, GWL_USERDATA, lParam );
|
||||
|
@ -114,12 +116,14 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
ceDlgComboShowHide( &bState->dlgHdr, BLANKFACE_LIST );
|
||||
|
||||
loadLettersList( bState );
|
||||
result = TRUE;
|
||||
} else {
|
||||
bState = (BlankDialogState*)GetWindowLongPtr( hDlg, GWL_USERDATA );
|
||||
if ( !!bState ) {
|
||||
|
||||
if ( ceDoDlgHandle( &bState->dlgHdr, message, wParam, lParam) ) {
|
||||
return TRUE;
|
||||
result = TRUE;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
switch ( message ) {
|
||||
|
@ -142,10 +146,11 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
}
|
||||
EndDialog( hDlg, id );
|
||||
return TRUE;
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
exit:
|
||||
return result;
|
||||
} /* BlankDlg */
|
||||
|
|
|
@ -42,7 +42,7 @@ static void ce_dict_destroy( DictionaryCtxt* dict );
|
|||
static const XP_UCHAR* ce_dict_getShortName( const DictionaryCtxt* dict );
|
||||
static void ceLoadSpecialData( CEDictionaryCtxt* ctxt, XP_U8** ptrp );
|
||||
static XP_U16 ceCountSpecials( CEDictionaryCtxt* ctxt );
|
||||
static XP_Bitmap* ceMakeBitmap( CEDictionaryCtxt* ctxt, XP_U8** ptrp );
|
||||
static XP_Bitmap ceMakeBitmap( CEDictionaryCtxt* ctxt, XP_U8** ptrp );
|
||||
|
||||
static XP_U32 n_ptr_tohl( XP_U8** in );
|
||||
static XP_U16 n_ptr_tohs( XP_U8** in );
|
||||
|
@ -321,7 +321,7 @@ longSwapData( XP_U8* destBase, XP_U16 nRows, XP_U16 rowBytes )
|
|||
} /* longSwapData */
|
||||
#endif
|
||||
|
||||
static XP_Bitmap*
|
||||
static XP_Bitmap
|
||||
ceMakeBitmap( CEDictionaryCtxt* XP_UNUSED_DBG(ctxt), XP_U8** ptrp )
|
||||
{
|
||||
XP_U8* ptr = *ptrp;
|
||||
|
@ -372,7 +372,7 @@ ceMakeBitmap( CEDictionaryCtxt* XP_UNUSED_DBG(ctxt), XP_U8** ptrp )
|
|||
}
|
||||
|
||||
*ptrp = ptr;
|
||||
return (XP_Bitmap*)bitmap;
|
||||
return (XP_Bitmap)bitmap;
|
||||
} /* ceMakeBitmap */
|
||||
|
||||
static void
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* -*- fill-column: 77; compile-command: "make TARGET_OS=wince DEBUG=TRUE"; -*- */
|
||||
/*
|
||||
* Copyright 2000-2008 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 2000-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
|
||||
|
@ -34,6 +35,7 @@
|
|||
#include "cedefines.h"
|
||||
#include "cedebug.h"
|
||||
#include "debhacks.h"
|
||||
#include "strutils.h"
|
||||
|
||||
#ifndef DRAW_FUNC_NAME
|
||||
#define DRAW_FUNC_NAME(nam) ce_draw_ ## nam
|
||||
|
@ -59,6 +61,7 @@ typedef enum { NO_FOCUS, SINGLE_FOCUS, TOP_FOCUS } CeFocusLevel;
|
|||
|
||||
typedef enum {
|
||||
RFONTS_TRAY
|
||||
,RFONTS_TRAYNOVAL
|
||||
,RFONTS_TRAYVAL
|
||||
,RFONTS_CELL
|
||||
,RFONTS_REM
|
||||
|
@ -85,6 +88,11 @@ typedef struct _FontCacheEntry {
|
|||
XP_U16 offset;
|
||||
} FontCacheEntry;
|
||||
|
||||
typedef struct _CeBMCacheEntry {
|
||||
XP_UCHAR letters[4]; /* currently the max */
|
||||
HBITMAP bms[2];
|
||||
} CeBMCacheEntry;
|
||||
|
||||
struct CEDrawCtx {
|
||||
DrawCtxVTable* vtable;
|
||||
|
||||
|
@ -101,6 +109,7 @@ struct CEDrawCtx {
|
|||
HGDIOBJ hintPens[MAX_NUM_PLAYERS];
|
||||
|
||||
FontCacheEntry fcEntry[N_RESIZE_FONTS];
|
||||
CeBMCacheEntry bmCache[3]; /* 3: max specials in current use */
|
||||
|
||||
HBITMAP rightArrow;
|
||||
HBITMAP downArrow;
|
||||
|
@ -115,7 +124,8 @@ struct CEDrawCtx {
|
|||
};
|
||||
|
||||
static void ceClearToBkground( CEDrawCtx* dctx, const XP_Rect* rect );
|
||||
static void ceDrawBitmapInRect( HDC hdc, const RECT* r, HBITMAP bitmap );
|
||||
static void ceDrawBitmapInRect( HDC hdc, const RECT* r, HBITMAP bitmap,
|
||||
XP_Bool stretch );
|
||||
static void ceClipToRect( HDC hdc, const RECT* rt );
|
||||
static void ceClearFontCache( CEDrawCtx* dctx );
|
||||
|
||||
|
@ -127,6 +137,7 @@ RFI2Str( RFIndex rfi )
|
|||
# define CASE_STR(c) case c: str = #c; break
|
||||
switch( rfi ) {
|
||||
CASE_STR( RFONTS_TRAY );
|
||||
CASE_STR( RFONTS_TRAYNOVAL );
|
||||
CASE_STR( RFONTS_TRAYVAL );
|
||||
CASE_STR( RFONTS_CELL );
|
||||
CASE_STR( RFONTS_REM );
|
||||
|
@ -151,6 +162,14 @@ XPRtoRECT( RECT* rt, const XP_Rect* xprect )
|
|||
rt->bottom = rt->top + xprect->height;
|
||||
} /* XPRtoRECT */
|
||||
|
||||
static void
|
||||
ceDeleteObjectNotNull( HGDIOBJ obj )
|
||||
{
|
||||
if ( !!obj ) {
|
||||
DeleteObject( obj );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DRAW_FOCUS_FRAME
|
||||
static HGDIOBJ
|
||||
ceGetPen( CEDrawCtx* dctx, XP_U16 colorIndx, XP_U16 width )
|
||||
|
@ -277,6 +296,7 @@ makeTestBuf( CEDrawCtx* dctx, XP_UCHAR* buf, XP_U16 bufLen, RFIndex index )
|
|||
{
|
||||
switch( index ) {
|
||||
case RFONTS_TRAY:
|
||||
case RFONTS_TRAYNOVAL:
|
||||
case RFONTS_CELL: {
|
||||
Tile tile;
|
||||
Tile blank = (Tile)-1;
|
||||
|
@ -422,13 +442,27 @@ ceClearFontCache( CEDrawCtx* dctx )
|
|||
{
|
||||
XP_U16 ii;
|
||||
for ( ii = 0; ii < N_RESIZE_FONTS; ++ii ) {
|
||||
if ( !!dctx->fcEntry[ii].setFont ) {
|
||||
DeleteObject( dctx->fcEntry[ii].setFont );
|
||||
}
|
||||
ceDeleteObjectNotNull( dctx->fcEntry[ii].setFont );
|
||||
}
|
||||
XP_MEMSET( &dctx->fcEntry, 0, sizeof(dctx->fcEntry) );
|
||||
}
|
||||
|
||||
static void
|
||||
ceClearBmCache( CEDrawCtx* dctx )
|
||||
{
|
||||
XP_U16 ii;
|
||||
CeBMCacheEntry* entry;
|
||||
|
||||
for ( entry = dctx->bmCache, ii = 0;
|
||||
ii < VSIZE(dctx->bmCache); ++ii, ++entry ) {
|
||||
ceDeleteObjectNotNull( entry->bms[0] );
|
||||
ceDeleteObjectNotNull( entry->bms[1] );
|
||||
}
|
||||
|
||||
/* clear letters in case we're changing not deleting */
|
||||
XP_MEMSET( &dctx->bmCache[0], 0, sizeof(dctx->bmCache) );
|
||||
} /* ceClearBmCache */
|
||||
|
||||
static void
|
||||
ceFillFontInfo( const CEDrawCtx* dctx, LOGFONT* fontInfo,
|
||||
XP_U16 height/* , XP_Bool bold */ )
|
||||
|
@ -482,9 +516,7 @@ ceBestFitFont( CEDrawCtx* dctx, const XP_U16 soughtHeight,
|
|||
XP_U16 prevHeight = testHeight;
|
||||
LOGFONT fontInfo;
|
||||
|
||||
if ( !!testFont ) {
|
||||
DeleteObject( testFont );
|
||||
}
|
||||
ceDeleteObjectNotNull( testFont );
|
||||
|
||||
ceFillFontInfo( dctx, &fontInfo, testHeight );
|
||||
testFont = CreateFontIndirect( &fontInfo );
|
||||
|
@ -586,6 +618,126 @@ ceGetSizedFont( CEDrawCtx* dctx, XP_U16 height, XP_U16 width, RFIndex index )
|
|||
return fce;
|
||||
} /* ceGetSizedFont */
|
||||
|
||||
static HBITMAP
|
||||
checkBMCache( CEDrawCtx* dctx, HDC hdc, const XP_UCHAR* letters,
|
||||
const XP_U16 index, const XP_Bitmaps* bitmaps, XP_Bool* cached )
|
||||
{
|
||||
HBITMAP bm = NULL;
|
||||
CeBMCacheEntry* entry = NULL;
|
||||
XP_U16 len = 1 + XP_STRLEN( letters );
|
||||
XP_Bool canCache = XP_FALSE;
|
||||
|
||||
XP_ASSERT( !!letters );
|
||||
XP_ASSERT( index < 2 );
|
||||
|
||||
if ( len <= sizeof( entry->letters ) ) {
|
||||
XP_U16 ii;
|
||||
for ( ii = 0, entry = dctx->bmCache; ii < VSIZE(dctx->bmCache);
|
||||
++ii, ++entry ) {
|
||||
if ( 0 == entry->letters[0] ) { /* available */
|
||||
XP_MEMCPY( entry->letters, letters, len );
|
||||
canCache = XP_TRUE;
|
||||
break;
|
||||
} else if ( !XP_STRNCMP( entry->letters, letters, len ) ) {
|
||||
canCache = XP_TRUE;
|
||||
bm = entry->bms[index]; /* may be null */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if ( !canCache ) {
|
||||
XP_WARNF( "%s: unable to cache bitmap for %s", __func__, letters );
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( !bm ) {
|
||||
const CEBitmapInfo* info = (const CEBitmapInfo*)(bitmaps->bmps[index]);
|
||||
XP_U16 row, col;
|
||||
COLORREF black = dctx->globals->appPrefs.colors[CE_BLACK_COLOR];
|
||||
COLORREF white = dctx->globals->appPrefs.colors[CE_WHITE_COLOR];
|
||||
HDC tmpDC;
|
||||
XP_U8* bits = info->bits;
|
||||
XP_U16 nCols = info->nCols;
|
||||
XP_U16 nRows = info->nRows;
|
||||
XP_U16 rowBytes = (info->nCols + 7) / 8; /* rows are 8-bit padded */
|
||||
|
||||
bm = CreateBitmap( info->nCols, info->nRows, 1, 1, NULL );
|
||||
tmpDC = CreateCompatibleDC( hdc );
|
||||
SelectObject( tmpDC, bm );
|
||||
for ( row = 0; row < nRows; ++row ) {
|
||||
for ( col = 0; col < nCols; ++col ) {
|
||||
/* Optimize me... */
|
||||
XP_U8 byt = bits[col / 8];
|
||||
XP_Bool set = (byt & (0x80 >> (col % 8))) != 0;
|
||||
(void)SetPixel( tmpDC, col, row, set ? black:white );
|
||||
}
|
||||
bits += rowBytes;
|
||||
}
|
||||
DeleteDC( tmpDC );
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
BITMAP bmp;
|
||||
int nBytes = GetObject( bm, sizeof(bmp), &bmp );
|
||||
XP_ASSERT( nBytes > 0 );
|
||||
XP_ASSERT( bmp.bmWidth == nCols );
|
||||
XP_ASSERT( bmp.bmHeight == nRows );
|
||||
}
|
||||
#endif
|
||||
if ( canCache && entry->bms[index] != bm ) {
|
||||
XP_ASSERT( !entry->bms[index] || (entry->bms[index] == bm) );
|
||||
entry->bms[index] = bm;
|
||||
XP_LOGF( "%s: storing %p", __func__, bm );
|
||||
}
|
||||
}
|
||||
|
||||
*cached = canCache;
|
||||
return bm;
|
||||
} /* checkBMCache */
|
||||
|
||||
static void
|
||||
makeAndDrawBitmap( CEDrawCtx* dctx, HDC hdc, const RECT* bnds,
|
||||
const XP_UCHAR* letters, const XP_Bitmaps* bitmaps,
|
||||
XP_Bool center )
|
||||
{
|
||||
XP_Bool cached;
|
||||
XP_U16 index;
|
||||
RECT lrt = *bnds;
|
||||
XP_U16 useSize;
|
||||
|
||||
SIZE size;
|
||||
GetTextExtentPoint32( hdc, L"M", 1, &size );
|
||||
useSize = size.cx;
|
||||
|
||||
for ( index = bitmaps->nBitmaps - 1; ; --index ) {
|
||||
const CEBitmapInfo* info = (const CEBitmapInfo*)(bitmaps->bmps[index]);
|
||||
if ( info->nCols <= useSize && info->nRows <= useSize ) {
|
||||
break;
|
||||
} else if ( index == 0 ) {
|
||||
/* none fits */
|
||||
useSize = XP_MAX( info->nCols, info->nRows );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( center ) {
|
||||
lrt.left += ((lrt.right - lrt.left) - useSize) / 2;
|
||||
lrt.top += ((lrt.bottom - lrt.top) - useSize) / 2;
|
||||
}
|
||||
lrt.right = lrt.left + useSize;
|
||||
lrt.bottom = lrt.top + useSize;
|
||||
|
||||
HBITMAP bm = checkBMCache( dctx, hdc, letters, index, bitmaps, &cached );
|
||||
|
||||
ceDrawBitmapInRect( hdc, &lrt, bm, XP_TRUE );
|
||||
|
||||
if ( !cached ) {
|
||||
DeleteObject( bm );
|
||||
}
|
||||
} /* makeAndDrawBitmap */
|
||||
|
||||
static void
|
||||
ceMeasureText( CEDrawCtx* dctx, HDC hdc, const FontCacheEntry* fce,
|
||||
const XP_UCHAR* str, XP_S16 padding,
|
||||
|
@ -804,7 +956,7 @@ ceSetBkColor( HDC hdc, const CEDrawCtx* dctx, XP_U16 index )
|
|||
DLSTATIC XP_Bool
|
||||
DRAW_FUNC_NAME(drawCell)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||
const XP_UCHAR* letters,
|
||||
const XP_Bitmap XP_UNUSED(bitmap),
|
||||
const XP_Bitmaps* bitmaps,
|
||||
Tile XP_UNUSED(tile), XP_S16 owner,
|
||||
XWBonusType bonus, HintAtts hintAtts,
|
||||
CellFlags flags )
|
||||
|
@ -843,7 +995,7 @@ DRAW_FUNC_NAME(drawCell)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
|||
/* always init to silence compiler warning */
|
||||
foreColorIndx = getPlayerColor(owner);
|
||||
|
||||
if ( !isDragSrc && !!letters ) {
|
||||
if ( !isDragSrc && (!!letters || !!bitmaps) ) {
|
||||
if ( isPending ) {
|
||||
bkIndex = CE_BLACK_COLOR;
|
||||
foreColorIndx = CE_WHITE_COLOR;
|
||||
|
@ -881,23 +1033,20 @@ DRAW_FUNC_NAME(drawCell)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
|||
}
|
||||
|
||||
ceSetBkColor( hdc, dctx, bkIndex );
|
||||
ceSetTextColor( hdc, dctx, foreColorIndx );
|
||||
|
||||
if ( !isDragSrc && !!letters && (letters[0] != '\0') ) {
|
||||
if ( !isDragSrc && !!bitmaps ) {
|
||||
makeAndDrawBitmap( dctx, hdc, &rt, letters, bitmaps, XP_TRUE );
|
||||
} else if ( !isDragSrc && !!letters && (letters[0] != '\0') ) {
|
||||
wchar_t widebuf[4];
|
||||
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, letters, -1,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
|
||||
ceSetTextColor( hdc, dctx, foreColorIndx );
|
||||
#ifndef _WIN32_WCE
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, letters, -1,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
#endif
|
||||
ceDrawTextClipped( hdc, widebuf, -1, XP_FALSE, fce, xprect->left+1,
|
||||
xprect->top+2, xprect->width, DT_CENTER );
|
||||
} else if ( (flags&CELL_ISSTAR) != 0 ) {
|
||||
ceSetTextColor( hdc, dctx, CE_BLACK_COLOR );
|
||||
ceDrawBitmapInRect( hdc, &textRect, dctx->origin );
|
||||
ceDrawBitmapInRect( hdc, &textRect, dctx->origin, XP_FALSE );
|
||||
}
|
||||
|
||||
ceDrawHintBorders( dctx, xprect, hintAtts );
|
||||
|
@ -948,12 +1097,12 @@ DRAW_FUNC_NAME(trayBegin)( DrawCtx* p_dctx, const XP_Rect* XP_UNUSED(rect),
|
|||
|
||||
static void
|
||||
drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||
const XP_UCHAR* letters, XP_S16 val, CellFlags flags )
|
||||
const XP_UCHAR* letters, const XP_Bitmaps* bitmaps,
|
||||
XP_U16 val, CellFlags flags )
|
||||
{
|
||||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||
CEAppGlobals* globals = dctx->globals;
|
||||
HDC hdc = globals->hdc;
|
||||
wchar_t widebuf[4];
|
||||
RECT rt;
|
||||
XP_U16 index;
|
||||
XP_Bool highlighted = XP_FALSE;
|
||||
|
@ -1003,36 +1152,56 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
|
|||
|
||||
if ( !isEmpty ) {
|
||||
const FontCacheEntry* fce;
|
||||
wchar_t widebuf[4];
|
||||
/* Dumb to calc these when only needed once.... */
|
||||
XP_U16 valHt, charHt;
|
||||
XP_Bool valHidden = 0 != (flags & CELL_VALHIDDEN);
|
||||
ceGetCharValHts( dctx, xprect, valHidden, &charHt, &valHt );
|
||||
|
||||
if ( !highlighted ) {
|
||||
InsetRect( &rt, 1, 1 );
|
||||
}
|
||||
|
||||
if ( !!letters ) {
|
||||
fce = ceGetSizedFont( dctx, charHt, 0, RFONTS_TRAY );
|
||||
HFONT oldFont = SelectObject( hdc, fce->setFont );
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, letters, -1,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
ceGetCharValHts( dctx, xprect, valHidden, &charHt, &valHt );
|
||||
fce = ceGetSizedFont( dctx, charHt, 0,
|
||||
valHidden ? RFONTS_TRAYNOVAL:RFONTS_TRAY );
|
||||
|
||||
ceDrawTextClipped( hdc, widebuf, -1, XP_TRUE, fce,
|
||||
xprect->left + 4, xprect->top + 4,
|
||||
xprect->width - 8,
|
||||
valHidden?DT_CENTER:DT_LEFT );
|
||||
if ( !!bitmaps || !!letters ) {
|
||||
HFONT oldFont = SelectObject( hdc, fce->setFont );
|
||||
XP_U16 len = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED,
|
||||
letters, -1,
|
||||
widebuf, VSIZE(widebuf) );
|
||||
|
||||
/* see if there's room to use text instead of bitmap */
|
||||
if ( !!bitmaps && valHidden ) {
|
||||
SIZE size;
|
||||
GetTextExtentPoint32( hdc, widebuf, len - 1, /* drop null */
|
||||
&size );
|
||||
if ( size.cx < (rt.right - rt.left) ) {
|
||||
bitmaps = NULL; /* use the letters instead */
|
||||
}
|
||||
}
|
||||
|
||||
if ( !!bitmaps ) {
|
||||
makeAndDrawBitmap( dctx, hdc, &rt, letters, bitmaps,
|
||||
valHidden );
|
||||
} else if ( !!letters ) {
|
||||
ceDrawTextClipped( hdc, widebuf, -1, XP_TRUE, fce,
|
||||
xprect->left + 4, xprect->top + 4,
|
||||
xprect->width - 8,
|
||||
valHidden?DT_CENTER:DT_LEFT );
|
||||
}
|
||||
SelectObject( hdc, oldFont );
|
||||
}
|
||||
|
||||
if ( val >= 0 && !valHidden ) {
|
||||
if ( !valHidden ) {
|
||||
fce = ceGetSizedFont( dctx, valHt, 0, RFONTS_TRAYVAL );
|
||||
HFONT oldFont = SelectObject( hdc, fce->setFont );
|
||||
swprintf( widebuf, L"%d", val );
|
||||
|
||||
ceDrawTextClipped( hdc, widebuf, -1, XP_TRUE, fce,
|
||||
xprect->left + 4,
|
||||
xprect->top + xprect->height - 4 - fce->glyphHt,
|
||||
xprect->top + xprect->height - 4
|
||||
- fce->glyphHt,
|
||||
xprect->width - 8, DT_RIGHT );
|
||||
SelectObject( hdc, oldFont );
|
||||
}
|
||||
|
@ -1042,21 +1211,22 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
|
|||
|
||||
DLSTATIC void
|
||||
DRAW_FUNC_NAME(drawTile)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||
const XP_UCHAR* letters, XP_Bitmap XP_UNUSED(bitmap),
|
||||
XP_S16 val, CellFlags flags )
|
||||
const XP_UCHAR* letters, const XP_Bitmaps* bitmaps,
|
||||
XP_U16 val, CellFlags flags )
|
||||
{
|
||||
drawDrawTileGuts( p_dctx, xprect, letters, val, flags );
|
||||
drawDrawTileGuts( p_dctx, xprect, letters, bitmaps, val, flags );
|
||||
} /* ce_draw_drawTile */
|
||||
|
||||
#ifdef POINTER_SUPPORT
|
||||
DLSTATIC void
|
||||
DRAW_FUNC_NAME(drawTileMidDrag)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||
const XP_UCHAR* letters,
|
||||
XP_Bitmap XP_UNUSED(bitmap),
|
||||
XP_S16 val, XP_U16 owner, CellFlags flags )
|
||||
const XP_Bitmaps* bitmaps, XP_U16 val,
|
||||
XP_U16 owner, CellFlags flags )
|
||||
{
|
||||
draw_trayBegin( p_dctx, xprect, owner, DFS_NONE );
|
||||
drawDrawTileGuts( p_dctx, xprect, letters, val, flags );
|
||||
if ( draw_trayBegin( p_dctx, xprect, owner, DFS_NONE ) ) {
|
||||
drawDrawTileGuts( p_dctx, xprect, letters, bitmaps, val, flags );
|
||||
}
|
||||
} /* ce_draw_drawTile */
|
||||
#endif
|
||||
|
||||
|
@ -1064,7 +1234,7 @@ DLSTATIC void
|
|||
DRAW_FUNC_NAME(drawTileBack)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||
CellFlags flags )
|
||||
{
|
||||
drawDrawTileGuts( p_dctx, xprect, "?", -1, flags );
|
||||
drawDrawTileGuts( p_dctx, xprect, "?", NULL, 0, flags | CELL_VALHIDDEN );
|
||||
} /* ce_draw_drawTileBack */
|
||||
|
||||
DLSTATIC void
|
||||
|
@ -1109,48 +1279,50 @@ ceClearToBkground( CEDrawCtx* dctx, const XP_Rect* rect )
|
|||
* change the proportions.
|
||||
*/
|
||||
static void
|
||||
ceDrawBitmapInRect( HDC hdc, const RECT* rect, HBITMAP bitmap )
|
||||
ceDrawBitmapInRect( HDC hdc, const RECT* rect, HBITMAP bitmap,
|
||||
XP_Bool stretch )
|
||||
{
|
||||
BITMAP bmp;
|
||||
int nBytes;
|
||||
int left = rect->left;
|
||||
int top = rect->top;
|
||||
XP_U16 width = rect->right - left;
|
||||
XP_U16 height = rect->bottom - top;
|
||||
XP_U16 ii;
|
||||
HDC tmpDC;
|
||||
|
||||
XP_ASSERT( !!bitmap );
|
||||
nBytes = GetObject( bitmap, sizeof(bmp), &bmp );
|
||||
XP_ASSERT( nBytes > 0 );
|
||||
if ( nBytes == 0 ) {
|
||||
logLastError( "ceDrawBitmapInRect:GetObject" );
|
||||
} else {
|
||||
int left = rect->left;
|
||||
int top = rect->top;
|
||||
XP_U16 width = rect->right - left;
|
||||
XP_U16 height = rect->bottom - top;
|
||||
HDC tmpDC;
|
||||
|
||||
if ( !stretch ) {
|
||||
/* Find dimensions that'll fit multiplying an integral number of
|
||||
times */
|
||||
XP_U16 factor = XP_MIN( width/bmp.bmWidth, height/bmp.bmHeight );
|
||||
if ( factor == 0 ) {
|
||||
XP_LOGF( "%s: cell at %dx%d too small for bitmap at %ldx%ld",
|
||||
__func__, width, height, bmp.bmWidth, bmp.bmHeight );
|
||||
factor = 1;
|
||||
}
|
||||
|
||||
width = bmp.bmWidth * factor;
|
||||
height = bmp.bmHeight * factor;
|
||||
}
|
||||
|
||||
tmpDC = CreateCompatibleDC( hdc );
|
||||
SelectObject( tmpDC, bitmap );
|
||||
|
||||
(void)IntersectClipRect( tmpDC, left, top, rect->right, rect->bottom );
|
||||
|
||||
left += ((rect->right - left) - width) / 2;
|
||||
top += ((rect->bottom - top) - height) / 2;
|
||||
|
||||
StretchBlt( hdc, left, top, width, height,
|
||||
tmpDC, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY );
|
||||
DeleteDC( tmpDC );
|
||||
}
|
||||
|
||||
for ( ii = 1;
|
||||
((bmp.bmWidth * ii) <= width) && ((bmp.bmHeight * ii) <= height);
|
||||
++ii ) {
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
if ( --ii == 0 ) {
|
||||
XP_LOGF( "%s: cell too small for bitmap", __func__ );
|
||||
ii = 1;
|
||||
}
|
||||
|
||||
tmpDC = CreateCompatibleDC( hdc );
|
||||
SelectObject( tmpDC, bitmap );
|
||||
|
||||
(void)IntersectClipRect( tmpDC, left, top, rect->right, rect->bottom );
|
||||
|
||||
width = bmp.bmWidth * ii;
|
||||
height = bmp.bmHeight * ii;
|
||||
|
||||
left += ((rect->right - left) - width) / 2;
|
||||
top += ((rect->bottom - top) - height) / 2;
|
||||
|
||||
StretchBlt( hdc, left, top, width, height,
|
||||
tmpDC, 0, 0, bmp.bmHeight, bmp.bmWidth, SRCCOPY );
|
||||
DeleteDC( tmpDC );
|
||||
} /* ceDrawBitmapInRect */
|
||||
|
||||
DLSTATIC void
|
||||
|
@ -1191,7 +1363,7 @@ DRAW_FUNC_NAME(drawBoardArrow)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
|||
ceSetBkColor( hdc, dctx, bkIndex );
|
||||
ceSetTextColor( hdc, dctx, CE_BLACK_COLOR );
|
||||
|
||||
ceDrawBitmapInRect( hdc, &rt, cursor );
|
||||
ceDrawBitmapInRect( hdc, &rt, cursor, XP_FALSE );
|
||||
|
||||
ceDrawHintBorders( dctx, xprect, hintAtts );
|
||||
} /* ce_draw_drawBoardArrow */
|
||||
|
@ -1600,18 +1772,15 @@ DRAW_FUNC_NAME(destroyCtxt)( DrawCtx* p_dctx )
|
|||
for ( ii = 0; ii < CE_NUM_COLORS; ++ii ) {
|
||||
DeleteObject( dctx->brushes[ii] );
|
||||
#ifdef DRAW_FOCUS_FRAME
|
||||
if ( !!dctx->pens[ii].pen ) {
|
||||
DeleteObject( dctx->pens[ii].pen );
|
||||
}
|
||||
ceDeleteObjectNotNull( dctx->pens[ii].pen );
|
||||
#endif
|
||||
}
|
||||
|
||||
for ( ii = 0; ii < VSIZE(dctx->hintPens); ++ii ) {
|
||||
if ( !!dctx->hintPens[ii] ) {
|
||||
DeleteObject( dctx->hintPens[ii] );
|
||||
}
|
||||
ceDeleteObjectNotNull( dctx->hintPens[ii] );
|
||||
}
|
||||
|
||||
ceClearBmCache( dctx );
|
||||
ceClearFontCache( dctx );
|
||||
|
||||
DeleteObject( dctx->rightArrow );
|
||||
|
@ -1631,6 +1800,8 @@ DRAW_FUNC_NAME(dictChanged)( DrawCtx* p_dctx, const DictionaryCtxt* dict )
|
|||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||
XP_ASSERT( !!dict );
|
||||
|
||||
ceClearBmCache( dctx );
|
||||
|
||||
/* If we don't yet have a dict, stick with the cache we have, which is
|
||||
either empty or came from the saved game and likely belong with the
|
||||
dict we're getting now. */
|
||||
|
@ -1699,9 +1870,7 @@ ce_draw_update( CEDrawCtx* dctx )
|
|||
XP_U16 ii;
|
||||
|
||||
for ( ii = 0; ii < CE_NUM_COLORS; ++ii ) {
|
||||
if ( !!dctx->brushes[ii] ) {
|
||||
DeleteObject( dctx->brushes[ii] );
|
||||
}
|
||||
ceDeleteObjectNotNull( dctx->brushes[ii] );
|
||||
dctx->brushes[ii] = CreateSolidBrush(dctx->globals->appPrefs.colors[ii]);
|
||||
}
|
||||
} /* ce_drawctxt_update */
|
||||
|
|
|
@ -1101,7 +1101,7 @@ ceLoadSavedGame( CEAppGlobals* globals )
|
|||
snprintf( buf, VSIZE(buf), "Unable to open dictionary: %s",
|
||||
dictName );
|
||||
buf[VSIZE(buf)-1] = '\0';
|
||||
ceOops( globals, NULL, buf );
|
||||
ceOops( globals, buf );
|
||||
|
||||
}
|
||||
XP_FREE( globals->mpool, dictName );
|
||||
|
@ -1128,7 +1128,7 @@ ceLoadSavedGame( CEAppGlobals* globals )
|
|||
if ( !!dict ) {
|
||||
dict_destroy( dict );
|
||||
}
|
||||
ceOops( globals, NULL, "Saved game cannot be opened." );
|
||||
ceOops( globals, "Saved game cannot be opened." );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2658,7 +2658,7 @@ messageBoxStream( CEAppGlobals* globals, XWStreamCtxt* stream, wchar_t* title,
|
|||
int result;
|
||||
|
||||
assertOnTop( globals->hWnd );
|
||||
result = ceMessageBoxChar( globals, NULL, buf, title, buttons );
|
||||
result = ceMessageBoxChar( globals, buf, title, buttons );
|
||||
|
||||
XP_FREE( globals->mpool, buf );
|
||||
return result;
|
||||
|
@ -2959,7 +2959,7 @@ ce_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
|||
break;
|
||||
}
|
||||
|
||||
ceOops( globals, NULL, message );
|
||||
ceOops( globals, message );
|
||||
} /* ce_util_userError */
|
||||
|
||||
static XP_Bool
|
||||
|
@ -3330,7 +3330,7 @@ ce_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
|||
sprintf( msgBuf, "Word[s] %s not found in dictionary.", wordsBuf );
|
||||
|
||||
if ( turnLost ) {
|
||||
ceMessageBoxChar( globals, NULL, msgBuf, L"Illegal word",
|
||||
ceMessageBoxChar( globals, msgBuf, L"Illegal word",
|
||||
MB_OK | MB_ICONHAND );
|
||||
isOk = XP_TRUE;
|
||||
} else {
|
||||
|
|
|
@ -333,7 +333,7 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
case IDC_CHECKHINTSLIMITS:
|
||||
if ( IS_SMARTPHONE(globals) ) {
|
||||
ceMessageBoxChar( globals, hDlg, "This feature "
|
||||
ceMessageBoxChar( globals, "This feature "
|
||||
"requires a touch screen.",
|
||||
L"Sorry", MB_OK | MB_ICONHAND );
|
||||
ceSetChecked( hDlg, IDC_CHECKHINTSLIMITS, XP_FALSE );
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*- fill-column: 77; c-basic-offset: 4; compile-command: "make TARGET_OS=wince DEBUG=TRUE" -*- */
|
||||
/*
|
||||
* Copyright 2002-2008 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 2002-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
|
||||
|
@ -511,7 +511,6 @@ adjustScrollPos( HWND hDlg, XP_S16 vertChange )
|
|||
|
||||
setScrollPos( hDlg, sinfo.nPos + vertChange );
|
||||
}
|
||||
LOG_RETURN_VOID();
|
||||
} /* adjustScrollPos */
|
||||
|
||||
static XP_Bool
|
||||
|
@ -881,9 +880,10 @@ ceGetPath( CEAppGlobals* globals, CePathType typ,
|
|||
} /* ceGetPath */
|
||||
|
||||
int
|
||||
ceMessageBoxChar( CEAppGlobals* globals, HWND parent, const XP_UCHAR* str,
|
||||
ceMessageBoxChar( CEAppGlobals* XP_UNUSED(globals), const XP_UCHAR* str,
|
||||
const wchar_t* title, XP_U16 buttons )
|
||||
{
|
||||
HWND parent;
|
||||
/* Get the length required, then alloc and go. This is technically
|
||||
correct, but everywhere else I assume a 2:1 ratio for wchar_t:char. */
|
||||
XP_U16 clen = 1 + strlen(str);
|
||||
|
@ -893,15 +893,13 @@ ceMessageBoxChar( CEAppGlobals* globals, HWND parent, const XP_UCHAR* str,
|
|||
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str, clen, widebuf, wlen );
|
||||
|
||||
if ( !parent ) {
|
||||
parent = globals->hWnd;
|
||||
}
|
||||
parent = GetForegroundWindow();
|
||||
return MessageBox( parent, widebuf, title, buttons );
|
||||
} /* ceMessageBoxChar */
|
||||
|
||||
int
|
||||
ceOops( CEAppGlobals* globals, HWND parent, const XP_UCHAR* str )
|
||||
ceOops( CEAppGlobals* globals, const XP_UCHAR* str )
|
||||
{
|
||||
return ceMessageBoxChar( globals, parent, str, L"Oops!",
|
||||
return ceMessageBoxChar( globals, str, L"Oops!",
|
||||
MB_OK | MB_ICONHAND );
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ void ceCheckMenus( const CEAppGlobals* globals );
|
|||
void ceGetItemRect( HWND hDlg, XP_U16 resID, RECT* rect );
|
||||
void ceMoveItem( HWND hDlg, XP_U16 resID, XP_S16 byX, XP_S16 byY );
|
||||
|
||||
int ceMessageBoxChar( CEAppGlobals* globals, HWND parent, const XP_UCHAR* str,
|
||||
int ceMessageBoxChar( CEAppGlobals* globals, const XP_UCHAR* str,
|
||||
const wchar_t* title, XP_U16 buttons );
|
||||
int ceOops( CEAppGlobals* globals, HWND parent, const XP_UCHAR* str );
|
||||
int ceOops( CEAppGlobals* globals, const XP_UCHAR* str );
|
||||
|
||||
typedef enum {
|
||||
PREFS_FILE_PATH_L
|
||||
|
|
Loading…
Reference in a new issue