get rid of draw methods; always highlight cursor same way;

board_handleKeyUp becomse board_handleKey for curses
This commit is contained in:
ehouse 2007-01-19 08:20:58 +00:00
parent 0a426b0876
commit 20ecd5f7d7
4 changed files with 29 additions and 71 deletions

View file

@ -1,5 +1,6 @@
# -*- mode: makefile; compile-command: "make MEMDEBUG=TRUE"; -*-
# Copyright 2002 by Eric House (xwords@eehouse.org). All rights reserved.
# Copyright 2002-2007 by Eric House (xwords@eehouse.org). All rights
# reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -67,6 +68,7 @@ DEFINES += -DXWFEATURE_BLUETOOTH
#DEFINES += -DFEATURE_TRAY_EDIT
DEFINES += -DDONT_ABORT_ENGINE
DEFINES += -DPERIMETER_FOCUS
#-DDEBUG -DEIGHT_TILES

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
/*
* Copyright 1997-2000 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 1997-2007 by Eric House (xwords@eehouse.org). All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -220,13 +220,11 @@ curses_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect,
} /* curses_draw_score_pendingScore */
static void
curses_draw_objFinished( DrawCtx* p_dctx, BoardObjectType typ,
const XP_Rect* rect, DrawFocusState dfs )
curses_draw_objFinished( DrawCtx* p_dctx, BoardObjectType XP_UNUSED(typ),
const XP_Rect* XP_UNUSED(rect),
DrawFocusState XP_UNUSED(dfs) )
{
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
if ( dfs == DFS_TOP && typ == OBJ_BOARD ) {
cursesHiliteRect( dctx->boardWin, rect );
}
wrefresh( dctx->boardWin );
} /* curses_draw_objFinished */
@ -289,6 +287,10 @@ curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
wstandend( dctx->boardWin );
}
if ( (flags&CELL_ISCURSOR) != 0 ) {
cursesHiliteRect( dctx->boardWin, rect );
}
return XP_TRUE;
} /* curses_draw_drawCell */
@ -384,16 +386,6 @@ curses_draw_drawBoardArrow( DrawCtx* p_dctx, const XP_Rect* rect,
#endif
} /* curses_draw_drawBoardArrow */
static void
curses_draw_drawCursor( DrawCtx* p_dctx, BoardObjectType typ,
const XP_Rect* rect )
{
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
if ( typ == OBJ_BOARD ) {
cursesHiliteRect( dctx->boardWin, rect );
}
} /* curses_draw_drawBoardCursor */
static void
curses_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP )
{
@ -425,6 +417,8 @@ curses_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
XP_Rect smallerR;
XP_ASSERT(0); /* does this really get called? */
smallerR.top = rect->top + 1;
smallerR.left = rect->left + 1;
smallerR.width = rect->width - 2;
@ -437,16 +431,6 @@ curses_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
strlen(text) );
} /* curses_draw_drawMiniWindow */
static void
curses_draw_eraseMiniWindow( DrawCtx* XP_UNUSED(p_dctx),
const XP_Rect* XP_UNUSED(rect),
XP_Bool XP_UNUSED(lastTime),
void** XP_UNUSED(closure),
XP_Bool* invalUnder )
{
*invalUnder = XP_TRUE;
} /* curses_draw_eraseMiniWindow*/
#if 0
static void
curses_draw_frameTray( DrawCtx* p_dctx, XP_Rect* rect )
@ -491,22 +475,13 @@ cursesDrawCtxtMake( WINDOW* boardWin )
SET_VTABLE_ENTRY( dctx->vtable, draw_drawTrayDivider, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawBoardArrow, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawCursor, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_eraseMiniWindow, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_getMiniWText, curses );
SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, curses );
/* SET_VTABLE_ENTRY( dctx, draw_getBonusText, gtk ); */
/* SET_VTABLE_ENTRY( dctx, draw_eraseMiniWindow, gtk ); */
/* SET_VTABLE_ENTRY( dctx, draw_frameTray, curses ); */
dctx->boardWin = boardWin;
return (DrawCtx*)dctx;

View file

