From be219b71f2524ca13fcd1dc1b6c3950f7528d2d9 Mon Sep 17 00:00:00 2001 From: ehouse Date: Fri, 1 Aug 2008 10:37:52 +0000 Subject: [PATCH] fix scrollbars now that I finally understand what nPage is supposed to be. --- xwords4/wince/cemain.c | 17 +++++++---------- xwords4/wince/ceutil.c | 23 ++++++++--------------- xwords4/wince/ceutil.h | 1 + 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index 9d112e089..c9a3a48b8 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -360,19 +360,17 @@ ceInitUtilFuncs( CEAppGlobals* globals ) # define SCROLL_SHRINK 1 static void -updateScrollInfo( HWND hwnd, XP_U16 nHidden ) +updateScrollInfo( CEAppGlobals* globals, XP_U16 nHidden ) { SCROLLINFO sinfo; XP_MEMSET( &sinfo, 0, sizeof(sinfo) ); sinfo.cbSize = sizeof(sinfo); sinfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; - sinfo.nPos = 0; - sinfo.nMin = 0; - sinfo.nMax = nHidden; - sinfo.nPage = 1; + sinfo.nMax = model_numRows( globals->game.model ); + sinfo.nPage = sinfo.nMax - nHidden + 1; - (void)SetScrollInfo( hwnd, SB_CTL, &sinfo, TRUE ); + (void)SetScrollInfo( globals->scrollHandle, SB_CTL, &sinfo, TRUE ); } static void @@ -398,11 +396,10 @@ showScroller( CEAppGlobals* globals, XP_U16 nHidden, XP_U16 x, XP_U16 y, globals->hInst, // The instance handle NULL ); // s'pposed to be NULL - updateScrollInfo( hwndSB, nHidden ); + globals->scrollHandle = hwndSB; + updateScrollInfo( globals, nHidden ); EnableWindow( hwndSB, nHidden > 0 ); - - globals->scrollHandle = hwndSB; } ShowWindow( globals->scrollHandle, SW_SHOW ); @@ -2831,7 +2828,7 @@ ce_util_trayHiddenChange( XW_UtilCtxt* uc, XW_TrayVisState XP_UNUSED(newState), if ( !!globals->scrollHandle ) { nHiddenRows = model_numRows( globals->game.model ) - nVisibleRows; - updateScrollInfo( globals->scrollHandle, nHiddenRows ); + updateScrollInfo( globals, nHiddenRows ); } #endif diff --git a/xwords4/wince/ceutil.c b/xwords4/wince/ceutil.c index 5a5bf2d9e..f7278f884 100755 --- a/xwords4/wince/ceutil.c +++ b/xwords4/wince/ceutil.c @@ -349,7 +349,7 @@ void ceDlgSetup( CeDlgHdr* dlgHdr, HWND hDlg, DlgStateTask doWhat ) { RECT rect; - XP_U16 vHeight; + XP_U16 fullHeight; CEAppGlobals* globals = dlgHdr->globals; dlgHdr->hDlg = hDlg; @@ -359,10 +359,10 @@ ceDlgSetup( CeDlgHdr* dlgHdr, HWND hDlg, DlgStateTask doWhat ) GetClientRect( hDlg, &rect ); XP_ASSERT( rect.top == 0 ); - vHeight = rect.bottom; /* This is before we've resized it */ + fullHeight = rect.bottom; /* This is before we've resized it */ #ifdef _WIN32_WCE - (void)mkFullscreenWithSoftkeys( globals, hDlg, vHeight, + (void)mkFullscreenWithSoftkeys( globals, hDlg, fullHeight, (doWhat & DLG_STATE_DONEONLY) != 0); #elif defined DEBUG /* Force it to be small so we can test scrolling etc. */ @@ -379,21 +379,14 @@ ceDlgSetup( CeDlgHdr* dlgHdr, HWND hDlg, DlgStateTask doWhat ) if ( !IS_SMARTPHONE(globals) ) { SCROLLINFO sinfo; - XP_LOGF( "%s: vHeight: %d; r.bottom: %ld", __func__, vHeight, - rect.bottom ); - XP_MEMSET( &sinfo, 0, sizeof(sinfo) ); sinfo.cbSize = sizeof(sinfo); sinfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; - sinfo.nPos = 0; - sinfo.nMin = 0; - sinfo.nMax = vHeight - rect.bottom; - if ( sinfo.nMax < 0 ) { - sinfo.nMax = 0; /* disables the thing! */ + if ( rect.bottom < fullHeight ) { + sinfo.nMax = fullHeight; + dlgHdr->nPage = sinfo.nPage = rect.bottom - 1; } - XP_LOGF( "%s: set max to %d", __func__, sinfo.nMax ); - sinfo.nPage = 10; (void)SetScrollInfo( hDlg, SB_VERT, &sinfo, FALSE ); } @@ -494,14 +487,14 @@ ceDoDlgScroll( CeDlgHdr* dlgHdr, WPARAM wParam ) vertChange = -1; break; case SB_PAGEUP: // - vertChange = -10; + vertChange = -dlgHdr->nPage; break; case SB_LINEDOWN: // Scrolls one line down vertChange = 1; break; case SB_PAGEDOWN: // Scrolls one page down - vertChange = 10; + vertChange = dlgHdr->nPage; break; case SB_THUMBTRACK: /* still dragging; don't redraw */ diff --git a/xwords4/wince/ceutil.h b/xwords4/wince/ceutil.h index cab824411..ce9fd34c2 100755 --- a/xwords4/wince/ceutil.h +++ b/xwords4/wince/ceutil.h @@ -54,6 +54,7 @@ typedef struct CeDlgHdr { /* Below this line is private to ceutil.c */ DlgStateTask doWhat; + XP_U16 nPage; } CeDlgHdr; void ceDlgSetup( CeDlgHdr* dlgHdr, HWND hDlg, DlgStateTask doWhat ); XP_Bool ceDoDlgHandle( CeDlgHdr* dlgHdr, UINT message, WPARAM wParam, LPARAM lParam);