38 #define LB_ARRAY_GRANULARITY 16 41 #define LB_SCROLL_TIMEOUT 50 47 #define LBS_DISPLAYCHANGED 0x80000000 91 #define IS_OWNERDRAW(descr) \ 92 ((descr)->style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE)) 94 #define HAS_STRINGS(descr) \ 95 (!IS_OWNERDRAW(descr) || ((descr)->style & LBS_HASSTRINGS)) 98 #define IS_MULTISELECT(descr) \ 99 ((descr)->style & (LBS_MULTIPLESEL|LBS_EXTENDEDSEL) && \ 100 !((descr)->style & LBS_NOSEL)) 102 #define SEND_NOTIFICATION(descr,code) \ 103 (SendMessageW( (descr)->owner, WM_COMMAND, \ 104 MAKEWPARAM( GetWindowLongPtrW((descr->self),GWLP_ID), (code)), (LPARAM)(descr->self) )) 106 #define ISWIN31 (LOWORD(GetVersion()) == 0x0a03) 163 for (
i =
descr->top_item,
height = 0; i < descr->nb_items;
i++)
167 if (
i ==
descr->top_item)
return 1;
168 else return i -
descr->top_item;
186 if (max < descr->nb_items - 1)
max++;
296 TRACE(
"setting top item %d, scroll %d\n",
index, scroll);
314 diff -=
descr->items[
i].height;
319 diff +=
descr->items[
i].height;
384 if(
descr->item_height != 0)
385 remaining =
descr->height %
descr->item_height;
388 if ((
descr->height >
descr->item_height) && remaining)
390 TRACE(
"[%p]: changing height %d -> %d\n",
478 if (!
descr->nb_items)
return -1;
501 if (
y >=
descr->item_height *
descr->page_size)
return -1;
510 if (
index < 0)
return 0;
537 if (!(
descr->UIState & UISF_HIDEFOCUS))
541 ERR(
"called with an out of bounds index %d(%d) in owner draw, Not good.\n",
index,
descr->nb_items);
560 if (!ignoreFocus && (
descr->focus_item ==
index) &&
566 TRACE(
"[%p]: drawitem %d (%s) action=%02x state=%02x rect=%s\n",
579 if (!(
descr->UIState & UISF_HIDEFOCUS))
589 TRACE(
"[%p]: painting %d (%s) action=%02x rect=%s\n",
613 if (!ignoreFocus && (
descr->focus_item ==
index) &&
658 HBRUSH
hbrush, oldBrush = 0;
699 if (
descr->focus_item == -1)
return;
700 if (!
descr->caret_on || !
descr->in_focus)
return;
768 for (
i = 0;
i <
descr->nb_tabs;
i++)
815 ERR(
"got an invalid buffer (Delphi bug?)\n" );
879 return exact ? -1 :
max;
903 if (*
str !=
'[')
res = -1;
904 else if (
p[1] ==
'-')
911 if (
str[1] ==
'-')
res = 1;
953 #define CHECK_DRIVE(item) \ 954 if ((item)->str[0] == '[') \ 956 if (!strncmpiW( str, (item)->str+1, len )) return i; \ 957 if (((item)->str[1] == '-') && !strncmpiW(str, (item)->str+2, len)) \ 1030 RECT focusRect = {-1, -1, -1, -1};
1032 HBRUSH
hbrush, oldBrush = 0;
1039 else if (
descr->horz_pos)
1055 if (!
descr->nb_items && (
descr->focus_item != -1) &&
descr->caret_on &&
1069 for (
i =
descr->top_item; i < descr->nb_items;
i++)
1077 if (
i ==
descr->focus_item)
1100 col_pos =
descr->page_size - 1;
1110 if (focusRect.
top != focusRect.
bottom &&
1191 else return descr->item_height;
1241 if (!(diff =
descr->horz_pos -
pos))
return;
1307 const char *alphabet =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1314 ERR(
"unable to get DC.\n" );
1322 descr->avg_char_width = (sz.
cx / 26 + 1) / 2;
1338 TRACE(
"current top item %d, index %d, fully %d\n",
descr->top_item,
index, fully);
1344 if (!fully) cols +=
descr->column_width - 1;
1345 if (cols >=
descr->column_width) cols /=
descr->column_width;
1377 TRACE(
"old focus %d, index %d\n", oldfocus,
index);
1418 if (
descr->items[
i].selected)
continue;
1427 if (!
descr->items[
i].selected)
continue;
1441 TRACE(
"cur_sel=%d index=%d notify=%s\n",
1461 if (oldsel != -1)
descr->items[oldsel].selected =
FALSE;
1502 if (
descr->anchor_item != -1)
1537 if (!
descr->items) max_items = 0;
1539 if (
descr->nb_items == max_items)
1582 item->height = mis.itemHeight ? mis.itemHeight : 1;
1583 TRACE(
"[%p]: measure item %d (%s) = %d\n",
1594 if (
descr->nb_items == 1)
1599 descr->selected_item++;
1606 descr->selected_item++;
1607 descr->focus_item = oldfocus;
1643 TRACE(
"[%p]: added item %d %s\n",
1660 if (!
descr->nb_items)
1735 descr->selected_item = -1;
1738 descr->selected_item--;
1747 if (
descr->focus_item < 0)
descr->focus_item = 0;
1762 descr->nb_items = 0;
1763 descr->top_item = 0;
1764 descr->selected_item = -1;
1765 descr->focus_item = 0;
1766 descr->anchor_item = -1;
1830 static const WCHAR bracketW[] = {
']',0 };
1835 if (!long_names &&
entry.cAlternateFileName[0])
1843 #define ATTRIBS (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \ 1844 FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE) 1850 if (!long_names &&
entry.cAlternateFileName[0])
1859 if (
ret <= maxinsert) maxinsert++;
else maxinsert =
ret;
1984 else if (
descr->horz_extent)
2025 UINT pulScrollLines = 3;
2030 if ((delta < 0 && descr->wheel_remain < 0) ||
2031 (delta > 0 &&
descr->wheel_remain > 0))
2032 descr->wheel_remain += delta;
2034 descr->wheel_remain = delta;
2036 if (
descr->wheel_remain && pulScrollLines)
2039 pulScrollLines =
min((
UINT)
descr->page_size, pulScrollLines);
2043 if (cLineScroll < 0)
2044 cLineScroll -=
descr->page_size;
2058 TRACE(
"[%p]: lbuttondown %d,%d item %d, focus item %d\n",
2061 if (!
descr->caret_on && (
descr->in_focus))
return 0;
2063 if (!
descr->in_focus)
2069 if (
index == -1)
return 0;
2161 RECT clientRect, screenRect;
2169 if(
PtInRect(&clientRect, mousePos))
2174 descr->lphc->droppedIndex =
descr->nb_items ?
descr->selected_item : -1;
2182 POINT screenMousePos;
2183 HWND hWndOldCapture;
2186 screenMousePos = mousePos;
2192 if(!
PtInRect(&screenRect, screenMousePos))
2207 if (
PtInRect( &clientRect, mousePos ))
2214 if (
PtInRect( &clientRect, mousePos ))
2220 if(nHitTestType != 0)
2223 MAKELONG(screenMousePos.
x, screenMousePos.
y));
2227 if(hWndOldCapture != 0)
2242 if (
descr->captured)
2315 if (!
descr->captured)
return;
2320 else if (
y >=
descr->item_height *
descr->page_size)
2328 else if (
x >=
descr->width)
2362 bForceSelection =
FALSE;
2369 if (caret == -2)
return 0;
2371 if (caret == -1)
switch(
key)
2376 bForceSelection =
FALSE;
2378 caret =
descr->focus_item -
descr->page_size;
2383 caret =
descr->focus_item - 1;
2384 if (caret < 0) caret = 0;
2389 bForceSelection =
FALSE;
2391 caret =
descr->focus_item +
descr->page_size;
2396 caret =
descr->focus_item + 1;
2397 if (caret >=
descr->nb_items) caret =
descr->nb_items - 1;
2408 if (caret < 0) caret = 0;
2418 if (caret >=
descr->nb_items) caret =
descr->nb_items - 1;
2424 caret =
descr->nb_items - 1;
2436 bForceSelection =
FALSE;
2438 if (bForceSelection)
2439 caret =
descr->focus_item;
2445 descr->anchor_item = caret;
2449 descr->selected_item = caret;
2482 if (caret == -2)
return 0;
2502 prev_flags =
descr->UIState;
2504 return prev_flags !=
descr->UIState;
2527 descr->nb_items = 0;
2528 descr->top_item = 0;
2529 descr->selected_item = -1;
2530 descr->focus_item = 0;
2531 descr->anchor_item = -1;
2532 descr->item_height = 1;
2533 descr->page_size = 1;
2534 descr->column_width = 150;
2535 descr->horz_extent = 0;
2536 descr->horz_pos = 0;
2539 descr->wheel_remain = 0;
2540 descr->caret_on = !lphc;
2590 descr->item_height = mis.itemHeight ? mis.itemHeight : 1;
2634 ERR(
"Wrong window class for listbox! fnId 0x%x\n",pWnd->
fnid);
2659 TRACE(
"[%p]: msg %s wp %08lx lp %08lx\n",
2761 return descr->nb_items;
2787 return descr->nb_items;
2804 if (
descr->nb_items == 0)
2807 return descr->selected_item;
2808 if (
descr->selected_item != -1)
2809 return descr->selected_item;
2810 return descr->focus_item;
2814 return descr->top_item;
2833 if(
descr->nb_items == 0)
2870 return descr->focus_item;
2983 return descr->horz_extent;
2989 return descr->anchor_item;
3020 return descr->locale;
3042 if (
descr->caret_on)
3045 if ((
descr->focus_item != -1) && (
descr->in_focus))
3050 if (!
descr->caret_on)
3053 if ((
descr->focus_item != -1) && (
descr->in_focus))
3058 return descr->page_size;
3095 if (
descr->focus_item != -1)
3102 descr->wheel_remain = 0;
3103 if ((
descr->focus_item != -1) &&
descr->caret_on)
3150 descr->captured = captured;
3234 if( lphc )
return 0;
3250 case WM_UPDATEUISTATE:
3259 if (
descr->focus_item != -1)
3266 WARN(
"[%p]: unknown msg %04x wp %08lx lp %08lx\n",
LRESULT WINAPI ListBoxWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
static DWORD(WINAPI *pGetListBoxInfo)(HWND)
#define ERROR_INVALID_PARAMETER
static INT LISTBOX_SetFont(LB_DESCR *descr, HFONT font)
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
static INT LISTBOX_GetMaxTopIndex(const LB_DESCR *descr)
GLint GLint GLsizei width
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define LB_INSERTSTRING_LOWER
static TIMER_DIRECTION LISTBOX_Timer
WINE_UNICODE_INLINE WCHAR * strlwrW(WCHAR *str)
LRESULT WINAPI ListBoxWndProcW(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
#define LB_FINDSTRINGEXACT
static const WCHAR combolboxW[]
#define CSTR_GREATER_THAN
#define CHECK_DRIVE(item)
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define LB_SETCOLUMNWIDTH
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define LB_SETHORIZONTALEXTENT
static LRESULT LISTBOX_Directory(LB_DESCR *descr, UINT attrib, LPCWSTR filespec, BOOL long_names)
#define WideCharToMultiByte
static void LISTBOX_HandleMouseMove(LB_DESCR *descr, INT x, INT y)
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define LB_GETHORIZONTALEXTENT
#define IS_MULTISELECT(descr)
#define LBS_DISPLAYCHANGED
#define ERROR_SETCOUNT_ON_BAD_LB
static BOOL LISTBOX_update_uistate(LB_DESCR *descr)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI GetTextExtentPointA(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
GLdouble GLdouble GLdouble r
#define LBS_WANTKEYBOARDINPUT
GLuint GLuint GLsizei count
static INT LISTBOX_GetCurrentPageSize(const LB_DESCR *descr)
LPWSTR WINAPI CharLowerW(_Inout_ LPWSTR)
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
static void LISTBOX_DeleteItem(LB_DESCR *descr, INT index)
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
#define IS_OWNERDRAW(descr)
static void LISTBOX_RepaintItem(LB_DESCR *descr, INT index, UINT action)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
#define INVALID_HANDLE_VALUE
DWORD WINAPI GetLastError(VOID)
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
HWND WINAPI SetFocus(_In_opt_ HWND)
static void LISTBOX_UpdateScroll(LB_DESCR *descr)
LCID WINAPI GetUserDefaultLCID(void)
#define GetWindowLongPtrW
static const WCHAR listboxW[]
#define LB_SCROLL_TIMEOUT
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define strncmpiW(s1, s2, n)
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
static LRESULT LISTBOX_InsertItem(LB_DESCR *descr, INT index, LPWSTR str, ULONG_PTR data)
#define WM_CTLCOLORLISTBOX
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
static LRESULT LISTBOX_HandleHScroll(LB_DESCR *descr, WORD scrollReq, WORD pos)
static void LISTBOX_ResetContent(LB_DESCR *descr)
DWORD WINAPI GetSysColor(_In_ int)
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
static LRESULT LISTBOX_HandleLButtonUp(LB_DESCR *descr)
#define LB_ADDSTRING_UPPER
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LB_GETANCHORINDEX
#define RtlMoveMemory(Destination, Source, Length)
WINE_DEFAULT_DEBUG_CHANNEL(listbox2)
const char * SPY_GetMsgName(UINT msg, HWND hWnd)
static BOOL LISTBOX_Create(HWND hwnd, LPHEADCOMBO lphc)
#define LBS_OWNERDRAWFIXED
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
static void LISTBOX_MakeItemVisible(LB_DESCR *descr, INT index, BOOL fully)
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
#define LBS_NOINTEGRALHEIGHT
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
static struct _test_info info[]
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
static char selected[MAX_PATH+1]
LONG WINAPI TabbedTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(chCount) LPCWSTR lpString, _In_ int chCount, _In_ int nTabPositions, _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions, _In_ int nTabOrigin)
HWND WINAPI GetCapture(void)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
static LRESULT LISTBOX_SetHorizontalExtent(LB_DESCR *descr, INT extent)
static LRESULT LISTBOX_HandleLButtonDownCombo(LB_DESCR *descr, UINT msg, DWORD keys, INT x, INT y)
static void LISTBOX_DrawFocusRect(LB_DESCR *descr, BOOL on)
static void LISTBOX_UpdateSize(LB_DESCR *descr)
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
BOOL WINAPI IsWindowEnabled(_In_ HWND)
static LRESULT LISTBOX_InsertString(LB_DESCR *descr, INT index, LPCWSTR str)
#define COLOR_HIGHLIGHTTEXT
#define ERROR_FILE_NOT_FOUND
#define ERROR_NO_MORE_FILES
UINT_PTR WINAPI SetSystemTimer(HWND, UINT_PTR, UINT, TIMERPROC)
#define FILE_ATTRIBUTE_DIRECTORY
SHORT WINAPI GetKeyState(_In_ int)
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
static INT LISTBOX_FindStringPos(LB_DESCR *descr, LPCWSTR str, BOOL exact)
#define LB_ARRAY_GRANULARITY
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static LRESULT LISTBOX_SelectItemRange(LB_DESCR *descr, INT first, INT last, BOOL on)
static LRESULT LISTBOX_HandleVScroll(LB_DESCR *descr, WORD scrollReq, WORD pos)
#define EXCEPTION_EXECUTE_HANDLER
static const char textA[]
static void LISTBOX_InvalidateItemRect(LB_DESCR *descr, INT index)
const char * wine_dbgstr_rect(const RECT *rect)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int WINAPI GetSystemMetrics(_In_ int)
static INT LISTBOX_GetItemFromPoint(const LB_DESCR *descr, INT x, INT y)
static LRESULT LISTBOX_HandleLButtonDown(LB_DESCR *descr, DWORD keys, INT x, INT y)
static LRESULT LISTBOX_SetCount(LB_DESCR *descr, INT count)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
static LRESULT LISTBOX_InitStorage(LB_DESCR *descr, INT nb_items)
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
BOOL WINAPI IsValidLocale(LCID lcid, DWORD flags)
static LRESULT LISTBOX_SetColumnWidth(LB_DESCR *descr, INT width)
static BOOL LISTBOX_SetTabStops(LB_DESCR *descr, INT count, LPINT tabs)
static LRESULT LISTBOX_GetSelCount(const LB_DESCR *descr)
static LRESULT LISTBOX_HandleMouseWheel(LB_DESCR *descr, SHORT delta)
#define memcpy(s1, s2, n)
#define SEND_NOTIFICATION(descr, code)