For dialogs in portrait-mode, move OK and Cancel buttons to the right

side and shrink up from the bottom
This commit is contained in:
ehouse 2006-05-25 03:41:32 +00:00
parent 340214d87d
commit be930f344c
11 changed files with 100 additions and 33 deletions

View file

@ -71,11 +71,17 @@ ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
CEAppGlobals* globals;
if ( message == WM_INITDIALOG ) {
XP_U16 buttons[] = { IDOK, IDCANCEL };
SetWindowLong( hDlg, GWL_USERDATA, lParam );
cState = (CeConnDlgState*)lParam;
globals = cState->globals;
ceControlsFromAddrRec( hDlg, cState );
ceStackButtonsRight( globals, hDlg, buttons,
sizeof(buttons)/sizeof(buttons[0]), 8 );
result = TRUE;
} else {
cState = (CeConnDlgState*)GetWindowLong( hDlg, GWL_USERDATA );

View file

@ -574,6 +574,7 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
#endif
if ( message == WM_INITDIALOG ) {
XP_U16 buttons[] = { IDOK, IDCANCEL };
SetWindowLong( hDlg, GWL_USERDATA, lParam );
giState = (GameInfoState*)lParam;
@ -589,6 +590,8 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
if ( giState->isNewGame ) {
(void)SetWindowText( hDlg, L"New game" );
}
ceStackButtonsRight( globals, hDlg, buttons,
sizeof(buttons)/sizeof(buttons[0]), 8 );
return TRUE;
} else {

View file

@ -1,6 +1,6 @@
/* -*- fill-column: 77; c-basic-offset: 4; compile-command: "make TARGET_OS=wince DEBUG=TRUE" -*- */
/*
* Copyright 2002-2004 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 2002-2006 by Eric House (xwords@eehouse.org). All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -630,6 +630,8 @@ cePositionBoard( CEAppGlobals* globals )
figureBoardParms( globals, nCols, &bparms );
globals->isLandscape = !bparms.horiz;
if ( globals->gameInfo.timerEnabled ) {
board_setTimerLoc( globals->game.board, bparms.timerLeft,
bparms.timerTop, bparms.timerWidth,

View file

@ -100,6 +100,7 @@ typedef struct CEAppGlobals {
XP_Bool penDown;
XP_Bool hintPending;
XP_Bool doGlobalPrefs;
XP_Bool isLandscape;
#ifdef XWFEATURE_SEARCHLIMIT
XP_Bool askTrayLimits;

View file

@ -261,6 +261,8 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
CePrefsDlgState* pState;
if ( message == WM_INITDIALOG ) {
XP_U16 buttons[] = { IDOK, IDCANCEL };
SetWindowLong( hDlg, GWL_USERDATA, lParam );
pState = (CePrefsDlgState*)lParam;
globals = pState->globals;
@ -270,6 +272,9 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
loadControlsFromState( hDlg, pState );
adjustForChoice( hDlg, pState );
ceStackButtonsRight( globals, hDlg, buttons,
sizeof(buttons)/sizeof(buttons[0]), 8 );
return TRUE;
} else {

View file

@ -1,6 +1,6 @@
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
/* -*- fill-column: 77; c-basic-offset: 4; compile-command: "make TARGET_OS=wince DEBUG=TRUE" -*- */
/*
* Copyright 2002-2004 by Eric House (xwords@eehouse.org). All rights reserved.
* Copyright 2002-2006 by Eric House (xwords@eehouse.org). All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -59,6 +59,8 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
XP_U16 id;
if ( message == WM_INITDIALOG ) {
XP_U16 buttons[] = { IDOK, IDCANCEL };
SetWindowLong( hDlg, GWL_USERDATA, (long)lParam );
init = (StrBoxInit*)lParam;
@ -68,12 +70,16 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
SendMessage( hDlg, WM_SETTEXT, 0, (long)init->title );
}
ceStackButtonsRight( globals, hDlg, buttons,
sizeof(buttons)/sizeof(buttons[0]), 8 );
if ( !init->isQuery ) {
ceShowOrHide( hDlg, IDCANCEL, XP_FALSE );
/* also want to expand the text box to the bottom */
ceCenterCtl( hDlg, IDOK );
if ( !globals->isLandscape ) {
ceCenterCtl( hDlg, IDOK );
}
}
init->textIsSet = XP_FALSE; /* postpone to avoid highlight. */
stuffTextInField( hDlg, init );
return TRUE;
} else {
@ -81,13 +87,7 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
if ( !!init ) {
switch (message) {
case WM_COMMAND:
if ( !init->textIsSet ) {
init->textIsSet = XP_TRUE;
stuffTextInField( hDlg, init );
}
id = LOWORD(wParam);
switch( id ) {

View file

@ -32,5 +32,4 @@ typedef struct StrBoxInit {
XWStreamCtxt* stream;
XP_U16 result;
XP_Bool isQuery;
XP_Bool textIsSet;
} StrBoxInit;

View file

@ -1,4 +1,4 @@
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
/* -*- fill-column: 77; c-basic-offset: 4; compile-command: "make TARGET_OS=wince DEBUG=TRUE" -*- */
/*
* Copyright 2002-2004 by Eric House (xwords@eehouse.org). All rights reserved.
*
@ -192,6 +192,50 @@ ceCenterCtl( HWND hDlg, XP_U16 resID )
}
} /* ceCenterCtl */
void
ceStackButtonsRight( CEAppGlobals* globals, HWND hDlg,
XP_U16* resIDs, XP_U16 nResIDs,
XP_U16 top )
{
if ( globals->isLandscape ) {
RECT rect;
XP_U16 left;
XP_U16 maxWidth = 0;
XP_U16 maxHt = 0;
GetClientRect( hDlg, &rect );
left = rect.right;
/* Now move any and all buttons into position along the right side */
while ( nResIDs-- ) {
HWND itemH = GetDlgItem( hDlg, *resIDs++ );
XP_U16 ht, width;
GetClientRect( itemH, &rect );
width = rect.right - rect.left;
if ( maxWidth < width ) {
maxWidth = width;
}
ht = rect.bottom - rect.top;
if ( maxHt < ht ) {
maxHt = ht;
}
(void)MoveWindow( itemH, left, top, width, ht, TRUE );
top += ht + (REPOS_BUTTON_VPAD*2);
}
maxWidth += 4; /* padding */
GetWindowRect( hDlg, &rect );
MoveWindow( hDlg, rect.left - (maxWidth/2), rect.top,
rect.right - rect.left + maxWidth,
rect.bottom - rect.top - maxHt - 2,
FALSE );
}
} /* ceStackButtonsRight */
#ifdef DEBUG
void
XP_LOGW( const XP_UCHAR* prefix, const wchar_t* arg )

View file

@ -43,6 +43,11 @@ void ceSetChecked( HWND hDlg, XP_U16 resID, XP_Bool check );
void ceCenterCtl( HWND hDlg, XP_U16 resID );
/* If app's in portrait mode, resize with some buttons at right rather than
bottom */
void ceStackButtonsRight( CEAppGlobals* globals, HWND hDlg,
XP_U16* resIDs, XP_U16 nResIDs, XP_U16 top );
#ifdef DEBUG
void XP_LOGW( const XP_UCHAR* prefix, const wchar_t* arg );
#else

View file

@ -173,8 +173,6 @@
#define ID_FILE_SAVEDGAMES 40020
#define ID_EDITTEXT 40021
#define ID_FILE_PREFERENCES 40022
#define ID_FILE_BEAMDICT 40023
#define ID_FILE_BEAMBOARDS 40024
#define ID_GAME_RESENDMSGS 40025
#define ID_COLORS_RES 9999
@ -198,3 +196,8 @@
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
#define REPOS_BUTTON_HT 14
#define REPOS_BUTTON_WIDTH 39
#define REPOS_BUTTON_VPAD 2
#define REPOS_BUTTON_HPAD 2

View file

@ -94,10 +94,6 @@ BEGIN
MENUITEM "Open &saved game", ID_FILE_SAVEDGAMES
MENUITEM "&Preferences", ID_FILE_PREFERENCES
MENUITEM SEPARATOR
#ifndef XWFEATURE_STANDALONE_ONLY
MENUITEM "Beam dictionary", ID_FILE_BEAMDICT
MENUITEM "Beam boards and colors", ID_FILE_BEAMBOARDS
#endif
MENUITEM "&About", ID_FILE_ABOUT
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_FILE_EXIT
@ -259,8 +255,9 @@ BEGIN
COMBOBOX IDC_DICTCOMBO,43,DICTPICK_ROW,85,58,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,29,BUTTONS_ROW,31,BUTTON_HT
DEFPUSHBUTTON "Cancel",IDCANCEL,70,BUTTONS_ROW,31,BUTTON_HT
DEFPUSHBUTTON "OK",IDOK,29,BUTTONS_ROW,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
DEFPUSHBUTTON "Cancel",IDCANCEL,70,BUTTONS_ROW,
REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
END
IDD_STRBOX DIALOG DISCARDABLE 0, 25, 127, 110
@ -270,8 +267,8 @@ FONT 8, "System"
BEGIN
EDITTEXT ID_EDITTEXT,6,5,115,80,ES_MULTILINE | ES_READONLY
| WS_VSCROLL
DEFPUSHBUTTON "OK",IDOK, 29,90,31,14
DEFPUSHBUTTON "No",IDCANCEL,70,90,31,14
DEFPUSHBUTTON "OK",IDOK, 29,90,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
DEFPUSHBUTTON "No",IDCANCEL,70,90,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
END
IDD_ASKBLANK DIALOG DISCARDABLE 0, 0, 131, 90
@ -325,8 +322,8 @@ BEGIN
COMBOBOX HC_MAX_COMBO,HC_DROPDOWNS_COL,HC_MAXROW,30,58,
CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,74,38,41,14
PUSHBUTTON "Cancel",IDCANCEL,15,38,45,14
DEFPUSHBUTTON "OK",IDOK,74,38,REPOS_BUTTON_WIDTH, REPOS_BUTTON_HT
PUSHBUTTON "Cancel",IDCANCEL,15,38,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
END
#endif
@ -366,8 +363,8 @@ BEGIN
BS_AUTOCHECKBOX | WS_TABSTOP,8,82,90,10
#else
#endif
DEFPUSHBUTTON "OK",IDOK,9,98,38,14
PUSHBUTTON "Cancel",IDCANCEL,70,98,39,14
DEFPUSHBUTTON "OK",IDOK,9,98,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
PUSHBUTTON "Cancel",IDCANCEL,70,98,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
END
#ifndef XWFEATURE_STANDALONE_ONLY
@ -406,8 +403,9 @@ BEGIN
EDITTEXT RELAYPORT_EDIT,CTRL_COL,CONN_ROW_4,CTRL_COL_WIDTH,12,
ES_AUTOHSCROLL | ES_NUMBER
DEFPUSHBUTTON "OK",IDOK,9,BUTTON_ROW,38,14
PUSHBUTTON "Cancel",IDCANCEL,70,BUTTON_ROW,39,14
DEFPUSHBUTTON "OK",IDOK,9,BUTTON_ROW,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
PUSHBUTTON "Cancel",IDCANCEL,70,BUTTON_ROW,
REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
END
#endif
@ -475,8 +473,9 @@ BEGIN
PUSHBUTTON "",PLAYER4_BUTTON,CLR_COL_4,CLR_ROW_5,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
DEFPUSHBUTTON "OK",IDOK,15,BUTTON_ROW,28,14
PUSHBUTTON "Cancel",IDCANCEL,60,BUTTON_ROW,39,14
DEFPUSHBUTTON "OK",IDOK,15,BUTTON_ROW,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
PUSHBUTTON "Cancel",IDCANCEL,60,BUTTON_ROW,REPOS_BUTTON_WIDTH,
REPOS_BUTTON_HT
END
//
@ -523,8 +522,8 @@ BEGIN
TBS_BOTH|TBS_NOTICKS|WS_TABSTOP,
CLRESLIDER_COL,CLREDIT_ROW_3,SLIDER_WIDTH,15
DEFPUSHBUTTON "OK",IDOK,15,57,28,14
PUSHBUTTON "Cancel",IDCANCEL,58,57,39,14
DEFPUSHBUTTON "OK",IDOK,15,57,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
PUSHBUTTON "Cancel",IDCANCEL,58,57,REPOS_BUTTON_WIDTH,REPOS_BUTTON_HT
END
#endif