Commit 72bdd5be authored by Alexandre Julliard's avatar Alexandre Julliard

Stephane Lussier

Sheri Steeves Haithem Hmida - Height of the listbox should be adjust when LBS_OWNERDRAWFIXED is set and not if LBS_OWNERDRAWVARIABLE is set, previously it was not adjusting the size in both cases. - When the caret index change, items repainting need tp be in this order a) Paint old caret item without the focus b) Paint old caret item without the selection c) Paint new caret item with the selection d) Paint new caret item with the focus. - When repainting the listbox, we should paint all items regarding if they are slected or not and then paint after the focus item. So focus item will end out being painted twice. (That's what Windows does).
parent feb71a69
......@@ -343,7 +343,7 @@ static void LISTBOX_UpdateSize( WND *wnd, LB_DESCR *descr )
GetClientRect( wnd->hwndSelf, &rect );
descr->width = rect.right - rect.left;
descr->height = rect.bottom - rect.top;
if (!(descr->style & LBS_NOINTEGRALHEIGHT) && !IS_OWNERDRAW(descr))
if (!(descr->style & LBS_NOINTEGRALHEIGHT) && !(descr->style & LBS_OWNERDRAWVARIABLE))
{
if ((descr->height > descr->item_height) &&
(descr->height % descr->item_height))
......@@ -893,8 +893,10 @@ static LRESULT LISTBOX_Paint( WND *wnd, LB_DESCR *descr, HDC hdc )
{
INT i, col_pos = descr->page_size - 1;
RECT rect;
RECT focusRect = {-1, -1, -1, -1};
HFONT oldFont = 0;
HBRUSH hbrush, oldBrush = 0;
INT focusItem;
SetRect( &rect, 0, 0, descr->width, descr->height );
if (descr->style & LBS_NOREDRAW) return 0;
......@@ -923,6 +925,11 @@ static LRESULT LISTBOX_Paint( WND *wnd, LB_DESCR *descr, HDC hdc )
rect.top = rect.bottom;
}
/* Paint all the item, regarding the selection
Focus state will be painted after */
focusItem = descr->focus_item;
descr->focus_item = -1;
for (i = descr->top_item; i < descr->nb_items; i++)
{
if (!(descr->style & LBS_OWNERDRAWVARIABLE))
......@@ -930,6 +937,14 @@ static LRESULT LISTBOX_Paint( WND *wnd, LB_DESCR *descr, HDC hdc )
else
rect.bottom = rect.top + descr->items[i].height;
if (i == focusItem)
{
/* keep the focus rect, to paint the focus item after */
focusRect.left = rect.left;
focusRect.right = rect.right;
focusRect.top = rect.top;
focusRect.bottom = rect.bottom;
}
LISTBOX_PaintItem( wnd, descr, hdc, &rect, i, ODA_DRAWENTIRE );
rect.top = rect.bottom;
......@@ -960,6 +975,11 @@ static LRESULT LISTBOX_Paint( WND *wnd, LB_DESCR *descr, HDC hdc )
}
}
/* Paint the focus item now */
descr->focus_item = focusItem;
if (focusRect.top != focusRect.bottom)
LISTBOX_PaintItem( wnd, descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS );
if (!IS_OWNERDRAW(descr))
{
/* Clear the remainder of the client area */
......@@ -1290,13 +1310,31 @@ static LRESULT LISTBOX_SetSelection( WND *wnd, LB_DESCR *descr, INT index,
static void LISTBOX_MoveCaret( WND *wnd, LB_DESCR *descr, INT index,
BOOL fully_visible )
{
LISTBOX_SetCaretIndex( wnd, descr, index, fully_visible );
INT oldfocus = descr->focus_item;
if ((index < 0) || (index >= descr->nb_items))
return;
/* Important, repaint needs to be done in this order if
you want to mimic Windows behavior:
1. Remove the focus and paint the item
2. Remove the selection and paint the item(s)
3. Set the selection and repaint the item(s)
4. Set the focus to 'index' and repaint the item */
/* 1. remove the focus and repaint the item */
descr->focus_item = -1;
if ((oldfocus != -1) && descr->caret_on && (descr->in_focus))
LISTBOX_RepaintItem( wnd, descr, oldfocus, ODA_FOCUS );
/* 2. then turn off the previous selection */
/* 3. repaint the new selected item */
if (descr->style & LBS_EXTENDEDSEL)
{
if (descr->anchor_item != -1)
{
INT first = min( descr->focus_item, descr->anchor_item );
INT last = max( descr->focus_item, descr->anchor_item );
INT first = min( index, descr->anchor_item );
INT last = max( index, descr->anchor_item );
if (first > 0)
LISTBOX_SelectItemRange( wnd, descr, 0, first - 1, FALSE );
LISTBOX_SelectItemRange( wnd, descr, last + 1, -1, FALSE );
......@@ -1308,6 +1346,12 @@ static void LISTBOX_MoveCaret( WND *wnd, LB_DESCR *descr, INT index,
/* Set selection to new caret item */
LISTBOX_SetSelection( wnd, descr, index, TRUE, FALSE );
}
/* 4. repaint the new item with the focus */
descr->focus_item = index;
LISTBOX_MakeItemVisible( wnd, descr, index, fully_visible );
if (descr->caret_on && (descr->in_focus))
LISTBOX_RepaintItem( wnd, descr, index, ODA_FOCUS );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment