Ignore:
Timestamp:
Oct 29, 2002, 1:19:36 PM (23 years ago)
Author:
sandervl
Message:

Wine resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/pager.c

    r8382 r9370  
    4545    INT    nPos;       /* scroll position */
    4646    INT    nWidth;     /* from child wnd's response to PGN_CALCSIZE */
    47     INT    nHeight;    /* from child wnd's response to PGN_CALCSIZE */ 
     47    INT    nHeight;    /* from child wnd's response to PGN_CALCSIZE */
    4848    BOOL   bForward;   /* forward WM_MOUSEMOVE msgs to the contained wnd */
     49    BOOL   bCapture;   /* we have captured the mouse  */
    4950    INT    TLbtnState; /* state of top or left btn */
    5051    INT    BRbtnState; /* state of bottom or right btn */
     
    6364#define REPEAT_DELAY     50
    6465
    65 /* the horizontal arrows are: 
     66/* the horizontal arrows are:
    6667 *
    6768 * 01234    01234
     
    7273 * 5 **      **
    7374 * 6  *      *
    74  * 7 
     75 * 7
    7576 *
    7677 */
     
    7980{
    8081    INT x, y, w, h;
    81     HPEN hOldPen;
    82    
     82    HPEN hPen, hOldPen;
     83
    8384    w = r.right - r.left + 1;
    8485    h = r.bottom - r.top + 1;
     
    8687        return;  /* refuse to draw partial arrow */
    8788
    88     hOldPen = SelectObject ( hdc, GetSysColorPen (colorRef));
     89    if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
     90    hOldPen = SelectObject ( hdc, hPen );
    8991    if (left)
    9092    {
     
    111113
    112114    SelectObject( hdc, hOldPen );
    113 }
    114 
    115 /* the vertical arrows are:
     115    DeleteObject( hPen );
     116}
     117
     118/* the vertical arrows are:
    116119 *
    117120 * 01234567    01234567
    118  * 1******        ** 
     121 * 1******        **
    119122 * 2 ****        ****
    120123 * 3  **        ******
     
    126129{
    127130    INT x, y, w, h;
    128     HPEN hOldPen;
    129    
     131    HPEN hPen, hOldPen;
     132
    130133    w = r.right - r.left + 1;
    131134    h = r.bottom - r.top + 1;
     
    133136        return;  /* refuse to draw partial arrow */
    134137
    135     hOldPen = SelectObject ( hdc, GetSysColorPen (colorRef));
     138    if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
     139    hOldPen = SelectObject ( hdc, hPen );
    136140    if (up)
    137141    {
     
    158162
    159163    SelectObject( hdc, hOldPen );
     164    DeleteObject( hPen );
    160165}
    161166
     
    171176
    172177    if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0))
    173         return; 
     178        return;
    174179
    175180    hBrush = CreateSolidBrush(clrBk);
     
    178183    FillRect(hdc, &rc, hBrush);
    179184
    180     if (btnState == PGF_HOT) 
     185    if (btnState == PGF_HOT)
    181186    {
    182187       DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT);
     
    186191           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    187192    }
    188     else if (btnState == PGF_NORMAL) 
     193    else if (btnState == PGF_NORMAL)
    189194    {
    190195       DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
     
    194199           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    195200    }
    196     else if (btnState == PGF_DEPRESSED) 
     201    else if (btnState == PGF_DEPRESSED)
    197202    {
    198203       DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
     
    202207           PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft);
    203208    }
    204     else if (btnState == PGF_GRAYED) 
     209    else if (btnState == PGF_GRAYED)
    205210    {
    206211       DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT);
     
    223228}
    224229
     230static void PAGER_CaptureandTrack(PAGER_INFO *infoPtr, HWND hwnd)
     231{
     232    TRACKMOUSEEVENT trackinfo;
     233
     234    TRACE("[%p] SetCapture\n", hwnd);
     235    SetCapture(hwnd);
     236    infoPtr->bCapture = TRUE;
     237
     238    trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
     239    trackinfo.dwFlags = TME_QUERY;
     240    trackinfo.hwndTrack = hwnd;
     241    trackinfo.dwHoverTime = HOVER_DEFAULT;
     242
     243    /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
     244    _TrackMouseEvent(&trackinfo);
     245
     246    /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
     247    if(!(trackinfo.dwFlags & TME_LEAVE)) {
     248        trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
     249
     250        /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
     251        /* and can properly deactivate the hot button */
     252        _TrackMouseEvent(&trackinfo);
     253    }
     254}
     255
     256
    225257/* << PAGER_GetDropTarget >> */
    226258
     
    229261{
    230262    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    231     TRACE("[%04x]\n", hwnd);
     263    TRACE("[%p]\n", hwnd);
    232264
    233265    infoPtr->bForward = (BOOL)wParam;
     
    239271PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam)
    240272{
    241     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
     273    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    242274    LRESULT btnState = PGF_INVISIBLE;
    243275    INT btn = (INT)lParam;
    244     TRACE("[%04x]\n", hwnd);
     276    TRACE("[%p]\n", hwnd);
    245277
    246278    if (btn == PGB_TOPORLEFT)
     
    256288PAGER_GetPos(HWND hwnd)
    257289{
    258     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    259     TRACE("[%04x] returns %d\n", hwnd, infoPtr->nPos);
     290    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     291    TRACE("[%p] returns %d\n", hwnd, infoPtr->nPos);
    260292    return (LRESULT)infoPtr->nPos;
    261293}
     
    264296PAGER_GetButtonSize(HWND hwnd)
    265297{
    266     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    267     TRACE("[%04x] returns %d\n", hwnd, infoPtr->nButtonSize);
     298    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     299    TRACE("[%p] returns %d\n", hwnd, infoPtr->nButtonSize);
    268300    return (LRESULT)infoPtr->nButtonSize;
    269301}
     
    272304PAGER_GetBorder(HWND hwnd)
    273305{
    274     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    275     TRACE("[%04x] returns %d\n", hwnd, infoPtr->nBorder);
     306    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     307    TRACE("[%p] returns %d\n", hwnd, infoPtr->nBorder);
    276308    return (LRESULT)infoPtr->nBorder;
    277309}
     
    280312PAGER_GetBkColor(HWND hwnd)
    281313{
    282     PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 
    283     TRACE("[%04x] returns %06lx\n", hwnd, infoPtr->clrBk);
     314    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     315    TRACE("[%p] returns %06lx\n", hwnd, infoPtr->clrBk);
    284316    return (LRESULT)infoPtr->clrBk;
    285317}
    286318
    287 static void 
    288 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 
     319static void
     320PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth)
    289321{
    290322    NMPGCALCSIZE nmpgcs;
     
    301333    *size = getWidth ? nmpgcs.iWidth : nmpgcs.iHeight;
    302334
    303     TRACE("[%04x] PGN_CALCSIZE returns %s=%d\n", hwnd,
     335    TRACE("[%p] PGN_CALCSIZE returns %s=%d\n", hwnd,
    304336                  getWidth ? "width" : "height", *size);
    305337}
     
    325357                infoPtr->nWidth = wndSize;
    326358
    327             TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd,
     359            TRACE("[%p] SWP %dx%d at (%d,%d)\n", hwnd,
    328360                         infoPtr->nWidth, infoPtr->nHeight,
    329361                         -nPos, 0);
     
    339371                infoPtr->nHeight = wndSize;
    340372
    341             TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd,
     373            TRACE("[%p] SWP %dx%d at (%d,%d)\n", hwnd,
    342374                         infoPtr->nWidth, infoPtr->nHeight,
    343375                         0, -nPos);
     
    381413    }
    382414
    383     TRACE("[%04x] returns %d\n", hwnd, scrollRange);
     415    TRACE("[%p] returns %d\n", hwnd, scrollRange);
    384416    return scrollRange;
    385417}
    386418
    387 static void 
     419static void
    388420PAGER_GrayAndRestoreBtns(PAGER_INFO* infoPtr, INT scrollRange,
    389421                         BOOL* needsResize, BOOL* needsRepaint)
     
    422454
    423455
    424 static void 
     456static void
    425457PAGER_NormalizeBtns(PAGER_INFO* infoPtr, BOOL* needsRepaint)
    426458{
     
    438470}
    439471
    440 static void 
     472static void
    441473PAGER_HideGrayBtns(PAGER_INFO* infoPtr, BOOL* needsResize)
    442474{
     
    470502
    471503    if (resizeClient) /* initiate NCCalcSize to resize client wnd */ {
    472         SetWindowPos(hwnd, 0,0,0,0,0, 
     504        SetWindowPos(hwnd, 0,0,0,0,0,
    473505                     SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
    474506                     SWP_NOZORDER | SWP_NOACTIVATE);
     
    476508
    477509    if (repaintBtns)
    478         SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
    479 }
    480 
    481 static LRESULT 
     510        SendMessageA(hwnd, WM_NCPAINT, 0, 0);
     511}
     512
     513static LRESULT
    482514PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress)
    483515{
     
    493525        infoPtr->nPos = newPos;
    494526
    495     TRACE("[%04x] pos=%d\n", hwnd, infoPtr->nPos);
     527    TRACE("[%p] pos=%d, oldpos=%d\n", hwnd, infoPtr->nPos, oldPos);
    496528
    497529    if (infoPtr->nPos != oldPos)
     
    537569}
    538570
    539 static INT 
     571static INT
    540572PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr)
    541573{
     
    562594    h = wndRect.bottom - wndRect.top + infoPtr->nButtonSize;
    563595
    564     TRACE("[%04x] infoPtr->nWidth set to %d\n",
     596    TRACE("[%p] infoPtr->nWidth set to %d\n",
    565597               hwnd, infoPtr->nWidth);
    566598
     
    568600}
    569601
    570 static INT 
     602static INT
    571603PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr)
    572604{
     
    593625    w = wndRect.right - wndRect.left + infoPtr->nButtonSize;
    594626
    595     TRACE("[%04x] infoPtr->nHeight set to %d\n",
     627    TRACE("[%p] infoPtr->nHeight set to %d\n",
    596628               hwnd, infoPtr->nHeight);
    597629
     
    616648    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    617649
    618     TRACE("[%04x]\n", hwnd);
     650    TRACE("[%p]\n", hwnd);
    619651
    620652    if (infoPtr->hwndChild)
     
    627659            PAGER_SetPos(hwnd, 0, FALSE);
    628660        }
    629         else 
     661        else
    630662        {
    631663            PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE);
     
    645677
    646678    infoPtr->clrBk = (COLORREF)lParam;
    647     TRACE("[%04x] %06lx\n", hwnd, infoPtr->clrBk);
     679    TRACE("[%p] %06lx\n", hwnd, infoPtr->clrBk);
    648680
    649681    /* the native control seems to do things this way */
    650     SetWindowPos(hwnd, 0,0,0,0,0, 
     682    SetWindowPos(hwnd, 0,0,0,0,0,
    651683                 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
    652684                 SWP_NOZORDER | SWP_NOACTIVATE);
     
    665697
    666698    infoPtr->nBorder = (INT)lParam;
    667     TRACE("[%04x] %d\n", hwnd, infoPtr->nBorder);
     699    TRACE("[%p] %d\n", hwnd, infoPtr->nBorder);
    668700
    669701    PAGER_RecalcSize(hwnd);
     
    680712
    681713    infoPtr->nButtonSize = (INT)lParam;
    682     TRACE("[%04x] %d\n", hwnd, infoPtr->nButtonSize);
     714    TRACE("[%p] %d\n", hwnd, infoPtr->nButtonSize);
    683715
    684716    PAGER_RecalcSize(hwnd);
     
    698730    if (infoPtr->hwndChild)
    699731    {
    700         TRACE("[%04x] hwndChild=%04x\n", hwnd, infoPtr->hwndChild);
     732        TRACE("[%p] hwndChild=%p\n", hwnd, infoPtr->hwndChild);
    701733
    702734        if (PAGER_IsHorizontal(hwnd)) {
    703735            hw = PAGER_SetFixedHeight(hwnd, infoPtr);
    704736            /* adjust non-scrollable dimension to fit the child */
    705             SetWindowPos(hwnd, 0, 0,0, hw, infoPtr->nHeight, 
     737            SetWindowPos(hwnd, 0, 0,0, hw, infoPtr->nHeight,
    706738                         SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
    707739                         SWP_NOSIZE | SWP_NOACTIVATE);
     
    710742            hw = PAGER_SetFixedWidth(hwnd, infoPtr);
    711743            /* adjust non-scrollable dimension to fit the child */
    712             SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, hw, 
     744            SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, hw,
    713745                         SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER |
    714746                         SWP_NOSIZE | SWP_NOACTIVATE);
     
    741773        nmpgScroll.hdr.code = PGN_SCROLL;
    742774
    743         GetWindowRect(hwnd, &rcWnd); 
    744         GetClientRect(hwnd, &nmpgScroll.rcParent); 
     775        GetWindowRect(hwnd, &rcWnd);
     776        GetClientRect(hwnd, &nmpgScroll.rcParent);
    745777        nmpgScroll.iXpos = nmpgScroll.iYpos = 0;
    746778        nmpgScroll.iDir = dir;
     
    757789        }
    758790        nmpgScroll.iScroll -= 2*infoPtr->nButtonSize;
    759  
    760         SendMessageA (hwnd, WM_NOTIFY,
     791
     792        SendMessageA (GetParent(hwnd), WM_NOTIFY,
    761793                    (WPARAM)nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll);
    762  
    763         TRACE("[%04x] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll);
     794
     795        TRACE("[%p] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll);
    764796
    765797        if (nmpgScroll.iScroll > 0)
     
    783815
    784816    /* initiate NCCalcSize to resize client wnd and get size */
    785     SetWindowPos(hwnd, 0, 0,0,0,0, 
     817    SetWindowPos(hwnd, 0, 0,0,0,0,
    786818                 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
    787819                 SWP_NOZORDER | SWP_NOACTIVATE);
    788820
    789     SetWindowPos(infoPtr->hwndChild, 0, 
    790                  0,0,infoPtr->nWidth,infoPtr->nHeight, 
     821    SetWindowPos(infoPtr->hwndChild, 0,
     822                 0,0,infoPtr->nWidth,infoPtr->nHeight,
    791823                 0);
    792824
     
    814846    infoPtr->nHeight = 0;
    815847    infoPtr->bForward = FALSE;
     848    infoPtr->bCapture = FALSE;
    816849    infoPtr->TLbtnState = PGF_INVISIBLE;
    817850    infoPtr->BRbtnState = PGF_INVISIBLE;
    818851    infoPtr->direction = -1;
    819852
    820     if (dwStyle & PGS_AUTOSCROLL)
    821         FIXME("[%04x] Autoscroll style is not implemented yet.\n", hwnd);
    822853    if (dwStyle & PGS_DRAGNDROP)
    823         FIXME("[%04x] Drag and Drop style is not implemented yet.\n", hwnd);
     854        FIXME("[%p] Drag and Drop style is not implemented yet.\n", hwnd);
    824855    /*
    825856         * If neither horizontal nor vertical style specified, default to vertical.
     
    852883    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    853884    LPRECT lpRect = (LPRECT)lParam;
    854     RECT rcChildw, rcmyw, wnrc, lbrc, rbrc;
     885    RECT rcChildw, rcmyw, wnrc, ltrc, rbrc;
    855886    POINT cursor;
    856887    BOOL resizeClient = FALSE;
     
    860891    /*
    861892     * lParam points to a RECT struct.  On entry, the struct
    862      * contains the proposed wnd rectangle for the window. 
     893     * contains the proposed wnd rectangle for the window.
    863894     * On exit, the struct should contain the screen
    864895     * coordinates of the corresponding window's client area.
    865896     */
    866        
     897
    867898    DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
    868899
     
    882913        scrollRange = infoPtr->nWidth - (rcmyw.right - rcmyw.left);
    883914
    884         TRACE("nPos=%d, scrollrange=%d, nWidth=%d, myw=(%d,%d)-(%d,%d)\n",
    885               infoPtr->nPos, scrollRange, infoPtr->nWidth,
    886               rcmyw.left, rcmyw.top, rcmyw.right, rcmyw.bottom);
     915        TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d), cursor=(%ld,%ld)\n",
     916              infoPtr->nPos, scrollRange, infoPtr->nHeight,
     917              rcmyw.left, rcmyw.top,
     918              rcmyw.right, rcmyw.bottom,
     919              cursor.x, cursor.y);
    887920        PAGER_GrayAndRestoreBtns(infoPtr, scrollRange, &resizeClient, &repaintBtns);
    888921        PAGER_HideGrayBtns(infoPtr, &resizeClient);
     
    890923        if (PtInRect (&rcmyw, cursor)) {
    891924            GetWindowRect (hwnd, &wnrc);
    892             lbrc = wnrc;
    893             lbrc.right = lbrc.left + infoPtr->nButtonSize;
     925            ltrc = wnrc;
     926            ltrc.right = ltrc.left + infoPtr->nButtonSize;
    894927            rbrc = wnrc;
    895928            rbrc.left = rbrc.right - infoPtr->nButtonSize;
    896             TRACE("horz lb rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
    897                   lbrc.left, lbrc.top, lbrc.right, lbrc.bottom,
     929            TRACE("horz lt rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
     930                  ltrc.left, ltrc.top, ltrc.right, ltrc.bottom,
    898931                  rbrc.left, rbrc.top, rbrc.right, rbrc.bottom);
    899             if (PtInRect (&lbrc, cursor) && infoPtr->TLbtnState)
     932            if (PtInRect (&ltrc, cursor) && infoPtr->TLbtnState)
    900933                RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE);
    901934            if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState)
     
    909942    else
    910943    {
    911         /* native does: (from trace of IE4 opening "Favorites" frame) 
     944        /* native does: (from trace of IE4 opening "Favorites" frame)
    912945         *        DefWindowProc
    913946         *        WM_NOITFY  PGN_CALCSIZE w/ dwFlag=2
     
    929962        scrollRange = infoPtr->nHeight - (rcmyw.bottom - rcmyw.top);
    930963
    931         TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d)\n",
     964        TRACE("nPos=%d, scrollrange=%d, nHeigth=%d, myw=(%d,%d)-(%d,%d), cursor=(%ld,%ld)\n",
    932965              infoPtr->nPos, scrollRange, infoPtr->nHeight,
    933966              rcmyw.left, rcmyw.top,
    934               rcmyw.right, rcmyw.bottom);
     967              rcmyw.right, rcmyw.bottom,
     968              cursor.x, cursor.y);
    935969        PAGER_GrayAndRestoreBtns(infoPtr, scrollRange, &resizeClient, &repaintBtns);
    936970        PAGER_HideGrayBtns(infoPtr, &resizeClient);
     
    949983
    950984            GetWindowRect (hwnd, &wnrc);
    951             lbrc = wnrc;
    952             lbrc.right = lbrc.left + infoPtr->nButtonSize;
     985            ltrc = wnrc;
     986            ltrc.right = ltrc.left + infoPtr->nButtonSize;
    953987            rbrc = wnrc;
    954988            rbrc.left = rbrc.right - infoPtr->nButtonSize;
    955             TRACE("vert lb rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
    956                   lbrc.left, lbrc.top, lbrc.right, lbrc.bottom,
     989            TRACE("vert lt rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n",
     990                  ltrc.left, ltrc.top, ltrc.right, ltrc.bottom,
    957991                  rbrc.left, rbrc.top, rbrc.right, rbrc.bottom);
    958             if (PtInRect (&lbrc, cursor) && infoPtr->TLbtnState)
     992            if (PtInRect (&ltrc, cursor) && infoPtr->TLbtnState)
    959993                RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE);
    960994            if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState)
     
    9701004    }
    9711005
    972     TRACE("[%04x] client rect set to %dx%d at (%d,%d) BtnState[%d,%d]\n",
     1006    TRACE("[%p] client rect set to %dx%d at (%d,%d) BtnState[%d,%d]\n",
    9731007          hwnd, lpRect->right-lpRect->left, lpRect->bottom-lpRect->top,
    9741008          lpRect->left, lpRect->top,
     
    10131047                     bHorizontal, TRUE, infoPtr->TLbtnState);
    10141048    PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight,
    1015                      bHorizontal, FALSE, infoPtr->BRbtnState); 
     1049                     bHorizontal, FALSE, infoPtr->BRbtnState);
    10161050
    10171051    ReleaseDC( hwnd, hdc );
     
    10191053}
    10201054
    1021 static INT 
     1055static INT
    10221056PAGER_HitTest (HWND hwnd, LPPOINT pt)
    10231057{
     
    10301064    if (PtInRect(&clientRect, *pt))
    10311065    {
    1032        /* TRACE("HTCLIENT\n"); */
     1066        TRACE("HTCLIENT\n");
    10331067        return HTCLIENT;
    10341068    }
     
    10401074            if (pt->x < clientRect.left)
    10411075            {
    1042                 /* TRACE("HTLEFT\n"); */
     1076                TRACE("HTLEFT\n");
    10431077                return HTLEFT;
    10441078            }
     
    10481082            if (pt->y < clientRect.top)
    10491083            {
    1050                 /* TRACE("HTTOP\n"); */
     1084                TRACE("HTTOP\n");
    10511085                return HTTOP;
    10521086            }
     
    10601094            if (pt->x > clientRect.right)
    10611095            {
    1062                 /* TRACE("HTRIGHT\n"); */
     1096                TRACE("HTRIGHT\n");
    10631097                return HTRIGHT;
    10641098            }
     
    10681102            if (pt->y > clientRect.bottom)
    10691103            {
    1070                /* TRACE("HTBOTTOM\n"); */
     1104                TRACE("HTBOTTOM\n");
    10711105                return HTBOTTOM;
    10721106            }
     
    10741108    }
    10751109
    1076     /* TRACE("HTNOWHERE\n"); */
     1110    TRACE("HTNOWHERE\n");
    10771111    return HTNOWHERE;
    10781112}
     
    10811115PAGER_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
    10821116{
    1083     POINT pt = { SLOWORD(lParam), SHIWORD(lParam) };
     1117    POINT pt;
     1118
     1119    pt.x = SLOWORD(lParam);
     1120    pt.y = SHIWORD(lParam);
     1121
    10841122    ScreenToClient (hwnd, &pt);
    10851123    return PAGER_HitTest(hwnd, &pt);
     
    11101148    if (notCaptured)
    11111149    {
    1112         TRACKMOUSEEVENT trackinfo;
    1113 
    1114         TRACE("[%04x] SetCapture\n", hwnd);
    1115         SetCapture(hwnd);
    1116 
    1117         trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
    1118         trackinfo.dwFlags = TME_QUERY;
    1119         trackinfo.hwndTrack = hwnd;
    1120         trackinfo.dwHoverTime = HOVER_DEFAULT;
    1121 
    1122         /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
    1123         _TrackMouseEvent(&trackinfo);
    1124 
    1125         /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
    1126         if(!(trackinfo.dwFlags & TME_LEAVE)) {
    1127             trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
    1128  
    1129            /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
    1130            /* and can properly deactivate the hot button */
    1131            _TrackMouseEvent(&trackinfo);
    1132         }
    1133 
    1134         SendMessageA(hwnd, WM_NCPAINT, 0, 0);
     1150        PAGER_CaptureandTrack(infoPtr, hwnd);
     1151
     1152        SendMessageA(hwnd, WM_NCPAINT, 0, 0);
    11351153    }
    11361154
     
    11461164    KillTimer (hwnd, TIMERID2);
    11471165
    1148     TRACE("[%04x] ReleaseCapture\n", hwnd);
     1166    TRACE("[%p] ReleaseCapture\n", hwnd);
    11491167    ReleaseCapture();
     1168    infoPtr->bCapture = FALSE;
    11501169
    11511170    /* Notify parent of released mouse capture */
     
    11671186
    11681187static LRESULT
     1188PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1189{
     1190    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     1191    POINT clpt, pt;
     1192    RECT wnrect, TLbtnrect, BRbtnrect, *btnrect = NULL;
     1193    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     1194    BOOL topLeft = FALSE;
     1195    INT btnstate = 0;
     1196    INT hit;
     1197    HDC hdc;
     1198
     1199    pt.x = SLOWORD(lParam);
     1200    pt.y = SHIWORD(lParam);
     1201
     1202    TRACE("[%p] to (%ld,%ld)\n", hwnd, pt.x, pt.y);
     1203    ClientToScreen(hwnd, &pt);
     1204    GetWindowRect(hwnd, &wnrect);
     1205    if (PtInRect(&wnrect, pt)) {
     1206        TLbtnrect = wnrect;
     1207        BRbtnrect = wnrect;
     1208        if (dwStyle & PGS_HORZ) {
     1209            TLbtnrect.right = TLbtnrect.left + infoPtr->nButtonSize;
     1210            BRbtnrect.left = BRbtnrect.right - infoPtr->nButtonSize;
     1211        }
     1212        else {
     1213            TLbtnrect.bottom = TLbtnrect.top + infoPtr->nButtonSize;
     1214            BRbtnrect.top = BRbtnrect.bottom - infoPtr->nButtonSize;
     1215        }
     1216
     1217        clpt = pt;
     1218        MapWindowPoints(0, hwnd, &clpt, 1);
     1219        hit = PAGER_HitTest(hwnd, &clpt);
     1220        if (hit == HTLEFT || hit == HTTOP) {
     1221            topLeft = TRUE;
     1222            btnrect = &TLbtnrect;
     1223            infoPtr->TLbtnState = PGF_DEPRESSED;
     1224            btnstate = infoPtr->TLbtnState;
     1225        }
     1226        else if (hit == HTRIGHT || hit == HTBOTTOM) {
     1227            topLeft = FALSE;
     1228            btnrect = &BRbtnrect;
     1229            infoPtr->BRbtnState = PGF_DEPRESSED;
     1230            btnstate = infoPtr->BRbtnState;
     1231        }
     1232
     1233        /* If in one of the buttons the capture and draw buttons */
     1234        if (btnrect) {
     1235            TRACE("[%p] draw btn (%d,%d)-(%d,%d), Capture %s, style %08lx\n",
     1236                  hwnd, btnrect->left, btnrect->top,
     1237                  btnrect->right, btnrect->bottom,
     1238                  (infoPtr->bCapture) ? "TRUE" : "FALSE",
     1239                  dwStyle);
     1240            if (!infoPtr->bCapture)
     1241                PAGER_CaptureandTrack(infoPtr, hwnd);
     1242            if (dwStyle & PGS_AUTOSCROLL)
     1243                SetTimer(hwnd, TIMERID1, 0x3e, 0);
     1244            MapWindowPoints(0, hwnd, (LPPOINT)btnrect, 2);
     1245            hdc = GetWindowDC(hwnd);
     1246            /* OffsetRect(wnrect, 0 | 1, 0 | 1) */
     1247            PAGER_DrawButton(hdc, infoPtr->clrBk, *btnrect,
     1248                             PAGER_IsHorizontal(hwnd), topLeft, btnstate);
     1249            ReleaseDC(hwnd, hdc);
     1250            return DefWindowProcA (hwnd, WM_MOUSEMOVE, wParam, lParam);
     1251        }
     1252    }
     1253
     1254    /* If we think we are captured, then do release */
     1255    if (infoPtr->bCapture) {
     1256        infoPtr->bCapture = FALSE;
     1257
     1258        if (GetCapture() == hwnd) {
     1259            ReleaseCapture();
     1260            /* Notify parent of released mouse capture */
     1261            {
     1262                NMHDR nmhdr;
     1263                ZeroMemory (&nmhdr, sizeof (NMHDR));
     1264                nmhdr.hwndFrom = hwnd;
     1265                nmhdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     1266                nmhdr.code = NM_RELEASEDCAPTURE;
     1267                SendMessageA (GetParent(hwnd), WM_NOTIFY,
     1268                              (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     1269            }
     1270        }
     1271        if (IsWindow(hwnd))
     1272            KillTimer(hwnd, TIMERID1);
     1273    }
     1274    return DefWindowProcA (hwnd, WM_MOUSEMOVE, wParam, lParam);
     1275}
     1276
     1277static LRESULT
    11691278PAGER_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
    11701279{
    11711280    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    11721281    BOOL repaintBtns = FALSE;
    1173     POINT pt = { SLOWORD(lParam), SHIWORD(lParam) };
     1282    POINT pt;
    11741283    INT hit;
    11751284
    1176     TRACE("[%04x]\n", hwnd);
    1177        
     1285    pt.x = SLOWORD(lParam);
     1286    pt.y = SHIWORD(lParam);
     1287
     1288    TRACE("[%p] at (%d,%d)\n", hwnd, SLOWORD(lParam), SHIWORD(lParam));
     1289
    11781290    hit = PAGER_HitTest(hwnd, &pt);
    11791291
     
    11831295        repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED;
    11841296        infoPtr->TLbtnState = PGF_DEPRESSED;
    1185         SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
     1297        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
    11861298    }
    11871299    else if (hit == HTRIGHT || hit == HTBOTTOM)
     
    11891301        repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED;
    11901302        infoPtr->BRbtnState = PGF_DEPRESSED;
    1191         SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 
     1303        SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0);
    11921304    }
    11931305
    11941306    if (repaintBtns)
    1195         SendMessageA(hwnd, WM_NCPAINT, 0, 0); 
     1307        SendMessageA(hwnd, WM_NCPAINT, 0, 0);
    11961308
    11971309    switch(hit)
    11981310    {
    11991311    case HTLEFT:
    1200         TRACE("[%04x] PGF_SCROLLLEFT\n", hwnd);
     1312        TRACE("[%p] PGF_SCROLLLEFT\n", hwnd);
    12011313        PAGER_Scroll(hwnd, PGF_SCROLLLEFT);
    12021314        break;
    12031315    case HTTOP:
    1204         TRACE("[%04x] PGF_SCROLLUP\n", hwnd);
     1316        TRACE("[%p] PGF_SCROLLUP\n", hwnd);
    12051317        PAGER_Scroll(hwnd, PGF_SCROLLUP);
    12061318        break;
    12071319    case HTRIGHT:
    1208         TRACE("[%04x] PGF_SCROLLRIGHT\n", hwnd);
     1320        TRACE("[%p] PGF_SCROLLRIGHT\n", hwnd);
    12091321        PAGER_Scroll(hwnd, PGF_SCROLLRIGHT);
    12101322        break;
    12111323    case HTBOTTOM:
    1212         TRACE("[%04x] PGF_SCROLLDOWN\n", hwnd);
     1324        TRACE("[%p] PGF_SCROLLDOWN\n", hwnd);
    12131325        PAGER_Scroll(hwnd, PGF_SCROLLDOWN);
    12141326        break;
     
    12241336{
    12251337    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    1226     TRACE("[%04x]\n", hwnd);
     1338    TRACE("[%p]\n", hwnd);
    12271339
    12281340    KillTimer (hwnd, TIMERID1);
     
    12321344    PAGER_UpdateBtns(hwnd, infoPtr, -1, FALSE);
    12331345
     1346    return 0;
     1347}
     1348
     1349static LRESULT
     1350PAGER_NCLButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1351{
     1352    POINT pt;
     1353
     1354    pt.x = SLOWORD(lParam);
     1355    pt.y = SHIWORD(lParam);
     1356
     1357    TRACE("[%p] at (%d,%d)\n", hwnd, SLOWORD(lParam), SHIWORD(lParam));
     1358    MapWindowPoints(0, hwnd, &pt, 1);
     1359    lParam = MAKELONG(pt.x, pt.y);
     1360    return PAGER_LButtonDown (hwnd, wParam, lParam);
     1361}
     1362
     1363static LRESULT
     1364PAGER_Timer (HWND hwnd, WPARAM wParam)
     1365{
     1366    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
     1367    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     1368    INT dir;
     1369
     1370    /* if initial timer, kill it and start the repeat timer */
     1371    if (wParam == TIMERID1) {
     1372        if (PAGER_IsHorizontal(hwnd)) {
     1373            dir = (infoPtr->TLbtnState & PGF_DEPRESSED) ?
     1374                PGF_SCROLLLEFT : PGF_SCROLLRIGHT;
     1375        }
     1376        else {
     1377            dir = (infoPtr->TLbtnState & PGF_DEPRESSED) ?
     1378                PGF_SCROLLUP : PGF_SCROLLDOWN;
     1379        }
     1380        TRACE("[%p] TIMERID1: style=%08lx, dir=%d\n", hwnd, dwStyle, dir);
     1381        KillTimer(hwnd, TIMERID1);
     1382        SetTimer(hwnd, TIMERID1, REPEAT_DELAY, 0);
     1383        if (dwStyle & PGS_AUTOSCROLL) {
     1384            PAGER_Scroll(hwnd, dir);
     1385            SetWindowPos(hwnd, 0,0,0,0,0,
     1386                         SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
     1387                         SWP_NOZORDER | SWP_NOACTIVATE);
     1388        }
     1389        return 0;
     1390
     1391    }
     1392
     1393    TRACE("[%p] TIMERID2: dir=%d\n", hwnd, infoPtr->direction);
     1394    KillTimer(hwnd, TIMERID2);
     1395    if (infoPtr->direction > 0) {
     1396        PAGER_Scroll(hwnd, infoPtr->direction);
     1397        SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);
     1398    }
    12341399    return 0;
    12351400}
     
    12881453
    12891454    PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd);
    1290     TRACE("[%04x] %dx%d\n", hwnd, LOWORD(lParam), HIWORD(lParam));
     1455    TRACE("[%p] %dx%d\n", hwnd, SLOWORD(lParam), SHIWORD(lParam));
    12911456
    12921457    if (PAGER_IsHorizontal(hwnd))
    1293         infoPtr->nHeight = HIWORD(lParam);
     1458        infoPtr->nHeight = SHIWORD(lParam);
    12941459    else
    1295         infoPtr->nWidth = LOWORD(lParam);
     1460        infoPtr->nWidth = SLOWORD(lParam);
    12961461
    12971462    return PAGER_RecalcSize(hwnd);
     
    13341499        case PGM_RECALCSIZE:
    13351500            return PAGER_RecalcSize(hwnd);
    1336    
     1501
    13371502        case PGM_SETBKCOLOR:
    13381503            return PAGER_SetBkColor (hwnd, wParam, lParam);
     
    13821547            if (infoPtr->bForward && infoPtr->hwndChild)
    13831548                PostMessageA(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam);
    1384             return TRUE;                       
     1549            return PAGER_MouseMove (hwnd, wParam, lParam);
    13851550
    13861551        case WM_MOUSELEAVE:
    1387             return PAGER_MouseLeave (hwnd, wParam, lParam);     
     1552            return PAGER_MouseLeave (hwnd, wParam, lParam);
     1553
     1554        case WM_NCLBUTTONDOWN:
     1555            return PAGER_NCLButtonDown (hwnd, wParam, lParam);
    13881556
    13891557        case WM_LBUTTONDOWN:
    13901558            return PAGER_LButtonDown (hwnd, wParam, lParam);
    13911559
     1560        case WM_NCLBUTTONUP:
    13921561        case WM_LBUTTONUP:
    13931562            return PAGER_LButtonUp (hwnd, wParam, lParam);
     
    13971566/*
    13981567        case WM_PAINT:
    1399             return PAGER_Paint (hwnd, wParam); 
     1568            return PAGER_Paint (hwnd, wParam);
    14001569*/
    14011570        case WM_TIMER:
    1402             /* if initial timer, kill it and start the repeat timer */
    1403             if (wParam == TIMERID1)
    1404             {
    1405                 KillTimer(hwnd, TIMERID1);
    1406                 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);
    1407             }
    1408 
    1409             KillTimer(hwnd, TIMERID2);
    1410             if (infoPtr->direction > 0)
    1411             {
    1412                 PAGER_Scroll(hwnd, infoPtr->direction);
    1413                 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0);         
    1414             }
    1415             break;
     1571            return PAGER_Timer (hwnd, wParam);
    14161572
    14171573        case WM_NOTIFY:
     
    14401596    wndClass.hbrBackground = 0;
    14411597    wndClass.lpszClassName = WC_PAGESCROLLERA;
    1442  
     1598
    14431599    RegisterClassA (&wndClass);
    14441600}
     
    14501606    UnregisterClassA (WC_PAGESCROLLERA, (HINSTANCE)NULL);
    14511607}
    1452 
Note: See TracChangeset for help on using the changeset viewer.