mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
Make miniwindow stuff compile-time optional. The goal's to use native
features where they look better or are easier to manage, e.g. Toasts and dialogs on Android.
This commit is contained in:
parent
3b719f54de
commit
c01981bc8f
11 changed files with 162 additions and 35 deletions
|
@ -402,6 +402,7 @@ and_draw_dictChanged( DrawCtx* dctx, XP_S16 playerNum,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
static const XP_UCHAR*
|
static const XP_UCHAR*
|
||||||
and_draw_getMiniWText( DrawCtx* dctx, XWMiniTextType textHint )
|
and_draw_getMiniWText( DrawCtx* dctx, XWMiniTextType textHint )
|
||||||
{
|
{
|
||||||
|
@ -448,6 +449,7 @@ and_draw_drawMiniWindow( DrawCtx* dctx, const XP_UCHAR* text,
|
||||||
|
|
||||||
(*env)->DeleteLocalRef( env, jstr );
|
(*env)->DeleteLocalRef( env, jstr );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
draw_doNothing( DrawCtx* dctx, ... )
|
draw_doNothing( DrawCtx* dctx, ... )
|
||||||
|
@ -496,9 +498,11 @@ makeDraw( MPFORMAL JNIEnv** envp, jobject jdraw )
|
||||||
SET_PROC(objFinished);
|
SET_PROC(objFinished);
|
||||||
SET_PROC(dictChanged);
|
SET_PROC(dictChanged);
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
SET_PROC(getMiniWText);
|
SET_PROC(getMiniWText);
|
||||||
SET_PROC(measureMiniWText);
|
SET_PROC(measureMiniWText);
|
||||||
SET_PROC(drawMiniWindow);
|
SET_PROC(drawMiniWindow);
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef SET_PROC
|
#undef SET_PROC
|
||||||
return (DrawCtx*)draw;
|
return (DrawCtx*)draw;
|
||||||
|
|
|
@ -95,7 +95,11 @@ static void setArrowFor( BoardCtxt* board, XP_U16 player, XP_U16 col,
|
||||||
XP_U16 row );
|
XP_U16 row );
|
||||||
static XP_Bool setArrowVisible( BoardCtxt* board, XP_Bool visible );
|
static XP_Bool setArrowVisible( BoardCtxt* board, XP_Bool visible );
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
static void invalTradeWindow( BoardCtxt* board, XP_S16 turn, XP_Bool redraw );
|
static void invalTradeWindow( BoardCtxt* board, XP_S16 turn, XP_Bool redraw );
|
||||||
|
#else
|
||||||
|
# define invalTradeWindow(b,t,r)
|
||||||
|
#endif
|
||||||
static XP_Bool invalCellsWithTiles( BoardCtxt* board );
|
static XP_Bool invalCellsWithTiles( BoardCtxt* board );
|
||||||
|
|
||||||
static void setTimerIf( BoardCtxt* board );
|
static void setTimerIf( BoardCtxt* board );
|
||||||
|
@ -678,6 +682,7 @@ invalCursorCell( BoardCtxt* board )
|
||||||
} /* invalCursorCell */
|
} /* invalCursorCell */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
static void
|
static void
|
||||||
invalTradeWindow( BoardCtxt* board, XP_S16 turn, XP_Bool redraw )
|
invalTradeWindow( BoardCtxt* board, XP_S16 turn, XP_Bool redraw )
|
||||||
{
|
{
|
||||||
|
@ -712,6 +717,7 @@ hideMiniWindow( BoardCtxt* board, XP_Bool destroy, MiniWindowType winType )
|
||||||
}
|
}
|
||||||
} /* hideMiniWindow */
|
} /* hideMiniWindow */
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
warnBadWords( XP_UCHAR* word, void* closure )
|
warnBadWords( XP_UCHAR* word, void* closure )
|
||||||
|
@ -904,6 +910,7 @@ board_resetEngine( BoardCtxt* board )
|
||||||
server_resetEngine( board->server, board->selPlayer );
|
server_resetEngine( board->server, board->selPlayer );
|
||||||
} /* board_resetEngine */
|
} /* board_resetEngine */
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
/* Find a rectangle either centered on the board or pinned to the point at
|
/* Find a rectangle either centered on the board or pinned to the point at
|
||||||
* which the mouse went down.
|
* which the mouse went down.
|
||||||
*/
|
*/
|
||||||
|
@ -929,6 +936,7 @@ positionMiniWRect( BoardCtxt* board, XP_Rect* rect, XP_Bool center )
|
||||||
}
|
}
|
||||||
forceRectToBoard( board, rect );
|
forceRectToBoard( board, rect );
|
||||||
} /*positionMiniWRect */
|
} /*positionMiniWRect */
|
||||||
|
#endif
|
||||||
|
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
timerFiredForPen( BoardCtxt* board )
|
timerFiredForPen( BoardCtxt* board )
|
||||||
|
@ -954,7 +962,11 @@ timerFiredForPen( BoardCtxt* board )
|
||||||
bonus = util_getSquareBonus( board->util, board->model,
|
bonus = util_getSquareBonus( board->util, board->model,
|
||||||
col, row );
|
col, row );
|
||||||
if ( bonus != BONUS_NONE ) {
|
if ( bonus != BONUS_NONE ) {
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
text = draw_getMiniWText( board->draw, (XWMiniTextType)bonus );
|
text = draw_getMiniWText( board->draw, (XWMiniTextType)bonus );
|
||||||
|
#else
|
||||||
|
util_bonusSquareHeld( board->util, bonus );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
board->penTimerFired = XP_TRUE;
|
board->penTimerFired = XP_TRUE;
|
||||||
|
@ -984,14 +996,18 @@ timerFiredForPen( BoardCtxt* board )
|
||||||
XP_ASSERT( XP_STRLEN(buf) + explLen < sizeof(buf) );
|
XP_ASSERT( XP_STRLEN(buf) + explLen < sizeof(buf) );
|
||||||
XP_STRCAT( buf, scoreExpl );
|
XP_STRCAT( buf, scoreExpl );
|
||||||
}
|
}
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
text = buf;
|
text = buf;
|
||||||
|
#else
|
||||||
|
util_playerScoreHeld( board->util, buf );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
board->penTimerFired = XP_TRUE;
|
board->penTimerFired = XP_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !!text ) {
|
if ( !!text ) {
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
MiniWindowStuff* stuff = &board->miniWindowStuff[MINIWINDOW_VALHINT];
|
MiniWindowStuff* stuff = &board->miniWindowStuff[MINIWINDOW_VALHINT];
|
||||||
makeMiniWindowForText( board, text, MINIWINDOW_VALHINT );
|
makeMiniWindowForText( board, text, MINIWINDOW_VALHINT );
|
||||||
XP_ASSERT( stuff->text == text );
|
XP_ASSERT( stuff->text == text );
|
||||||
|
@ -1002,6 +1018,7 @@ timerFiredForPen( BoardCtxt* board )
|
||||||
dragDropEnd( board, board->penDownX, board->penDownY, &dragged );
|
dragDropEnd( board, board->penDownX, board->penDownY, &dragged );
|
||||||
XP_ASSERT( !dragged );
|
XP_ASSERT( !dragged );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return draw;
|
return draw;
|
||||||
} /* timerFiredForPen */
|
} /* timerFiredForPen */
|
||||||
|
@ -1123,7 +1140,9 @@ board_invalAllTiles( BoardCtxt* board )
|
||||||
while ( lastRow-- ) {
|
while ( lastRow-- ) {
|
||||||
board->redrawFlags[lastRow] = ~0;
|
board->redrawFlags[lastRow] = ~0;
|
||||||
}
|
}
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
board->tradingMiniWindowInvalid = XP_TRUE;
|
board->tradingMiniWindowInvalid = XP_TRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
board->needsDrawing = XP_TRUE;
|
board->needsDrawing = XP_TRUE;
|
||||||
} /* board_invalAllTiles */
|
} /* board_invalAllTiles */
|
||||||
|
@ -1967,6 +1986,7 @@ invalCell( BoardCtxt* board, XP_U16 col, XP_U16 row )
|
||||||
XP_ASSERT( col < MAX_ROWS );
|
XP_ASSERT( col < MAX_ROWS );
|
||||||
XP_ASSERT( row < MAX_ROWS );
|
XP_ASSERT( row < MAX_ROWS );
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
/* if the trade window is up and this cell intersects it, set up to draw
|
/* if the trade window is up and this cell intersects it, set up to draw
|
||||||
it again */
|
it again */
|
||||||
if ( (board->trayVisState != TRAY_HIDDEN) && TRADE_IN_PROGRESS(board) ) {
|
if ( (board->trayVisState != TRAY_HIDDEN) && TRADE_IN_PROGRESS(board) ) {
|
||||||
|
@ -1978,6 +1998,7 @@ invalCell( BoardCtxt* board, XP_U16 col, XP_U16 row )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
board->needsDrawing = XP_TRUE;
|
board->needsDrawing = XP_TRUE;
|
||||||
} /* invalCell */
|
} /* invalCell */
|
||||||
|
@ -2030,6 +2051,7 @@ moveTileToArrowLoc( BoardCtxt* board, XP_U8 index )
|
||||||
} /* moveTileToArrowLoc */
|
} /* moveTileToArrowLoc */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
void
|
void
|
||||||
makeMiniWindowForText( BoardCtxt* board, const XP_UCHAR* text,
|
makeMiniWindowForText( BoardCtxt* board, const XP_UCHAR* text,
|
||||||
MiniWindowType winType )
|
MiniWindowType winType )
|
||||||
|
@ -2044,6 +2066,7 @@ makeMiniWindowForText( BoardCtxt* board, const XP_UCHAR* text,
|
||||||
stuff->rect = rect;
|
stuff->rect = rect;
|
||||||
stuff->text = text;
|
stuff->text = text;
|
||||||
} /* makeMiniWindowForText */
|
} /* makeMiniWindowForText */
|
||||||
|
#endif
|
||||||
|
|
||||||
XP_Bool
|
XP_Bool
|
||||||
board_beginTrade( BoardCtxt* board )
|
board_beginTrade( BoardCtxt* board )
|
||||||
|
@ -2059,7 +2082,11 @@ board_beginTrade( BoardCtxt* board )
|
||||||
} else if ( server_countTilesInPool(board->server) < MIN_TRADE_TILES){
|
} else if ( server_countTilesInPool(board->server) < MIN_TRADE_TILES){
|
||||||
util_userError( board->util, ERR_TOO_FEW_TILES_LEFT_TO_TRADE );
|
util_userError( board->util, ERR_TOO_FEW_TILES_LEFT_TO_TRADE );
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
board->tradingMiniWindowInvalid = XP_TRUE;
|
board->tradingMiniWindowInvalid = XP_TRUE;
|
||||||
|
#else
|
||||||
|
util_setInTrade( board->util, board->selPlayer, XP_TRUE );
|
||||||
|
#endif
|
||||||
board->needsDrawing = XP_TRUE;
|
board->needsDrawing = XP_TRUE;
|
||||||
board->selInfo->tradeInProgress = XP_TRUE;
|
board->selInfo->tradeInProgress = XP_TRUE;
|
||||||
setArrowVisible( board, XP_FALSE );
|
setArrowVisible( board, XP_FALSE );
|
||||||
|
@ -2077,6 +2104,9 @@ board_endTrade( BoardCtxt* board )
|
||||||
PerTurnInfo* pti = board->selInfo;
|
PerTurnInfo* pti = board->selInfo;
|
||||||
invalSelTradeWindow( board );
|
invalSelTradeWindow( board );
|
||||||
pti->tradeInProgress = XP_FALSE;
|
pti->tradeInProgress = XP_FALSE;
|
||||||
|
#ifndef XWFEATURE_MINIWIN
|
||||||
|
util_setInTrade( board->util, board->selPlayer, XP_FALSE );
|
||||||
|
#endif
|
||||||
pti->traySelBits = NO_TILES;
|
pti->traySelBits = NO_TILES;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -2084,12 +2114,16 @@ board_endTrade( BoardCtxt* board )
|
||||||
|
|
||||||
|
|
||||||
#if defined POINTER_SUPPORT || defined KEYBOARD_NAV
|
#if defined POINTER_SUPPORT || defined KEYBOARD_NAV
|
||||||
|
# ifdef XWFEATURE_MINIWIN
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
ptOnTradeWindow( BoardCtxt* board, XP_U16 x, XP_U16 y )
|
ptOnTradeWindow( BoardCtxt* board, XP_U16 x, XP_U16 y )
|
||||||
{
|
{
|
||||||
XP_Rect* windowR = &board->miniWindowStuff[MINIWINDOW_TRADING].rect;
|
XP_Rect* windowR = &board->miniWindowStuff[MINIWINDOW_TRADING].rect;
|
||||||
return rectContainsPt( windowR, x, y );
|
return rectContainsPt( windowR, x, y );
|
||||||
} /* ptOnTradeWindow */
|
} /* ptOnTradeWindow */
|
||||||
|
# else
|
||||||
|
# define ptOnTradeWindow(b,x,y) XP_FALSE
|
||||||
|
# endif
|
||||||
|
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
#ifdef XWFEATURE_SEARCHLIMIT
|
||||||
|
|
||||||
|
@ -2455,6 +2489,9 @@ exitTradeMode( BoardCtxt* board )
|
||||||
PerTurnInfo* pti = board->selInfo;
|
PerTurnInfo* pti = board->selInfo;
|
||||||
invalSelTradeWindow( board );
|
invalSelTradeWindow( board );
|
||||||
pti->tradeInProgress = XP_FALSE;
|
pti->tradeInProgress = XP_FALSE;
|
||||||
|
#ifndef XWFEATURE_MINIWIN
|
||||||
|
util_setInTrade( board->util, board->selPlayer, XP_FALSE );
|
||||||
|
#endif
|
||||||
board_invalTrayTiles( board, pti->traySelBits );
|
board_invalTrayTiles( board, pti->traySelBits );
|
||||||
pti->traySelBits = 0x00;
|
pti->traySelBits = 0x00;
|
||||||
return XP_TRUE;
|
return XP_TRUE;
|
||||||
|
@ -2493,9 +2530,11 @@ handlePenUpInternal( BoardCtxt* board, XP_U16 xx, XP_U16 yy, XP_Bool isPen )
|
||||||
if ( dragged ) {
|
if ( dragged ) {
|
||||||
/* do nothing further */
|
/* do nothing further */
|
||||||
} else if ( board->penTimerFired ) {
|
} else if ( board->penTimerFired ) {
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
if ( valHintMiniWindowActive( board ) ) {
|
if ( valHintMiniWindowActive( board ) ) {
|
||||||
hideMiniWindow( board, XP_TRUE, MINIWINDOW_VALHINT );
|
hideMiniWindow( board, XP_TRUE, MINIWINDOW_VALHINT );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
draw = XP_TRUE; /* might have cancelled a drag */
|
draw = XP_TRUE; /* might have cancelled a drag */
|
||||||
/* Need to clean up if there's been any dragging happening */
|
/* Need to clean up if there's been any dragging happening */
|
||||||
board->penTimerFired = XP_FALSE;
|
board->penTimerFired = XP_FALSE;
|
||||||
|
|
|
@ -76,7 +76,11 @@ static void scrollIfCan( BoardCtxt* board );
|
||||||
#ifdef KEYBOARD_NAV
|
#ifdef KEYBOARD_NAV
|
||||||
static XP_Bool cellFocused( const BoardCtxt* board, XP_U16 col, XP_U16 row );
|
static XP_Bool cellFocused( const BoardCtxt* board, XP_U16 col, XP_U16 row );
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
static void drawTradeWindowIf( BoardCtxt* board );
|
static void drawTradeWindowIf( BoardCtxt* board );
|
||||||
|
#else
|
||||||
|
# define drawTradeWindowIf( board )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
#ifdef XWFEATURE_SEARCHLIMIT
|
||||||
|
@ -221,6 +225,7 @@ rectContainsRect( XP_Rect* rect1, XP_Rect* rect2 )
|
||||||
&& rect1->left + rect1->width >= rect2->left + rect2->width );
|
&& rect1->left + rect1->width >= rect2->left + rect2->width );
|
||||||
} /* rectContainsRect */
|
} /* rectContainsRect */
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
static void
|
static void
|
||||||
makeMiniWindowForTrade( BoardCtxt* board )
|
makeMiniWindowForTrade( BoardCtxt* board )
|
||||||
{
|
{
|
||||||
|
@ -230,6 +235,7 @@ makeMiniWindowForTrade( BoardCtxt* board )
|
||||||
|
|
||||||
makeMiniWindowForText( board, text, MINIWINDOW_TRADING );
|
makeMiniWindowForText( board, text, MINIWINDOW_TRADING );
|
||||||
} /* makeMiniWindowForTrade */
|
} /* makeMiniWindowForTrade */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef XWFEATURE_CROSSHAIRS
|
#ifdef XWFEATURE_CROSSHAIRS
|
||||||
static CellFlags
|
static CellFlags
|
||||||
|
@ -591,6 +597,7 @@ scrollIfCan( BoardCtxt* board )
|
||||||
}
|
}
|
||||||
} /* scrollIfCan */
|
} /* scrollIfCan */
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
static void
|
static void
|
||||||
drawTradeWindowIf( BoardCtxt* board )
|
drawTradeWindowIf( BoardCtxt* board )
|
||||||
{
|
{
|
||||||
|
@ -607,6 +614,7 @@ drawTradeWindowIf( BoardCtxt* board )
|
||||||
board->tradingMiniWindowInvalid = XP_FALSE;
|
board->tradingMiniWindowInvalid = XP_FALSE;
|
||||||
}
|
}
|
||||||
} /* drawTradeWindowIf */
|
} /* drawTradeWindowIf */
|
||||||
|
#endif
|
||||||
|
|
||||||
XP_Bool
|
XP_Bool
|
||||||
board_draw( BoardCtxt* board )
|
board_draw( BoardCtxt* board )
|
||||||
|
|
|
@ -89,6 +89,7 @@ typedef struct _BdCursorLoc {
|
||||||
} BdCursorLoc;
|
} BdCursorLoc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
/* We only need two of these, one for the value hint and the other for the
|
/* We only need two of these, one for the value hint and the other for the
|
||||||
trading window. There's never more than of the former since it lives only
|
trading window. There's never more than of the former since it lives only
|
||||||
as long as the pen is down. There are, in theory, as many trading windows
|
as long as the pen is down. There are, in theory, as many trading windows
|
||||||
|
@ -101,6 +102,7 @@ typedef struct _MiniWindowStuff {
|
||||||
|
|
||||||
enum { MINIWINDOW_VALHINT, MINIWINDOW_TRADING };
|
enum { MINIWINDOW_VALHINT, MINIWINDOW_TRADING };
|
||||||
typedef XP_U16 MiniWindowType; /* one of the two above */
|
typedef XP_U16 MiniWindowType; /* one of the two above */
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct _PerTurnInfo {
|
typedef struct _PerTurnInfo {
|
||||||
#ifdef KEYBOARD_NAV
|
#ifdef KEYBOARD_NAV
|
||||||
|
@ -213,8 +215,10 @@ struct BoardCtxt {
|
||||||
XP_Bool scoreBoardInvalid;
|
XP_Bool scoreBoardInvalid;
|
||||||
DragState dragState;
|
DragState dragState;
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
MiniWindowStuff miniWindowStuff[2];
|
MiniWindowStuff miniWindowStuff[2];
|
||||||
XP_Bool tradingMiniWindowInvalid;
|
XP_Bool tradingMiniWindowInvalid;
|
||||||
|
#endif
|
||||||
|
|
||||||
TileBit trayInvalBits;
|
TileBit trayInvalBits;
|
||||||
#ifdef KEYBOARD_NAV
|
#ifdef KEYBOARD_NAV
|
||||||
|
@ -230,9 +234,10 @@ struct BoardCtxt {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CURSOR_LOC_REM 0
|
#define CURSOR_LOC_REM 0
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
#define valHintMiniWindowActive( board ) \
|
# define valHintMiniWindowActive( board ) \
|
||||||
((XP_Bool)((board)->miniWindowStuff[MINIWINDOW_VALHINT].text != NULL))
|
((XP_Bool)((board)->miniWindowStuff[MINIWINDOW_VALHINT].text != NULL))
|
||||||
|
#endif
|
||||||
#define MY_TURN(b) ((b)->selPlayer == server_getCurrentTurn( (b)->server ))
|
#define MY_TURN(b) ((b)->selPlayer == server_getCurrentTurn( (b)->server ))
|
||||||
#define TRADE_IN_PROGRESS(b) ((b)->selInfo->tradeInProgress==XP_TRUE)
|
#define TRADE_IN_PROGRESS(b) ((b)->selInfo->tradeInProgress==XP_TRUE)
|
||||||
|
|
||||||
|
@ -274,21 +279,27 @@ void invalRow( BoardCtxt* board, XP_U16 row );
|
||||||
void invalTrayTilesAbove( BoardCtxt* board, XP_U16 tileIndex );
|
void invalTrayTilesAbove( BoardCtxt* board, XP_U16 tileIndex );
|
||||||
void invalTrayTilesBetween( BoardCtxt* board, XP_U16 tileIndex1,
|
void invalTrayTilesBetween( BoardCtxt* board, XP_U16 tileIndex1,
|
||||||
XP_U16 tileIndex2 );
|
XP_U16 tileIndex2 );
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
void makeMiniWindowForText( BoardCtxt* board, const XP_UCHAR* text,
|
void makeMiniWindowForText( BoardCtxt* board, const XP_UCHAR* text,
|
||||||
MiniWindowType winType );
|
MiniWindowType winType );
|
||||||
|
void hideMiniWindow( BoardCtxt* board, XP_Bool destroy,
|
||||||
|
MiniWindowType winType );
|
||||||
|
|
||||||
|
void invalSelTradeWindow( BoardCtxt* board );
|
||||||
|
#else
|
||||||
|
# define invalSelTradeWindow(b)
|
||||||
|
#endif
|
||||||
|
|
||||||
XP_Bool getCellRect( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
XP_Bool getCellRect( const BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||||
XP_Rect* rect);
|
XP_Rect* rect);
|
||||||
void getDragCellRect( BoardCtxt* board, XP_U16 col, XP_U16 row,
|
void getDragCellRect( BoardCtxt* board, XP_U16 col, XP_U16 row,
|
||||||
XP_Rect* rectP );
|
XP_Rect* rectP );
|
||||||
void invalSelTradeWindow( BoardCtxt* board );
|
|
||||||
void invalCellsUnderRect( BoardCtxt* board, const XP_Rect* rect );
|
void invalCellsUnderRect( BoardCtxt* board, const XP_Rect* rect );
|
||||||
|
|
||||||
#ifdef XWFEATURE_SEARCHLIMIT
|
#ifdef XWFEATURE_SEARCHLIMIT
|
||||||
void invalCurHintRect( BoardCtxt* board, XP_U16 player );
|
void invalCurHintRect( BoardCtxt* board, XP_U16 player );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void hideMiniWindow( BoardCtxt* board, XP_Bool destroy,
|
|
||||||
MiniWindowType winType );
|
|
||||||
|
|
||||||
void moveTileInTray( BoardCtxt* board, XP_U16 moveTo, XP_U16 moveFrom );
|
void moveTileInTray( BoardCtxt* board, XP_U16 moveTo, XP_U16 moveFrom );
|
||||||
XP_Bool handleTrayDuringTrade( BoardCtxt* board, XP_S16 index );
|
XP_Bool handleTrayDuringTrade( BoardCtxt* board, XP_S16 index );
|
||||||
|
|
|
@ -217,6 +217,10 @@ typedef struct _PlayerDicts {
|
||||||
#define LOG_RETURN_VOID() LOG_RETURNF("%s","void")
|
#define LOG_RETURN_VOID() LOG_RETURNF("%s","void")
|
||||||
#define XP_LOGLOC() XP_LOGF( "%s(), line %d", __func__, __LINE__ )
|
#define XP_LOGLOC() XP_LOGF( "%s(), line %d", __func__, __LINE__ )
|
||||||
|
|
||||||
|
#ifndef XP_USE
|
||||||
|
# define XP_USE(v) v=v
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef XP_UNUSED
|
#ifndef XP_UNUSED
|
||||||
# if defined __GNUC__
|
# if defined __GNUC__
|
||||||
# define XP_UNUSED(x) UNUSED__ ## x __attribute__((unused))
|
# define XP_UNUSED(x) UNUSED__ ## x __attribute__((unused))
|
||||||
|
|
|
@ -566,9 +566,11 @@ dragDropContinueImpl( BoardCtxt* board, XP_U16 xx, XP_U16 yy,
|
||||||
/* This is the first time we've moved!!! Kill any future timers,
|
/* This is the first time we've moved!!! Kill any future timers,
|
||||||
and if there's a window up kill it.*/
|
and if there's a window up kill it.*/
|
||||||
board->penTimerFired = XP_FALSE;
|
board->penTimerFired = XP_FALSE;
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
if ( valHintMiniWindowActive( board ) ) {
|
if ( valHintMiniWindowActive( board ) ) {
|
||||||
hideMiniWindow( board, XP_TRUE, MINIWINDOW_VALHINT );
|
hideMiniWindow( board, XP_TRUE, MINIWINDOW_VALHINT );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
ds->didMove = XP_TRUE;
|
ds->didMove = XP_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,12 +197,14 @@ typedef struct DrawCtxVTable {
|
||||||
XWBonusType bonus, XP_Bool vert,
|
XWBonusType bonus, XP_Bool vert,
|
||||||
HintAtts hintAtts,
|
HintAtts hintAtts,
|
||||||
CellFlags flags);
|
CellFlags flags);
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
const XP_UCHAR* DRAW_VTABLE_NAME(getMiniWText) ( DrawCtx* dctx,
|
const XP_UCHAR* DRAW_VTABLE_NAME(getMiniWText) ( DrawCtx* dctx,
|
||||||
XWMiniTextType textHint );
|
XWMiniTextType textHint );
|
||||||
void DRAW_VTABLE_NAME(measureMiniWText) ( DrawCtx* dctx, const XP_UCHAR* textP,
|
void DRAW_VTABLE_NAME(measureMiniWText) ( DrawCtx* dctx, const XP_UCHAR* textP,
|
||||||
XP_U16* width, XP_U16* height );
|
XP_U16* width, XP_U16* height );
|
||||||
void DRAW_VTABLE_NAME(drawMiniWindow)( DrawCtx* dctx, const XP_UCHAR* text,
|
void DRAW_VTABLE_NAME(drawMiniWindow)( DrawCtx* dctx, const XP_UCHAR* text,
|
||||||
const XP_Rect* rect, void** closure );
|
const XP_Rect* rect, void** closure );
|
||||||
|
#endif
|
||||||
#ifndef DRAW_LINK_DIRECT
|
#ifndef DRAW_LINK_DIRECT
|
||||||
} DrawCtxVTable; /* */
|
} DrawCtxVTable; /* */
|
||||||
#endif
|
#endif
|
||||||
|
@ -291,11 +293,13 @@ struct DrawCtx {
|
||||||
#define draw_drawBoardArrow( dc, r, b, v, h, f ) \
|
#define draw_drawBoardArrow( dc, r, b, v, h, f ) \
|
||||||
CALL_DRAW_NAME5(drawBoardArrow,(dc),(r),(b), (v), (h), (f))
|
CALL_DRAW_NAME5(drawBoardArrow,(dc),(r),(b), (v), (h), (f))
|
||||||
|
|
||||||
#define draw_getMiniWText( dc, b ) CALL_DRAW_NAME1(getMiniWText, (dc),(b) )
|
#ifdef XWFEATURE_MINIWIN
|
||||||
#define draw_measureMiniWText( dc, t, wp, hp) \
|
# define draw_getMiniWText( dc, b ) CALL_DRAW_NAME1(getMiniWText, (dc),(b) )
|
||||||
|
# define draw_measureMiniWText( dc, t, wp, hp) \
|
||||||
CALL_DRAW_NAME3(measureMiniWText, (dc),(t), (wp), (hp) )
|
CALL_DRAW_NAME3(measureMiniWText, (dc),(t), (wp), (hp) )
|
||||||
#define draw_drawMiniWindow( dc, t, r, c ) \
|
# define draw_drawMiniWindow( dc, t, r, c ) \
|
||||||
CALL_DRAW_NAME3(drawMiniWindow, (dc), (t), (r), (c) )
|
CALL_DRAW_NAME3(drawMiniWindow, (dc), (t), (r), (c) )
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DRAW_WITH_PRIMITIVES
|
#ifdef DRAW_WITH_PRIMITIVES
|
||||||
# define draw_setClip( dc, rn, ro ) CALL_DRAW_NAME2(setClip, (dc), (rn), (ro))
|
# define draw_setClip( dc, rn, ro ) CALL_DRAW_NAME2(setClip, (dc), (rn), (ro))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 1997 - 2010 by Eric House (xwords@eehouse.org). All rights
|
* Copyright 1997 - 2010 by Eric House (xwords@eehouse.org). All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
|
@ -158,6 +158,12 @@ typedef struct UtilVtable {
|
||||||
|
|
||||||
void (*m_util_remSelected)(XW_UtilCtxt* uc);
|
void (*m_util_remSelected)(XW_UtilCtxt* uc);
|
||||||
|
|
||||||
|
#ifndef XWFEATURE_MINIWIN
|
||||||
|
void (*m_util_setInTrade)( XW_UtilCtxt* uc, XP_U16 turn, XP_Bool entering );
|
||||||
|
void (*m_util_bonusSquareHeld)( XW_UtilCtxt* uc, XWBonusType bonus );
|
||||||
|
void (*m_util_playerScoreHeld)( XW_UtilCtxt* uc, const XP_UCHAR* txt );
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
void (*m_util_addrChange)( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr,
|
void (*m_util_addrChange)( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr,
|
||||||
const CommsAddrRec* newAddr );
|
const CommsAddrRec* newAddr );
|
||||||
|
@ -258,6 +264,15 @@ struct XW_UtilCtxt {
|
||||||
#define util_remSelected( uc ) \
|
#define util_remSelected( uc ) \
|
||||||
(uc)->vtable->m_util_remSelected((uc))
|
(uc)->vtable->m_util_remSelected((uc))
|
||||||
|
|
||||||
|
#ifndef XWFEATURE_MINIWIN
|
||||||
|
# define util_setInTrade( uc, t, e ) \
|
||||||
|
(uc)->vtable->m_util_setInTrade( (uc), (t), (e) )
|
||||||
|
# define util_bonusSquareHeld( uc, b ) \
|
||||||
|
(uc)->vtable->m_util_bonusSquareHeld( (uc), (b) )
|
||||||
|
# define util_playerScoreHeld( uc, txt ) \
|
||||||
|
(uc)->vtable->m_util_playerScoreHeld( (uc), (txt) )
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
# define util_addrChange( uc, addro, addrn ) \
|
# define util_addrChange( uc, addro, addrn ) \
|
||||||
(uc)->vtable->m_util_addrChange((uc), (addro), (addrn))
|
(uc)->vtable->m_util_addrChange((uc), (addro), (addrn))
|
||||||
|
|
|
@ -39,20 +39,6 @@ typedef struct CursesDrawCtx {
|
||||||
static void curses_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP );
|
static void curses_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP );
|
||||||
static void getTops( const XP_Rect* rect, int* toptop, int* topbot );
|
static void getTops( const XP_Rect* rect, int* toptop, int* topbot );
|
||||||
|
|
||||||
static void
|
|
||||||
drawRect( WINDOW* win, const XP_Rect* rect, char vert, char hor )
|
|
||||||
{
|
|
||||||
wmove( win, rect->top-1, rect->left );
|
|
||||||
whline( win, hor, rect->width );
|
|
||||||
wmove( win, rect->top+rect->height, rect->left );
|
|
||||||
whline( win, hor, rect->width );
|
|
||||||
|
|
||||||
wmove( win, rect->top, rect->left-1 );
|
|
||||||
wvline( win, vert, rect->height );
|
|
||||||
wmove( win, rect->top, rect->left+rect->width );
|
|
||||||
wvline( win, vert, rect->height );
|
|
||||||
} /* drawRect */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eraseRect( CursesDrawCtx* dctx, const XP_Rect* rect )
|
eraseRect( CursesDrawCtx* dctx, const XP_Rect* rect )
|
||||||
{
|
{
|
||||||
|
@ -484,6 +470,7 @@ curses_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP )
|
||||||
eraseRect( dctx, &rect );
|
eraseRect( dctx, &rect );
|
||||||
} /* curses_draw_clearRect */
|
} /* curses_draw_clearRect */
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
static const XP_UCHAR*
|
static const XP_UCHAR*
|
||||||
curses_draw_getMiniWText( DrawCtx* XP_UNUSED(p_dctx),
|
curses_draw_getMiniWText( DrawCtx* XP_UNUSED(p_dctx),
|
||||||
XWMiniTextType XP_UNUSED(textHint) )
|
XWMiniTextType XP_UNUSED(textHint) )
|
||||||
|
@ -499,6 +486,20 @@ curses_draw_measureMiniWText( DrawCtx* XP_UNUSED(p_dctx), const XP_UCHAR* str,
|
||||||
*heightP = 3;
|
*heightP = 3;
|
||||||
} /* curses_draw_measureMiniWText */
|
} /* curses_draw_measureMiniWText */
|
||||||
|
|
||||||
|
static void
|
||||||
|
drawRect( WINDOW* win, const XP_Rect* rect, char vert, char hor )
|
||||||
|
{
|
||||||
|
wmove( win, rect->top-1, rect->left );
|
||||||
|
whline( win, hor, rect->width );
|
||||||
|
wmove( win, rect->top+rect->height, rect->left );
|
||||||
|
whline( win, hor, rect->width );
|
||||||
|
|
||||||
|
wmove( win, rect->top, rect->left-1 );
|
||||||
|
wvline( win, vert, rect->height );
|
||||||
|
wmove( win, rect->top, rect->left+rect->width );
|
||||||
|
wvline( win, vert, rect->height );
|
||||||
|
} /* drawRect */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
curses_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
|
curses_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
|
||||||
const XP_Rect* rect, void** XP_UNUSED(closure) )
|
const XP_Rect* rect, void** XP_UNUSED(closure) )
|
||||||
|
@ -519,6 +520,7 @@ curses_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
|
||||||
mvwprintw( dctx->boardWin, smallerR.top, smallerR.left, text,
|
mvwprintw( dctx->boardWin, smallerR.top, smallerR.left, text,
|
||||||
strlen(text) );
|
strlen(text) );
|
||||||
} /* curses_draw_drawMiniWindow */
|
} /* curses_draw_drawMiniWindow */
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void
|
static void
|
||||||
|
@ -568,9 +570,11 @@ cursesDrawCtxtMake( WINDOW* boardWin )
|
||||||
|
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, curses );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, curses );
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, curses );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, curses );
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_getMiniWText, curses );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_getMiniWText, curses );
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, curses );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, curses );
|
||||||
|
#endif
|
||||||
|
|
||||||
dctx->boardWin = boardWin;
|
dctx->boardWin = boardWin;
|
||||||
|
|
||||||
|
|
|
@ -127,14 +127,6 @@ gtkEraseRect( const GtkDrawCtx* dctx, const XP_Rect* rect )
|
||||||
rect->width, rect->height );
|
rect->width, rect->height );
|
||||||
} /* gtkEraseRect */
|
} /* gtkEraseRect */
|
||||||
|
|
||||||
static void
|
|
||||||
frameRect( GtkDrawCtx* dctx, const XP_Rect* rect )
|
|
||||||
{
|
|
||||||
draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC,
|
|
||||||
FALSE, rect->left, rect->top,
|
|
||||||
rect->width, rect->height );
|
|
||||||
} /* frameRect */
|
|
||||||
|
|
||||||
#ifdef DRAW_WITH_PRIMITIVES
|
#ifdef DRAW_WITH_PRIMITIVES
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1149,9 +1141,18 @@ gtk_draw_drawTimer( DrawCtx* p_dctx, const XP_Rect* rInner,
|
||||||
&dctx->playerColors[playerNum], NULL );
|
&dctx->playerColors[playerNum], NULL );
|
||||||
} /* gtk_draw_drawTimer */
|
} /* gtk_draw_drawTimer */
|
||||||
|
|
||||||
#define MINI_LINE_HT 12
|
#ifdef XWFEATURE_MINIWIN
|
||||||
#define MINI_V_PADDING 6
|
# define MINI_LINE_HT 12
|
||||||
#define MINI_H_PADDING 8
|
# define MINI_V_PADDING 6
|
||||||
|
# define MINI_H_PADDING 8
|
||||||
|
|
||||||
|
static void
|
||||||
|
frameRect( GtkDrawCtx* dctx, const XP_Rect* rect )
|
||||||
|
{
|
||||||
|
draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC,
|
||||||
|
FALSE, rect->left, rect->top,
|
||||||
|
rect->width, rect->height );
|
||||||
|
} /* frameRect */
|
||||||
|
|
||||||
static const XP_UCHAR*
|
static const XP_UCHAR*
|
||||||
gtk_draw_getMiniWText( DrawCtx* XP_UNUSED(p_dctx), XWMiniTextType textHint )
|
gtk_draw_getMiniWText( DrawCtx* XP_UNUSED(p_dctx), XWMiniTextType textHint )
|
||||||
|
@ -1221,6 +1222,7 @@ gtk_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
|
||||||
&localR, XP_GTK_JUST_CENTER,
|
&localR, XP_GTK_JUST_CENTER,
|
||||||
&dctx->black, NULL );
|
&dctx->black, NULL );
|
||||||
} /* gtk_draw_drawMiniWindow */
|
} /* gtk_draw_drawMiniWindow */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SET_GDK_COLOR( c, r, g, b ) { \
|
#define SET_GDK_COLOR( c, r, g, b ) { \
|
||||||
c.red = (r); \
|
c.red = (r); \
|
||||||
|
@ -1301,9 +1303,11 @@ gtkDrawCtxtMake( GtkWidget* drawing_area, GtkAppGlobals* globals )
|
||||||
|
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTimer, gtk );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTimer, gtk );
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_MINIWIN
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_getMiniWText, gtk );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_getMiniWText, gtk );
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, gtk );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, gtk );
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, gtk );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, gtk );
|
||||||
|
#endif
|
||||||
|
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_destroyCtxt, gtk );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_destroyCtxt, gtk );
|
||||||
SET_VTABLE_ENTRY( dctx->vtable, draw_dictChanged, gtk );
|
SET_VTABLE_ENTRY( dctx->vtable, draw_dictChanged, gtk );
|
||||||
|
|
|
@ -1682,6 +1682,32 @@ gtk_util_getTraySearchLimits( XW_UtilCtxt* XP_UNUSED(uc),
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef XWFEATURE_MINIWIN
|
||||||
|
static void
|
||||||
|
gtk_util_setInTrade( XW_UtilCtxt* uc, XP_U16 turn, XP_Bool entering )
|
||||||
|
{
|
||||||
|
XP_LOGF( "%s(turn=%d; entering=%d)", __func__, turn, entering );
|
||||||
|
XP_USE( uc );
|
||||||
|
XP_USE( turn );
|
||||||
|
XP_USE( entering );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_util_bonusSquareHeld( XW_UtilCtxt* uc, XWBonusType bonus )
|
||||||
|
{
|
||||||
|
LOG_FUNC();
|
||||||
|
XP_USE( uc );
|
||||||
|
XP_USE( bonus );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_util_playerScoreHeld( XW_UtilCtxt* uc, const XP_UCHAR* txt )
|
||||||
|
{
|
||||||
|
LOG_FUNC();
|
||||||
|
XP_USE( uc );
|
||||||
|
XP_USE( txt );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
gtk_util_userError( XW_UtilCtxt* uc, UtilErrID id )
|
||||||
|
@ -1901,6 +1927,12 @@ setupGtkUtilCallbacks( GtkAppGlobals* globals, XW_UtilCtxt* util )
|
||||||
util->vtable->m_util_getTraySearchLimits = gtk_util_getTraySearchLimits;
|
util->vtable->m_util_getTraySearchLimits = gtk_util_getTraySearchLimits;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef XWFEATURE_MINIWIN
|
||||||
|
util->vtable->m_util_setInTrade = gtk_util_setInTrade;
|
||||||
|
util->vtable->m_util_bonusSquareHeld = gtk_util_bonusSquareHeld;
|
||||||
|
util->vtable->m_util_playerScoreHeld = gtk_util_playerScoreHeld;
|
||||||
|
#endif
|
||||||
|
|
||||||
util->closure = globals;
|
util->closure = globals;
|
||||||
} /* setupGtkUtilCallbacks */
|
} /* setupGtkUtilCallbacks */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue