more progress on hires: fix miniwindow; start fixing tray tiles

This commit is contained in:
ehouse 2004-03-17 04:57:09 +00:00
parent 733ef9aa24
commit 70eb614c93

View file

@ -56,30 +56,25 @@ static void palm_draw_drawMiniWindow( DrawCtx* p_dctx, unsigned char* text,
#define HIGHRES_PUSH_LOC( dctx ) \ #define HIGHRES_PUSH_LOC( dctx ) \
{ \ { \
XP_U16 oldVal = 0; \ XP_U16 oldVal = 0; \
XP_LOGF( "HIGHRES_PUSH_LOC line %d", __LINE__ ); \
if ( (dctx)->doHiRes ) { \ if ( (dctx)->doHiRes ) { \
oldVal = WinSetCoordinateSystem( kCoordinatesNative ); \ oldVal = WinSetCoordinateSystem( kCoordinatesNative ); \
} }
#define HIGHRES_POP_LOC(dctx) \ #define HIGHRES_POP_LOC(dctx) \
XP_LOGF( "HIGHRES_POP_LOC line %d", __LINE__ ); \
if ( (dctx)->doHiRes ) { \ if ( (dctx)->doHiRes ) { \
(void)WinSetCoordinateSystem( oldVal ); \ (void)WinSetCoordinateSystem( oldVal ); \
(dctx)->oldCoord = 0; \ (dctx)->oldCoord = 0; \
} \ } \
} }
#define HIGHRES_PUSH_NOPOP( dctx ) \ #define HIGHRES_PUSH_NOPOP( dctx ) \
XP_LOGF( "HIGHRES_PUSH_NOPOP line %d", __LINE__ ); \
if ( (dctx)->doHiRes ) { \ if ( (dctx)->doHiRes ) { \
WinSetCoordinateSystem( kCoordinatesNative ); \ WinSetCoordinateSystem( kCoordinatesNative ); \
} }
#define HIGHRES_PUSH( dctx ) \ #define HIGHRES_PUSH( dctx ) \
XP_LOGF( "HIGHRES_PUSH line %d", __LINE__ ); \
if ( (dctx)->doHiRes ) { \ if ( (dctx)->doHiRes ) { \
XP_ASSERT( (dctx)->oldCoord == 0 ); \ XP_ASSERT( (dctx)->oldCoord == 0 ); \
(dctx)->oldCoord = WinSetCoordinateSystem( kCoordinatesNative ); \ (dctx)->oldCoord = WinSetCoordinateSystem( kCoordinatesNative ); \
} }
#define HIGHRES_POP(dctx) \ #define HIGHRES_POP(dctx) \
XP_LOGF( "HIGHRES_POP line %d", __LINE__ ); \
if ( (dctx)->doHiRes ) { \ if ( (dctx)->doHiRes ) { \
(void)WinSetCoordinateSystem( (dctx)->oldCoord ); \ (void)WinSetCoordinateSystem( (dctx)->oldCoord ); \
(dctx)->oldCoord = 0; \ (dctx)->oldCoord = 0; \
@ -418,13 +413,18 @@ palm_draw_drawTile( DrawCtx* p_dctx, XP_Rect* rect,
XP_Rect localR = *rect; XP_Rect localR = *rect;
XP_U16 len, width; XP_U16 len, width;
WinHandle numberWin = dctx->numberWin; WinHandle numberWin = dctx->numberWin;
XP_U16 doubler = 1;
#ifdef FEATURE_HIGHRES
if ( dctx->doHiRes ) {
doubler = 2;
}
#endif
draw_clearRect( p_dctx, &localR ); draw_clearRect( p_dctx, &localR );
localR.width -= 3; localR.width -= 3 * doubler;
localR.height -= 3; localR.height -= 3 * doubler;
localR.top += 2; localR.top += 2 * doubler;
localR.left += 2; localR.left += 2 * doubler;
/* this will fill it with the tile background color */ /* this will fill it with the tile background color */
WinEraseRectangle( (const RectangleType*)&localR, 0 ); WinEraseRectangle( (const RectangleType*)&localR, 0 );
@ -434,19 +434,21 @@ palm_draw_drawTile( DrawCtx* p_dctx, XP_Rect* rect,
FontID curFont = FntGetFont(); FontID curFont = FntGetFont();
FntSetFont( largeFont ); FntSetFont( largeFont );
#ifdef TILE_SUBSCRIPT #ifdef TILE_SUBSCRIPT
WinDrawChars( (const char*)letters, 1, localR.left+2, WinDrawChars( (const char*)letters, doubler,
rect->top+2 ); localR.left+(2*doubler),
rect->top+(2*doubler) );
#else #else
WinDrawChars( letters, 1, localR.left+2, rect->top+7 ); WinDrawChars( letters, 1, localR.left+2, rect->top+7 );
#endif #endif
FntSetFont( curFont ); FntSetFont( curFont );
} }
} else if ( !!bitmap ) { } else if ( !!bitmap ) {
WinDrawBitmap( (BitmapPtr)bitmap, localR.left+2, localR.top+2 ); WinDrawBitmap( (BitmapPtr)bitmap, localR.left+(2*doubler),
localR.top+(2*doubler) );
} }
if ( val >= 0 ) { if ( val >= 0 ) {
RectangleType numRect = {{0,0}, {NUMRECT_WIDTH, NUMRECT_HEIGHT}}; RectangleType numRect = {{0,0}, {NUMRECT_WIDTH*2, NUMRECT_HEIGHT*2}};
WinHandle curWind; WinHandle curWind;
(void)StrPrintF( valBuf, "%d", val ); (void)StrPrintF( valBuf, "%d", val );
@ -458,14 +460,15 @@ palm_draw_drawTile( DrawCtx* p_dctx, XP_Rect* rect,
WinEraseRectangle( &numRect, 0 ); WinEraseRectangle( &numRect, 0 );
WinDrawChars( valBuf, len, 0, 0 ); WinDrawChars( valBuf, len, 0, 0 );
width = FntCharsWidth( valBuf, len ); width = FntCharsWidth( valBuf, len );
XP_LOGF( "width=%d", width );
(void)WinSetDrawWindow( curWind ); (void)WinSetDrawWindow( curWind );
numRect.extent.x = width; numRect.extent.x = width;
#ifdef TILE_SUBSCRIPT #ifdef TILE_SUBSCRIPT
WinCopyRectangle( numberWin, 0, &numRect, WinCopyRectangle( numberWin, 0, &numRect,
localR.left + localR.width - width, localR.left + localR.width - width,
localR.top + localR.height - 10, localR.top + localR.height - (10*doubler),
winOverlay ); winOverlay );
#else #else
WinCopyRectangle( numberWin, 0, &numRect, WinCopyRectangle( numberWin, 0, &numRect,
@ -974,26 +977,35 @@ palm_draw_getMiniWText( DrawCtx* p_dctx, XWMiniTextType textHint )
} /* palm_draw_getMiniWText */ } /* palm_draw_getMiniWText */
#define VALUE_HINT_RECT_HEIGHT 16 #define VALUE_HINT_RECT_HEIGHT 16
#define VALUE_HINT_RECT_HEIGHT_HR 29
static void static void
palm_draw_measureMiniWText( DrawCtx* p_dctx, unsigned char* str, palm_draw_measureMiniWText( DrawCtx* p_dctx, unsigned char* str,
XP_U16* widthP, XP_U16* heightP ) XP_U16* widthP, XP_U16* heightP )
{ {
HIGHRES_PUSH_LOC( (PalmDrawCtx*)p_dctx ); PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
HIGHRES_PUSH_LOC( dctx );
/* PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; */ /* PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; */
FntSetFont( stdFont ); FntSetFont( stdFont );
/* 8 stolen from xwords.c*/ /* 8 stolen from xwords.c*/
*widthP = FntCharsWidth( (const char*)str, *widthP = FntCharsWidth( (const char*)str,
XP_STRLEN((const char*)str) ) + 8; XP_STRLEN((const char*)str) ) + 8;
*heightP = VALUE_HINT_RECT_HEIGHT; if ( 0 ) {
#ifdef FEATURE_HIGHRES
} else if ( dctx->doHiRes ) {
*heightP = VALUE_HINT_RECT_HEIGHT_HR;
#endif
} else {
*heightP = VALUE_HINT_RECT_HEIGHT;
}
HIGHRES_POP_LOC( (PalmDrawCtx*)p_dctx ); HIGHRES_POP_LOC( (PalmDrawCtx*)p_dctx );
} /* palm_draw_measureMiniWText */ } /* palm_draw_measureMiniWText */
typedef struct MiniWinData { typedef struct PalmMiniWinData {
WinHandle bitsBehind; WinHandle bitsBehind;
XP_S16 miniX; XP_S16 miniX;
XP_S16 miniY; XP_S16 miniY;
} MiniWinData; } PalmMiniWinData;
static void static void
palm_draw_drawMiniWindow( DrawCtx* p_dctx, unsigned char* text, palm_draw_drawMiniWindow( DrawCtx* p_dctx, unsigned char* text,
@ -1002,7 +1014,7 @@ palm_draw_drawMiniWindow( DrawCtx* p_dctx, unsigned char* text,
RectangleType localR = *(RectangleType*)rect; RectangleType localR = *(RectangleType*)rect;
XP_U16 ignoreErr; XP_U16 ignoreErr;
XP_Bool hasClosure = !!closureP; XP_Bool hasClosure = !!closureP;
MiniWinData* data = (MiniWinData*)(hasClosure? *closureP: NULL); PalmMiniWinData* data = (PalmMiniWinData*)(hasClosure? *closureP: NULL);
#ifdef MEM_DEBUG #ifdef MEM_DEBUG
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
#endif #endif
@ -1011,8 +1023,12 @@ palm_draw_drawMiniWindow( DrawCtx* p_dctx, unsigned char* text,
if ( hasClosure ) { if ( hasClosure ) {
if ( !data ) { if ( !data ) {
data = XP_MALLOC( dctx->mpool, sizeof(MiniWinData) ); data = XP_MALLOC( dctx->mpool, sizeof(PalmMiniWinData) );
#ifdef FEATURE_HIGHRES
data->bitsBehind = WinSaveBits( &localR, &ignoreErr ); data->bitsBehind = WinSaveBits( &localR, &ignoreErr );
#else
data->bitsBehind = NULL;
#endif
data->miniX = localR.topLeft.x; data->miniX = localR.topLeft.x;
data->miniY = localR.topLeft.y; data->miniY = localR.topLeft.y;
*closureP = data; *closureP = data;
@ -1038,21 +1054,21 @@ static void
palm_draw_eraseMiniWindow( DrawCtx* p_dctx, XP_Rect* rect, XP_Bool lastTime, palm_draw_eraseMiniWindow( DrawCtx* p_dctx, XP_Rect* rect, XP_Bool lastTime,
void** closure, XP_Bool* invalUnder ) void** closure, XP_Bool* invalUnder )
{ {
#ifdef FEATURE_HIGHRES PalmMiniWinData* data = (PalmMiniWinData*)*closure;
*invalUnder = XP_TRUE; /* cop out (for now) */
#else
MiniWinData* data = *closure;
# ifdef DEBUG # ifdef DEBUG
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
# endif # endif
if ( !!closure && !!*closure ) { if ( !!closure && !!*closure ) {
#ifdef FEATURE_HIGHRES
*invalUnder = XP_TRUE; /* cop out (for now) */
#else
/* this DELETES data->bitsBehind */ /* this DELETES data->bitsBehind */
WinRestoreBits( data->bitsBehind, data->miniX, data->miniY ); WinRestoreBits( data->bitsBehind, data->miniX, data->miniY );
#endif
XP_FREE( dctx->mpool, data ); XP_FREE( dctx->mpool, data );
*closure = NULL; *closure = NULL;
} }
#endif
} /* palm_draw_eraseMiniWindow */ } /* palm_draw_eraseMiniWindow */
static void static void
@ -1067,6 +1083,7 @@ palm_drawctxt_make( MPFORMAL GraphicsAbility able,
{ {
PalmDrawCtx* dctx; PalmDrawCtx* dctx;
XP_U16 i; XP_U16 i;
XP_U16 nWinWidth, nWinHeight;
Err ignore; Err ignore;
dctx = XP_MALLOC( mpool, sizeof(PalmDrawCtx) ); dctx = XP_MALLOC( mpool, sizeof(PalmDrawCtx) );
@ -1141,7 +1158,15 @@ palm_drawctxt_make( MPFORMAL GraphicsAbility able,
SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, palm_bnw ); SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, palm_bnw );
} }
dctx->numberWin = WinCreateOffscreenWindow( NUMRECT_WIDTH, NUMRECT_HEIGHT, nWinWidth = NUMRECT_WIDTH;
nWinHeight = NUMRECT_HEIGHT;
#ifdef FEATURE_HIGHRES
if ( dctx->doHiRes ) {
nWinWidth *= 2;
nWinHeight *= 2;
}
#endif
dctx->numberWin = WinCreateOffscreenWindow( nWinWidth, nWinHeight,
screenFormat, &ignore ); screenFormat, &ignore );
if ( able == COLOR ) { if ( able == COLOR ) {