mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
draw bitmaps larger when will fit; draw hint region border thicker and
in player color; rename constants.
This commit is contained in:
parent
b3d3f80860
commit
de6f6dcdef
3 changed files with 76 additions and 39 deletions
|
@ -96,6 +96,7 @@ struct CEDrawCtx {
|
||||||
|
|
||||||
HBRUSH brushes[CE_NUM_COLORS];
|
HBRUSH brushes[CE_NUM_COLORS];
|
||||||
PenColorPair pens[CE_NUM_COLORS];
|
PenColorPair pens[CE_NUM_COLORS];
|
||||||
|
HGDIOBJ hintPens[MAX_NUM_PLAYERS];
|
||||||
|
|
||||||
FontCacheEntry fcEntry[N_RESIZE_FONTS];
|
FontCacheEntry fcEntry[N_RESIZE_FONTS];
|
||||||
|
|
||||||
|
@ -781,7 +782,7 @@ getPlayerColor( XP_S16 player )
|
||||||
if ( player < 0 ) {
|
if ( player < 0 ) {
|
||||||
return CE_BLACK_COLOR;
|
return CE_BLACK_COLOR;
|
||||||
} else {
|
} else {
|
||||||
return CE_USER_COLOR1 + player;
|
return CE_PLAYER0_COLOR + player;
|
||||||
}
|
}
|
||||||
} /* getPlayerColor */
|
} /* getPlayerColor */
|
||||||
|
|
||||||
|
@ -793,25 +794,40 @@ ceDrawLine( HDC hdc, XP_S32 x1, XP_S32 y1, XP_S32 x2, XP_S32 y2 )
|
||||||
} /* ceDrawLine */
|
} /* ceDrawLine */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ceDrawHintBorders( HDC hdc, const XP_Rect* xprect, HintAtts hintAtts )
|
ceDrawHintBorders( CEDrawCtx* dctx, const XP_Rect* xprect, HintAtts hintAtts )
|
||||||
{
|
{
|
||||||
if ( hintAtts != HINT_BORDER_NONE && hintAtts != HINT_BORDER_CENTER ) {
|
if ( hintAtts != HINT_BORDER_NONE && hintAtts != HINT_BORDER_CENTER ) {
|
||||||
RECT rt;
|
RECT rt;
|
||||||
|
HDC hdc = dctx->globals->hdc;
|
||||||
|
HGDIOBJ pen, oldPen;
|
||||||
|
|
||||||
|
pen = dctx->hintPens[dctx->trayOwner];
|
||||||
|
if ( !pen ) {
|
||||||
|
COLORREF ref = dctx->globals->appPrefs.colors[CE_PLAYER0_COLOR
|
||||||
|
+ dctx->trayOwner];
|
||||||
|
pen = CreatePen( PS_SOLID, 4, ref ); /* 4 must be an even number
|
||||||
|
thx to clipping */
|
||||||
|
dctx->hintPens[dctx->trayOwner] = pen;
|
||||||
|
}
|
||||||
|
|
||||||
XPRtoRECT( &rt, xprect );
|
XPRtoRECT( &rt, xprect );
|
||||||
InsetRect( &rt, 1, 1 );
|
InsetRect( &rt, 1, 1 );
|
||||||
|
|
||||||
|
oldPen = SelectObject( hdc, pen );
|
||||||
|
|
||||||
if ( (hintAtts & HINT_BORDER_LEFT) != 0 ) {
|
if ( (hintAtts & HINT_BORDER_LEFT) != 0 ) {
|
||||||
ceDrawLine( hdc, rt.left, rt.top, rt.left, rt.bottom+1 );
|
ceDrawLine( hdc, rt.left+1, rt.top, rt.left+1, rt.bottom+1 );
|
||||||
}
|
}
|
||||||
if ( (hintAtts & HINT_BORDER_RIGHT) != 0 ) {
|
if ( (hintAtts & HINT_BORDER_RIGHT) != 0 ) {
|
||||||
ceDrawLine( hdc, rt.right, rt.top, rt.right, rt.bottom+1 );
|
ceDrawLine( hdc, rt.right, rt.top, rt.right, rt.bottom+1 );
|
||||||
}
|
}
|
||||||
if ( (hintAtts & HINT_BORDER_TOP) != 0 ) {
|
if ( (hintAtts & HINT_BORDER_TOP) != 0 ) {
|
||||||
ceDrawLine( hdc, rt.left, rt.top, rt.right+1, rt.top );
|
ceDrawLine( hdc, rt.left, rt.top+1, rt.right+1, rt.top+1 );
|
||||||
}
|
}
|
||||||
if ( (hintAtts & HINT_BORDER_BOTTOM) != 0 ) {
|
if ( (hintAtts & HINT_BORDER_BOTTOM) != 0 ) {
|
||||||
ceDrawLine( hdc, rt.left, rt.bottom, rt.right+1, rt.bottom );
|
ceDrawLine( hdc, rt.left, rt.bottom, rt.right+1, rt.bottom );
|
||||||
}
|
}
|
||||||
|
(void)SelectObject( hdc, oldPen );
|
||||||
}
|
}
|
||||||
} /* ceDrawHintBorders */
|
} /* ceDrawHintBorders */
|
||||||
|
|
||||||
|
@ -867,7 +883,7 @@ DRAW_FUNC_NAME(drawCell)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
} else if ( bonus == BONUS_NONE ) {
|
} else if ( bonus == BONUS_NONE ) {
|
||||||
bkIndex = CE_BKG_COLOR;
|
bkIndex = CE_BKG_COLOR;
|
||||||
} else {
|
} else {
|
||||||
bkIndex = (bonus - BONUS_DOUBLE_LETTER) + CE_BONUS1_COLOR;
|
bkIndex = (bonus - BONUS_DOUBLE_LETTER) + CE_BONUS0_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isFocussed ) {
|
if ( isFocussed ) {
|
||||||
|
@ -912,11 +928,10 @@ DRAW_FUNC_NAME(drawCell)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
makeAndDrawBitmap( dctx, hdc, &rt, XP_TRUE,
|
makeAndDrawBitmap( dctx, hdc, &rt, XP_TRUE,
|
||||||
foreColorIndx, (CEBitmapInfo*)bitmap );
|
foreColorIndx, (CEBitmapInfo*)bitmap );
|
||||||
} else if ( (flags&CELL_ISSTAR) != 0 ) {
|
} else if ( (flags&CELL_ISSTAR) != 0 ) {
|
||||||
InsetRect( &textRect, 1, 1 );
|
|
||||||
ceDrawBitmapInRect( hdc, &textRect, dctx->origin );
|
ceDrawBitmapInRect( hdc, &textRect, dctx->origin );
|
||||||
}
|
}
|
||||||
|
|
||||||
ceDrawHintBorders( hdc, xprect, hintAtts );
|
ceDrawHintBorders( dctx, xprect, hintAtts );
|
||||||
|
|
||||||
SelectObject( hdc, oldFont );
|
SelectObject( hdc, oldFont );
|
||||||
|
|
||||||
|
@ -1040,7 +1055,7 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
SelectObject( hdc, oldFont );
|
SelectObject( hdc, oldFont );
|
||||||
} else if ( !!bitmap ) {
|
} else if ( !!bitmap ) {
|
||||||
RECT lrt = rt;
|
RECT lrt = rt;
|
||||||
XP_U16 tmp = CE_USER_COLOR1+dctx->trayOwner;
|
XP_U16 tmp = CE_PLAYER0_COLOR+dctx->trayOwner;
|
||||||
++lrt.left;
|
++lrt.left;
|
||||||
lrt.top += 4;
|
lrt.top += 4;
|
||||||
makeAndDrawBitmap( dctx, hdc, &lrt, XP_FALSE,
|
makeAndDrawBitmap( dctx, hdc, &lrt, XP_FALSE,
|
||||||
|
@ -1111,7 +1126,7 @@ DRAW_FUNC_NAME(drawTrayDivider)( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
if ( selected ) {
|
if ( selected ) {
|
||||||
Rectangle( hdc, rt.left, rt.top, rt.right, rt.bottom );
|
Rectangle( hdc, rt.left, rt.top, rt.right, rt.bottom );
|
||||||
} else {
|
} else {
|
||||||
FillRect( hdc, &rt, dctx->brushes[dctx->trayOwner+CE_USER_COLOR1] );
|
FillRect( hdc, &rt, dctx->brushes[dctx->trayOwner+CE_PLAYER0_COLOR] );
|
||||||
}
|
}
|
||||||
} /* ce_draw_drawTrayDivider */
|
} /* ce_draw_drawTrayDivider */
|
||||||
|
|
||||||
|
@ -1127,19 +1142,19 @@ ceClearToBkground( CEDrawCtx* dctx, const XP_Rect* rect )
|
||||||
FillRect( hdc, &rt, dctx->brushes[CE_BKG_COLOR] );
|
FillRect( hdc, &rt, dctx->brushes[CE_BKG_COLOR] );
|
||||||
} /* ceClearToBkground */
|
} /* ceClearToBkground */
|
||||||
|
|
||||||
|
/* Draw bitmap in rect. Use StretchBlt to fit it to the rect, but don't
|
||||||
|
* change the proportions.
|
||||||
|
*/
|
||||||
static void
|
static void
|
||||||
ceDrawBitmapInRect( HDC hdc, const RECT* rect, HBITMAP bitmap )
|
ceDrawBitmapInRect( HDC hdc, const RECT* rect, HBITMAP bitmap )
|
||||||
{
|
{
|
||||||
BITMAP bmp;
|
BITMAP bmp;
|
||||||
HDC tmpDC;
|
|
||||||
int nBytes;
|
int nBytes;
|
||||||
int x = rect->left;
|
int left = rect->left;
|
||||||
int y = rect->top;
|
int top = rect->top;
|
||||||
|
XP_U16 width = rect->right - left;
|
||||||
tmpDC = CreateCompatibleDC( hdc );
|
XP_U16 height = rect->bottom - top;
|
||||||
SelectObject( tmpDC, bitmap );
|
XP_U16 ii;
|
||||||
|
|
||||||
(void)IntersectClipRect( tmpDC, x, y, rect->right, rect->bottom );
|
|
||||||
|
|
||||||
nBytes = GetObject( bitmap, sizeof(bmp), &bmp );
|
nBytes = GetObject( bitmap, sizeof(bmp), &bmp );
|
||||||
XP_ASSERT( nBytes > 0 );
|
XP_ASSERT( nBytes > 0 );
|
||||||
|
@ -1147,13 +1162,29 @@ ceDrawBitmapInRect( HDC hdc, const RECT* rect, HBITMAP bitmap )
|
||||||
logLastError( "ceDrawBitmapInRect:GetObject" );
|
logLastError( "ceDrawBitmapInRect:GetObject" );
|
||||||
}
|
}
|
||||||
|
|
||||||
x += ((rect->right - x) - bmp.bmWidth) / 2;
|
for ( ii = 1;
|
||||||
y += ((rect->bottom - y) - bmp.bmHeight) / 2;
|
((bmp.bmWidth * ii) <= width) && ((bmp.bmHeight * ii) <= height);
|
||||||
|
++ii ) {
|
||||||
|
/* do nothing */
|
||||||
|
}
|
||||||
|
|
||||||
BitBlt( hdc, x, y, bmp.bmWidth, bmp.bmHeight,
|
XP_ASSERT( ii > 1 );
|
||||||
tmpDC, 0, 0, SRCCOPY ); /* BLACKNESS */
|
if ( --ii > 0 ) {
|
||||||
|
HDC 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 );
|
DeleteDC( tmpDC );
|
||||||
|
}
|
||||||
} /* ceDrawBitmapInRect */
|
} /* ceDrawBitmapInRect */
|
||||||
|
|
||||||
DLSTATIC void
|
DLSTATIC void
|
||||||
|
@ -1188,7 +1219,7 @@ DRAW_FUNC_NAME(drawBoardArrow)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
} else if ( cursorBonus == BONUS_NONE ) {
|
} else if ( cursorBonus == BONUS_NONE ) {
|
||||||
bkIndex = CE_BKG_COLOR;
|
bkIndex = CE_BKG_COLOR;
|
||||||
} else {
|
} else {
|
||||||
bkIndex = cursorBonus - BONUS_DOUBLE_LETTER + CE_BONUS1_COLOR;
|
bkIndex = cursorBonus - BONUS_DOUBLE_LETTER + CE_BONUS0_COLOR;
|
||||||
}
|
}
|
||||||
FillRect( hdc, &rt, dctx->brushes[bkIndex] );
|
FillRect( hdc, &rt, dctx->brushes[bkIndex] );
|
||||||
SetBkColor( hdc, dctx->globals->appPrefs.colors[bkIndex] );
|
SetBkColor( hdc, dctx->globals->appPrefs.colors[bkIndex] );
|
||||||
|
@ -1196,7 +1227,7 @@ DRAW_FUNC_NAME(drawBoardArrow)( DrawCtx* p_dctx, const XP_Rect* xprect,
|
||||||
|
|
||||||
ceDrawBitmapInRect( hdc, &rt, cursor );
|
ceDrawBitmapInRect( hdc, &rt, cursor );
|
||||||
|
|
||||||
ceDrawHintBorders( hdc, xprect, hintAtts );
|
ceDrawHintBorders( dctx, xprect, hintAtts );
|
||||||
} /* ce_draw_drawBoardArrow */
|
} /* ce_draw_drawBoardArrow */
|
||||||
|
|
||||||
DLSTATIC void
|
DLSTATIC void
|
||||||
|
@ -1599,13 +1630,19 @@ DRAW_FUNC_NAME(drawMiniWindow)( DrawCtx* p_dctx, const XP_UCHAR* text,
|
||||||
DLSTATIC void
|
DLSTATIC void
|
||||||
DRAW_FUNC_NAME(destroyCtxt)( DrawCtx* p_dctx )
|
DRAW_FUNC_NAME(destroyCtxt)( DrawCtx* p_dctx )
|
||||||
{
|
{
|
||||||
XP_U16 i;
|
XP_U16 ii;
|
||||||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||||
|
|
||||||
for ( i = 0; i < CE_NUM_COLORS; ++i ) {
|
for ( ii = 0; ii < CE_NUM_COLORS; ++ii ) {
|
||||||
DeleteObject( dctx->brushes[i] );
|
DeleteObject( dctx->brushes[ii] );
|
||||||
if ( !!dctx->pens[i].pen ) {
|
if ( !!dctx->pens[ii].pen ) {
|
||||||
DeleteObject( dctx->pens[i].pen );
|
DeleteObject( dctx->pens[ii].pen );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( ii = 0; ii < VSIZE(dctx->hintPens); ++ii ) {
|
||||||
|
if ( !!dctx->hintPens[ii] ) {
|
||||||
|
DeleteObject( dctx->hintPens[ii] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -962,10 +962,10 @@ canUpdatePrefs( CEAppGlobals* globals, HANDLE fileH, XP_U16 curVersion,
|
||||||
|
|
||||||
XP_MEMCPY( &prefs->colors[0], &oldPrefs.colors[0],
|
XP_MEMCPY( &prefs->colors[0], &oldPrefs.colors[0],
|
||||||
CE_FOCUS_COLOR*sizeof(prefs->colors[0]));
|
CE_FOCUS_COLOR*sizeof(prefs->colors[0]));
|
||||||
XP_ASSERT( CE_USER_COLOR1 - 1 == CE_FOCUS_COLOR );
|
XP_ASSERT( CE_PLAYER0_COLOR - 1 == CE_FOCUS_COLOR );
|
||||||
XP_MEMCPY( &prefs->colors[CE_USER_COLOR1],
|
XP_MEMCPY( &prefs->colors[CE_PLAYER0_COLOR],
|
||||||
&oldPrefs.colors[CE_FOCUS_COLOR],
|
&oldPrefs.colors[CE_FOCUS_COLOR],
|
||||||
(CE_NUM_COLORS-CE_USER_COLOR1)
|
(CE_NUM_COLORS-CE_PLAYER0_COLOR)
|
||||||
* sizeof(prefs->colors[0]));
|
* sizeof(prefs->colors[0]));
|
||||||
success = XP_TRUE;
|
success = XP_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -58,20 +58,20 @@ typedef enum {
|
||||||
# define IS_SMARTPHONE(g) ((g) != (g)) /* make compiler warnings go away */
|
# define IS_SMARTPHONE(g) ((g) != (g)) /* make compiler warnings go away */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum { CE_BONUS1_COLOR,
|
enum { CE_BONUS0_COLOR,
|
||||||
|
CE_BONUS1_COLOR,
|
||||||
CE_BONUS2_COLOR,
|
CE_BONUS2_COLOR,
|
||||||
CE_BONUS3_COLOR,
|
CE_BONUS3_COLOR,
|
||||||
CE_BONUS4_COLOR,
|
|
||||||
|
|
||||||
CE_BKG_COLOR,
|
CE_BKG_COLOR,
|
||||||
CE_TILEBACK_COLOR,
|
CE_TILEBACK_COLOR,
|
||||||
|
|
||||||
CE_FOCUS_COLOR,
|
CE_FOCUS_COLOR,
|
||||||
|
|
||||||
CE_USER_COLOR1,
|
CE_PLAYER0_COLOR,
|
||||||
CE_USER_COLOR2,
|
CE_PLAYER1_COLOR,
|
||||||
CE_USER_COLOR3,
|
CE_PLAYER2_COLOR,
|
||||||
CE_USER_COLOR4,
|
CE_PLAYER3_COLOR,
|
||||||
|
|
||||||
CE_BLACK_COLOR, /* not editable by users */
|
CE_BLACK_COLOR, /* not editable by users */
|
||||||
CE_WHITE_COLOR,
|
CE_WHITE_COLOR,
|
||||||
|
|
Loading…
Reference in a new issue