Ignore:
Timestamp:
May 22, 2000, 7:21:11 PM (25 years ago)
Author:
cbratschi
Message:

merged controls with Corel WINE 20000513, maximize/minimize fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/listbox.cpp

    r3153 r3584  
    1 /* $Id: listbox.cpp,v 1.24 2000-03-18 16:13:30 cbratschi Exp $ */
     1/* $Id: listbox.cpp,v 1.25 2000-05-22 17:21:08 cbratschi Exp $ */
    22/*
    33 * Listbox controls
     
    66 * Copyright 1999 Christoph Bratschi (ported from WINE)
    77 *
    8  * Corel version: 20000317
     8 * Corel version: 20000513
    99 * (WINE version: 991212)
    1010 *
     
    3434 - VK_LINEDOWN -> bottom most item not always visible
    3535 - performance not optimized
    36  - ownerdraw is broken -> toolbar customize dialog
    3736 - first item selection mark not redrawn on new selection
     37 - LISTBOX_HandleLButtonDownCombo fails, bug in GetWindowRect or ClientToScreen!
     38   I clicked on the vertical scrollbar, this happens:
     39    t1: SendInternalMessageA WM_LBUTTONDOWN for 68000009 1 1d00c6
     40    t1: GetClientRect of 68000009 returned (0,0) (191,110)
     41    t1: USER32: GetCapture returned 68000009
     42    t1: GetWindowRect 68000009 (450,130) (657,242)
     43    t1: ClientToScreen 68000009 (198,29) -> (424,108)
     44   mouse position is ok, but screen point is outside window rect!!!
     45   the new point is left-top and not on the right!!!
    3846 */
    3947
     
    112120#define SEND_NOTIFICATION(hwnd,descr,code) \
    113121    (SendMessageA( (descr)->owner, WM_COMMAND, \
    114      MAKEWPARAM((((descr)->lphc)?ID_CB_LISTBOX:GetWindowLongA(hwnd,GWL_ID)), (code) ), hwnd ))
     122     MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID), (code)), hwnd ))
    115123
    116124/* Current timer status */
     
    482490    {
    483491        DRAWITEMSTRUCT dis;
    484         UINT           id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     492        UINT           id = GetWindowLongA(hwnd,GWL_ID);
    485493
    486494        if (!item)
     
    714722        {
    715723            COMPAREITEMSTRUCT cis;
    716             UINT                id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     724            UINT                id = GetWindowLongA(hwnd,GWL_ID);
    717725
    718726            cis.CtlType    = ODT_LISTBOX;
     
    887895    INT focusItem;
    888896
     897    if (descr->style & LBS_NOREDRAW) return 0;
     898
    889899    SetRect( &rect, 0, 0, descr->width, descr->height );
    890     if (descr->style & LBS_NOREDRAW) return 0;
    891900    if (descr->style & LBS_MULTICOLUMN)
    892901        rect.right = rect.left + descr->column_width;
     
    966975    /* Paint the focus item now */
    967976    descr->focus_item = focusItem;
    968     if (focusRect.top != focusRect.bottom)
     977    if (focusRect.top != focusRect.bottom && descr->caret_on)
    969978        LISTBOX_DrawItem( hwnd, descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS );
    970979
     
    12811290    {
    12821291        INT oldsel = descr->selected_item;
    1283         //SvL: Why was this commented out??? (enabled in latest wine code)
    1284         if (index == oldsel) return LB_OKAY;
    1285 
    1286         if (oldsel != -1) descr->items[oldsel].selected = FALSE;
    1287         if (index != -1) descr->items[index].selected = TRUE;
    1288         descr->selected_item = index;
    1289         if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT);
    1290         if (index != -1) LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT );
    1291         if (send_notify && descr->nb_items) SEND_NOTIFICATION( hwnd, descr,
    1292                                (index != -1) ? LBN_SELCHANGE : LBN_SELCANCEL );
    1293         else
    1294             if( descr->lphc ) /* set selection change flag for parent combo */
    1295                 descr->lphc->wState |= CBF_SELCHANGE;
    1296     }
    1297     return LB_OKAY;
     1292
     1293        if (index != oldsel)
     1294        {
     1295          if (oldsel != -1) descr->items[oldsel].selected = FALSE;
     1296          if (index != -1) descr->items[index].selected = TRUE;
     1297
     1298          descr->selected_item = index;
     1299
     1300          if (oldsel != -1)
     1301            LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT);
     1302          if (index != -1)
     1303            LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT );
     1304
     1305          if (send_notify && descr->nb_items)
     1306            SEND_NOTIFICATION( hwnd, descr, (index != -1)
     1307                               ? LBN_SELCHANGE : LBN_SELCANCEL );
     1308          else
     1309            if( descr->lphc )
     1310              /* set selection change flag for parent combo */
     1311              descr->lphc->wState |= CBF_SELCHANGE;
     1312        }
     1313    }
     1314
     1315    /* "If the index parameter is -1, the return value is LB_ERR even though
     1316     * no error occurred." (At least for single selection boxes.) */
     1317    return (index == -1) ? LB_ERR : LB_OKAY;
    12981318}
    12991319
     
    13961416    {
    13971417        MEASUREITEMSTRUCT mis;
    1398         UINT                id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     1418        UINT              id = GetWindowLongA(hwnd,GWL_ID);
    13991419
    14001420        mis.CtlType    = ODT_LISTBOX;
     
    14901510    {
    14911511        DELETEITEMSTRUCT dis;
    1492         UINT               id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     1512        UINT             id = GetWindowLongA(hwnd,GWL_ID);
    14931513
    14941514        dis.CtlType  = ODT_LISTBOX;
     
    19771997
    19781998static LRESULT LISTBOX_HandleLButtonDownCombo( HWND hwnd, LB_DESCR *pDescr,
    1979                                                WPARAM wParam, INT x, INT y)
     1999                                               UINT msg,WPARAM wParam, INT x, INT y)
    19802000{
    19812001    RECT clientRect, screenRect;
     
    19892009    if(PtInRect(&clientRect, mousePos))
    19902010    {
    1991         /* MousePos is in client, resume normal processing */
    1992         return LISTBOX_HandleLButtonDown( hwnd, pDescr, wParam, x, y);
     2011      /* MousePos is in client, resume normal processing */
     2012      if (msg == WM_LBUTTONDOWN)
     2013      {
     2014         pDescr->lphc->droppedIndex = pDescr->nb_items ? pDescr->selected_item : -1;
     2015         return LISTBOX_HandleLButtonDown( hwnd, pDescr, wParam, x, y);
     2016      }
     2017      else if (pDescr->style & LBS_NOTIFY)
     2018        SEND_NOTIFICATION( hwnd, pDescr, LBN_DBLCLK );
     2019      return 0;
    19932020    }
    19942021    else
    19952022    {
    1996         POINT screenMousePos;
    1997         HWND hWndOldCapture;
    1998 
    1999         /* Check the Non-Client Area */
    2000         screenMousePos = mousePos;
    2001         hWndOldCapture = GetCapture();
     2023      POINT screenMousePos;
     2024      RECT screenRect;
     2025      HWND hWndOldCapture;
     2026//CB: read buglist
     2027      /* Check the Non-Client Area */
     2028      screenMousePos = mousePos;
     2029      hWndOldCapture = GetCapture();
     2030      GetWindowRect(hwnd,&screenRect);
     2031      ClientToScreen(hwnd,&screenMousePos);
     2032
     2033      if (!PtInRect(&screenRect,screenMousePos))
     2034      {
    20022035        ReleaseCapture();
    2003         GetWindowRect(hwnd, &screenRect);
    2004         ClientToScreen(hwnd, &screenMousePos);
    2005 
    2006         if(!PtInRect(&screenRect, screenMousePos))
    2007         {
    2008             /* Close The Drop Down */
    2009             SEND_NOTIFICATION( hwnd, pDescr, LBN_SELCANCEL );
    2010             return 0;
    2011         }
    2012         else
    2013         {
    2014             /* Check to see the NC is a scrollbar */
    2015             INT nHitTestType=0;
    2016             DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    2017             /* Check Vertical scroll bar */
    2018             if (dwStyle & WS_VSCROLL)
    2019             {
    2020                 clientRect.right += GetSystemMetrics(SM_CXVSCROLL);
    2021                 if (PtInRect( &clientRect, mousePos ))
    2022                 {
    2023                     nHitTestType = HTVSCROLL;
    2024                 }
    2025             }
    2026               /* Check horizontal scroll bar */
    2027             if (dwStyle & WS_HSCROLL)
    2028             {
    2029                 clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL);
    2030                 if (PtInRect( &clientRect, mousePos ))
    2031                 {
    2032                     nHitTestType = HTHSCROLL;
    2033                 }
    2034             }
    2035             /* Windows sends this message when a scrollbar is clicked
    2036              */
    2037 
    2038             if(nHitTestType != 0)
    2039             {
    2040                 SendMessageA(hwnd, WM_NCLBUTTONDOWN, nHitTestType,
    2041                     MAKELONG(screenMousePos.x, screenMousePos.y));
    2042             }
    2043             /* Resume the Capture after scrolling is complete
    2044              */
    2045             if(hWndOldCapture != 0)
    2046             {
    2047                 SetCapture(hWndOldCapture);
    2048             }
    2049         }
     2036        LISTBOX_SetSelection( hwnd, pDescr, pDescr->lphc->droppedIndex, FALSE, FALSE );
     2037        COMBO_FlipListbox( pDescr->lphc, FALSE, FALSE );
     2038
     2039        return 0;
     2040      } else
     2041      {
     2042        /* Check to see the NC is a scrollbar */
     2043        INT nHitTestType = SendMessageA(hwnd,WM_NCHITTEST,0,MAKELONG(screenMousePos.x,screenMousePos.y));
     2044
     2045        /* Windows sends this message when a scrollbar is clicked
     2046         */
     2047        if (nHitTestType != HTCLIENT)
     2048        {
     2049          SendMessageA(hwnd,(msg == WM_LBUTTONDOWN) ? WM_NCLBUTTONDOWN:WM_NCLBUTTONDBLCLK,nHitTestType,MAKELONG(screenMousePos.x,screenMousePos.y));
     2050        }
     2051
     2052        /* Resume the Capture after scrolling is complete
     2053         */
     2054        if (hWndOldCapture)
     2055        {
     2056          SetCapture(hWndOldCapture);
     2057        }
     2058      }
    20502059    }
    20512060    return 0;
     
    21352144{
    21362145    INT index;
    2137     TIMER_DIRECTION dir;
     2146    TIMER_DIRECTION dir = LB_TIMER_NONE;
    21382147
    21392148    if (GetCapture() != hwnd) return 0;
     
    21562165            x = descr->width - 1;
    21572166        }
    2158         else dir = LB_TIMER_NONE;  /* inside */
    21592167    }
    21602168    else
     
    21622170        if (y < 0) dir = LB_TIMER_UP;  /* above */
    21632171        else if (y >= descr->height) dir = LB_TIMER_DOWN;  /* below */
    2164         else dir = LB_TIMER_NONE;  /* inside */
    21652172    }
    21662173
     
    23562363    descr->nb_tabs       = 0;
    23572364    descr->tabs          = NULL;
    2358     descr->caret_on      = TRUE;
     2365    descr->caret_on      = lphc ? FALSE:TRUE;
    23592366    descr->in_focus      = FALSE;
    23602367    descr->captured      = FALSE;
     
    23882395        else
    23892396        {
    2390             UINT        id = (descr->lphc ) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     2397            UINT        id = GetWindowLongA(hwnd,GWL_ID);
    23912398
    23922399            mis.CtlType    = ODT_LISTBOX;
     
    30623069            }
    30633070            case WM_LBUTTONDOWN:
    3064                  return LISTBOX_HandleLButtonDownCombo( hwnd, descr, wParam,
     3071            case WM_LBUTTONDBLCLK:
     3072                 return LISTBOX_HandleLButtonDownCombo( hwnd, descr,msg, wParam,
    30653073                         (INT16)LOWORD(lParam), (INT16)HIWORD(lParam));
    30663074            case WM_MOUSEACTIVATE:
     
    30773085                           && (wParam == VK_DOWN || wParam == VK_UP)) )
    30783086                     {
    3079                          COMBO_FlipListbox( lphc, FALSE );
     3087                         COMBO_FlipListbox( lphc, FALSE, FALSE );
    30803088                         return 0;
    30813089                     }
Note: See TracChangeset for help on using the changeset viewer.