2006-11-03 07:23:54 +01:00
|
|
|
|
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make ARCH=68K_ONLY MEMDEBUG=TRUE";-*- */
|
2003-11-16 20:37:12 +01:00
|
|
|
|
/*
|
2007-01-19 09:22:14 +01:00
|
|
|
|
* Copyright 1999 - 2007 by Eric House (xwords@eehouse.org). All rights
|
|
|
|
|
* reserved.
|
2003-11-16 20:37:12 +01:00
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <UIResources.h>
|
|
|
|
|
#include <SystemMgr.h>
|
2006-11-03 07:23:54 +01:00
|
|
|
|
#ifdef XWFEATURE_FIVEWAY
|
|
|
|
|
# include <Hs.h>
|
|
|
|
|
#endif
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
#include "draw.h"
|
2006-11-03 07:23:54 +01:00
|
|
|
|
#include "dbgutil.h"
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
#include "palmmain.h"
|
|
|
|
|
#include "xwords4defines.h"
|
|
|
|
|
#include "LocalizedStrIncludes.h"
|
|
|
|
|
|
2004-11-14 17:19:21 +01:00
|
|
|
|
#define CHARRECT_WIDTH 12
|
|
|
|
|
#define CHARRECT_HEIGHT 14
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
#define FONT_HEIGHT 8
|
|
|
|
|
#define LINE_SPACING 1
|
|
|
|
|
|
2006-10-29 19:24:50 +01:00
|
|
|
|
#define SCORE_SEP ':'
|
|
|
|
|
#define SCORE_SEPSTR ":"
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
#define TILE_SUBSCRIPT 1 /* draw tile with numbers below letters? */
|
|
|
|
|
|
2007-01-19 09:22:14 +01:00
|
|
|
|
/* Let's try both for a while */
|
|
|
|
|
#define DRAW_FOCUS_FRAME 1
|
2007-01-20 05:30:02 +01:00
|
|
|
|
#ifdef DRAW_FOCUS_FRAME
|
|
|
|
|
# define TREAT_AS_CURSOR(d,f) ((((f) & CELL_ISCURSOR) != 0) && !(d)->topFocus )
|
2007-01-21 23:59:29 +01:00
|
|
|
|
# define FOCUS_BORDER_WIDTH 6
|
2007-01-20 05:30:02 +01:00
|
|
|
|
#else
|
|
|
|
|
# define TREAT_AS_CURSOR(d,f) (((f) & CELL_ISCURSOR) != 0)
|
|
|
|
|
#endif
|
2007-01-19 09:22:14 +01:00
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
static XP_Bool palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
|
|
|
|
|
const XP_UCHAR* letters,
|
|
|
|
|
XP_Bitmap bitmap, Tile tile,
|
2003-11-16 20:37:12 +01:00
|
|
|
|
XP_S16 owner, XWBonusType bonus,
|
2006-11-12 15:36:15 +01:00
|
|
|
|
HintAtts hintAtts, CellFlags flags );
|
2006-02-18 07:39:40 +01:00
|
|
|
|
static void palm_bnw_draw_score_drawPlayer( DrawCtx* p_dctx,
|
|
|
|
|
const XP_Rect* rInner,
|
|
|
|
|
const XP_Rect* rOuter,
|
|
|
|
|
const DrawScoreInfo* dsi );
|
|
|
|
|
static XP_Bool palm_bnw_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect,
|
2006-11-03 07:23:54 +01:00
|
|
|
|
XP_U16 owner, DrawFocusState dfs );
|
2006-02-18 07:39:40 +01:00
|
|
|
|
static void palm_clr_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP );
|
|
|
|
|
static void palm_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
|
|
|
|
|
const XP_Rect* rect, void** closureP );
|
2006-11-12 15:36:15 +01:00
|
|
|
|
static void doDrawPlayer( PalmDrawCtx* dctx, const DrawScoreInfo* dsi,
|
|
|
|
|
const XP_Rect* rInner );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2004-03-16 06:25:23 +01:00
|
|
|
|
#define HIGHRES_PUSH_LOC( dctx ) \
|
|
|
|
|
{ \
|
|
|
|
|
XP_U16 oldVal = 0; \
|
|
|
|
|
if ( (dctx)->doHiRes ) { \
|
|
|
|
|
oldVal = WinSetCoordinateSystem( kCoordinatesNative ); \
|
|
|
|
|
}
|
|
|
|
|
#define HIGHRES_POP_LOC(dctx) \
|
|
|
|
|
if ( (dctx)->doHiRes ) { \
|
|
|
|
|
(void)WinSetCoordinateSystem( oldVal ); \
|
|
|
|
|
(dctx)->oldCoord = 0; \
|
|
|
|
|
} \
|
|
|
|
|
}
|
|
|
|
|
#define HIGHRES_PUSH_NOPOP( dctx ) \
|
|
|
|
|
if ( (dctx)->doHiRes ) { \
|
|
|
|
|
WinSetCoordinateSystem( kCoordinatesNative ); \
|
|
|
|
|
}
|
|
|
|
|
#define HIGHRES_PUSH( dctx ) \
|
|
|
|
|
if ( (dctx)->doHiRes ) { \
|
|
|
|
|
XP_ASSERT( (dctx)->oldCoord == 0 ); \
|
|
|
|
|
(dctx)->oldCoord = WinSetCoordinateSystem( kCoordinatesNative ); \
|
|
|
|
|
}
|
|
|
|
|
#define HIGHRES_POP(dctx) \
|
|
|
|
|
if ( (dctx)->doHiRes ) { \
|
|
|
|
|
(void)WinSetCoordinateSystem( (dctx)->oldCoord ); \
|
|
|
|
|
(dctx)->oldCoord = 0; \
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
eraseRect( /* PalmDrawCtx* dctx, */const XP_Rect* rect )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
WinEraseRectangle( (const RectangleType*)rect, 0 );
|
|
|
|
|
} /* eraseRect */
|
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
static void
|
|
|
|
|
insetRect2( XP_Rect* rect, XP_S16 byX, XP_S16 byY )
|
|
|
|
|
{
|
|
|
|
|
XP_U16 i;
|
|
|
|
|
rect->left += byX;
|
|
|
|
|
rect->top += byY;
|
|
|
|
|
for ( i = 0; i < 2; ++i ) {
|
|
|
|
|
rect->width -= byX;
|
|
|
|
|
rect->height -= byY;
|
|
|
|
|
}
|
|
|
|
|
} /* insetRect */
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
static void
|
|
|
|
|
insetRect( XP_Rect* rect, XP_S16 by )
|
|
|
|
|
{
|
2006-11-12 15:36:15 +01:00
|
|
|
|
insetRect2( rect, by, by );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* insetRect */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-16 15:44:44 +02:00
|
|
|
|
drawBitmapAt( DrawCtx* XP_UNUSED(p_dctx), Int16 resID, Int16 x, Int16 y )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
MemHandle handle;
|
|
|
|
|
handle = DmGetResource( bitmapRsc, resID );
|
|
|
|
|
XP_ASSERT( handle != NULL );
|
|
|
|
|
|
|
|
|
|
if ( handle != NULL ) {
|
|
|
|
|
WinDrawBitmap( (BitmapPtr)MemHandleLock(handle), x, y );
|
|
|
|
|
XP_ASSERT( MemHandleLockCount(handle ) == 1 );
|
|
|
|
|
MemHandleUnlock( handle );
|
|
|
|
|
DmReleaseResource( handle );
|
|
|
|
|
}
|
|
|
|
|
} /* drawBitmapAt */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
bitmapInRect( PalmDrawCtx* dctx, Int16 resID, const XP_Rect* rectP )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
XP_U16 left = rectP->left;
|
|
|
|
|
XP_U16 top = rectP->top;
|
|
|
|
|
if ( dctx->globals->gState.showGrid ) {
|
|
|
|
|
++left;
|
|
|
|
|
++top;
|
|
|
|
|
}
|
|
|
|
|
drawBitmapAt( (DrawCtx*)dctx, resID, left, top );
|
|
|
|
|
} /* bitmapInRect */
|
|
|
|
|
|
2005-07-08 10:30:42 +02:00
|
|
|
|
# define BMP_WIDTH 16
|
|
|
|
|
# define BMP_HT 16
|
|
|
|
|
|
2005-07-08 05:14:43 +02:00
|
|
|
|
static void
|
|
|
|
|
measureFace( PalmDrawCtx* dctx, XP_UCHAR face, PalmFontHtInfo* fhi )
|
|
|
|
|
{
|
|
|
|
|
WinHandle win;
|
|
|
|
|
BitmapType* bitmap;
|
|
|
|
|
Coord x, y;
|
|
|
|
|
Err err;
|
|
|
|
|
XP_Bool gotIt;
|
|
|
|
|
XP_U16 top = 0;
|
|
|
|
|
XP_U16 bottom = 0;
|
|
|
|
|
XP_UCHAR ch = (XP_UCHAR)face;
|
|
|
|
|
|
|
|
|
|
bitmap = BmpCreate( BMP_WIDTH, BMP_HT, 1, NULL, &err );
|
|
|
|
|
if ( err == errNone ) {
|
|
|
|
|
win = WinCreateBitmapWindow( bitmap, &err );
|
|
|
|
|
if ( err == errNone ) {
|
|
|
|
|
WinHandle oldWin = WinSetDrawWindow( win );
|
|
|
|
|
|
|
|
|
|
WinSetBackColor( 0 ); /* white */
|
|
|
|
|
(void)WinSetTextColor( 1 ); /* black */
|
|
|
|
|
(void)WinSetDrawMode( winOverlay );
|
|
|
|
|
|
|
|
|
|
WinDrawChars( &ch, 1, 0, 0 );
|
|
|
|
|
|
|
|
|
|
/* Scan from top for top, then from bottom for botton */
|
|
|
|
|
gotIt = XP_FALSE;
|
|
|
|
|
for ( y = 0; !gotIt && y < BMP_HT; ++y ) {
|
|
|
|
|
for ( x = 0; !gotIt && x < BMP_WIDTH; ++x ) {
|
|
|
|
|
IndexedColorType pxl = WinGetPixel( x, y );
|
|
|
|
|
if ( pxl != 0 ) {
|
|
|
|
|
top = y;
|
|
|
|
|
gotIt = XP_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gotIt = XP_FALSE;
|
|
|
|
|
for ( y = BMP_HT - 1; !gotIt && y >= 0; --y ) {
|
|
|
|
|
for ( x = 0; !gotIt && x < BMP_WIDTH; ++x ) {
|
|
|
|
|
IndexedColorType pxl = WinGetPixel( x, y );
|
|
|
|
|
if ( pxl != 0 ) {
|
|
|
|
|
bottom = y;
|
|
|
|
|
gotIt = XP_TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(void)WinSetDrawWindow( oldWin );
|
|
|
|
|
WinDeleteWindow( win, false );
|
|
|
|
|
|
|
|
|
|
/* There should be a way to avoid this, but HIGHRES_PUSH after
|
|
|
|
|
WinSetDrawWindow isn't working... Fix this... */
|
|
|
|
|
if ( dctx->doHiRes ) {
|
|
|
|
|
top *= 2;
|
|
|
|
|
bottom *= 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fhi->topOffset = top;
|
|
|
|
|
fhi->height = bottom - top + 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
BmpDelete( bitmap );
|
|
|
|
|
}
|
|
|
|
|
} /* measureFace */
|
|
|
|
|
|
2005-07-07 05:46:07 +02:00
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
checkFontOffsets( PalmDrawCtx* dctx, const DictionaryCtxt* dict )
|
2005-07-07 05:46:07 +02:00
|
|
|
|
{
|
|
|
|
|
XP_LangCode code;
|
|
|
|
|
XP_U16 nFaces;
|
|
|
|
|
Tile tile;
|
|
|
|
|
|
|
|
|
|
code = dict_getLangCode( dict );
|
|
|
|
|
if ( code != dctx->fontLangCode ) {
|
|
|
|
|
|
2005-07-08 05:14:43 +02:00
|
|
|
|
if ( !!dctx->fontHtInfo ) {
|
|
|
|
|
XP_FREE( dctx->mpool, dctx->fontHtInfo );
|
2005-07-07 05:46:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nFaces = dict_numTileFaces( dict );
|
2005-07-08 05:14:43 +02:00
|
|
|
|
dctx->fontHtInfo = XP_MALLOC( dctx->mpool,
|
|
|
|
|
nFaces * sizeof(*dctx->fontHtInfo) );
|
2005-07-07 05:46:07 +02:00
|
|
|
|
|
|
|
|
|
for ( tile = 0; tile < nFaces; ++tile ) {
|
2005-07-08 05:14:43 +02:00
|
|
|
|
XP_UCHAR face[2];
|
|
|
|
|
if ( 1 == dict_tilesToString( dict, &tile, 1,
|
|
|
|
|
face, sizeof(face) ) ) {
|
|
|
|
|
measureFace( dctx, face[0], &dctx->fontHtInfo[tile] );
|
|
|
|
|
}
|
2005-07-07 05:46:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dctx->fontLangCode = code;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-13 14:54:52 +01:00
|
|
|
|
static XP_Bool
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_common_draw_boardBegin( DrawCtx* p_dctx, const DictionaryCtxt* dict,
|
2006-11-03 07:23:54 +01:00
|
|
|
|
const XP_Rect* rect, DrawFocusState dfs )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
PalmAppGlobals* globals = dctx->globals;
|
|
|
|
|
if ( !globals->gState.showGrid ) {
|
2003-11-16 20:46:51 +01:00
|
|
|
|
WinDrawRectangleFrame(rectangleFrame, (RectangleType*)rect);
|
2003-11-16 20:37:12 +01:00
|
|
|
|
}
|
2005-07-07 05:46:07 +02:00
|
|
|
|
|
|
|
|
|
checkFontOffsets( dctx, dict );
|
|
|
|
|
|
2007-01-19 09:22:14 +01:00
|
|
|
|
#ifdef DRAW_FOCUS_FRAME
|
|
|
|
|
dctx->topFocus = dfs == DFS_TOP;
|
|
|
|
|
#endif
|
2004-02-13 14:54:52 +01:00
|
|
|
|
return XP_TRUE;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_common_draw_boardBegin */
|
|
|
|
|
|
|
|
|
|
#ifdef COLOR_SUPPORT
|
2004-02-13 14:54:52 +01:00
|
|
|
|
static XP_Bool
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_clr_draw_boardBegin( DrawCtx* p_dctx, const DictionaryCtxt* dict,
|
2006-11-03 07:23:54 +01:00
|
|
|
|
const XP_Rect* rect, DrawFocusState dfs )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
|
|
|
|
|
WinPushDrawState();
|
|
|
|
|
|
|
|
|
|
WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] );
|
|
|
|
|
WinSetTextColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] );
|
|
|
|
|
WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_WHITE] );
|
2004-03-16 06:25:23 +01:00
|
|
|
|
|
|
|
|
|
HIGHRES_PUSH_NOPOP(dctx);
|
|
|
|
|
|
2006-11-03 07:23:54 +01:00
|
|
|
|
palm_common_draw_boardBegin( p_dctx, dict, rect, dfs );
|
2004-05-16 17:06:39 +02:00
|
|
|
|
|
2004-02-13 14:54:52 +01:00
|
|
|
|
return XP_TRUE;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_clr_draw_boardBegin */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-11-05 17:54:18 +01:00
|
|
|
|
palm_draw_objFinished( DrawCtx* p_dctx, BoardObjectType typ,
|
2006-12-21 08:55:19 +01:00
|
|
|
|
const XP_Rect* rect, DrawFocusState dfs )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
2006-11-05 17:54:18 +01:00
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
2007-01-19 09:22:14 +01:00
|
|
|
|
#if defined XWFEATURE_FIVEWAY && defined DRAW_FOCUS_FRAME
|
2007-01-18 06:49:07 +01:00
|
|
|
|
if ( (dfs == DFS_TOP) && (typ == OBJ_BOARD) ) {
|
2006-12-21 08:55:19 +01:00
|
|
|
|
XP_Rect r;
|
|
|
|
|
XP_U16 i;
|
|
|
|
|
IndexedColorType oldColor;
|
|
|
|
|
|
|
|
|
|
oldColor
|
|
|
|
|
= WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] );
|
|
|
|
|
|
|
|
|
|
r.left = rect->left + 1;
|
|
|
|
|
r.top = rect->top + 1;
|
|
|
|
|
r.width = rect->width - 1;
|
|
|
|
|
r.height = rect->height - 1;
|
|
|
|
|
|
2007-01-21 23:59:29 +01:00
|
|
|
|
for ( i = dctx->doHiRes?FOCUS_BORDER_WIDTH:FOCUS_BORDER_WIDTH/2;
|
|
|
|
|
i > 0; --i ) {
|
2006-12-21 08:55:19 +01:00
|
|
|
|
insetRect( &r, 1 );
|
|
|
|
|
WinDrawRectangleFrame(rectangleFrame, (RectangleType*)&r );
|
|
|
|
|
}
|
|
|
|
|
(void)WinSetForeColor( oldColor );
|
2006-11-05 17:54:18 +01:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2006-11-03 07:23:54 +01:00
|
|
|
|
|
2006-11-05 17:54:18 +01:00
|
|
|
|
if ( typ == OBJ_BOARD ) {
|
|
|
|
|
WinPopDrawState();
|
|
|
|
|
} else if ( typ == OBJ_TRAY ) {
|
|
|
|
|
WinSetClip( &dctx->oldTrayClip );
|
|
|
|
|
WinPopDrawState();
|
|
|
|
|
} else if ( typ == OBJ_SCORE ) {
|
|
|
|
|
WinSetClip( &dctx->oldScoreClip );
|
|
|
|
|
HIGHRES_POP(dctx);
|
|
|
|
|
}
|
|
|
|
|
} /* palm_draw_objFinished */
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
static XP_Bool
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_clr_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
|
|
|
|
|
const XP_UCHAR* letters, XP_Bitmap bitmap,
|
2006-11-12 15:36:15 +01:00
|
|
|
|
Tile tile, XP_S16 owner, XWBonusType bonus,
|
|
|
|
|
HintAtts hintAtts, CellFlags flags )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
IndexedColorType color;
|
|
|
|
|
XP_U16 index;
|
2007-01-20 05:30:02 +01:00
|
|
|
|
XP_Bool isCursor = TREAT_AS_CURSOR( dctx, flags );
|
2006-11-12 15:36:15 +01:00
|
|
|
|
XP_Bool isPending = (flags & CELL_HIGHLIGHT) != 0;
|
|
|
|
|
if ( isCursor ) {
|
|
|
|
|
index = COLOR_CURSOR;
|
|
|
|
|
} else if ( isPending ) {
|
2003-11-16 20:37:12 +01:00
|
|
|
|
/* don't color background if will invert */
|
|
|
|
|
index = COLOR_WHITE;
|
2004-03-01 03:31:25 +01:00
|
|
|
|
} else if ( !!bitmap || (!!letters && XP_STRLEN((const char*)letters) > 0)){
|
2003-11-16 20:37:12 +01:00
|
|
|
|
index = COLOR_TILE;
|
|
|
|
|
} else if ( bonus == BONUS_NONE ) {
|
|
|
|
|
index = COLOR_EMPTY;
|
|
|
|
|
} else {
|
|
|
|
|
index = COLOR_DBL_LTTR + bonus - 1;
|
|
|
|
|
}
|
|
|
|
|
color = dctx->drawingPrefs->drawColors[index];
|
|
|
|
|
WinSetBackColor( color );
|
|
|
|
|
|
|
|
|
|
if ( !!letters ) {
|
2004-03-01 03:31:25 +01:00
|
|
|
|
if ( (owner >= 0) && !isPending ) {
|
|
|
|
|
index = COLOR_PLAYER1 + owner;
|
|
|
|
|
} else {
|
|
|
|
|
index = COLOR_BLACK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
color = dctx->drawingPrefs->drawColors[index];
|
2003-11-16 20:37:12 +01:00
|
|
|
|
WinSetTextColor( color );
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-07 05:46:07 +02:00
|
|
|
|
return palm_common_draw_drawCell( p_dctx, rect, letters, bitmap,
|
2006-11-12 15:36:15 +01:00
|
|
|
|
tile, owner, bonus, hintAtts, flags );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_clr_draw_drawCell */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_clr_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
|
|
|
|
|
const XP_Rect* rOuter,
|
|
|
|
|
const DrawScoreInfo* dsi )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
2005-03-15 07:26:58 +01:00
|
|
|
|
XP_U16 playerNum = dsi->playerNum;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
2006-11-12 15:36:15 +01:00
|
|
|
|
XP_U16 txtIndex;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
IndexedColorType newColor;
|
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
WinPushDrawState();
|
|
|
|
|
|
|
|
|
|
if ( dsi->flags && CELL_ISCURSOR ) {
|
|
|
|
|
WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] );
|
|
|
|
|
eraseRect( rOuter );
|
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
if ( dsi->selected ) {
|
|
|
|
|
XP_Rect r = *rInner;
|
|
|
|
|
insetRect2( &r, (r.width - rOuter->width) >> 2,
|
|
|
|
|
(r.height - rOuter->height) >> 2 );
|
|
|
|
|
WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] );
|
|
|
|
|
eraseRect( &r );
|
|
|
|
|
txtIndex = COLOR_WHITE;
|
|
|
|
|
} else {
|
|
|
|
|
txtIndex = COLOR_PLAYER1+playerNum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newColor = dctx->drawingPrefs->drawColors[txtIndex];
|
|
|
|
|
(void)WinSetTextColor( newColor );
|
|
|
|
|
(void)WinSetForeColor( newColor );
|
|
|
|
|
|
|
|
|
|
doDrawPlayer( dctx, dsi, rInner );
|
|
|
|
|
|
|
|
|
|
WinPopDrawState();
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_clr_draw_score_drawPlayer */
|
2007-12-19 06:29:53 +01:00
|
|
|
|
#endif /* #ifdef COLOR_SUPPORT */
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2004-06-16 06:06:43 +02:00
|
|
|
|
static void
|
2007-12-19 06:29:53 +01:00
|
|
|
|
palmDrawHintBorders( PalmDrawCtx* dctx, const XP_Rect* rect,
|
|
|
|
|
HintAtts hintAtts )
|
2004-06-16 06:06:43 +02:00
|
|
|
|
{
|
2007-12-19 06:29:53 +01:00
|
|
|
|
if ( 0 != (HINT_BORDER_EDGE & hintAtts) ) {
|
2004-11-14 17:19:21 +01:00
|
|
|
|
XP_Rect frame = *rect;
|
2007-12-19 06:29:53 +01:00
|
|
|
|
XP_U16 width = dctx->doHiRes ? 4 : 2;
|
|
|
|
|
XP_Bool showGrid = dctx->globals->gState.showGrid;
|
|
|
|
|
if ( showGrid ) {
|
|
|
|
|
++width;
|
|
|
|
|
}
|
2004-06-16 06:06:43 +02:00
|
|
|
|
|
2004-11-14 17:19:21 +01:00
|
|
|
|
if ( (hintAtts & HINT_BORDER_LEFT) != 0 ) {
|
2007-12-19 06:29:53 +01:00
|
|
|
|
XP_Rect r = frame;
|
|
|
|
|
r.width = width;
|
|
|
|
|
WinDrawRectangle( (RectangleType*)&r, 0 );
|
2004-11-14 17:19:21 +01:00
|
|
|
|
}
|
|
|
|
|
if ( (hintAtts & HINT_BORDER_TOP) != 0 ) {
|
2007-12-19 06:29:53 +01:00
|
|
|
|
XP_Rect r = frame;
|
|
|
|
|
r.height = width;
|
|
|
|
|
WinDrawRectangle( (RectangleType*)&r, 0 );
|
2004-11-14 17:19:21 +01:00
|
|
|
|
}
|
|
|
|
|
if ( (hintAtts & HINT_BORDER_RIGHT) != 0 ) {
|
2007-12-19 06:29:53 +01:00
|
|
|
|
XP_Rect r = frame;
|
|
|
|
|
r.left += r.width - width;
|
|
|
|
|
if ( showGrid ) {
|
|
|
|
|
++r.left;
|
|
|
|
|
}
|
|
|
|
|
r.width = width;
|
|
|
|
|
WinDrawRectangle( (RectangleType*)&r, 0 );
|
2004-11-14 17:19:21 +01:00
|
|
|
|
}
|
|
|
|
|
if ( (hintAtts & HINT_BORDER_BOTTOM) != 0 ) {
|
2007-12-19 06:29:53 +01:00
|
|
|
|
XP_Rect r = frame;
|
|
|
|
|
r.top += r.height - width;
|
|
|
|
|
if ( showGrid ) {
|
|
|
|
|
++r.top;
|
|
|
|
|
}
|
|
|
|
|
r.height = width;
|
|
|
|
|
WinDrawRectangle( (RectangleType*)&r, 0 );
|
2004-11-14 17:19:21 +01:00
|
|
|
|
}
|
2004-06-16 06:06:43 +02:00
|
|
|
|
}
|
|
|
|
|
} /* palmDrawHintBorders */
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
static XP_Bool
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_common_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
|
|
|
|
|
const XP_UCHAR* letters, XP_Bitmap bitmap,
|
2006-11-12 15:36:15 +01:00
|
|
|
|
Tile tile, XP_S16 owner, XWBonusType bonus,
|
|
|
|
|
HintAtts hintAtts, CellFlags flags )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
GraphicsAbility able = dctx->able;
|
|
|
|
|
XP_Rect localR = *rect;
|
|
|
|
|
XP_U16 len;
|
|
|
|
|
RectangleType saveClip, intersectR;
|
|
|
|
|
PalmAppGlobals* globals = dctx->globals;
|
|
|
|
|
Boolean showGrid = globals->gState.showGrid;
|
|
|
|
|
Boolean showBonus = bonus != BONUS_NONE;
|
|
|
|
|
Boolean complete;
|
|
|
|
|
XP_Bool empty = XP_TRUE;
|
|
|
|
|
|
|
|
|
|
if ( showGrid ) {
|
|
|
|
|
++localR.width;
|
|
|
|
|
++localR.height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WinGetClip( &saveClip );
|
|
|
|
|
|
|
|
|
|
RctGetIntersection( &saveClip, (RectangleType*)&localR, &intersectR );
|
|
|
|
|
|
|
|
|
|
/* If there's no rect left inside the clip rgn, exit. But if the rect's
|
|
|
|
|
only partial go ahead and draw, but still return false indicating that
|
|
|
|
|
we'd like to be allowed to draw again. This is necessary when a cell
|
|
|
|
|
needs to be redrawn for two reasons, e.g. because its bottom half
|
|
|
|
|
overlaps a form that's gone away (and that supplied the clip region)
|
|
|
|
|
and because its top is covered by the trading miniwindow that's also
|
|
|
|
|
going away. Under no circumstances draw outside the clip region or
|
|
|
|
|
risk overdrawing menus, other forms, etc. */
|
|
|
|
|
|
|
|
|
|
if ( intersectR.extent.x == 0 || intersectR.extent.y == 0 ) {
|
|
|
|
|
return XP_FALSE;
|
|
|
|
|
} else if ( intersectR.extent.x < localR.width ||
|
|
|
|
|
intersectR.extent.y < localR.height ) {
|
|
|
|
|
complete = XP_FALSE;
|
|
|
|
|
} else {
|
|
|
|
|
complete = XP_TRUE;
|
|
|
|
|
}
|
|
|
|
|
WinSetClip( (RectangleType*)&intersectR );
|
|
|
|
|
|
|
|
|
|
if ( showGrid ) {
|
|
|
|
|
insetRect( &localR, 1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
eraseRect( &localR );
|
|
|
|
|
|
|
|
|
|
if ( !!letters ) {
|
|
|
|
|
len = XP_STRLEN( (const char*)letters );
|
|
|
|
|
if ( len > 0 ) {
|
|
|
|
|
XP_S16 strWidth = FntCharsWidth( (const char*)letters, len );
|
2005-07-07 05:46:07 +02:00
|
|
|
|
XP_U16 x, y;
|
|
|
|
|
x = localR.left + ((localR.width-strWidth) / 2);
|
2005-07-08 05:14:43 +02:00
|
|
|
|
y = localR.top - dctx->fontHtInfo[tile].topOffset;
|
2006-07-04 02:16:08 +02:00
|
|
|
|
/* '+ 1' below causes us to round up. Without this "Q" is drawn
|
|
|
|
|
with its top higher than other ASCII letters because it's
|
|
|
|
|
taller; looks bad. */
|
|
|
|
|
y += (localR.height + 1 - dctx->fontHtInfo[tile].height) / 2;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
if ( len == 1 ) {
|
|
|
|
|
++x;
|
|
|
|
|
}
|
2005-07-08 05:14:43 +02:00
|
|
|
|
|
2004-11-02 07:05:23 +01:00
|
|
|
|
WinDrawChars( (const char*)letters, len, x, y );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
showBonus = XP_FALSE;
|
|
|
|
|
empty = XP_FALSE;
|
|
|
|
|
}
|
|
|
|
|
} else if ( !!bitmap ) {
|
|
|
|
|
XP_Bool doColor = (able == COLOR) && (owner >= 0);
|
2006-03-31 12:57:01 +02:00
|
|
|
|
XP_U16 x = localR.left+1;
|
|
|
|
|
XP_U16 y = localR.top+1;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
/* cheating again; this belongs in a palm_clr method. But the
|
|
|
|
|
special bitmaps are rare enough that we shouldn't change the palm
|
|
|
|
|
draw state every time. */
|
|
|
|
|
if ( doColor ) {
|
|
|
|
|
WinSetForeColor(
|
|
|
|
|
dctx->drawingPrefs->drawColors[COLOR_PLAYER1+owner] );
|
|
|
|
|
}
|
2006-03-31 12:57:01 +02:00
|
|
|
|
|
|
|
|
|
if ( dctx->doHiRes ) {
|
|
|
|
|
++x;
|
|
|
|
|
++y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WinDrawBitmap( (BitmapPtr)bitmap, x, y );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
if ( doColor ) {
|
|
|
|
|
WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] );
|
|
|
|
|
}
|
|
|
|
|
showBonus = doColor; /* skip bonus in B&W case; can't draw both! */
|
|
|
|
|
empty = XP_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
if ( (flags & CELL_ISSTAR) != 0 ) {
|
2003-11-16 20:37:12 +01:00
|
|
|
|
bitmapInRect( dctx, STAR_BMP_RES_ID, rect );
|
|
|
|
|
} else if ( showBonus && (able == ONEBIT) ) {
|
|
|
|
|
/* this is my one refusal to totally factor bandw and color
|
|
|
|
|
code */
|
|
|
|
|
WinSetPattern( (const CustomPatternType*)
|
|
|
|
|
&dctx->u.bnw.valuePatterns[bonus-1] );
|
2003-11-16 20:46:51 +01:00
|
|
|
|
WinFillRectangle( (RectangleType*)&localR, 0 );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} else if ( !showBonus && empty && !showGrid ) {
|
|
|
|
|
/* should this be in the v-table so I don't have to test each
|
|
|
|
|
time? */
|
2004-05-16 17:06:39 +02:00
|
|
|
|
RectangleType r;
|
|
|
|
|
r.topLeft.x = localR.left + ((PALM_BOARD_SCALE-1)/2);
|
|
|
|
|
r.topLeft.y = localR.top + ((PALM_BOARD_SCALE-1)/2);
|
|
|
|
|
|
|
|
|
|
if ( dctx->doHiRes ) {
|
|
|
|
|
r.topLeft.x += PALM_BOARD_SCALE/2;
|
|
|
|
|
r.topLeft.y += PALM_BOARD_SCALE/2;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
if ( globals->romVersion >= 35 ) {
|
2004-05-16 17:06:39 +02:00
|
|
|
|
WinDrawPixel( r.topLeft.x, r.topLeft.y );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} else {
|
|
|
|
|
r.extent.x = r.extent.y = 1;
|
|
|
|
|
WinDrawRectangle( &r, 0 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
|
2007-01-20 05:30:02 +01:00
|
|
|
|
if ( !TREAT_AS_CURSOR( dctx, flags ) ) {
|
2006-11-12 15:36:15 +01:00
|
|
|
|
XP_ASSERT( !!bitmap ||
|
|
|
|
|
(!!letters && XP_STRLEN((const char*)letters)>0));
|
|
|
|
|
WinInvertRectangle( (RectangleType*)&localR, 0 );
|
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( showGrid ) {
|
2003-11-16 20:46:51 +01:00
|
|
|
|
WinDrawRectangleFrame(rectangleFrame, (RectangleType*)&localR);
|
2003-11-16 20:37:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
if ( (flags & CELL_ISBLANK) != 0 ) {
|
2003-11-16 20:37:12 +01:00
|
|
|
|
WinEraseRectangleFrame( roundFrame, (RectangleType*)&localR );
|
|
|
|
|
}
|
|
|
|
|
|
2007-12-19 06:29:53 +01:00
|
|
|
|
palmDrawHintBorders( dctx, rect, hintAtts );
|
2004-06-16 06:06:43 +02:00
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
WinSetClip( &saveClip );
|
|
|
|
|
return complete;
|
|
|
|
|
} /* palm_common_draw_drawCell */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_invertCell( DrawCtx* p_dctx, const XP_Rect* rect )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
XP_Rect localR = *rect;
|
|
|
|
|
/* insetRect( &localR, 3 ); */
|
|
|
|
|
localR.top += 3;
|
|
|
|
|
localR.left += 3;
|
|
|
|
|
localR.width -= 5;
|
|
|
|
|
localR.height -= 5;
|
2004-04-20 06:05:59 +02:00
|
|
|
|
|
|
|
|
|
HIGHRES_PUSH_LOC( (PalmDrawCtx*)p_dctx );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
WinInvertRectangle( (RectangleType*)&localR, 0 );
|
2004-04-20 06:05:59 +02:00
|
|
|
|
HIGHRES_POP_LOC( (PalmDrawCtx*)p_dctx );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_draw_invertCell */
|
|
|
|
|
|
2004-03-13 15:18:28 +01:00
|
|
|
|
static XP_Bool
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_clr_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect,
|
2006-11-03 07:23:54 +01:00
|
|
|
|
XP_U16 owner, DrawFocusState dfs )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
|
|
|
|
|
dctx->trayOwner = owner;
|
|
|
|
|
|
|
|
|
|
WinPushDrawState();
|
|
|
|
|
WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_TILE] );
|
|
|
|
|
WinSetTextColor( dctx->drawingPrefs->drawColors[COLOR_PLAYER1+owner] );
|
|
|
|
|
WinSetForeColor( dctx->drawingPrefs->drawColors[COLOR_PLAYER1+owner] );
|
2004-03-16 06:25:23 +01:00
|
|
|
|
|
|
|
|
|
HIGHRES_PUSH_NOPOP(dctx);
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2006-11-03 07:23:54 +01:00
|
|
|
|
palm_bnw_draw_trayBegin( p_dctx, rect, owner, dfs );
|
2004-03-13 15:18:28 +01:00
|
|
|
|
return XP_TRUE;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_clr_draw_trayBegin */
|
|
|
|
|
|
2004-03-13 15:18:28 +01:00
|
|
|
|
static XP_Bool
|
2006-08-16 15:44:44 +02:00
|
|
|
|
palm_bnw_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect,
|
|
|
|
|
XP_U16 XP_UNUSED(owner),
|
2006-11-03 07:23:54 +01:00
|
|
|
|
DrawFocusState dfs )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
|
|
|
|
|
WinGetClip( &dctx->oldTrayClip );
|
|
|
|
|
WinSetClip( (RectangleType*)rect );
|
2006-11-17 14:46:06 +01:00
|
|
|
|
dctx->topFocus = dfs == DFS_TOP;
|
2004-03-13 15:18:28 +01:00
|
|
|
|
return XP_TRUE;
|
2006-11-03 07:23:54 +01:00
|
|
|
|
} /* palm_bnw_draw_trayBegin */
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2004-11-03 04:57:07 +01:00
|
|
|
|
static void
|
|
|
|
|
smallBoldStringAt( const char* str, XP_U16 len, XP_S16 x, XP_U16 y )
|
|
|
|
|
{
|
|
|
|
|
UInt32 oldMode = WinSetScalingMode( kTextScalingOff );
|
|
|
|
|
FontID curFont = FntGetFont();
|
|
|
|
|
FntSetFont( boldFont );
|
|
|
|
|
|
|
|
|
|
/* negative x means position backwards from it */
|
|
|
|
|
if ( x < 0 ) {
|
|
|
|
|
x = (-x) - FntCharsWidth( str, len );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WinDrawChars( str, len, x, y );
|
|
|
|
|
|
|
|
|
|
FntSetFont( curFont );
|
|
|
|
|
WinSetScalingMode( oldMode );
|
|
|
|
|
} /* smallBoldStringAt */
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
|
|
|
|
|
const XP_UCHAR* letters, XP_Bitmap bitmap,
|
2006-11-12 15:36:15 +01:00
|
|
|
|
XP_S16 val, CellFlags flags )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
char valBuf[3];
|
|
|
|
|
XP_Rect localR = *rect;
|
|
|
|
|
XP_U16 len, width;
|
2004-03-17 05:57:09 +01:00
|
|
|
|
XP_U16 doubler = 1;
|
2006-11-14 07:52:11 +01:00
|
|
|
|
const XP_Bool cursor = (flags & CELL_ISCURSOR) != 0;
|
2006-11-12 15:36:15 +01:00
|
|
|
|
XP_Bool empty = (flags & CELL_ISEMPTY) != 0;
|
2004-03-18 06:41:59 +01:00
|
|
|
|
|
2006-11-17 14:46:06 +01:00
|
|
|
|
WinPushDrawState();
|
|
|
|
|
|
2004-03-17 05:57:09 +01:00
|
|
|
|
if ( dctx->doHiRes ) {
|
|
|
|
|
doubler = 2;
|
|
|
|
|
}
|
2004-03-18 06:41:59 +01:00
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
draw_clearRect( p_dctx, &localR );
|
2006-11-17 14:46:06 +01:00
|
|
|
|
|
2007-01-20 05:30:02 +01:00
|
|
|
|
if ( cursor ) {
|
2006-11-17 14:46:06 +01:00
|
|
|
|
(void)WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] );
|
|
|
|
|
if ( dctx->topFocus ) {
|
|
|
|
|
WinEraseRectangle( (const RectangleType*)&localR, 0 );
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2006-11-14 07:52:11 +01:00
|
|
|
|
localR.height -= 3 * doubler;
|
|
|
|
|
localR.top += 2 * doubler;
|
2006-11-17 14:46:06 +01:00
|
|
|
|
localR.width -= 3 * doubler;
|
|
|
|
|
localR.left += 2 * doubler;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2006-11-17 14:46:06 +01:00
|
|
|
|
if ( cursor && !dctx->topFocus ) {
|
2006-11-14 07:52:11 +01:00
|
|
|
|
/* this will fill it with the tile background color */
|
|
|
|
|
WinEraseRectangle( (const RectangleType*)&localR, 0 );
|
2006-11-12 15:36:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
/* this will fill it with the tile background color */
|
2006-11-14 07:52:11 +01:00
|
|
|
|
if ( !empty && !cursor ) {
|
2006-11-12 15:36:15 +01:00
|
|
|
|
WinEraseRectangle( (const RectangleType*)&localR, 0 );
|
2004-11-14 17:19:21 +01:00
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
if ( !empty ) {
|
|
|
|
|
/* Draw the number before the letter. Some PalmOS version don't
|
|
|
|
|
honor the winOverlay flag and erase. Better to erase the value
|
|
|
|
|
than the letter. */
|
|
|
|
|
if ( val >= 0 ) {
|
|
|
|
|
(void)StrPrintF( valBuf, "%d", val );
|
|
|
|
|
len = XP_STRLEN((const char*)valBuf);
|
|
|
|
|
|
|
|
|
|
if ( dctx->doHiRes && dctx->oneDotFiveAvail ) {
|
|
|
|
|
smallBoldStringAt( valBuf, len,
|
|
|
|
|
-(localR.left + localR.width),
|
|
|
|
|
localR.top + localR.height - dctx->fntHeight
|
|
|
|
|
- 1 );
|
|
|
|
|
} else {
|
|
|
|
|
width = FntCharsWidth( valBuf, len );
|
|
|
|
|
WinDrawChars( valBuf, len, localR.left + localR.width - width,
|
|
|
|
|
localR.top + localR.height - (10*doubler) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !!letters ) {
|
|
|
|
|
if ( *letters != LETTER_NONE ) { /* blank */
|
|
|
|
|
FontID curFont = FntSetFont( largeFont );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
HIGHRES_PUSH_LOC( dctx );
|
2004-03-18 06:41:59 +01:00
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
WinDrawChars( (char*)letters, 1,
|
|
|
|
|
localR.left + (1*doubler),
|
|
|
|
|
localR.top + (0*doubler) );
|
2004-10-30 21:25:23 +02:00
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
HIGHRES_POP_LOC(dctx);
|
2004-10-30 21:25:23 +02:00
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
FntSetFont( curFont );
|
|
|
|
|
}
|
|
|
|
|
} else if ( !!bitmap ) {
|
|
|
|
|
WinDrawBitmap( (BitmapPtr)bitmap, localR.left+(2*doubler),
|
|
|
|
|
localR.top+(2*doubler) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WinDrawRectangleFrame( rectangleFrame, (RectangleType*)&localR );
|
|
|
|
|
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
|
|
|
|
|
insetRect( &localR, 1 );
|
|
|
|
|
WinDrawRectangleFrame(rectangleFrame, (RectangleType*)&localR );
|
|
|
|
|
if ( dctx->doHiRes ) {
|
|
|
|
|
insetRect( &localR, 1 );
|
|
|
|
|
WinDrawRectangleFrame(rectangleFrame,
|
|
|
|
|
(RectangleType*)&localR );
|
|
|
|
|
}
|
2004-10-30 21:25:23 +02:00
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
}
|
2006-11-17 14:46:06 +01:00
|
|
|
|
WinPopDrawState();
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_draw_drawTile */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-11-12 15:36:15 +01:00
|
|
|
|
palm_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect, CellFlags flags )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
palm_draw_drawTile( p_dctx, rect, (unsigned char*)"?", (XP_Bitmap)NULL,
|
2006-11-12 15:36:15 +01:00
|
|
|
|
-1, flags & CELL_ISCURSOR );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_draw_drawTileBack */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect, XP_Bool selected )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
XP_Rect lRect = *rect;
|
|
|
|
|
|
|
|
|
|
draw_clearRect( p_dctx, &lRect );
|
|
|
|
|
|
|
|
|
|
++lRect.left;
|
|
|
|
|
--lRect.width;
|
|
|
|
|
|
|
|
|
|
if ( selected ) {
|
|
|
|
|
short pattern[] = { 0xFF00, 0xFF00, 0xFF00, 0xFF00 };
|
|
|
|
|
|
|
|
|
|
WinSetPattern( (const CustomPatternType*)&pattern );
|
2003-11-16 20:46:51 +01:00
|
|
|
|
WinFillRectangle( (RectangleType*)&lRect, 0 );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
WinDrawRectangle( (RectangleType*)&lRect, 0 );
|
|
|
|
|
}
|
|
|
|
|
} /* palm_draw_drawTrayDivider */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-16 15:44:44 +02:00
|
|
|
|
palm_bnw_draw_clearRect( DrawCtx* XP_UNUSED(p_dctx), const XP_Rect* rectP )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
eraseRect( rectP );
|
|
|
|
|
} /* palm_draw_clearRect */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_clr_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
2004-03-13 15:18:28 +01:00
|
|
|
|
IndexedColorType oldColor;
|
|
|
|
|
|
|
|
|
|
oldColor = WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_WHITE] );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
eraseRect( rectP );
|
2004-03-13 15:18:28 +01:00
|
|
|
|
WinSetBackColor( oldColor );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_clr_draw_clearRect */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_clr_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
|
|
|
|
|
const XP_Rect* rect, void** closureP )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_WHITE] );
|
|
|
|
|
WinSetTextColor( dctx->drawingPrefs->drawColors[COLOR_BLACK] );
|
|
|
|
|
|
|
|
|
|
palm_draw_drawMiniWindow( p_dctx, text, rect, closureP );
|
|
|
|
|
} /* palm_clr_draw_drawMiniWindow */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_drawBoardArrow( DrawCtx* p_dctx, const XP_Rect* rectP,
|
2006-08-16 15:44:44 +02:00
|
|
|
|
XWBonusType XP_UNUSED(cursorBonus), XP_Bool vertical,
|
2006-11-12 15:36:15 +01:00
|
|
|
|
HintAtts hintAtts, CellFlags flags )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
2004-11-02 07:05:23 +01:00
|
|
|
|
RectangleType oldClip;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
Int16 resID = vertical? DOWN_ARROW_RESID:RIGHT_ARROW_RESID;
|
|
|
|
|
|
2004-11-02 07:05:23 +01:00
|
|
|
|
WinGetClip( &oldClip );
|
|
|
|
|
WinSetClip( (RectangleType*)rectP );
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
bitmapInRect( dctx, resID, rectP );
|
2007-12-19 06:29:53 +01:00
|
|
|
|
palmDrawHintBorders( dctx, rectP, hintAtts );
|
2004-11-02 07:05:23 +01:00
|
|
|
|
|
|
|
|
|
WinSetClip( &oldClip );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_draw_drawBoardArrow */
|
|
|
|
|
|
|
|
|
|
#ifdef COLOR_SUPPORT
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_clr_draw_drawBoardArrow( DrawCtx* p_dctx, const XP_Rect* rectP,
|
2004-11-14 17:19:21 +01:00
|
|
|
|
XWBonusType cursorBonus, XP_Bool vertical,
|
2006-11-12 15:36:15 +01:00
|
|
|
|
HintAtts hintAtts, CellFlags flags )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
XP_U16 index;
|
|
|
|
|
|
2007-01-20 05:30:02 +01:00
|
|
|
|
if ( TREAT_AS_CURSOR( dctx, flags ) ) {
|
2006-11-12 15:36:15 +01:00
|
|
|
|
index = COLOR_CURSOR;
|
|
|
|
|
} else if ( cursorBonus == BONUS_NONE ) {
|
2003-11-16 20:37:12 +01:00
|
|
|
|
index = COLOR_EMPTY;
|
|
|
|
|
} else {
|
|
|
|
|
index = COLOR_DBL_LTTR + cursorBonus - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WinSetBackColor( dctx->drawingPrefs->drawColors[index] );
|
2006-11-12 15:36:15 +01:00
|
|
|
|
palm_draw_drawBoardArrow( p_dctx, rectP, cursorBonus, vertical,
|
|
|
|
|
hintAtts, flags );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_clr_draw_drawBoardArrow */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-16 15:44:44 +02:00
|
|
|
|
palm_draw_scoreBegin( DrawCtx* p_dctx, const XP_Rect* rect,
|
|
|
|
|
XP_U16 XP_UNUSED(numPlayers),
|
2007-01-21 23:59:29 +01:00
|
|
|
|
DrawFocusState XP_UNUSED(dfs) )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
|
2004-03-16 06:25:23 +01:00
|
|
|
|
HIGHRES_PUSH( dctx );
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
WinGetClip( &dctx->oldScoreClip );
|
|
|
|
|
WinSetClip( (RectangleType*)rect );
|
|
|
|
|
|
|
|
|
|
eraseRect( rect );
|
|
|
|
|
} /* palm_draw_scoreBegin */
|
|
|
|
|
|
|
|
|
|
/* rectContainsRect: Dup of something in board.c. They could share if I were
|
|
|
|
|
* willing to link from here out.
|
|
|
|
|
*/
|
|
|
|
|
static XP_Bool
|
2006-02-18 07:39:40 +01:00
|
|
|
|
rectContainsRect( const XP_Rect* rect1, const XP_Rect* rect2 )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
return ( rect1->top <= rect2->top
|
|
|
|
|
&& rect1->left <= rect2->left
|
|
|
|
|
&& rect1->top + rect1->height >= rect2->top + rect2->height
|
|
|
|
|
&& rect1->left + rect1->width >= rect2->left + rect2->width );
|
|
|
|
|
} /* rectContainsRect */
|
|
|
|
|
|
|
|
|
|
static XP_Bool
|
2006-08-16 15:44:44 +02:00
|
|
|
|
palm_draw_vertScrollBoard( DrawCtx* XP_UNUSED(p_dctx), XP_Rect* rect,
|
2007-01-21 23:59:29 +01:00
|
|
|
|
XP_S16 dist, DrawFocusState dfs )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
RectangleType clip;
|
|
|
|
|
XP_Bool canDoIt;
|
|
|
|
|
|
|
|
|
|
/* if the clip rect doesn't contain the scroll rect we can't do anything
|
|
|
|
|
right now: WinScrollRectangle won't do its job. */
|
|
|
|
|
WinGetClip( &clip );
|
|
|
|
|
canDoIt = rectContainsRect( (XP_Rect*)&clip, rect );
|
|
|
|
|
|
|
|
|
|
if ( canDoIt ) {
|
|
|
|
|
RectangleType vacated;
|
|
|
|
|
WinDirectionType dir;
|
|
|
|
|
|
|
|
|
|
if ( dist >= 0 ) {
|
|
|
|
|
dir = winUp;
|
|
|
|
|
} else {
|
|
|
|
|
dir = winDown;
|
|
|
|
|
dist = -dist;
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-21 23:59:29 +01:00
|
|
|
|
#ifdef PERIMETER_FOCUS
|
|
|
|
|
if ( dfs == DFS_TOP ) {
|
|
|
|
|
rect->height -= FOCUS_BORDER_WIDTH;
|
|
|
|
|
if ( dir == winDown ) {
|
|
|
|
|
rect->top += FOCUS_BORDER_WIDTH;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
WinScrollRectangle( (RectangleType*)rect, dir, dist, &vacated );
|
|
|
|
|
*rect = *(XP_Rect*)&vacated;
|
|
|
|
|
}
|
|
|
|
|
return canDoIt;
|
|
|
|
|
} /* palm_draw_vertScrollBoard */
|
|
|
|
|
|
|
|
|
|
/* Given some text, determine its bounds and draw it if requested, else
|
|
|
|
|
* return the bounds. If the width of the string exceeds that of the rect in
|
|
|
|
|
* which it can be fit, split it at ':'.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
palmMeasureDrawText( PalmDrawCtx* dctx, XP_Rect* bounds, XP_UCHAR* txt,
|
|
|
|
|
XP_Bool vertical, XP_Bool isTurn, XP_UCHAR skipChar,
|
|
|
|
|
XP_Bool draw )
|
|
|
|
|
{
|
|
|
|
|
XP_U16 len = XP_STRLEN( (const char*)txt );
|
|
|
|
|
XP_U16 widths[2];
|
|
|
|
|
XP_U16 maxWidth, height;
|
|
|
|
|
XP_U16 nLines = 1;
|
|
|
|
|
XP_U16 secondLen = 0;
|
|
|
|
|
XP_UCHAR* second = NULL;
|
2004-05-16 17:06:39 +02:00
|
|
|
|
XP_U16 doubler = 1;
|
|
|
|
|
|
|
|
|
|
if ( dctx->doHiRes ) {
|
|
|
|
|
doubler = 2;
|
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
widths[0] = FntCharsWidth( (const char*)txt, len ) + 1;
|
|
|
|
|
|
|
|
|
|
if ( widths[0] > bounds->width ) {
|
|
|
|
|
XP_UCHAR ch[2];
|
|
|
|
|
ch[0] = skipChar;
|
|
|
|
|
ch[1] = '\0';
|
|
|
|
|
|
|
|
|
|
XP_ASSERT( skipChar );
|
|
|
|
|
second = (XP_UCHAR*)StrStr( (const char*)txt, (const char*)ch );
|
|
|
|
|
XP_ASSERT( !!second );
|
|
|
|
|
++second; /* colon's on the first line */
|
|
|
|
|
secondLen = XP_STRLEN( (const char*)second );
|
|
|
|
|
|
|
|
|
|
len -= secondLen;
|
|
|
|
|
|
|
|
|
|
if ( skipChar ) {
|
|
|
|
|
--len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
widths[0] = FntCharsWidth( (const char*)txt, len );
|
|
|
|
|
widths[1] = FntCharsWidth( (const char*)second, secondLen );
|
|
|
|
|
maxWidth = XP_MAX( widths[0], widths[1] );
|
|
|
|
|
++nLines;
|
|
|
|
|
} else {
|
|
|
|
|
maxWidth = widths[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
height = nLines * FONT_HEIGHT + ( LINE_SPACING * (nLines-1) );
|
|
|
|
|
if ( vertical && isTurn ) {
|
|
|
|
|
height += 5; /* for the horizontal bars */
|
|
|
|
|
}
|
2004-05-16 17:06:39 +02:00
|
|
|
|
height *= doubler;
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
XP_ASSERT( height <= bounds->height );
|
|
|
|
|
XP_ASSERT( maxWidth <= bounds->width );
|
|
|
|
|
|
|
|
|
|
if ( draw ) {
|
|
|
|
|
XP_U16 x, y;
|
|
|
|
|
|
|
|
|
|
/* Center what we'll be drawing by advancing the appropriate
|
|
|
|
|
coordinate to eat up half the extra space */
|
|
|
|
|
x = bounds->left + 1;// + (bounds->width - widths[0]) / 2;
|
|
|
|
|
y = bounds->top;
|
|
|
|
|
if ( vertical && isTurn ) {
|
|
|
|
|
y += 1;
|
|
|
|
|
} else {
|
|
|
|
|
y -= 2;
|
2005-07-14 04:45:10 +02:00
|
|
|
|
if ( dctx->doHiRes ) {
|
|
|
|
|
--y; /* tweak it up one high-res pixel */
|
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 20:46:51 +01:00
|
|
|
|
WinDrawChars( (const char*)txt, len, x, y );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
if ( nLines == 2 ) {
|
|
|
|
|
XP_ASSERT( vertical );
|
2004-05-16 17:06:39 +02:00
|
|
|
|
y += (FONT_HEIGHT + LINE_SPACING) * doubler;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
x = bounds->left + ((bounds->width - widths[1]) / 2);
|
2003-11-16 20:46:51 +01:00
|
|
|
|
WinDrawChars( (const char*)second, secondLen, x, y );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
/* return the measurements */
|
|
|
|
|
bounds->width = maxWidth;
|
|
|
|
|
bounds->height = height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} /* palmMeasureDrawText */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
palmFormatRemText( PalmDrawCtx* dctx, XP_UCHAR* buf, XP_S16 nTilesLeft )
|
|
|
|
|
{
|
2007-02-03 18:54:20 +01:00
|
|
|
|
const XP_UCHAR* remStr = (*dctx->getResStrFunc)(dctx->globals, STR_REMTILES);
|
2003-11-16 20:37:12 +01:00
|
|
|
|
if ( nTilesLeft < 0 ) {
|
|
|
|
|
nTilesLeft = 0;
|
|
|
|
|
}
|
|
|
|
|
(void)StrPrintF( (char*)buf, (const char*)remStr, nTilesLeft );
|
|
|
|
|
} /* palmFormatRemText */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_measureRemText( DrawCtx* p_dctx, const XP_Rect* rect, XP_S16 nTilesLeft,
|
2003-11-16 20:37:12 +01:00
|
|
|
|
XP_U16* widthP, XP_U16* heightP )
|
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
PalmAppGlobals* globals = dctx->globals;
|
|
|
|
|
XP_UCHAR buf[10];
|
|
|
|
|
XP_Rect localRect;
|
|
|
|
|
XP_Bool isVertical = !globals->gState.showGrid;
|
|
|
|
|
|
|
|
|
|
palmFormatRemText( dctx, buf, nTilesLeft );
|
|
|
|
|
|
|
|
|
|
localRect = *rect;
|
|
|
|
|
palmMeasureDrawText( dctx, &localRect, buf, isVertical, XP_FALSE,
|
|
|
|
|
':', XP_FALSE );
|
|
|
|
|
|
|
|
|
|
*widthP = localRect.width;
|
|
|
|
|
*heightP = localRect.height;
|
|
|
|
|
} /* palm_draw_measureRemText */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_drawRemText( DrawCtx* p_dctx, const XP_Rect* rInner,
|
2006-08-16 15:44:44 +02:00
|
|
|
|
const XP_Rect* XP_UNUSED(rOuter), XP_S16 nTilesLeft )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
PalmAppGlobals* globals = dctx->globals;
|
|
|
|
|
XP_UCHAR buf[10];
|
|
|
|
|
|
|
|
|
|
XP_Bool isVertical = !globals->gState.showGrid;
|
|
|
|
|
|
|
|
|
|
palmFormatRemText( dctx, buf, nTilesLeft );
|
|
|
|
|
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palmMeasureDrawText( dctx, (XP_Rect*)rInner, buf, isVertical, XP_FALSE,
|
2003-11-16 20:37:12 +01:00
|
|
|
|
':', XP_TRUE );
|
|
|
|
|
} /* palm_draw_drawRemText */
|
|
|
|
|
|
|
|
|
|
/* Measure text that'll be drawn for player. If vertical, it'll often get
|
|
|
|
|
* split into two lines, esp after the number of remaining tiles appears.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palmFormatScore( char* buf, const DrawScoreInfo* dsi, XP_Bool vertical )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
char borders[] = {'<EFBFBD>', '\0'};
|
|
|
|
|
char remBuf[10];
|
|
|
|
|
char* remPart = remBuf;
|
|
|
|
|
|
|
|
|
|
if ( vertical || !dsi->isTurn ) {
|
|
|
|
|
borders[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( dsi->nTilesLeft >= 0 ) {
|
|
|
|
|
StrPrintF( remPart, SCORE_SEPSTR "%d", dsi->nTilesLeft );
|
|
|
|
|
} else {
|
|
|
|
|
*remPart = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(void)StrPrintF( buf, "%s%d%s%s", borders, dsi->score, remPart, borders );
|
|
|
|
|
} /* palmFormatScore */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_measureScoreText( DrawCtx* p_dctx, const XP_Rect* rect,
|
|
|
|
|
const DrawScoreInfo* dsi,
|
2003-11-16 20:37:12 +01:00
|
|
|
|
XP_U16* widthP, XP_U16* heightP )
|
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
PalmAppGlobals* globals = dctx->globals;
|
|
|
|
|
char buf[20];
|
|
|
|
|
/* FontID oldFont = 0; */
|
|
|
|
|
XP_Bool vertical = !globals->gState.showGrid;
|
|
|
|
|
XP_Rect localRect = *rect;
|
|
|
|
|
|
|
|
|
|
/* if ( !vertical && dsi->selected ) { */
|
|
|
|
|
/* oldFont = FntGetFont(); */
|
|
|
|
|
/* FntSetFont( boldFont ); */
|
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
|
|
palmFormatScore( buf, dsi, vertical );
|
2006-10-29 19:24:50 +01:00
|
|
|
|
palmMeasureDrawText( dctx, &localRect, (XP_UCHAR*)buf, dsi->isTurn,
|
|
|
|
|
vertical, SCORE_SEP, XP_FALSE );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
*widthP = localRect.width;
|
|
|
|
|
*heightP = localRect.height;
|
|
|
|
|
|
|
|
|
|
/* result = widthAndText( buf, score, nTilesInTray, isTurn, */
|
|
|
|
|
/* !globals->gState.showGrid, &ignore, ignoreLines ); */
|
|
|
|
|
|
|
|
|
|
/* if ( !vertical && dsi->selected ) { */
|
|
|
|
|
/* FntSetFont( oldFont ); */
|
|
|
|
|
/* } */
|
|
|
|
|
} /* palm_draw_measureScoreText */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-11-12 15:36:15 +01:00
|
|
|
|
doDrawPlayer( PalmDrawCtx* dctx, const DrawScoreInfo* dsi,
|
|
|
|
|
const XP_Rect* rInner )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmAppGlobals* globals = dctx->globals;
|
|
|
|
|
XP_Bool vertical = !globals->gState.showGrid;
|
2006-11-12 15:36:15 +01:00
|
|
|
|
XP_UCHAR scoreBuf[20];
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
palmFormatScore( (char*)scoreBuf, dsi, vertical );
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palmMeasureDrawText( dctx, (XP_Rect*)rInner, (XP_UCHAR*)scoreBuf, vertical,
|
2004-03-16 06:25:23 +01:00
|
|
|
|
dsi->isTurn, SCORE_SEP, XP_TRUE );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
if ( vertical && dsi->isTurn ) {
|
|
|
|
|
RectangleType r = *(RectangleType*)rInner;
|
|
|
|
|
XP_U16 x, y;
|
|
|
|
|
|
|
|
|
|
x = r.topLeft.x;
|
|
|
|
|
y = r.topLeft.y + 1;
|
|
|
|
|
|
|
|
|
|
WinDrawLine( x, y, x + r.extent.x - 1, y);
|
|
|
|
|
y += r.extent.y - 3;
|
|
|
|
|
WinDrawLine( x, y, x + r.extent.x - 1, y );
|
|
|
|
|
}
|
2006-11-12 15:36:15 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
palm_bnw_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
|
|
|
|
|
const XP_Rect* rOuter,
|
|
|
|
|
const DrawScoreInfo* dsi )
|
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
|
|
|
|
|
doDrawPlayer( dctx, dsi, rInner );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
if ( dsi->selected ) {
|
|
|
|
|
WinInvertRectangle( (RectangleType*)rInner, 0 );
|
|
|
|
|
}
|
|
|
|
|
} /* palm_bnw_draw_score_drawPlayer */
|
|
|
|
|
|
|
|
|
|
#define PENDING_DIGITS 3
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect,
|
2006-11-12 15:36:15 +01:00
|
|
|
|
XP_S16 score, XP_U16 XP_UNUSED(playerNum),
|
|
|
|
|
CellFlags flags )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
char buf[PENDING_DIGITS+1] = "000";
|
|
|
|
|
RectangleType oldClip, newClip;
|
|
|
|
|
XP_U16 x = rect->left + 1;
|
2006-11-12 15:36:15 +01:00
|
|
|
|
IndexedColorType oclr = 0;
|
|
|
|
|
|
|
|
|
|
XP_ASSERT( flags == CELL_NONE || flags == CELL_ISCURSOR );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2004-03-16 06:25:23 +01:00
|
|
|
|
HIGHRES_PUSH_LOC(dctx);
|
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
if ( flags != 0 ) {
|
|
|
|
|
oclr = WinSetBackColor( dctx->drawingPrefs->drawColors[COLOR_CURSOR] );
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
WinGetClip( &oldClip );
|
|
|
|
|
RctGetIntersection( &oldClip, (RectangleType*)rect, &newClip );
|
|
|
|
|
if ( newClip.extent.y > 0 ) {
|
|
|
|
|
WinSetClip( &newClip );
|
|
|
|
|
eraseRect( rect );
|
|
|
|
|
|
|
|
|
|
if ( score >= 0 ) {
|
|
|
|
|
XP_UCHAR tbuf[4];
|
|
|
|
|
UInt16 len;
|
|
|
|
|
if ( score <= 999 ) {
|
|
|
|
|
StrPrintF( (char*)tbuf, "%d", score );
|
|
|
|
|
} else {
|
|
|
|
|
StrCopy( (char*)tbuf, "wow" ); /* thanks, Marcus :-) */
|
|
|
|
|
}
|
|
|
|
|
len = XP_STRLEN( (const char*)tbuf );
|
|
|
|
|
XP_MEMCPY( &buf[PENDING_DIGITS-len], tbuf, len );
|
|
|
|
|
} else {
|
|
|
|
|
StrCopy( buf, "???" );
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-03 04:57:07 +01:00
|
|
|
|
/* There's no room for the pts string if we're in highres mode and
|
|
|
|
|
WinSetScalingMode isn't available. */
|
2006-03-31 12:57:01 +02:00
|
|
|
|
if ( !dctx->doHiRes || dctx->oneDotFiveAvail ) {
|
2007-02-03 18:54:20 +01:00
|
|
|
|
const XP_UCHAR* str = (*dctx->getResStrFunc)( dctx->globals,
|
|
|
|
|
STR_PTS );
|
2006-03-31 12:57:01 +02:00
|
|
|
|
|
|
|
|
|
if ( dctx->oneDotFiveAvail ) {
|
|
|
|
|
smallBoldStringAt( (const char*)str, XP_STRLEN((const char*)str),
|
|
|
|
|
x, rect->top );
|
|
|
|
|
} else {
|
|
|
|
|
WinDrawChars( (const char*)str,
|
|
|
|
|
XP_STRLEN((const char*)str), x, rect->top );
|
2004-11-03 04:57:07 +01:00
|
|
|
|
}
|
2006-03-31 12:57:01 +02:00
|
|
|
|
}
|
2004-11-03 04:57:07 +01:00
|
|
|
|
|
2003-11-16 20:46:51 +01:00
|
|
|
|
WinDrawChars( buf, PENDING_DIGITS, x,
|
2003-11-16 20:37:12 +01:00
|
|
|
|
rect->top + (rect->height/2) - 1 );
|
|
|
|
|
WinSetClip( &oldClip );
|
|
|
|
|
}
|
2004-03-16 06:25:23 +01:00
|
|
|
|
|
2006-11-12 15:36:15 +01:00
|
|
|
|
if ( flags != 0 ) {
|
|
|
|
|
(void)WinSetBackColor( oclr );
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-16 06:25:23 +01:00
|
|
|
|
HIGHRES_POP_LOC(dctx);
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_draw_score_pendingScore */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
palmFormatTimerText( XP_UCHAR* buf, XP_S16 secondsLeft )
|
|
|
|
|
{
|
|
|
|
|
XP_U16 minutes, seconds;
|
|
|
|
|
XP_UCHAR secBuf[6];
|
|
|
|
|
|
|
|
|
|
if ( secondsLeft < 0 ) {
|
|
|
|
|
*buf++ = '-';
|
|
|
|
|
secondsLeft *= -1;
|
|
|
|
|
}
|
|
|
|
|
minutes = secondsLeft / 60;
|
|
|
|
|
seconds = secondsLeft % 60;
|
|
|
|
|
|
|
|
|
|
/* StrPrintF can't do 0-padding; do it manually. Otherwise 5:03 will
|
|
|
|
|
come out 5:3 */
|
|
|
|
|
StrPrintF( (char*)secBuf, "0%d", seconds );
|
|
|
|
|
StrPrintF( (char*)buf, "%d:%s", minutes,
|
|
|
|
|
secBuf[2] == '\0'? secBuf:&secBuf[1] );
|
|
|
|
|
} /* palmFormatTimerText */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_drawTimer( DrawCtx* p_dctx, const XP_Rect* rInner,
|
2006-08-16 15:44:44 +02:00
|
|
|
|
const XP_Rect* XP_UNUSED(rOuter),
|
|
|
|
|
XP_U16 XP_UNUSED(player), XP_S16 secondsLeft )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
2005-06-23 06:21:35 +02:00
|
|
|
|
/* This is called both from within drawScoreboard and not, meaning that
|
|
|
|
|
* sometimes draw_boardBegin() and draw_boardFinished() bracket it and
|
|
|
|
|
* sometimes they don't. So it has to do its own HIGHRES_PUSH_LOC stuff.
|
|
|
|
|
*/
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
XP_UCHAR buf[10];
|
|
|
|
|
XP_Rect localR = *rInner;
|
|
|
|
|
RectangleType saveClip;
|
2005-07-14 04:45:10 +02:00
|
|
|
|
XP_U16 len, width, y;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2005-06-23 06:21:35 +02:00
|
|
|
|
HIGHRES_PUSH_LOC(dctx);
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
palmFormatTimerText( buf, secondsLeft );
|
|
|
|
|
len = XP_STRLEN( (const char*)buf );
|
|
|
|
|
|
|
|
|
|
width = FntCharsWidth( (const char*)buf, len );
|
|
|
|
|
|
|
|
|
|
eraseRect( &localR );
|
|
|
|
|
|
|
|
|
|
if ( width < localR.width ) {
|
|
|
|
|
localR.left += localR.width - width;
|
|
|
|
|
localR.width = width;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-14 04:45:10 +02:00
|
|
|
|
y = localR.top - 2;
|
|
|
|
|
if ( dctx->doHiRes ) {
|
|
|
|
|
y -= 1; /* tweak it up one high-res pixel */
|
2005-06-23 06:21:35 +02:00
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
WinGetClip( &saveClip );
|
|
|
|
|
WinSetClip( (RectangleType*)&localR );
|
2005-06-23 06:21:35 +02:00
|
|
|
|
|
2005-07-14 04:45:10 +02:00
|
|
|
|
WinDrawChars( (const char*)buf, len, localR.left, y );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
WinSetClip( &saveClip );
|
2005-06-23 06:21:35 +02:00
|
|
|
|
|
|
|
|
|
HIGHRES_POP_LOC(dctx);
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_draw_drawTimer */
|
|
|
|
|
|
|
|
|
|
#define MINI_LINE_HT 12
|
|
|
|
|
#define MINI_V_PADDING 6
|
|
|
|
|
#define MINI_H_PADDING 8
|
|
|
|
|
|
2007-02-03 18:54:20 +01:00
|
|
|
|
static const XP_UCHAR*
|
2003-11-16 20:37:12 +01:00
|
|
|
|
palm_draw_getMiniWText( DrawCtx* p_dctx, XWMiniTextType textHint )
|
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
2007-02-03 18:54:20 +01:00
|
|
|
|
const XP_UCHAR* str;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
XP_U16 strID = 0; /* make compiler happy */
|
|
|
|
|
|
|
|
|
|
switch( textHint ) {
|
|
|
|
|
case BONUS_DOUBLE_LETTER:
|
|
|
|
|
strID = STR_DOUBLE_LETTER; break;
|
|
|
|
|
case BONUS_DOUBLE_WORD:
|
|
|
|
|
strID = STR_DOUBLE_WORD; break;
|
|
|
|
|
case BONUS_TRIPLE_LETTER:
|
|
|
|
|
strID = STR_TRIPLE_LETTER; break;
|
|
|
|
|
case BONUS_TRIPLE_WORD:
|
|
|
|
|
strID = STR_TRIPLE_WORD; break;
|
|
|
|
|
case INTRADE_MW_TEXT:
|
|
|
|
|
strID = STR_TRADING_REMINDER; break;
|
|
|
|
|
default:
|
|
|
|
|
XP_ASSERT( XP_FALSE );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
str = (*dctx->getResStrFunc)( dctx->globals, strID );
|
|
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
} /* palm_draw_getMiniWText */
|
|
|
|
|
|
2004-04-30 10:35:51 +02:00
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
splitString( const XP_UCHAR* str, XP_U16* nBufsP, XP_UCHAR** bufs )
|
2004-04-30 10:35:51 +02:00
|
|
|
|
{
|
|
|
|
|
XP_U16 nBufs = 0;
|
|
|
|
|
|
|
|
|
|
for ( ; ; ) {
|
|
|
|
|
XP_UCHAR* nextStr = StrStr( str, XP_CR );
|
|
|
|
|
XP_U16 len = nextStr==NULL? XP_STRLEN(str): nextStr - str;
|
|
|
|
|
|
|
|
|
|
XP_ASSERT( nextStr != str );
|
|
|
|
|
|
|
|
|
|
XP_MEMCPY( bufs[nBufs], str, len );
|
|
|
|
|
bufs[nBufs][len] = '\0';
|
|
|
|
|
++nBufs;
|
|
|
|
|
|
|
|
|
|
if ( nextStr == NULL ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
str = nextStr + XP_STRLEN(XP_CR); /* skip '\n' */
|
|
|
|
|
}
|
|
|
|
|
*nBufsP = nBufs;
|
|
|
|
|
} /* splitString */
|
|
|
|
|
|
|
|
|
|
#define VALUE_HINT_RECT_HEIGHT 12
|
2004-05-06 06:11:04 +02:00
|
|
|
|
#define VALUE_HINT_RECT_HEIGHT_HR 24
|
|
|
|
|
static XP_U16
|
|
|
|
|
getMiniLineHt( PalmDrawCtx* dctx )
|
|
|
|
|
{
|
2006-03-31 12:57:01 +02:00
|
|
|
|
if ( dctx->doHiRes ) {
|
2004-05-06 06:11:04 +02:00
|
|
|
|
return VALUE_HINT_RECT_HEIGHT_HR;
|
|
|
|
|
} else {
|
|
|
|
|
return VALUE_HINT_RECT_HEIGHT;
|
|
|
|
|
}
|
|
|
|
|
} /* getMiniLineHt */
|
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_measureMiniWText( DrawCtx* p_dctx, const XP_UCHAR* str,
|
2003-11-16 20:37:12 +01:00
|
|
|
|
XP_U16* widthP, XP_U16* heightP )
|
|
|
|
|
{
|
2004-04-30 10:35:51 +02:00
|
|
|
|
XP_U16 maxWidth, height;
|
|
|
|
|
XP_UCHAR buf1[48];
|
|
|
|
|
XP_UCHAR buf2[48];
|
|
|
|
|
XP_UCHAR* bufs[2] = { buf1, buf2 };
|
|
|
|
|
XP_U16 nBufs, i;
|
|
|
|
|
|
|
|
|
|
HIGHRES_PUSH_LOC( (PalmDrawCtx*)p_dctx );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
FntSetFont( stdFont );
|
2004-04-30 10:35:51 +02:00
|
|
|
|
|
|
|
|
|
splitString( str, &nBufs, bufs );
|
|
|
|
|
|
|
|
|
|
for ( height = 0, maxWidth = 0, i = 0; i < nBufs; ++i ) {
|
|
|
|
|
XP_U16 oneWidth = 8 + FntCharsWidth( (const char*)bufs[i],
|
|
|
|
|
XP_STRLEN(bufs[i]) );
|
|
|
|
|
|
|
|
|
|
maxWidth = XP_MAX( maxWidth, oneWidth );
|
2004-05-06 06:11:04 +02:00
|
|
|
|
height += getMiniLineHt((PalmDrawCtx*)p_dctx);
|
2004-03-17 05:57:09 +01:00
|
|
|
|
}
|
2004-03-16 06:25:23 +01:00
|
|
|
|
|
2004-04-30 10:35:51 +02:00
|
|
|
|
*widthP = maxWidth;
|
2007-01-21 23:59:29 +01:00
|
|
|
|
*heightP = height + 4;
|
2004-04-30 10:35:51 +02:00
|
|
|
|
|
2004-03-16 06:25:23 +01:00
|
|
|
|
HIGHRES_POP_LOC( (PalmDrawCtx*)p_dctx );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_draw_measureMiniWText */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-02-18 07:39:40 +01:00
|
|
|
|
palm_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
|
2007-01-18 06:49:07 +01:00
|
|
|
|
const XP_Rect* rect, void** XP_UNUSED(closureP) )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
2007-01-18 06:49:07 +01:00
|
|
|
|
XP_Rect localR;
|
2004-04-30 10:35:51 +02:00
|
|
|
|
XP_UCHAR buf1[48];
|
|
|
|
|
XP_UCHAR buf2[48];
|
|
|
|
|
XP_UCHAR* bufs[2] = { buf1, buf2 };
|
|
|
|
|
XP_U16 nBufs, i, offset;
|
2004-02-13 14:54:52 +01:00
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
2004-03-16 06:25:23 +01:00
|
|
|
|
HIGHRES_PUSH_LOC(dctx);
|
|
|
|
|
|
2007-01-18 06:49:07 +01:00
|
|
|
|
localR = *rect;
|
|
|
|
|
insetRect( &localR, 1 );
|
|
|
|
|
WinEraseRectangle( (RectangleType*)&localR, 0 );
|
|
|
|
|
localR.left++;
|
|
|
|
|
localR.top++;
|
|
|
|
|
localR.width -= 3;
|
|
|
|
|
localR.height -= 3;
|
|
|
|
|
WinDrawRectangleFrame( popupFrame, (RectangleType*)&localR );
|
2004-04-30 10:35:51 +02:00
|
|
|
|
|
|
|
|
|
splitString( text, &nBufs, bufs );
|
|
|
|
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
for ( i = 0; i < nBufs; ++i ) {
|
|
|
|
|
XP_UCHAR* txt = bufs[i];
|
|
|
|
|
XP_U16 len = XP_STRLEN( txt );
|
|
|
|
|
XP_U16 width = FntCharsWidth( txt, len );
|
|
|
|
|
|
|
|
|
|
WinDrawChars( (const char*)txt, len,
|
2007-01-18 06:49:07 +01:00
|
|
|
|
localR.left + ((localR.width-width)/2),
|
|
|
|
|
localR.top + 1 + offset );
|
2004-05-06 06:11:04 +02:00
|
|
|
|
offset += getMiniLineHt( dctx );
|
2004-04-30 10:35:51 +02:00
|
|
|
|
}
|
2004-03-16 06:25:23 +01:00
|
|
|
|
|
|
|
|
|
HIGHRES_POP_LOC( dctx );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
} /* palm_draw_drawMiniWindow */
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-16 15:44:44 +02:00
|
|
|
|
draw_doNothing( DrawCtx* XP_UNUSED(dctx), ... )
|
2003-11-16 20:37:12 +01:00
|
|
|
|
{
|
|
|
|
|
} /* draw_doNothing */
|
|
|
|
|
|
|
|
|
|
DrawCtx*
|
|
|
|
|
palm_drawctxt_make( MPFORMAL GraphicsAbility able,
|
|
|
|
|
PalmAppGlobals* globals,
|
|
|
|
|
GetResStringFunc getRSF, DrawingPrefs* drawprefs )
|
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx;
|
|
|
|
|
XP_U16 i;
|
2004-11-14 17:19:21 +01:00
|
|
|
|
XP_U16 cWinWidth, cWinHeight;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
dctx = XP_MALLOC( mpool, sizeof(PalmDrawCtx) );
|
|
|
|
|
XP_MEMSET( dctx, 0, sizeof(PalmDrawCtx) );
|
|
|
|
|
|
|
|
|
|
MPASSIGN(dctx->mpool, mpool);
|
|
|
|
|
|
|
|
|
|
dctx->able = able;
|
2004-03-18 06:41:59 +01:00
|
|
|
|
dctx->doHiRes = globals->hasHiRes && globals->width == 320;
|
2003-11-16 20:37:12 +01:00
|
|
|
|
dctx->globals = globals;
|
|
|
|
|
dctx->getResStrFunc = getRSF;
|
|
|
|
|
dctx->drawingPrefs = drawprefs;
|
|
|
|
|
|
|
|
|
|
dctx->vtable = XP_MALLOC( mpool,
|
|
|
|
|
sizeof(*(((PalmDrawCtx*)dctx)->vtable)) );
|
|
|
|
|
for ( i = 0; i < sizeof(*dctx->vtable)/4; ++i ) {
|
|
|
|
|
((void**)(dctx->vtable))[i] = draw_doNothing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* To keep the number of entry points this file has to 1, all
|
|
|
|
|
functions but the initter called from here must go through a
|
|
|
|
|
vtable call. so....*/
|
|
|
|
|
dctx->drawBitmapFunc = drawBitmapAt;
|
|
|
|
|
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_invertCell, palm );
|
|
|
|
|
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTile, palm );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTileBack, palm );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTrayDivider, palm );
|
|
|
|
|
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawBoardArrow, palm );
|
|
|
|
|
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_scoreBegin, palm );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_vertScrollBoard, palm );
|
|
|
|
|
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_measureRemText, palm );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawRemText, palm );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_measureScoreText, palm );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_score_pendingScore, palm );
|
2006-11-05 17:54:18 +01:00
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_objFinished, palm );
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTimer, palm );
|
|
|
|
|
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_getMiniWText, palm );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, palm );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, palm );
|
|
|
|
|
|
|
|
|
|
if ( able == COLOR ) {
|
|
|
|
|
#ifdef COLOR_SUPPORT
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_boardBegin, palm_clr );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, palm_clr );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_score_drawPlayer, palm_clr );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, palm_clr );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, palm_clr );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, palm_clr );
|
|
|
|
|
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawBoardArrow, palm_clr );
|
|
|
|
|
#else
|
|
|
|
|
XP_ASSERT(0);
|
|
|
|
|
#endif
|
|
|
|
|
} else {
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_boardBegin, palm_common );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, palm_common );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_score_drawPlayer, palm_bnw );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, palm_bnw );
|
|
|
|
|
SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, palm_bnw );
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-14 17:19:21 +01:00
|
|
|
|
cWinWidth = CHARRECT_WIDTH;
|
|
|
|
|
cWinHeight = CHARRECT_HEIGHT;
|
2004-03-17 05:57:09 +01:00
|
|
|
|
if ( dctx->doHiRes ) {
|
2004-11-14 17:19:21 +01:00
|
|
|
|
cWinWidth *= 2;
|
|
|
|
|
cWinHeight *= 2;
|
2004-03-17 05:57:09 +01:00
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
|
|
|
|
|
if ( able == COLOR ) {
|
|
|
|
|
} else {
|
|
|
|
|
short patBits[] = { 0x8844, 0x2211, 0x8844, 0x2211,
|
|
|
|
|
0xaa55, 0xaa55, 0xaa55, 0xaa55,
|
|
|
|
|
0xCC66, 0x3399, 0xCC66, 0x3399,
|
|
|
|
|
0xCCCC, 0x3333, 0xCCCC, 0x3333 };
|
|
|
|
|
XP_MEMCPY( &dctx->u.bnw.valuePatterns[0], patBits, sizeof(patBits) );
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-30 21:25:23 +02:00
|
|
|
|
dctx->fntHeight = FntBaseLine();
|
2004-11-02 07:05:23 +01:00
|
|
|
|
dctx->oneDotFiveAvail = globals->oneDotFiveAvail;
|
2004-10-30 21:25:23 +02:00
|
|
|
|
|
2003-11-16 20:37:12 +01:00
|
|
|
|
return (DrawCtx*)dctx;
|
|
|
|
|
} /* palm_drawctxt_make */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
palm_drawctxt_destroy( DrawCtx* p_dctx )
|
|
|
|
|
{
|
|
|
|
|
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
|
|
|
|
|
|
|
|
|
|
XP_FREE( dctx->mpool, p_dctx->vtable );
|
2005-07-08 05:14:43 +02:00
|
|
|
|
if ( !!dctx->fontHtInfo ) {
|
|
|
|
|
XP_FREE( dctx->mpool, dctx->fontHtInfo );
|
2005-07-07 05:46:07 +02:00
|
|
|
|
}
|
2003-11-16 20:37:12 +01:00
|
|
|
|
XP_FREE( dctx->mpool, dctx );
|
|
|
|
|
} /* palm_drawctxt_destroy */
|