mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-13 08:01:33 +01:00
reorder some formal params; provide width so score font isn't
recalculated each time.
This commit is contained in:
parent
6bd1c4be15
commit
e9287fcbbf
1 changed files with 29 additions and 25 deletions
|
@ -521,9 +521,9 @@ ceFillFontInfo( const CEDrawCtx* dctx, LOGFONT* fontInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ceBestFitFont( CEDrawCtx* dctx, const XP_U16 soughtHeight,
|
ceBestFitFont( CEDrawCtx* dctx, RFIndex index,
|
||||||
const XP_U16 soughtWidth, /* pass 0 to ignore width */
|
const XP_U16 soughtWidth, /* pass 0 to ignore width */
|
||||||
RFIndex index, FontCacheEntry* fce )
|
const XP_U16 soughtHeight, FontCacheEntry* fce )
|
||||||
{
|
{
|
||||||
wchar_t widebuf[65];
|
wchar_t widebuf[65];
|
||||||
XP_U16 len, wlen;
|
XP_U16 len, wlen;
|
||||||
|
@ -656,7 +656,7 @@ ceBestFitFont( CEDrawCtx* dctx, const XP_U16 soughtHeight,
|
||||||
} /* ceBestFitFont */
|
} /* ceBestFitFont */
|
||||||
|
|
||||||
static const FontCacheEntry*
|
static const FontCacheEntry*
|
||||||
ceGetSizedFont( CEDrawCtx* dctx, XP_U16 height, XP_U16 width, RFIndex index )
|
ceGetSizedFont( CEDrawCtx* dctx, RFIndex index, XP_U16 width, XP_U16 height )
|
||||||
{
|
{
|
||||||
FontCacheEntry* fce = &dctx->fcEntry[index];
|
FontCacheEntry* fce = &dctx->fcEntry[index];
|
||||||
if ( (0 != height) /* 0 means use what we have */
|
if ( (0 != height) /* 0 means use what we have */
|
||||||
|
@ -664,7 +664,7 @@ ceGetSizedFont( CEDrawCtx* dctx, XP_U16 height, XP_U16 width, RFIndex index )
|
||||||
XP_LOGF( "%s: no match for %s (have %d, want %d (width %d) "
|
XP_LOGF( "%s: no match for %s (have %d, want %d (width %d) "
|
||||||
"so recalculating",
|
"so recalculating",
|
||||||
__func__, RFI2Str(index), fce->indexHt, height, width );
|
__func__, RFI2Str(index), fce->indexHt, height, width );
|
||||||
ceBestFitFont( dctx, height, width, index, fce );
|
ceBestFitFont( dctx, index, width, height, fce );
|
||||||
}
|
}
|
||||||
|
|
||||||
XP_ASSERT( !!fce->setFont );
|
XP_ASSERT( !!fce->setFont );
|
||||||
|
@ -1040,8 +1040,7 @@ DRAW_FUNC_NAME(drawCell)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
ceClipToRect( hdc, &rt );
|
ceClipToRect( hdc, &rt );
|
||||||
|
|
||||||
XP_ASSERT( xprect->height == globals->cellHt );
|
XP_ASSERT( xprect->height == globals->cellHt );
|
||||||
fce = ceGetSizedFont( dctx, xprect->height - CELL_BORDER,
|
fce = ceGetSizedFont( dctx, RFONTS_CELL, 0, xprect->height - CELL_BORDER );
|
||||||
0, RFONTS_CELL );
|
|
||||||
oldFont = SelectObject( hdc, fce->setFont );
|
oldFont = SelectObject( hdc, fce->setFont );
|
||||||
|
|
||||||
/* always init to silence compiler warning */
|
/* always init to silence compiler warning */
|
||||||
|
@ -1215,8 +1214,8 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
}
|
}
|
||||||
|
|
||||||
ceGetCharValHts( dctx, xprect, valHidden, &charHt, &valHt );
|
ceGetCharValHts( dctx, xprect, valHidden, &charHt, &valHt );
|
||||||
fce = ceGetSizedFont( dctx, charHt, 0,
|
fce = ceGetSizedFont( dctx, valHidden ? RFONTS_TRAYNOVAL:RFONTS_TRAY,
|
||||||
valHidden ? RFONTS_TRAYNOVAL:RFONTS_TRAY );
|
0, charHt );
|
||||||
|
|
||||||
if ( !!bitmaps || !!letters ) {
|
if ( !!bitmaps || !!letters ) {
|
||||||
HFONT oldFont = SelectObject( hdc, fce->setFont );
|
HFONT oldFont = SelectObject( hdc, fce->setFont );
|
||||||
|
@ -1246,7 +1245,7 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !valHidden ) {
|
if ( !valHidden ) {
|
||||||
fce = ceGetSizedFont( dctx, valHt, 0, RFONTS_TRAYVAL );
|
fce = ceGetSizedFont( dctx, RFONTS_TRAYVAL, 0, valHt );
|
||||||
HFONT oldFont = SelectObject( hdc, fce->setFont );
|
HFONT oldFont = SelectObject( hdc, fce->setFont );
|
||||||
swprintf( widebuf, L"%d", val );
|
swprintf( widebuf, L"%d", val );
|
||||||
|
|
||||||
|
@ -1449,8 +1448,9 @@ formatRemText( XP_S16 nTilesLeft, XP_UCHAR* buf, XP_U16 bufLen )
|
||||||
XP_SNPRINTF( buf, bufLen, "%d", nTilesLeft );
|
XP_SNPRINTF( buf, bufLen, "%d", nTilesLeft );
|
||||||
} /* formatRemText */
|
} /* formatRemText */
|
||||||
|
|
||||||
static XP_U16
|
static void
|
||||||
scoreFontHt( CEDrawCtx* dctx, const XP_Rect* rect )
|
scoreFontDims( CEDrawCtx* dctx, const XP_Rect* rect,
|
||||||
|
XP_U16* width, XP_U16* height )
|
||||||
{
|
{
|
||||||
XP_U16 fontHt, cellHt;
|
XP_U16 fontHt, cellHt;
|
||||||
fontHt = rect->height;
|
fontHt = rect->height;
|
||||||
|
@ -1464,7 +1464,8 @@ scoreFontHt( CEDrawCtx* dctx, const XP_Rect* rect )
|
||||||
fontHt = cellHt;
|
fontHt = cellHt;
|
||||||
}
|
}
|
||||||
fontHt -= 2; /* for whitespace top and bottom */
|
fontHt -= 2; /* for whitespace top and bottom */
|
||||||
return fontHt;
|
*height = fontHt;
|
||||||
|
*width = rect->width - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
DLSTATIC void
|
DLSTATIC void
|
||||||
|
@ -1478,16 +1479,16 @@ DRAW_FUNC_NAME(measureRemText)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
HDC hdc = globals->hdc;
|
HDC hdc = globals->hdc;
|
||||||
XP_UCHAR buf[4];
|
XP_UCHAR buf[4];
|
||||||
const FontCacheEntry* fce;
|
const FontCacheEntry* fce;
|
||||||
XP_U16 height;
|
XP_U16 width, height;
|
||||||
HFONT oldFont;
|
HFONT oldFont;
|
||||||
|
|
||||||
XP_ASSERT( !!hdc );
|
XP_ASSERT( !!hdc );
|
||||||
|
|
||||||
formatRemText( nTilesLeft, buf, VSIZE(buf) );
|
formatRemText( nTilesLeft, buf, VSIZE(buf) );
|
||||||
|
|
||||||
height = scoreFontHt( dctx, xprect );
|
scoreFontDims( dctx, xprect, &width, &height );
|
||||||
|
|
||||||
fce = ceGetSizedFont( dctx, height, xprect->width - 2, RFONTS_SCORE );
|
fce = ceGetSizedFont( dctx, RFONTS_SCORE, width, height );
|
||||||
oldFont = SelectObject( hdc, fce->setFont );
|
oldFont = SelectObject( hdc, fce->setFont );
|
||||||
ceMeasureText( dctx, hdc, fce, buf, 0, widthP, heightP );
|
ceMeasureText( dctx, hdc, fce, buf, 0, widthP, heightP );
|
||||||
|
|
||||||
|
@ -1499,7 +1500,7 @@ DRAW_FUNC_NAME(measureRemText)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
|
|
||||||
DLSTATIC void
|
DLSTATIC void
|
||||||
DRAW_FUNC_NAME(drawRemText)( DrawCtx* p_dctx, const XP_Rect* rInner,
|
DRAW_FUNC_NAME(drawRemText)( DrawCtx* p_dctx, const XP_Rect* rInner,
|
||||||
const XP_Rect* XP_UNUSED(rOuter),
|
const XP_Rect* rOuter,
|
||||||
XP_S16 nTilesLeft, XP_Bool focussed )
|
XP_S16 nTilesLeft, XP_Bool focussed )
|
||||||
{
|
{
|
||||||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||||
|
@ -1513,15 +1514,16 @@ DRAW_FUNC_NAME(drawRemText)( DrawCtx* p_dctx, const XP_Rect* rInner,
|
||||||
|
|
||||||
formatRemText( nTilesLeft, buf, VSIZE(buf) );
|
formatRemText( nTilesLeft, buf, VSIZE(buf) );
|
||||||
|
|
||||||
XPRtoRECT( &rt, rInner );
|
XPRtoRECT( &rt, rOuter );
|
||||||
|
|
||||||
ceSetTextColor( hdc, dctx, CE_BLACK_COLOR );
|
ceSetTextColor( hdc, dctx, CE_BLACK_COLOR );
|
||||||
bkColor = focussed ? CE_FOCUS_COLOR : CE_TILEBACK_COLOR;
|
bkColor = focussed ? CE_FOCUS_COLOR : CE_TILEBACK_COLOR;
|
||||||
ceSetBkColor( hdc, dctx, bkColor );
|
ceSetBkColor( hdc, dctx, bkColor );
|
||||||
FillRect( hdc, &rt, dctx->brushes[bkColor] );
|
FillRect( hdc, &rt, dctx->brushes[bkColor] );
|
||||||
|
|
||||||
|
XPRtoRECT( &rt, rInner );
|
||||||
InsetRect( &rt, 1, 1 );
|
InsetRect( &rt, 1, 1 );
|
||||||
fce = ceGetSizedFont( dctx, 0, 0, RFONTS_SCORE );
|
fce = ceGetSizedFont( dctx, RFONTS_SCORE, 0, 0 );
|
||||||
oldFont = SelectObject( hdc, fce->setFont );
|
oldFont = SelectObject( hdc, fce->setFont );
|
||||||
|
|
||||||
ceDrawLinesClipped( hdc, fce, buf, CP_ACP, XP_TRUE, &rt );
|
ceDrawLinesClipped( hdc, fce, buf, CP_ACP, XP_TRUE, &rt );
|
||||||
|
@ -1578,16 +1580,18 @@ DRAW_FUNC_NAME(measureScoreText)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
HDC hdc = globals->hdc;
|
HDC hdc = globals->hdc;
|
||||||
HFONT oldFont;
|
HFONT oldFont;
|
||||||
const FontCacheEntry* fce;
|
const FontCacheEntry* fce;
|
||||||
XP_U16 fontHt = scoreFontHt( dctx, xprect );
|
XP_U16 fontWidth, fontHt;
|
||||||
XP_U16 nameLen;
|
XP_U16 nameLen;
|
||||||
XP_U16 targetWidth = xprect->width;
|
XP_U16 targetWidth = xprect->width;
|
||||||
|
|
||||||
|
scoreFontDims( dctx, xprect, &fontWidth, &fontHt );
|
||||||
|
|
||||||
if ( !dctx->scoreIsVertical ) {
|
if ( !dctx->scoreIsVertical ) {
|
||||||
targetWidth -= (SCORE_HPAD * 2);
|
targetWidth -= (SCORE_HPAD * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
fce = ceGetSizedFont( dctx, fontHt, 0,
|
fce = ceGetSizedFont( dctx, dsi->selected ? RFONTS_SCORE_BOLD:RFONTS_SCORE,
|
||||||
dsi->selected ? RFONTS_SCORE_BOLD:RFONTS_SCORE );
|
fontWidth, fontHt );
|
||||||
nameLen = dsi->isTurn? XP_STRLEN(dsi->name) : 0;
|
nameLen = dsi->isTurn? XP_STRLEN(dsi->name) : 0;
|
||||||
oldFont = SelectObject( hdc, fce->setFont );
|
oldFont = SelectObject( hdc, fce->setFont );
|
||||||
|
|
||||||
|
@ -1637,8 +1641,8 @@ DRAW_FUNC_NAME(score_drawPlayer)( DrawCtx* p_dctx,
|
||||||
XP_U16 bkIndex = isFocussed ? CE_FOCUS_COLOR : CE_BKG_COLOR;
|
XP_U16 bkIndex = isFocussed ? CE_FOCUS_COLOR : CE_BKG_COLOR;
|
||||||
const FontCacheEntry* fce;
|
const FontCacheEntry* fce;
|
||||||
|
|
||||||
fce = ceGetSizedFont( dctx, 0, 0,
|
fce = ceGetSizedFont( dctx, dsi->selected ? RFONTS_SCORE_BOLD:RFONTS_SCORE,
|
||||||
dsi->selected ? RFONTS_SCORE_BOLD:RFONTS_SCORE );
|
0, 0 );
|
||||||
|
|
||||||
oldFont = SelectObject( hdc, fce->setFont );
|
oldFont = SelectObject( hdc, fce->setFont );
|
||||||
|
|
||||||
|
@ -1680,7 +1684,7 @@ DRAW_FUNC_NAME(score_pendingScore)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
HFONT oldFont;
|
HFONT oldFont;
|
||||||
XP_U16 spareHt;
|
XP_U16 spareHt;
|
||||||
|
|
||||||
fce = ceGetSizedFont( dctx, xprect->height, xprect->width, RFONTS_PTS );
|
fce = ceGetSizedFont( dctx, RFONTS_PTS, xprect->width, xprect->height );
|
||||||
spareHt = xprect->height - fce->glyphHt;
|
spareHt = xprect->height - fce->glyphHt;
|
||||||
|
|
||||||
oldFont = SelectObject( hdc, fce->setFont );
|
oldFont = SelectObject( hdc, fce->setFont );
|
||||||
|
@ -1722,7 +1726,7 @@ DRAW_FUNC_NAME(drawTimer)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
HFONT oldFont;
|
HFONT oldFont;
|
||||||
const FontCacheEntry* fce;
|
const FontCacheEntry* fce;
|
||||||
|
|
||||||
fce = ceGetSizedFont( dctx, 0, 0, RFONTS_SCORE );
|
fce = ceGetSizedFont( dctx, RFONTS_SCORE, 0, 0 );
|
||||||
|
|
||||||
XPRtoRECT( &rt, xprect );
|
XPRtoRECT( &rt, xprect );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue