use clipping when drawing bitmaps, can center 'em. This fixes

overwriting borders when cells shrink when SIP is visible.
This commit is contained in:
ehouse 2005-06-13 13:32:06 +00:00
parent c787f05711
commit 215885af76

View file

@ -33,8 +33,7 @@
#include "cedefines.h" #include "cedefines.h"
static void ceClearToBkground( CEDrawCtx* dctx, XP_Rect* rect ); static void ceClearToBkground( CEDrawCtx* dctx, XP_Rect* rect );
static void ceDrawBitmapInRect( HDC hdc, XP_U32 x, XP_U32 y, static void ceDrawBitmapInRect( HDC hdc, const RECT* r, HBITMAP bitmap );
HBITMAP bitmap );
static void static void
@ -240,7 +239,7 @@ ce_draw_drawCell( DrawCtx* p_dctx, XP_Rect* xprect,
makeAndDrawBitmap( dctx, hdc, textRect.left + 2, textRect.top + 2, makeAndDrawBitmap( dctx, hdc, textRect.left + 2, textRect.top + 2,
foreColorRef, (CEBitmapInfo*)bitmap ); foreColorRef, (CEBitmapInfo*)bitmap );
} else if ( isStar ) { } else if ( isStar ) {
ceDrawBitmapInRect( hdc, textRect.left+2, textRect.top+1, dctx->origin ); ceDrawBitmapInRect( hdc, &textRect, dctx->origin );
} }
ceDrawHintBorders( hdc, xprect, hintAtts ); ceDrawHintBorders( hdc, xprect, hintAtts );
@ -388,21 +387,28 @@ ce_draw_clearRect( DrawCtx* p_dctx, XP_Rect* rectP )
} /* ce_draw_clearRect */ } /* ce_draw_clearRect */
static void static void
ceDrawBitmapInRect( HDC hdc, XP_U32 x, XP_U32 y, HBITMAP bitmap ) ceDrawBitmapInRect( HDC hdc, const RECT* rect, HBITMAP bitmap )
{ {
BITMAP bmp; BITMAP bmp;
HDC tmpDC; HDC tmpDC;
int nBytes; int nBytes;
int x = rect->left;
int y = rect->top;
tmpDC = CreateCompatibleDC( hdc ); tmpDC = CreateCompatibleDC( hdc );
SelectObject( tmpDC, bitmap ); SelectObject( tmpDC, bitmap );
(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 );
if ( nBytes == 0 ) { if ( nBytes == 0 ) {
logLastError( "ceDrawBitmapInRect:GetObject" ); logLastError( "ceDrawBitmapInRect:GetObject" );
} }
x += ((rect->right - x) - bmp.bmWidth) / 2;
y += ((rect->bottom - y) - bmp.bmHeight) / 2;
BitBlt( hdc, x, y, bmp.bmWidth, bmp.bmHeight, BitBlt( hdc, x, y, bmp.bmWidth, bmp.bmHeight,
tmpDC, 0, 0, SRCCOPY ); /* BLACKNESS */ tmpDC, 0, 0, SRCCOPY ); /* BLACKNESS */
@ -443,7 +449,7 @@ ce_draw_drawBoardArrow( DrawCtx* p_dctx, XP_Rect* xprect,
SetBkColor( hdc, dctx->globals->appPrefs.colors[bkIndex] ); SetBkColor( hdc, dctx->globals->appPrefs.colors[bkIndex] );
SetTextColor( hdc, dctx->globals->appPrefs.colors[BLACK_COLOR] ); SetTextColor( hdc, dctx->globals->appPrefs.colors[BLACK_COLOR] );
ceDrawBitmapInRect( hdc, rt.left+2, rt.top+1, cursor ); ceDrawBitmapInRect( hdc, &rt, cursor );
ceDrawHintBorders( hdc, xprect, hintAtts ); ceDrawHintBorders( hdc, xprect, hintAtts );
} /* ce_draw_drawBoardArrow */ } /* ce_draw_drawBoardArrow */