From 7da66696ede9d8bbfe47c0124a2245b270c49c00 Mon Sep 17 00:00:00 2001 From: ehouse Date: Sat, 31 May 2008 22:07:29 +0000 Subject: [PATCH] Fix dictionary-search code to look in top-level temporary directories rather than hard-coded "SD Card" etc. to work in non-English cases; fix password dialog to fit, and simplify it; fix backspace on smartphone for all dialogs with EDIT fields to actually backspace rather than exiting app; and in main window have it raise focus. This change requires SHSendBackToFocusWindow(), which is not yet in cegcc. Until I get a patch accepted this breaks wince builds. --- wince/ceaskpwd.c | 12 ++++ wince/ceaskpwd.h | 1 + wince/ceblank.c | 32 ++++++--- wince/ceblank.h | 3 +- wince/ceclrsel.c | 10 ++- wince/cedict.c | 172 +++++++++++++---------------------------------- wince/cedict.h | 3 +- wince/cedraw.c | 10 ++- wince/ceginfo.c | 14 +++- wince/cemain.c | 32 +++++++-- wince/ceprefs.c | 10 ++- wince/cesvdgms.c | 11 +++ wince/ceutil.c | 16 ++++- wince/ceutil.h | 3 + wince/debhacks.h | 12 ++++ wince/resource.h | 8 +-- wince/xwords4.rc | 37 +++++----- 17 files changed, 209 insertions(+), 177 deletions(-) diff --git a/wince/ceaskpwd.c b/wince/ceaskpwd.c index d4eda9b25..3a384d184 100755 --- a/wince/ceaskpwd.c +++ b/wince/ceaskpwd.c @@ -20,6 +20,7 @@ #include "ceaskpwd.h" #include "cemain.h" #include "ceutil.h" +#include "debhacks.h" #include /* swprintf */ static void @@ -48,6 +49,9 @@ PasswdDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetWindowLong( hDlg, GWL_USERDATA, lParam ); pState = (PasswdDialogState*)lParam; + ceDlgSetup( pState->globals, hDlg ); + trapBackspaceKey( hDlg ); + nameToLabel( hDlg, pState->name, IDC_PWDLABEL ); return TRUE; @@ -56,6 +60,14 @@ PasswdDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if ( !!pState ) { switch ( message ) { +#ifdef _WIN32_WCE + case WM_HOTKEY: + if ( VK_TBACK == HIWORD(lParam) ) { + SHSendBackToFocusWindow( message, wParam, lParam ); + return TRUE; + } + break; +#endif case WM_COMMAND: id = LOWORD(wParam); switch( id ) { diff --git a/wince/ceaskpwd.h b/wince/ceaskpwd.h index ce777aa37..807e1e6bb 100755 --- a/wince/ceaskpwd.h +++ b/wince/ceaskpwd.h @@ -24,6 +24,7 @@ #include "cemain.h" typedef struct PasswdDialogState { + CEAppGlobals* globals; const XP_UCHAR* name; XP_UCHAR* buf; XP_U16* lenp; diff --git a/wince/ceblank.c b/wince/ceblank.c index 151a55c88..fc86fd9e3 100755 --- a/wince/ceblank.c +++ b/wince/ceblank.c @@ -1,6 +1,6 @@ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* - * Copyright 2002 by Eric House (xwords@eehouse.org). All rights reserved. + * Copyright 2002,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 @@ -20,6 +20,7 @@ #include "ceblank.h" #include "cemain.h" #include "ceutil.h" +#include "debhacks.h" static void loadLettersList( HWND hDlg, BlankDialogState* bState ) @@ -37,7 +38,7 @@ loadLettersList( HWND hDlg, BlankDialogState* bState ) widebuf, VSIZE(widebuf) ); widebuf[len] = 0; - SendDlgItemMessage( hDlg, BLANKFACE_LIST, LB_ADDSTRING, + SendDlgItemMessage( hDlg, BLANKFACE_LIST, ADDSTRING, 0, (long)widebuf ); } ce_selectAndShow( hDlg, BLANKFACE_LIST, 0 ); @@ -95,15 +96,15 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } else { XP_ASSERT( bState->pi->why == PICK_FOR_BLANK ); ceShowOrHide( hDlg, IDC_CPICK, XP_FALSE ); - ceShowOrHide( hDlg, IDC_PICKALL, XP_FALSE ); ceShowOrHide( hDlg, IDC_PICKMSG, XP_FALSE ); } - ceShowOrHide( hDlg, IDC_BACKUP, - bState->pi->why == PICK_FOR_CHEAT - && bState->pi->thisPick > 0 ); + bState->canBackup = (bState->pi->why == PICK_FOR_CHEAT) + && (bState->pi->thisPick > 0); + ceShowOrHide( hDlg, IDC_BACKUP, bState->canBackup ); #endif ceDlgSetup( bState->globals, hDlg ); + trapBackspaceKey( hDlg ); loadLettersList( hDlg, bState ); } else { @@ -111,14 +112,25 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if ( !!bState ) { switch ( message ) { - case WM_KEYDOWN: /* key down. Select a list item? */ - XP_LOGF( "got WM_KEYDOWN" ); +/* case WM_KEYDOWN: /\* key down. Select a list item? *\/ */ +/* XP_LOGF( "got WM_KEYDOWN" ); */ +/* break; */ +#ifdef _WIN32_WCE + case WM_HOTKEY: + if ( VK_TBACK == HIWORD(lParam) ) { + if ( bState->canBackup ) { + bState->result = PICKER_BACKUP; + EndDialog( hDlg, IDC_BACKUP ); + return TRUE; + } + } break; +#endif case WM_COMMAND: id = LOWORD(wParam); if ( 0 ) { #ifdef FEATURE_TRAY_EDIT - } else if ( id == IDC_PICKALL ) { + } else if ( id == IDCANCEL ) { bState->result = PICKER_PICKALL; } else if ( id == IDC_BACKUP ) { bState->result = PICKER_BACKUP; @@ -126,7 +138,7 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } else if ( id == IDOK ) { bState->result = (XP_S16)SendDlgItemMessage( hDlg, BLANKFACE_LIST, - LB_GETCURSEL, 0, 0 ); + GETCURSEL, 0, 0 ); } else { break; } diff --git a/wince/ceblank.h b/wince/ceblank.h index 5f0227fec..2e714a155 100755 --- a/wince/ceblank.h +++ b/wince/ceblank.h @@ -1,6 +1,6 @@ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* - * Copyright 2002 by Eric House (xwords@eehouse.org). All rights reserved. + * Copyright 2002, 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 @@ -30,6 +30,7 @@ typedef struct BlankDialogState { const XP_UCHAR4* texts; XP_U16 nTiles; XP_S16 result; + XP_Bool canBackup; } BlankDialogState; LRESULT CALLBACK BlankDlg(HWND, UINT, WPARAM, LPARAM); diff --git a/wince/ceclrsel.c b/wince/ceclrsel.c index 9957c3c57..5987a2f11 100644 --- a/wince/ceclrsel.c +++ b/wince/ceclrsel.c @@ -146,6 +146,7 @@ EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) eState->inited = XP_FALSE; ceDlgSetup( eState->globals, hDlg ); + trapBackspaceKey( hDlg ); wchar_t label[32]; XP_U16 len = SendDlgItemMessage( eState->parent, eState->labelID, @@ -197,7 +198,14 @@ EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) break; } break; - +#ifdef _WIN32_WCE + case WM_HOTKEY: + if ( VK_TBACK == HIWORD(lParam) ) { + SHSendBackToFocusWindow( message, wParam, lParam ); + return TRUE; + } + break; +#endif case WM_COMMAND: wid = LOWORD(wParam); switch( wid ) { diff --git a/wince/cedict.c b/wince/cedict.c index 33fb80cfd..6362634a3 100755 --- a/wince/cedict.c +++ b/wince/cedict.c @@ -23,11 +23,13 @@ #include /* _snwprintf */ #include "stdafx.h" +/* #include */ #include #include "dictnryp.h" #include "strutils.h" #include "cedict.h" #include "debhacks.h" +#include "cedebug.h" typedef struct CEDictionaryCtxt { DictionaryCtxt super; @@ -621,121 +623,47 @@ locateOneDir( MPFORMAL wchar_t* path, OnePathCB cb, void* ctxt, XP_U16 nSought, return done; } /* locateOneDir */ -#define USE_FOREACH /* FOREACH avoids code duplication, but may not be worth - the extra complexity. Size is the same. */ -#ifdef USE_FOREACH -/* return true when done */ -typedef XP_Bool (*ForEachCB)( wchar_t* dir, void* ctxt ); - -static void -forEachDictDir( HINSTANCE hInstance, ForEachCB cb, void* ctxt ) -{ - UINT id; - for ( id = IDS_DICTDIRS; ; ++id ) { - wchar_t pathBuf[CE_MAX_PATH_LEN+1]; - if ( 0 >= LoadString( hInstance, id, pathBuf, - VSIZE(pathBuf) ) ) { - break; - } - - if ( (*cb)( pathBuf, ctxt ) ) { - break; - } - } -} /* forEachDictDir */ - -typedef struct LocateOneData { - XP_U16 nFound; - XP_U16 nSought; - OnePathCB cb; - void* ctxt; - - MPSLOT -} LocateOneData; - static XP_Bool -locateOneDirCB( wchar_t* dir, void* ctxt ) +getDictDir( wchar_t* buf ) { - LocateOneData* datap = (LocateOneData*)ctxt; - - return locateOneDir( MPPARM(datap->mpool) dir, datap->cb, - datap->ctxt, datap->nSought, &datap->nFound ) - || datap->nFound >= datap->nSought; -} /* locateOneDirCB */ - -XP_U16 -ceLocateNDicts( MPFORMAL HINSTANCE hInstance, XP_U16 nSought, - OnePathCB cb, void* ctxt ) -{ - LocateOneData data; - - data.nFound = 0; - data.nSought = nSought; - data.cb = cb; - data.ctxt = ctxt; -#ifdef MEM_DEBUG - data.mpool = mpool; -#endif - - forEachDictDir( hInstance, locateOneDirCB, &data ); - return data.nFound; +/* BOOL found = SHGetKnownFolderPath(HWND,LPWSTR,int,BOOL); */ + // temporary hack until I figure SHGetKnownFolderPath out + wsprintf( buf, L"\\Program Files\\Crosswords" ); + return XP_TRUE; } -typedef struct FormatDirsData { - XWStreamCtxt* stream; - XP_Bool firstPassDone; -} FormatDirsData; - -static XP_Bool -formatDirsCB( wchar_t* dir, void* ctxt ) -{ - FormatDirsData* datap = (FormatDirsData*)ctxt; - XP_UCHAR narrow[CE_MAX_PATH_LEN+1]; - int len; - - if ( datap->firstPassDone ) { - stream_putString( datap->stream, ", " ); - } else { - datap->firstPassDone = XP_TRUE; - } - - len = WideCharToMultiByte( CP_ACP, 0, dir, -1, - narrow, VSIZE(narrow), - NULL, NULL ); - stream_putString( datap->stream, narrow ); - return XP_FALSE; -} /* formatDirsCB */ - -void -ceFormatDictDirs( XWStreamCtxt* stream, HINSTANCE hInstance ) -{ - FormatDirsData data; - data.stream = stream; - data.firstPassDone = XP_FALSE; - - forEachDictDir( hInstance, formatDirsCB, &data ); -} - -#else - XP_U16 -ceLocateNDicts( MPFORMAL HINSTANCE hInstance, XP_U16 nSought, - OnePathCB cb, void* ctxt ) +ceLocateNDicts( MPFORMAL XP_U16 nSought, OnePathCB cb, void* ctxt ) { XP_U16 nFound = 0; - UINT id; + wchar_t path[CE_MAX_PATH_LEN+1]; - for ( id = IDS_DICTDIRS; ; ++id ) { - wchar_t pathBuf[CE_MAX_PATH_LEN+1]; - if ( 0 >= LoadString( hInstance, id, pathBuf, - VSIZE(pathBuf) ) ) { - break; - } + if ( getDictDir( path ) ) { + locateOneDir( MPPARM(mpool) path, cb, ctxt, nSought, &nFound ); + } - locateOneDir( MPPARM(mpool) pathBuf, cb, ctxt, nSought, &nFound ); + if ( nFound < nSought ) { + WIN32_FIND_DATA data; + HANDLE fileH; - if ( nFound >= nSought ) { - break; + XP_MEMSET( &data, 0, sizeof(data) ); + + fileH = FindFirstFile( L"\\*", &data ); + while ( fileH != INVALID_HANDLE_VALUE ) { + if ( ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) + && (((data.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY) != 0) ) ) { + wsprintf( path, L"\\%s\\Crosswords", data.cFileName ); + + XP_LOGW( "looking in:", path ); + locateOneDir( MPPARM(mpool) path, cb, ctxt, nSought, &nFound ); + } + if ( nFound >= nSought ) { + break; + } + + if ( !FindNextFile( fileH, &data ) ) { + break; + } } } @@ -745,28 +673,19 @@ ceLocateNDicts( MPFORMAL HINSTANCE hInstance, XP_U16 nSought, void ceFormatDictDirs( XWStreamCtxt* stream, HINSTANCE hInstance ) { - UINT id; - - for ( id = IDS_DICTDIRS; ; ++id ) { - wchar_t wide[CE_MAX_PATH_LEN+1]; - XP_UCHAR narrow[CE_MAX_PATH_LEN+1]; - XP_U16 len; - - if ( 0 >= LoadString( hInstance, id, wide, - VSIZE(wide) ) ) { - break; - } - - if ( id != IDS_DICTDIRS ) { - stream_putString( stream, ", " ); - } - len = WideCharToMultiByte( CP_ACP, 0, wide, -1, - narrow, VSIZE(narrow), - NULL, NULL ); - stream_putString( stream, narrow ); + wchar_t path[CE_MAX_PATH_LEN+1]; + if ( getDictDir( path ) ) { + char narrowName[CE_MAX_PATH_LEN+1]; + int len = wcslen( path ); + len = WideCharToMultiByte( CP_ACP, 0, path, len + 1, + narrowName, len + 1, NULL, NULL ); + stream_putString( stream, narrowName ); + stream_putString( stream, " or" ); } + + const char* rest = " on an external card, e.g. in \\Storage Card\\Crosswords"; + stream_putString( stream, rest ); } -#endif /* USE_FOREACH */ typedef struct FindOneData { wchar_t* result; @@ -807,8 +726,7 @@ findAlternateDict( CEAppGlobals* globals, wchar_t* path ) data.sought = wbname( shortPath, sizeof(shortPath), path ); data.result = path; - (void)ceLocateNDicts( MPPARM(globals->mpool) globals->hInst, CE_MAXDICTS, - matchShortName, &data ); + (void)ceLocateNDicts( MPPARM(globals->mpool) CE_MAXDICTS, matchShortName, &data ); return data.found; } /* findAlternateDict */ diff --git a/wince/cedict.h b/wince/cedict.h index cafed7828..0f3b5431d 100755 --- a/wince/cedict.h +++ b/wince/cedict.h @@ -41,8 +41,7 @@ typedef XP_Bool (*OnePathCB)( const wchar_t* wPath, XP_U16 index, void* ctxt ); * dict files. Return the number actually found. Caller is responsible for * making sure bufs contains nSought slots. */ -XP_U16 ceLocateNDicts( MPFORMAL HINSTANCE hInstance, XP_U16 nSought, - OnePathCB cb, void* ctxt ); +XP_U16 ceLocateNDicts( MPFORMAL XP_U16 nSought, OnePathCB cb, void* ctxt ); void ceFormatDictDirs( XWStreamCtxt* stream, HINSTANCE hInstance ); /* return just the name, no extension, of dict, written to buf, pointed to by diff --git a/wince/cedraw.c b/wince/cedraw.c index a7dcb4f50..8539d61cb 100755 --- a/wince/cedraw.c +++ b/wince/cedraw.c @@ -900,7 +900,7 @@ DRAW_FUNC_NAME(score_pendingScore)( DrawCtx* p_dctx, const XP_Rect* rect, wchar_t widebuf[5]; XP_UCHAR buf[5]; - RECT rt; + RECT rt, clip; XP_U16 bkIndex = (flags & CELL_ISCURSOR) == 0? CE_BKG_COLOR : CE_FOCUS_COLOR; @@ -912,9 +912,13 @@ DRAW_FUNC_NAME(score_pendingScore)( DrawCtx* p_dctx, const XP_Rect* rect, XPRtoRECT( &rt, rect ); FillRect( hdc, &rt, dctx->brushes[bkIndex] ); - ceClipToRect( hdc, &rt ); + /* Use a separate rect for clipping since shrinking puts text to close + together on smartphone's small screen. */ + clip = rt; + InsetRect( &clip, 2, 2 ); + ceClipToRect( hdc, &clip ); - DrawText(hdc, L"Pts", -1, &rt, DT_SINGLELINE | DT_TOP | DT_CENTER); + DrawText(hdc, L"Pts", -1, &rt, DT_SINGLELINE | DT_TOP | DT_CENTER); if ( score < 0 ) { buf[0] = '?'; diff --git a/wince/ceginfo.c b/wince/ceginfo.c index 1f8d94c66..56f437211 100755 --- a/wince/ceginfo.c +++ b/wince/ceginfo.c @@ -26,6 +26,7 @@ #include "cecondlg.h" #include "strutils.h" #include "cedebug.h" +#include "debhacks.h" #define NUM_COLS 4 #define MENUDICTS_INCR 16 @@ -181,7 +182,7 @@ loadFromGameInfo( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) (XP_U16)XP_STRLEN(gi->dictName)+1 ); } if ( giState->isNewGame ) { - (void)ceLocateNDicts( MPPARM(globals->mpool) globals->hInst, + (void)ceLocateNDicts( MPPARM(globals->mpool) CE_MAXDICTS, addDictToState, giState ); } else { wchar_t wPath[CE_MAX_PATH_LEN+1]; @@ -495,6 +496,7 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) globals = giState->globals; ceDlgSetup( globals, hDlg ); + trapBackspaceKey( hDlg ); giState->newGameCtx = newg_make( MPPARM(globals->mpool) giState->isNewGame, @@ -513,6 +515,7 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if ( giState->isNewGame ) { (void)SetWindowText( hDlg, L"New game" ); } + result = TRUE; } else { @@ -521,7 +524,14 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) globals = giState->globals; switch (message) { - +#ifdef _WIN32_WCE + case WM_HOTKEY: + if ( VK_TBACK == HIWORD(lParam) ) { + SHSendBackToFocusWindow( message, wParam, lParam ); + result = TRUE; + } + break; +#endif case WM_VSCROLL: result = ceDoDlgScroll( globals, hDlg, wParam ); break; diff --git a/wince/cemain.c b/wince/cemain.c index 668fe2065..cbc4e3c06 100755 --- a/wince/cemain.c +++ b/wince/cemain.c @@ -1064,7 +1064,7 @@ doDictsMovedAlert( CEAppGlobals* globals ) stream_putString( stream, "Please be aware that starting with this version " "Crosswords will not find dictionaries unless they " - "are located in one of these directories: " ); + "are located in " ); ceFormatDictDirs( stream, globals->hInst ); stream_putString( stream, ". From now on, dictionaries will be " "available as .cab files which will put them in the " @@ -1239,15 +1239,15 @@ InitInstance(HINSTANCE hInstance, int nCmdShow) /* choose one. If none found it's an error. */ #ifndef STUBBED_DICT - result = 1 == ceLocateNDicts( MPPARM(mpool) hInstance, 1, ceSetDictName, + result = 1 == ceLocateNDicts( MPPARM(mpool) 1, ceSetDictName, globals ); if ( !result ) { XWStreamCtxt* stream = make_generic_stream( globals ); stream_putString( stream, "Please install a Crosswords dictionary " - "in one of these directories: " ); + "in " ); ceFormatDictDirs( stream, hInstance ); stream_putString( stream, ". Download dictionaries from " - "http://xwords.sf.net." ); + "http://xwords.sf.net or http://eehouse.org/xwords." ); messageBoxStream( globals, stream, L"Dictionary Not Found", MB_OK ); stream_destroy( stream ); result = FALSE; @@ -1284,6 +1284,8 @@ InitInstance(HINSTANCE hInstance, int nCmdShow) } } + trapBackspaceKey( hWnd ); + ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); #ifdef _WIN32_WCE @@ -1995,7 +1997,7 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) XP_Bool draw = XP_FALSE; XWTimerReason why; CEAppGlobals* globals; - XP_Bool handled; + XP_Bool handled = XP_FALSE; XP_Bool callDefault = XP_FALSE; if ( message == WM_CREATE ) { @@ -2204,7 +2206,24 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) HIWORD(lParam) ); globals->penDown = XP_FALSE; } - break; + break; + +#ifdef _WIN32_WCE + /* Make the back key mean raise focus, but only if dived. + Otherwise allow the OS to do what it wants. Which means + exit? */ + case WM_HOTKEY: + if ( VK_TBACK == HIWORD(lParam) ) { + if ( !!globals->game.board ) { + draw = board_handleKey( globals->game.board, + XP_RAISEFOCUS_KEY, &handled ); + } + } + if ( !draw || !handled ) { + callDefault = XP_TRUE; + } + break; +#endif #ifdef KEYBOARD_NAV case WM_KEYDOWN: @@ -2798,6 +2817,7 @@ ce_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name, CEAppGlobals* globals = (CEAppGlobals*)uc->closure; XP_MEMSET( &state, 0, sizeof(state) ); + state.globals = globals; state.name = name; state.buf = buf; state.lenp = len; diff --git a/wince/ceprefs.c b/wince/ceprefs.c index d88dee8e6..de3df1a0a 100755 --- a/wince/ceprefs.c +++ b/wince/ceprefs.c @@ -263,6 +263,7 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) adjustForChoice( hDlg, pState ); ceDlgSetup( globals, hDlg ); + trapBackspaceKey( hDlg ); return TRUE; @@ -276,7 +277,14 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case WM_VSCROLL: ceDoDlgScroll( globals, hDlg, wParam ); break; - +#ifdef _WIN32_WCE + case WM_HOTKEY: + if ( VK_TBACK == HIWORD(lParam) ) { + SHSendBackToFocusWindow( message, wParam, lParam ); + return TRUE; + } + break; +#endif case WM_NEXTDLGCTL: ceDoDlgFocusScroll( globals, hDlg, wParam, lParam ); break; diff --git a/wince/cesvdgms.c b/wince/cesvdgms.c index 740fc71d6..55a33653a 100644 --- a/wince/cesvdgms.c +++ b/wince/cesvdgms.c @@ -20,11 +20,13 @@ #include #include "stdafx.h" #include +#include #include "cemain.h" #include "cesvdgms.h" #include "ceutil.h" #include "cedebug.h" +#include "debhacks.h" typedef struct CeSaveGameNameState { CEAppGlobals* globals; @@ -82,6 +84,7 @@ SaveNameDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) state->inited = XP_FALSE; ceDlgSetup( state->globals, hDlg ); + trapBackspaceKey( hDlg ); result = TRUE; } else { @@ -93,6 +96,14 @@ SaveNameDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) } switch (message) { +#ifdef _WIN32_WCE + case WM_HOTKEY: + if ( VK_TBACK == HIWORD(lParam) ) { + SHSendBackToFocusWindow( message, wParam, lParam ); + result = TRUE; + } + break; +#endif case WM_COMMAND: wid = LOWORD(wParam); switch( wid ) { diff --git a/wince/ceutil.c b/wince/ceutil.c index ac7dbf25a..1f593680a 100755 --- a/wince/ceutil.c +++ b/wince/ceutil.c @@ -23,6 +23,7 @@ #include "ceutil.h" #include "cedefines.h" #include "cedebug.h" +#include "debhacks.h" #define BUF_SIZE 128 #define VPADDING 4 @@ -119,8 +120,10 @@ ceGetDlgItemNum( HWND hDlg, XP_U16 id ) void ce_selectAndShow( HWND hDlg, XP_U16 resID, XP_U16 index ) { - SendDlgItemMessage( hDlg, resID, LB_SETCURSEL, index, 0 ); + SendDlgItemMessage( hDlg, resID, SETCURSEL, index, 0 ); +#ifdef _WIN32_WCE SendDlgItemMessage( hDlg, resID, LB_SETANCHORINDEX, index, 0 ); +#endif } /* ce_selectAndShow */ void @@ -670,3 +673,14 @@ ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 newId ) #endif } } /* ceSetLeftSoftkey */ + +#ifdef _WIN32_WCE +void +trapBackspaceKey( HWND hDlg ) +{ + /* Override back key so we can pass it to edit controls */ + SendMessage( SHFindMenuBar(hDlg), SHCMBM_OVERRIDEKEY, VK_TBACK, + MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY, + SHMBOF_NODEFAULT | SHMBOF_NOTIFY)); +} +#endif diff --git a/wince/ceutil.h b/wince/ceutil.h index 8cbb8af6f..9081a18f0 100755 --- a/wince/ceutil.h +++ b/wince/ceutil.h @@ -55,8 +55,11 @@ void ceDoDlgFocusScroll( CEAppGlobals* globals, HWND hDlg, WPARAM wParam, LPARAM lParam ); #ifdef _WIN32_WCE void ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd ); +void trapBackspaceKey( HWND hDlg ); #else # define ceSizeIfFullscreen( globals, hWnd ) +# define trapBackspaceKey( hDlg ) #endif + #endif diff --git a/wince/debhacks.h b/wince/debhacks.h index 1e9327252..1e162eb83 100644 --- a/wince/debhacks.h +++ b/wince/debhacks.h @@ -67,6 +67,18 @@ BOOL DH(ResetEvent)(HANDLE); #endif /* USE_RAW_MINGW */ + +#ifdef _WIN32_WCE +/* from http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1733046&SiteID=1 */ +# define SHMBOF_NODEFAULT 0x00000001 // do not do default handling of this key +# define SHMBOF_NOTIFY 0x00000002 // send us the WM_* messages for this key +# define SHCMBM_OVERRIDEKEY (WM_USER + 403) + + +# define VK_TBACK VK_ESCAPE +#endif + + #if 0 /* http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1591512&SiteID=1 */ #define IM_SPELL 0 diff --git a/wince/resource.h b/wince/resource.h index 700a9d455..0804a46e2 100755 --- a/wince/resource.h +++ b/wince/resource.h @@ -81,7 +81,6 @@ #define IDC_PICKMSG 1053 #ifdef FEATURE_TRAY_EDIT # define IDC_CPICK 1054 -# define IDC_PICKALL 1055 # define IDC_BACKUP 1056 #endif #ifdef XWFEATURE_SEARCHLIMIT @@ -171,6 +170,7 @@ #define IDC_NPLAYERSUPDOWN 1115 #define IDC_PHONIESUPDOWN 1116 #define IDC_SVGM_UPDOWN 1117 +#define IDC_ASKBLANK_UPDOWN 1124 #define IDC_SVGM_SELLAB 1118 @@ -231,17 +231,13 @@ #define IDS_OK 40005 #define IDS_ABOUT 40006 -// Don't use the numbers after 4009: one string needs not to be there -// to stop the progression in cedict.c -#define IDS_DICTDIRS 40009 - // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 125 #define _APS_NEXT_COMMAND_VALUE 40029 -#define _APS_NEXT_CONTROL_VALUE 1124 +#define _APS_NEXT_CONTROL_VALUE 1125 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/wince/xwords4.rc b/wince/xwords4.rc index a70947563..ab243ae4e 100755 --- a/wince/xwords4.rc +++ b/wince/xwords4.rc @@ -343,23 +343,33 @@ BEGIN #endif END -IDD_ASKBLANK DIALOG DISCARDABLE 0, 0, 131, 90 +IDD_ASKBLANK DIALOG DISCARDABLE 0, 0, 80, 90 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER CAPTION "Tile picker" FONT 8, "System" BEGIN - DEFPUSHBUTTON "OK",IDOK,70,70,20,14 - LTEXT "Enter a letter for this blank tile.",IDC_BPICK,8,8,63,18 + LTEXT "Enter a letter for this blank tile.",IDC_BPICK,8,8,50,18 #ifdef FEATURE_TRAY_EDIT - PUSHBUTTON "Pick all!",IDC_PICKALL,8,70,39,14 - PUSHBUTTON "Del",IDC_BACKUP,48,70,18,14 - LTEXT "Pick a tile for your tray.",IDC_CPICK,8,8,63,18 + LTEXT "Pick a tile for your tray.",IDC_CPICK,8,8,50,18 + PUSHBUTTON "Put back",IDC_BACKUP,8,70,28,14 EDITTEXT IDC_PICKMSG,8,28,80,30,ES_MULTILINE | ES_READONLY - #endif - LISTBOX BLANKFACE_LIST,100,5,25,83,LBS_NOINTEGRALHEIGHT | - WS_VSCROLL | WS_TABSTOP + +#ifdef _WIN32_WCE + LISTBOX BLANKFACE_LIST,65,8,25,12,WS_TABSTOP + CONTROL "", IDC_ASKBLANK_UPDOWN, UPDOWN_CLASS, + UDS_AUTOBUDDY | UDS_HORZ | UDS_ALIGNRIGHT | UDS_WRAP | + UDS_SETBUDDYINT | UDS_EXPANDABLE | UDS_NOSCROLL, + 0, 0, 0, 0 +#else + COMBOBOX BLANKFACE_LIST,60,5,25,12, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + DEFPUSHBUTTON "OK",IDOK,70,70,REPOS_BUTTON_WIDTH, BUTTON_HT + PUSHBUTTON "Cancel",IDCANCEL,20,70,REPOS_BUTTON_WIDTH, BUTTON_HT +#endif + END #define SVGN_LEFT_COL 2 @@ -843,19 +853,12 @@ BEGIN IDS_DUMMY "--" IDS_CANCEL "Cancel" IDS_OK "Ok" - IDS_ABOUT "Crosswords 4.2b2 (rev " SVN_REV ") "\ + IDS_ABOUT "Crosswords 4.2b3 (rev " SVN_REV ") "\ "for PocketPC. Copyright 1998-2008 by "\ "Eric House. This software is released under the GNU "\ "Public License.\r\r"\ "For dictionaries, a manual, or source code go to "\ "http://xwords.sf.net or http://eehouse.org/xwords/." -#ifdef _WIN32_WCE - IDS_DICTDIRS "\\Program Files\\Crosswords" - IDS_DICTDIRS+1 "\\SD Card\\Crosswords" - IDS_DICTDIRS+2 "\\Storage Card\\Crosswords" -#else - IDS_DICTDIRS "." -#endif END #endif // English (U.S.) resources