diff --git a/wince/cemain.c b/wince/cemain.c index 30ede0600..48f544acc 100755 --- a/wince/cemain.c +++ b/wince/cemain.c @@ -320,36 +320,6 @@ MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass) return RegisterClass(&wc); } -#ifdef _WIN32_WCE -static void -addButtonsToCmdBar( CEAppGlobals* globals ) -{ - XP_Bool success; - XP_U16 i; - int index; - int cmds[] = { FLIP_BUTTON_ID, VALUE_BUTTON_ID, - HINT_BUTTON_ID, JUGGLE_BUTTON_ID }; - int resIDs[] = { IDB_FLIPBUTTON, IDB_VALUESBUTTON, - IDB_HINTBUTTON, IDB_JUGGLEBUTTON }; - - for ( i = 0; i < VSIZE(cmds); ++i ) { - TBBUTTON buttData; - - index = CommandBar_AddBitmap(globals->hwndCB, globals->hInst, - resIDs[i], 1, 16, 16 ); - - XP_MEMSET( &buttData, 0, sizeof(buttData) ); - buttData.fsState = TBSTATE_ENABLED; - buttData.fsStyle = TBSTYLE_BUTTON; - buttData.iBitmap = index; - buttData.idCommand = cmds[i]; - - success = CommandBar_InsertButton( globals->hwndCB, -1, - (LPARAM)&buttData ); - } -} /* addButtonsToCmdBar */ -#endif - static void ceInitUtilFuncs( CEAppGlobals* globals ) { @@ -517,11 +487,11 @@ figureBoardParms( CEAppGlobals* globals, XP_U16 nRows, CEBoardParms* bparms ) GetClientRect( globals->hWnd, &rc ); #ifndef _WIN32_WCE -#if defined FORCE_HEIGHT && defined FORCE_WIDTH +# if defined FORCE_HEIGHT && defined FORCE_WIDTH rc.right = rc.left + FORCE_WIDTH; rc.bottom = rc.top + FORCE_HEIGHT; -#else -#if defined DEBUG +# else +# if defined DEBUG if ( g_dbWidth != 0 ) { rc.right = rc.left + g_dbWidth; @@ -529,9 +499,9 @@ figureBoardParms( CEAppGlobals* globals, XP_U16 nRows, CEBoardParms* bparms ) if ( g_dbHeight != 0 ) { rc.bottom = rc.top + g_dbHeight; } -#endif -#endif -#endif +# endif +# endif +#endif /* #ifndef _WIN32_WCE */ scrnWidth = (XP_U16)(rc.right - rc.left); scrnHeight = (XP_U16)(rc.bottom - rc.top); @@ -1724,9 +1694,12 @@ makeCommandBar( HWND hwnd, HINSTANCE hInst ) mbi.hwndParent = hwnd; mbi.nToolBarId = IDM_MENU; mbi.hInstRes = hInst; + mbi.dwFlags = SHCMBF_HMENU; + //mbi.dwFlags = SHCMBF_HIDESIPBUTTON; /* eeh added. Why??? */ if (!SHCreateMenuBar(&mbi)) { + /* will want to use this to change menubar: SHEnableSoftkey? */ XP_LOGF( "SHCreateMenuBar failed" ); return NULL; } @@ -1826,36 +1799,42 @@ checkPenDown( CEAppGlobals* globals ) #ifdef KEYBOARD_NAV static XP_Bool -ceHandleFocusKey( CEAppGlobals* globals, WPARAM wParam, XP_Bool* handledP ) +ceHandleFocusKey( CEAppGlobals* globals, WPARAM wParam, + XP_Bool isDown, XP_Bool* handledP ) { XP_Bool draw = XP_FALSE; XP_Key key; XP_S16 incr = 0; - XP_LOGF( "%s: 0x%x", __func__, wParam ); + XP_LOGF( "%s(%s): 0x%x", __func__, + isDown?"down":"up", + wParam ); switch ( wParam ) { - /* get constants for these!!! */ - case 0x26: + case VK_UP: key = XP_CURSOR_KEY_UP; incr = -1; break; - case 0x27: + case VK_RIGHT: key = XP_CURSOR_KEY_RIGHT; incr = 1; break; - case 0x28: + case VK_DOWN: key = XP_CURSOR_KEY_DOWN; incr = 1; break; - case 0x25: + case VK_LEFT: key = XP_CURSOR_KEY_LEFT; incr = -1; break; case 0x0d: - key = XP_RETURN_KEY; - XP_LOGF( "XP_RETURN_KEY" ); - break; + case 0x5d: /* center key on WinMo5 Treo (at least) */ + case VK_HOME: +/* if ( !isRepeat ) { */ + key = XP_RETURN_KEY; + XP_LOGF( "%s: XP_RETURN_KEY", __func__ ); + break; +/* } */ /* XP_CURSOR_KEY_ALTRIGHT, */ /* XP_CURSOR_KEY_ALTUP, */ @@ -1869,8 +1848,10 @@ ceHandleFocusKey( CEAppGlobals* globals, WPARAM wParam, XP_Bool* handledP ) if ( key != XP_KEY_NONE ) { BoardCtxt* board = globals->game.board; - draw = board_handleKey( board, key, handledP ); - if ( !*handledP && incr != 0 ) { + draw = isDown? + board_handleKeyDown( board, key, handledP ) : + board_handleKeyUp( board, key, handledP ) ; + if ( !*handledP && incr != 0 && !isDown ) { BoardObjectType order[] = { OBJ_SCORE, OBJ_BOARD, OBJ_TRAY }; BoardObjectType cur = board_getFocusOwner( board ); XP_U16 index = 0; @@ -1885,7 +1866,7 @@ ceHandleFocusKey( CEAppGlobals* globals, WPARAM wParam, XP_Bool* handledP ) } index = (index + 3 + incr) % 3; } - XP_LOGF( "calling board_focusChanged" ); + XP_LOGF( "%s: calling board_focusChanged", __func__ ); draw = board_focusChanged( board, order[index], XP_TRUE ); } } @@ -1894,6 +1875,43 @@ ceHandleFocusKey( CEAppGlobals* globals, WPARAM wParam, XP_Bool* handledP ) } /* ceHandleFocusKey */ #endif /* KEYBOARD_NAV */ +#ifdef _WIN32_WCE +static void +ceToggleFullScreen( CEAppGlobals* globals ) +{ + RECT rect; + XP_U16 cbHeight = 0; + + if ( !!globals->hwndCB ) { + GetWindowRect( globals->hwndCB, &rect ); + cbHeight = rect.bottom - rect.top; + } + + /* I'm leaving the SIP/cmdbar in place until I can figure out how to get + menu events with it hidden -- and also the UI for making sure users + don't get stuck in fullscreen mode not knowing how to reach menus to + get out. Later, add SHFS_SHOWSIPBUTTON and SHFS_HIDESIPBUTTON to the + sets shown and hidden below.*/ + if ( globals->fullScreen ) { + SHFullScreen( globals->hWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON ); + + SystemParametersInfo( SPI_GETWORKAREA, 0, &rect, FALSE ); + } else { + SHFullScreen( globals->hWnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON ); + + SetRect( &rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), + GetSystemMetrics(SM_CYSCREEN) ); + } + + rect.bottom -= cbHeight; + MoveWindow( globals->hWnd, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE ); + + globals->fullScreen = !globals->fullScreen; + (void)cePositionBoard( globals ); +} /* ceToggleFullScreen */ +#endif + LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -1909,7 +1927,6 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) SetWindowLong( hWnd, GWL_USERDATA, (long)globals ); #ifdef _WIN32_WCE globals->hwndCB = makeCommandBar( hWnd, globals->hInst ); - addButtonsToCmdBar( globals ); #endif #ifdef _WIN32_WCE @@ -1925,18 +1942,16 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) // Notify shell of our activate message SHHandleWMActivate( hWnd, wParam, lParam, &globals->sai, FALSE ); break; -#endif case WM_SETTINGCHANGE: -#ifdef _WIN32_WCE SHHandleWMSettingChange( hWnd, wParam, lParam, &globals->sai ); -#endif if ( !!globals && !!globals->game.model ) { cePositionBoard( globals ); board_invalAll( globals->game.board ); draw = XP_TRUE; } break; +#endif #ifdef CEFEATURE_CANSCROLL case WM_VSCROLL: @@ -1991,7 +2006,11 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case ID_FILE_PREFERENCES: ceDoPrefsDlg( globals ); break; - +#ifdef _WIN32_WCE + case ID_FILE_FULLSCREEN: + ceToggleFullScreen( globals ); + break; +#endif case ID_GAME_FINALSCORES: if ( server_getGameIsOver( globals->game.server ) ) { ceDisplayFinalScores( globals ); @@ -2019,7 +2038,6 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) draw = handleTradeCmd( globals ); break; case ID_MOVE_JUGGLE: - case JUGGLE_BUTTON_ID: draw = handleJuggleCmd( globals ); break; @@ -2031,10 +2049,9 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; case ID_MOVE_FLIP: - case FLIP_BUTTON_ID: draw = board_flip( globals->game.board ); break; - case VALUE_BUTTON_ID: + case ID_MOVE_VALUES: draw = board_toggle_showValues( globals->game.board ); break; @@ -2046,7 +2063,6 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) board_resetEngine( globals->game.board ); /* fallthru */ case ID_MOVE_NEXTHINT: - case HINT_BUTTON_ID: draw = ceHandleHintRequest( globals ); break; @@ -2112,9 +2128,11 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; #ifdef KEYBOARD_NAV -/* case WM_KEYDOWN: */ + case WM_KEYDOWN: + draw = ceHandleFocusKey( globals, wParam, XP_TRUE, &handled ); + break; case WM_KEYUP: - draw = ceHandleFocusKey( globals, wParam, &handled ); + draw = ceHandleFocusKey( globals, wParam, XP_FALSE, &handled ); break; #endif case WM_CHAR: diff --git a/wince/cemain.h b/wince/cemain.h index e409c7531..06e26ebb5 100755 --- a/wince/cemain.h +++ b/wince/cemain.h @@ -72,6 +72,8 @@ typedef struct CEAppGlobals { #ifdef _WIN32_WCE SHACTIVATEINFO sai; + XP_Bool fullScreen; /* this probably wants to be a preference, + i.e. preserved */ #endif DrawCtx* draw; diff --git a/wince/debhacks.h b/wince/debhacks.h index abb1fb637..070916a44 100644 --- a/wince/debhacks.h +++ b/wince/debhacks.h @@ -49,4 +49,18 @@ BOOL DH(ResetEvent)(HANDLE); #endif +/* these are apparently defined in aygshell.h. I got the values by googling + for 'define SHFS_SHOWTASKBAR' etc. They should eventually move into the + mingw project's headers .*/ + +#define SHFS_SHOWTASKBAR 0x0001 +#define SHFS_HIDETASKBAR 0x0002 +#define SHFS_SHOWSIPBUTTON 0x0004 +#define SHFS_HIDESIPBUTTON 0x0008 +#define SHFS_SHOWSTARTICON 0x0010 +#define SHFS_HIDESTARTICON 0x0020 + +/* got this somewhere else via google */ +#define SHCMBF_HMENU 0x0010 + #endif diff --git a/wince/resource.h b/wince/resource.h index 037de251f..6016bc78d 100755 --- a/wince/resource.h +++ b/wince/resource.h @@ -17,10 +17,6 @@ #define IDD_OPTIONSDLG 117 #define IDD_COLORSDLG 118 #define IDD_COLOREDITDLG 119 -#define IDB_FLIPBUTTON 120 -#define IDB_VALUESBUTTON 121 -#define IDB_HINTBUTTON 122 -#define IDB_JUGGLEBUTTON 123 #define IDB_ORIGIN 124 #ifdef XWFEATURE_SEARCHLIMIT # define IDD_ASKHINTLIMTS 125 @@ -29,11 +25,6 @@ # define IDD_CONNSSDLG 126 #endif -#define FLIP_BUTTON_ID 1001 -#define VALUE_BUTTON_ID 1002 -#define HINT_BUTTON_ID 1003 -#define JUGGLE_BUTTON_ID 1004 - #define REMOTE_CHECK1 1005 #define NAME_EDIT1 1006 #define ROBOT_CHECK1 1007 @@ -178,12 +169,14 @@ #define ID_MOVE_JUGGLE 40016 #define ID_MOVE_HIDETRAY 40017 #define ID_MOVE_TURNDONE 40018 -#define ID_MOVE_FLIP 40019 +#define ID_MOVE_FLIP 40019 +#define ID_MOVE_VALUES 40027 #define ID_FILE_NEWGAME 40020 #define ID_FILE_SAVEDGAMES 40021 #define ID_EDITTEXT 40022 #define ID_FILE_PREFERENCES 40023 #define ID_GAME_RESENDMSGS 40025 +#define ID_FILE_FULLSCREEN 40026 #define ID_COLORS_RES 9999 #define ID_BONUS_RES 9998 @@ -192,6 +185,7 @@ #define IDS_FILE 40002 #define IDS_GAME 40003 #define IDS_MOVE 40004 +#define IDS_MENU 40006 // Don't use the numbers after 4005: one string needs not to be there // to stop the progression in cedict.c #define IDS_DICTDIRS 40005 @@ -201,7 +195,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 125 -#define _APS_NEXT_COMMAND_VALUE 40026 +#define _APS_NEXT_COMMAND_VALUE 40028 #define _APS_NEXT_CONTROL_VALUE 1087 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/wince/xwords4.rc b/wince/xwords4.rc index 635113301..b9b2aac91 100755 --- a/wince/xwords4.rc +++ b/wince/xwords4.rc @@ -66,68 +66,57 @@ END // Menubar // -#ifdef _WIN32_WCE -IDM_MENU RCDATA -BEGIN - IDM_MENU, 3, - - I_IMAGENONE, 65001, TBSTATE_ENABLED, - TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_FILE, 0, 0, - - I_IMAGENONE, 65002, TBSTATE_ENABLED, - TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_GAME, 0, 1, - - I_IMAGENONE, 65003, TBSTATE_ENABLED, - TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, - IDS_MOVE, 0, 2 - -END -#endif - IDM_MENU MENU DISCARDABLE BEGIN - POPUP "&File" + POPUP "Menu" BEGIN - MENUITEM "&New game", ID_FILE_NEWGAME - MENUITEM "Open &saved game", ID_FILE_SAVEDGAMES - MENUITEM "&Preferences", ID_FILE_PREFERENCES - MENUITEM SEPARATOR - MENUITEM "&About", ID_FILE_ABOUT - MENUITEM SEPARATOR - MENUITEM "E&xit", IDM_FILE_EXIT - END - POPUP "&Game" - BEGIN - MENUITEM "Tile counts and values", ID_GAME_TILECOUNTSANDVALUES - MENUITEM "Tiles left", ID_GAME_TILESLEFT - MENUITEM SEPARATOR - MENUITEM "Game info", ID_GAME_GAMEINFO - MENUITEM "History", ID_GAME_HISTORY - MENUITEM "Final scores", ID_GAME_FINALSCORES -#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH - MENUITEM SEPARATOR - MENUITEM "Resend messages", ID_GAME_RESENDMSGS -#endif - END - POPUP "&Move" - BEGIN - MENUITEM "H&int", ID_MOVE_HINT -#ifdef XWFEATURE_SEARCHLIMIT - MENUITEM "Limited hint (&c)", ID_MOVE_LIMITEDHINT - MENUITEM SEPARATOR -#endif - MENUITEM "Next hint (&m)", ID_MOVE_NEXTHINT - MENUITEM SEPARATOR - MENUITEM "&Undo current", ID_MOVE_UNDOCURRENT - MENUITEM "Undo last (&z)", ID_MOVE_UNDOLAST - MENUITEM SEPARATOR MENUITEM "Turn &done", ID_MOVE_TURNDONE MENUITEM "&Juggle", ID_MOVE_JUGGLE - MENUITEM "&Flip", ID_MOVE_FLIP + MENUITEM "Fli&p", ID_MOVE_FLIP MENUITEM "&Trade", ID_MOVE_TRADE MENUITEM "(un)&Hide tray", ID_MOVE_HIDETRAY + MENUITEM "Tile &values", ID_MOVE_VALUES + + POPUP "&Undo" + BEGIN + MENUITEM "Undo current", ID_MOVE_UNDOCURRENT + MENUITEM "Undo last (&z)", ID_MOVE_UNDOLAST + END + + POPUP "Hint" + BEGIN + MENUITEM "H&int", ID_MOVE_HINT +#ifdef XWFEATURE_SEARCHLIMIT + MENUITEM "Limited hint (&c)", ID_MOVE_LIMITEDHINT +#endif + MENUITEM "Next hint (&m)", ID_MOVE_NEXTHINT + END + + POPUP "&File" + BEGIN + MENUITEM "Fu&ll screen", ID_FILE_FULLSCREEN + MENUITEM SEPARATOR + MENUITEM "&New game", ID_FILE_NEWGAME + MENUITEM "Open &saved game", ID_FILE_SAVEDGAMES + MENUITEM "P&references", ID_FILE_PREFERENCES + MENUITEM SEPARATOR + MENUITEM "&About", ID_FILE_ABOUT + MENUITEM SEPARATOR + MENUITEM "E&xit", IDM_FILE_EXIT + END + + POPUP "&Game" + BEGIN + MENUITEM "Tile counts and values", ID_GAME_TILECOUNTSANDVALUES + MENUITEM "Tiles left", ID_GAME_TILESLEFT + MENUITEM SEPARATOR + MENUITEM "Game info", ID_GAME_GAMEINFO + MENUITEM "History", ID_GAME_HISTORY + MENUITEM "Final sc&ores", ID_GAME_FINALSCORES +#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH + MENUITEM "Resend messages", ID_GAME_RESENDMSGS +#endif + END END END @@ -676,10 +665,6 @@ END IDB_RIGHTARROW BITMAP DISCARDABLE "bmps/rightarrow.bmp" IDB_DOWNARROW BITMAP DISCARDABLE "bmps/downarro.bmp" -IDB_FLIPBUTTON BITMAP DISCARDABLE "bmps/flip.bmp" -IDB_VALUESBUTTON BITMAP DISCARDABLE "bmps/values.bmp" -IDB_HINTBUTTON BITMAP DISCARDABLE "bmps/hint.bmp" -IDB_JUGGLEBUTTON BITMAP DISCARDABLE "bmps/juggle.bmp" IDB_ORIGIN BITMAP DISCARDABLE "bmps/origin.bmp" /////////////////////////////////////////////////////////////////////////////