mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
first cut at supporting landscape mode by moving scoreboard to left edge of screen from top.
This commit is contained in:
parent
14c973354b
commit
58f4b08623
4 changed files with 260 additions and 162 deletions
|
@ -32,6 +32,9 @@
|
|||
#define CE_TIMER_WIDTH 35
|
||||
#define CE_SCORE_WIDTH (4 * 51)
|
||||
|
||||
#define CE_TIMER_HT_HORIZ CE_SCORE_HEIGHT
|
||||
#define CE_TIMER_HT_VERT CE_SCORE_WIDTH
|
||||
|
||||
#if 1 /* Palm-like case */
|
||||
|
||||
#define CE_SCORE_TOP 0
|
||||
|
|
221
wince/cedraw.c
221
wince/cedraw.c
|
@ -37,6 +37,9 @@
|
|||
#define DRAW_FUNC_NAME(nam) ce_draw_ ## nam
|
||||
#endif
|
||||
|
||||
#define CE_MINI_V_PADDING 6
|
||||
#define CE_INTERLINE_SPACE 0
|
||||
|
||||
static void ceClearToBkground( CEDrawCtx* dctx, const XP_Rect* rect );
|
||||
static void ceDrawBitmapInRect( HDC hdc, const RECT* r, HBITMAP bitmap );
|
||||
|
||||
|
@ -107,6 +110,73 @@ makeAndDrawBitmap( CEDrawCtx* dctx, HDC hdc, const RECT* bnds, XP_Bool center,
|
|||
#endif
|
||||
} /* makeAndDrawBitmap */
|
||||
|
||||
static void
|
||||
measureText( CEDrawCtx* dctx, const XP_UCHAR* str,
|
||||
XP_U16* widthP, XP_U16* heightP )
|
||||
{
|
||||
HDC hdc = GetDC(dctx->mainWin);//globals->hdc;
|
||||
XP_U16 height, maxWidth;
|
||||
|
||||
for ( height = CE_MINI_V_PADDING, maxWidth = 0; ; ) {
|
||||
wchar_t widebuf[64];
|
||||
XP_UCHAR* nextStr = strstr( str, XP_CR );
|
||||
XP_U16 len = nextStr==NULL? strlen(str): nextStr - str;
|
||||
SIZE size;
|
||||
|
||||
XP_ASSERT( nextStr != str );
|
||||
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str, len,
|
||||
widebuf, sizeof(widebuf)/sizeof(widebuf[0]) );
|
||||
widebuf[len] = 0;
|
||||
GetTextExtentPoint32( hdc, widebuf, wcslen(widebuf), &size );
|
||||
|
||||
maxWidth = (XP_U16)XP_MAX( maxWidth, size.cx );
|
||||
height += size.cy + CE_INTERLINE_SPACE;
|
||||
dctx->miniLineHt = (XP_U16)size.cy;
|
||||
|
||||
if ( nextStr == NULL ) {
|
||||
break;
|
||||
}
|
||||
str = nextStr + XP_STRLEN(XP_CR); /* skip '\n' */
|
||||
}
|
||||
|
||||
*widthP = maxWidth + 8;
|
||||
*heightP = height;
|
||||
}
|
||||
|
||||
static void
|
||||
drawLines( CEDrawCtx* dctx, HDC hdc, const XP_UCHAR* text, const RECT* rp,
|
||||
int flags )
|
||||
{
|
||||
wchar_t widebuf[128];
|
||||
RECT textRt = *rp;
|
||||
|
||||
for ( ; ; ) { /* draw up to the '\n' each time */
|
||||
XP_UCHAR* nextStr = strstr( text, XP_CR );
|
||||
XP_U16 len;
|
||||
|
||||
if ( nextStr == NULL ) {
|
||||
len = XP_STRLEN(text);
|
||||
} else {
|
||||
len = nextStr - text;
|
||||
}
|
||||
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, text, len,
|
||||
widebuf, sizeof(widebuf)/sizeof(widebuf[0]) );
|
||||
widebuf[len] = 0;
|
||||
|
||||
textRt.bottom = textRt.top + dctx->miniLineHt;
|
||||
|
||||
DrawText( hdc, widebuf, -1, &textRt, flags );
|
||||
|
||||
if ( nextStr == NULL ) {
|
||||
break;
|
||||
}
|
||||
textRt.top = textRt.bottom + CE_INTERLINE_SPACE;
|
||||
text = nextStr + XP_STRLEN(XP_CR);
|
||||
}
|
||||
} /* drawLines */
|
||||
|
||||
DLSTATIC XP_Bool
|
||||
DRAW_FUNC_NAME(boardBegin)( DrawCtx* p_dctx, const DictionaryCtxt* dict,
|
||||
const XP_Rect* rect, XP_Bool hasfocus )
|
||||
|
@ -278,6 +348,7 @@ DRAW_FUNC_NAME(invertCell)( DrawCtx* p_dctx, const XP_Rect* rect )
|
|||
} /* ce_draw_invertCell */
|
||||
|
||||
#ifdef DEBUG
|
||||
#if 0
|
||||
static char*
|
||||
logClipResult( int icrResult )
|
||||
{
|
||||
|
@ -292,6 +363,7 @@ logClipResult( int icrResult )
|
|||
return "unknown";
|
||||
} /* logClipResult */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
DLSTATIC XP_Bool
|
||||
DRAW_FUNC_NAME(trayBegin)( DrawCtx* p_dctx, const XP_Rect* rect, XP_U16 owner,
|
||||
|
@ -496,20 +568,24 @@ DRAW_FUNC_NAME(scoreBegin)( DrawCtx* p_dctx, const XP_Rect* rect,
|
|||
HDC hdc = globals->hdc;
|
||||
SetBkColor( hdc, dctx->globals->appPrefs.colors[BKG_COLOR] );
|
||||
|
||||
dctx->scoreIsVertical = rect->height > rect->width;
|
||||
|
||||
ceClearToBkground( (CEDrawCtx*)p_dctx, rect );
|
||||
} /* ce_draw_scoreBegin */
|
||||
|
||||
static void
|
||||
formatRemText( HDC hdc, wchar_t* buf, XP_S16 nTilesLeft, SIZE* size )
|
||||
formatRemText( HDC hdc, XP_S16 nTilesLeft, XP_Bool isVertical, XP_UCHAR* buf )
|
||||
{
|
||||
wchar_t* format = L"Rem:%d";
|
||||
|
||||
if ( nTilesLeft <= 0 ) {
|
||||
buf[0] = 0;
|
||||
size->cx = size->cy = 0;
|
||||
} else {
|
||||
swprintf( buf, format, nTilesLeft );
|
||||
GetTextExtentPoint32( hdc, buf, wcslen(buf), size );
|
||||
} else {
|
||||
char* fmt;
|
||||
if ( isVertical ) {
|
||||
fmt = "Rem" XP_CR "%d";
|
||||
} else {
|
||||
fmt = "Rem:%d";
|
||||
}
|
||||
sprintf( buf, fmt, nTilesLeft );
|
||||
}
|
||||
} /* formatRemText */
|
||||
|
||||
|
@ -521,13 +597,10 @@ DRAW_FUNC_NAME(measureRemText)( DrawCtx* p_dctx, const XP_Rect* r,
|
|||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||
CEAppGlobals* globals = dctx->globals;
|
||||
HDC hdc = globals->hdc;
|
||||
wchar_t buf[16];
|
||||
SIZE size;
|
||||
XP_UCHAR buf[16];
|
||||
|
||||
formatRemText( hdc, buf, nTilesLeft, &size );
|
||||
|
||||
*width = (XP_U16)size.cx + 1; /* 1: don't write up against edge */
|
||||
*height = (XP_U16)size.cy;
|
||||
formatRemText( hdc, nTilesLeft, dctx->scoreIsVertical, buf );
|
||||
measureText( dctx, buf, width, height );
|
||||
} /* ce_draw_measureRemText */
|
||||
|
||||
DLSTATIC void
|
||||
|
@ -537,44 +610,45 @@ DRAW_FUNC_NAME(drawRemText)( DrawCtx* p_dctx, const XP_Rect* rInner,
|
|||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||
CEAppGlobals* globals = dctx->globals;
|
||||
HDC hdc = globals->hdc;
|
||||
wchar_t buf[16];
|
||||
XP_UCHAR buf[16];
|
||||
RECT rt;
|
||||
SIZE size;
|
||||
|
||||
formatRemText( hdc, buf, nTilesLeft, &size );
|
||||
formatRemText( hdc, nTilesLeft, dctx->scoreIsVertical, buf );
|
||||
|
||||
XPRtoRECT( &rt, rInner );
|
||||
++rt.left; /* 1: don't write up against edge */
|
||||
DrawText( hdc, buf, -1, &rt, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
|
||||
drawLines( dctx, hdc, buf, &rt, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_CENTER );
|
||||
} /* ce_draw_drawRemText */
|
||||
|
||||
static void
|
||||
ceWidthAndText( HDC hdc, wchar_t* buf, const DrawScoreInfo* dsi,
|
||||
XP_U16* widthP, XP_U16* heightP )
|
||||
ceWidthAndText( CEDrawCtx* dctx, HDC hdc, const DrawScoreInfo* dsi, XP_Bool isVertical,
|
||||
XP_UCHAR* buf, XP_U16* widthP, XP_U16* heightP )
|
||||
{
|
||||
XP_UCHAR borders[] = {'•', '\0'};
|
||||
XP_UCHAR tilesLeftTxt[8];
|
||||
XP_UCHAR tbuf[10]; /* *9999:7* is 8 chars */
|
||||
SIZE size;
|
||||
XP_U16 len;
|
||||
|
||||
if ( !dsi->isTurn ) {
|
||||
borders[0] = '\0';
|
||||
}
|
||||
|
||||
if ( dsi->nTilesLeft >= 0 ) {
|
||||
sprintf( tilesLeftTxt, ":%d", dsi->nTilesLeft );
|
||||
if ( isVertical ) {
|
||||
sprintf( buf, "%d", dsi->score );
|
||||
XP_LOGF( "%s: write %s", __FUNCTION__, buf );
|
||||
if ( dsi->nTilesLeft >= 0 ) {
|
||||
XP_UCHAR smallBuf[32];
|
||||
sprintf( smallBuf, XP_CR "%s%d%s", borders, dsi->nTilesLeft, borders );
|
||||
strcat( buf, smallBuf );
|
||||
}
|
||||
} else {
|
||||
tilesLeftTxt[0] = '\0';
|
||||
if ( dsi->nTilesLeft >= 0 ) {
|
||||
sprintf( tilesLeftTxt, ":%d", dsi->nTilesLeft );
|
||||
} else {
|
||||
tilesLeftTxt[0] = '\0';
|
||||
}
|
||||
sprintf( buf, "%s%d%s%s", borders, dsi->score, tilesLeftTxt, borders );
|
||||
}
|
||||
sprintf( tbuf, "%s%d%s%s", borders, dsi->score, tilesLeftTxt, borders );
|
||||
|
||||
len = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, tbuf, -1,
|
||||
buf, 10 );
|
||||
|
||||
GetTextExtentPoint32( hdc, buf, len, &size );
|
||||
*widthP = (XP_U16)size.cx;
|
||||
*heightP = (XP_U16)size.cy;
|
||||
measureText( dctx, buf, widthP, heightP );
|
||||
} /* ceWidthAndText */
|
||||
|
||||
DLSTATIC void
|
||||
|
@ -585,7 +659,7 @@ DRAW_FUNC_NAME(measureScoreText)( DrawCtx* p_dctx, const XP_Rect* r,
|
|||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||
CEAppGlobals* globals = dctx->globals;
|
||||
HDC hdc = globals->hdc;
|
||||
wchar_t widebuf[10];
|
||||
XP_UCHAR buf[16];
|
||||
HFONT newFont;
|
||||
HFONT oldFont;
|
||||
|
||||
|
@ -596,7 +670,8 @@ DRAW_FUNC_NAME(measureScoreText)( DrawCtx* p_dctx, const XP_Rect* r,
|
|||
}
|
||||
oldFont = SelectObject( hdc, newFont );
|
||||
|
||||
ceWidthAndText( hdc, widebuf, dsi, widthP, heightP );
|
||||
ceWidthAndText( dctx, hdc, dsi, dctx->scoreIsVertical,
|
||||
buf, widthP, heightP );
|
||||
|
||||
SelectObject( hdc, oldFont );
|
||||
} /* ce_draw_measureScoreText */
|
||||
|
@ -611,7 +686,7 @@ DRAW_FUNC_NAME(score_drawPlayer)( DrawCtx* p_dctx,
|
|||
HDC hdc = globals->hdc;
|
||||
RECT rt;
|
||||
XP_U16 width, height;
|
||||
wchar_t scoreBuf[20];
|
||||
XP_UCHAR scoreBuf[20];
|
||||
HFONT newFont;
|
||||
HFONT oldFont;
|
||||
|
||||
|
@ -626,9 +701,10 @@ DRAW_FUNC_NAME(score_drawPlayer)( DrawCtx* p_dctx,
|
|||
SetTextColor( hdc, dctx->globals->
|
||||
appPrefs.colors[getPlayerColor(dsi->playerNum)] );
|
||||
|
||||
ceWidthAndText( hdc, scoreBuf, dsi, &width, &height );
|
||||
DrawText( hdc, scoreBuf, -1, &rt,
|
||||
DT_SINGLELINE | DT_VCENTER | DT_CENTER );
|
||||
ceWidthAndText( dctx, hdc, dsi, dctx->scoreIsVertical,
|
||||
scoreBuf, &width, &height );
|
||||
|
||||
drawLines( dctx, hdc, scoreBuf, &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER );
|
||||
|
||||
SelectObject( hdc, oldFont );
|
||||
} /* ce_draw_score_drawPlayer */
|
||||
|
@ -680,7 +756,7 @@ DRAW_FUNC_NAME(drawTimer)( DrawCtx* p_dctx,
|
|||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||
CEAppGlobals* globals = dctx->globals;
|
||||
HDC hdc = globals->hdc;
|
||||
wchar_t widebuf[10];
|
||||
XP_UCHAR buf[16];
|
||||
XP_U16 mins, secs;
|
||||
RECT rt;
|
||||
PAINTSTRUCT ps;
|
||||
|
@ -696,7 +772,9 @@ DRAW_FUNC_NAME(drawTimer)( DrawCtx* p_dctx,
|
|||
mins = secondsLeft / 60;
|
||||
secs = secondsLeft % 60;
|
||||
|
||||
swprintf( widebuf, L"%s%.1d:%.2d", isNegative? L"-": L"", mins, secs );
|
||||
snprintf( buf, sizeof(buf),
|
||||
dctx->scoreIsVertical? "%s%.1dm" XP_CR "%.2ds" : "%s%.1d:%.2d",
|
||||
isNegative? "-": "", mins, secs );
|
||||
|
||||
if ( !globals->hdc ) {
|
||||
InvalidateRect( dctx->mainWin, &rt, FALSE );
|
||||
|
@ -705,7 +783,7 @@ DRAW_FUNC_NAME(drawTimer)( DrawCtx* p_dctx,
|
|||
|
||||
SetTextColor( hdc, dctx->globals->appPrefs.colors[getPlayerColor(player)] );
|
||||
ceClearToBkground( dctx, rInner );
|
||||
DrawText( hdc, widebuf, -1, &rt, DT_SINGLELINE | DT_VCENTER | DT_RIGHT);
|
||||
drawLines( dctx, hdc, buf, &rt, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
|
||||
|
||||
if ( !globals->hdc ) {
|
||||
EndPaint( dctx->mainWin, &ps );
|
||||
|
@ -735,44 +813,12 @@ DRAW_FUNC_NAME(getMiniWText)( DrawCtx* p_dctx, XWMiniTextType whichText )
|
|||
return str;
|
||||
} /* ce_draw_getMiniWText */
|
||||
|
||||
#define CE_MINI_V_PADDING 6
|
||||
#define CE_INTERLINE_SPACE 0
|
||||
|
||||
DLSTATIC void
|
||||
DRAW_FUNC_NAME(measureMiniWText)( DrawCtx* p_dctx, const XP_UCHAR* str,
|
||||
XP_U16* widthP, XP_U16* heightP )
|
||||
{
|
||||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||
CEAppGlobals* globals = dctx->globals;
|
||||
HDC hdc = GetDC(dctx->mainWin);//globals->hdc;
|
||||
XP_Bool lastLine = XP_FALSE;
|
||||
XP_U16 height, maxWidth;
|
||||
|
||||
for ( height = CE_MINI_V_PADDING, maxWidth = 0; ; ) {
|
||||
wchar_t widebuf[64];
|
||||
XP_UCHAR* nextStr = strstr( str, XP_CR );
|
||||
XP_U16 len = nextStr==NULL? strlen(str): nextStr - str;
|
||||
SIZE size;
|
||||
|
||||
XP_ASSERT( nextStr != str );
|
||||
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, str, len,
|
||||
widebuf, sizeof(widebuf)/sizeof(widebuf[0]) );
|
||||
widebuf[len] = 0;
|
||||
GetTextExtentPoint32( hdc, widebuf, wcslen(widebuf), &size );
|
||||
|
||||
maxWidth = (XP_U16)XP_MAX( maxWidth, size.cx );
|
||||
height += size.cy + CE_INTERLINE_SPACE;
|
||||
dctx->miniLineHt = (XP_U16)size.cy;
|
||||
|
||||
if ( nextStr == NULL ) {
|
||||
break;
|
||||
}
|
||||
str = nextStr + XP_STRLEN(XP_CR); /* skip '\n' */
|
||||
}
|
||||
|
||||
*widthP = maxWidth + 8;
|
||||
*heightP = height;
|
||||
measureText( dctx, str, widthP, heightP );
|
||||
} /* ce_draw_measureMiniWText */
|
||||
|
||||
DLSTATIC void
|
||||
|
@ -784,7 +830,6 @@ DRAW_FUNC_NAME(drawMiniWindow)( DrawCtx* p_dctx, const XP_UCHAR* text,
|
|||
HDC hdc;
|
||||
RECT rt, textRt;
|
||||
PAINTSTRUCT ps;
|
||||
wchar_t widebuf[64];
|
||||
|
||||
XPRtoRECT( &rt, rect );
|
||||
|
||||
|
@ -808,30 +853,7 @@ DRAW_FUNC_NAME(drawMiniWindow)( DrawCtx* p_dctx, const XP_UCHAR* text,
|
|||
textRt.top += 2;
|
||||
InsetRect( &textRt, 3, 0 );
|
||||
|
||||
for ( ; ; ) { /* draw up to the '\n' each time */
|
||||
XP_UCHAR* nextStr = strstr( text, XP_CR );
|
||||
XP_U16 len;
|
||||
|
||||
if ( nextStr == NULL ) {
|
||||
len = XP_STRLEN(text);
|
||||
} else {
|
||||
len = nextStr - text;
|
||||
}
|
||||
|
||||
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, text, len,
|
||||
widebuf, sizeof(widebuf)/sizeof(widebuf[0]) );
|
||||
widebuf[len] = 0;
|
||||
|
||||
textRt.bottom = textRt.top + dctx->miniLineHt;
|
||||
|
||||
DrawText( hdc, widebuf, -1, &textRt, DT_CENTER | DT_VCENTER );
|
||||
|
||||
if ( nextStr == NULL ) {
|
||||
break;
|
||||
}
|
||||
textRt.top = textRt.bottom + CE_INTERLINE_SPACE;
|
||||
text = nextStr + XP_STRLEN(XP_CR);
|
||||
}
|
||||
drawLines( dctx, hdc, text, &textRt, DT_CENTER | DT_VCENTER );
|
||||
|
||||
if ( !globals->hdc ) {
|
||||
EndPaint( dctx->mainWin, &ps );
|
||||
|
@ -922,7 +944,6 @@ ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals )
|
|||
{
|
||||
CEDrawCtx* dctx = (CEDrawCtx*)XP_MALLOC( mpool,
|
||||
sizeof(*dctx) );
|
||||
XP_U16 i;
|
||||
|
||||
#ifndef DRAW_LINK_DIRECT
|
||||
dctx->vtable = (DrawCtxVTable*)XP_MALLOC( mpool, sizeof(*((dctx)->vtable)));
|
||||
|
|
197
wince/cemain.c
197
wince/cemain.c
|
@ -371,98 +371,171 @@ hideScroller( CEAppGlobals* globals )
|
|||
#define MIN_CELL_HEIGHT 12
|
||||
#if defined TARGET_OS_WINCE
|
||||
# define MIN_TRAY_HEIGHT 20
|
||||
# define CE_MIN_SCORE_WIDTH 20 /* for vertical score case */
|
||||
#elif defined TARGET_OS_WIN32
|
||||
# define MIN_TRAY_HEIGHT 40
|
||||
# define CE_MIN_SCORE_WIDTH 34
|
||||
#endif
|
||||
#define TRAY_PADDING 1
|
||||
|
||||
typedef struct CEBoardParms {
|
||||
XP_U16 boardHScale;
|
||||
XP_U16 boardVScale;
|
||||
XP_U16 boardTop;
|
||||
XP_U16 trayTop;
|
||||
XP_U16 trayVScale;
|
||||
XP_U16 trayHScale;
|
||||
XP_U16 leftEdge;
|
||||
|
||||
XP_U16 trayHeight;
|
||||
XP_U16 trayWidth;
|
||||
|
||||
XP_U16 timerLeft, timerTop, timerWidth, timerHeight;
|
||||
|
||||
XP_U16 boardLeft, trayLeft;
|
||||
XP_U16 scoreWidth;
|
||||
XP_U16 scoreHeight;
|
||||
XP_Bool needsScroller;
|
||||
XP_Bool horiz;
|
||||
} CEBoardParms;
|
||||
|
||||
static XP_U16
|
||||
sizeBoard( XP_U16* bdHeightP, /* INOUT */
|
||||
XP_U16* nRowsP, /* INOUT: on OUT, gives nRowsVisible */
|
||||
XP_U16* scrollWidthP )
|
||||
{
|
||||
/* given the initial max board height, figure how many rows are visible
|
||||
and the adjusted heights of the board and tray. */
|
||||
XP_U16 bdHeight = *bdHeightP;
|
||||
XP_U16 nVisibleRows = *nRowsP;
|
||||
XP_U16 vScale;
|
||||
XP_U16 boardHtLimit;
|
||||
|
||||
*scrollWidthP = 0;
|
||||
|
||||
vScale = bdHeight / nVisibleRows;
|
||||
if ( vScale < MIN_CELL_HEIGHT ) {
|
||||
vScale = MIN_CELL_HEIGHT;
|
||||
}
|
||||
|
||||
/* Now adjust tray height to make board height a multiple */
|
||||
boardHtLimit = nVisibleRows * vScale;
|
||||
while ( boardHtLimit > bdHeight ) {
|
||||
boardHtLimit -= vScale;
|
||||
--nVisibleRows;
|
||||
*scrollWidthP = SCROLLBAR_WIDTH;
|
||||
}
|
||||
|
||||
*bdHeightP = boardHtLimit;
|
||||
*nRowsP = nVisibleRows;
|
||||
return vScale;
|
||||
} /* sizeBoard */
|
||||
|
||||
static void
|
||||
figureBoardParms( CEAppGlobals* globals, XP_U16 nCols, CEBoardParms* bparms )
|
||||
figureBoardParms( CEAppGlobals* globals, XP_U16 nRows, CEBoardParms* bparms )
|
||||
{
|
||||
RECT rc;
|
||||
XP_U16 width, height;
|
||||
XP_U16 trayVScale, leftEdge, scoreWidth;
|
||||
XP_U16 boardHt, boardWidth, visBoardHt, hScale, vScale, nHiddenRows;
|
||||
XP_U16 boardHtLimit, trayTop;
|
||||
XP_Bool needsScroller;
|
||||
XP_U16 scrnWidth, scrnHeight;
|
||||
XP_U16 trayVScale, boardLeft, scoreWidth, scoreHeight;
|
||||
XP_U16 boardHt, boardWidth, visBoardHt, hScale, vScale, nVisibleRows;
|
||||
XP_U16 boardHtLimit, trayTop, boardTop;
|
||||
XP_Bool horiz;
|
||||
XP_U16 trayWidth;
|
||||
XP_U16 scrollWidth = 0;
|
||||
|
||||
GetClientRect( globals->hWnd, &rc );
|
||||
boardWidth = width = (XP_U16)(rc.right - rc.left);
|
||||
height = (XP_U16)(rc.bottom - rc.top);
|
||||
#if 1
|
||||
#ifndef _WIN32_WCE
|
||||
{
|
||||
int width = rc.right - rc.left;
|
||||
int height = rc.bottom - rc.top;
|
||||
if ( width > height ) {
|
||||
width = (height * 3) / 4;
|
||||
rc.right = rc.left + width;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
boardHt = height - CE_SCORE_HEIGHT - MIN_TRAY_HEIGHT;
|
||||
scrnWidth = (XP_U16)(rc.right - rc.left);
|
||||
scrnHeight = (XP_U16)(rc.bottom - rc.top);
|
||||
|
||||
horiz = (scrnHeight - CE_SCORE_HEIGHT) >= (scrnWidth - CE_MIN_SCORE_WIDTH);
|
||||
nVisibleRows = nRows;
|
||||
|
||||
if ( horiz ) {
|
||||
scoreHeight = horiz? CE_SCORE_HEIGHT : 0;
|
||||
}
|
||||
boardTop = scoreHeight;
|
||||
|
||||
/* Try to make it fit without scrolling. But if necessary, reduce the
|
||||
width for a scrollbar. */
|
||||
vScale = boardHt / nCols;
|
||||
needsScroller = vScale < MIN_CELL_HEIGHT;
|
||||
if ( needsScroller ) {
|
||||
vScale = MIN_CELL_HEIGHT;
|
||||
boardWidth -= SCROLLBAR_WIDTH;
|
||||
}
|
||||
hScale = boardWidth / nCols;
|
||||
boardHt = scrnHeight - scoreHeight - MIN_TRAY_HEIGHT;
|
||||
vScale = sizeBoard( &boardHt, &nVisibleRows, &scrollWidth );
|
||||
|
||||
/* Figure tray top. May overlap board. The tray's height must be at
|
||||
least the minimum, plus whatever fraction of a row is left when
|
||||
visible board height is determined. */
|
||||
visBoardHt = vScale * nCols;
|
||||
nHiddenRows = 0;
|
||||
boardHtLimit = height - CE_SCORE_HEIGHT - MIN_TRAY_HEIGHT;
|
||||
while ( visBoardHt > boardHtLimit ) {
|
||||
visBoardHt -= vScale;
|
||||
++nHiddenRows;
|
||||
boardWidth = scrnWidth - scrollWidth;
|
||||
if ( horiz ) {
|
||||
scoreWidth = scrnWidth;
|
||||
hScale = boardWidth / nRows;
|
||||
/* center the board */
|
||||
boardWidth += scrollWidth;
|
||||
boardLeft = (scrnWidth - boardWidth) / 2; /* center it all */
|
||||
} else {
|
||||
/* move extra pixels into scoreboard */
|
||||
hScale = (boardWidth - CE_MIN_SCORE_WIDTH) / nRows;
|
||||
boardWidth = hScale * nRows;
|
||||
scoreWidth = scrnWidth - boardWidth - scrollWidth;
|
||||
boardLeft = scoreWidth;
|
||||
}
|
||||
trayTop = CE_SCORE_HEIGHT + visBoardHt + TRAY_PADDING;
|
||||
trayVScale = height - trayTop;
|
||||
trayWidth = boardWidth;
|
||||
|
||||
/* Center the board */
|
||||
boardWidth = nCols * hScale;
|
||||
if ( needsScroller ) {
|
||||
boardWidth += SCROLLBAR_WIDTH;
|
||||
}
|
||||
leftEdge = (width - boardWidth) / 2; /* center it all */
|
||||
|
||||
scoreWidth = width;
|
||||
if ( globals->gameInfo.timerEnabled ) {
|
||||
scoreWidth -= CE_TIMER_WIDTH;
|
||||
}
|
||||
trayTop = boardHt + scoreHeight + TRAY_PADDING;
|
||||
trayVScale = scrnHeight - trayTop;
|
||||
|
||||
if ( !horiz ) {
|
||||
scoreHeight = scrnHeight;
|
||||
}
|
||||
|
||||
if ( globals->gameInfo.timerEnabled ) {
|
||||
if ( horiz ) {
|
||||
scoreWidth -= CE_TIMER_WIDTH;
|
||||
bparms->timerLeft = scoreWidth;
|
||||
bparms->timerTop = 0;
|
||||
bparms->timerWidth = CE_TIMER_WIDTH;
|
||||
bparms->timerHeight = CE_SCORE_HEIGHT;
|
||||
} else {
|
||||
bparms->timerLeft = 0;
|
||||
bparms->timerHeight = CE_SCORE_HEIGHT * 2;
|
||||
bparms->timerTop = scrnHeight - bparms->timerHeight;
|
||||
bparms->timerWidth = scoreWidth;
|
||||
|
||||
scoreHeight -= bparms->timerHeight;
|
||||
}
|
||||
}
|
||||
|
||||
bparms->boardHScale = hScale;
|
||||
bparms->boardVScale = vScale;
|
||||
bparms->boardTop = boardTop;
|
||||
bparms->trayTop = trayTop;
|
||||
bparms->trayVScale = trayVScale;
|
||||
bparms->trayHScale = CE_TRAY_SCALEH; /* unchanged so far... */
|
||||
bparms->leftEdge = leftEdge;
|
||||
bparms->trayHeight = trayVScale;
|
||||
bparms->trayWidth = trayWidth;
|
||||
bparms->boardLeft = boardLeft;
|
||||
bparms->trayLeft = boardLeft;
|
||||
bparms->scoreWidth = scoreWidth;
|
||||
bparms->scoreHeight = CE_SCORE_HEIGHT;
|
||||
bparms->scoreHeight = scoreHeight;
|
||||
bparms->horiz = horiz;
|
||||
|
||||
#ifdef CEFEATURE_CANSCROLL
|
||||
bparms->needsScroller = needsScroller;
|
||||
|
||||
if ( needsScroller ) {
|
||||
XP_U16 boardRight = leftEdge + (nCols * hScale);
|
||||
showScroller( globals, nHiddenRows,
|
||||
bparms->needsScroller = nVisibleRows < nRows;
|
||||
if ( bparms->needsScroller ) {
|
||||
XP_U16 boardRight = boardLeft + (nRows * hScale);
|
||||
showScroller( globals, nRows - nVisibleRows,
|
||||
boardRight,
|
||||
CE_SCORE_HEIGHT,
|
||||
rc.right - boardRight, visBoardHt );
|
||||
XP_LOGF( "NEEDING SCROLLBAR!!!!" );
|
||||
XP_LOGF( "%d rows hidden", nHiddenRows );
|
||||
XP_LOGF( "%d rows hidden", nRows - nVisibleRows );
|
||||
} else {
|
||||
hideScroller( globals );
|
||||
}
|
||||
globals->nHiddenRows = nHiddenRows;
|
||||
globals->nHiddenRows = nVisibleRows - nVisibleRows;
|
||||
#endif
|
||||
} /* figureBoardParms */
|
||||
|
||||
|
@ -479,26 +552,26 @@ cePositionBoard( CEAppGlobals* globals )
|
|||
|
||||
figureBoardParms( globals, nCols, &bparms );
|
||||
|
||||
board_setTimerLoc( globals->game.board, CE_TIMER_LEFT,
|
||||
CE_TIMER_TOP, CE_TIMER_WIDTH, CE_TIMER_HEIGHT );
|
||||
if ( globals->gameInfo.timerEnabled ) {
|
||||
board_setTimerLoc( globals->game.board, bparms.timerLeft,
|
||||
bparms.timerTop, bparms.timerWidth,
|
||||
bparms.timerHeight );
|
||||
}
|
||||
|
||||
board_setPos( globals->game.board, bparms.leftEdge,
|
||||
bparms.scoreHeight, XP_FALSE );
|
||||
board_setPos( globals->game.board, bparms.boardLeft,
|
||||
bparms.boardTop, XP_FALSE );
|
||||
board_setScale( globals->game.board, bparms.boardHScale, bparms.boardVScale );
|
||||
|
||||
board_setScoreboardLoc( globals->game.board, CE_SCORE_LEFT,
|
||||
CE_SCORE_TOP, bparms.scoreWidth,
|
||||
bparms.scoreHeight, XP_TRUE );
|
||||
bparms.scoreHeight, bparms.horiz );
|
||||
board_setShowColors( globals->game.board, globals->appPrefs.showColors );
|
||||
board_setYOffset( globals->game.board, 0 );
|
||||
|
||||
board_prefsChanged( globals->game.board, &globals->appPrefs.cp );
|
||||
|
||||
board_setTrayLoc( globals->game.board,
|
||||
CE_TRAY_LEFT_RH,
|
||||
bparms.trayTop,
|
||||
bparms.trayHScale, bparms.trayVScale,
|
||||
CE_DIVIDER_WIDTH );
|
||||
board_setTrayLoc( globals->game.board, bparms.trayLeft, bparms.trayTop,
|
||||
bparms.trayWidth, bparms.trayHeight, CE_DIVIDER_WIDTH );
|
||||
|
||||
server_prefsChanged( globals->game.server, &globals->appPrefs.cp );
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ typedef struct CEDrawCtx {
|
|||
|
||||
XP_U16 trayOwner;
|
||||
XP_U16 miniLineHt;
|
||||
XP_Bool scoreIsVertical;
|
||||
|
||||
MPSLOT
|
||||
} CEDrawCtx;
|
||||
|
|
Loading…
Reference in a new issue