@ -229,20 +229,16 @@ curses_util_engineProgressCallback( XW_UtilCtxt* XP_UNUSED(uc) )
return XP_TRUE;
} /* curses_util_engineProgressCallback */
#ifdef XWFEATURE_RELAY
static void
curses_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
TimerProc proc, void* closure )
{
CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure;
XP_ASSERT( why == TIMER_HEARTBEAT );
globals->cGlobals.timerProcs[why] = proc;
globals->cGlobals.timerClosures[why] = closure;
globals->nextTimer = util_getCurSeconds(uc) + when;
} /* curses_util_setTimer */
#endif
static void
curses_util_requestTime( XW_UtilCtxt* uc )
@ -340,8 +336,8 @@ handleSpace( CursesAppGlobals* globals )
XP_Bool handled;
checkAssignFocus( globals->cGlobals.game.board );
globals->doDraw = board_handleKeyUp( globals->cGlobals.game.board,
XP_RAISEFOCUS_KEY, &handled );
globals->doDraw = board_handleKey( globals->cGlobals.game.board,
XP_RAISEFOCUS_KEY, &handled );
return XP_TRUE;
} /* handleSpace */
@ -349,8 +345,8 @@ static XP_Bool
handleRet( CursesAppGlobals* globals )
{
XP_Bool handled;
globals->doDraw = board_handleKeyUp( globals->cGlobals.game.board,
XP_RETURN_KEY, &handled );
globals->doDraw = board_handleKey( globals->cGlobals.game.board,
XP_RETURN_KEY, &handled );
return XP_TRUE;
} /* handleRet */
@ -437,8 +433,8 @@ static XP_Bool
handleBackspace( CursesAppGlobals* globals )
{
XP_Bool handled;
globals->doDraw = board_handleKeyUp( globals->cGlobals.game.board,
XP_CURSOR_KEY_DEL, &handled );
globals->doDraw = board_handleKey( globals->cGlobals.game.board,
XP_CURSOR_KEY_DEL, &handled );
return XP_TRUE;
} /* handleBackspace */
@ -490,7 +486,7 @@ handleFocusKey( CursesAppGlobals* globals, XP_Key key )
checkAssignFocus( globals->cGlobals.game.board );
draw = board_handleKeyUp( globals->cGlobals.game.board, key, &handled );
draw = board_handleKey( globals->cGlobals.game.board, key, &handled );
if ( !handled ) {
BoardObjectType nxt;
BoardObjectType order[] = { OBJ_BOARD, OBJ_SCORE, OBJ_TRAY };
@ -965,9 +961,7 @@ setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util )
util->vtable->m_util_engineProgressCallback =
curses_util_engineProgressCallback;
#ifdef XWFEATURE_RELAY
util->vtable->m_util_setTimer = curses_util_setTimer;
#endif
util->vtable->m_util_requestTime = curses_util_requestTime;
util->closure = globals;
@ -1002,8 +996,8 @@ passKeyToBoard( CursesAppGlobals* globals, char ch )
XP_Bool handled = ch >= 'a' && ch <= 'z';
if ( handled ) {
ch += 'A' - 'a';
globals->doDraw = board_handleKeyUp( globals->cGlobals.game.board,
ch, NULL );
globals->doDraw = board_handleKey( globals->cGlobals.game.board,
ch, NULL );
}
return handled;
} /* passKeyToBoard */

View file

@ -281,13 +281,11 @@ drawFocusFrame( GtkDrawCtx* dctx, const XP_Rect* r )
}
static void
gtk_draw_objFinished( DrawCtx* p_dctx, BoardObjectType XP_UNUSED(typ),
const XP_Rect* rect, DrawFocusState dfs )
gtk_draw_objFinished( DrawCtx* XP_UNUSED(p_dctx),
BoardObjectType XP_UNUSED(typ),
const XP_Rect* XP_UNUSED(rect),
DrawFocusState XP_UNUSED(dfs) )
{
if ( dfs == DFS_TOP ) {
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
drawFocusFrame( dctx, rect );
}
} /* draw_finished */
static void
@ -509,7 +507,7 @@ gtk_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
}
}
if ( !dctx->topFocus && (flags & CELL_ISCURSOR) != 0 ) {
if ((flags & CELL_ISCURSOR) != 0 ) {
drawFocusFrame( dctx, rect );
}
@ -540,7 +538,7 @@ gtk_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect,
&r, XP_GTK_JUST_CENTER,
&dctx->playerColors[dctx->trayOwner], NULL );
if ( !dctx->topFocus && (flags & CELL_ISCURSOR) != 0 ) {
if ( (flags & CELL_ISCURSOR) != 0 ) {
drawFocusFrame( dctx, rect );
}
} /* gtk_draw_drawTileBack */
@ -745,7 +743,7 @@ gtk_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
rInner, XP_GTK_JUST_CENTER,
&dctx->playerColors[dsi->playerNum], NULL );
if ( !dctx->topFocus && ((dsi->flags & CELL_ISCURSOR) != 0) ) {
if ( ((dsi->flags & CELL_ISCURSOR) != 0) ) {
drawFocusFrame( dctx, rOuter );
}
} /* gtk_draw_score_drawPlayer */
@ -886,16 +884,6 @@ gtk_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
&dctx->black, NULL );
} /* gtk_draw_drawMiniWindow */
static void
gtk_draw_eraseMiniWindow( DrawCtx* XP_UNUSED(p_dctx),
const XP_Rect* XP_UNUSED(rect),
XP_Bool XP_UNUSED(lastTime),
void** XP_UNUSED(closure), XP_Bool* invalUnder )
{
/* GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; */
*invalUnder = XP_TRUE;
} /* gtk_draw_eraseMiniWindow */
#define SET_GDK_COLOR( c, r, g, b ) { \
c.red = (r); \
c.green = (g); \
@ -999,7 +987,6 @@ gtkDrawCtxtMake( GtkWidget* drawing_area, GtkAppGlobals* globals )
SET_VTABLE_ENTRY( dctx->vtable, draw_getMiniWText, gtk );
SET_VTABLE_ENTRY( dctx->vtable, draw_measureMiniWText, gtk );
SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, gtk );
SET_VTABLE_ENTRY( dctx->vtable, draw_eraseMiniWindow, gtk );
SET_VTABLE_ENTRY( dctx->vtable, draw_destroyCtxt, gtk );
#endif