mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
Make CEDrawCtx def private; erase background when OS invalidates it.
This gets rid of what's visible behind the board when it's not full-screen width, but causes a lot of flashing. Better will be to make board.c own an entire rectangle and to decide board dimensions itself.
This commit is contained in:
parent
226f1ea470
commit
9be9842e48
4 changed files with 92 additions and 52 deletions
|
@ -24,6 +24,7 @@
|
|||
#include <stdio.h> /* for sprintf, etc. */
|
||||
|
||||
#include "xptypes.h"
|
||||
#include "cedraw.h"
|
||||
#include "board.h"
|
||||
#include "draw.h"
|
||||
#include "mempool.h"
|
||||
|
@ -52,7 +53,34 @@
|
|||
# define TREAT_AS_CURSOR(d,f) (((f) & CELL_ISCURSOR) != 0)
|
||||
#endif
|
||||
|
||||
struct CEDrawCtx {
|
||||
DrawCtxVTable* vtable;
|
||||
|
||||
HWND mainWin;
|
||||
CEAppGlobals* globals;
|
||||
|
||||
COLORREF prevBkColor;
|
||||
|
||||
HBRUSH brushes[CE_NUM_COLORS];
|
||||
PenColorPair pens[CE_NUM_COLORS];
|
||||
|
||||
HFONT selPlayerFont;
|
||||
HFONT playerFont;
|
||||
|
||||
FontCacheEntry fcEntry[N_RESIZE_FONTS];
|
||||
|
||||
HBITMAP rightArrow;
|
||||
HBITMAP downArrow;
|
||||
HBITMAP origin;
|
||||
|
||||
XP_U16 trayOwner;
|
||||
XP_U16 miniLineHt;
|
||||
XP_Bool scoreIsVertical;
|
||||
XP_Bool topFocus;
|
||||
XP_Bool beenCleared;
|
||||
|
||||
MPSLOT
|
||||
};
|
||||
|
||||
static void ceClearToBkground( CEDrawCtx* dctx, const XP_Rect* rect );
|
||||
static void ceDrawBitmapInRect( HDC hdc, const RECT* r, HBITMAP bitmap );
|
||||
|
@ -350,9 +378,9 @@ ceGetSizedFont( CEDrawCtx* dctx, XP_U16 height, RFIndex index,
|
|||
XP_ASSERT( !!font );
|
||||
DeleteObject( testFont );
|
||||
break;
|
||||
} else if ( trialHt == height /* first time through */
|
||||
&& testOffset > 0 ) { /* for safety */
|
||||
trialHt += testOffset;
|
||||
/* } else if ( trialHt == height /\* first time through *\/ */
|
||||
/* && testOffset > 0 ) { /\* for safety *\/ */
|
||||
/* trialHt += testOffset; */
|
||||
} else {
|
||||
++trialHt;
|
||||
}
|
||||
|
@ -729,7 +757,7 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
|
|||
InsetRect( &rt, 1, 1 );
|
||||
Rectangle(hdc, rt.left, rt.top, rt.right, rt.bottom); /* draw frame */
|
||||
InsetRect( &rt, 1, 1 );
|
||||
ceClipToRect( hdc, &rt );
|
||||
/* ceClipToRect( hdc, &rt ); */
|
||||
|
||||
if ( !isEmpty ) {
|
||||
index = getPlayerColor(dctx->trayOwner);
|
||||
|
@ -942,8 +970,8 @@ DRAW_FUNC_NAME(scoreBegin)( DrawCtx* p_dctx, const XP_Rect* rect,
|
|||
{
|
||||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||
CEAppGlobals* globals = dctx->globals;
|
||||
HDC hdc = globals->hdc;
|
||||
SetBkColor( hdc, dctx->globals->appPrefs.colors[CE_BKG_COLOR] );
|
||||
XP_ASSERT( !!globals->hdc );
|
||||
SetBkColor( globals->hdc, dctx->globals->appPrefs.colors[CE_BKG_COLOR] );
|
||||
|
||||
dctx->scoreIsVertical = rect->height > rect->width;
|
||||
|
||||
|
@ -1412,9 +1440,8 @@ ceFontsSetup( CEDrawCtx* dctx )
|
|||
} /* ceFontsSetup */
|
||||
|
||||
void
|
||||
ce_drawctxt_update( DrawCtx* p_dctx )
|
||||
ce_draw_update( CEDrawCtx* dctx )
|
||||
{
|
||||
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
|
||||
XP_U16 i;
|
||||
|
||||
for ( i = 0; i < CE_NUM_COLORS; ++i ) {
|
||||
|
@ -1425,7 +1452,14 @@ ce_drawctxt_update( DrawCtx* p_dctx )
|
|||
}
|
||||
} /* ce_drawctxt_update */
|
||||
|
||||
DrawCtx*
|
||||
void
|
||||
ce_draw_erase( CEDrawCtx* dctx, const RECT* invalR )
|
||||
{
|
||||
CEAppGlobals* globals = dctx->globals;
|
||||
FillRect( globals->hdc, invalR, dctx->brushes[CE_BKG_COLOR] );
|
||||
}
|
||||
|
||||
CEDrawCtx*
|
||||
ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals )
|
||||
{
|
||||
CEDrawCtx* dctx = (CEDrawCtx*)XP_MALLOC( mpool,
|
||||
|
@ -1473,7 +1507,7 @@ ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals )
|
|||
dctx->mainWin = mainWin;
|
||||
dctx->globals = globals;
|
||||
|
||||
ce_drawctxt_update( (DrawCtx*)dctx );
|
||||
ce_draw_update( dctx );
|
||||
|
||||
ceFontsSetup( dctx );
|
||||
|
||||
|
@ -1484,5 +1518,5 @@ ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals )
|
|||
dctx->origin = LoadBitmap( globals->hInst,
|
||||
MAKEINTRESOURCE(IDB_ORIGIN) );
|
||||
|
||||
return (DrawCtx*)dctx;
|
||||
return dctx;
|
||||
} /* ce_drawctxt_make */
|
||||
|
|
32
wince/cedraw.h
Normal file
32
wince/cedraw.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */
|
||||
/*
|
||||
* Copyright 2000-2008 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _CEDRAW_H_
|
||||
#define _CEDRAW_H_
|
||||
|
||||
#include "cemain.h"
|
||||
|
||||
typedef struct CEDrawCtx CEDrawCtx;
|
||||
|
||||
CEDrawCtx* ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals );
|
||||
void ce_draw_update( CEDrawCtx* dctx );
|
||||
void ce_draw_erase( CEDrawCtx* dctx, const RECT* invalR );
|
||||
|
||||
#endif
|
||||
|
|
@ -51,6 +51,7 @@
|
|||
#include "LocalizedStrIncludes.h"
|
||||
#include "debhacks.h"
|
||||
#include "cesvdgms.h"
|
||||
#include "cedraw.h"
|
||||
|
||||
#include "dbgutil.h"
|
||||
|
||||
|
@ -994,7 +995,7 @@ ceLoadSavedGame( CEAppGlobals* globals )
|
|||
XP_DEBUGF( "calling game_makeFromStream" );
|
||||
game_makeFromStream( MEMPOOL stream, &globals->game,
|
||||
&globals->gameInfo,
|
||||
dict, &globals->util, globals->draw,
|
||||
dict, &globals->util, (DrawCtx*)globals->draw,
|
||||
&globals->appPrefs.cp, CE_SEND_PROC,
|
||||
CE_RESET_PROC globals );
|
||||
}
|
||||
|
@ -1227,7 +1228,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
if ( !oldGameLoaded ) {
|
||||
XP_U16 gameID = 0; /* good enough until I get networking going */
|
||||
game_makeNewGame( MPPARM(mpool) &globals->game, &globals->gameInfo,
|
||||
&globals->util, globals->draw, gameID,
|
||||
&globals->util, (DrawCtx*)globals->draw, gameID,
|
||||
&globals->appPrefs.cp,
|
||||
CE_SEND_PROC, CE_RESET_PROC globals );
|
||||
|
||||
|
@ -1372,7 +1373,7 @@ ceDoHistory( CEAppGlobals* globals )
|
|||
} /* ceDoHistory */
|
||||
|
||||
static void
|
||||
drawInsidePaint( CEAppGlobals* globals )
|
||||
drawInsidePaint( CEAppGlobals* globals, const RECT* invalR )
|
||||
{
|
||||
HDC hdc;
|
||||
|
||||
|
@ -1383,6 +1384,10 @@ drawInsidePaint( CEAppGlobals* globals )
|
|||
HDC prevHDC = globals->hdc;
|
||||
globals->hdc = hdc;
|
||||
|
||||
if ( !!invalR ) {
|
||||
ce_draw_erase( globals->draw, invalR );
|
||||
}
|
||||
|
||||
board_draw( globals->game.board );
|
||||
|
||||
globals->hdc = prevHDC;
|
||||
|
@ -1494,7 +1499,7 @@ ceChooseAndOpen( CEAppGlobals* globals )
|
|||
static void
|
||||
updateForColors( CEAppGlobals* globals )
|
||||
{
|
||||
ce_drawctxt_update( globals->draw );
|
||||
ce_draw_update( globals->draw );
|
||||
if ( !!globals->game.board ) {
|
||||
board_invalAll( globals->game.board );
|
||||
}
|
||||
|
@ -1678,7 +1683,7 @@ freeGlobals( CEAppGlobals* globals )
|
|||
|
||||
MPASSIGN( mpool, globals->mpool );
|
||||
|
||||
draw_destroyCtxt( globals->draw );
|
||||
draw_destroyCtxt( (DrawCtx*)globals->draw );
|
||||
|
||||
closeGame( globals );
|
||||
|
||||
|
@ -2137,7 +2142,7 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
board_invalRect( globals->game.board, &rect );
|
||||
|
||||
XP_ASSERT( globals->hWnd == hWnd );
|
||||
drawInsidePaint( globals );
|
||||
drawInsidePaint( globals, &winrect );
|
||||
}
|
||||
if ( !ValidateRect( hWnd, &winrect ) ) {
|
||||
logLastError( "WM_PAINT:ValidateRect" );
|
||||
|
@ -2832,7 +2837,7 @@ ce_util_trayHiddenChange( XW_UtilCtxt* uc, XW_TrayVisState XP_UNUSED(newState),
|
|||
}
|
||||
#endif
|
||||
|
||||
drawInsidePaint( globals );
|
||||
drawInsidePaint( globals, NULL );
|
||||
} /* ce_util_trayHiddenChange */
|
||||
|
||||
static void
|
||||
|
@ -2858,7 +2863,7 @@ static void
|
|||
ce_util_notifyGameOver( XW_UtilCtxt* uc )
|
||||
{
|
||||
CEAppGlobals* globals = (CEAppGlobals*)uc->closure;
|
||||
drawInsidePaint( globals );
|
||||
drawInsidePaint( globals, NULL );
|
||||
ceDisplayFinalScores( globals );
|
||||
|
||||
ceSetLeftSoftkey( globals, ID_FILE_NEWGAME );
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4;-*- */
|
||||
/*
|
||||
* Copyright 2000-2007 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
* Copyright 2000-2008 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
|
||||
|
@ -108,7 +108,7 @@ typedef struct CEAppGlobals {
|
|||
|
||||
XP_U16 softKeyId; /* id of item now on left button */
|
||||
|
||||
DrawCtx* draw;
|
||||
struct CEDrawCtx* draw;
|
||||
XWGame game;
|
||||
CurGameInfo gameInfo;
|
||||
XP_UCHAR* curGameName; /* path to storage for current game */
|
||||
|
@ -181,37 +181,6 @@ typedef struct _FontCacheEntry {
|
|||
XP_U16 actualHt;
|
||||
} FontCacheEntry;
|
||||
|
||||
typedef struct CEDrawCtx {
|
||||
DrawCtxVTable* vtable;
|
||||
|
||||
HWND mainWin;
|
||||
CEAppGlobals* globals;
|
||||
|
||||
COLORREF prevBkColor;
|
||||
|
||||
HBRUSH brushes[CE_NUM_COLORS];
|
||||
PenColorPair pens[CE_NUM_COLORS];
|
||||
|
||||
HFONT selPlayerFont;
|
||||
HFONT playerFont;
|
||||
|
||||
FontCacheEntry fcEntry[N_RESIZE_FONTS];
|
||||
|
||||
HBITMAP rightArrow;
|
||||
HBITMAP downArrow;
|
||||
HBITMAP origin;
|
||||
|
||||
XP_U16 trayOwner;
|
||||
XP_U16 miniLineHt;
|
||||
XP_Bool scoreIsVertical;
|
||||
XP_Bool topFocus;
|
||||
|
||||
MPSLOT
|
||||
} CEDrawCtx;
|
||||
|
||||
DrawCtx* ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals );
|
||||
void ce_drawctxt_update( DrawCtx* dctx );
|
||||
|
||||
int messageBoxChar( CEAppGlobals* globals, XP_UCHAR* str, wchar_t* title,
|
||||
XP_U16 buttons );
|
||||
XP_Bool queryBoxChar( CEAppGlobals* globals, const XP_UCHAR* msg );
|
||||
|
|
Loading…
Add table
Reference in a new issue