mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-11 08:48:06 +01:00
Use minimum height for tile value; draw bitmaps (clipped) even if too large.
This commit is contained in:
parent
ca53a3a74c
commit
1dd8363c3f
1 changed files with 35 additions and 25 deletions
|
@ -710,31 +710,38 @@ drawTextLines( CEDrawCtx* dctx, HDC hdc, const XP_UCHAR* text, XP_S16 padding,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ceGetCharValHts( const CEDrawCtx* dctx, const XP_Rect* xprect,
|
ceGetCharValHts( const CEDrawCtx* dctx, const XP_Rect* xprect,
|
||||||
XP_U16* charHt, XP_U16* valHt )
|
XP_U16* charHtP, XP_U16* valHtP )
|
||||||
{
|
{
|
||||||
XP_U16 visHt = xprect->height - TRAY_BORDER;
|
XP_U16 visHt = xprect->height - TRAY_BORDER;
|
||||||
XP_U16 visWidth = xprect->width - 5; /* ??? */
|
XP_U16 visWidth = xprect->width - 5; /* ??? */
|
||||||
XP_U16 minHt;
|
XP_U16 minHt;
|
||||||
|
XP_U16 charHt, valHt;
|
||||||
|
|
||||||
/* if tiles are wider than tall we can let them overlap vertically */
|
/* if tiles are wider than tall we can let them overlap vertically */
|
||||||
if ( visWidth > visHt ) {
|
if ( visWidth > visHt ) {
|
||||||
if ( visWidth > (visHt*2) ) {
|
if ( visWidth > (visHt*2) ) {
|
||||||
*charHt = visHt;
|
charHt = visHt;
|
||||||
*valHt = (3*visHt) / 4;
|
valHt = (3*visHt) / 4;
|
||||||
} else {
|
} else {
|
||||||
*charHt = (visHt * 4) / 5;
|
charHt = (visHt * 4) / 5;
|
||||||
*valHt = visHt / 2;
|
valHt = visHt / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
*valHt = visHt / 3;
|
valHt = visHt / 3;
|
||||||
*charHt = visHt - *valHt;
|
charHt = visHt - valHt;
|
||||||
}
|
}
|
||||||
|
|
||||||
minHt = dctx->globals->cellHt - CELL_BORDER;
|
minHt = dctx->globals->cellHt - CELL_BORDER;
|
||||||
if ( *charHt < minHt ) {
|
if ( charHt < minHt ) {
|
||||||
*charHt = minHt;
|
charHt = minHt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( valHt < MIN_CELL_HEIGHT - CELL_BORDER - 2 ) {
|
||||||
|
valHt = MIN_CELL_HEIGHT - CELL_BORDER - 2;
|
||||||
|
}
|
||||||
|
*valHtP = valHt;
|
||||||
|
*charHtP = charHt;
|
||||||
/* XP_LOGF( "%s(width:%d, height:%d)=>char: %d, val:%d", __func__, */
|
/* XP_LOGF( "%s(width:%d, height:%d)=>char: %d, val:%d", __func__, */
|
||||||
/* xprect->width, xprect->height, *charHt, *valHt ); */
|
/* xprect->width, xprect->height, *charHt, *valHt ); */
|
||||||
} /* ceGetCharValHts */
|
} /* ceGetCharValHts */
|
||||||
|
@ -1155,6 +1162,7 @@ ceDrawBitmapInRect( HDC hdc, const RECT* rect, HBITMAP bitmap )
|
||||||
XP_U16 width = rect->right - left;
|
XP_U16 width = rect->right - left;
|
||||||
XP_U16 height = rect->bottom - top;
|
XP_U16 height = rect->bottom - top;
|
||||||
XP_U16 ii;
|
XP_U16 ii;
|
||||||
|
HDC tmpDC;
|
||||||
|
|
||||||
nBytes = GetObject( bitmap, sizeof(bmp), &bmp );
|
nBytes = GetObject( bitmap, sizeof(bmp), &bmp );
|
||||||
XP_ASSERT( nBytes > 0 );
|
XP_ASSERT( nBytes > 0 );
|
||||||
|
@ -1168,23 +1176,25 @@ ceDrawBitmapInRect( HDC hdc, const RECT* rect, HBITMAP bitmap )
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
}
|
}
|
||||||
|
|
||||||
XP_ASSERT( ii > 1 );
|
if ( --ii == 0 ) {
|
||||||
if ( --ii > 0 ) {
|
XP_LOGF( "%s: cell too small for bitmap", __func__ );
|
||||||
HDC tmpDC = CreateCompatibleDC( hdc );
|
ii = 1;
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 */
|
} /* ceDrawBitmapInRect */
|
||||||
|
|
||||||
DLSTATIC void
|
DLSTATIC void
|
||||||
|
|
Loading…
Add table
Reference in a new issue