When fewer than 4 players shown in game info dialog, move controls

higher that are below player rows. On some screen sizes this prevents
those items from being off-screen. Note that this requires use of
DM_RESETSCROLL message to get Smartphone to recalc scroll info and
that DM_RESETSCROLL is not yet defined in cegcc.
This commit is contained in:
ehouse 2008-11-18 12:36:27 +00:00
parent d4e2f5c07a
commit 5f27b1552c
7 changed files with 126 additions and 57 deletions

View file

@ -152,6 +152,11 @@ cleanupGameInfoState( GameInfoState* giState )
XP_FREE( giState->dlgHdr.globals->mpool, giState->menuDicts ); XP_FREE( giState->dlgHdr.globals->mpool, giState->menuDicts );
giState->menuDicts = NULL; giState->menuDicts = NULL;
} }
if ( !!giState->moveIds ) {
XP_FREE( giState->dlgHdr.globals->mpool, giState->moveIds );
giState->moveIds = NULL;
}
} /* cleanupGameInfoState */ } /* cleanupGameInfoState */
static void static void
@ -249,6 +254,64 @@ stateToGameInfo( GameInfoState* giState )
return success; return success;
} /* stateToGameInfo */ } /* stateToGameInfo */
#ifndef DM_RESETSCROLL
//http://www.nah6.com/~itsme/cvs-xdadevtools/itsutils/src/its_windows_message_list.txt
# define DM_RESETSCROLL 0x0402
#endif
static void
raiseForHiddenPlayers( GameInfoState* giState, XP_U16 nPlayers )
{
HWND hDlg = giState->dlgHdr.hDlg;
XP_U16 ii;
XP_S16 moveY;
if ( nPlayers != giState->prevNPlayers ) {
if ( !giState->moveIds ) {
XP_S16 ids[32];
HWND child;
RECT rect;
XP_U16 playersBottom;
ceGetItemRect( hDlg, NAME_EDIT4, &rect );
playersBottom = rect.bottom;
ceGetItemRect( hDlg, NAME_EDIT3, &rect );
giState->playersSpacing = playersBottom - rect.bottom;
for ( child = GetWindow( hDlg, GW_CHILD ), ii = 0;
!!child;
child = GetWindow( child, GW_HWNDNEXT ) ) {
XP_S16 resID = GetDlgCtrlID( child );
if ( resID > 0 ) {
ceGetItemRect( hDlg, resID, &rect );
if ( rect.top > playersBottom ) {
XP_ASSERT( ii < VSIZE(ids)-1 );
ids[ii] = resID;
++ii;
}
}
}
giState->moveIds = XP_MALLOC( giState->dlgHdr.globals->mpool,
sizeof(giState->moveIds[0]) * ii );
XP_MEMCPY( giState->moveIds, ids,
sizeof(giState->moveIds[0]) * ii );
giState->nMoveIds = ii;
}
moveY = giState->playersSpacing * (nPlayers - giState->prevNPlayers);
for ( ii = 0; ii < giState->nMoveIds; ++ii ) {
ceMoveItem( hDlg, giState->moveIds[ii], 0, moveY );
}
giState->prevNPlayers = nPlayers;
#ifdef _WIN32_WCE
if ( IS_SMARTPHONE(giState->dlgHdr.globals) ) {
SendMessage( hDlg, DM_RESETSCROLL, (WPARAM)FALSE, (LPARAM)TRUE );
}
#endif
}
}
static void static void
handlePrefsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState ) handlePrefsButton( HWND hDlg, CEAppGlobals* globals, GameInfoState* giState )
{ {
@ -433,6 +496,7 @@ ceSetAttrProc(void* closure, NewGameAttr attr, const NGValue value )
SendDlgItemMessage( giState->dlgHdr.hDlg, resID, SendDlgItemMessage( giState->dlgHdr.hDlg, resID,
SETCURSEL(globals), SETCURSEL(globals),
value.ng_u16 - 1, 0L ); value.ng_u16 - 1, 0L );
raiseForHiddenPlayers( giState, value.ng_u16 );
break; break;
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY
case NG_ATTR_ROLE: case NG_ATTR_ROLE:
@ -491,12 +555,15 @@ checkUpdateCombo( GameInfoState* giState, XP_U16 id )
if ( (id == giState->nPlayersId) if ( (id == giState->nPlayersId)
&& giState->isNewGame ) { /* ignore if in info mode */ && giState->isNewGame ) { /* ignore if in info mode */
NGValue value; NGValue value;
value.ng_u16 = 1 + (XP_U16) XP_U16 nPlayers = 1 + (XP_U16)
SendDlgItemMessage( giState->dlgHdr.hDlg, id, SendDlgItemMessage( giState->dlgHdr.hDlg, id,
GETCURSEL(giState->dlgHdr.globals), 0, 0L); GETCURSEL(giState->dlgHdr.globals), 0, 0L);
value.ng_u16 = nPlayers;
XP_ASSERT( !!giState->newGameCtx ); XP_ASSERT( !!giState->newGameCtx );
newg_attrChanged( giState->newGameCtx, newg_attrChanged( giState->newGameCtx,
NG_ATTR_NPLAYERS, value ); NG_ATTR_NPLAYERS, value );
raiseForHiddenPlayers( giState, nPlayers );
} }
} /* checkUpdateCombo */ } /* checkUpdateCombo */
@ -517,6 +584,7 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
giState->nPlayersId = LB_IF_PPC(globals,IDC_NPLAYERSCOMBO); giState->nPlayersId = LB_IF_PPC(globals,IDC_NPLAYERSCOMBO);
giState->dictListId = LB_IF_PPC(globals,IDC_DICTLIST); giState->dictListId = LB_IF_PPC(globals,IDC_DICTLIST);
giState->prevNPlayers = MAX_NUM_PLAYERS;
ceDlgSetup( &giState->dlgHdr, hDlg, DLG_STATE_TRAPBACK ); ceDlgSetup( &giState->dlgHdr, hDlg, DLG_STATE_TRAPBACK );
ceDlgComboShowHide( &giState->dlgHdr, IDC_NPLAYERSCOMBO ); ceDlgComboShowHide( &giState->dlgHdr, IDC_NPLAYERSCOMBO );

