Don't subtract command bar height from client rect height on

smartphone.  This prevents windows from being too small in
non-fullscreen mode.  Make ceSizeIfFullscreen work based on state
rather than assuming it's toggling.
This commit is contained in:
ehouse 2008-03-15 18:32:22 +00:00
parent cae88f5b6c
commit b7f35d2958
3 changed files with 59 additions and 27 deletions

View file

@ -1227,7 +1227,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow)
} }
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
if ( globals->hwndCB ) { if ( globals->hwndCB && !IS_SMARTPHONE(globals) ) {
RECT rc, rcmb; RECT rc, rcmb;
GetWindowRect( hWnd, &rc ); GetWindowRect( hWnd, &rc );

View file

@ -40,6 +40,8 @@ typedef enum {
, WINCE_SMARTPHONE_2003 , WINCE_SMARTPHONE_2003
, WINCE_SMARTPHONE_2005 , WINCE_SMARTPHONE_2005
} XW_WinceVersion; } XW_WinceVersion;
# define IS_SMARTPHONE(g) ((g)->winceVersion > _LAST_PPC)
#endif #endif
enum { CE_BONUS1_COLOR, enum { CE_BONUS1_COLOR,

View file

@ -249,9 +249,35 @@ ceIsVisible( HWND XP_UNUSED_CE(hwnd) )
} /* ceIsVisible */ } /* ceIsVisible */
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
static XP_Bool
ceIsFullScreen( CEAppGlobals* globals, HWND hWnd )
{
XP_S16 screenHt;
XP_U16 winHt;
RECT rect;
GetClientRect( hWnd, &rect );
winHt = rect.bottom - rect.top; /* top should always be 0 */
screenHt = GetSystemMetrics( SM_CYSCREEN );
XP_ASSERT( screenHt >= winHt );
screenHt -= winHt;
if ( !!globals->hwndCB ) {
RECT rect;
GetWindowRect( globals->hwndCB, &rect );
screenHt -= rect.bottom - rect.top;
}
XP_ASSERT( screenHt >= 0 );
return screenHt == 0;
} /* ceIsFullScreen */
void void
ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd ) ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd )
{ {
if ( globals->appPrefs.fullScreen != ceIsFullScreen(globals, hWnd) ) {
RECT rect; RECT rect;
XP_U16 cbHeight = 0; XP_U16 cbHeight = 0;
if ( !!globals->hwndCB && hWnd == globals->hWnd ) { if ( !!globals->hwndCB && hWnd == globals->hWnd ) {
@ -259,25 +285,29 @@ ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd )
cbHeight = rect.bottom - rect.top; cbHeight = rect.bottom - rect.top;
} }
/* I'm leaving the SIP/cmdbar in place until I can figure out how to get /* I'm leaving the SIP/cmdbar in place until I can figure out how to
menu events with it hidden -- and also the UI for making sure users get menu events with it hidden -- and also the UI for making sure
don't get stuck in fullscreen mode not knowing how to reach menus to users don't get stuck in fullscreen mode not knowing how to reach
get out. Later, add SHFS_SHOWSIPBUTTON and SHFS_HIDESIPBUTTON to the menus to get out. Later, add SHFS_SHOWSIPBUTTON and
sets shown and hidden below.*/ SHFS_HIDESIPBUTTON to the sets shown and hidden below.*/
if ( globals->appPrefs.fullScreen ) { if ( globals->appPrefs.fullScreen ) {
SHFullScreen( hWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON );
SystemParametersInfo( SPI_GETWORKAREA, 0, &rect, FALSE );
} else {
SHFullScreen( hWnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON ); SHFullScreen( hWnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON );
SetRect( &rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), SetRect( &rect, 0, 0, GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN) ); GetSystemMetrics(SM_CYSCREEN) );
} else {
SHFullScreen( hWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON );
SystemParametersInfo( SPI_GETWORKAREA, 0, &rect, FALSE );
if ( IS_SMARTPHONE(globals) ) {
cbHeight = 0;
}
} }
rect.bottom -= cbHeight; rect.bottom -= cbHeight;
MoveWindow( hWnd, rect.left, rect.top, rect.right - rect.left, MoveWindow( hWnd, rect.left, rect.top, rect.right - rect.left,
rect.bottom - rect.top, TRUE ); rect.bottom - rect.top, TRUE );
}
} /* ceSizeIfFullscreen */ } /* ceSizeIfFullscreen */
static XP_Bool static XP_Bool
@ -298,7 +328,7 @@ mkFullscreenWithSoftkeys( CEAppGlobals* globals, HWND hDlg )
mbi.hInstRes = globals->hInst; mbi.hInstRes = globals->hInst;
success = SHCreateMenuBar( &mbi ); success = SHCreateMenuBar( &mbi );
if ( !success ) { if ( !success ) {
XP_LOGF( "SHCreateMenuBar failed" ); XP_LOGF( "SHCreateMenuBar failed: %ld", GetLastError() );
} }
return success; return success;
} /* mkFullscreenWithSoftkeys */ } /* mkFullscreenWithSoftkeys */