| 1 | /* $Id: smoothscroll.cpp,v 1.2 2000-09-30 13:43:21 achimha Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Undocumented SmoothScrollWindow function from COMCTL32.DLL
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 2000 Marcus Meissner <marcus@jet.franken.de>
|
|---|
| 7 | *
|
|---|
| 8 | * TODO
|
|---|
| 9 | * - actually add smooth scrolling
|
|---|
| 10 | */
|
|---|
| 11 |
|
|---|
| 12 | /* WINE CVS 000929 level */
|
|---|
| 13 |
|
|---|
| 14 | #include "winbase.h"
|
|---|
| 15 | #include "winreg.h"
|
|---|
| 16 | #include "winerror.h"
|
|---|
| 17 | #include "commctrl.h"
|
|---|
| 18 |
|
|---|
| 19 | static DWORD smoothscroll = 2;
|
|---|
| 20 |
|
|---|
| 21 | typedef BOOL (CALLBACK *SCROLLWINDOWEXPROC)(HWND,INT,INT,LPRECT,LPRECT,HRGN,LPRECT,DWORD);
|
|---|
| 22 | typedef struct tagSMOOTHSCROLLSTRUCT {
|
|---|
| 23 | DWORD dwSize;
|
|---|
| 24 | DWORD x2;
|
|---|
| 25 | HWND hwnd;
|
|---|
| 26 | DWORD dx;
|
|---|
| 27 |
|
|---|
| 28 | DWORD dy;
|
|---|
| 29 | LPRECT lpscrollrect;
|
|---|
| 30 | LPRECT lpcliprect;
|
|---|
| 31 | HRGN hrgnupdate;
|
|---|
| 32 |
|
|---|
| 33 | LPRECT lpupdaterect;
|
|---|
| 34 | DWORD flags;
|
|---|
| 35 | DWORD stepinterval;
|
|---|
| 36 | DWORD dx_step;
|
|---|
| 37 |
|
|---|
| 38 | DWORD dy_step;
|
|---|
| 39 | SCROLLWINDOWEXPROC scrollfun; /* same parameters as ScrollWindowEx */
|
|---|
| 40 | } SMOOTHSCROLLSTRUCT;
|
|---|
| 41 |
|
|---|
| 42 | /**************************************************************************
|
|---|
| 43 | * SmoothScrollWindow [COMCTL32.382]
|
|---|
| 44 | *
|
|---|
| 45 | * Lots of magic for smooth scrolling windows.
|
|---|
| 46 | *
|
|---|
| 47 | * Currently only scrolls ONCE. The comctl32 implementation uses GetTickCount
|
|---|
| 48 | * and what else to do smooth scrolling.
|
|---|
| 49 | */
|
|---|
| 50 |
|
|---|
| 51 | BOOL WINAPI SmoothScrollWindow( SMOOTHSCROLLSTRUCT *smooth ) {
|
|---|
| 52 | LPRECT lpupdaterect = smooth->lpupdaterect;
|
|---|
| 53 | HRGN hrgnupdate = smooth->hrgnupdate;
|
|---|
| 54 | RECT tmprect;
|
|---|
| 55 | BOOL ret = TRUE;
|
|---|
| 56 | DWORD flags = smooth->flags;
|
|---|
| 57 |
|
|---|
| 58 | if (smooth->dwSize!=sizeof(SMOOTHSCROLLSTRUCT))
|
|---|
| 59 | return FALSE;
|
|---|
| 60 |
|
|---|
| 61 | if (!lpupdaterect)
|
|---|
| 62 | lpupdaterect = &tmprect;
|
|---|
| 63 | SetRectEmpty(lpupdaterect);
|
|---|
| 64 |
|
|---|
| 65 | if (!(flags & 0x40000)) { /* no override, use system wide defaults */
|
|---|
| 66 | if (smoothscroll == 2) {
|
|---|
| 67 | HKEY hkey;
|
|---|
| 68 |
|
|---|
| 69 | smoothscroll = 0;
|
|---|
| 70 | if (!RegOpenKeyA(HKEY_CURRENT_USER,"Control Panel\\Desktop",&hkey)) {
|
|---|
| 71 | DWORD len = 4;
|
|---|
| 72 |
|
|---|
| 73 | RegQueryValueExA(hkey,"SmoothScroll",0,0,(LPBYTE)&smoothscroll,&len);
|
|---|
| 74 | RegCloseKey(hkey);
|
|---|
| 75 | }
|
|---|
| 76 | }
|
|---|
| 77 | if (!smoothscroll)
|
|---|
| 78 | flags |= 0x20000;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | if (flags & 0x20000) { /* are we doing jump scrolling? */
|
|---|
| 82 | if ((smooth->x2 & 1) && smooth->scrollfun)
|
|---|
| 83 | return smooth->scrollfun(
|
|---|
| 84 | smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
|
|---|
| 85 | smooth->lpcliprect,hrgnupdate,lpupdaterect,
|
|---|
| 86 | flags & 0xffff
|
|---|
| 87 | );
|
|---|
| 88 | else
|
|---|
| 89 | return ScrollWindowEx(
|
|---|
| 90 | smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
|
|---|
| 91 | smooth->lpcliprect,hrgnupdate,lpupdaterect,
|
|---|
| 92 | flags & 0xffff
|
|---|
| 93 | );
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | // FIXME("(hwnd=%x,flags=%lx,x2=%lx): should smooth scroll here.\n",
|
|---|
| 97 | // smooth->hwnd,flags,smooth->x2
|
|---|
| 98 | // );
|
|---|
| 99 | /* FIXME: do timer based smooth scrolling */
|
|---|
| 100 | if ((smooth->x2 & 1) && smooth->scrollfun)
|
|---|
| 101 | return smooth->scrollfun(
|
|---|
| 102 | smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
|
|---|
| 103 | smooth->lpcliprect,hrgnupdate,lpupdaterect,
|
|---|
| 104 | flags & 0xffff
|
|---|
| 105 | );
|
|---|
| 106 | else
|
|---|
| 107 | return ScrollWindowEx(
|
|---|
| 108 | smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
|
|---|
| 109 | smooth->lpcliprect,hrgnupdate,lpupdaterect,
|
|---|
| 110 | flags & 0xffff
|
|---|
| 111 | );
|
|---|
| 112 | return ret;
|
|---|
| 113 | }
|
|---|