From 1384be68957a5bc4f6b981fe38387b567fb82d97 Mon Sep 17 00:00:00 2001 From: ehouse Date: Wed, 27 Aug 2008 12:38:01 +0000 Subject: [PATCH] Get rid of cute-but-confusing feature whereby the menuitem to which the left softkey is set is removed from the right key's menu. More important is that menu-9-6 always mean "exit". --- xwords4/wince/cemain.h | 7 +----- xwords4/wince/ceutil.c | 50 ++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/xwords4/wince/cemain.h b/xwords4/wince/cemain.h index acb87faac..12a4b6d01 100755 --- a/xwords4/wince/cemain.h +++ b/xwords4/wince/cemain.h @@ -106,12 +106,7 @@ typedef struct CEAppGlobals { XP_U16 dummyPos; #endif - struct { - HMENU oldMenu; /* menu whose item is now on left button */ - XP_U16 oldId; /* id of item now on left button */ - XP_U16 oldPos; /* position of prev item within oldMenu */ - wchar_t oldName[32]; /* name of previous item */ - } softkey; + XP_U16 softKeyId; /* id of item now on left button */ DrawCtx* draw; XWGame game; diff --git a/xwords4/wince/ceutil.c b/xwords4/wince/ceutil.c index a42a35f50..d4790845b 100755 --- a/xwords4/wince/ceutil.c +++ b/xwords4/wince/ceutil.c @@ -579,7 +579,10 @@ ceDoDlgFocusScroll( CeDlgHdr* dlgHdr, HWND nextCtrl ) } /* ceDoDlgFocusScroll */ static XP_Bool -ceFindMenu( HMENU menu, XP_U16 id, HMENU* foundMenu, XP_U16* foundPos, +ceFindMenu( HMENU menu, XP_U16 id, +#ifndef _WIN32_WCE + HMENU* foundMenu, XP_U16* foundPos, +#endif wchar_t* foundBuf, XP_U16 bufLen ) { XP_Bool found = XP_FALSE; @@ -600,14 +603,19 @@ ceFindMenu( HMENU menu, XP_U16 id, HMENU* foundMenu, XP_U16* foundPos, if ( !GetMenuItemInfo( menu, pos, TRUE, &minfo ) ) { break; /* pos is too big */ } else if ( NULL != minfo.hSubMenu ) { - found = ceFindMenu( minfo.hSubMenu, id, foundMenu, foundPos, + found = ceFindMenu( minfo.hSubMenu, id, +#ifndef _WIN32_WCE + foundMenu, foundPos, +#endif foundBuf, bufLen ); } else if ( MFT_SEPARATOR == minfo.fType ) { continue; } else if ( minfo.wID == id ) { found = XP_TRUE; +#ifndef _WIN32_WCE *foundPos = pos; *foundMenu = menu; +#endif } } return found; @@ -650,11 +658,14 @@ setW32DummyMenu( CEAppGlobals* globals, HMENU menu, XP_U16 id, wchar_t* oldNm ) void ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 newId ) { - if ( newId != globals->softkey.oldId ) { + if ( newId != globals->softKeyId ) { + wchar_t menuTxt[32]; /* text of newId menu */ HMENU menu; +#ifndef _WIN32_WCE HMENU prevMenu; XP_U16 prevPos; - XP_U16 oldId = globals->softkey.oldId; +#endif + XP_U16 oldId = globals->softKeyId; if ( 0 == oldId ) { oldId = ID_INITIAL_SOFTID; } @@ -675,26 +686,13 @@ ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 newId ) menu = GetMenu( globals->hWnd ); #endif - /* First put any existing menu item back in the main menu! */ - if ( globals->softkey.oldMenu != 0 ) { - if ( ! InsertMenu( globals->softkey.oldMenu, - globals->softkey.oldPos, MF_BYPOSITION, - globals->softkey.oldId, - globals->softkey.oldName ) ) { - XP_LOGF( "%s: InsertMenu failed", __func__ ); - } - } - - /* Then find, remember and remove the new */ - if ( ceFindMenu( menu, newId, &prevMenu, &prevPos, - globals->softkey.oldName, - VSIZE(globals->softkey.oldName) ) ) { - if ( !DeleteMenu( prevMenu, prevPos, MF_BYPOSITION ) ) { - XP_LOGF( "%s: DeleteMenu failed", __func__ ); - } - globals->softkey.oldMenu = prevMenu; - globals->softkey.oldPos = prevPos; - globals->softkey.oldId = newId; + /* Look up the text... */ + if ( ceFindMenu( menu, newId, +#ifndef _WIN32_WCE + &prevMenu, &prevPos, +#endif + menuTxt, VSIZE(menuTxt) ) ) { + globals->softKeyId = newId; } else { XP_LOGF( "%s: ceFindMenu failed", __func__ ); } @@ -703,10 +701,10 @@ ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 newId ) #ifdef _WIN32_WCE info.dwMask = TBIF_TEXT | TBIF_COMMAND; info.idCommand = newId; - info.pszText = globals->softkey.oldName; + info.pszText = menuTxt; SendMessage( globals->hwndCB, TB_SETBUTTONINFO, oldId, (LPARAM)&info ); #else - setW32DummyMenu( globals, menu, newId, globals->softkey.oldName ); + setW32DummyMenu( globals, menu, newId, menuTxt ); #endif } } /* ceSetLeftSoftkey */