mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
Trapped back key should exit dialog even if it has an edit control if
that control does not have focus. Do that. And since I can't figure out how to use APIs available in CE to find edit controls dynamically each dialog proc has to pass its IDs in. May fix that later, in which case ceDlgSetEdits() should be removed.
This commit is contained in:
parent
6b6d5d79d0
commit
20bcdea816
9 changed files with 78 additions and 14 deletions
|
@ -64,6 +64,8 @@ CFLAGS += -D_WIN32_WCE=0x0400 -D_WIN32_IE=0x0400 -DUNDER_CE \
|
||||||
$(STANDALONE) $(USE_RAW_MINGW) -DDRAW_LINK_DIRECT \
|
$(STANDALONE) $(USE_RAW_MINGW) -DDRAW_LINK_DIRECT \
|
||||||
-DXWFEATURE_TURNCHANGENOTIFY \
|
-DXWFEATURE_TURNCHANGENOTIFY \
|
||||||
-fdollars-in-identifiers -D__W32API_USE_DLLIMPORT__
|
-fdollars-in-identifiers -D__W32API_USE_DLLIMPORT__
|
||||||
|
# back key should raise focus on main board and backspace in edit controls
|
||||||
|
CFLAGS += -DOVERRIDE_BACKKEY
|
||||||
RESFLAGS += -D_WIN32_WCE=400
|
RESFLAGS += -D_WIN32_WCE=400
|
||||||
LFLAGS += -Wl,--major-subsystem-version,4,--minor-subsystem-version,20
|
LFLAGS += -Wl,--major-subsystem-version,4,--minor-subsystem-version,20
|
||||||
ifdef HAVE_COMMCTRL
|
ifdef HAVE_COMMCTRL
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
#include "cemain.h"
|
#include "cemain.h"
|
||||||
#include "ceutil.h"
|
#include "ceutil.h"
|
||||||
#include "debhacks.h"
|
#include "debhacks.h"
|
||||||
#include <stdio.h> /* swprintf */
|
//##include <stdio.h> /* swprintf */
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nameToLabel( HWND hDlg, const XP_UCHAR* name, XP_U16 labelID )
|
nameToLabel( HWND hDlg, const XP_UCHAR* name, XP_U16 labelID )
|
||||||
|
@ -50,6 +51,7 @@ PasswdDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
pState = (PasswdDialogState*)lParam;
|
pState = (PasswdDialogState*)lParam;
|
||||||
|
|
||||||
ceDlgSetup( &pState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
ceDlgSetup( &pState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
||||||
|
ceDlgSetEdits( &pState->dlgHdr, PASS_EDIT, 0 );
|
||||||
|
|
||||||
nameToLabel( hDlg, pState->name, IDC_PWDLABEL );
|
nameToLabel( hDlg, pState->name, IDC_PWDLABEL );
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,7 @@ BlankDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ceDlgSetup( &bState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
ceDlgSetup( &bState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
||||||
|
ceDlgSetEdits( &bState->dlgHdr, IDC_PICKMSG, 0 );
|
||||||
ceDlgComboShowHide( &bState->dlgHdr, BLANKFACE_LIST );
|
ceDlgComboShowHide( &bState->dlgHdr, BLANKFACE_LIST );
|
||||||
|
|
||||||
loadLettersList( bState );
|
loadLettersList( bState );
|
||||||
|
|
|
@ -145,6 +145,7 @@ EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
eState->inited = XP_FALSE;
|
eState->inited = XP_FALSE;
|
||||||
|
|
||||||
ceDlgSetup( &eState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
ceDlgSetup( &eState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
||||||
|
ceDlgSetEdits( &eState->dlgHdr, RED_EDIT, GREEN_EDIT, BLUE_EDIT, 0 );
|
||||||
|
|
||||||
wchar_t label[32];
|
wchar_t label[32];
|
||||||
XP_U16 len = SendDlgItemMessage( eState->parent, eState->labelID,
|
XP_U16 len = SendDlgItemMessage( eState->parent, eState->labelID,
|
||||||
|
|
|
@ -520,6 +520,9 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
giState->dictListId = LB_IF_PPC(globals,IDC_DICTLIST);
|
giState->dictListId = LB_IF_PPC(globals,IDC_DICTLIST);
|
||||||
|
|
||||||
ceDlgSetup( &giState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
ceDlgSetup( &giState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
||||||
|
ceDlgSetEdits( &giState->dlgHdr, NAME_EDIT1, PASS_EDIT1, NAME_EDIT2,
|
||||||
|
PASS_EDIT2, NAME_EDIT3, PASS_EDIT3, NAME_EDIT4,
|
||||||
|
PASS_EDIT4, 0 );
|
||||||
ceDlgComboShowHide( &giState->dlgHdr, IDC_NPLAYERSCOMBO );
|
ceDlgComboShowHide( &giState->dlgHdr, IDC_NPLAYERSCOMBO );
|
||||||
ceDlgComboShowHide( &giState->dlgHdr, IDC_DICTLIST );
|
ceDlgComboShowHide( &giState->dlgHdr, IDC_DICTLIST );
|
||||||
|
|
||||||
|
|
|
@ -275,6 +275,7 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
pState->phonComboId = LB_IF_PPC(pState->dlgHdr.globals,PHONIES_COMBO);
|
pState->phonComboId = LB_IF_PPC(pState->dlgHdr.globals,PHONIES_COMBO);
|
||||||
|
|
||||||
ceDlgSetup( &pState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
ceDlgSetup( &pState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
||||||
|
ceDlgSetEdits( &pState->dlgHdr, TIMER_EDIT, 0 );
|
||||||
ceDlgComboShowHide( &pState->dlgHdr, PHONIES_COMBO );
|
ceDlgComboShowHide( &pState->dlgHdr, PHONIES_COMBO );
|
||||||
|
|
||||||
stuffPhoniesList( pState );
|
stuffPhoniesList( pState );
|
||||||
|
|
|
@ -89,6 +89,7 @@ SaveNameDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
(void)SetDlgItemText( hDlg, IDC_SVGN_SELLAB, buf );
|
(void)SetDlgItemText( hDlg, IDC_SVGN_SELLAB, buf );
|
||||||
|
|
||||||
ceDlgSetup( &state->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
ceDlgSetup( &state->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
|
||||||
|
ceDlgSetEdits( &state->dlgHdr, IDC_SVGN_EDIT, 0 );
|
||||||
|
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -366,7 +367,7 @@ SavedGamesDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
state->inited = XP_FALSE;
|
state->inited = XP_FALSE;
|
||||||
state->gameListId = LB_IF_PPC(state->dlgHdr.globals,IDC_SVGM_GAMELIST);
|
state->gameListId = LB_IF_PPC(state->dlgHdr.globals,IDC_SVGM_GAMELIST);
|
||||||
|
|
||||||
ceDlgSetup( &state->dlgHdr, hDlg, DLG_STATE_NONE|DLG_STATE_DONEONLY );
|
ceDlgSetup( &state->dlgHdr, hDlg, DLG_STATE_DONEONLY );
|
||||||
ceDlgComboShowHide( &state->dlgHdr, IDC_SVGM_GAMELIST );
|
ceDlgComboShowHide( &state->dlgHdr, IDC_SVGM_GAMELIST );
|
||||||
|
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
|
|
|
@ -382,13 +382,31 @@ ceDlgSetup( CeDlgHdr* dlgHdr, HWND hDlg, DlgStateTask doWhat )
|
||||||
(void)SetScrollInfo( hDlg, SB_VERT, &sinfo, FALSE );
|
(void)SetScrollInfo( hDlg, SB_VERT, &sinfo, FALSE );
|
||||||
}
|
}
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
if ( IS_SMARTPHONE(globals) && ((doWhat & DLG_STATE_TRAPBACK) != 0) ) {
|
/* Need to trap this for all dialogs, even if they don't have edit
|
||||||
|
controls. The need goes away if the main window stops trapping it,
|
||||||
|
but I don't understand why: trapping here is still required. */
|
||||||
|
if ( IS_SMARTPHONE(globals) ) {
|
||||||
trapBackspaceKey( hDlg );
|
trapBackspaceKey( hDlg );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
dlgHdr->doWhat = doWhat;
|
dlgHdr->doWhat = doWhat;
|
||||||
} /* ceDlgSetup */
|
} /* ceDlgSetup */
|
||||||
|
|
||||||
|
void
|
||||||
|
ceDlgSetEdits( CeDlgHdr* dlgHdr, XP_U16 firstEdit, ... )
|
||||||
|
{
|
||||||
|
XP_U16 ii;
|
||||||
|
va_list ap;
|
||||||
|
va_start( ap, firstEdit );
|
||||||
|
XP_ASSERT( (dlgHdr->doWhat & DLG_STATE_TRAPBACK) != 0 );
|
||||||
|
|
||||||
|
for ( ii = 0; firstEdit != 0 && ii < MAX_EDITS; ++ii ) {
|
||||||
|
dlgHdr->edits[ii] = firstEdit;
|
||||||
|
firstEdit = va_arg( ap, int );
|
||||||
|
}
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ceDlgComboShowHide( CeDlgHdr* dlgHdr, XP_U16 baseId )
|
ceDlgComboShowHide( CeDlgHdr* dlgHdr, XP_U16 baseId )
|
||||||
{
|
{
|
||||||
|
@ -402,17 +420,40 @@ ceDlgComboShowHide( CeDlgHdr* dlgHdr, XP_U16 baseId )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static XP_Bool
|
||||||
|
editHasFocus( const CeDlgHdr* dlgHdr )
|
||||||
|
{
|
||||||
|
XP_Bool found = XP_FALSE;
|
||||||
|
XP_U16 focusId = GetDlgCtrlID( GetFocus() );
|
||||||
|
XP_U16 ii;
|
||||||
|
for ( ii = 0; ii < MAX_EDITS && !found; ++ii ) {
|
||||||
|
XP_U16 id = dlgHdr->edits[ii];
|
||||||
|
if ( 0 == id ) {
|
||||||
|
break;
|
||||||
|
} else if ( id == focusId ) {
|
||||||
|
found = XP_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
} /* editHasFocus */
|
||||||
|
|
||||||
XP_Bool
|
XP_Bool
|
||||||
ceDoDlgHandle( CeDlgHdr* dlgHdr, UINT message, WPARAM wParam, LPARAM lParam )
|
ceDoDlgHandle( CeDlgHdr* dlgHdr, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
{
|
{
|
||||||
XP_Bool handled = XP_FALSE;
|
XP_Bool handled = XP_FALSE;
|
||||||
|
|
||||||
switch( message ) {
|
switch( message ) {
|
||||||
#ifdef _WIN32_WCE
|
#ifdef OVERRIDE_BACKKEY
|
||||||
case WM_HOTKEY:
|
case WM_HOTKEY:
|
||||||
XP_ASSERT( (dlgHdr->doWhat && DLG_STATE_TRAPBACK) != 0 );
|
|
||||||
if ( VK_TBACK == HIWORD(lParam) ) {
|
if ( VK_TBACK == HIWORD(lParam) ) {
|
||||||
SHSendBackToFocusWindow( message, wParam, lParam );
|
if ( editHasFocus( dlgHdr ) ) {
|
||||||
handled = TRUE;
|
SHSendBackToFocusWindow( message, wParam, lParam );
|
||||||
|
handled = TRUE;
|
||||||
|
} else {
|
||||||
|
WPARAM cmd = (0 != (dlgHdr->doWhat & DLG_STATE_DONEONLY)) ?
|
||||||
|
IDOK : IDCANCEL;
|
||||||
|
SendMessage( dlgHdr->hDlg, WM_COMMAND, cmd, 0L );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
@ -709,13 +750,18 @@ ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 newId )
|
||||||
}
|
}
|
||||||
} /* ceSetLeftSoftkey */
|
} /* ceSetLeftSoftkey */
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
#ifdef OVERRIDE_BACKKEY
|
||||||
void
|
void
|
||||||
trapBackspaceKey( HWND hDlg )
|
trapBackspaceKey( HWND hDlg )
|
||||||
{
|
{
|
||||||
/* Override back key so we can pass it to edit controls */
|
/* Override back key so we can pass it to edit controls */
|
||||||
SendMessage( SHFindMenuBar(hDlg), SHCMBM_OVERRIDEKEY, VK_TBACK,
|
SendMessage( SHFindMenuBar(hDlg), SHCMBM_OVERRIDEKEY, VK_TBACK,
|
||||||
MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
|
MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
|
||||||
SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
|
SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
|
||||||
|
/* To undo the above
|
||||||
|
SendMessage( SHFindMenuBar(hDlg), SHCMBM_OVERRIDEKEY, VK_TBACK,
|
||||||
|
MAKELPARAM( SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
|
||||||
|
0 ) );
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -48,6 +48,7 @@ typedef enum { DLG_STATE_NONE = 0
|
||||||
, DLG_STATE_TRAPBACK = 1
|
, DLG_STATE_TRAPBACK = 1
|
||||||
, DLG_STATE_DONEONLY = 2
|
, DLG_STATE_DONEONLY = 2
|
||||||
} DlgStateTask;
|
} DlgStateTask;
|
||||||
|
#define MAX_EDITS 8 /* the most any control has */
|
||||||
typedef struct CeDlgHdr {
|
typedef struct CeDlgHdr {
|
||||||
CEAppGlobals* globals;
|
CEAppGlobals* globals;
|
||||||
HWND hDlg;
|
HWND hDlg;
|
||||||
|
@ -55,8 +56,10 @@ typedef struct CeDlgHdr {
|
||||||
/* Below this line is private to ceutil.c */
|
/* Below this line is private to ceutil.c */
|
||||||
DlgStateTask doWhat;
|
DlgStateTask doWhat;
|
||||||
XP_U16 nPage;
|
XP_U16 nPage;
|
||||||
|
XP_U16 edits[MAX_EDITS];
|
||||||
} CeDlgHdr;
|
} CeDlgHdr;
|
||||||
void ceDlgSetup( CeDlgHdr* dlgHdr, HWND hDlg, DlgStateTask doWhat );
|
void ceDlgSetup( CeDlgHdr* dlgHdr, HWND hDlg, DlgStateTask doWhat );
|
||||||
|
void ceDlgSetEdits( CeDlgHdr* dlgHdr, XP_U16 firstEdit, ... );
|
||||||
void ceDlgComboShowHide( CeDlgHdr* dlgHdr, XP_U16 baseId );
|
void ceDlgComboShowHide( CeDlgHdr* dlgHdr, XP_U16 baseId );
|
||||||
XP_Bool ceDoDlgHandle( CeDlgHdr* dlgHdr, UINT message, WPARAM wParam, LPARAM lParam);
|
XP_Bool ceDoDlgHandle( CeDlgHdr* dlgHdr, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
@ -65,11 +68,15 @@ XP_Bool ceIsLandscape( CEAppGlobals* globals );
|
||||||
|
|
||||||
void ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 id );
|
void ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 id );
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
#if defined _WIN32_WCE
|
||||||
void ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd );
|
void ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd );
|
||||||
void trapBackspaceKey( HWND hDlg );
|
|
||||||
#else
|
#else
|
||||||
# define ceSizeIfFullscreen( globals, hWnd )
|
# define ceSizeIfFullscreen( globals, hWnd )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef OVERRIDE_BACKKEY
|
||||||
|
void trapBackspaceKey( HWND hDlg );
|
||||||
|
#else
|
||||||
# define trapBackspaceKey( hDlg )
|
# define trapBackspaceKey( hDlg )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue