Ignore:
Timestamp:
Feb 14, 2000, 6:30:11 PM (26 years ago)
Author:
cbratschi
Message:

merged combobox with core 20000212

File:
1 edited

Legend:

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

    r2469 r2781  
    1 /* $Id: combo.cpp,v 1.24 2000-01-18 20:10:31 sandervl Exp $ */
     1/* $Id: combo.cpp,v 1.25 2000-02-14 17:30:10 cbratschi Exp $ */
    22/*
    33 * Combo controls
     
    88 * FIXME: roll up in Netscape 3.01.
    99 *
    10  * WINE version: 991212
     10 * Corel version: 20000212
     11 * (WINE version: 991212)
    1112 *
    1213 * Status:  in progress
     
    442443
    443444  if( !CB_GETTYPE(lphc) ) lphc->dwStyle |= CBS_SIMPLE;
    444   else if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT;
     445  if( CB_GETTYPE(lphc) != CBS_DROPDOWNLIST ) lphc->wState |= CBF_EDIT;
    445446
    446447  lphc->hwndself  = hwnd;
     
    521522      }
    522523      else                                      /* popup listbox */
     524      {
    523525        lbeStyle |= WS_POPUP;
     526        lbeStyle |= WS_EX_TOOLWINDOW;
     527      }
    524528
    525529     /* Dropdown ComboLBox is not a child window and we cannot pass
     
    535539                                       lphc->droppedRect.bottom - lphc->droppedRect.top,
    536540                                       lphc->hwndself,
    537                        (lphc->dwStyle & CBS_DROPDOWN)? (HMENU)0 : (HMENU)ID_CB_LISTBOX,
     541                                       (lphc->dwStyle & CBS_DROPDOWN)? (HMENU)0 : (HMENU)ID_CB_LISTBOX,
    538542                                       GetWindowLongA(lphc->hwndself,GWL_HINSTANCE),
    539543                                       (LPVOID)lphc );
     
    551555           (CB_GETTYPE(lphc) != CBS_SIMPLE) )
    552556      {
    553         SetWindowLongA(lphc->hWndLBox,
    554                        GWL_STYLE,
    555                        (GetWindowLongA(lphc->hWndLBox, GWL_STYLE) | WS_CHILD) & ~WS_POPUP);
     557        /*  Not using SetWindowLongA here because it doesn't allow us to
     558         *  change the WS_CHILD style. This code should be equivalent (excluding
     559         *  the change in owner) to:
     560         *       SetWindowLongA(lphc->hWndLBox, GWL_STYLE,
     561         *      (GetWindowLongA(lphc->hWndLBox,GWL_STYLE) | WS_CHILD) & ~WS_POPUP);
     562         */
     563        STYLESTRUCT style;
     564        Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(lphc->hWndLBox);
     565
     566        if (!win32wnd)
     567        {
     568          /* Is this the right error? */
     569          SetLastError( ERROR_INVALID_WINDOW_HANDLE );
     570          return 0;
     571        }
     572
     573        /* save old style, set new style */
     574        style.styleOld = win32wnd->getStyle();
     575        style.styleNew = (style.styleOld | WS_CHILD) & ~WS_POPUP;
     576
     577        SendMessageA(lphc->hWndLBox,WM_STYLECHANGING,GWL_STYLE,(LPARAM)&style);
     578#if 0 //CB: our code doesn't work with this style change
     579        win32wnd->setStyle(style.styleNew);
     580#endif
     581        SendMessageA(lphc->hWndLBox,WM_STYLECHANGED,GWL_STYLE,(LPARAM)&style);
     582
     583        /* Set owner to NULL - it seems to be what Windows does to a ComboLBox
     584         * after creation.
     585         */
     586        win32wnd->setOwner(NULL);
    556587      }
    557588
     
    10161047
    10171048   SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, pText ? (LPARAM)pText : (LPARAM)"" );
     1049   if( lphc->wState & CBF_FOCUSED )
     1050     SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
     1051
    10181052
    10191053   if( pText )
     
    10331067   int nHeight;
    10341068   int nDroppedHeight,nTempDroppedHeight;
     1069   int screenH
    10351070
    10361071   //TRACE("[%04x]: drop down\n", CB_HWND(lphc));
     
    10911126   nDroppedHeight = nTempDroppedHeight;
    10921127
    1093    SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
     1128   /*If height of dropped rectangle gets beyond a screen size it should go up, otherwise down.*/
     1129   screenH = GetSystemMetrics(SM_CYSCREEN);
     1130   if((rect.bottom + nDroppedHeight) >= screenH)
     1131   {
     1132     SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.top - nDroppedHeight,
    10941133                 lphc->droppedRect.right - lphc->droppedRect.left,
    10951134                 nDroppedHeight,
    10961135                 SWP_NOACTIVATE | SWP_NOREDRAW);
    1097 
     1136   }
     1137   else
     1138   {
     1139     SetWindowPos( lphc->hWndLBox, HWND_TOP, rect.left, rect.bottom,
     1140                 lphc->droppedRect.right - lphc->droppedRect.left,
     1141                 nDroppedHeight,
     1142                 SWP_NOACTIVATE | SWP_NOREDRAW);
     1143   }
    10981144
    10991145   if( !(lphc->wState & CBF_NOREDRAW) )
     
    13251371                }
    13261372
    1327                 CBUpdateLBox( lphc );
     1373                if (lphc->wState & CBF_NOLBSELECT)
     1374                {
     1375                  lphc->wState &= ~CBF_NOLBSELECT;
     1376                }
     1377                else
     1378                {
     1379                  CBUpdateLBox( lphc );
     1380                }
    13281381                break;
    13291382
     
    13571410                 * by arrowkeys in the dropdown listbox */
    13581411
    1359                 if( (lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP) )
    1360                      CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE );
     1412                if( (lphc->dwStyle & CBS_SIMPLE) ||
     1413                    ((lphc->wState & CBF_DROPPED) && !(lphc->wState & CBF_NOROLLUP)) )
     1414                {
     1415                   CBRollUp( lphc, (HIWORD(wParam) == LBN_SELCHANGE), TRUE );
     1416                }
    13611417                else lphc->wState &= ~CBF_NOROLLUP;
    13621418
     
    13641420                {
    13651421                    INT index = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
     1422
     1423                    lphc->wState |= CBF_NOLBSELECT;
    13661424                    CBUpdateEdit( lphc, index );
    13671425                    /* select text in edit, as Windows does */
     
    17371795}
    17381796
     1797static LRESULT COMBO_MouseWheel(HWND hwnd,WPARAM wParam,LPARAM lParam)
     1798{
     1799  if (wParam & (MK_SHIFT | MK_CONTROL))
     1800    return DefWindowProcA(hwnd,WM_MOUSEWHEEL,wParam,lParam);
     1801
     1802  if ((short) HIWORD(wParam) > 0) return SendMessageA(hwnd,WM_KEYDOWN,VK_UP,0);
     1803  if ((short) HIWORD(wParam) < 0) return SendMessageA(hwnd,WM_KEYDOWN,VK_DOWN,0);
     1804
     1805  return TRUE;
     1806}
     1807
    17391808static LRESULT COMBO_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam)
    17401809{
     
    20292098
    20302099  lParam = SendMessageA( lphc->hWndLBox, LB_SETCURSEL, wParam, 0);
     2100  if( lParam >= 0 )
     2101    SendMessageA( lphc->hWndLBox, LB_SETTOPINDEX, wParam, 0);
    20312102  if( lphc->wState & CBF_SELCHANGE )
    20322103  {
     
    22132284        case WM_MOUSEMOVE:
    22142285          return COMBO_MouseMove(hwnd,wParam,lParam);
     2286
     2287        case WM_MOUSEWHEEL:
     2288          return COMBO_MouseWheel(hwnd,wParam,lParam);
    22152289
    22162290        /* Combo messages */
Note: See TracChangeset for help on using the changeset viewer.