ReactOS  0.4.15-dev-1070-ge1a01de
listbox.c File Reference
#include <user32.h>
Include dependency graph for listbox.c:

Go to the source code of this file.

Classes

struct  LB_ITEMDATA
 
struct  LB_DESCR
 

Macros

#define LB_ARRAY_GRANULARITY   16
 
#define LB_SCROLL_TIMEOUT   50
 
#define LB_TIMER_ID   2
 
#define LBS_DISPLAYCHANGED   0x80000000
 
#define IS_OWNERDRAW(descr)   ((descr)->style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE))
 
#define HAS_STRINGS(descr)   (!IS_OWNERDRAW(descr) || ((descr)->style & LBS_HASSTRINGS))
 
#define IS_MULTISELECT(descr)
 
#define SEND_NOTIFICATION(descr, code)
 
#define ISWIN31   (LOWORD(GetVersion()) == 0x0a03)
 
#define CHECK_DRIVE(item)
 
#define ATTRIBS
 

Enumerations

enum  TIMER_DIRECTION {
  LB_TIMER_NONE, LB_TIMER_UP, LB_TIMER_LEFT, LB_TIMER_DOWN,
  LB_TIMER_RIGHT, LB_TIMER_NONE, LB_TIMER_UP, LB_TIMER_LEFT,
  LB_TIMER_DOWN, LB_TIMER_RIGHT
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (listbox)
 
static LRESULT LISTBOX_GetItemRect (const LB_DESCR *descr, INT index, RECT *rect)
 
static INT LISTBOX_GetCurrentPageSize (const LB_DESCR *descr)
 
static INT LISTBOX_GetMaxTopIndex (const LB_DESCR *descr)
 
static void LISTBOX_UpdateScroll (LB_DESCR *descr)
 
static LRESULT LISTBOX_SetTopItem (LB_DESCR *descr, INT index, BOOL scroll)
 
static void LISTBOX_UpdatePage (LB_DESCR *descr)
 
static void LISTBOX_UpdateSize (LB_DESCR *descr)
 
static INT LISTBOX_GetItemFromPoint (const LB_DESCR *descr, INT x, INT y)
 
static void LISTBOX_PaintItem (LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus)
 
static void LISTBOX_SetRedraw (LB_DESCR *descr, BOOL on)
 
static void LISTBOX_RepaintItem (LB_DESCR *descr, INT index, UINT action)
 
static void LISTBOX_DrawFocusRect (LB_DESCR *descr, BOOL on)
 
static LRESULT LISTBOX_InitStorage (LB_DESCR *descr, INT nb_items)
 
static BOOL LISTBOX_SetTabStops (LB_DESCR *descr, INT count, LPINT tabs)
 
static LRESULT LISTBOX_GetText (LB_DESCR *descr, INT index, LPWSTR buffer, BOOL unicode)
 
static INT LISTBOX_lstrcmpiW (LCID lcid, LPCWSTR str1, LPCWSTR str2)
 
static INT LISTBOX_FindStringPos (LB_DESCR *descr, LPCWSTR str, BOOL exact)
 
static INT LISTBOX_FindFileStrPos (LB_DESCR *descr, LPCWSTR str)
 
static INT LISTBOX_FindString (LB_DESCR *descr, INT start, LPCWSTR str, BOOL exact)
 
static LRESULT LISTBOX_GetSelCount (const LB_DESCR *descr)
 
static LRESULT LISTBOX_GetSelItems (const LB_DESCR *descr, INT max, LPINT array)
 
static LRESULT LISTBOX_Paint (LB_DESCR *descr, HDC hdc)
 
static void LISTBOX_InvalidateItems (LB_DESCR *descr, INT index)
 
static void LISTBOX_InvalidateItemRect (LB_DESCR *descr, INT index)
 
static LRESULT LISTBOX_GetItemHeight (const LB_DESCR *descr, INT index)
 
static LRESULT LISTBOX_SetItemHeight (LB_DESCR *descr, INT index, INT height, BOOL repaint)
 
static void LISTBOX_SetHorizontalPos (LB_DESCR *descr, INT pos)
 
static LRESULT LISTBOX_SetHorizontalExtent (LB_DESCR *descr, INT extent)
 
static LRESULT LISTBOX_SetColumnWidth (LB_DESCR *descr, INT width)
 
static INT LISTBOX_SetFont (LB_DESCR *descr, HFONT font)
 
static void LISTBOX_MakeItemVisible (LB_DESCR *descr, INT index, BOOL fully)
 
static LRESULT LISTBOX_SetCaretIndex (LB_DESCR *descr, INT index, BOOL fully_visible)
 
static LRESULT LISTBOX_SelectItemRange (LB_DESCR *descr, INT first, INT last, BOOL on)
 
static LRESULT LISTBOX_SetSelection (LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
 
static void LISTBOX_MoveCaret (LB_DESCR *descr, INT index, BOOL fully_visible)
 
static LRESULT LISTBOX_InsertItem (LB_DESCR *descr, INT index, LPWSTR str, ULONG_PTR data)
 
static LRESULT LISTBOX_InsertString (LB_DESCR *descr, INT index, LPCWSTR str)
 
static void LISTBOX_DeleteItem (LB_DESCR *descr, INT index)
 
static LRESULT LISTBOX_RemoveItem (LB_DESCR *descr, INT index)
 
static void LISTBOX_ResetContent (LB_DESCR *descr)
 
static LRESULT LISTBOX_SetCount (LB_DESCR *descr, INT count)
 
static LRESULT LISTBOX_Directory (LB_DESCR *descr, UINT attrib, LPCWSTR filespec, BOOL long_names)
 
static LRESULT LISTBOX_HandleVScroll (LB_DESCR *descr, WORD scrollReq, WORD pos)
 
static LRESULT LISTBOX_HandleHScroll (LB_DESCR *descr, WORD scrollReq, WORD pos)
 
static LRESULT LISTBOX_HandleMouseWheel (LB_DESCR *descr, SHORT delta)
 
static LRESULT LISTBOX_HandleLButtonDown (LB_DESCR *descr, DWORD keys, INT x, INT y)
 
static LRESULT LISTBOX_HandleLButtonDownCombo (LB_DESCR *descr, UINT msg, DWORD keys, INT x, INT y)
 
static LRESULT LISTBOX_HandleLButtonUp (LB_DESCR *descr)
 
static LRESULT LISTBOX_HandleTimer (LB_DESCR *descr, INT index, TIMER_DIRECTION dir)
 
static LRESULT LISTBOX_HandleSystemTimer (LB_DESCR *descr)
 
static void LISTBOX_HandleMouseMove (LB_DESCR *descr, INT x, INT y)
 
static LRESULT LISTBOX_HandleKeyDown (LB_DESCR *descr, DWORD key)
 
static LRESULT LISTBOX_HandleChar (LB_DESCR *descr, WCHAR charW)
 
static BOOL LISTBOX_update_uistate (LB_DESCR *descr)
 
static BOOL LISTBOX_Create (HWND hwnd, LPHEADCOMBO lphc)
 
static BOOL LISTBOX_Destroy (LB_DESCR *descr)
 
LRESULT WINAPI ListBoxWndProc_common (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
 
LRESULT WINAPI ListBoxWndProcA (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI ListBoxWndProcW (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 

Variables

static TIMER_DIRECTION LISTBOX_Timer = LB_TIMER_NONE
 
static const WCHAR listboxW [] = {'L','i','s','t','B','o','x',0}
 
const struct builtin_class_descr LISTBOX_builtin_class
 
static const WCHAR combolboxW [] = {'C','o','m','b','o','L','B','o','x',0}
 
const struct builtin_class_descr COMBOLBOX_builtin_class
 

Macro Definition Documentation

◆ ATTRIBS

#define ATTRIBS
Value:
FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE)
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703

◆ CHECK_DRIVE

#define CHECK_DRIVE (   item)
Value:
if ((item)->str[0] == '[') \
{ \
if (!strncmpiW( str, (item)->str+1, len )) return i; \
if (((item)->str[1] == '-') && !strncmpiW(str, (item)->str+2, len)) \
return i; \
}
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const WCHAR * str
GLenum GLsizei len
Definition: glext.h:6722
static ATOM item
Definition: dde.c:856

◆ HAS_STRINGS

#define HAS_STRINGS (   descr)    (!IS_OWNERDRAW(descr) || ((descr)->style & LBS_HASSTRINGS))

Definition at line 94 of file listbox.c.

◆ IS_MULTISELECT

#define IS_MULTISELECT (   descr)
Value:
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
const char * descr
Definition: boot.c:45
#define LBS_NOSEL
Definition: winuser.h:316
Arabic default style
Definition: afstyles.h:93
#define LBS_MULTIPLESEL
Definition: pedump.c:681

Definition at line 98 of file listbox.c.

◆ IS_OWNERDRAW

#define IS_OWNERDRAW (   descr)    ((descr)->style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE))

Definition at line 91 of file listbox.c.

◆ ISWIN31

#define ISWIN31   (LOWORD(GetVersion()) == 0x0a03)

Definition at line 106 of file listbox.c.

◆ LB_ARRAY_GRANULARITY

#define LB_ARRAY_GRANULARITY   16

Definition at line 38 of file listbox.c.

◆ LB_SCROLL_TIMEOUT

#define LB_SCROLL_TIMEOUT   50

Definition at line 41 of file listbox.c.

◆ LB_TIMER_ID

#define LB_TIMER_ID   2

Definition at line 44 of file listbox.c.

◆ LBS_DISPLAYCHANGED

#define LBS_DISPLAYCHANGED   0x80000000

Definition at line 47 of file listbox.c.

◆ SEND_NOTIFICATION

#define SEND_NOTIFICATION (   descr,
  code 
)
Value:
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG_PTR LPARAM
Definition: windef.h:208
const char * descr
Definition: boot.c:45
#define WM_COMMAND
Definition: winuser.h:1722
Definition: inflate.c:139
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GWLP_ID
Definition: winuser.h:854

Definition at line 102 of file listbox.c.

Enumeration Type Documentation

◆ TIMER_DIRECTION

Enumerator
LB_TIMER_NONE 
LB_TIMER_UP 
LB_TIMER_LEFT 
LB_TIMER_DOWN 
LB_TIMER_RIGHT 
LB_TIMER_NONE 
LB_TIMER_UP 
LB_TIMER_LEFT 
LB_TIMER_DOWN 
LB_TIMER_RIGHT 

Definition at line 109 of file listbox.c.

Function Documentation

◆ LISTBOX_Create()

static BOOL LISTBOX_Create ( HWND  hwnd,
LPHEADCOMBO  lphc 
)
static

Definition at line 2511 of file listbox.c.

2512 {
2513  LB_DESCR *descr;
2514  MEASUREITEMSTRUCT mis;
2515  RECT rect;
2516 
2517  if (!(descr = HeapAlloc( GetProcessHeap(), 0, sizeof(*descr) )))
2518  return FALSE;
2519 
2520  GetClientRect( hwnd, &rect );
2521  descr->self = hwnd;
2522  descr->owner = GetParent( descr->self );
2523  descr->style = GetWindowLongPtrW( descr->self, GWL_STYLE );
2524  descr->width = rect.right - rect.left;
2525  descr->height = rect.bottom - rect.top;
2526  descr->items = NULL;
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;
2537  descr->nb_tabs = 0;
2538  descr->tabs = NULL;
2539  descr->wheel_remain = 0;
2540  descr->caret_on = !lphc;
2541  if (descr->style & LBS_NOSEL) descr->caret_on = FALSE;
2542  descr->in_focus = FALSE;
2543  descr->captured = FALSE;
2544  descr->font = 0;
2545  descr->locale = GetUserDefaultLCID();
2546  descr->lphc = lphc;
2547 
2548  if( lphc )
2549  {
2550  TRACE("[%p]: resetting owner %p -> %p\n", descr->self, descr->owner, lphc->self );
2551  descr->owner = lphc->self;
2552  }
2553 
2554  SetWindowLongPtrW( descr->self, 0, (LONG_PTR)descr );
2555 
2556  LISTBOX_update_uistate(descr); // ReactOS
2557 
2558 /* if (wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) descr->style &= ~LBS_NOTIFY;
2559  */
2560  if (descr->style & LBS_EXTENDEDSEL) descr->style |= LBS_MULTIPLESEL;
2561  if (descr->style & LBS_MULTICOLUMN) descr->style &= ~LBS_OWNERDRAWVARIABLE;
2562  if (descr->style & LBS_OWNERDRAWVARIABLE) descr->style |= LBS_NOINTEGRALHEIGHT;
2563 
2565  /* A no-data list box must also have the LBS_OWNERDRAWFIXED style, but must
2566  not have the LBS_SORT or LBS_HASSTRINGS style. */
2567  if ( descr->style & LBS_NODATA &&
2568  (!(descr->style & LBS_OWNERDRAWFIXED) || descr->style & (LBS_HASSTRINGS|LBS_SORT) ) )
2569  descr->style &= ~LBS_NODATA;
2571  descr->item_height = LISTBOX_SetFont( descr, 0 );
2572 
2573  if (descr->style & LBS_OWNERDRAWFIXED)
2574  {
2575  if( descr->lphc && (descr->lphc->dwStyle & CBS_DROPDOWN))
2576  {
2577  /* WinWord gets VERY unhappy if we send WM_MEASUREITEM from here */
2578  descr->item_height = lphc->fixedOwnerDrawHeight;
2579  }
2580  else
2581  {
2582  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
2583  mis.CtlType = ODT_LISTBOX;
2584  mis.CtlID = id;
2585  mis.itemID = -1;
2586  mis.itemWidth = 0;
2587  mis.itemData = 0;
2588  mis.itemHeight = descr->item_height;
2589  SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
2590  descr->item_height = mis.itemHeight ? mis.itemHeight : 1;
2591  }
2592  }
2593 
2594  TRACE("owner: %p, style: %08x, width: %d, height: %d\n", descr->owner, descr->style, descr->width, descr->height);
2595  return TRUE;
2596 }
static INT LISTBOX_SetFont(LB_DESCR *descr, HFONT font)
Definition: listbox.c:1303
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define LBS_NODATA
Definition: winuser.h:313
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
#define TRUE
Definition: types.h:120
static BOOL LISTBOX_update_uistate(LB_DESCR *descr)
Definition: listbox.c:2498
#define LBS_HASSTRINGS
Definition: pedump.c:684
#define LBS_SORT
Definition: pedump.c:679
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:768
#define GetWindowLongPtrW
Definition: winuser.h:4804
& rect
Definition: startmenu.cpp:1413
#define LBS_OWNERDRAWFIXED
Definition: pedump.c:682
#define FALSE
Definition: types.h:117
INT fixedOwnerDrawHeight
Definition: comctl32.h:148
#define LBS_NOINTEGRALHEIGHT
Definition: pedump.c:686
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
const char * descr
Definition: boot.c:45
#define WM_MEASUREITEM
Definition: winuser.h:1628
ULONG_PTR itemData
Definition: winuser.h:3621
#define GWL_STYLE
Definition: winuser.h:846
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
HWND self
Definition: comctl32.h:137
#define CBS_DROPDOWN
Definition: winuser.h:283
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
#define ODT_LISTBOX
Definition: winuser.h:2513
#define LBS_MULTICOLUMN
Definition: pedump.c:687
GLenum GLuint id
Definition: glext.h:5579
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define LBS_NOSEL
Definition: winuser.h:316
#define GWLP_ID
Definition: winuser.h:854
#define LBS_MULTIPLESEL
Definition: pedump.c:681

Referenced by ListBoxWndProc_common().

◆ LISTBOX_DeleteItem()

static void LISTBOX_DeleteItem ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1654 of file listbox.c.

1655 {
1656  /* save the item data before it gets freed by LB_RESETCONTENT */
1657  ULONG_PTR item_data = descr->items[index].data;
1658  LPWSTR item_str = descr->items[index].str;
1659 
1660  if (!descr->nb_items)
1661  SendMessageW( descr->self, LB_RESETCONTENT, 0, 0 );
1662 
1663  /* Note: Win 3.1 only sends DELETEITEM on owner-draw items,
1664  * while Win95 sends it for all items with user data.
1665  * It's probably better to send it too often than not
1666  * often enough, so this is what we do here.
1667  */
1668  if (IS_OWNERDRAW(descr) || item_data)
1669  {
1670  DELETEITEMSTRUCT dis;
1671  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1672 
1673  dis.CtlType = ODT_LISTBOX;
1674  dis.CtlID = id;
1675  dis.itemID = index;
1676  dis.hwndItem = descr->self;
1677  dis.itemData = item_data;
1678  SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis );
1679  }
1680  if (HAS_STRINGS(descr))
1681  HeapFree( GetProcessHeap(), 0, item_str );
1682 }
#define IS_OWNERDRAW(descr)
Definition: listbox.c:91
#define GetWindowLongPtrW
Definition: winuser.h:4804
ULONG_PTR itemData
Definition: winuser.h:3019
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define LB_RESETCONTENT
Definition: winuser.h:2037
#define WM_DELETEITEM
Definition: winuser.h:1629
LONG_PTR LPARAM
Definition: windef.h:208
#define GetProcessHeap()
Definition: compat.h:484
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
#define ODT_LISTBOX
Definition: winuser.h:2513
GLenum GLuint id
Definition: glext.h:5579
#define HAS_STRINGS(descr)
Definition: listbox.c:94
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:483
#define GWLP_ID
Definition: winuser.h:854

Referenced by LISTBOX_RemoveItem(), and LISTBOX_ResetContent().

◆ LISTBOX_Destroy()

static BOOL LISTBOX_Destroy ( LB_DESCR descr)
static

Definition at line 2602 of file listbox.c.

2603 {
2605  SetWindowLongPtrW( descr->self, 0, 0 );
2606  HeapFree( GetProcessHeap(), 0, descr );
2607  return TRUE;
2608 }
#define TRUE
Definition: types.h:120
static void LISTBOX_ResetContent(LB_DESCR *descr)
Definition: listbox.c:1756
#define GetProcessHeap()
Definition: compat.h:484
const char * descr
Definition: boot.c:45
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by ListBoxWndProc_common().

◆ LISTBOX_Directory()

static LRESULT LISTBOX_Directory ( LB_DESCR descr,
UINT  attrib,
LPCWSTR  filespec,
BOOL  long_names 
)
static

Definition at line 1806 of file listbox.c.

1808 {
1809  HANDLE handle;
1810  LRESULT ret = LB_OKAY;
1812  int pos;
1813  LRESULT maxinsert = LB_ERR;
1814 
1815  /* don't scan directory if we just want drives exclusively */
1816  if (attrib != (DDL_DRIVES | DDL_EXCLUSIVE)) {
1817  /* scan directory */
1818  if ((handle = FindFirstFileW(filespec, &entry)) == INVALID_HANDLE_VALUE)
1819  {
1820  int le = GetLastError();
1821  if ((le != ERROR_NO_MORE_FILES) && (le != ERROR_FILE_NOT_FOUND)) return LB_ERR;
1822  }
1823  else
1824  {
1825  do
1826  {
1827  WCHAR buffer[270];
1828  if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1829  {
1830  static const WCHAR bracketW[] = { ']',0 };
1831  static const WCHAR dotW[] = { '.',0 };
1832  if (!(attrib & DDL_DIRECTORY) ||
1833  !strcmpW( entry.cFileName, dotW )) continue;
1834  buffer[0] = '[';
1835  if (!long_names && entry.cAlternateFileName[0])
1836  strcpyW( buffer + 1, entry.cAlternateFileName );
1837  else
1838  strcpyW( buffer + 1, entry.cFileName );
1839  strcatW(buffer, bracketW);
1840  }
1841  else /* not a directory */
1842  {
1843 #define ATTRIBS (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \
1844  FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE)
1845 
1846  if ((attrib & DDL_EXCLUSIVE) &&
1847  ((attrib & ATTRIBS) != (entry.dwFileAttributes & ATTRIBS)))
1848  continue;
1849 #undef ATTRIBS
1850  if (!long_names && entry.cAlternateFileName[0])
1851  strcpyW( buffer, entry.cAlternateFileName );
1852  else
1853  strcpyW( buffer, entry.cFileName );
1854  }
1855  if (!long_names) CharLowerW( buffer );
1857  if ((ret = LISTBOX_InsertString( descr, pos, buffer )) < 0)
1858  break;
1859  if (ret <= maxinsert) maxinsert++; else maxinsert = ret;
1860  } while (FindNextFileW( handle, &entry ));
1861  FindClose( handle );
1862  }
1863  }
1864  if (ret >= 0)
1865  {
1866  ret = maxinsert;
1867 
1868  /* scan drives */
1869  if (attrib & DDL_DRIVES)
1870  {
1871  WCHAR buffer[] = {'[','-','a','-',']',0};
1872  WCHAR root[] = {'A',':','\\',0};
1873  int drive;
1874  for (drive = 0; drive < 26; drive++, buffer[2]++, root[0]++)
1875  {
1876  if (GetDriveTypeW(root) <= DRIVE_NO_ROOT_DIR) continue;
1877  if ((ret = LISTBOX_InsertString( descr, -1, buffer )) < 0)
1878  break;
1879  }
1880  }
1881  }
1882  return ret;
1883 }
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define ATTRIBS
LPWSTR WINAPI CharLowerW(_Inout_ LPWSTR)
#define DDL_DIRECTORY
Definition: winuser.h:422
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
GLuint buffer
Definition: glext.h:5915
#define LB_ERR
Definition: winuser.h:2407
static LRESULT LISTBOX_InsertString(LB_DESCR *descr, INT index, LPCWSTR str)
Definition: listbox.c:1617
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define ERROR_NO_MORE_FILES
Definition: winerror.h:121
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45
int ret
#define DDL_DRIVES
Definition: winuser.h:425
uint32_t entry
Definition: isohybrid.c:63
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:254
static char drive[2]
Definition: batch.c:28
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static INT LISTBOX_FindFileStrPos(LB_DESCR *descr, LPCWSTR str)
Definition: listbox.c:889
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
WINE_UNICODE_INLINE int strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: unicode.h:229
LONG_PTR LRESULT
Definition: windef.h:209
static const WCHAR dotW[]
Definition: directory.c:80
#define DDL_EXCLUSIVE
Definition: winuser.h:426
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by ListBoxWndProc_common().

◆ LISTBOX_DrawFocusRect()

static void LISTBOX_DrawFocusRect ( LB_DESCR descr,
BOOL  on 
)
static

Definition at line 690 of file listbox.c.

691 {
692  HDC hdc;
693  RECT rect;
694  HFONT oldFont = 0;
695 
696  /* Do not repaint the item if the item is not visible */
697  if (!IsWindowVisible(descr->self)) return;
698 
699  if (descr->focus_item == -1) return;
700  if (!descr->caret_on || !descr->in_focus) return;
701 
702  if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) != 1) return;
703  if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
704  if (descr->font) oldFont = SelectObject( hdc, descr->font );
705  if (!IsWindowEnabled(descr->self))
707  SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
708  LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, !on );
709  if (oldFont) SelectObject( hdc, oldFont );
710  ReleaseDC( descr->self, hdc );
711 }
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
#define ODA_FOCUS
Definition: winuser.h:2519
DWORD WINAPI GetSysColor(_In_ int)
& rect
Definition: startmenu.cpp:1413
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI IsWindowEnabled(_In_ HWND)
const char * descr
Definition: boot.c:45
#define COLOR_GRAYTEXT
Definition: winuser.h:922
HDC hdc
Definition: main.c:9
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
#define DCX_CACHE
Definition: winuser.h:2096
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
BOOL WINAPI IsWindowVisible(_In_ HWND)
static void LISTBOX_PaintItem(LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus)
Definition: listbox.c:521
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:416

Referenced by LISTBOX_MoveCaret(), LISTBOX_SetCaretIndex(), and ListBoxWndProc_common().

◆ LISTBOX_FindFileStrPos()

static INT LISTBOX_FindFileStrPos ( LB_DESCR descr,
LPCWSTR  str 
)
static

Definition at line 889 of file listbox.c.

890 {
891  INT min, max, res;
892 
893  if (!HAS_STRINGS(descr))
894  return LISTBOX_FindStringPos( descr, str, FALSE );
895  min = 0;
896  max = descr->nb_items;
897  while (min != max)
898  {
899  INT index = (min + max) / 2;
900  LPCWSTR p = descr->items[index].str;
901  if (*p == '[') /* drive or directory */
902  {
903  if (*str != '[') res = -1;
904  else if (p[1] == '-') /* drive */
905  {
906  if (str[1] == '-') res = str[2] - p[2];
907  else res = -1;
908  }
909  else /* directory */
910  {
911  if (str[1] == '-') res = 1;
912  else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
913  }
914  }
915  else /* filename */
916  {
917  if (*str == '[') res = 1;
918  else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
919  }
920  if (!res) return index;
921  if (res < 0) max = index;
922  else min = index + 1;
923  }
924  return max;
925 }
#define max(a, b)
Definition: svc.c:63
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
Definition: listbox.c:828
const WCHAR * str
GLuint index
Definition: glext.h:6031
static INT LISTBOX_FindStringPos(LB_DESCR *descr, LPCWSTR str, BOOL exact)
Definition: listbox.c:846
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
#define min(a, b)
Definition: monoChain.cc:55
GLuint res
Definition: glext.h:9613
#define HAS_STRINGS(descr)
Definition: listbox.c:94
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by LISTBOX_Directory(), and ListBoxWndProc_common().

◆ LISTBOX_FindString()

static INT LISTBOX_FindString ( LB_DESCR descr,
INT  start,
LPCWSTR  str,
BOOL  exact 
)
static

Definition at line 933 of file listbox.c.

934 {
935  INT i;
936  LB_ITEMDATA *item;
937 
938  if (start >= descr->nb_items) start = -1;
939  item = descr->items + start + 1;
940  if (HAS_STRINGS(descr))
941  {
942  if (!str || ! str[0] ) return LB_ERR;
943  if (exact)
944  {
945  for (i = start + 1; i < descr->nb_items; i++, item++)
946  if (!LISTBOX_lstrcmpiW( descr->locale, str, item->str )) return i;
947  for (i = 0, item = descr->items; i <= start; i++, item++)
948  if (!LISTBOX_lstrcmpiW( descr->locale, str, item->str )) return i;
949  }
950  else
951  {
952  /* Special case for drives and directories: ignore prefix */
953 #define CHECK_DRIVE(item) \
954  if ((item)->str[0] == '[') \
955  { \
956  if (!strncmpiW( str, (item)->str+1, len )) return i; \
957  if (((item)->str[1] == '-') && !strncmpiW(str, (item)->str+2, len)) \
958  return i; \
959  }
960 
961  INT len = strlenW(str);
962  for (i = start + 1; i < descr->nb_items; i++, item++)
963  {
964  if (!strncmpiW( str, item->str, len )) return i;
965  CHECK_DRIVE(item);
966  }
967  for (i = 0, item = descr->items; i <= start; i++, item++)
968  {
969  if (!strncmpiW( str, item->str, len )) return i;
970  CHECK_DRIVE(item);
971  }
972 #undef CHECK_DRIVE
973  }
974  }
975  else
976  {
977  if (exact && (descr->style & LBS_SORT))
978  /* If sorted, use a WM_COMPAREITEM binary search */
979  return LISTBOX_FindStringPos( descr, str, TRUE );
980 
981  /* Otherwise use a linear search */
982  for (i = start + 1; i < descr->nb_items; i++, item++)
983  if (item->data == (ULONG_PTR)str) return i;
984  for (i = 0, item = descr->items; i <= start; i++, item++)
985  if (item->data == (ULONG_PTR)str) return i;
986  }
987  return LB_ERR;
988 }
#define CHECK_DRIVE(item)
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define TRUE
Definition: types.h:120
#define LBS_SORT
Definition: pedump.c:679
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LB_ERR
Definition: winuser.h:2407
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
Definition: listbox.c:828
const WCHAR * str
static INT LISTBOX_FindStringPos(LB_DESCR *descr, LPCWSTR str, BOOL exact)
Definition: listbox.c:846
const char * descr
Definition: boot.c:45
GLenum GLsizei len
Definition: glext.h:6722
static ATOM item
Definition: dde.c:856
GLuint start
Definition: gl.h:1545
#define HAS_STRINGS(descr)
Definition: listbox.c:94

Referenced by LISTBOX_HandleChar(), and ListBoxWndProc_common().

◆ LISTBOX_FindStringPos()

static INT LISTBOX_FindStringPos ( LB_DESCR descr,
LPCWSTR  str,
BOOL  exact 
)
static

Definition at line 846 of file listbox.c.

847 {
848  INT index, min, max, res;
849 
850  if (!(descr->style & LBS_SORT)) return -1; /* Add it at the end */
851  min = 0;
852  max = descr->nb_items;
853  while (min != max)
854  {
855  index = (min + max) / 2;
856  if (HAS_STRINGS(descr))
857  res = LISTBOX_lstrcmpiW( descr->locale, str, descr->items[index].str);
858  else
859  {
860  COMPAREITEMSTRUCT cis;
861  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
862 
863  cis.CtlType = ODT_LISTBOX;
864  cis.CtlID = id;
865  cis.hwndItem = descr->self;
866  /* note that some application (MetaStock) expects the second item
867  * to be in the listbox */
868  cis.itemID1 = -1;
869  cis.itemData1 = (ULONG_PTR)str;
870  cis.itemID2 = index;
871  cis.itemData2 = descr->items[index].data;
872  cis.dwLocaleId = descr->locale;
873  res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis );
874  }
875  if (!res) return index;
876  if (res < 0) max = index;
877  else min = index + 1;
878  }
879  return exact ? -1 : max;
880 }
#define max(a, b)
Definition: svc.c:63
#define LBS_SORT
Definition: pedump.c:679
ULONG_PTR itemData2
Definition: winuser.h:2971
#define GetWindowLongPtrW
Definition: winuser.h:4804
int32_t INT
Definition: typedefs.h:58
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
Definition: listbox.c:828
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
GLuint index
Definition: glext.h:6031
ULONG_PTR itemData1
Definition: winuser.h:2969
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
#define WM_COMPAREITEM
Definition: winuser.h:1637
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define ODT_LISTBOX
Definition: winuser.h:2513
GLuint res
Definition: glext.h:9613
GLenum GLuint id
Definition: glext.h:5579
#define ULONG_PTR
Definition: config.h:101
#define HAS_STRINGS(descr)
Definition: listbox.c:94
#define GWLP_ID
Definition: winuser.h:854

Referenced by LISTBOX_FindFileStrPos(), LISTBOX_FindString(), and ListBoxWndProc_common().

◆ LISTBOX_GetCurrentPageSize()

static INT LISTBOX_GetCurrentPageSize ( const LB_DESCR descr)
static

Definition at line 159 of file listbox.c.

160 {
161  INT i, height;
162  if (!(descr->style & LBS_OWNERDRAWVARIABLE)) return descr->page_size;
163  for (i = descr->top_item, height = 0; i < descr->nb_items; i++)
164  {
165  if ((height += descr->items[i].height) > descr->height) break;
166  }
167  if (i == descr->top_item) return 1;
168  else return i - descr->top_item;
169 }
int32_t INT
Definition: typedefs.h:58
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const char * descr
Definition: boot.c:45
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683

Referenced by LISTBOX_HandleKeyDown(), LISTBOX_HandleTimer(), LISTBOX_HandleVScroll(), and LISTBOX_UpdateScroll().

◆ LISTBOX_GetItemFromPoint()

static INT LISTBOX_GetItemFromPoint ( const LB_DESCR descr,
INT  x,
INT  y 
)
static

Definition at line 474 of file listbox.c.

475 {
476  INT index = descr->top_item;
477 
478  if (!descr->nb_items) return -1; /* No items */
479  if (descr->style & LBS_OWNERDRAWVARIABLE)
480  {
481  INT pos = 0;
482  if (y >= 0)
483  {
484  while (index < descr->nb_items)
485  {
486  if ((pos += descr->items[index].height) > y) break;
487  index++;
488  }
489  }
490  else
491  {
492  while (index > 0)
493  {
494  index--;
495  if ((pos -= descr->items[index].height) <= y) break;
496  }
497  }
498  }
499  else if (descr->style & LBS_MULTICOLUMN)
500  {
501  if (y >= descr->item_height * descr->page_size) return -1;
502  if (y >= 0) index += y / descr->item_height;
503  if (x >= 0) index += (x / descr->column_width) * descr->page_size;
504  else index -= (((x + 1) / descr->column_width) - 1) * descr->page_size;
505  }
506  else
507  {
508  index += (y / descr->item_height);
509  }
510  if (index < 0) return 0;
511  if (index >= descr->nb_items) return -1;
512  return index;
513 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:58
GLuint index
Definition: glext.h:6031
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
#define LBS_MULTICOLUMN
Definition: pedump.c:687

Referenced by LISTBOX_HandleLButtonDown(), LISTBOX_HandleMouseMove(), and ListBoxWndProc_common().

◆ LISTBOX_GetItemHeight()

static LRESULT LISTBOX_GetItemHeight ( const LB_DESCR descr,
INT  index 
)
static

Definition at line 1180 of file listbox.c.

1181 {
1182  if (descr->style & LBS_OWNERDRAWVARIABLE && descr->nb_items > 0)
1183  {
1184  if ((index < 0) || (index >= descr->nb_items))
1185  {
1187  return LB_ERR;
1188  }
1189  return descr->items[index].height;
1190  }
1191  else return descr->item_height;
1192 }
#define LB_ERR
Definition: winuser.h:2407
GLuint index
Definition: glext.h:6031
const char * descr
Definition: boot.c:45
#define SetLastError(x)
Definition: compat.h:500
#define index(s, c)
Definition: various.h:29
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
#define ERROR_INVALID_INDEX
Definition: winerror.h:894

Referenced by ListBoxWndProc_common().

◆ LISTBOX_GetItemRect()

static LRESULT LISTBOX_GetItemRect ( const LB_DESCR descr,
INT  index,
RECT rect 
)
static

Definition at line 416 of file listbox.c.

417 {
418  /* Index <= 0 is legal even on empty listboxes */
419  if (index && (index >= descr->nb_items))
420  {
421  memset(rect, 0, sizeof(*rect));
423  return LB_ERR;
424  }
425  SetRect( rect, 0, 0, descr->width, descr->height );
426  if (descr->style & LBS_MULTICOLUMN)
427  {
428  INT col = (index / descr->page_size) -
429  (descr->top_item / descr->page_size);
430  rect->left += col * descr->column_width;
431  rect->right = rect->left + descr->column_width;
432  rect->top += (index % descr->page_size) * descr->item_height;
433  rect->bottom = rect->top + descr->item_height;
434  }
435  else if (descr->style & LBS_OWNERDRAWVARIABLE)
436  {
437  INT i;
438  rect->right += descr->horz_pos;
439  if ((index >= 0) && (index < descr->nb_items))
440  {
441  if (index < descr->top_item)
442  {
443  for (i = descr->top_item-1; i >= index; i--)
444  rect->top -= descr->items[i].height;
445  }
446  else
447  {
448  for (i = descr->top_item; i < index; i++)
449  rect->top += descr->items[i].height;
450  }
451  rect->bottom = rect->top + descr->items[index].height;
452 
453  }
454  }
455  else
456  {
457  rect->top += (index - descr->top_item) * descr->item_height;
458  rect->bottom = rect->top + descr->item_height;
459  rect->right += descr->horz_pos;
460  }
461 
462  TRACE("item %d, rect %s\n", index, wine_dbgstr_rect(rect));
463 
464  return ((rect->left < descr->width) && (rect->right > 0) &&
465  (rect->top < descr->height) && (rect->bottom > 0));
466 }
int32_t INT
Definition: typedefs.h:58
& rect
Definition: startmenu.cpp:1413
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LB_ERR
Definition: winuser.h:2407
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
const char * descr
Definition: boot.c:45
const char * wine_dbgstr_rect(const RECT *rect)
#define SetLastError(x)
Definition: compat.h:500
#define index(s, c)
Definition: various.h:29
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
#define ERROR_INVALID_INDEX
Definition: winerror.h:894
#define LBS_MULTICOLUMN
Definition: pedump.c:687
#define memset(x, y, z)
Definition: compat.h:39

Referenced by LISTBOX_DrawFocusRect(), LISTBOX_InvalidateItemRect(), LISTBOX_InvalidateItems(), LISTBOX_RepaintItem(), LISTBOX_SetHorizontalPos(), LISTBOX_UpdateSize(), and ListBoxWndProc_common().

◆ LISTBOX_GetMaxTopIndex()

static INT LISTBOX_GetMaxTopIndex ( const LB_DESCR descr)
static

Definition at line 177 of file listbox.c.

178 {
179  INT max, page;
180 
181  if (descr->style & LBS_OWNERDRAWVARIABLE)
182  {
183  page = descr->height;
184  for (max = descr->nb_items - 1; max >= 0; max--)
185  if ((page -= descr->items[max].height) < 0) break;
186  if (max < descr->nb_items - 1) max++;
187  }
188  else if (descr->style & LBS_MULTICOLUMN)
189  {
190  if ((page = descr->width / descr->column_width) < 1) page = 1;
191  max = (descr->nb_items + descr->page_size - 1) / descr->page_size;
192  max = (max - page) * descr->page_size;
193  }
194  else
195  {
196  max = descr->nb_items - descr->page_size;
197  }
198  if (max < 0) max = 0;
199  return max;
200 }
#define max(a, b)
Definition: svc.c:63
int32_t INT
Definition: typedefs.h:58
Definition: module.h:566
const char * descr
Definition: boot.c:45
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
#define LBS_MULTICOLUMN
Definition: pedump.c:687

Referenced by LISTBOX_SetTopItem().

◆ LISTBOX_GetSelCount()

static LRESULT LISTBOX_GetSelCount ( const LB_DESCR descr)
static

Definition at line 994 of file listbox.c.

995 {
996  INT i, count;
997  const LB_ITEMDATA *item = descr->items;
998 
999  if (!(descr->style & LBS_MULTIPLESEL) ||
1000  (descr->style & LBS_NOSEL))
1001  return LB_ERR;
1002  for (i = count = 0; i < descr->nb_items; i++, item++)
1003  if (item->selected) count++;
1004  return count;
1005 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:58
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LB_ERR
Definition: winuser.h:2407
const char * descr
Definition: boot.c:45
static ATOM item
Definition: dde.c:856
#define LBS_NOSEL
Definition: winuser.h:316
#define LBS_MULTIPLESEL
Definition: pedump.c:681

Referenced by ListBoxWndProc_common().

◆ LISTBOX_GetSelItems()

static LRESULT LISTBOX_GetSelItems ( const LB_DESCR descr,
INT  max,
LPINT  array 
)
static

Definition at line 1011 of file listbox.c.

1012 {
1013  INT i, count;
1014  const LB_ITEMDATA *item = descr->items;
1015 
1016  if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
1017  for (i = count = 0; (i < descr->nb_items) && (count < max); i++, item++)
1018  if (item->selected) array[count++] = i;
1019  return count;
1020 }
#define max(a, b)
Definition: svc.c:63
GLuint GLuint GLsizei count
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:58
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define LB_ERR
Definition: winuser.h:2407
const char * descr
Definition: boot.c:45
static ATOM item
Definition: dde.c:856
#define LBS_MULTIPLESEL
Definition: pedump.c:681

Referenced by ListBoxWndProc_common().

◆ LISTBOX_GetText()

static LRESULT LISTBOX_GetText ( LB_DESCR descr,
INT  index,
LPWSTR  buffer,
BOOL  unicode 
)
static

Definition at line 778 of file listbox.c.

779 {
780  DWORD len;
781 
782  if ((index < 0) || (index >= descr->nb_items))
783  {
785  return LB_ERR;
786  }
787  if (HAS_STRINGS(descr))
788  {
789  if (!buffer)
790  {
791  len = strlenW(descr->items[index].str);
792  if( unicode )
793  return len;
794  return WideCharToMultiByte( CP_ACP, 0, descr->items[index].str, len,
795  NULL, 0, NULL, NULL );
796  }
797 
798  TRACE("index %d (0x%04x) %s\n", index, index, debugstr_w(descr->items[index].str));
799 
800  _SEH2_TRY /* hide a Delphi bug that passes a read-only buffer */
801  {
802  if(unicode)
803  {
804  strcpyW( buffer, descr->items[index].str );
805  len = strlenW(buffer);
806  }
807  else
808  {
809  len = WideCharToMultiByte(CP_ACP, 0, descr->items[index].str, -1,
810  (LPSTR)buffer, 0x7FFFFFFF, NULL, NULL) - 1;
811  }
812  }
814  {
815  ERR( "got an invalid buffer (Delphi bug?)\n" );
817  len = LB_ERR;
818  }
819  _SEH2_END
820  } else {
821  if (buffer)
822  *((LPDWORD)buffer)=*(LPDWORD)(&descr->items[index].data);
823  len = sizeof(DWORD);
824  }
825  return len;
826 }
static DWORD(WINAPI *pGetListBoxInfo)(HWND)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
GLuint buffer
Definition: glext.h:5915
char * LPSTR
Definition: xmlstorage.h:182
_SEH2_TRY
Definition: create.c:4226
#define LB_ERR
Definition: winuser.h:2407
#define debugstr_w
Definition: kernel32.h:32
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
const char * descr
Definition: boot.c:45
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
#define LPDWORD
Definition: nt_native.h:46
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:110
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
_SEH2_END
Definition: create.c:4400
#define ERROR_INVALID_INDEX
Definition: winerror.h:894
#define HAS_STRINGS(descr)
Definition: listbox.c:94
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleChar()

static LRESULT LISTBOX_HandleChar ( LB_DESCR descr,
WCHAR  charW 
)
static

Definition at line 2469 of file listbox.c.

2470 {
2471  INT caret = -1;
2472  WCHAR str[2];
2473 
2474  str[0] = charW;
2475  str[1] = '\0';
2476 
2477  if (descr->style & LBS_WANTKEYBOARDINPUT)
2478  {
2480  MAKEWPARAM(charW, descr->focus_item),
2481  (LPARAM)descr->self );
2482  if (caret == -2) return 0;
2483  }
2484  if (caret == -1)
2485  caret = LISTBOX_FindString( descr, descr->focus_item, str, FALSE);
2486  if (caret != -1)
2487  {
2488  if ((!IS_MULTISELECT(descr)) && descr->selected_item == -1)
2491  if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2493  }
2494  return 0;
2495 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1438
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
#define IS_MULTISELECT(descr)
Definition: listbox.c:98
#define TRUE
Definition: types.h:120
#define LBS_WANTKEYBOARDINPUT
Definition: pedump.c:688
static const WCHAR charW[]
Definition: tokenize.c:46
#define LBN_SELCHANGE
Definition: winuser.h:2057
int32_t INT
Definition: typedefs.h:58
#define WM_CHARTOITEM
Definition: winuser.h:1631
#define FALSE
Definition: types.h:117
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
const char * descr
Definition: boot.c:45
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:102
#define LBS_NOTIFY
Definition: pedump.c:678
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1481
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static INT LISTBOX_FindString(LB_DESCR *descr, INT start, LPCWSTR str, BOOL exact)
Definition: listbox.c:933

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleHScroll()

static LRESULT LISTBOX_HandleHScroll ( LB_DESCR descr,
WORD  scrollReq,
WORD  pos 
)
static

Definition at line 1933 of file listbox.c.

1934 {
1935  SCROLLINFO info;
1936  INT page;
1937 
1938  if (descr->style & LBS_MULTICOLUMN)
1939  {
1940  switch(scrollReq)
1941  {
1942  case SB_LINELEFT:
1943  LISTBOX_SetTopItem( descr, descr->top_item-descr->page_size,
1944  TRUE );
1945  break;
1946  case SB_LINERIGHT:
1947  LISTBOX_SetTopItem( descr, descr->top_item+descr->page_size,
1948  TRUE );
1949  break;
1950  case SB_PAGELEFT:
1951  page = descr->width / descr->column_width;
1952  if (page < 1) page = 1;
1954  descr->top_item - page * descr->page_size, TRUE );
1955  break;
1956  case SB_PAGERIGHT:
1957  page = descr->width / descr->column_width;
1958  if (page < 1) page = 1;
1960  descr->top_item + page * descr->page_size, TRUE );
1961  break;
1962  case SB_THUMBPOSITION:
1963  LISTBOX_SetTopItem( descr, pos*descr->page_size, TRUE );
1964  break;
1965  case SB_THUMBTRACK:
1966  info.cbSize = sizeof(info);
1967  info.fMask = SIF_TRACKPOS;
1968 #ifdef __REACTOS__
1969  GetScrollInfo( descr->self, SB_HORZ, &info );
1970 #else
1971  GetScrollInfo( descr->self, SB_VERT, &info );
1972 #endif
1973  LISTBOX_SetTopItem( descr, info.nTrackPos*descr->page_size,
1974  TRUE );
1975  break;
1976  case SB_LEFT:
1977  LISTBOX_SetTopItem( descr, 0, TRUE );
1978  break;
1979  case SB_RIGHT:
1980  LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
1981  break;
1982  }
1983  }
1984  else if (descr->horz_extent)
1985  {
1986  switch(scrollReq)
1987  {
1988  case SB_LINELEFT:
1989  LISTBOX_SetHorizontalPos( descr, descr->horz_pos - 1 );
1990  break;
1991  case SB_LINERIGHT:
1992  LISTBOX_SetHorizontalPos( descr, descr->horz_pos + 1 );
1993  break;
1994  case SB_PAGELEFT:
1996  descr->horz_pos - descr->width );
1997  break;
1998  case SB_PAGERIGHT:
2000  descr->horz_pos + descr->width );
2001  break;
2002  case SB_THUMBPOSITION:
2004  break;
2005  case SB_THUMBTRACK:
2006  info.cbSize = sizeof(info);
2007  info.fMask = SIF_TRACKPOS;
2008  GetScrollInfo( descr->self, SB_HORZ, &info );
2009  LISTBOX_SetHorizontalPos( descr, info.nTrackPos );
2010  break;
2011  case SB_LEFT:
2013  break;
2014  case SB_RIGHT:
2016  descr->horz_extent - descr->width );
2017  break;
2018  }
2019  }
2020  return 0;
2021 }
#define SB_RIGHT
Definition: winuser.h:576
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
#define SB_HORZ
Definition: winuser.h:552
int32_t INT
Definition: typedefs.h:58
struct _test_info info[]
Definition: SetCursorPos.c:19
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:292
#define SB_THUMBPOSITION
Definition: winuser.h:572
Definition: module.h:566
#define SB_THUMBTRACK
Definition: winuser.h:573
const char * descr
Definition: boot.c:45
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SB_PAGELEFT
Definition: winuser.h:570
#define SB_LEFT
Definition: winuser.h:575
#define SB_LINERIGHT
Definition: winuser.h:567
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define SB_PAGERIGHT
Definition: winuser.h:571
#define LBS_MULTICOLUMN
Definition: pedump.c:687
#define SB_LINELEFT
Definition: winuser.h:566
static void LISTBOX_SetHorizontalPos(LB_DESCR *descr, INT pos)
Definition: listbox.c:1234

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleKeyDown()

static LRESULT LISTBOX_HandleKeyDown ( LB_DESCR descr,
DWORD  key 
)
static

Definition at line 2357 of file listbox.c.

2358 {
2359  INT caret = -1;
2360  BOOL bForceSelection = TRUE; /* select item pointed to by focus_item */
2361  if ((IS_MULTISELECT(descr)) || (descr->selected_item == descr->focus_item))
2362  bForceSelection = FALSE; /* only for single select list */
2363 
2364  if (descr->style & LBS_WANTKEYBOARDINPUT)
2365  {
2367  MAKEWPARAM(LOWORD(key), descr->focus_item),
2368  (LPARAM)descr->self );
2369  if (caret == -2) return 0;
2370  }
2371  if (caret == -1) switch(key)
2372  {
2373  case VK_LEFT:
2374  if (descr->style & LBS_MULTICOLUMN)
2375  {
2376  bForceSelection = FALSE;
2377  if (descr->focus_item >= descr->page_size)
2378  caret = descr->focus_item - descr->page_size;
2379  break;
2380  }
2381  /* fall through */
2382  case VK_UP:
2383  caret = descr->focus_item - 1;
2384  if (caret < 0) caret = 0;
2385  break;
2386  case VK_RIGHT:
2387  if (descr->style & LBS_MULTICOLUMN)
2388  {
2389  bForceSelection = FALSE;
2390  if (descr->focus_item + descr->page_size < descr->nb_items)
2391  caret = descr->focus_item + descr->page_size;
2392  break;
2393  }
2394  /* fall through */
2395  case VK_DOWN:
2396  caret = descr->focus_item + 1;
2397  if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2398  break;
2399 
2400  case VK_PRIOR:
2401  if (descr->style & LBS_MULTICOLUMN)
2402  {
2403  INT page = descr->width / descr->column_width;
2404  if (page < 1) page = 1;
2405  caret = descr->focus_item - (page * descr->page_size) + 1;
2406  }
2407  else caret = descr->focus_item-LISTBOX_GetCurrentPageSize(descr) + 1;
2408  if (caret < 0) caret = 0;
2409  break;
2410  case VK_NEXT:
2411  if (descr->style & LBS_MULTICOLUMN)
2412  {
2413  INT page = descr->width / descr->column_width;
2414  if (page < 1) page = 1;
2415  caret = descr->focus_item + (page * descr->page_size) - 1;
2416  }
2417  else caret = descr->focus_item + LISTBOX_GetCurrentPageSize(descr) - 1;
2418  if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2419  break;
2420  case VK_HOME:
2421  caret = 0;
2422  break;
2423  case VK_END:
2424  caret = descr->nb_items - 1;
2425  break;
2426  case VK_SPACE:
2427  if (descr->style & LBS_EXTENDEDSEL) caret = descr->focus_item;
2428  else if (descr->style & LBS_MULTIPLESEL)
2429  {
2430  LISTBOX_SetSelection( descr, descr->focus_item,
2431  !descr->items[descr->focus_item].selected,
2432  (descr->style & LBS_NOTIFY) != 0 );
2433  }
2434  break;
2435  default:
2436  bForceSelection = FALSE;
2437  }
2438  if (bForceSelection) /* focused item is used instead of key */
2439  caret = descr->focus_item;
2440  if (caret >= 0)
2441  {
2442  if (((descr->style & LBS_EXTENDEDSEL) &&
2443  !(GetKeyState( VK_SHIFT ) & 0x8000)) ||
2445  descr->anchor_item = caret;
2447 
2448  if (descr->style & LBS_MULTIPLESEL)
2449  descr->selected_item = caret;
2450  else
2452  if (descr->style & LBS_NOTIFY)
2453  {
2454  if (descr->lphc && IsWindowVisible( descr->self ))
2455  {
2456  /* make sure that combo parent doesn't hide us */
2457  descr->lphc->wState |= CBF_NOROLLUP;
2458  }
2459  if (descr->nb_items) SEND_NOTIFICATION( descr, LBN_SELCHANGE );
2460  }
2461  }
2462  return 0;
2463 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1438
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
#define IS_MULTISELECT(descr)
Definition: listbox.c:98
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
#define TRUE
Definition: types.h:120
#define LBS_WANTKEYBOARDINPUT
Definition: pedump.c:688
static INT LISTBOX_GetCurrentPageSize(const LB_DESCR *descr)
Definition: listbox.c:159
#define VK_LEFT
Definition: winuser.h:2199
#define VK_DOWN
Definition: winuser.h:2202
#define VK_PRIOR
Definition: winuser.h:2195
#define LBN_SELCHANGE
Definition: winuser.h:2057
int32_t INT
Definition: typedefs.h:58
#define VK_NEXT
Definition: winuser.h:2196
#define VK_HOME
Definition: winuser.h:2198
#define VK_UP
Definition: winuser.h:2200
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define VK_SHIFT
Definition: winuser.h:2177
LONG_PTR LPARAM
Definition: windef.h:208
Definition: module.h:566
SHORT WINAPI GetKeyState(_In_ int)
const char * descr
Definition: boot.c:45
#define WM_VKEYTOITEM
Definition: winuser.h:1630
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:102
#define VK_RIGHT
Definition: winuser.h:2201
#define LBS_NOTIFY
Definition: pedump.c:678
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1481
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_SPACE
Definition: winuser.h:2194
#define LBS_MULTICOLUMN
Definition: pedump.c:687
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define LOWORD(l)
Definition: pedump.c:82
#define VK_END
Definition: winuser.h:2197
#define LBS_MULTIPLESEL
Definition: pedump.c:681
Definition: path.c:41

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleLButtonDown()

static LRESULT LISTBOX_HandleLButtonDown ( LB_DESCR descr,
DWORD  keys,
INT  x,
INT  y 
)
static

Definition at line 2054 of file listbox.c.

2055 {
2057 
2058  TRACE("[%p]: lbuttondown %d,%d item %d, focus item %d\n",
2059  descr->self, x, y, index, descr->focus_item);
2060 
2061  if (!descr->caret_on && (descr->in_focus)) return 0;
2062 
2063  if (!descr->in_focus)
2064  {
2065  if( !descr->lphc ) SetFocus( descr->self );
2066  else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit : descr->lphc->self );
2067  }
2068 
2069  if (index == -1) return 0;
2070 
2071  if (!descr->lphc)
2072  {
2073  if (descr->style & LBS_NOTIFY )
2075  MAKELPARAM( x, y ) );
2076  }
2077 
2078  descr->captured = TRUE;
2079  SetCapture( descr->self );
2080 
2081  if (descr->style & (LBS_EXTENDEDSEL | LBS_MULTIPLESEL))
2082  {
2083  /* we should perhaps make sure that all items are deselected
2084  FIXME: needed for !LBS_EXTENDEDSEL, too ?
2085  if (!(keys & (MK_SHIFT|MK_CONTROL)))
2086  LISTBOX_SetSelection( descr, -1, FALSE, FALSE);
2087  */
2088 
2089  if (!(keys & MK_SHIFT)) descr->anchor_item = index;
2090  if (keys & MK_CONTROL)
2091  {
2094  !descr->items[index].selected,
2095  (descr->style & LBS_NOTIFY) != 0);
2096  }
2097  else
2098  {
2100 
2101  if (descr->style & LBS_EXTENDEDSEL)
2102  {
2104  descr->items[index].selected,
2105  (descr->style & LBS_NOTIFY) != 0 );
2106  }
2107  else
2108  {
2110  !descr->items[index].selected,
2111  (descr->style & LBS_NOTIFY) != 0 );
2112  }
2113  }
2114  }
2115  else
2116  {
2117  descr->anchor_item = index;
2120  TRUE, (descr->style & LBS_NOTIFY) != 0 );
2121  }
2122 
2123  if (!descr->lphc)
2124  { // See rev 40864 use Ptr for 64 bit.
2126  {
2127  POINT pt;
2128 
2129  pt.x = x;
2130  pt.y = y;
2131 
2132  if (DragDetect( descr->self, pt ))
2133  SendMessageW( descr->owner, WM_BEGINDRAG, 0, 0 );
2134  }
2135  }
2136  return 0;
2137 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1438
#define MK_SHIFT
Definition: winuser.h:2344
#define WS_EX_DRAGDETECT
Definition: undocuser.h:21
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
#define WM_LBTRACKPOINT
Definition: msg.c:59
#define GWL_EXSTYLE
Definition: winuser.h:845
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define WM_BEGINDRAG
Definition: undocuser.h:55
HWND WINAPI SetFocus(_In_opt_ HWND)
#define GetWindowLongPtrW
Definition: winuser.h:4804
int32_t INT
Definition: typedefs.h:58
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1373
#define FALSE
Definition: types.h:117
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
const char * descr
Definition: boot.c:45
static INT LISTBOX_GetItemFromPoint(const LB_DESCR *descr, INT x, INT y)
Definition: listbox.c:474
#define index(s, c)
Definition: various.h:29
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define LBS_NOTIFY
Definition: pedump.c:678
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1481
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define MK_CONTROL
Definition: winuser.h:2345
BOOL WINAPI DragDetect(_In_ HWND, _In_ POINT)
#define LBS_MULTIPLESEL
Definition: pedump.c:681

Referenced by LISTBOX_HandleLButtonDownCombo(), and ListBoxWndProc_common().

◆ LISTBOX_HandleLButtonDownCombo()

static LRESULT LISTBOX_HandleLButtonDownCombo ( LB_DESCR descr,
UINT  msg,
DWORD  keys,
INT  x,
INT  y 
)
static

Definition at line 2159 of file listbox.c.

2160 {
2161  RECT clientRect, screenRect;
2162  POINT mousePos;
2163 
2164  mousePos.x = x;
2165  mousePos.y = y;
2166 
2167  GetClientRect(descr->self, &clientRect);
2168 
2169  if(PtInRect(&clientRect, mousePos))
2170  {
2171  /* MousePos is in client, resume normal processing */
2172  if (msg == WM_LBUTTONDOWN)
2173  {
2174  descr->lphc->droppedIndex = descr->nb_items ? descr->selected_item : -1;
2175  return LISTBOX_HandleLButtonDown( descr, keys, x, y);
2176  }
2177  else if (descr->style & LBS_NOTIFY)
2179  }
2180  else
2181  {
2182  POINT screenMousePos;
2183  HWND hWndOldCapture;
2184 
2185  /* Check the Non-Client Area */
2186  screenMousePos = mousePos;
2187  hWndOldCapture = GetCapture();
2188  ReleaseCapture();
2189  GetWindowRect(descr->self, &screenRect);
2190  ClientToScreen(descr->self, &screenMousePos);
2191 
2192  if(!PtInRect(&screenRect, screenMousePos))
2193  {
2194  LISTBOX_SetCaretIndex( descr, descr->lphc->droppedIndex, FALSE );
2195  LISTBOX_SetSelection( descr, descr->lphc->droppedIndex, FALSE, FALSE );
2196  COMBO_FlipListbox( descr->lphc, FALSE, FALSE );
2197  }
2198  else
2199  {
2200  /* Check to see the NC is a scrollbar */
2201  INT nHitTestType=0;
2203  /* Check Vertical scroll bar */
2204  if (style & WS_VSCROLL)
2205  {
2206  clientRect.right += GetSystemMetrics(SM_CXVSCROLL);
2207  if (PtInRect( &clientRect, mousePos ))
2208  nHitTestType = HTVSCROLL;
2209  }
2210  /* Check horizontal scroll bar */
2211  if (style & WS_HSCROLL)
2212  {
2213  clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL);
2214  if (PtInRect( &clientRect, mousePos ))
2215  nHitTestType = HTHSCROLL;
2216  }
2217  /* Windows sends this message when a scrollbar is clicked
2218  */
2219 
2220  if(nHitTestType != 0)
2221  {
2222  SendMessageW(descr->self, WM_NCLBUTTONDOWN, nHitTestType,
2223  MAKELONG(screenMousePos.x, screenMousePos.y));
2224  }
2225  /* Resume the Capture after scrolling is complete
2226  */
2227  if(hWndOldCapture != 0)
2228  SetCapture(hWndOldCapture);
2229  }
2230  }
2231  return 0;
2232 }
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1674
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1438
#define HTHSCROLL
Definition: winuser.h:2456
#define SM_CYHSCROLL
Definition: winuser.h:952
long y
Definition: polytest.cpp:48
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
long x
Definition: polytest.cpp:48
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define GetWindowLongPtrW
Definition: winuser.h:4804
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1373
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
HWND WINAPI GetCapture(void)
Definition: message.c:2880
#define MAKELONG(a, b)
Definition: typedefs.h:249
const char * descr
Definition: boot.c:45
int WINAPI GetSystemMetrics(_In_ int)
static LRESULT LISTBOX_HandleLButtonDown(LB_DESCR *descr, DWORD keys, INT x, INT y)
Definition: listbox.c:2054
#define LBN_DBLCLK
Definition: winuser.h:2053
#define WS_HSCROLL
Definition: pedump.c:628
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:102
#define GWL_STYLE
Definition: winuser.h:846
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define LBS_NOTIFY
Definition: pedump.c:678
BOOL COMBO_FlipListbox(LPHEADCOMBO lphc, BOOL ok, BOOL bRedrawButton)
Definition: combo.c:1117
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WS_VSCROLL
Definition: pedump.c:627
#define SM_CXVSCROLL
Definition: winuser.h:951
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define HTVSCROLL
Definition: winuser.h:2457
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
Arabic default style
Definition: afstyles.h:93

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleLButtonUp()

static LRESULT LISTBOX_HandleLButtonUp ( LB_DESCR descr)
static

Definition at line 2237 of file listbox.c.

2238 {
2240  KillSystemTimer( descr->self, LB_TIMER_ID );
2242  if (descr->captured)
2243  {
2244  descr->captured = FALSE;
2245  if (GetCapture() == descr->self) ReleaseCapture();
2246  if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2248  }
2249  return 0;
2250 }
static TIMER_DIRECTION LISTBOX_Timer
Definition: listbox.c:118
#define LBN_SELCHANGE
Definition: winuser.h:2057
#define FALSE
Definition: types.h:117
HWND WINAPI GetCapture(void)
Definition: message.c:2880
const char * descr
Definition: boot.c:45
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:102
BOOL WINAPI KillSystemTimer(HWND, UINT_PTR)
Definition: timer.c:35
#define LBS_NOTIFY
Definition: pedump.c:678
#define LB_TIMER_ID
Definition: listbox.c:44
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleMouseMove()

static void LISTBOX_HandleMouseMove ( LB_DESCR descr,
INT  x,
INT  y 
)
static

Definition at line 2309 of file listbox.c.

2311 {
2312  INT index;
2314 
2315  if (!descr->captured) return;
2316 
2317  if (descr->style & LBS_MULTICOLUMN)
2318  {
2319  if (y < 0) y = 0;
2320  else if (y >= descr->item_height * descr->page_size)
2321  y = descr->item_height * descr->page_size - 1;
2322 
2323  if (x < 0)
2324  {
2325  dir = LB_TIMER_LEFT;
2326  x = 0;
2327  }
2328  else if (x >= descr->width)
2329  {
2330  dir = LB_TIMER_RIGHT;
2331  x = descr->width - 1;
2332  }
2333  }
2334  else
2335  {
2336  if (y < 0) dir = LB_TIMER_UP; /* above */
2337  else if (y >= descr->height) dir = LB_TIMER_DOWN; /* below */
2338  }
2339 
2341  if (index == -1) index = descr->focus_item;
2343 
2344  /* Start/stop the system timer */
2345 
2346  if (dir != LB_TIMER_NONE)
2348  else if (LISTBOX_Timer != LB_TIMER_NONE)
2349  KillSystemTimer( descr->self, LB_TIMER_ID );
2350  LISTBOX_Timer = dir;
2351 }
static TIMER_DIRECTION LISTBOX_Timer
Definition: listbox.c:118
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
TIMER_DIRECTION
Definition: listbox.c:115
#define LB_SCROLL_TIMEOUT
Definition: listbox.c:41
int32_t INT
Definition: typedefs.h:58
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
unsigned int dir
Definition: maze.c:112
UINT_PTR WINAPI SetSystemTimer(HWND, UINT_PTR, UINT, TIMERPROC)
Definition: ntwrapper.h:106
const char * descr
Definition: boot.c:45
static INT LISTBOX_GetItemFromPoint(const LB_DESCR *descr, INT x, INT y)
Definition: listbox.c:474
#define index(s, c)
Definition: various.h:29
BOOL WINAPI KillSystemTimer(HWND, UINT_PTR)
Definition: timer.c:35
#define LB_TIMER_ID
Definition: listbox.c:44
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define LBS_MULTICOLUMN
Definition: pedump.c:687
static LRESULT LISTBOX_HandleTimer(LB_DESCR *descr, INT index, TIMER_DIRECTION dir)
Definition: listbox.c:2259

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleMouseWheel()

static LRESULT LISTBOX_HandleMouseWheel ( LB_DESCR descr,
SHORT  delta 
)
static

Definition at line 2023 of file listbox.c.

2024 {
2025  UINT pulScrollLines = 3;
2026 
2027  SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
2028 
2029  /* if scrolling changes direction, ignore left overs */
2030  if ((delta < 0 && descr->wheel_remain < 0) ||
2031  (delta > 0 && descr->wheel_remain > 0))
2032  descr->wheel_remain += delta;
2033  else
2034  descr->wheel_remain = delta;
2035 
2036  if (descr->wheel_remain && pulScrollLines)
2037  {
2038  int cLineScroll;
2039  pulScrollLines = min((UINT) descr->page_size, pulScrollLines);
2040  cLineScroll = pulScrollLines * (float)descr->wheel_remain / WHEEL_DELTA;
2041  descr->wheel_remain -= WHEEL_DELTA * cLineScroll / (int)pulScrollLines;
2042 #ifdef __REACTOS__
2043  if (cLineScroll < 0)
2044  cLineScroll -= descr->page_size;
2045 #endif
2046  LISTBOX_SetTopItem( descr, descr->top_item - cLineScroll, TRUE );
2047  }
2048  return 0;
2049 }
#define TRUE
Definition: types.h:120
#define WHEEL_DELTA
Definition: treelist.c:99
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:292
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
const char * descr
Definition: boot.c:45
static float(__cdecl *square_half_float)(float x
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleSystemTimer()

static LRESULT LISTBOX_HandleSystemTimer ( LB_DESCR descr)
static

Definition at line 2293 of file listbox.c.

2294 {
2295  if (!LISTBOX_HandleTimer( descr, descr->focus_item, LISTBOX_Timer ))
2296  {
2297  KillSystemTimer( descr->self, LB_TIMER_ID );
2299  }
2300  return 0;
2301 }
static TIMER_DIRECTION LISTBOX_Timer
Definition: listbox.c:118
const char * descr
Definition: boot.c:45
BOOL WINAPI KillSystemTimer(HWND, UINT_PTR)
Definition: timer.c:35
#define LB_TIMER_ID
Definition: listbox.c:44
static LRESULT LISTBOX_HandleTimer(LB_DESCR *descr, INT index, TIMER_DIRECTION dir)
Definition: listbox.c:2259

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleTimer()

static LRESULT LISTBOX_HandleTimer ( LB_DESCR descr,
INT  index,
TIMER_DIRECTION  dir 
)
static

Definition at line 2259 of file listbox.c.

2260 {
2261  switch(dir)
2262  {
2263  case LB_TIMER_UP:
2264  if (descr->top_item) index = descr->top_item - 1;
2265  else index = 0;
2266  break;
2267  case LB_TIMER_LEFT:
2268  if (descr->top_item) index -= descr->page_size;
2269  break;
2270  case LB_TIMER_DOWN:
2271  index = descr->top_item + LISTBOX_GetCurrentPageSize( descr );
2272  if (index == descr->focus_item) index++;
2273  if (index >= descr->nb_items) index = descr->nb_items - 1;
2274  break;
2275  case LB_TIMER_RIGHT:
2276  if (index + descr->page_size < descr->nb_items)
2277  index += descr->page_size;
2278  break;
2279  case LB_TIMER_NONE:
2280  break;
2281  }
2282  if (index == descr->focus_item) return FALSE;
2284  return TRUE;
2285 }
#define TRUE
Definition: types.h:120
static INT LISTBOX_GetCurrentPageSize(const LB_DESCR *descr)
Definition: listbox.c:159
#define FALSE
Definition: types.h:117
GLuint index
Definition: glext.h:6031
unsigned int dir
Definition: maze.c:112
const char * descr
Definition: boot.c:45
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1481

Referenced by LISTBOX_HandleMouseMove(), and LISTBOX_HandleSystemTimer().

◆ LISTBOX_HandleVScroll()

static LRESULT LISTBOX_HandleVScroll ( LB_DESCR descr,
WORD  scrollReq,
WORD  pos 
)
static

Definition at line 1889 of file listbox.c.

1890 {
1891  SCROLLINFO info;
1892 
1893  if (descr->style & LBS_MULTICOLUMN) return 0;
1894  switch(scrollReq)
1895  {
1896  case SB_LINEUP:
1897  LISTBOX_SetTopItem( descr, descr->top_item - 1, TRUE );
1898  break;
1899  case SB_LINEDOWN:
1900  LISTBOX_SetTopItem( descr, descr->top_item + 1, TRUE );
1901  break;
1902  case SB_PAGEUP:
1903  LISTBOX_SetTopItem( descr, descr->top_item -
1905  break;
1906  case SB_PAGEDOWN:
1907  LISTBOX_SetTopItem( descr, descr->top_item +
1909  break;
1910  case SB_THUMBPOSITION:
1912  break;
1913  case SB_THUMBTRACK:
1914  info.cbSize = sizeof(info);
1915  info.fMask = SIF_TRACKPOS;
1916  GetScrollInfo( descr->self, SB_VERT, &info );
1917  LISTBOX_SetTopItem( descr, info.nTrackPos, TRUE );
1918  break;
1919  case SB_TOP:
1920  LISTBOX_SetTopItem( descr, 0, TRUE );
1921  break;
1922  case SB_BOTTOM:
1923  LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
1924  break;
1925  }
1926  return 0;
1927 }
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
#define SB_VERT
Definition: winuser.h:553
#define TRUE
Definition: types.h:120
static INT LISTBOX_GetCurrentPageSize(const LB_DESCR *descr)
Definition: listbox.c:159
struct _test_info info[]
Definition: SetCursorPos.c:19
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:292
#define SB_THUMBPOSITION
Definition: winuser.h:572
#define SB_THUMBTRACK
Definition: winuser.h:573
const char * descr
Definition: boot.c:45
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define SB_TOP
Definition: winuser.h:578
#define SIF_TRACKPOS
Definition: winuser.h:1223
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_LINEUP
Definition: winuser.h:564
#define SB_BOTTOM
Definition: winuser.h:577
#define LBS_MULTICOLUMN
Definition: pedump.c:687

Referenced by ListBoxWndProc_common().

◆ LISTBOX_InitStorage()

static LRESULT LISTBOX_InitStorage ( LB_DESCR descr,
INT  nb_items 
)
static

Definition at line 717 of file listbox.c.

718 {
719  LB_ITEMDATA *item;
720 
721  nb_items += LB_ARRAY_GRANULARITY - 1;
722  nb_items -= (nb_items % LB_ARRAY_GRANULARITY);
723  if (descr->items) {
724  nb_items += HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(*item);
725  item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
726  nb_items * sizeof(LB_ITEMDATA));
727  }
728  else {
729  item = HeapAlloc( GetProcessHeap(), 0,
730  nb_items * sizeof(LB_ITEMDATA));
731  }
732 
733  if (!item)
734  {
736  return LB_ERRSPACE;
737  }
738  descr->items = item;
739  return LB_OKAY;
740 }
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
#define LB_ARRAY_GRANULARITY
Definition: listbox.c:38
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45
#define LBN_ERRSPACE
Definition: winuser.h:2054
#define LB_ERRSPACE
Definition: winuser.h:2408
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:102
static ATOM item
Definition: dde.c:856
#define HeapReAlloc
Definition: compat.h:482

Referenced by ListBoxWndProc_common().

◆ LISTBOX_InsertItem()

static LRESULT LISTBOX_InsertItem ( LB_DESCR descr,
INT  index,
LPWSTR  str,
ULONG_PTR  data 
)
static

Definition at line 1528 of file listbox.c.

1530 {
1531  LB_ITEMDATA *item;
1532  INT max_items;
1533  INT oldfocus = descr->focus_item;
1534 
1535  if (index == -1) index = descr->nb_items;
1536  else if ((index < 0) || (index > descr->nb_items)) return LB_ERR;
1537  if (!descr->items) max_items = 0;
1538  else max_items = HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(*item);
1539  if (descr->nb_items == max_items)
1540  {
1541  /* We need to grow the array */
1542  max_items += LB_ARRAY_GRANULARITY;
1543  if (descr->items)
1544  item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
1545  max_items * sizeof(LB_ITEMDATA) );
1546  else
1547  item = HeapAlloc( GetProcessHeap(), 0,
1548  max_items * sizeof(LB_ITEMDATA) );
1549  if (!item)
1550  {
1552  return LB_ERRSPACE;
1553  }
1554  descr->items = item;
1555  }
1556 
1557  /* Insert the item structure */
1558 
1559  item = &descr->items[index];
1560  if (index < descr->nb_items)
1561  RtlMoveMemory( item + 1, item,
1562  (descr->nb_items - index) * sizeof(LB_ITEMDATA) );
1563  item->str = str;
1564  item->data = data;
1565  item->height = 0;
1566  item->selected = FALSE;
1567  descr->nb_items++;
1568 
1569  /* Get item height */
1570 
1571  if (descr->style & LBS_OWNERDRAWVARIABLE)
1572  {
1573  MEASUREITEMSTRUCT mis;
1574  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1575 
1576  mis.CtlType = ODT_LISTBOX;
1577  mis.CtlID = id;
1578  mis.itemID = index;
1579  mis.itemData = descr->items[index].data;
1580  mis.itemHeight = descr->item_height;
1581  SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
1582  item->height = mis.itemHeight ? mis.itemHeight : 1;
1583  TRACE("[%p]: measure item %d (%s) = %d\n",
1584  descr->self, index, str ? debugstr_w(str) : "", item->height );
1585  }
1586 
1587  /* Repaint the items */
1588 
1591 
1592  /* Move selection and focused item */
1593  /* If listbox was empty, set focus to the first item */
1594  if (descr->nb_items == 1)
1596  /* single select don't change selection index in win31 */
1597  else if ((ISWIN31) && !(IS_MULTISELECT(descr)))
1598  {
1599  descr->selected_item++;
1600  LISTBOX_SetSelection( descr, descr->selected_item-1, TRUE, FALSE );
1601  }
1602  else
1603  {
1604  if (index <= descr->selected_item)
1605  {
1606  descr->selected_item++;
1607  descr->focus_item = oldfocus; /* focus not changed */
1608  }
1609  }
1610  return LB_OKAY;
1611 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1438
#define IS_MULTISELECT(descr)
Definition: listbox.c:98
#define TRUE
Definition: types.h:120
static void LISTBOX_UpdateScroll(LB_DESCR *descr)
Definition: listbox.c:209
#define GetWindowLongPtrW
Definition: winuser.h:4804
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
int32_t INT
Definition: typedefs.h:58
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1373
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define ISWIN31
Definition: listbox.c:106
#define FALSE
Definition: types.h:117
#define LB_ERR
Definition: winuser.h:2407
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
GLuint index
Definition: glext.h:6031
#define LB_ARRAY_GRANULARITY
Definition: listbox.c:38
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45
#define LBN_ERRSPACE
Definition: winuser.h:2054
#define WM_MEASUREITEM
Definition: winuser.h:1628
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define LB_ERRSPACE
Definition: winuser.h:2408
#define index(s, c)
Definition: various.h:29
ULONG_PTR itemData
Definition: winuser.h:3621
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:102
static ATOM item
Definition: dde.c:856
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HeapReAlloc
Definition: compat.h:482
unsigned int UINT
Definition: ndis.h:50
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
#define ODT_LISTBOX
Definition: winuser.h:2513
GLenum GLuint id
Definition: glext.h:5579
#define GWLP_ID
Definition: winuser.h:854
static void LISTBOX_InvalidateItems(LB_DESCR *descr, INT index)
Definition: listbox.c:1145

Referenced by LISTBOX_InsertString().

◆ LISTBOX_InsertString()

static LRESULT LISTBOX_InsertString ( LB_DESCR descr,
INT  index,
LPCWSTR  str 
)
static

Definition at line 1617 of file listbox.c.

1618 {
1619  LPWSTR new_str = NULL;
1620  ULONG_PTR data = 0;
1621  LRESULT ret;
1622 
1623  if (HAS_STRINGS(descr))
1624  {
1625  static const WCHAR empty_stringW[] = { 0 };
1626  if (!str) str = empty_stringW;
1627  if (!(new_str = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(WCHAR) )))
1628  {
1630  return LB_ERRSPACE;
1631  }
1632  strcpyW(new_str, str);
1633  }
1634  else data = (ULONG_PTR)str;
1635 
1636  if (index == -1) index = descr->nb_items;
1637  if ((ret = LISTBOX_InsertItem( descr, index, new_str, data )) != 0)
1638  {
1639  HeapFree( GetProcessHeap(), 0, new_str );
1640  return ret;
1641  }
1642 
1643  TRACE("[%p]: added item %d %s\n",
1644  descr->self, index, HAS_STRINGS(descr) ? debugstr_w(new_str) : "" );
1645  return index;
1646 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static LRESULT LISTBOX_InsertItem(LB_DESCR *descr, INT index, LPWSTR str, ULONG_PTR data)
Definition: listbox.c:1528
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
const char * descr
Definition: boot.c:45
#define LBN_ERRSPACE
Definition: winuser.h:2054
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define LB_ERRSPACE
Definition: winuser.h:2408
int ret
#define index(s, c)
Definition: various.h:29
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:102
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define ULONG_PTR
Definition: config.h:101
#define HAS_STRINGS(descr)
Definition: listbox.c:94
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LONG_PTR LRESULT
Definition: windef.h:209
static const WCHAR empty_stringW[]
Definition: edit.c:166
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by LISTBOX_Directory(), LISTBOX_SetCount(), and ListBoxWndProc_common().

◆ LISTBOX_InvalidateItemRect()

static void LISTBOX_InvalidateItemRect ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1169 of file listbox.c.

1170 {
1171  RECT rect;
1172 
1173  if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1174  InvalidateRect( descr->self, &rect, TRUE );
1175 }
#define TRUE
Definition: types.h:120
& rect
Definition: startmenu.cpp:1413
GLuint index
Definition: glext.h:6031
const char * descr
Definition: boot.c:45
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:416

Referenced by LISTBOX_SelectItemRange().

◆ LISTBOX_InvalidateItems()

static void LISTBOX_InvalidateItems ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1145 of file listbox.c.

1146 {
1147  RECT rect;
1148 
1149  if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1150  {
1151  if (descr->style & LBS_NOREDRAW)
1152  {
1153  descr->style |= LBS_DISPLAYCHANGED;
1154  return;
1155  }
1156  rect.bottom = descr->height;
1157  InvalidateRect( descr->self, &rect, TRUE );
1158  if (descr->style & LBS_MULTICOLUMN)
1159  {
1160  /* Repaint the other columns */
1161  rect.left = rect.right;
1162  rect.right = descr->width;
1163  rect.top = 0;
1164  InvalidateRect( descr->self, &rect, TRUE );
1165  }
1166  }
1167 }
#define LBS_DISPLAYCHANGED
Definition: listbox.c:47
#define TRUE
Definition: types.h:120
& rect
Definition: startmenu.cpp:1413
#define LBS_NOREDRAW
Definition: pedump.c:680
GLuint index
Definition: glext.h:6031
const char * descr
Definition: boot.c:45
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define LBS_MULTICOLUMN
Definition: pedump.c:687
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:416

Referenced by LISTBOX_InsertItem(), LISTBOX_RemoveItem(), and LISTBOX_SetItemHeight().

◆ LISTBOX_lstrcmpiW()

static INT LISTBOX_lstrcmpiW ( LCID  lcid,
LPCWSTR  str1,
LPCWSTR  str2 
)
inlinestatic

Definition at line 828 of file listbox.c.

829 {
830  INT ret = CompareStringW( lcid, NORM_IGNORECASE, str1, -1, str2, -1 );
831  if (ret == CSTR_LESS_THAN)
832  return -1;
833  if (ret == CSTR_EQUAL)
834  return 0;
835  if (ret == CSTR_GREATER_THAN)
836  return 1;
837  return -1;
838 }
#define CSTR_GREATER_THAN
Definition: winnls.h:454
#define NORM_IGNORECASE
Definition: winnls.h:173
int32_t INT
Definition: typedefs.h:58
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2275
int ret
#define CSTR_EQUAL
Definition: winnls.h:453
#define CSTR_LESS_THAN
Definition: winnls.h:452

Referenced by LISTBOX_FindFileStrPos(), LISTBOX_FindString(), and LISTBOX_FindStringPos().

◆ LISTBOX_MakeItemVisible()

static void LISTBOX_MakeItemVisible ( LB_DESCR descr,
INT  index,
BOOL  fully 
)
static

Definition at line 1334 of file listbox.c.

1335 {
1336  INT top;
1337 
1338  TRACE("current top item %d, index %d, fully %d\n", descr->top_item, index, fully);
1339 
1340  if (index <= descr->top_item) top = index;
1341  else if (descr->style & LBS_MULTICOLUMN)
1342  {
1343  INT cols = descr->width;
1344  if (!fully) cols += descr->column_width - 1;
1345  if (cols >= descr->column_width) cols /= descr->column_width;
1346  else cols = 1;
1347  if (index < descr->top_item + (descr->page_size * cols)) return;
1348  top = index - descr->page_size * (cols - 1);
1349  }
1350  else if (descr->style & LBS_OWNERDRAWVARIABLE)
1351  {
1352  INT height = fully ? descr->items[index].height : 1;
1353  for (top = index; top > descr->top_item; top--)
1354  if ((height += descr->items[top-1].height) > descr->height) break;
1355  }
1356  else
1357  {
1358  if (index < descr->top_item + descr->page_size) return;
1359  if (!fully && (index == descr->top_item + descr->page_size) &&
1360  (descr->height > (descr->page_size * descr->item_height))) return;
1361  top = index - descr->page_size + 1;
1362  }
1364 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:292
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
#define LBS_MULTICOLUMN
Definition: pedump.c:687
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859

Referenced by LISTBOX_MoveCaret(), and LISTBOX_SetCaretIndex().

◆ LISTBOX_MoveCaret()

static void LISTBOX_MoveCaret ( LB_DESCR descr,
INT  index,
BOOL  fully_visible 
)
static

Definition at line 1481 of file listbox.c.

1482 {
1483  TRACE("old focus %d, index %d\n", descr->focus_item, index);
1484 
1485  if ((index < 0) || (index >= descr->nb_items))
1486  return;
1487 
1488  /* Important, repaint needs to be done in this order if
1489  you want to mimic Windows behavior:
1490  1. Remove the focus and paint the item
1491  2. Remove the selection and paint the item(s)
1492  3. Set the selection and repaint the item(s)
1493  4. Set the focus to 'index' and repaint the item */
1494 
1495  /* 1. remove the focus and repaint the item */
1497 
1498  /* 2. then turn off the previous selection */
1499  /* 3. repaint the new selected item */
1500  if (descr->style & LBS_EXTENDEDSEL)
1501  {
1502  if (descr->anchor_item != -1)
1503  {
1504  INT first = min( index, descr->anchor_item );
1505  INT last = max( index, descr->anchor_item );
1506  if (first > 0)
1508  LISTBOX_SelectItemRange( descr, last + 1, -1, FALSE );
1510  }
1511  }
1512  else if (!(descr->style & LBS_MULTIPLESEL))
1513  {
1514  /* Set selection to new caret item */
1516  }
1517 
1518  /* 4. repaint the new item with the focus */
1519  descr->focus_item = index;
1520  LISTBOX_MakeItemVisible( descr, index, fully_visible );
1522 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1438
#define max(a, b)
Definition: svc.c:63
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
POINT last
Definition: font.c:46
#define TRUE
Definition: types.h:120
const GLint * first
Definition: glext.h:5794
int32_t INT
Definition: typedefs.h:58
static void LISTBOX_MakeItemVisible(LB_DESCR *descr, INT index, BOOL fully)
Definition: listbox.c:1334
#define FALSE
Definition: types.h:117
static void LISTBOX_DrawFocusRect(LB_DESCR *descr, BOOL on)
Definition: listbox.c:690
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
static LRESULT LISTBOX_SelectItemRange(LB_DESCR *descr, INT first, INT last, BOOL on)
Definition: listbox.c:1398
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
#define min(a, b)
Definition: monoChain.cc:55
#define LBS_MULTIPLESEL
Definition: pedump.c:681

Referenced by LISTBOX_HandleChar(), LISTBOX_HandleKeyDown(), LISTBOX_HandleLButtonDown(), LISTBOX_HandleTimer(), and ListBoxWndProc_common().

◆ LISTBOX_Paint()

static LRESULT LISTBOX_Paint ( LB_DESCR descr,
HDC  hdc 
)
static

Definition at line 1026 of file listbox.c.

1027 {
1028  INT i, col_pos = descr->page_size - 1;
1029  RECT rect;
1030  RECT focusRect = {-1, -1, -1, -1};
1031  HFONT oldFont = 0;
1032  HBRUSH hbrush, oldBrush = 0;
1033 
1034  if (descr->style & LBS_NOREDRAW) return 0;
1035 
1036  SetRect( &rect, 0, 0, descr->width, descr->height );
1037  if (descr->style & LBS_MULTICOLUMN)
1038  rect.right = rect.left + descr->column_width;
1039  else if (descr->horz_pos)
1040  {
1041  SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
1042  rect.right += descr->horz_pos;
1043  }
1044 
1045  if (descr->font) oldFont = SelectObject( hdc, descr->font );
1046 #ifdef __REACTOS__
1048 #else
1049  hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
1050  (WPARAM)hdc, (LPARAM)descr->self );
1051 #endif
1052  if (hbrush) oldBrush = SelectObject( hdc, hbrush );
1054 
1055  if (!descr->nb_items && (descr->focus_item != -1) && descr->caret_on &&
1056  (descr->in_focus))
1057  {
1058  /* Special case for empty listbox: paint focus rect */
1059  rect.bottom = rect.top + descr->item_height;
1061  &rect, NULL, 0, NULL );
1062  LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, FALSE );
1063  rect.top = rect.bottom;
1064  }
1065 
1066  /* Paint all the item, regarding the selection
1067  Focus state will be painted after */
1068 
1069  for (i = descr->top_item; i < descr->nb_items; i++)
1070  {
1071  if (!(descr->style & LBS_OWNERDRAWVARIABLE))
1072  rect.bottom = rect.top + descr->item_height;
1073  else
1074  rect.bottom = rect.top + descr->items[i].height;
1075 
1076  /* keep the focus rect, to paint the focus item after */
1077  if (i == descr->focus_item)
1078  focusRect = rect;
1079 
1081  rect.top = rect.bottom;
1082 
1083  if ((descr->style & LBS_MULTICOLUMN) && !col_pos)
1084  {
1085  if (!IS_OWNERDRAW(descr))
1086  {
1087  /* Clear the bottom of the column */
1088  if (rect.top < descr->height)
1089  {
1090  rect.bottom = descr->height;
1092  &rect, NULL, 0, NULL );
1093  }
1094  }
1095 
1096  /* Go to the next column */
1097  rect.left += descr->column_width;
1098  rect.right += descr->column_width;
1099  rect.top = 0;
1100  col_pos = descr->page_size - 1;
1101  }
1102  else
1103  {
1104  col_pos--;
1105  if (rect.top >= descr->height) break;
1106  }
1107  }
1108 
1109  /* Paint the focus item now */
1110  if (focusRect.top != focusRect.bottom &&
1111  descr->caret_on && descr->in_focus)
1112  LISTBOX_PaintItem( descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS, FALSE );
1113 
1114  if (!IS_OWNERDRAW(descr))
1115  {
1116  /* Clear the remainder of the client area */
1117  if (rect.top < descr->height)
1118  {
1119  rect.bottom = descr->height;
1121  &rect, NULL, 0, NULL );
1122  }
1123  if (rect.right < descr->width)
1124  {
1125  rect.left = rect.right;
1126  rect.right = descr->width;
1127  rect.top = 0;
1128  rect.bottom = descr->height;
1130  &rect, NULL, 0, NULL );
1131  }
1132  }
1133  if (oldFont) SelectObject( hdc, oldFont );
1134  if (oldBrush) SelectObject( hdc, oldBrush );
1135  return 0;
1136 }
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)
static HBRUSH hbrush
#define TRUE
Definition: types.h:120
#define IS_OWNERDRAW(descr)
Definition: listbox.c:91
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_CTLCOLORLISTBOX
Definition: winuser.h:1750
#define ODA_FOCUS
Definition: winuser.h:2519
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetSysColor(_In_ int)
& rect
Definition: startmenu.cpp:1413
#define LBS_NOREDRAW
Definition: pedump.c:680
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:145
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
#define ETO_OPAQUE
Definition: wingdi.h:646
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define ETO_CLIPPED
Definition: wingdi.h:647
#define ODA_DRAWENTIRE
Definition: winuser.h:2517
const char * descr
Definition: boot.c:45
#define COLOR_GRAYTEXT
Definition: winuser.h:922
HDC hdc
Definition: main.c:9
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define LBS_MULTICOLUMN
Definition: pedump.c:687
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
LONG bottom
Definition: windef.h:309
static void LISTBOX_PaintItem(LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus)
Definition: listbox.c:521

