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:
ehouse 2008-05-10 15:42:52 +00:00
parent ebad668227
commit e178b7ccf5
7 changed files with 96 additions and 93 deletions

View file

@ -181,9 +181,7 @@ EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
switch (message) {
case WM_VSCROLL:
if ( !IS_SMARTPHONE(eState->globals) ) {
ceDoDlgScroll( hDlg, wParam );
}
ceDoDlgScroll( eState->globals, hDlg, wParam );
break;
case WM_PAINT: {
@ -424,13 +422,11 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
switch (message) {
case WM_VSCROLL:
if ( !IS_SMARTPHONE(state->globals) ) {
ceDoDlgScroll( hDlg, wParam );
}
ceDoDlgScroll( state->globals, hDlg, wParam );
break;
case WM_DRAWITEM: /* passed when button has BS_OWNERDRAW style */
ceDoDlgFocusScroll( hDlg,
ceDoDlgFocusScroll( state->globals, hDlg,
/* Fake out ceDoDlgFocusScroll, passing ctrl itself */
(WPARAM)((DRAWITEMSTRUCT*)lParam)->hwndItem,
(LPARAM)TRUE );

View file

@ -523,17 +523,12 @@ GameInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
switch (message) {
case WM_VSCROLL:
if ( !IS_SMARTPHONE(globals) ) {
ceDoDlgScroll( hDlg, wParam );
result = TRUE;
}
result = ceDoDlgScroll( globals, hDlg, wParam );
break;
/* WM_NEXTDLGCTL is worthless; prev obj still has focus */
case WM_NEXTDLGCTL:
if ( !IS_SMARTPHONE(globals) ) {
ceDoDlgFocusScroll( hDlg, wParam, lParam );
}
ceDoDlgFocusScroll( globals, hDlg, wParam, lParam );
break;
#ifdef OWNERDRAW_JUGGLE

View file

@ -272,15 +272,11 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
switch (message) {
case WM_VSCROLL:
if ( !IS_SMARTPHONE(globals) ) {
ceDoDlgScroll( hDlg, wParam );
}
ceDoDlgScroll( globals, hDlg, wParam );
break;
case WM_NEXTDLGCTL:
if ( !IS_SMARTPHONE(globals) ) {
ceDoDlgFocusScroll( hDlg, wParam, lParam );
}
ceDoDlgFocusScroll( globals, hDlg, wParam, lParam );
break;
case WM_COMMAND:

View file

@ -90,9 +90,7 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
switch (message) {
case WM_VSCROLL:
if ( !IS_SMARTPHONE(globals) ) {
ceDoDlgScroll( hDlg, wParam );
}
ceDoDlgScroll( globals, hDlg, wParam );
break;
case WM_COMMAND:

View file

@ -284,15 +284,11 @@ SavedGamesDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
switch (message) {
case WM_VSCROLL:
if ( !IS_SMARTPHONE(state->globals) ) {
ceDoDlgScroll( hDlg, wParam );
}
ceDoDlgScroll( state->globals, hDlg, wParam );
break;
case WM_NEXTDLGCTL:
if ( !IS_SMARTPHONE(state->globals) ) {
ceDoDlgFocusScroll( hDlg, wParam, lParam );
}
ceDoDlgFocusScroll( state->globals, hDlg, wParam, lParam );
break;
case WM_COMMAND:

View file

@ -294,13 +294,26 @@ static XP_Bool
mkFullscreenWithSoftkeys( CEAppGlobals* globals, HWND hDlg )
{
XP_Bool success = XP_FALSE;
SHMENUBARINFO mbi;
XP_Bool fullScreen = XP_TRUE; /* probably want this TRUE for
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 );
success = XP_TRUE;
}
if ( success ) {
SHMENUBARINFO mbi;
XP_MEMSET( &mbi, 0, sizeof(mbi) );
mbi.cbSize = sizeof(mbi);
mbi.hwndParent = hDlg;
@ -310,6 +323,8 @@ mkFullscreenWithSoftkeys( CEAppGlobals* globals, HWND hDlg )
if ( !success ) {
XP_LOGF( "SHCreateMenuBar failed: %ld", GetLastError() );
}
}
return success;
} /* mkFullscreenWithSoftkeys */
#endif
@ -414,9 +429,11 @@ adjustScrollPos( HWND hDlg, XP_S16 vertChange )
LOG_RETURN_VOID();
} /* adjustScrollPos */
void
ceDoDlgScroll( HWND hDlg, WPARAM wParam )
XP_Bool
ceDoDlgScroll( CEAppGlobals* globals, HWND hDlg, WPARAM wParam )
{
XP_Bool handled = !IS_SMARTPHONE(globals);
if ( handled ) {
XP_S16 vertChange = 0;
switch ( LOWORD(wParam) ) {
@ -444,6 +461,8 @@ ceDoDlgScroll( HWND hDlg, WPARAM wParam )
if ( 0 != vertChange ) {
adjustScrollPos( hDlg, vertChange );
}
}
return handled;
} /* ceDoDlgScroll */
@ -462,7 +481,7 @@ ceDoDlgScroll( HWND hDlg, WPARAM wParam )
style receives the focus. */
void
ceDoDlgFocusScroll( HWND hDlg, WPARAM wParam, LPARAM lParam )
ceDoDlgFocusScroll( CEAppGlobals* globals, HWND hDlg, WPARAM wParam, LPARAM lParam )
{
/* Scroll the current focus owner into view.
*
@ -480,6 +499,7 @@ ceDoDlgFocusScroll( HWND hDlg, WPARAM wParam, LPARAM lParam )
* scrolling to see how to fix it.
*/
if ( !IS_SMARTPHONE(globals) ) {
HWND nextCtrl;
if ( LOWORD(lParam) ) {
nextCtrl = (HWND)wParam;
@ -515,6 +535,7 @@ ceDoDlgFocusScroll( HWND hDlg, WPARAM wParam, LPARAM lParam )
setScrollPos( hDlg, ctrlPos - ctrlHeight );
}
}
}
} /* ceDoDlgFocusScroll */
static XP_Bool

View file

@ -50,8 +50,9 @@ void ceDlgSetup( CEAppGlobals* globals, HWND hDlg );
XP_Bool ceIsLandscape( CEAppGlobals* globals );
void ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 id );
void ceDoDlgScroll( HWND hDlg, WPARAM wParam );
void ceDoDlgFocusScroll( HWND hDlg, WPARAM wParam, LPARAM lParam );
XP_Bool ceDoDlgScroll( CEAppGlobals* globals, HWND hDlg, WPARAM wParam );
void ceDoDlgFocusScroll( CEAppGlobals* globals, HWND hDlg,
WPARAM wParam, LPARAM lParam );
#ifdef _WIN32_WCE
void ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd );
#else