View file

@ -45,6 +45,13 @@ typedef struct GameInfoState {
XP_Bool colorsChanged; XP_Bool colorsChanged;
XP_Bool addrChanged; XP_Bool addrChanged;
CePrefsPrefs prefsPrefs; CePrefsPrefs prefsPrefs;
/* Support for repositioning lower items based on num players */
XP_U16* moveIds;
XP_U16 nMoveIds;
XP_U16 prevNPlayers;
XP_U16 playersSpacing;
} GameInfoState; } GameInfoState;

View file

@ -1335,8 +1335,8 @@ InitInstance(HINSTANCE hInstance, int nCmdShow
GetWindowRect( globals->hwndCB, &rcmb ); GetWindowRect( globals->hwndCB, &rcmb );
rc.bottom -= (rcmb.bottom - rcmb.top); rc.bottom -= (rcmb.bottom - rcmb.top);
MoveWindow(hWnd, rc.left, rc.top, rc.right-rc.left, MoveWindow( hWnd, rc.left, rc.top, rc.right-rc.left,
rc.bottom-rc.top, FALSE); rc.bottom-rc.top, FALSE );
} }
#endif #endif

View file

@ -156,48 +156,51 @@ ceGetChecked( HWND hDlg, XP_U16 resID )
/* Return dlg-relative rect. /* Return dlg-relative rect.
*/ */
static void void
GetItemRect( HWND hDlg, XP_U16 resID, RECT* rect ) ceGetItemRect( HWND hDlg, XP_U16 resID, RECT* rect )
{ {
RECT dlgRect; HWND itemH;
HWND itemH = GetDlgItem( hDlg, resID ); POINT pt = { .x = 0, .y = 0 };
XP_U16 clientHt, winHt; ScreenToClient( hDlg, &pt );
GetClientRect( hDlg, &dlgRect ); itemH = GetDlgItem( hDlg, resID );
clientHt = dlgRect.bottom;
GetWindowRect( hDlg, &dlgRect );
winHt = dlgRect.bottom - dlgRect.top;
GetWindowRect( itemH, rect ); GetWindowRect( itemH, rect );
(void)OffsetRect( rect, pt.x, pt.y );
} /* ceGetItemRect */
/* GetWindowRect includes the title bar, but functions like MoveWindow void
set relative to the client area below it. So subtract out the ceMoveItem( HWND hDlg, XP_U16 resID, XP_S16 byX, XP_S16 byY )
difference between window ht and client rect ht -- the title bar -- {
when returning the item's rect. */ RECT rect;
(void)OffsetRect( rect, -dlgRect.left, HWND itemH = GetDlgItem( hDlg, resID );
-(dlgRect.top + winHt - clientHt) ); ceGetItemRect( hDlg, resID, &rect );
} /* GetItemRect */ if ( !MoveWindow( itemH, rect.left + byX, rect.top + byY,
rect.right - rect.left, rect.bottom - rect.top,
TRUE ) ) {
XP_LOGF( "MoveWindow=>%ld", GetLastError() );
}
} /* ceMoveItem */
#if 0
/* This has not been tested with ceMoveItem... */
void void
ceCenterCtl( HWND hDlg, XP_U16 resID ) ceCenterCtl( HWND hDlg, XP_U16 resID )
{ {
RECT buttonR, dlgR; RECT buttonR, dlgR;
HWND itemH = GetDlgItem( hDlg, resID ); XP_U16 buttonWidth;
XP_U16 newX, buttonWidth; XP_S16 byX;
GetClientRect( hDlg, &dlgR ); GetClientRect( hDlg, &dlgR );
XP_ASSERT( dlgR.left == 0 && dlgR.top == 0 ); XP_ASSERT( dlgR.left == 0 && dlgR.top == 0 );
GetItemRect( hDlg, resID, &buttonR ); ceGetItemRect( hDlg, resID, &buttonR );
buttonWidth = buttonR.right - buttonR.left; buttonWidth = buttonR.right - buttonR.left;
newX = ( dlgR.right - buttonWidth ) / 2; byX = buttonR.left - ((dlgR.right - buttonWidth) / 2);
if ( !MoveWindow( itemH, newX, buttonR.top, ceMoveItem( hDlg, resID, byX, 0 );
buttonWidth,
buttonR.bottom - buttonR.top, TRUE ) ) {
XP_LOGF( "MoveWindow=>%ld", GetLastError() );
}
} /* ceCenterCtl */ } /* ceCenterCtl */
#endif
/* XP_Bool */ /* XP_Bool */
/* ceIsLandscape( CEAppGlobals* globals ) */ /* ceIsLandscape( CEAppGlobals* globals ) */

View file

@ -44,6 +44,9 @@ void ceSetChecked( HWND hDlg, XP_U16 resID, XP_Bool check );
void ceCenterCtl( HWND hDlg, XP_U16 resID ); void ceCenterCtl( HWND hDlg, XP_U16 resID );
void ceCheckMenus( const CEAppGlobals* globals ); void ceCheckMenus( const CEAppGlobals* globals );
void ceGetItemRect( HWND hDlg, XP_U16 resID, RECT* rect );
void ceMoveItem( HWND hDlg, XP_U16 resID, XP_S16 byX, XP_S16 byY );
typedef enum { typedef enum {
PREFS_FILE_PATH_L PREFS_FILE_PATH_L
,DEFAULT_DIR_PATH_L ,DEFAULT_DIR_PATH_L

View file

@ -267,6 +267,8 @@
#define IDC_NPLAYERSUPDOWN 1219 #define IDC_NPLAYERSUPDOWN 1219
#define IDC_NPLAYERSCOMBO_PPC 1220 #define IDC_NPLAYERSCOMBO_PPC 1220
#define IDC_DICTLABEL 1221
// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED

View file

@ -237,6 +237,15 @@ END
#undef UPDOWN_CLASS #undef UPDOWN_CLASS
#define UPDOWN_CLASS "msctls_updown32" #define UPDOWN_CLASS "msctls_updown32"
#define CE_PLAYER_ROW(nameEdit,playerRow,robotCheck,passEdit) \
EDITTEXT nameEdit,GAME_NAME_LEFT,playerRow,GAME_NAME_WIDTH,ROW_HEIGHT, \
ES_AUTOHSCROLL \
CONTROL "",robotCheck,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, \
GAME_ROBOT_LEFT,playerRow,CHECK_WIDTH,ROW_HEIGHT \
EDITTEXT passEdit,GAME_PWD_LEFT,playerRow,15,ROW_HEIGHT, \
ES_PASSWORD | ES_AUTOHSCROLL \
IDD_GAMEINFO DIALOG DISCARDABLE 0, 0, 116, GAMEINFO_HEIGHT IDD_GAMEINFO DIALOG DISCARDABLE 0, 0, 116, GAMEINFO_HEIGHT
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER | WS_VSCROLL STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | DS_CENTER | WS_VSCROLL
CAPTION "Game info" CAPTION "Game info"
@ -264,6 +273,7 @@ BEGIN
LABELS_ROW,19,8,SS_NOPREFIX LABELS_ROW,19,8,SS_NOPREFIX
LTEXT "Robot",IDC_STATIC,GAME_ROBOTLABEL_LEFT-7,LABELS_ROW,20,8 LTEXT "Robot",IDC_STATIC,GAME_ROBOTLABEL_LEFT-7,LABELS_ROW,20,8
LTEXT "Pwd",IDC_STATIC,GAME_PWDLABEL_LEFT,LABELS_ROW,16,8 LTEXT "Pwd",IDC_STATIC,GAME_PWDLABEL_LEFT,LABELS_ROW,16,8
#if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH #if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH
LTEXT "Remote",IDC_REMOTE_LABEL,LEFT_COL,LABELS_ROW,25,8,SS_NOPREFIX LTEXT "Remote",IDC_REMOTE_LABEL,LEFT_COL,LABELS_ROW,25,8,SS_NOPREFIX
CONTROL "",REMOTE_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, CONTROL "",REMOTE_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
@ -275,36 +285,12 @@ BEGIN
CONTROL "",REMOTE_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, CONTROL "",REMOTE_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
GAME_REMOTE_LEFT, PLAYER_ROW_4,CHECK_WIDTH,ROW_HEIGHT GAME_REMOTE_LEFT, PLAYER_ROW_4,CHECK_WIDTH,ROW_HEIGHT
#endif #endif
EDITTEXT NAME_EDIT1,GAME_NAME_LEFT,PLAYER_ROW_1,GAME_NAME_WIDTH,ROW_HEIGHT, CE_PLAYER_ROW( NAME_EDIT1, PLAYER_ROW_1, ROBOT_CHECK1, PASS_EDIT1 )
ES_AUTOHSCROLL CE_PLAYER_ROW( NAME_EDIT2, PLAYER_ROW_2, ROBOT_CHECK2, PASS_EDIT2 )
CONTROL "",ROBOT_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, CE_PLAYER_ROW( NAME_EDIT3, PLAYER_ROW_3, ROBOT_CHECK3, PASS_EDIT3 )
GAME_ROBOT_LEFT,PLAYER_ROW_1,CHECK_WIDTH,ROW_HEIGHT CE_PLAYER_ROW( NAME_EDIT4, PLAYER_ROW_4, ROBOT_CHECK4, PASS_EDIT4 )
EDITTEXT PASS_EDIT1,GAME_PWD_LEFT,PLAYER_ROW_1,15,ROW_HEIGHT,
ES_PASSWORD | ES_AUTOHSCROLL | WS_TABSTOP
LTEXT "Dictionary:",IDC_DICTLABEL,LEFT_COL,DICTPICK_LAB_ROW,36,8,
EDITTEXT NAME_EDIT2,GAME_NAME_LEFT,PLAYER_ROW_2,GAME_NAME_WIDTH,ROW_HEIGHT,
ES_AUTOHSCROLL
CONTROL "",ROBOT_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
GAME_ROBOT_LEFT,PLAYER_ROW_2,CHECK_WIDTH,ROW_HEIGHT
EDITTEXT PASS_EDIT2,GAME_PWD_LEFT,PLAYER_ROW_2,15,ROW_HEIGHT,
ES_PASSWORD | ES_AUTOHSCROLL
EDITTEXT NAME_EDIT3,GAME_NAME_LEFT,PLAYER_ROW_3,GAME_NAME_WIDTH,ROW_HEIGHT,
ES_AUTOHSCROLL
CONTROL "",ROBOT_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
GAME_ROBOT_LEFT,PLAYER_ROW_3,CHECK_WIDTH,ROW_HEIGHT
EDITTEXT PASS_EDIT3,GAME_PWD_LEFT,PLAYER_ROW_3,15,ROW_HEIGHT,
ES_PASSWORD | ES_AUTOHSCROLL
EDITTEXT NAME_EDIT4,GAME_NAME_LEFT,PLAYER_ROW_4,GAME_NAME_WIDTH,ROW_HEIGHT,
ES_AUTOHSCROLL | NOT WS_VISIBLE
CONTROL "",ROBOT_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
GAME_ROBOT_LEFT, PLAYER_ROW_4,CHECK_WIDTH,ROW_HEIGHT
EDITTEXT PASS_EDIT4,GAME_PWD_LEFT,PLAYER_ROW_4,15,ROW_HEIGHT,
ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Dictionary:",IDC_STATIC,LEFT_COL,DICTPICK_LAB_ROW,36,8,
SS_NOPREFIX SS_NOPREFIX
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
LISTBOX IDC_DICTLIST, LEFT_COL+10,DICTPICK_ROW,70,12,LISTBOX_CONTROL_FLAGS LISTBOX IDC_DICTLIST, LEFT_COL+10,DICTPICK_ROW,70,12,LISTBOX_CONTROL_FLAGS