Referenced by ListBoxWndProc_common().

◆ LISTBOX_PaintItem()

static void LISTBOX_PaintItem ( LB_DESCR descr,
HDC  hdc,
const RECT rect,
INT  index,
UINT  action,
BOOL  ignoreFocus 
)
static

Definition at line 521 of file listbox.c.

523 {
524  LB_ITEMDATA *item = NULL;
525  if (index < descr->nb_items) item = &descr->items[index];
526 
527  if (IS_OWNERDRAW(descr))
528  {
529  DRAWITEMSTRUCT dis;
530  RECT r;
531  HRGN hrgn;
532 
533  if (!item)
534  {
535  if (action == ODA_FOCUS)
536  { // REACTOS
537  if (!(descr->UIState & UISF_HIDEFOCUS))
538  DrawFocusRect( hdc, rect );
539  } //
540  else
541  ERR("called with an out of bounds index %d(%d) in owner draw, Not good.\n",index,descr->nb_items);
542  return;
543  }
544 
545  /* some programs mess with the clipping region when
546  drawing the item, *and* restore the previous region
547  after they are done, so a region has better to exist
548  else everything ends clipped */
549  GetClientRect(descr->self, &r);
551 
552  dis.CtlType = ODT_LISTBOX;
553  dis.CtlID = GetWindowLongPtrW( descr->self, GWLP_ID );
554  dis.hwndItem = descr->self;
555  dis.itemAction = action;
556  dis.hDC = hdc;
557  dis.itemID = index;
558  dis.itemState = 0;
559  if (item->selected) dis.itemState |= ODS_SELECTED;
560  if (!ignoreFocus && (descr->focus_item == index) &&
561  (descr->caret_on) &&
562  (descr->in_focus)) dis.itemState |= ODS_FOCUS;
563  if (!IsWindowEnabled(descr->self)) dis.itemState |= ODS_DISABLED;
564  dis.itemData = item->data;
565  dis.rcItem = *rect;
566  TRACE("[%p]: drawitem %d (%s) action=%02x state=%02x rect=%s\n",
567  descr->self, index, debugstr_w(item->str), action,
569  SendMessageW(descr->owner, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
570  SelectClipRgn( hdc, hrgn );
571  if (hrgn) DeleteObject( hrgn );
572  }
573  else
574  {
575  COLORREF oldText = 0, oldBk = 0;
576 
577  if (action == ODA_FOCUS)
578  {
579  if (!(descr->UIState & UISF_HIDEFOCUS)) // REACTOS
580  DrawFocusRect( hdc, rect );
581  return;
582  }
583  if (item && item->selected)
584  {
585  oldBk = SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
587  }
588 
589  TRACE("[%p]: painting %d (%s) action=%02x rect=%s\n",
590  descr->self, index, item ? debugstr_w(item->str) : "", action,
592  if (!item)
593  ExtTextOutW( hdc, rect->left + 1, rect->top,
594  ETO_OPAQUE | ETO_CLIPPED, rect, NULL, 0, NULL );
595  else if (!(descr->style & LBS_USETABSTOPS))
596  ExtTextOutW( hdc, rect->left + 1, rect->top,
597  ETO_OPAQUE | ETO_CLIPPED, rect, item->str,
598  strlenW(item->str), NULL );
599  else
600  {
601  /* Output empty string to paint background in the full width. */
602  ExtTextOutW( hdc, rect->left + 1, rect->top,
603  ETO_OPAQUE | ETO_CLIPPED, rect, NULL, 0, NULL );
604  TabbedTextOutW( hdc, rect->left + 1 , rect->top,
605  item->str, strlenW(item->str),
606  descr->nb_tabs, descr->tabs, 0);
607  }
608  if (item && item->selected)
609  {
610  SetBkColor( hdc, oldBk );
611  SetTextColor( hdc, oldText );
612  }
613  if (!ignoreFocus && (descr->focus_item == index) &&
614  (descr->caret_on) &&
615  (descr->in_focus) &&
616  !(descr->UIState & UISF_HIDEFOCUS)) DrawFocusRect( hdc, rect );
617  }
618 }
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)
#define COLOR_HIGHLIGHT
Definition: winuser.h:916
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define IS_OWNERDRAW(descr)
Definition: listbox.c:91
ULONG_PTR itemData
Definition: winuser.h:3068
#define ODS_FOCUS
Definition: winuser.h:2524
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GetWindowLongPtrW
Definition: winuser.h:4804
#define ODA_FOCUS
Definition: winuser.h:2519
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:239
DWORD WINAPI GetSysColor(_In_ int)
& rect
Definition: startmenu.cpp:1413
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:977
#define ETO_OPAQUE
Definition: wingdi.h:646
#define debugstr_w
Definition: kernel32.h:32
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)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define ETO_CLIPPED
Definition: wingdi.h:647
GLuint index
Definition: glext.h:6031
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:917
#define LBS_USETABSTOPS
Definition: pedump.c:685
#define TRACE(s)
Definition: solgame.cpp:4
#define ODS_DISABLED
Definition: winuser.h:2522
DWORD COLORREF
Definition: windef.h:300
const char * descr
Definition: boot.c:45
const char * wine_dbgstr_rect(const RECT *rect)
#define index(s, c)
Definition: various.h:29
HDC hdc
Definition: main.c:9
static HRGN hrgn
Definition: win.c:55
#define ERR(fmt,...)
Definition: debug.h:110
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
const WCHAR * action
Definition: action.c:7783
static ATOM item
Definition: dde.c:856
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ODT_LISTBOX
Definition: winuser.h:2513
#define WM_DRAWITEM
Definition: winuser.h:1627
#define ODS_SELECTED
Definition: winuser.h:2520
#define GWLP_ID
Definition: winuser.h:854

Referenced by LISTBOX_DrawFocusRect(), LISTBOX_Paint(), and LISTBOX_RepaintItem().

◆ LISTBOX_RemoveItem()

static LRESULT LISTBOX_RemoveItem ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1690 of file listbox.c.

1691 {
1692  LB_ITEMDATA *item;
1693  INT max_items;
1694 
1695  if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1696 
1697  /* We need to invalidate the original rect instead of the updated one. */
1699 
1700  descr->nb_items--;
1702 
1703  if (!descr->nb_items) return LB_OKAY;
1704 
1705  /* Remove the item */
1706 
1707  item = &descr->items[index];
1708  if (index < descr->nb_items)
1709  RtlMoveMemory( item, item + 1,
1710  (descr->nb_items - index) * sizeof(LB_ITEMDATA) );
1711  if (descr->anchor_item == descr->nb_items) descr->anchor_item--;
1712 
1713  /* Shrink the item array if possible */
1714 
1715  max_items = HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(LB_ITEMDATA);
1716  if (descr->nb_items < max_items - 2*LB_ARRAY_GRANULARITY)
1717  {
1718  max_items -= LB_ARRAY_GRANULARITY;
1719  item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
1720  max_items * sizeof(LB_ITEMDATA) );
1721  if (item) descr->items = item;
1722  }
1723  /* Repaint the items */
1724 
1726  /* if we removed the scrollbar, reset the top of the list
1727  (correct for owner-drawn ???) */
1728  if (descr->nb_items == descr->page_size)
1729  LISTBOX_SetTopItem( descr, 0, TRUE );
1730 
1731  /* Move selection and focused item */
1732  if (!IS_MULTISELECT(descr))
1733  {
1734  if (index == descr->selected_item)
1735  descr->selected_item = -1;
1736  else if (index < descr->selected_item)
1737  {
1738  descr->selected_item--;
1739  if (ISWIN31) /* win 31 do not change the selected item number */
1740  LISTBOX_SetSelection( descr, descr->selected_item + 1, TRUE, FALSE);
1741  }
1742  }
1743 
1744  if (descr->focus_item >= descr->nb_items)
1745  {
1746  descr->focus_item = descr->nb_items - 1;
1747  if (descr->focus_item < 0) descr->focus_item = 0;
1748  }
1749  return LB_OKAY;
1750 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1438
#define IS_MULTISELECT(descr)
Definition: listbox.c:98
#define TRUE
Definition: types.h:120
static void LISTBOX_DeleteItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1654
static void LISTBOX_UpdateScroll(LB_DESCR *descr)
Definition: listbox.c:209
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
int32_t INT
Definition: typedefs.h:58
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define ISWIN31
Definition: listbox.c:106
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:292
#define FALSE
Definition: types.h:117
#define LB_ERR
Definition: winuser.h:2407
GLuint index
Definition: glext.h:6031
#define LB_ARRAY_GRANULARITY
Definition: listbox.c:38
#define GetProcessHeap()
Definition: compat.h:484
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
static ATOM item
Definition: dde.c:856
#define HeapReAlloc
Definition: compat.h:482
static void LISTBOX_InvalidateItems(LB_DESCR *descr, INT index)
Definition: listbox.c:1145

Referenced by LISTBOX_SetCount(), and ListBoxWndProc_common().

◆ LISTBOX_RepaintItem()

static void LISTBOX_RepaintItem ( LB_DESCR descr,
INT  index,
UINT  action 
)
static

Definition at line 653 of file listbox.c.

654 {
655  HDC hdc;
656  RECT rect;
657  HFONT oldFont = 0;
658  HBRUSH hbrush, oldBrush = 0;
659 
660  /* Do not repaint the item if the item is not visible */
661  if (!IsWindowVisible(descr->self)) return;
662  if (descr->style & LBS_NOREDRAW)
663  {
664  descr->style |= LBS_DISPLAYCHANGED;
665  return;
666  }
667  if (LISTBOX_GetItemRect( descr, index, &rect ) != 1) return;
668  if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
669  if (descr->font) oldFont = SelectObject( hdc, descr->font );
670 #ifdef __REACTOS__
672 #else
673  hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
674  (WPARAM)hdc, (LPARAM)descr->self );
675 #endif
676  if (hbrush) oldBrush = SelectObject( hdc, hbrush );
677  if (!IsWindowEnabled(descr->self))
679  SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
681  if (oldFont) SelectObject( hdc, oldFont );
682  if (oldBrush) SelectObject( hdc, oldBrush );
683  ReleaseDC( descr->self, hdc );
684 }
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
static HBRUSH hbrush
#define LBS_DISPLAYCHANGED
Definition: listbox.c:47
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_CTLCOLORLISTBOX
Definition: winuser.h:1750
DWORD WINAPI GetSysColor(_In_ int)
& rect
Definition: startmenu.cpp:1413
#define LBS_NOREDRAW
Definition: pedump.c:680
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:145
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI IsWindowEnabled(_In_ HWND)
GLuint index
Definition: glext.h:6031
const char * descr
Definition: boot.c:45
#define COLOR_GRAYTEXT
Definition: winuser.h:922
HDC hdc
Definition: main.c:9
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
#define DCX_CACHE
Definition: winuser.h:2096
const WCHAR * action
Definition: action.c:7783
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
BOOL WINAPI IsWindowVisible(_In_ HWND)
static void LISTBOX_PaintItem(LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus)
Definition: listbox.c:521
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:416

Referenced by LISTBOX_SetSelection(), and ListBoxWndProc_common().

◆ LISTBOX_ResetContent()

static void LISTBOX_ResetContent ( LB_DESCR descr)
static

Definition at line 1756 of file listbox.c.

1757 {
1758  INT i;
1759 
1760  for(i = descr->nb_items - 1; i>=0; i--) LISTBOX_DeleteItem( descr, i);
1761  HeapFree( GetProcessHeap(), 0, descr->items );
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;
1767  descr->items = NULL;
1768 }
static void LISTBOX_DeleteItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1654
int32_t INT
Definition: typedefs.h:58
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
const char * descr
Definition: boot.c:45
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by LISTBOX_Destroy(), and ListBoxWndProc_common().

◆ LISTBOX_SelectItemRange()

static LRESULT LISTBOX_SelectItemRange ( LB_DESCR descr,
INT  first,
INT  last,
BOOL  on 
)
static

Definition at line 1398 of file listbox.c.

1400 {
1401  INT i;
1402 
1403  /* A few sanity checks */
1404 
1405  if (descr->style & LBS_NOSEL) return LB_ERR;
1406  if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
1407 
1408  if (!descr->nb_items) return LB_OKAY;
1409 
1410  if (last == -1 || last >= descr->nb_items) last = descr->nb_items - 1;
1411  if (first < 0) first = 0;
1412  if (last < first) return LB_OKAY;
1413 
1414  if (on) /* Turn selection on */
1415  {
1416  for (i = first; i <= last; i++)
1417  {
1418  if (descr->items[i].selected) continue;
1419  descr->items[i].selected = TRUE;
1421  }
1422  }
1423  else /* Turn selection off */
1424  {
1425  for (i = first; i <= last; i++)
1426  {
1427  if (!descr->items[i].selected) continue;
1428  descr->items[i].selected = FALSE;
1430  }
1431  }
1432  return LB_OKAY;
1433 }
POINT last
Definition: font.c:46
#define TRUE
Definition: types.h:120
const GLint * first
Definition: glext.h:5794
int32_t INT
Definition: typedefs.h:58
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
#define LB_ERR
Definition: winuser.h:2407
#define LB_OKAY
Definition: winuser.h:2406
static void LISTBOX_InvalidateItemRect(LB_DESCR *descr, INT index)
Definition: listbox.c:1169
const char * descr
Definition: boot.c:45
#define LBS_NOSEL
Definition: winuser.h:316
#define LBS_MULTIPLESEL
Definition: pedump.c:681

Referenced by LISTBOX_MoveCaret(), LISTBOX_SetSelection(), and ListBoxWndProc_common().

◆ LISTBOX_SetCaretIndex()

static LRESULT LISTBOX_SetCaretIndex ( LB_DESCR descr,
INT  index,
BOOL  fully_visible 
)
static

Definition at line 1373 of file listbox.c.

1374 {
1375  INT oldfocus = descr->focus_item;
1376 
1377  TRACE("old focus %d, index %d\n", oldfocus, index);
1378 
1379  if (descr->style & LBS_NOSEL) return LB_ERR;
1380  if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1381  if (index == oldfocus) return LB_OKAY;
1382 
1384  descr->focus_item = index;
1385 
1386  LISTBOX_MakeItemVisible( descr, index, fully_visible );
1388 
1389  return LB_OKAY;
1390 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
static void LISTBOX_MakeItemVisible(LB_DESCR *descr, INT index, BOOL fully)
Definition: listbox.c:1334
#define FALSE
Definition: types.h:117
#define LB_ERR
Definition: winuser.h:2407
static void LISTBOX_DrawFocusRect(LB_DESCR *descr, BOOL on)
Definition: listbox.c:690
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
#define LBS_NOSEL
Definition: winuser.h:316

Referenced by LISTBOX_HandleLButtonDown(), LISTBOX_HandleLButtonDownCombo(), LISTBOX_InsertItem(), and ListBoxWndProc_common().

◆ LISTBOX_SetColumnWidth()

static LRESULT LISTBOX_SetColumnWidth ( LB_DESCR descr,
INT  width 
)
static

Definition at line 1288 of file listbox.c.

1289 {
1290  if (width == descr->column_width) return LB_OKAY;
1291  TRACE("[%p]: new column width = %d\n", descr->self, width );
1292  descr->column_width = width;
1294  return LB_OKAY;
1295 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define TRACE(s)
Definition: solgame.cpp:4
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45
static void LISTBOX_UpdatePage(LB_DESCR *descr)
Definition: listbox.c:348

Referenced by ListBoxWndProc_common().

◆ LISTBOX_SetCount()

static LRESULT LISTBOX_SetCount ( LB_DESCR descr,
INT  count 
)
static

Definition at line 1774 of file listbox.c.

1775 {
1776  LRESULT ret;
1777 
1778  if (HAS_STRINGS(descr))
1779  {
1781  return LB_ERR;
1782  }
1783 
1784  /* FIXME: this is far from optimal... */
1785  if (count > descr->nb_items)
1786  {
1787  while (count > descr->nb_items)
1788  if ((ret = LISTBOX_InsertString( descr, -1, 0 )) < 0)
1789  return ret;
1790  }
1791  else if (count < descr->nb_items)
1792  {
1793  while (count < descr->nb_items)
1794  if ((ret = LISTBOX_RemoveItem( descr, (descr->nb_items - 1) )) < 0)
1795  return ret;
1796  }
1797 
1798  InvalidateRect( descr->self, NULL, TRUE );
1799  return LB_OKAY;
1800 }
#define ERROR_SETCOUNT_ON_BAD_LB
Definition: winerror.h:914
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define LB_ERR
Definition: winuser.h:2407
smooth NULL
Definition: ftsmooth.c:416
static LRESULT LISTBOX_InsertString(LB_DESCR *descr, INT index, LPCWSTR str)
Definition: listbox.c:1617
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define SetLastError(x)
Definition: compat.h:500
int ret
#define HAS_STRINGS(descr)
Definition: listbox.c:94
LONG_PTR LRESULT
Definition: windef.h:209
static LRESULT LISTBOX_RemoveItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1690

Referenced by ListBoxWndProc_common().

◆ LISTBOX_SetFont()

static INT LISTBOX_SetFont ( LB_DESCR descr,
HFONT  font 
)
static

Definition at line 1303 of file listbox.c.

1304 {
1305  HDC hdc;
1306  HFONT oldFont = 0;
1307  const char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1308  SIZE sz;
1309 
1310  descr->font = font;
1311 
1312  if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE )))
1313  {
1314  ERR("unable to get DC.\n" );
1315  return 16;
1316  }
1317  if (font) oldFont = SelectObject( hdc, font );
1318  GetTextExtentPointA( hdc, alphabet, 52, &sz);
1319  if (oldFont) SelectObject( hdc, oldFont );
1320  ReleaseDC( descr->self, hdc );
1321 
1322  descr->avg_char_width = (sz.cx / 26 + 1) / 2;
1323  if (!IS_OWNERDRAW(descr))
1324  LISTBOX_SetItemHeight( descr, 0, sz.cy, FALSE );
1325  return sz.cy;
1326 }
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
Definition: mk_font.cpp:20
BOOL WINAPI GetTextExtentPointA(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
static HDC
Definition: imagelist.c:92
#define IS_OWNERDRAW(descr)
Definition: listbox.c:91
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
#define FALSE
Definition: types.h:117
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LONG cx
Definition: windef.h:334
const char * descr
Definition: boot.c:45
HDC hdc
Definition: main.c:9
#define ERR(fmt,...)
Definition: debug.h:110
#define DCX_CACHE
Definition: winuser.h:2096
static LRESULT LISTBOX_SetItemHeight(LB_DESCR *descr, INT index, INT height, BOOL repaint)
Definition: listbox.c:1198
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LONG cy
Definition: windef.h:335

Referenced by LISTBOX_Create(), and ListBoxWndProc_common().

◆ LISTBOX_SetHorizontalExtent()

static LRESULT LISTBOX_SetHorizontalExtent ( LB_DESCR descr,
INT  extent 
)
static

Definition at line 1262 of file listbox.c.

1263 {
1264  if (descr->style & LBS_MULTICOLUMN)
1265  return LB_OKAY;
1266  if (extent == descr->horz_extent) return LB_OKAY;
1267  TRACE("[%p]: new horz extent = %d\n", descr->self, extent );
1268  descr->horz_extent = extent;
1269  if (descr->style & WS_HSCROLL) {
1270  SCROLLINFO info;
1271  info.cbSize = sizeof(info);
1272  info.nMin = 0;
1273  info.nMax = descr->horz_extent ? descr->horz_extent - 1 : 0;
1274  info.fMask = SIF_RANGE;
1275  if (descr->style & LBS_DISABLENOSCROLL)
1276  info.fMask |= SIF_DISABLENOSCROLL;
1277  SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
1278  }
1279  if (descr->horz_pos > extent - descr->width)
1281  return LB_OKAY;
1282 }
#define SIF_RANGE
Definition: winuser.h:1221
#define TRUE
Definition: types.h:120
#define SB_HORZ
Definition: winuser.h:552
struct _test_info info[]
Definition: SetCursorPos.c:19
#define TRACE(s)
Definition: solgame.cpp:4
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45
#define WS_HSCROLL
Definition: pedump.c:628
#define LBS_DISABLENOSCROLL
Definition: pedump.c:690
#define SIF_DISABLENOSCROLL
Definition: winuser.h:1222
#define LBS_MULTICOLUMN
Definition: pedump.c:687
static void LISTBOX_SetHorizontalPos(LB_DESCR *descr, INT pos)
Definition: listbox.c:1234
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by ListBoxWndProc_common().

◆ LISTBOX_SetHorizontalPos()

static void LISTBOX_SetHorizontalPos ( LB_DESCR descr,
INT  pos 
)
static

Definition at line 1234 of file listbox.c.

1235 {
1236  INT diff;
1237 
1238