diff --git a/xwords4/wince/ceblank.c b/xwords4/wince/ceblank.c index 2e0367d44..fcd62b239 100755 --- a/xwords4/wince/ceblank.c +++ b/xwords4/wince/ceblank.c @@ -103,6 +103,8 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) && bState->pi->thisPick > 0 ); #endif + ceDlgSetup( bState->globals, hDlg, XP_TRUE ); + loadLettersList( hDlg, bState ); } else { bState = (BlankDialogState*)GetWindowLong( hDlg, GWL_USERDATA ); diff --git a/xwords4/wince/ceclrsel.c b/xwords4/wince/ceclrsel.c index 02b45910a..b64edcbda 100644 --- a/xwords4/wince/ceclrsel.c +++ b/xwords4/wince/ceclrsel.c @@ -150,7 +150,7 @@ EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) eState->cancelled = XP_TRUE; eState->inited = XP_FALSE; - ceStackButtonsRight( eState->globals, hDlg ); + ceDlgSetup( eState->globals, hDlg, XP_FALSE ); wchar_t label[32]; XP_U16 len = SendDlgItemMessage( eState->parent, eState->labelID, @@ -180,6 +180,12 @@ EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) switch (message) { + case WM_VSCROLL: + if ( !IS_SMARTPHONE(eState->globals) ) { + ceDoDlgScroll( eState->globals, hDlg, wParam ); + } + break; + case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint( hDlg, &ps ); @@ -395,7 +401,7 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) cState->cancelled = XP_TRUE; cState->inited = XP_FALSE; - ceStackButtonsRight( cState->globals, hDlg ); + ceDlgSetup( cState->globals, hDlg, XP_TRUE ); result = TRUE; } else { @@ -412,12 +418,24 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) switch (message) { + case WM_VSCROLL: + if ( !IS_SMARTPHONE(cState->globals) ) { + ceDoDlgScroll( cState->globals, hDlg, wParam ); + } + break; + case WM_DRAWITEM: /* passed when button has BS_OWNERDRAW style */ + if ( !IS_SMARTPHONE(cState->globals) ) { + ceDoDlgFocusScroll( cState->globals, hDlg ); + } ceDrawColorButton( cState, (DRAWITEMSTRUCT*)lParam ); result = TRUE; break; case WM_COMMAND: + if ( !IS_SMARTPHONE(cState->globals) ) { + ceDoDlgFocusScroll( cState->globals, hDlg ); + } wid = LOWORD(wParam); switch( wid ) { diff --git a/xwords4/wince/cecondlg.c b/xwords4/wince/cecondlg.c index de97c4486..51d14346c 100755 --- a/xwords4/wince/cecondlg.c +++ b/xwords4/wince/cecondlg.c @@ -178,7 +178,7 @@ ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) ceControlsFromAddrRec( hDlg, cState ); - ceStackButtonsRight( globals, hDlg ); + ceDlgSetup( globals, hDlg, XP_FALSE ); result = TRUE; } else { @@ -209,6 +209,10 @@ ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) cState->userCancelled = id == IDCANCEL; result = TRUE; } + } else if ( message == WM_VSCROLL ) { + if ( !IS_SMARTPHONE(globals) ) { + ceDoDlgScroll( globals, hDlg, wParam ); + } } } } diff --git a/xwords4/wince/ceginfo.c b/xwords4/wince/ceginfo.c index ae9081f95..ec8a80ddc 100755 --- a/xwords4/wince/ceginfo.c +++ b/xwords4/wince/ceginfo.c @@ -489,13 +489,15 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) XP_U16 id; GameInfoState* giState; +/* XP_LOGF( "%s: %s(%d)", __func__, messageToStr( message ), message ); */ + if ( message == WM_INITDIALOG ) { SetWindowLong( hDlg, GWL_USERDATA, lParam ); giState = (GameInfoState*)lParam; giState->hDlg = hDlg; globals = giState->globals; - ceStackButtonsRight( globals, hDlg ); + ceDlgSetup( globals, hDlg, XP_TRUE ); giState->newGameCtx = newg_make( MPPARM(globals->mpool) giState->isNewGame, @@ -523,6 +525,19 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) switch (message) { + case WM_VSCROLL: + if ( !IS_SMARTPHONE(globals) ) { + ceDoDlgScroll( globals, hDlg, wParam ); + } + break; + + /* WM_NEXTDLGCTL is worthless; prev obj still has focus */ +/* case WM_NEXTDLGCTL: */ +/* if ( !IS_SMARTPHONE(globals) ) { */ +/* ceDoDlgFocusScroll( globals, hDlg, wParam, lParam ); */ +/* } */ +/* break; */ + #ifdef OWNERDRAW_JUGGLE case WM_DRAWITEM: /* for BS_OWNERDRAW style */ ceDrawIconButton( globals, (DRAWITEMSTRUCT*)lParam ); @@ -530,6 +545,9 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) #endif case WM_COMMAND: + if ( !IS_SMARTPHONE(globals) ) { + ceDoDlgFocusScroll( globals, hDlg ); + } id = LOWORD(wParam); switch( id ) { diff --git a/xwords4/wince/cehntlim.c b/xwords4/wince/cehntlim.c index 434aff862..4a776f1ba 100755 --- a/xwords4/wince/cehntlim.c +++ b/xwords4/wince/cehntlim.c @@ -63,7 +63,7 @@ HintLimitsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) hState = (HintLimitsState*)lParam; globals = hState->globals; - ceStackButtonsRight( globals, hDlg ); + ceDlgSetup( globals, hDlg, XP_FALSE ); return TRUE; } else { diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index 9788867dc..e3a424b30 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -49,21 +49,12 @@ #include "cedebug.h" #include "LocalizedStrIncludes.h" #include "debhacks.h" +#include "cesvdgms.h" #include "dbgutil.h" #define MAX_LOADSTRING 100 -#ifdef _WIN32_WCE -# define DEFAULT_DIR_NAME L"\\My Documents\\Crosswords" -# define PREFSFILENAME L"\\My Documents\\Crosswords\\xwprefs" -# define UNSAVEDGAMEFILENAME "\\My Documents\\Crosswords\\_newgame" -#else -# define DEFAULT_DIR_NAME L"." -# define PREFSFILENAME L".\\xwprefs" -# define UNSAVEDGAMEFILENAME ".\\_newgame" -#endif - #define SCROLLBAR_WIDTH 12 #define SCROLLBARID 0x4321 /* needs to be unique! */ @@ -145,8 +136,6 @@ static void ce_util_engineStarting( XW_UtilCtxt* uc ); static void ce_util_engineStopping( XW_UtilCtxt* uc ); #endif -static int messageBoxChar( CEAppGlobals* globals, XP_UCHAR* str, - wchar_t* title, XP_U16 buttons ); static XP_Bool queryBoxChar( CEAppGlobals* globals, XP_UCHAR* msg ); static XP_Bool ceMsgFromStream( CEAppGlobals* globals, XWStreamCtxt* stream, @@ -882,14 +871,12 @@ ceLoadPrefs( CEAppGlobals* globals ) XP_U32 bytesRead; if ( ReadFile( fileH, &tmpPrefs, sizeof(tmpPrefs), &bytesRead, NULL ) ) { - - XP_ASSERT( tmpPrefs.versionFlags == CUR_CE_PREFS_FLAGS ) { - - result = XP_TRUE; - } + XP_ASSERT( tmpPrefs.versionFlags == CUR_CE_PREFS_FLAGS ); + result = XP_TRUE; } } - } else if ( canUpdatePrefs( globals, fileH, curVersion, &tmpPrefs ) ) { + } else if ( canUpdatePrefs( globals, fileH, curVersion, + &tmpPrefs ) ) { result = XP_TRUE; } else { XP_LOGF( "%s: old prefs; cannot read.", __func__ ); @@ -1157,7 +1144,6 @@ InitInstance(HINSTANCE hInstance, int nCmdShow) XP_Bool oldGameLoaded; XP_Bool prevStateExists; XP_Bool newDone = XP_FALSE; - XP_U16 len; MPSLOT; #ifdef XWFEATURE_RELAY @@ -1206,11 +1192,6 @@ InitInstance(HINSTANCE hInstance, int nCmdShow) globals->vtMgr = make_vtablemgr( MPPARM_NOCOMMA(mpool) ); - len = wcslen( DEFAULT_DIR_NAME ); - len = (len + 1) * sizeof(globals->lastDefaultDir[0]); - globals->lastDefaultDir = XP_MALLOC( mpool, len ); - XP_MEMCPY( globals->lastDefaultDir, DEFAULT_DIR_NAME, len ); - globals->hInst = hInstance; // Initialize global strings MyRegisterClass(hInstance, szWindowClass); @@ -1498,23 +1479,8 @@ static void ceChooseAndOpen( CEAppGlobals* globals ) { wchar_t path[256]; - OPENFILENAME openFileStruct; - - XP_MEMSET( &openFileStruct, 0, sizeof(openFileStruct) ); - XP_MEMSET( path, 0, sizeof(path) ); - - openFileStruct.lStructSize = sizeof(openFileStruct); - openFileStruct.hwndOwner = globals->hWnd; - openFileStruct.lpstrFilter = L"Crosswords games" L"\0" - L"*.xwg" L"\0\0"; - openFileStruct.Flags = OFN_FILEMUSTEXIST - | OFN_HIDEREADONLY - | OFN_PATHMUSTEXIST; - - openFileStruct.lpstrFile = path; - openFileStruct.nMaxFile = VSIZE(path); - - if ( GetOpenFileName( &openFileStruct ) ) { + path[0] = 0; + if ( ceSavedGamesDlg( globals, globals->curGameName, path, VSIZE(path) ) ) { XP_UCHAR* name; XP_U16 len; @@ -1627,25 +1593,6 @@ isDefaultName( XP_UCHAR* name ) return 0 == XP_STRCMP( UNSAVEDGAMEFILENAME, name ); } /* isDefaultName */ -static void -makeUniqueName( wchar_t* buf, XP_U16 XP_UNUSED_DBG(bufLen) ) -{ - XP_U16 i; - DWORD attributes; - - for ( i = 1; i < 100; ++i ) { - swprintf( buf, DEFAULT_DIR_NAME L"\\Untitled%d.xwg", i ); - XP_ASSERT( wcslen(buf) < bufLen ); - - attributes = GetFileAttributes( buf ); - if ( attributes == 0xFFFFFFFF ) { - break; - } - } - /* If we fall out of the loop, the user will be asked to confirm delete - of Untitled99 or somesuch. That's ok.... */ -} /* makeUniqueName */ - static XP_Bool ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave ) { @@ -1657,7 +1604,6 @@ ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave ) involved. */ XP_UCHAR* name = globals->curGameName; if ( name == NULL || isDefaultName(name) ) { - wchar_t nameBuf[256]; XP_UCHAR* newName = NULL; if ( autoSave ) { @@ -1667,45 +1613,15 @@ ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave ) confirmed = XP_TRUE; } else { + wchar_t nameBuf[256]; - OPENFILENAME sfs; - - XP_MEMSET( &sfs, 0, sizeof(sfs) ); - XP_MEMSET( nameBuf, 0, sizeof(nameBuf) ); - - makeUniqueName( nameBuf, VSIZE(nameBuf) ); - - sfs.lStructSize = sizeof(sfs); - sfs.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; - sfs.hwndOwner = globals->hWnd; - sfs.lpstrFile = nameBuf; - sfs.nMaxFile = VSIZE(nameBuf); - - sfs.lpstrDefExt = L"xwg"; - - // sfs.lpstrTitle didn't work in earlier PPC OSes, but does now - sfs.lpstrTitle = L"Save current game as"; - // sfs.lpstrInitialDir: doesn't either - - confirmed = GetSaveFileName( &sfs ); - + confirmed = ceConfirmUniqueName( globals, nameBuf, VSIZE(nameBuf) ); if ( confirmed ) { XP_U16 len = wcslen(nameBuf); XP_DEBUGF( "len(nameBuf) = %d", len ); newName = XP_MALLOC( globals->mpool, len + 1 ); WideCharToMultiByte( CP_ACP, 0, nameBuf, len + 1, newName, len + 1, NULL, NULL ); - - /* If user picked from a different directory, remember it - as the new starting point. */ - nameBuf[sfs.nFileOffset] = 0; - if ( wcscmp( nameBuf, globals->lastDefaultDir ) != 0 ) { - XP_FREE( globals->mpool, globals->lastDefaultDir ); - globals->lastDefaultDir = - XP_MALLOC( globals->mpool, - (sfs.nFileOffset + 1) * 2 ); - wcscpy( globals->lastDefaultDir, nameBuf ); - } } } @@ -1716,7 +1632,6 @@ ceSaveCurGame( CEAppGlobals* globals, XP_Bool autoSave ) } globals->curGameName = newName; } - } else { confirmed = XP_TRUE; } @@ -1792,10 +1707,6 @@ freeGlobals( CEAppGlobals* globals ) XP_FREE( mpool, globals->util.vtable ); } - if ( !!globals->lastDefaultDir ) { - XP_FREE( mpool, globals->lastDefaultDir ); - } - XP_FREE( globals->mpool, globals ); mpool_destroy( mpool ); @@ -2413,7 +2324,7 @@ ceMsgFromStream( CEAppGlobals* globals, XWStreamCtxt* stream, return saidYes; } /* ceMsgFromStream */ -static int +int messageBoxChar( CEAppGlobals* globals, XP_UCHAR* str, wchar_t* title, XP_U16 buttons ) { @@ -2780,7 +2691,6 @@ ce_util_userError( XW_UtilCtxt* uc, UtilErrID id ) } messageBoxChar( globals, message, L"Oops!", MB_OK ); - } /* ce_util_userError */ static XP_Bool diff --git a/xwords4/wince/cemain.h b/xwords4/wince/cemain.h index 2e1eb240b..0cc4fdb82 100755 --- a/xwords4/wince/cemain.h +++ b/xwords4/wince/cemain.h @@ -120,7 +120,6 @@ typedef struct CEAppGlobals { XW_UtilCtxt util; VTableMgr* vtMgr; XP_U16* bonusInfo; - wchar_t* lastDefaultDir; XP_U32 timerIDs[NUM_TIMERS_PLUS_ONE]; XWTimerProc timerProcs[NUM_TIMERS_PLUS_ONE]; @@ -205,6 +204,8 @@ typedef struct 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 ); #ifdef DEBUG void logLastError( const char* comment ); @@ -218,10 +219,14 @@ void messageToBuf( UINT message, char* buf, int bufSize ); # define SETCURSEL LB_SETCURSEL # define GETCURSEL LB_GETCURSEL # define ADDSTRING LB_ADDSTRING +# define GETLBTEXTLEN LB_GETTEXTLEN +# define GETLBTEXT LB_GETTEXT #else # define SETCURSEL CB_SETCURSEL # define GETCURSEL CB_GETCURSEL # define ADDSTRING CB_ADDSTRING +# define GETLBTEXTLEN CB_GETLBTEXTLEN +# define GETLBTEXT CB_GETLBTEXT #endif #endif /* _CEMAIN_H_ */ diff --git a/xwords4/wince/ceprefs.c b/xwords4/wince/ceprefs.c index 0ac6c4005..464b8b59b 100755 --- a/xwords4/wince/ceprefs.c +++ b/xwords4/wince/ceprefs.c @@ -24,6 +24,7 @@ #include "ceclrsel.h" #include "ceutil.h" #include "debhacks.h" +#include "cedebug.h" /* Stuff the strings for phonies. Why can't I put this in the resource? */ @@ -259,7 +260,7 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) loadControlsFromState( hDlg, pState ); adjustForChoice( hDlg, pState ); - ceStackButtonsRight( globals, hDlg ); + ceDlgSetup( globals, hDlg, XP_TRUE ); return TRUE; @@ -270,7 +271,15 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) globals = pState->globals; switch (message) { + case WM_VSCROLL: + if ( !IS_SMARTPHONE(globals) ) { + ceDoDlgScroll( globals, hDlg, wParam ); + } + break; case WM_COMMAND: + if ( !IS_SMARTPHONE(globals) ) { + ceDoDlgFocusScroll( globals, hDlg ); + } id = LOWORD(wParam); switch( id ) { diff --git a/xwords4/wince/cestrbx.c b/xwords4/wince/cestrbx.c index 9811a08a6..45db69fe3 100755 --- a/xwords4/wince/cestrbx.c +++ b/xwords4/wince/cestrbx.c @@ -79,7 +79,7 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) } } - ceStackButtonsRight( globals, hDlg ); + ceDlgSetup( globals, hDlg, XP_TRUE ); handled = TRUE; } else { @@ -88,6 +88,13 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) if ( !!init ) { switch (message) { + + case WM_VSCROLL: + if ( !IS_SMARTPHONE(globals) ) { + ceDoDlgScroll( globals, hDlg, wParam ); + } + break; + case WM_COMMAND: /* If I add the text above in the WM_INITDIALOG section it