Ignore:
Timestamp:
Feb 21, 2000, 6:25:33 PM (26 years ago)
Author:
cbratschi
Message:

merged with Corel WINE 20000212, added WS_EX_CONTEXTHELP

File:
1 edited

Legend:

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

    r2804 r2852  
    1 /* $Id: listbox.cpp,v 1.19 2000-02-16 14:34:20 sandervl Exp $ */
     1/* $Id: listbox.cpp,v 1.20 2000-02-21 17:25:27 cbratschi Exp $ */
    22/*
    33 * Listbox controls
     
    66 * Copyright 1999 Christoph Bratschi (ported from WINE)
    77 *
     8 * Corel version: 20000212
    89 * WINE version: 991212
    910 */
     
    1819#include <misc.h>
    1920
    20 #define DBG_LOCALLOG    DBG_listbox
     21#define DBG_LOCALLOG    DBG_listbox
    2122#include "dbglocal.h"
    2223
     
    8182    BOOL        caret_on;       /* Is caret on? */
    8283    BOOL        captured;       /* Is mouse captured? */
     84    BOOL        in_focus;
    8385    HFONT       font;           /* Current font */
    8486    LCID          locale;         /* Current locale for string comparisons */
     
    172174    SCROLLINFO info;
    173175
    174     if (!(descr->style & WS_VSCROLL)) return;
     176    /* Check the listbox scroll bar flags individually before we call
     177       SetScrollInfo otherwise when the listbox style is WS_HSCROLL and
     178       no WS_VSCROLL, we end up with an uninitialized, visible horizontal
     179       scroll bar when we do not need one.
     180              if (!(descr->style & WS_VSCROLL)) return;
     181          */
     182
    175183    /*   It is important that we check descr->style, and not wnd->dwStyle,
    176184       for WS_VSCROLL, as the former is exactly the one passed in
     
    194202        if (descr->style & LBS_DISABLENOSCROLL)
    195203            info.fMask |= SIF_DISABLENOSCROLL;
    196         SetScrollInfo( hwnd, SB_HORZ, &info, TRUE );
     204        if (descr->style & WS_HSCROLL)
     205          SetScrollInfo( hwnd, SB_HORZ, &info, TRUE );
    197206        info.nMax = 0;
    198207        info.fMask = SIF_RANGE;
    199         SetScrollInfo( hwnd, SB_VERT, &info, TRUE );
     208        if (descr->style & WS_VSCROLL)
     209          SetScrollInfo( hwnd, SB_VERT, &info, TRUE );
    200210    }
    201211    else
     
    208218        if (descr->style & LBS_DISABLENOSCROLL)
    209219            info.fMask |= SIF_DISABLENOSCROLL;
    210 
    211         SetScrollInfo( hwnd, SB_VERT, &info, TRUE );
     220        if (descr->style & WS_VSCROLL)
     221          SetScrollInfo( hwnd, SB_VERT, &info, TRUE );
    212222
    213223        if (descr->horz_extent)
     
    220230            if (descr->style & LBS_DISABLENOSCROLL)
    221231                info.fMask |= SIF_DISABLENOSCROLL;
    222             SetScrollInfo( hwnd, SB_HORZ, &info, TRUE );
     232            if (descr->style & WS_HSCROLL)
     233              SetScrollInfo( hwnd, SB_HORZ, &info, TRUE );
    223234        }
    224235    }
     
    314325
    315326    GetWindowRect( hwnd, &rectWindow );
    316     OffsetRect(&rectWindow, -rectWindow.left, -rectWindow.top);
    317327    GetClientRect( hwnd, &rect );
    318328
     329    //CB: todo: doesn't works in ShellAbout dialog
    319330    descr->width  = rect.right - rect.left;
    320331    descr->height = rect.bottom - rect.top;
     
    479490        if ((descr->focus_item == index) &&
    480491            (descr->caret_on) &&
    481             (GetFocus() == hwnd)) dis.itemState |= ODS_FOCUS;
     492            (descr->in_focus)) dis.itemState |= ODS_FOCUS;
    482493        if (dwStyle & WS_DISABLED) dis.itemState |= ODS_DISABLED;
    483494        dis.itemData     = item ? item->data : 0;
     
    532543        if ((descr->focus_item == index) &&
    533544            (descr->caret_on) &&
    534             (GetFocus() == hwnd)) DrawFocusRect( hdc, rect );
     545            (descr->in_focus)) DrawFocusRect( hdc, rect );
    535546    }
    536547}
     
    878889
    879890    if (!descr->nb_items && (descr->focus_item != -1) && descr->caret_on &&
    880         (GetFocus() == hwnd))
     891        (descr->in_focus))
    881892    {
    882893        /* Special case for empty listbox: paint focus rect */
     
    10711082static LRESULT LISTBOX_SetColumnWidth( HWND hwnd, LB_DESCR *descr, UINT width)
    10721083{
    1073     width += 2;  /* For left and right margin */
    10741084    if (width == descr->column_width) return LB_OKAY;
    10751085    //TRACE("[%04x]: new column width = %d\n",
     
    12031213    if (index == oldfocus) return LB_OKAY;
    12041214    descr->focus_item = index;
    1205     if ((oldfocus != -1) && descr->caret_on && (GetFocus() == hwnd))
     1215    if ((oldfocus != -1) && descr->caret_on && (descr->in_focus))
    12061216        LISTBOX_RepaintItem( hwnd, descr, oldfocus, ODA_FOCUS );
    12071217
    12081218    LISTBOX_MakeItemVisible( hwnd, descr, index, fully_visible );
    1209     if (descr->caret_on && (GetFocus() == hwnd))
     1219    if (descr->caret_on && (descr->in_focus))
    12101220        LISTBOX_RepaintItem( hwnd, descr, index, ODA_FOCUS );
    12111221
     
    12351245        if (index != -1) descr->items[index].selected = TRUE;
    12361246        descr->selected_item = index;
    1237         if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, 0);
     1247        if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT);
    12381248        if (index != -1) LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT );
    12391249        if (send_notify && descr->nb_items) SEND_NOTIFICATION( hwnd, descr,
     
    14401450    if (index == -1) index = descr->nb_items - 1;
    14411451    else if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
     1452
     1453    /* We need to Invalidate the original rect intead of the updated one. */
     1454    LISTBOX_InvalidateItems( hwnd, descr, index );
     1455
    14421456    LISTBOX_DeleteItem( hwnd, descr, index );
    14431457
     
    14801494      }
    14811495    }
    1482     LISTBOX_InvalidateItems( hwnd, descr, index );
     1496
    14831497    if (descr->focus_item >= descr->nb_items)
    14841498    {
     
    17331747}
    17341748
     1749static LRESULT LISTBOX_HandleMouseWheel(HWND hwnd, LB_DESCR *descr,WPARAM wParam, LPARAM lParam )
     1750{
     1751    short gcWheelDelta = 0;
     1752    UINT pulScrollLines = 3;
     1753
     1754    SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
     1755
     1756    gcWheelDelta -= (short) HIWORD(wParam);
     1757
     1758    if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines)
     1759    {
     1760        int cLineScroll = (int) min((UINT) descr->page_size, pulScrollLines);
     1761        cLineScroll *= (gcWheelDelta / WHEEL_DELTA);
     1762        LISTBOX_SetTopItem( hwnd, descr, descr->top_item + cLineScroll, TRUE );
     1763    }
     1764    return 0;
     1765}
    17351766
    17361767/***********************************************************************
     
    17431774    //TRACE("[%04x]: lbuttondown %d,%d item %d\n",
    17441775    //             wnd->hwndSelf, x, y, index );
    1745     if (!descr->caret_on && (GetFocus() == hwnd)) return 0;
     1776    if (!descr->caret_on && (descr->in_focus)) return 0;
    17461777    if (index != -1)
    17471778    {
     
    17681799    }
    17691800
    1770     if( !descr->lphc ) SetFocus( hwnd );
    1771     else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit
     1801    if (!descr->in_focus)
     1802    {
     1803      if( !descr->lphc ) SetFocus( hwnd );
     1804      else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit
    17721805                                             : descr->lphc->hwndself ) ;
     1806    }
    17731807
    17741808    descr->captured = TRUE;
     
    21912225    descr->tabs          = NULL;
    21922226    descr->caret_on      = TRUE;
     2227    descr->in_focus      = FALSE;
    21932228    descr->captured      = FALSE;
    21942229    descr->font          = 0;
     
    24832518            return LB_OKAY;
    24842519        descr->caret_on = TRUE;
    2485         if ((descr->focus_item != -1) && (GetFocus() == hwnd))
     2520        if ((descr->focus_item != -1) && (descr->in_focus))
    24862521            LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS );
    24872522        return LB_OKAY;
     
    24912526            return LB_OKAY;
    24922527        descr->caret_on = FALSE;
    2493         if ((descr->focus_item != -1) && (GetFocus() == hwnd))
     2528        if ((descr->focus_item != -1) && (descr->in_focus))
    24942529            LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS );
    24952530        return LB_OKAY;
     
    25282563        return 0;
    25292564    case WM_SETFOCUS:
     2565        descr->in_focus = TRUE;
    25302566        descr->caret_on = TRUE;
    25312567        if (descr->focus_item != -1)
     
    25342570        return 0;
    25352571    case WM_KILLFOCUS:
     2572        descr->in_focus = FALSE;
    25362573        if ((descr->focus_item != -1) && descr->caret_on)
    25372574            LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS );
     
    25422579    case WM_VSCROLL:
    25432580        return LISTBOX_HandleVScroll( hwnd, descr, wParam, lParam );
     2581    case WM_MOUSEACTIVATE:
     2582        return MA_NOACTIVATE;
     2583    case WM_MOUSEWHEEL:
     2584        if (wParam & (MK_SHIFT | MK_CONTROL))
     2585            return DefWindowProcA( hwnd, msg, wParam, lParam );
     2586        return LISTBOX_HandleMouseWheel( hwnd, descr, wParam, lParam );
    25442587    case WM_LBUTTONDOWN:
    25452588        return LISTBOX_HandleLButtonDown( hwnd, descr, wParam,
     
    26502693                 return LISTBOX_Create( hwnd, lphc );
    26512694            case WM_MOUSEMOVE:
    2652                  if (CB_GETTYPE(lphc) != CBS_SIMPLE)
     2695                 if (lphc && (CB_GETTYPE(lphc) != CBS_SIMPLE))
    26532696                 {
    26542697                   POINT   mousePos;
     
    26912734                 }
    26922735            case WM_LBUTTONUP:
     2736            if (lphc)
     2737            {
    26932738                 POINT mousePos;
    26942739                 RECT  clientRect;
     
    27192764                 }
    27202765                 return LISTBOX_HandleLButtonUp( hwnd, descr );
     2766            }
    27212767            case WM_LBUTTONDOWN:
    27222768                 return LISTBOX_HandleLButtonDownCombo( hwnd, descr, wParam,
     
    27272773                 return FALSE;
    27282774            case WM_KEYDOWN:
    2729                  if( CB_GETTYPE(lphc) != CBS_SIMPLE )
     2775                 if(lphc && (CB_GETTYPE(lphc) != CBS_SIMPLE))
    27302776                 {
    27312777                     /* for some reason(?) Windows makes it possible to
     
    27462792                 return lRet;
    27472793            case WM_NCDESTROY:
    2748                  if( CB_GETTYPE(lphc) != CBS_SIMPLE )
     2794                 if(lphc && (CB_GETTYPE(lphc) != CBS_SIMPLE))
    27492795                     lphc->hWndLBox = 0;
    27502796                 /* fall through */
Note: See TracChangeset for help on using the changeset viewer.