Ignore:
Timestamp:
Mar 18, 2000, 5:13:41 PM (25 years ago)
Author:
cbratschi
Message:

merged with Corel 20000317, small icon

File:
1 edited

Legend:

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

    r3144 r3153  
    1 /* $Id: listbox.cpp,v 1.23 2000-03-17 17:12:07 cbratschi Exp $ */
     1/* $Id: listbox.cpp,v 1.24 2000-03-18 16:13:30 cbratschi Exp $ */
    22/*
    33 * Listbox controls
     
    66 * Copyright 1999 Christoph Bratschi (ported from WINE)
    77 *
    8  * Corel version: 20000212
    9  * WINE version: 991212
     8 * Corel version: 20000317
     9 * (WINE version: 991212)
    1010 *
    1111 * Status: ???
     
    2626#include "dbglocal.h"
    2727
    28 /* Unimplemented yet:
     28/* bugs:
    2929 - LBS_NOSEL
    3030 - LBS_USETABSTOPS
     
    3434 - VK_LINEDOWN -> bottom most item not always visible
    3535 - performance not optimized
     36 - ownerdraw is broken -> toolbar customize dialog
     37 - first item selection mark not redrawn on new selection
    3638 */
    3739
     
    340342    descr->width  = rect.right - rect.left;
    341343    descr->height = rect.bottom - rect.top;
    342     if (!(descr->style & LBS_NOINTEGRALHEIGHT) && !IS_OWNERDRAW(descr))
     344    if (!(descr->style & LBS_NOINTEGRALHEIGHT) && !(descr->style & LBS_OWNERDRAWVARIABLE))
    343345    {
    344346        if ((descr->height > descr->item_height) &&
     
    480482    {
    481483        DRAWITEMSTRUCT dis;
    482         UINT             id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
     484        UINT           id = (descr->lphc) ? ID_CB_LISTBOX : GetWindowLongA(hwnd,GWL_ID);
    483485
    484486        if (!item)
     
    879881    INT i, col_pos = descr->page_size - 1;
    880882    RECT rect;
     883    RECT focusRect = {-1, -1, -1, -1};
    881884    HFONT oldFont = 0;
    882885    HBRUSH hbrush, oldBrush = 0;
    883886    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     887    INT focusItem;
    884888
    885889    SetRect( &rect, 0, 0, descr->width, descr->height );
     
    910914    }
    911915
     916    /* Paint all the item, regarding the selection
     917       Focus state will be painted after  */
     918    focusItem = descr->focus_item;
     919    descr->focus_item = -1;
     920
    912921    for (i = descr->top_item; i < descr->nb_items; i++)
    913922    {
     
    917926            rect.bottom = rect.top + descr->items[i].height;
    918927
     928        if (i == focusItem)
     929        {
     930            /* keep the focus rect, to paint the focus item after */
     931            focusRect.left = rect.left;
     932            focusRect.right = rect.right;
     933            focusRect.top = rect.top;
     934            focusRect.bottom = rect.bottom;
     935        }
    919936        LISTBOX_DrawItem( hwnd, descr, hdc, &rect, i, ODA_DRAWENTIRE );
    920937        rect.top = rect.bottom;
     
    946963        }
    947964    }
     965
     966    /* Paint the focus item now */
     967    descr->focus_item = focusItem;
     968    if (focusRect.top != focusRect.bottom)
     969        LISTBOX_DrawItem( hwnd, descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS );
    948970
    949971    if (!IS_OWNERDRAW(descr))
     
    12851307                               BOOL fully_visible )
    12861308{
    1287     LISTBOX_SetCaretIndex( hwnd, descr, index, fully_visible );
     1309    INT oldfocus = descr->focus_item;
     1310
     1311    if ((index <  0) || (index >= descr->nb_items) || (oldfocus == index))
     1312        return;
     1313
     1314    /* Important, repaint need ot be done in this order if
     1315       you want to mimic Windows behavior:
     1316       1. Remove the focus and paint the item
     1317       2. Remove the selection and paint the item(s)
     1318       3. Set the selection and repaint the item(s)
     1319       4. Set the focus to 'index' and repaint the item */
     1320
     1321    /* 1. remove the focus and repaint the item */
     1322    descr->focus_item = -1;
     1323    if ((oldfocus != -1) && descr->caret_on && (descr->in_focus))
     1324        LISTBOX_RepaintItem( hwnd, descr, oldfocus, ODA_FOCUS );
     1325
     1326    /* 2. then turn off the previous selection */
     1327    /* 3. repaint the new selected item */
    12881328    if (descr->style & LBS_EXTENDEDSEL)
    12891329    {
    12901330        if (descr->anchor_item != -1)
    12911331        {
    1292             INT first = MIN( descr->focus_item, descr->anchor_item );
    1293             INT last  = MAX( descr->focus_item, descr->anchor_item );
     1332            INT first = MIN( index, descr->anchor_item );
     1333            INT last  = MAX( index, descr->anchor_item );
    12941334            if (first > 0)
    12951335                LISTBOX_SelectItemRange( hwnd, descr, 0, first - 1, FALSE );
     
    13031343        LISTBOX_SetSelection( hwnd, descr, index, TRUE, FALSE );
    13041344    }
     1345
     1346    /* 4. repaint the new item with the focus */
     1347    descr->focus_item = index;
     1348    LISTBOX_MakeItemVisible( hwnd, descr, index, fully_visible );
     1349    if (descr->caret_on && (descr->in_focus))
     1350        LISTBOX_RepaintItem( hwnd, descr, index, ODA_FOCUS );
    13051351}
    13061352
Note: See TracChangeset for help on using the changeset viewer.