From 6aca59abe05b650232a34f8e56ec517d1b716073 Mon Sep 17 00:00:00 2001 From: ehouse Date: Fri, 23 Oct 2009 08:54:54 +0000 Subject: [PATCH] =?UTF-8?q?Make=20state=20private=20to=20ceblank.c;=20all?= =?UTF-8?q?=20dict=20strings=20are=20utf8,=20so=20don't=20ever=20convert?= =?UTF-8?q?=20using=20CP=5FACP.=20=20Fixes=20misdisplay=20of=20Spanish=20?= =?UTF-8?q?=C3=91.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xwords4/wince/ceblank.c | 38 +++++++++++++++++++++++++++++++++----- xwords4/wince/ceblank.h | 14 ++------------ xwords4/wince/cemain.c | 14 +------------- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/xwords4/wince/ceblank.c b/xwords4/wince/ceblank.c index 35333f8f0..d278cc481 100755 --- a/xwords4/wince/ceblank.c +++ b/xwords4/wince/ceblank.c @@ -22,6 +22,17 @@ #include "cemain.h" #include "ceutil.h" #include "debhacks.h" +#include "cedebug.h" + +typedef struct BlankDialogState { + CeDlgHdr dlgHdr; + const PickInfo* pi; + XP_U16 playerNum; + const XP_UCHAR** texts; + XP_U16 nTiles; + XP_S16 result; + XP_Bool canBackup; +} BlankDialogState; static void loadLettersList( BlankDialogState* bState ) @@ -31,13 +42,12 @@ loadLettersList( BlankDialogState* bState ) HWND hDlg = bState->dlgHdr.hDlg; CEAppGlobals* globals = bState->dlgHdr.globals; const XP_UCHAR** texts = bState->texts; - UINT codePage = ceCurDictIsUTF8(globals)? CP_UTF8 : CP_ACP; for ( ii = 0; ii < nTiles; ++ii ) { XP_U16 len; wchar_t widebuf[4]; - len = MultiByteToWideChar( codePage, 0, texts[ii], strlen(texts[ii]), + len = MultiByteToWideChar( CP_UTF8, 0, texts[ii], strlen(texts[ii]), widebuf, VSIZE(widebuf) ); widebuf[len] = 0; @@ -78,8 +88,7 @@ showCurTray( HWND hDlg, BlankDialogState* bState ) i==0?": ":", ", pi->curTiles[i] ); } - (void)MultiByteToWideChar( ceCurDictIsUTF8(globals)? CP_UTF8 : CP_ACP, - 0, labelBuf, lenSoFar + 1, widebuf, + (void)MultiByteToWideChar( CP_UTF8, 0, labelBuf, lenSoFar + 1, widebuf, VSIZE(widebuf) + sizeof(widebuf[0]) ); SetDlgItemText( hDlg,IDC_PICKMSG, widebuf ); @@ -87,7 +96,7 @@ showCurTray( HWND hDlg, BlankDialogState* bState ) } /* showCurTray */ #endif -LRESULT CALLBACK +static LRESULT CALLBACK BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { BlankDialogState* bState; @@ -154,3 +163,22 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) exit: return result; } /* BlankDlg */ + +XP_Bool +WrapBlankDlg( CEAppGlobals* globals, const PickInfo* pi, + XP_U16 playerNum, const XP_UCHAR** texts, XP_U16 nTiles ) +{ + BlankDialogState state; + XP_MEMSET( &state, 0, sizeof(state) ); + + state.dlgHdr.globals = globals; + state.texts = texts; + state.nTiles = nTiles; + state.playerNum = playerNum; + state.pi = pi; + + assertOnTop( globals->hWnd ); + DialogBoxParam( globals->locInst, (LPCTSTR)IDD_ASKBLANK, globals->hWnd, + (DLGPROC)BlankDlg, (long)&state ); + return state.result; +} diff --git a/xwords4/wince/ceblank.h b/xwords4/wince/ceblank.h index 9c37f740c..8d13f3049 100755 --- a/xwords4/wince/ceblank.h +++ b/xwords4/wince/ceblank.h @@ -24,16 +24,6 @@ #include "cemain.h" #include "ceutil.h" -typedef struct BlankDialogState { - CeDlgHdr dlgHdr; - const PickInfo* pi; - XP_U16 playerNum; - const XP_UCHAR** texts; - XP_U16 nTiles; - XP_S16 result; - XP_Bool canBackup; -} BlankDialogState; - -LRESULT CALLBACK BlankDlg(HWND, UINT, WPARAM, LPARAM); - +XP_Bool WrapBlankDlg( CEAppGlobals* globals, const PickInfo* pi, + XP_U16 playerNum, const XP_UCHAR** texts, XP_U16 nTiles ); #endif diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index 19083381f..0799b6c91 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -3292,20 +3292,8 @@ ce_util_userPickTile( XW_UtilCtxt* uc, const PickInfo* pi, XP_U16 playerNum, const XP_UCHAR** texts, XP_U16 nTiles ) { - BlankDialogState state; CEAppGlobals* globals = (CEAppGlobals*)uc->closure; - XP_MEMSET( &state, 0, sizeof(state) ); - - state.dlgHdr.globals = globals; - state.texts = texts; - state.nTiles = nTiles; - state.playerNum = playerNum; - state.pi = pi; - - assertOnTop( globals->hWnd ); - DialogBoxParam( globals->locInst, (LPCTSTR)IDD_ASKBLANK, globals->hWnd, - (DLGPROC)BlankDlg, (long)&state ); - return state.result; + return WrapBlankDlg( globals, pi, playerNum, texts, nTiles ); } /* ce_util_userPickTile */ static XP_Bool