mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
Use SHInitDialog on smartphone to create fullscreen dialogs. Move
test for smartphone into util functions so can't forget it. This fixes scrolling on smartphone.
This commit is contained in:
parent
8a6df572ae
commit
44186e220d
7 changed files with 96 additions and 93 deletions
|
@ -181,9 +181,7 @@ EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
switch (message) {
|
switch (message) {
|
||||||
|
|
||||||
case WM_VSCROLL:
|
case WM_VSCROLL:
|
||||||
if ( !IS_SMARTPHONE(eState->globals) ) {
|
ceDoDlgScroll( eState->globals, hDlg, wParam );
|
||||||
ceDoDlgScroll( hDlg, wParam );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_PAINT: {
|
case WM_PAINT: {
|
||||||
|
@ -424,13 +422,11 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
switch (message) {
|
switch (message) {
|
||||||
|
|
||||||
case WM_VSCROLL:
|
case WM_VSCROLL:
|
||||||
if ( !IS_SMARTPHONE(state->globals) ) {
|
ceDoDlgScroll( state->globals, hDlg, wParam );
|
||||||
ceDoDlgScroll( hDlg, wParam );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_DRAWITEM: /* passed when button has BS_OWNERDRAW style */
|
case WM_DRAWITEM: /* passed when button has BS_OWNERDRAW style */
|
||||||
ceDoDlgFocusScroll( hDlg,
|
ceDoDlgFocusScroll( state->globals, hDlg,
|
||||||
/* Fake out ceDoDlgFocusScroll, passing ctrl itself */
|
/* Fake out ceDoDlgFocusScroll, passing ctrl itself */
|
||||||
(WPARAM)((DRAWITEMSTRUCT*)lParam)->hwndItem,
|
(WPARAM)((DRAWITEMSTRUCT*)lParam)->hwndItem,
|
||||||
(LPARAM)TRUE );
|
(LPARAM)TRUE );
|
||||||
|
|
|
@ -523,17 +523,12 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
switch (message) {
|
switch (message) {
|
||||||
|
|
||||||
case WM_VSCROLL:
|
case WM_VSCROLL:
|
||||||
if ( !IS_SMARTPHONE(globals) ) {
|
result = ceDoDlgScroll( globals, hDlg, wParam );
|
||||||
ceDoDlgScroll( hDlg, wParam );
|
|
||||||
result = TRUE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* WM_NEXTDLGCTL is worthless; prev obj still has focus */
|
/* WM_NEXTDLGCTL is worthless; prev obj still has focus */
|
||||||
case WM_NEXTDLGCTL:
|
case WM_NEXTDLGCTL:
|
||||||
if ( !IS_SMARTPHONE(globals) ) {
|
ceDoDlgFocusScroll( globals, hDlg, wParam, lParam );
|
||||||
ceDoDlgFocusScroll( hDlg, wParam, lParam );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef OWNERDRAW_JUGGLE
|
#ifdef OWNERDRAW_JUGGLE
|
||||||
|
|
|
@ -272,15 +272,11 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_VSCROLL:
|
case WM_VSCROLL:
|
||||||
if ( !IS_SMARTPHONE(globals) ) {
|
ceDoDlgScroll( globals, hDlg, wParam );
|
||||||
ceDoDlgScroll( hDlg, wParam );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NEXTDLGCTL:
|
case WM_NEXTDLGCTL:
|
||||||
if ( !IS_SMARTPHONE(globals) ) {
|
ceDoDlgFocusScroll( globals, hDlg, wParam, lParam );
|
||||||
ceDoDlgFocusScroll( hDlg, wParam, lParam );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
|
|
@ -90,9 +90,7 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
switch (message) {
|
switch (message) {
|
||||||
|
|
||||||
case WM_VSCROLL:
|
case WM_VSCROLL:
|
||||||
if ( !IS_SMARTPHONE(globals) ) {
|
ceDoDlgScroll( globals, hDlg, wParam );
|
||||||
ceDoDlgScroll( hDlg, wParam );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
|
|
@ -284,15 +284,11 @@ SavedGamesDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
switch (message) {
|
switch (message) {
|
||||||
|
|
||||||
case WM_VSCROLL:
|
case WM_VSCROLL:
|
||||||
if ( !IS_SMARTPHONE(state->globals) ) {
|
ceDoDlgScroll( state->globals, hDlg, wParam );
|
||||||
ceDoDlgScroll( hDlg, wParam );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NEXTDLGCTL:
|
case WM_NEXTDLGCTL:
|
||||||
if ( !IS_SMARTPHONE(state->globals) ) {
|
ceDoDlgFocusScroll( state->globals, hDlg, wParam, lParam );
|
||||||
ceDoDlgFocusScroll( hDlg, wParam, lParam );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
|
145
wince/ceutil.c
145
wince/ceutil.c
|
@ -294,22 +294,37 @@ static XP_Bool
|
||||||
mkFullscreenWithSoftkeys( CEAppGlobals* globals, HWND hDlg )
|
mkFullscreenWithSoftkeys( CEAppGlobals* globals, HWND hDlg )
|
||||||
{
|
{
|
||||||
XP_Bool success = XP_FALSE;
|
XP_Bool success = XP_FALSE;
|
||||||
SHMENUBARINFO mbi;
|
|
||||||
XP_Bool fullScreen = XP_TRUE; /* probably want this TRUE for
|
XP_Bool fullScreen = XP_TRUE; /* probably want this TRUE for
|
||||||
small-screened smartphones only. */
|
small-screened smartphones only. */
|
||||||
if ( fullScreen ) {
|
|
||||||
|
if ( IS_SMARTPHONE(globals) ) {
|
||||||
|
SHINITDLGINFO info;
|
||||||
|
XP_MEMSET( &info, 0, sizeof(info) );
|
||||||
|
info.dwMask = SHIDIM_FLAGS;
|
||||||
|
info.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
|
||||||
|
info.hDlg = hDlg;
|
||||||
|
success = SHInitDialog( &info );
|
||||||
|
if ( !success ) {
|
||||||
|
XP_LOGF( "SHInitDialog failed: %ld", GetLastError() );
|
||||||
|
}
|
||||||
|
} else if ( fullScreen ) {
|
||||||
ceSizeIfFullscreen( globals, hDlg );
|
ceSizeIfFullscreen( globals, hDlg );
|
||||||
|
success = XP_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
XP_MEMSET( &mbi, 0, sizeof(mbi) );
|
if ( success ) {
|
||||||
mbi.cbSize = sizeof(mbi);
|
SHMENUBARINFO mbi;
|
||||||
mbi.hwndParent = hDlg;
|
XP_MEMSET( &mbi, 0, sizeof(mbi) );
|
||||||
mbi.nToolBarId = IDM_OKCANCEL_MENUBAR;
|
mbi.cbSize = sizeof(mbi);
|
||||||
mbi.hInstRes = globals->hInst;
|
mbi.hwndParent = hDlg;
|
||||||
success = SHCreateMenuBar( &mbi );
|
mbi.nToolBarId = IDM_OKCANCEL_MENUBAR;
|
||||||
if ( !success ) {
|
mbi.hInstRes = globals->hInst;
|
||||||
XP_LOGF( "SHCreateMenuBar failed: %ld", GetLastError() );
|
success = SHCreateMenuBar( &mbi );
|
||||||
|
if ( !success ) {
|
||||||
|
XP_LOGF( "SHCreateMenuBar failed: %ld", GetLastError() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
} /* mkFullscreenWithSoftkeys */
|
} /* mkFullscreenWithSoftkeys */
|
||||||
#endif
|
#endif
|
||||||
|
@ -414,36 +429,40 @@ adjustScrollPos( HWND hDlg, XP_S16 vertChange )
|
||||||
LOG_RETURN_VOID();
|
LOG_RETURN_VOID();
|
||||||
} /* adjustScrollPos */
|
} /* adjustScrollPos */
|
||||||
|
|
||||||
void
|
XP_Bool
|
||||||
ceDoDlgScroll( HWND hDlg, WPARAM wParam )
|
ceDoDlgScroll( CEAppGlobals* globals, HWND hDlg, WPARAM wParam )
|
||||||
{
|
{
|
||||||
XP_S16 vertChange = 0;
|
XP_Bool handled = !IS_SMARTPHONE(globals);
|
||||||
|
if ( handled ) {
|
||||||
|
XP_S16 vertChange = 0;
|
||||||
|
|
||||||
switch ( LOWORD(wParam) ) {
|
switch ( LOWORD(wParam) ) {
|
||||||
|
|
||||||
case SB_LINEUP: // Scrolls one line up
|
case SB_LINEUP: // Scrolls one line up
|
||||||
vertChange = -1;
|
vertChange = -1;
|
||||||
break;
|
break;
|
||||||
case SB_PAGEUP: //
|
case SB_PAGEUP: //
|
||||||
vertChange = -10;
|
vertChange = -10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_LINEDOWN: // Scrolls one line down
|
case SB_LINEDOWN: // Scrolls one line down
|
||||||
vertChange = 1;
|
vertChange = 1;
|
||||||
break;
|
break;
|
||||||
case SB_PAGEDOWN: // Scrolls one page down
|
case SB_PAGEDOWN: // Scrolls one page down
|
||||||
vertChange = 10;
|
vertChange = 10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SB_THUMBTRACK: /* still dragging; don't redraw */
|
case SB_THUMBTRACK: /* still dragging; don't redraw */
|
||||||
case SB_THUMBPOSITION:
|
case SB_THUMBPOSITION:
|
||||||
setScrollPos( hDlg, HIWORD(wParam) );
|
setScrollPos( hDlg, HIWORD(wParam) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 != vertChange ) {
|
if ( 0 != vertChange ) {
|
||||||
adjustScrollPos( hDlg, vertChange );
|
adjustScrollPos( hDlg, vertChange );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return handled;
|
||||||
} /* ceDoDlgScroll */
|
} /* ceDoDlgScroll */
|
||||||
|
|
||||||
|
|
||||||
|
@ -462,7 +481,7 @@ ceDoDlgScroll( HWND hDlg, WPARAM wParam )
|
||||||
style receives the focus. */
|
style receives the focus. */
|
||||||
|
|
||||||
void
|
void
|
||||||
ceDoDlgFocusScroll( HWND hDlg, WPARAM wParam, LPARAM lParam )
|
ceDoDlgFocusScroll( CEAppGlobals* globals, HWND hDlg, WPARAM wParam, LPARAM lParam )
|
||||||
{
|
{
|
||||||
/* Scroll the current focus owner into view.
|
/* Scroll the current focus owner into view.
|
||||||
*
|
*
|
||||||
|
@ -480,39 +499,41 @@ ceDoDlgFocusScroll( HWND hDlg, WPARAM wParam, LPARAM lParam )
|
||||||
* scrolling to see how to fix it.
|
* scrolling to see how to fix it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HWND nextCtrl;
|
if ( !IS_SMARTPHONE(globals) ) {
|
||||||
if ( LOWORD(lParam) ) {
|
HWND nextCtrl;
|
||||||
nextCtrl = (HWND)wParam;
|
if ( LOWORD(lParam) ) {
|
||||||
} else {
|
nextCtrl = (HWND)wParam;
|
||||||
BOOL previous = wParam != 0;
|
} else {
|
||||||
nextCtrl = GetNextDlgTabItem( hDlg, GetFocus(), previous );
|
BOOL previous = wParam != 0;
|
||||||
}
|
nextCtrl = GetNextDlgTabItem( hDlg, GetFocus(), previous );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !!nextCtrl ) {
|
if ( !!nextCtrl ) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
XP_U16 dlgHeight, ctrlHeight, dlgTop;
|
XP_U16 dlgHeight, ctrlHeight, dlgTop;
|
||||||
XP_S16 ctrlPos;
|
XP_S16 ctrlPos;
|
||||||
|
|
||||||
GetClientRect( hDlg, &rect );
|
GetClientRect( hDlg, &rect );
|
||||||
dlgHeight = rect.bottom - rect.top;
|
dlgHeight = rect.bottom - rect.top;
|
||||||
XP_LOGF( "dlgHeight: %d", dlgHeight );
|
XP_LOGF( "dlgHeight: %d", dlgHeight );
|
||||||
|
|
||||||
GetWindowRect( hDlg, &rect );
|
GetWindowRect( hDlg, &rect );
|
||||||
dlgTop = rect.top;
|
dlgTop = rect.top;
|
||||||
|
|
||||||
GetWindowRect( nextCtrl, &rect );
|
GetWindowRect( nextCtrl, &rect );
|
||||||
ctrlPos = rect.top - dlgTop - TITLE_HT;
|
ctrlPos = rect.top - dlgTop - TITLE_HT;
|
||||||
ctrlHeight = rect.bottom - rect.top;
|
ctrlHeight = rect.bottom - rect.top;
|
||||||
|
|
||||||
XP_LOGF( "%p: ctrlPos is %d; height is %d",
|
XP_LOGF( "%p: ctrlPos is %d; height is %d",
|
||||||
nextCtrl, ctrlPos, ctrlHeight );
|
nextCtrl, ctrlPos, ctrlHeight );
|
||||||
|
|
||||||
if ( ctrlPos < 0 ) {
|
if ( ctrlPos < 0 ) {
|
||||||
XP_LOGF( "need to scroll it DOWN into view" );
|
XP_LOGF( "need to scroll it DOWN into view" );
|
||||||
adjustScrollPos( hDlg, ctrlPos );
|
adjustScrollPos( hDlg, ctrlPos );
|
||||||
} else if ( (ctrlPos + ctrlHeight) > dlgHeight ) {
|
} else if ( (ctrlPos + ctrlHeight) > dlgHeight ) {
|
||||||
XP_LOGF( "need to scroll it UP into view" );
|
XP_LOGF( "need to scroll it UP into view" );
|
||||||
setScrollPos( hDlg, ctrlPos - ctrlHeight );
|
setScrollPos( hDlg, ctrlPos - ctrlHeight );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* ceDoDlgFocusScroll */
|
} /* ceDoDlgFocusScroll */
|
||||||
|
|
|
@ -50,8 +50,9 @@ void ceDlgSetup( CEAppGlobals* globals, HWND hDlg );
|
||||||
XP_Bool ceIsLandscape( CEAppGlobals* globals );
|
XP_Bool ceIsLandscape( CEAppGlobals* globals );
|
||||||
|
|
||||||
void ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 id );
|
void ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 id );
|
||||||
void ceDoDlgScroll( HWND hDlg, WPARAM wParam );
|
XP_Bool ceDoDlgScroll( CEAppGlobals* globals, HWND hDlg, WPARAM wParam );
|
||||||
void ceDoDlgFocusScroll( HWND hDlg, WPARAM wParam, LPARAM lParam );
|
void ceDoDlgFocusScroll( CEAppGlobals* globals, HWND hDlg,
|
||||||
|
WPARAM wParam, LPARAM lParam );
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
void ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd );
|
void ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd );
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue