diff --git a/xwords4/wince/cedraw.c b/xwords4/wince/cedraw.c index e3056f142..42c763e1a 100755 --- a/xwords4/wince/cedraw.c +++ b/xwords4/wince/cedraw.c @@ -1587,11 +1587,23 @@ ce_draw_update( CEDrawCtx* dctx ) } } /* ce_drawctxt_update */ +static void +drawColoredRect( CEDrawCtx* dctx, const RECT* invalR, XP_U16 index ) +{ + CEAppGlobals* globals = dctx->globals; + FillRect( globals->hdc, invalR, dctx->brushes[index] ); +} + void ce_draw_erase( CEDrawCtx* dctx, const RECT* invalR ) { - CEAppGlobals* globals = dctx->globals; - FillRect( globals->hdc, invalR, dctx->brushes[CE_BKG_COLOR] ); + drawColoredRect( dctx, invalR, CE_BKG_COLOR ); +} + +void +ce_draw_focus( CEDrawCtx* dctx, const RECT* invalR ) +{ + drawColoredRect( dctx, invalR, CE_FOCUS_COLOR ); } CEDrawCtx* diff --git a/xwords4/wince/cedraw.h b/xwords4/wince/cedraw.h index 2868fb351..0e092bb85 100644 --- a/xwords4/wince/cedraw.h +++ b/xwords4/wince/cedraw.h @@ -27,6 +27,7 @@ typedef struct CEDrawCtx CEDrawCtx; CEDrawCtx* ce_drawctxt_make( MPFORMAL HWND mainWin, CEAppGlobals* globals ); void ce_draw_update( CEDrawCtx* dctx ); void ce_draw_erase( CEDrawCtx* dctx, const RECT* invalR ); +void ce_draw_focus( CEDrawCtx* dctx, const RECT* invalR ); void ce_draw_toStream( const CEDrawCtx* dctx, XWStreamCtxt* stream ); void ce_draw_fromStream( CEDrawCtx* dctx, XWStreamCtxt* stream ); diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index e6dcbc9aa..fcbc9aa4f 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -430,6 +430,19 @@ makeScrollbar( CEAppGlobals* globals, XP_U16 nHidden, XP_U16 xx, XP_U16 yy, XP_U16 width, XP_U16 height ) { HWND hwndSB; + RECT tmp = { .left = xx, .right = xx + width }; + XP_U16 rectHt = height / 10; /* each focus rect to be 1/10th height */ + + tmp.top = yy; + tmp.bottom = yy + rectHt; + XP_MEMCPY( &globals->scrollRects[0], &tmp, sizeof(globals->scrollRects[0]) ); + + tmp.bottom = yy + height; + tmp.top = tmp.bottom - rectHt; + XP_MEMCPY( &globals->scrollRects[1], &tmp, sizeof(globals->scrollRects[1]) ); + + yy += rectHt; + height -= rectHt * 2; /* above and below */ /* Need to destroy it, or resize it, because board size may be changing in case where portrait display's been flipped. */ @@ -442,10 +455,8 @@ makeScrollbar( CEAppGlobals* globals, XP_U16 nHidden, XP_U16 xx, XP_U16 yy, NULL, // Window text // Window style SBS_VERT|WS_VISIBLE|WS_CHILD, - xx + SCROLL_SHRINK, yy + 2, - width - SCROLL_SHRINK, height - 4, - globals->hWnd, - (HMENU)SCROLLBARID,// The control identifier + xx, yy, width, height, globals->hWnd, + (HMENU)SCROLLBARID, // The control identifier globals->hInst, // The instance handle NULL ); // s'pposed to be NULL @@ -1488,13 +1499,23 @@ drawInsidePaint( CEAppGlobals* globals, const RECT* invalR ) if ( !!invalR ) { XP_U16 ii; + RECT interR; for ( ii = 0; ii < N_OWNED_RECTS; ++ii ) { - RECT interR; if ( IntersectRect( &interR, invalR, &globals->ownedRects[ii] ) ) { ce_draw_erase( globals->draw, &interR ); } } + for ( ii = 0; ii < VSIZE(globals->scrollRects); ++ii ) { + if ( IntersectRect( &interR, invalR, + &globals->scrollRects[ii] ) ) { + if ( globals->scrollerHasFocus ) { + ce_draw_focus( globals->draw, &interR ); + } else { + ce_draw_erase( globals->draw, &interR ); + } + } + } } board_draw( globals->game.board ); @@ -2078,10 +2099,14 @@ ceCheckHandleFocusKey( CEAppGlobals* globals, WPARAM wParam, LPARAM lParam, draw = board_focusChanged( board, order[index], XP_TRUE ); if ( !!globals->scrollHandle ) { + InvalidateRect( globals->hWnd, &globals->scrollRects[0], TRUE ); + InvalidateRect( globals->hWnd, &globals->scrollRects[1], TRUE ); if ( order[index] == OBJ_NONE ) { SetFocus( globals->scrollHandle ); + globals->scrollerHasFocus = XP_TRUE; } else { SetFocus( globals->hWnd ); + globals->scrollerHasFocus = XP_FALSE; } } } diff --git a/xwords4/wince/cemain.h b/xwords4/wince/cemain.h index bffcbedfb..a9e1cca62 100755 --- a/xwords4/wince/cemain.h +++ b/xwords4/wince/cemain.h @@ -132,6 +132,8 @@ typedef struct CEAppGlobals { #ifdef CEFEATURE_CANSCROLL HWND scrollHandle; WNDPROC oldScrollProc; + RECT scrollRects[2]; /* above and below the scroller */ + XP_Bool scrollerHasFocus; #endif CeSocketWrapper* socketWrap;