void FMEDITAPI UpdateScroll( void ) /*********************************/ { RECT newrect; RECT clrect; POINT offset; HWND wnd; if( GetScrollConfig() == SCROLL_NONE ) { return; } wnd = GetAppWnd(); GetClientRect( wnd, &clrect ); newrect = clrect; RequestScrollRect( &newrect ); SetScrollRect( newrect ); GetOffset( &offset ); if( GetScrollConfig() & SCROLL_HORZ ) { SetScrollRange( wnd, SB_HORZ, newrect.left, newrect.right - clrect.right, FALSE ); SetScrollPos( wnd, SB_HORZ, offset.x, TRUE ); } if( GetScrollConfig() & SCROLL_VERT ) { SetScrollRange( wnd, SB_VERT, newrect.top, newrect.bottom - clrect.bottom, FALSE ); SetScrollPos( wnd, SB_VERT, offset.y, TRUE ); } }
static void DoScroll( HWND wnd, int dx, int dy, BOOL lock ) /*********************************************************/ { /* scroll 'wnd' by 'dx' and 'dy'. 'lock' says to lock the scrolling on the */ /* bottom and right into the scrolling rectangle */ POINT offset; RECT srect; GetOffset( &offset ); GetScrollBounds( &srect, lock ); dx = AdjustScroll( offset.x, srect.left, srect.right, dx ); dy = AdjustScroll( offset.y, srect.top, srect.bottom, dy ); if( dx != 0 || dy != 0 ) { offset.x += dx; offset.y += dy; SetOffset( offset ); ScrollWindow( wnd, -dx, -dy, NULL, NULL ); if( GetScrollConfig() & SCROLL_HORZ ) { SetScrollPos( wnd, SB_HORZ, offset.x, TRUE ); } if( GetScrollConfig() & SCROLL_VERT ) { SetScrollPos( wnd, SB_VERT, offset.y, TRUE ); } } }
extern void ScrollResize( HWND wnd, WPARAM lparam ) /*************************************************/ { RECT newrect; POINT offset; RECT clrect; if( GetScrollConfig() == SCROLL_NONE ) { return; } clrect.left = 0; clrect.top = 0; clrect.right = LOWORD( lparam ); clrect.bottom = HIWORD( lparam ); newrect = clrect; RequestScrollRect( &newrect ); SetScrollRect( newrect ); GetOffset( &offset ); if( GetScrollConfig() & SCROLL_HORZ ) { SetScrollRange( wnd, SB_HORZ, newrect.left, newrect.right - clrect.right, FALSE ); SetScrollPos( wnd, SB_HORZ, offset.x, TRUE ); } if( GetScrollConfig() & SCROLL_VERT ) { SetScrollRange( wnd, SB_VERT, newrect.top, newrect.bottom - clrect.bottom, FALSE ); SetScrollPos( wnd, SB_VERT, offset.y, TRUE ); } }
extern void AutoScroll( RECT eatom, POINT delta ) /***********************************************/ { POINT offset; RECT clrect; HWND wnd; int xdel; int ydel; POINT mouse; eatom = eatom; /* ref'd to avoid warnings */ if( GetScrollConfig() == SCROLL_NONE ) { return; } wnd = GetAppWnd(); GetClientRect( wnd, &clrect ); GetOffset( &offset ); OffsetRect( &clrect, offset.x, offset.y ); xdel = 0; ydel = 0; mouse = GetPrevMouse(); mouse.x += delta.x; mouse.y += delta.y; if( (delta.x > 0 && (abs( mouse.x - clrect.right ) < GetHorizontalInc() || mouse.x > clrect.right)) || (delta.x < 0 && (abs( mouse.x - clrect.left ) < GetHorizontalInc() || mouse.x < clrect.left)) ) { xdel = delta.x; if( xdel > 0 ) { xdel = __max( 1, (xdel * SLOW_DOWN_N) / SLOW_DOWN_D ); } else { xdel = __min( -1, (xdel * SLOW_DOWN_N) / SLOW_DOWN_D ); } } if( (delta.y > 0 && (abs( mouse.y - clrect.bottom ) < GetVerticalInc() || mouse.y > clrect.bottom)) || (delta.y < 0 && (abs( mouse.y - clrect.top ) < GetVerticalInc() || mouse.y < clrect.top)) ) { ydel = delta.y; if( ydel > 0 ) { ydel = __max( 1, (ydel * SLOW_DOWN_N) / SLOW_DOWN_D ); } else { ydel = __min( -1, (ydel * SLOW_DOWN_N) / SLOW_DOWN_D ); } } if( !(GetScrollConfig() & SCROLL_VERT) ) { ydel = 0; } if( !(GetScrollConfig() & SCROLL_HORZ) ) { xdel = 0; } DoScroll( wnd, xdel, ydel, TRUE ); UpdateWindow( wnd ); }
extern void VerticalScroll( WPARAM wparam, LPARAM lparam, HWND wnd ) /******************************************************************/ { int ydel; RECT clrect; POINT offset; RECT scrollrect; wparam = wparam; lparam = lparam; if( !(GetScrollConfig() & SCROLL_VERT) ) { return; } GetClientRect( GetAppWnd(), &clrect ); scrollrect = GetScrollRect(); ydel = 0; GetOffset( &offset ); switch( LOWORD( wparam ) ) { case SB_BOTTOM: ydel = scrollrect.bottom - offset.y - clrect.bottom; break; case SB_LINEDOWN: ydel = LN_SC_AMOUNT; break; case SB_LINEUP: ydel = -LN_SC_AMOUNT; break; case SB_PAGEDOWN: ydel = (long)clrect.bottom * PG_SC_PERCENT / 100; break; case SB_PAGEUP: ydel = -((long)clrect.bottom * PG_SC_PERCENT / 100); break; case SB_THUMBPOSITION: //ydel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.y - clrect.bottom; ydel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.y; break; case SB_TOP: ydel = -offset.y; break; default: break; } // make sure we do not expose area's not in the scroll rect if( clrect.bottom <= scrollrect.bottom && clrect.top >= scrollrect.top ) { if( ydel ) { if( clrect.bottom + offset.y + ydel > scrollrect.bottom ) { ydel = scrollrect.bottom - clrect.bottom - offset.y; } } else { if( clrect.top + offset.y + ydel < scrollrect.top ) { ydel = clrect.top + offset.y - scrollrect.top; } } } DoScroll( wnd, 0, ydel, TRUE ); }
extern void HorizontalScroll( WPARAM wparam, LPARAM lparam, HWND wnd ) /********************************************************************/ { int xdel; RECT clrect; POINT offset; RECT scrollrect; wparam = wparam; lparam = lparam; if( !(GetScrollConfig() & SCROLL_HORZ) ) { return; } GetClientRect( GetAppWnd(), &clrect ); scrollrect = GetScrollRect(); xdel = 0; GetOffset( &offset ); switch( LOWORD( wparam ) ) { case SB_BOTTOM: xdel = scrollrect.right - offset.x - clrect.right; break; case SB_LINEDOWN: xdel = LN_SC_AMOUNT; break; case SB_LINEUP: xdel = -LN_SC_AMOUNT; break; case SB_PAGEDOWN: xdel = (long)clrect.right * PG_SC_PERCENT / 100; break; case SB_PAGEUP: xdel = -(long)clrect.right * PG_SC_PERCENT / 100; break; case SB_THUMBPOSITION: //xdel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.x - clrect.right; xdel = GET_WM_VSCROLL_POS( wparam, lparam ) - offset.x; break; case SB_TOP: xdel = -offset.x; break; default: break; } // make sure we do not expose area's not in the scroll rect if( clrect.right <= scrollrect.right && clrect.left >= scrollrect.left ) { if( xdel ) { if( clrect.right + offset.x + xdel > scrollrect.right ) { xdel = scrollrect.right - clrect.right - offset.x; } } else { if( clrect.left + offset.x + xdel < scrollrect.left ) { xdel = clrect.left + offset.x - scrollrect.left; } } } DoScroll( wnd, xdel, 0, TRUE ); }