ReactOS  0.4.14-dev-337-gf981a68
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:3948
#define GetWindowLongPtrW
Definition: winuser.h:4730
LONG_PTR LPARAM
Definition: windef.h:208
const char * descr
Definition: boot.c:45
#define WM_COMMAND
Definition: winuser.h:1722
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 2497 of file listbox.c.

2498 {
2499  LB_DESCR *descr;
2500  MEASUREITEMSTRUCT mis;
2501  RECT rect;
2502 
2503  if (!(descr = HeapAlloc( GetProcessHeap(), 0, sizeof(*descr) )))
2504  return FALSE;
2505 
2506  GetClientRect( hwnd, &rect );
2507  descr->self = hwnd;
2508  descr->owner = GetParent( descr->self );
2509  descr->style = GetWindowLongPtrW( descr->self, GWL_STYLE );
2510  descr->width = rect.right - rect.left;
2511  descr->height = rect.bottom - rect.top;
2512  descr->items = NULL;
2513  descr->nb_items = 0;
2514  descr->top_item = 0;
2515  descr->selected_item = -1;
2516  descr->focus_item = 0;
2517  descr->anchor_item = -1;
2518  descr->item_height = 1;
2519  descr->page_size = 1;
2520  descr->column_width = 150;
2521  descr->horz_extent = 0;
2522  descr->horz_pos = 0;
2523  descr->nb_tabs = 0;
2524  descr->tabs = NULL;
2525  descr->wheel_remain = 0;
2526  descr->caret_on = !lphc;
2527  if (descr->style & LBS_NOSEL) descr->caret_on = FALSE;
2528  descr->in_focus = FALSE;
2529  descr->captured = FALSE;
2530  descr->font = 0;
2531  descr->locale = GetUserDefaultLCID();
2532  descr->lphc = lphc;
2533 
2534  if( lphc )
2535  {
2536  TRACE("[%p]: resetting owner %p -> %p\n", descr->self, descr->owner, lphc->self );
2537  descr->owner = lphc->self;
2538  }
2539 
2540  SetWindowLongPtrW( descr->self, 0, (LONG_PTR)descr );
2541 
2542  LISTBOX_update_uistate(descr); // ReactOS
2543 
2544 /* if (wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) descr->style &= ~LBS_NOTIFY;
2545  */
2546  if (descr->style & LBS_EXTENDEDSEL) descr->style |= LBS_MULTIPLESEL;
2547  if (descr->style & LBS_MULTICOLUMN) descr->style &= ~LBS_OWNERDRAWVARIABLE;
2548  if (descr->style & LBS_OWNERDRAWVARIABLE) descr->style |= LBS_NOINTEGRALHEIGHT;
2549 
2551  /* A no-data list box must also have the LBS_OWNERDRAWFIXED style, but must
2552  not have the LBS_SORT or LBS_HASSTRINGS style. */
2553  if ( descr->style & LBS_NODATA &&
2554  (!(descr->style & LBS_OWNERDRAWFIXED) || descr->style & (LBS_HASSTRINGS|LBS_SORT) ) )
2555  descr->style &= ~LBS_NODATA;
2557  descr->item_height = LISTBOX_SetFont( descr, 0 );
2558 
2559  if (descr->style & LBS_OWNERDRAWFIXED)
2560  {
2561  if( descr->lphc && (descr->lphc->dwStyle & CBS_DROPDOWN))
2562  {
2563  /* WinWord gets VERY unhappy if we send WM_MEASUREITEM from here */
2564  descr->item_height = lphc->fixedOwnerDrawHeight;
2565  }
2566  else
2567  {
2568  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
2569  mis.CtlType = ODT_LISTBOX;
2570  mis.CtlID = id;
2571  mis.itemID = -1;
2572  mis.itemWidth = 0;
2573  mis.itemData = 0;
2574  mis.itemHeight = descr->item_height;
2575  SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
2576  descr->item_height = mis.itemHeight ? mis.itemHeight : 1;
2577  }
2578  }
2579 
2580  TRACE("owner: %p, style: %08x, width: %d, height: %d\n", descr->owner, descr->style, descr->width, descr->height);
2581  return TRUE;
2582 }
static INT LISTBOX_SetFont(LB_DESCR *descr, HFONT font)
Definition: listbox.c:1297
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define LBS_NODATA
Definition: winuser.h:313
#define TRUE
Definition: types.h:120
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
static BOOL LISTBOX_update_uistate(LB_DESCR *descr)
Definition: listbox.c:2484
#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:4730
& rect
Definition: startmenu.cpp:1413
#define LBS_OWNERDRAWFIXED
Definition: pedump.c:682
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:403
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:3620
#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:5247
#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 1648 of file listbox.c.

1649 {
1650  /* save the item data before it gets freed by LB_RESETCONTENT */
1651  ULONG_PTR item_data = descr->items[index].data;
1652  LPWSTR item_str = descr->items[index].str;
1653 
1654  if (!descr->nb_items)
1655  SendMessageW( descr->self, LB_RESETCONTENT, 0, 0 );
1656 
1657  /* Note: Win 3.1 only sends DELETEITEM on owner-draw items,
1658  * while Win95 sends it for all items with user data.
1659  * It's probably better to send it too often than not
1660  * often enough, so this is what we do here.
1661  */
1662  if (IS_OWNERDRAW(descr) || item_data)
1663  {
1664  DELETEITEMSTRUCT dis;
1665  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1666 
1667  dis.CtlType = ODT_LISTBOX;
1668  dis.CtlID = id;
1669  dis.itemID = index;
1670  dis.hwndItem = descr->self;
1671  dis.itemData = item_data;
1672  SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis );
1673  }
1674  if (HAS_STRINGS(descr))
1675  HeapFree( GetProcessHeap(), 0, item_str );
1676 }
#define IS_OWNERDRAW(descr)
Definition: listbox.c:91
#define GetWindowLongPtrW
Definition: winuser.h:4730
ULONG_PTR itemData
Definition: winuser.h:3018
uint32_t ULONG_PTR
Definition: typedefs.h:63
#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:403
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:402
#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 2588 of file listbox.c.

2589 {
2591  SetWindowLongPtrW( descr->self, 0, 0 );
2592  HeapFree( GetProcessHeap(), 0, descr );
2593  return TRUE;
2594 }
#define TRUE
Definition: types.h:120
static void LISTBOX_ResetContent(LB_DESCR *descr)
Definition: listbox.c:1750
#define GetProcessHeap()
Definition: compat.h:403
const char * descr
Definition: boot.c:45
#define SetWindowLongPtrW
Definition: winuser.h:5247
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by ListBoxWndProc_common().

◆ LISTBOX_Directory()

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

Definition at line 1800 of file listbox.c.

1802 {
1803  HANDLE handle;
1804  LRESULT ret = LB_OKAY;
1806  int pos;
1807  LRESULT maxinsert = LB_ERR;
1808 
1809  /* don't scan directory if we just want drives exclusively */
1810  if (attrib != (DDL_DRIVES | DDL_EXCLUSIVE)) {
1811  /* scan directory */
1812  if ((handle = FindFirstFileW(filespec, &entry)) == INVALID_HANDLE_VALUE)
1813  {
1814  int le = GetLastError();
1815  if ((le != ERROR_NO_MORE_FILES) && (le != ERROR_FILE_NOT_FOUND)) return LB_ERR;
1816  }
1817  else
1818  {
1819  do
1820  {
1821  WCHAR buffer[270];
1822  if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1823  {
1824  static const WCHAR bracketW[] = { ']',0 };
1825  static const WCHAR dotW[] = { '.',0 };
1826  if (!(attrib & DDL_DIRECTORY) ||
1827  !strcmpW( entry.cFileName, dotW )) continue;
1828  buffer[0] = '[';
1829  if (!long_names && entry.cAlternateFileName[0])
1830  strcpyW( buffer + 1, entry.cAlternateFileName );
1831  else
1832  strcpyW( buffer + 1, entry.cFileName );
1833  strcatW(buffer, bracketW);
1834  }
1835  else /* not a directory */
1836  {
1837 #define ATTRIBS (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \
1838  FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE)
1839 
1840  if ((attrib & DDL_EXCLUSIVE) &&
1841  ((attrib & ATTRIBS) != (entry.dwFileAttributes & ATTRIBS)))
1842  continue;
1843 #undef ATTRIBS
1844  if (!long_names && entry.cAlternateFileName[0])
1845  strcpyW( buffer, entry.cAlternateFileName );
1846  else
1847  strcpyW( buffer, entry.cFileName );
1848  }
1849  if (!long_names) CharLowerW( buffer );
1851  if ((ret = LISTBOX_InsertString( descr, pos, buffer )) < 0)
1852  break;
1853  if (ret <= maxinsert) maxinsert++; else maxinsert = ret;
1854  } while (FindNextFileW( handle, &entry ));
1855  FindClose( handle );
1856  }
1857  }
1858  if (ret >= 0)
1859  {
1860  ret = maxinsert;
1861 
1862  /* scan drives */
1863  if (attrib & DDL_DRIVES)
1864  {
1865  WCHAR buffer[] = {'[','-','a','-',']',0};
1866  WCHAR root[] = {'A',':','\\',0};
1867  int drive;
1868  for (drive = 0; drive < 26; drive++, buffer[2]++, root[0]++)
1869  {
1870  if (GetDriveTypeW(root) <= DRIVE_NO_ROOT_DIR) continue;
1871  if ((ret = LISTBOX_InsertString( descr, -1, buffer )) < 0)
1872  break;
1873  }
1874  }
1875  }
1876  return ret;
1877 }
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:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
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:1611
#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:883
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 684 of file listbox.c.

685 {
686  HDC hdc;
687  RECT rect;
688  HFONT oldFont = 0;
689 
690  /* Do not repaint the item if the item is not visible */
691  if (!IsWindowVisible(descr->self)) return;
692 
693  if (descr->focus_item == -1) return;
694  if (!descr->caret_on || !descr->in_focus) return;
695 
696  if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) != 1) return;
697  if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
698  if (descr->font) oldFont = SelectObject( hdc, descr->font );
699  if (!IsWindowEnabled(descr->self))
701  SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
702  LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, !on );
703  if (oldFont) SelectObject( hdc, oldFont );
704  ReleaseDC( descr->self, hdc );
705 }
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:1497
#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:515
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:410

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

◆ LISTBOX_FindFileStrPos()

static INT LISTBOX_FindFileStrPos ( LB_DESCR descr,
LPCWSTR  str 
)
static

Definition at line 883 of file listbox.c.

884 {
885  INT min, max, res;
886 
887  if (!HAS_STRINGS(descr))
888  return LISTBOX_FindStringPos( descr, str, FALSE );
889  min = 0;
890  max = descr->nb_items;
891  while (min != max)
892  {
893  INT index = (min + max) / 2;
894  LPCWSTR p = descr->items[index].str;
895  if (*p == '[') /* drive or directory */
896  {
897  if (*str != '[') res = -1;
898  else if (p[1] == '-') /* drive */
899  {
900  if (str[1] == '-') res = str[2] - p[2];
901  else res = -1;
902  }
903  else /* directory */
904  {
905  if (str[1] == '-') res = 1;
906  else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
907  }
908  }
909  else /* filename */
910  {
911  if (*str == '[') res = 1;
912  else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
913  }
914  if (!res) return index;
915  if (res < 0) max = index;
916  else min = index + 1;
917  }
918  return max;
919 }
#define max(a, b)
Definition: svc.c:63
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
int32_t INT
Definition: typedefs.h:56
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
Definition: listbox.c:822
const WCHAR * str
GLuint index
Definition: glext.h:6031
static INT LISTBOX_FindStringPos(LB_DESCR *descr, LPCWSTR str, BOOL exact)
Definition: listbox.c:840
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 927 of file listbox.c.

928 {
929  INT i;
930  LB_ITEMDATA *item;
931 
932  if (start >= descr->nb_items) start = -1;
933  item = descr->items + start + 1;
934  if (HAS_STRINGS(descr))
935  {
936  if (!str || ! str[0] ) return LB_ERR;
937  if (exact)
938  {
939  for (i = start + 1; i < descr->nb_items; i++, item++)
940  if (!LISTBOX_lstrcmpiW( descr->locale, str, item->str )) return i;
941  for (i = 0, item = descr->items; i <= start; i++, item++)
942  if (!LISTBOX_lstrcmpiW( descr->locale, str, item->str )) return i;
943  }
944  else
945  {
946  /* Special case for drives and directories: ignore prefix */
947 #define CHECK_DRIVE(item) \
948  if ((item)->str[0] == '[') \
949  { \
950  if (!strncmpiW( str, (item)->str+1, len )) return i; \
951  if (((item)->str[1] == '-') && !strncmpiW(str, (item)->str+2, len)) \
952  return i; \
953  }
954 
955  INT len = strlenW(str);
956  for (i = start + 1; i < descr->nb_items; i++, item++)
957  {
958  if (!strncmpiW( str, item->str, len )) return i;
959  CHECK_DRIVE(item);
960  }
961  for (i = 0, item = descr->items; i <= start; i++, item++)
962  {
963  if (!strncmpiW( str, item->str, len )) return i;
964  CHECK_DRIVE(item);
965  }
966 #undef CHECK_DRIVE
967  }
968  }
969  else
970  {
971  if (exact && (descr->style & LBS_SORT))
972  /* If sorted, use a WM_COMPAREITEM binary search */
973  return LISTBOX_FindStringPos( descr, str, TRUE );
974 
975  /* Otherwise use a linear search */
976  for (i = start + 1; i < descr->nb_items; i++, item++)
977  if (item->data == (ULONG_PTR)str) return i;
978  for (i = 0, item = descr->items; i <= start; i++, item++)
979  if (item->data == (ULONG_PTR)str) return i;
980  }
981  return LB_ERR;
982 }
#define TRUE
Definition: types.h:120
#define CHECK_DRIVE(item)
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define LBS_SORT
Definition: pedump.c:679
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
int32_t INT
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:63
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:822
const WCHAR * str
static INT LISTBOX_FindStringPos(LB_DESCR *descr, LPCWSTR str, BOOL exact)
Definition: listbox.c:840
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 840 of file listbox.c.

841 {
842  INT index, min, max, res;
843 
844  if (!(descr->style & LBS_SORT)) return -1; /* Add it at the end */
845  min = 0;
846  max = descr->nb_items;
847  while (min != max)
848  {
849  index = (min + max) / 2;
850  if (HAS_STRINGS(descr))
851  res = LISTBOX_lstrcmpiW( descr->locale, str, descr->items[index].str);
852  else
853  {
854  COMPAREITEMSTRUCT cis;
855  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
856 
857  cis.CtlType = ODT_LISTBOX;
858  cis.CtlID = id;
859  cis.hwndItem = descr->self;
860  /* note that some application (MetaStock) expects the second item
861  * to be in the listbox */
862  cis.itemID1 = -1;
863  cis.itemData1 = (ULONG_PTR)str;
864  cis.itemID2 = index;
865  cis.itemData2 = descr->items[index].data;
866  cis.dwLocaleId = descr->locale;
867  res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis );
868  }
869  if (!res) return index;
870  if (res < 0) max = index;
871  else min = index + 1;
872  }
873  return exact ? -1 : max;
874 }
#define max(a, b)
Definition: svc.c:63
#define LBS_SORT
Definition: pedump.c:679
ULONG_PTR itemData2
Definition: winuser.h:2970
#define GetWindowLongPtrW
Definition: winuser.h:4730
int32_t INT
Definition: typedefs.h:56
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
Definition: listbox.c:822
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
GLuint index
Definition: glext.h:6031
ULONG_PTR itemData1
Definition: winuser.h:2968
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:56
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 468 of file listbox.c.

469 {
470  INT index = descr->top_item;
471 
472  if (!descr->nb_items) return -1; /* No items */
473  if (descr->style & LBS_OWNERDRAWVARIABLE)
474  {
475  INT pos = 0;
476  if (y >= 0)
477  {
478  while (index < descr->nb_items)
479  {
480  if ((pos += descr->items[index].height) > y) break;
481  index++;
482  }
483  }
484  else
485  {
486  while (index > 0)
487  {
488  index--;
489  if ((pos -= descr->items[index].height) <= y) break;
490  }
491  }
492  }
493  else if (descr->style & LBS_MULTICOLUMN)
494  {
495  if (y >= descr->item_height * descr->page_size) return -1;
496  if (y >= 0) index += y / descr->item_height;
497  if (x >= 0) index += (x / descr->column_width) * descr->page_size;
498  else index -= (((x + 1) / descr->column_width) - 1) * descr->page_size;
499  }
500  else
501  {
502  index += (y / descr->item_height);
503  }
504  if (index < 0) return 0;
505  if (index >= descr->nb_items) return -1;
506  return index;
507 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:56
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 1174 of file listbox.c.

1175 {
1176  if (descr->style & LBS_OWNERDRAWVARIABLE && descr->nb_items > 0)
1177  {
1178  if ((index < 0) || (index >= descr->nb_items))
1179  {
1181  return LB_ERR;
1182  }
1183  return descr->items[index].height;
1184  }
1185  else return descr->item_height;
1186 }
#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:417
#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 410 of file listbox.c.

411 {
412  /* Index <= 0 is legal even on empty listboxes */
413  if (index && (index >= descr->nb_items))
414  {
415  memset(rect, 0, sizeof(*rect));
417  return LB_ERR;
418  }
419  SetRect( rect, 0, 0, descr->width, descr->height );
420  if (descr->style & LBS_MULTICOLUMN)
421  {
422  INT col = (index / descr->page_size) -
423  (descr->top_item / descr->page_size);
424  rect->left += col * descr->column_width;
425  rect->right = rect->left + descr->column_width;
426  rect->top += (index % descr->page_size) * descr->item_height;
427  rect->bottom = rect->top + descr->item_height;
428  }
429  else if (descr->style & LBS_OWNERDRAWVARIABLE)
430  {
431  INT i;
432  rect->right += descr->horz_pos;
433  if ((index >= 0) && (index < descr->nb_items))
434  {
435  if (index < descr->top_item)
436  {
437  for (i = descr->top_item-1; i >= index; i--)
438  rect->top -= descr->items[i].height;
439  }
440  else
441  {
442  for (i = descr->top_item; i < index; i++)
443  rect->top += descr->items[i].height;
444  }
445  rect->bottom = rect->top + descr->items[index].height;
446 
447  }
448  }
449  else
450  {
451  rect->top += (index - descr->top_item) * descr->item_height;
452  rect->bottom = rect->top + descr->item_height;
453  rect->right += descr->horz_pos;
454  }
455 
456  TRACE("item %d, rect %s\n", index, wine_dbgstr_rect(rect));
457 
458  return ((rect->left < descr->width) && (rect->right > 0) &&
459  (rect->top < descr->height) && (rect->bottom > 0));
460 }
int32_t INT
Definition: typedefs.h:56
& 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:417
#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:56
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 988 of file listbox.c.

989 {
990  INT i, count;
991  const LB_ITEMDATA *item = descr->items;
992 
993  if (!(descr->style & LBS_MULTIPLESEL) ||
994  (descr->style & LBS_NOSEL))
995  return LB_ERR;
996  for (i = count = 0; i < descr->nb_items; i++, item++)
997  if (item->selected) count++;
998  return count;
999 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:56
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 1005 of file listbox.c.

1006 {
1007  INT i, count;
1008  const LB_ITEMDATA *item = descr->items;
1009 
1010  if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
1011  for (i = count = 0; (i < descr->nb_items) && (count < max); i++, item++)
1012  if (item->selected) array[count++] = i;
1013  return count;
1014 }
#define max(a, b)
Definition: svc.c:63
GLuint GLuint GLsizei count
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:56
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 772 of file listbox.c.

773 {
774  DWORD len;
775 
776  if ((index < 0) || (index >= descr->nb_items))
777  {
779  return LB_ERR;
780  }
781  if (HAS_STRINGS(descr))
782  {
783  if (!buffer)
784  {
785  len = strlenW(descr->items[index].str);
786  if( unicode )
787  return len;
788  return WideCharToMultiByte( CP_ACP, 0, descr->items[index].str, len,
789  NULL, 0, NULL, NULL );
790  }
791 
792  TRACE("index %d (0x%04x) %s\n", index, index, debugstr_w(descr->items[index].str));
793 
794  _SEH2_TRY /* hide a Delphi bug that passes a read-only buffer */
795  {
796  if(unicode)
797  {
798  strcpyW( buffer, descr->items[index].str );
799  len = strlenW(buffer);
800  }
801  else
802  {
803  len = WideCharToMultiByte(CP_ACP, 0, descr->items[index].str, -1,
804  (LPSTR)buffer, 0x7FFFFFFF, NULL, NULL) - 1;
805  }
806  }
808  {
809  ERR( "got an invalid buffer (Delphi bug?)\n" );
811  len = LB_ERR;
812  }
813  _SEH2_END
814  } else {
815  if (buffer)
816  *((LPDWORD)buffer)=*(LPDWORD)(&descr->items[index].data);
817  len = sizeof(DWORD);
818  }
819  return len;
820 }
static DWORD(WINAPI *pGetListBoxInfo)(HWND)
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
GLuint buffer
Definition: glext.h:5915
char * LPSTR
Definition: xmlstorage.h:182
_SEH2_TRY
Definition: create.c:4250
#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:417
#define LPDWORD
Definition: nt_native.h:46
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:109
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
_SEH2_END
Definition: create.c:4424
#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 2455 of file listbox.c.

2456 {
2457  INT caret = -1;
2458  WCHAR str[2];
2459 
2460  str[0] = charW;
2461  str[1] = '\0';
2462 
2463  if (descr->style & LBS_WANTKEYBOARDINPUT)
2464  {
2466  MAKEWPARAM(charW, descr->focus_item),
2467  (LPARAM)descr->self );
2468  if (caret == -2) return 0;
2469  }
2470  if (caret == -1)
2471  caret = LISTBOX_FindString( descr, descr->focus_item, str, FALSE);
2472  if (caret != -1)
2473  {
2474  if ((!IS_MULTISELECT(descr)) && descr->selected_item == -1)
2477  if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2479  }
2480  return 0;
2481 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1432
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3948
#define IS_MULTISELECT(descr)
Definition: listbox.c:98
#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:56
#define WM_CHARTOITEM
Definition: winuser.h:1631
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:1475
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:927

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleHScroll()

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

Definition at line 1927 of file listbox.c.

1928 {
1929  SCROLLINFO info;
1930  INT page;
1931 
1932  if (descr->style & LBS_MULTICOLUMN)
1933  {
1934  switch(scrollReq)
1935  {
1936  case SB_LINELEFT:
1937  LISTBOX_SetTopItem( descr, descr->top_item-descr->page_size,
1938  TRUE );
1939  break;
1940  case SB_LINERIGHT:
1941  LISTBOX_SetTopItem( descr, descr->top_item+descr->page_size,
1942  TRUE );
1943  break;
1944  case SB_PAGELEFT:
1945  page = descr->width / descr->column_width;
1946  if (page < 1) page = 1;
1948  descr->top_item - page * descr->page_size, TRUE );
1949  break;
1950  case SB_PAGERIGHT:
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_THUMBPOSITION:
1957  LISTBOX_SetTopItem( descr, pos*descr->page_size, TRUE );
1958  break;
1959  case SB_THUMBTRACK:
1960  info.cbSize = sizeof(info);
1961  info.fMask = SIF_TRACKPOS;
1962  GetScrollInfo( descr->self, SB_VERT, &info );
1963  LISTBOX_SetTopItem( descr, info.nTrackPos*descr->page_size,
1964  TRUE );
1965  break;
1966  case SB_LEFT:
1967  LISTBOX_SetTopItem( descr, 0, TRUE );
1968  break;
1969  case SB_RIGHT:
1970  LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
1971  break;
1972  }
1973  }
1974  else if (descr->horz_extent)
1975  {
1976  switch(scrollReq)
1977  {
1978  case SB_LINELEFT:
1979  LISTBOX_SetHorizontalPos( descr, descr->horz_pos - 1 );
1980  break;
1981  case SB_LINERIGHT:
1982  LISTBOX_SetHorizontalPos( descr, descr->horz_pos + 1 );
1983  break;
1984  case SB_PAGELEFT:
1986  descr->horz_pos - descr->width );
1987  break;
1988  case SB_PAGERIGHT:
1990  descr->horz_pos + descr->width );
1991  break;
1992  case SB_THUMBPOSITION:
1994  break;
1995  case SB_THUMBTRACK:
1996  info.cbSize = sizeof(info);
1997  info.fMask = SIF_TRACKPOS;
1998  GetScrollInfo( descr->self, SB_HORZ, &info );
1999  LISTBOX_SetHorizontalPos( descr, info.nTrackPos );
2000  break;
2001  case SB_LEFT:
2003  break;
2004  case SB_RIGHT:
2006  descr->horz_extent - descr->width );
2007  break;
2008  }
2009  }
2010  return 0;
2011 }
#define TRUE
Definition: types.h:120
#define SB_RIGHT
Definition: winuser.h:576
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
int32_t INT
Definition: typedefs.h:56
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:1228

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleKeyDown()

static LRESULT LISTBOX_HandleKeyDown ( LB_DESCR descr,
DWORD  key 
)
static

Definition at line 2343 of file listbox.c.

2344 {
2345  INT caret = -1;
2346  BOOL bForceSelection = TRUE; /* select item pointed to by focus_item */
2347  if ((IS_MULTISELECT(descr)) || (descr->selected_item == descr->focus_item))
2348  bForceSelection = FALSE; /* only for single select list */
2349 
2350  if (descr->style & LBS_WANTKEYBOARDINPUT)
2351  {
2353  MAKEWPARAM(LOWORD(key), descr->focus_item),
2354  (LPARAM)descr->self );
2355  if (caret == -2) return 0;
2356  }
2357  if (caret == -1) switch(key)
2358  {
2359  case VK_LEFT:
2360  if (descr->style & LBS_MULTICOLUMN)
2361  {
2362  bForceSelection = FALSE;
2363  if (descr->focus_item >= descr->page_size)
2364  caret = descr->focus_item - descr->page_size;
2365  break;
2366  }
2367  /* fall through */
2368  case VK_UP:
2369  caret = descr->focus_item - 1;
2370  if (caret < 0) caret = 0;
2371  break;
2372  case VK_RIGHT:
2373  if (descr->style & LBS_MULTICOLUMN)
2374  {
2375  bForceSelection = FALSE;
2376  if (descr->focus_item + descr->page_size < descr->nb_items)
2377  caret = descr->focus_item + descr->page_size;
2378  break;
2379  }
2380  /* fall through */
2381  case VK_DOWN:
2382  caret = descr->focus_item + 1;
2383  if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2384  break;
2385 
2386  case VK_PRIOR:
2387  if (descr->style & LBS_MULTICOLUMN)
2388  {
2389  INT page = descr->width / descr->column_width;
2390  if (page < 1) page = 1;
2391  caret = descr->focus_item - (page * descr->page_size) + 1;
2392  }
2393  else caret = descr->focus_item-LISTBOX_GetCurrentPageSize(descr) + 1;
2394  if (caret < 0) caret = 0;
2395  break;
2396  case VK_NEXT:
2397  if (descr->style & LBS_MULTICOLUMN)
2398  {
2399  INT page = descr->width / descr->column_width;
2400  if (page < 1) page = 1;
2401  caret = descr->focus_item + (page * descr->page_size) - 1;
2402  }
2403  else caret = descr->focus_item + LISTBOX_GetCurrentPageSize(descr) - 1;
2404  if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2405  break;
2406  case VK_HOME:
2407  caret = 0;
2408  break;
2409  case VK_END:
2410  caret = descr->nb_items - 1;
2411  break;
2412  case VK_SPACE:
2413  if (descr->style & LBS_EXTENDEDSEL) caret = descr->focus_item;
2414  else if (descr->style & LBS_MULTIPLESEL)
2415  {
2416  LISTBOX_SetSelection( descr, descr->focus_item,
2417  !descr->items[descr->focus_item].selected,
2418  (descr->style & LBS_NOTIFY) != 0 );
2419  }
2420  break;
2421  default:
2422  bForceSelection = FALSE;
2423  }
2424  if (bForceSelection) /* focused item is used instead of key */
2425  caret = descr->focus_item;
2426  if (caret >= 0)
2427  {
2428  if (((descr->style & LBS_EXTENDEDSEL) &&
2429  !(GetKeyState( VK_SHIFT ) & 0x8000)) ||
2431  descr->anchor_item = caret;
2433 
2434  if (descr->style & LBS_MULTIPLESEL)
2435  descr->selected_item = caret;
2436  else
2438  if (descr->style & LBS_NOTIFY)
2439  {
2440  if (descr->lphc && IsWindowVisible( descr->self ))
2441  {
2442  /* make sure that combo parent doesn't hide us */
2443  descr->lphc->wState |= CBF_NOROLLUP;
2444  }
2445  if (descr->nb_items) SEND_NOTIFICATION( descr, LBN_SELCHANGE );
2446  }
2447  }
2448  return 0;
2449 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1432
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3948
#define IS_MULTISELECT(descr)
Definition: listbox.c:98
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
#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:56
#define VK_NEXT
Definition: winuser.h:2196
#define VK_HOME
Definition: winuser.h:2198
#define VK_UP
Definition: winuser.h:2200
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:1475
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:42

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleLButtonDown()

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

Definition at line 2040 of file listbox.c.

2041 {
2043 
2044  TRACE("[%p]: lbuttondown %d,%d item %d, focus item %d\n",
2045  descr->self, x, y, index, descr->focus_item);
2046 
2047  if (!descr->caret_on && (descr->in_focus)) return 0;
2048 
2049  if (!descr->in_focus)
2050  {
2051  if( !descr->lphc ) SetFocus( descr->self );
2052  else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit : descr->lphc->self );
2053  }
2054 
2055  if (index == -1) return 0;
2056 
2057  if (!descr->lphc)
2058  {
2059  if (descr->style & LBS_NOTIFY )
2061  MAKELPARAM( x, y ) );
2062  }
2063 
2064  descr->captured = TRUE;
2065  SetCapture( descr->self );
2066 
2067  if (descr->style & (LBS_EXTENDEDSEL | LBS_MULTIPLESEL))
2068  {
2069  /* we should perhaps make sure that all items are deselected
2070  FIXME: needed for !LBS_EXTENDEDSEL, too ?
2071  if (!(keys & (MK_SHIFT|MK_CONTROL)))
2072  LISTBOX_SetSelection( descr, -1, FALSE, FALSE);
2073  */
2074 
2075  if (!(keys & MK_SHIFT)) descr->anchor_item = index;
2076  if (keys & MK_CONTROL)
2077  {
2080  !descr->items[index].selected,
2081  (descr->style & LBS_NOTIFY) != 0);
2082  }
2083  else
2084  {
2086 
2087  if (descr->style & LBS_EXTENDEDSEL)
2088  {
2090  descr->items[index].selected,
2091  (descr->style & LBS_NOTIFY) != 0 );
2092  }
2093  else
2094  {
2096  !descr->items[index].selected,
2097  (descr->style & LBS_NOTIFY) != 0 );
2098  }
2099  }
2100  }
2101  else
2102  {
2103  descr->anchor_item = index;
2106  TRUE, (descr->style & LBS_NOTIFY) != 0 );
2107  }
2108 
2109  if (!descr->lphc)
2110  { // See rev 40864 use Ptr for 64 bit.
2112  {
2113  POINT pt;
2114 
2115  pt.x = x;
2116  pt.y = y;
2117 
2118  if (DragDetect( descr->self, pt ))
2119  SendMessageW( descr->owner, WM_BEGINDRAG, 0, 0 );
2120  }
2121  }
2122  return 0;
2123 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1432
#define TRUE
Definition: types.h:120
#define MK_SHIFT
Definition: winuser.h:2344
#define WS_EX_DRAGDETECT
Definition: undocuser.h:21
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
#define pt(x, y)
Definition: drawing.c:79
#define MAKELPARAM(l, h)
Definition: winuser.h:3947
#define WM_LBTRACKPOINT
Definition: msg.c:64
#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:4730
int32_t INT
Definition: typedefs.h:56
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1367
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:468
#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:1475
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 2145 of file listbox.c.

2146 {
2147  RECT clientRect, screenRect;
2148  POINT mousePos;
2149 
2150  mousePos.x = x;
2151  mousePos.y = y;
2152 
2153  GetClientRect(descr->self, &clientRect);
2154 
2155  if(PtInRect(&clientRect, mousePos))
2156  {
2157  /* MousePos is in client, resume normal processing */
2158  if (msg == WM_LBUTTONDOWN)
2159  {
2160  descr->lphc->droppedIndex = descr->nb_items ? descr->selected_item : -1;
2161  return LISTBOX_HandleLButtonDown( descr, keys, x, y);
2162  }
2163  else if (descr->style & LBS_NOTIFY)
2165  }
2166  else
2167  {
2168  POINT screenMousePos;
2169  HWND hWndOldCapture;
2170 
2171  /* Check the Non-Client Area */
2172  screenMousePos = mousePos;
2173  hWndOldCapture = GetCapture();
2174  ReleaseCapture();
2175  GetWindowRect(descr->self, &screenRect);
2176  ClientToScreen(descr->self, &screenMousePos);
2177 
2178  if(!PtInRect(&screenRect, screenMousePos))
2179  {
2180  LISTBOX_SetCaretIndex( descr, descr->lphc->droppedIndex, FALSE );
2181  LISTBOX_SetSelection( descr, descr->lphc->droppedIndex, FALSE, FALSE );
2182  COMBO_FlipListbox( descr->lphc, FALSE, FALSE );
2183  }
2184  else
2185  {
2186  /* Check to see the NC is a scrollbar */
2187  INT nHitTestType=0;
2189  /* Check Vertical scroll bar */
2190  if (style & WS_VSCROLL)
2191  {
2192  clientRect.right += GetSystemMetrics(SM_CXVSCROLL);
2193  if (PtInRect( &clientRect, mousePos ))
2194  nHitTestType = HTVSCROLL;
2195  }
2196  /* Check horizontal scroll bar */
2197  if (style & WS_HSCROLL)
2198  {
2199  clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL);
2200  if (PtInRect( &clientRect, mousePos ))
2201  nHitTestType = HTHSCROLL;
2202  }
2203  /* Windows sends this message when a scrollbar is clicked
2204  */
2205 
2206  if(nHitTestType != 0)
2207  {
2208  SendMessageW(descr->self, WM_NCLBUTTONDOWN, nHitTestType,
2209  MAKELONG(screenMousePos.x, screenMousePos.y));
2210  }
2211  /* Resume the Capture after scrolling is complete
2212  */
2213  if(hWndOldCapture != 0)
2214  SetCapture(hWndOldCapture);
2215  }
2216  }
2217  return 0;
2218 }
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1674
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1432
#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:4730
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1367
long LONG
Definition: pedump.c:60
HWND WINAPI GetCapture(void)
Definition: message.c:2879
#define MAKELONG(a, b)
Definition: typedefs.h:248
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:2040
#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:2888
LONG bottom
Definition: windef.h:294
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 2223 of file listbox.c.

2224 {
2226  KillSystemTimer( descr->self, LB_TIMER_ID );
2228  if (descr->captured)
2229  {
2230  descr->captured = FALSE;
2231  if (GetCapture() == descr->self) ReleaseCapture();
2232  if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2234  }
2235  return 0;
2236 }
static TIMER_DIRECTION LISTBOX_Timer
Definition: listbox.c:118
#define LBN_SELCHANGE
Definition: winuser.h:2057
HWND WINAPI GetCapture(void)
Definition: message.c:2879
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:2888

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleMouseMove()

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

Definition at line 2295 of file listbox.c.

2297 {
2298  INT index;
2300 
2301  if (!descr->captured) return;
2302 
2303  if (descr->style & LBS_MULTICOLUMN)
2304  {
2305  if (y < 0) y = 0;
2306  else if (y >= descr->item_height * descr->page_size)
2307  y = descr->item_height * descr->page_size - 1;
2308 
2309  if (x < 0)
2310  {
2311  dir = LB_TIMER_LEFT;
2312  x = 0;
2313  }
2314  else if (x >= descr->width)
2315  {
2316  dir = LB_TIMER_RIGHT;
2317  x = descr->width - 1;
2318  }
2319  }
2320  else
2321  {
2322  if (y < 0) dir = LB_TIMER_UP; /* above */
2323  else if (y >= descr->height) dir = LB_TIMER_DOWN; /* below */
2324  }
2325 
2327  if (index == -1) index = descr->focus_item;
2329 
2330  /* Start/stop the system timer */
2331 
2332  if (dir != LB_TIMER_NONE)
2334  else if (LISTBOX_Timer != LB_TIMER_NONE)
2335  KillSystemTimer( descr->self, LB_TIMER_ID );
2336  LISTBOX_Timer = dir;
2337 }
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:56
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:468
#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:2245

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleMouseWheel()

static LRESULT LISTBOX_HandleMouseWheel ( LB_DESCR descr,
SHORT  delta 
)
static

Definition at line 2013 of file listbox.c.

2014 {
2015  UINT pulScrollLines = 3;
2016 
2017  SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
2018 
2019  /* if scrolling changes direction, ignore left overs */
2020  if ((delta < 0 && descr->wheel_remain < 0) ||
2021  (delta > 0 && descr->wheel_remain > 0))
2022  descr->wheel_remain += delta;
2023  else
2024  descr->wheel_remain = delta;
2025 
2026  if (descr->wheel_remain && pulScrollLines)
2027  {
2028  int cLineScroll;
2029  pulScrollLines = min((UINT) descr->page_size, pulScrollLines);
2030  cLineScroll = pulScrollLines * (float)descr->wheel_remain / WHEEL_DELTA;
2031  descr->wheel_remain -= WHEEL_DELTA * cLineScroll / (int)pulScrollLines;
2032  LISTBOX_SetTopItem( descr, descr->top_item - cLineScroll, TRUE );
2033  }
2034  return 0;
2035 }
#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
#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 2279 of file listbox.c.

2280 {
2281  if (!LISTBOX_HandleTimer( descr, descr->focus_item, LISTBOX_Timer ))
2282  {
2283  KillSystemTimer( descr->self, LB_TIMER_ID );
2285  }
2286  return 0;
2287 }
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:2245

Referenced by ListBoxWndProc_common().

◆ LISTBOX_HandleTimer()

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

Definition at line 2245 of file listbox.c.

2246 {
2247  switch(dir)
2248  {
2249  case LB_TIMER_UP:
2250  if (descr->top_item) index = descr->top_item - 1;
2251  else index = 0;
2252  break;
2253  case LB_TIMER_LEFT:
2254  if (descr->top_item) index -= descr->page_size;
2255  break;
2256  case LB_TIMER_DOWN:
2257  index = descr->top_item + LISTBOX_GetCurrentPageSize( descr );
2258  if (index == descr->focus_item) index++;
2259  if (index >= descr->nb_items) index = descr->nb_items - 1;
2260  break;
2261  case LB_TIMER_RIGHT:
2262  if (index + descr->page_size < descr->nb_items)
2263  index += descr->page_size;
2264  break;
2265  case LB_TIMER_NONE:
2266  break;
2267  }
2268  if (index == descr->focus_item) return FALSE;
2270  return TRUE;
2271 }
#define TRUE
Definition: types.h:120
static INT LISTBOX_GetCurrentPageSize(const LB_DESCR *descr)
Definition: listbox.c:159
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:1475

Referenced by LISTBOX_HandleMouseMove(), and LISTBOX_HandleSystemTimer().

◆ LISTBOX_HandleVScroll()

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

Definition at line 1883 of file listbox.c.

1884 {
1885  SCROLLINFO info;
1886 
1887  if (descr->style & LBS_MULTICOLUMN) return 0;
1888  switch(scrollReq)
1889  {
1890  case SB_LINEUP:
1891  LISTBOX_SetTopItem( descr, descr->top_item - 1, TRUE );
1892  break;
1893  case SB_LINEDOWN:
1894  LISTBOX_SetTopItem( descr, descr->top_item + 1, TRUE );
1895  break;
1896  case SB_PAGEUP:
1897  LISTBOX_SetTopItem( descr, descr->top_item -
1899  break;
1900  case SB_PAGEDOWN:
1901  LISTBOX_SetTopItem( descr, descr->top_item +
1903  break;
1904  case SB_THUMBPOSITION:
1906  break;
1907  case SB_THUMBTRACK:
1908  info.cbSize = sizeof(info);
1909  info.fMask = SIF_TRACKPOS;
1910  GetScrollInfo( descr->self, SB_VERT, &info );
1911  LISTBOX_SetTopItem( descr, info.nTrackPos, TRUE );
1912  break;
1913  case SB_TOP:
1914  LISTBOX_SetTopItem( descr, 0, TRUE );
1915  break;
1916  case SB_BOTTOM:
1917  LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
1918  break;
1919  }
1920  return 0;
1921 }
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_PAGEUP
Definition: winuser.h:568
#define TRUE
Definition: types.h:120
#define SB_VERT
Definition: winuser.h:553
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 711 of file listbox.c.

712 {
713  LB_ITEMDATA *item;
714 
715  nb_items += LB_ARRAY_GRANULARITY - 1;
716  nb_items -= (nb_items % LB_ARRAY_GRANULARITY);
717  if (descr->items) {
718  nb_items += HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(*item);
719  item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
720  nb_items * sizeof(LB_ITEMDATA));
721  }
722  else {
723  item = HeapAlloc( GetProcessHeap(), 0,
724  nb_items * sizeof(LB_ITEMDATA));
725  }
726 
727  if (!item)
728  {
730  return LB_ERRSPACE;
731  }
732  descr->items = item;
733  return LB_OKAY;
734 }
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
#define LB_ARRAY_GRANULARITY
Definition: listbox.c:38
#define GetProcessHeap()
Definition: compat.h:403
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:401

Referenced by ListBoxWndProc_common().

◆ LISTBOX_InsertItem()

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

Definition at line 1522 of file listbox.c.

1524 {
1525  LB_ITEMDATA *item;
1526  INT max_items;
1527  INT oldfocus = descr->focus_item;
1528 
1529  if (index == -1) index = descr->nb_items;
1530  else if ((index < 0) || (index > descr->nb_items)) return LB_ERR;
1531  if (!descr->items) max_items = 0;
1532  else max_items = HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(*item);
1533  if (descr->nb_items == max_items)
1534  {
1535  /* We need to grow the array */
1536  max_items += LB_ARRAY_GRANULARITY;
1537  if (descr->items)
1538  item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
1539  max_items * sizeof(LB_ITEMDATA) );
1540  else
1541  item = HeapAlloc( GetProcessHeap(), 0,
1542  max_items * sizeof(LB_ITEMDATA) );
1543  if (!item)
1544  {
1546  return LB_ERRSPACE;
1547  }
1548  descr->items = item;
1549  }
1550 
1551  /* Insert the item structure */
1552 
1553  item = &descr->items[index];
1554  if (index < descr->nb_items)
1555  RtlMoveMemory( item + 1, item,
1556  (descr->nb_items - index) * sizeof(LB_ITEMDATA) );
1557  item->str = str;
1558  item->data = data;
1559  item->height = 0;
1560  item->selected = FALSE;
1561  descr->nb_items++;
1562 
1563  /* Get item height */
1564 
1565  if (descr->style & LBS_OWNERDRAWVARIABLE)
1566  {
1567  MEASUREITEMSTRUCT mis;
1568  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1569 
1570  mis.CtlType = ODT_LISTBOX;
1571  mis.CtlID = id;
1572  mis.itemID = index;
1573  mis.itemData = descr->items[index].data;
1574  mis.itemHeight = descr->item_height;
1575  SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
1576  item->height = mis.itemHeight ? mis.itemHeight : 1;
1577  TRACE("[%p]: measure item %d (%s) = %d\n",
1578  descr->self, index, str ? debugstr_w(str) : "", item->height );
1579  }
1580 
1581  /* Repaint the items */
1582 
1585 
1586  /* Move selection and focused item */
1587  /* If listbox was empty, set focus to the first item */
1588  if (descr->nb_items == 1)
1590  /* single select don't change selection index in win31 */
1591  else if ((ISWIN31) && !(IS_MULTISELECT(descr)))
1592  {
1593  descr->selected_item++;
1594  LISTBOX_SetSelection( descr, descr->selected_item-1, TRUE, FALSE );
1595  }
1596  else
1597  {
1598  if (index <= descr->selected_item)
1599  {
1600  descr->selected_item++;
1601  descr->focus_item = oldfocus; /* focus not changed */
1602  }
1603  }
1604  return LB_OKAY;
1605 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1432
#define TRUE
Definition: types.h:120
#define IS_MULTISELECT(descr)
Definition: listbox.c:98
static void LISTBOX_UpdateScroll(LB_DESCR *descr)
Definition: listbox.c:209
#define GetWindowLongPtrW
Definition: winuser.h:4730
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
int32_t INT
Definition: typedefs.h:56
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1367
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define ISWIN31
Definition: listbox.c:106
#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:403
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:3620
#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:401
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:1139

Referenced by LISTBOX_InsertString().

◆ LISTBOX_InsertString()

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

Definition at line 1611 of file listbox.c.

1612 {
1613  LPWSTR new_str = NULL;
1614  ULONG_PTR data = 0;
1615  LRESULT ret;
1616 
1617  if (HAS_STRINGS(descr))
1618  {
1619  static const WCHAR empty_stringW[] = { 0 };
1620  if (!str) str = empty_stringW;
1621  if (!(new_str = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(WCHAR) )))
1622  {
1624  return LB_ERRSPACE;
1625  }
1626  strcpyW(new_str, str);
1627  }
1628  else data = (ULONG_PTR)str;
1629 
1630  if (index == -1) index = descr->nb_items;
1631  if ((ret = LISTBOX_InsertItem( descr, index, new_str, data )) != 0)
1632  {
1633  HeapFree( GetProcessHeap(), 0, new_str );
1634  return ret;
1635  }
1636 
1637  TRACE("[%p]: added item %d %s\n",
1638  descr->self, index, HAS_STRINGS(descr) ? debugstr_w(new_str) : "" );
1639  return index;
1640 }
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:1522
uint32_t ULONG_PTR
Definition: typedefs.h:63
#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:403
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:402

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

◆ LISTBOX_InvalidateItemRect()

static void LISTBOX_InvalidateItemRect ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1163 of file listbox.c.

1164 {
1165  RECT rect;
1166 
1167  if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1168  InvalidateRect( descr->self, &rect, TRUE );
1169 }
#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:410

Referenced by LISTBOX_SelectItemRange().

◆ LISTBOX_InvalidateItems()

static void LISTBOX_InvalidateItems ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1139 of file listbox.c.

1140 {
1141  RECT rect;
1142 
1143  if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1144  {
1145  if (descr->style & LBS_NOREDRAW)
1146  {
1147  descr->style |= LBS_DISPLAYCHANGED;
1148  return;
1149  }
1150  rect.bottom = descr->height;
1151  InvalidateRect( descr->self, &rect, TRUE );
1152  if (descr->style & LBS_MULTICOLUMN)
1153  {
1154  /* Repaint the other columns */
1155  rect.left = rect.right;
1156  rect.right = descr->width;
1157  rect.top = 0;
1158  InvalidateRect( descr->self, &rect, TRUE );
1159  }
1160  }
1161 }
#define TRUE
Definition: types.h:120
#define LBS_DISPLAYCHANGED
Definition: listbox.c:47
& 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:410

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 822 of file listbox.c.

823 {
824  INT ret = CompareStringW( lcid, NORM_IGNORECASE, str1, -1, str2, -1 );
825  if (ret == CSTR_LESS_THAN)
826  return -1;
827  if (ret == CSTR_EQUAL)
828  return 0;
829  if (ret == CSTR_GREATER_THAN)
830  return 1;
831  return -1;
832 }
#define CSTR_GREATER_THAN
Definition: winnls.h:454
#define NORM_IGNORECASE
Definition: winnls.h:173
int32_t INT
Definition: typedefs.h:56
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 1328 of file listbox.c.

1329 {
1330  INT top;
1331 
1332  TRACE("current top item %d, index %d, fully %d\n", descr->top_item, index, fully);
1333 
1334  if (index <= descr->top_item) top = index;
1335  else if (descr->style & LBS_MULTICOLUMN)
1336  {
1337  INT cols = descr->width;
1338  if (!fully) cols += descr->column_width - 1;
1339  if (cols >= descr->column_width) cols /= descr->column_width;
1340  else cols = 1;
1341  if (index < descr->top_item + (descr->page_size * cols)) return;
1342  top = index - descr->page_size * (cols - 1);
1343  }
1344  else if (descr->style & LBS_OWNERDRAWVARIABLE)
1345  {
1346  INT height = fully ? descr->items[index].height : 1;
1347  for (top = index; top > descr->top_item; top--)
1348  if ((height += descr->items[top-1].height) > descr->height) break;
1349  }
1350  else
1351  {
1352  if (index < descr->top_item + descr->page_size) return;
1353  if (!fully && (index == descr->top_item + descr->page_size) &&
1354  (descr->height > (descr->page_size * descr->item_height))) return;
1355  top = index - descr->page_size + 1;
1356  }
1358 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
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 1475 of file listbox.c.

1476 {
1477  TRACE("old focus %d, index %d\n", descr->focus_item, index);
1478 
1479  if ((index < 0) || (index >= descr->nb_items))
1480  return;
1481 
1482  /* Important, repaint needs to be done in this order if
1483  you want to mimic Windows behavior:
1484  1. Remove the focus and paint the item
1485  2. Remove the selection and paint the item(s)
1486  3. Set the selection and repaint the item(s)
1487  4. Set the focus to 'index' and repaint the item */
1488 
1489  /* 1. remove the focus and repaint the item */
1491 
1492  /* 2. then turn off the previous selection */
1493  /* 3. repaint the new selected item */
1494  if (descr->style & LBS_EXTENDEDSEL)
1495  {
1496  if (descr->anchor_item != -1)
1497  {
1498  INT first = min( index, descr->anchor_item );
1499  INT last = max( index, descr->anchor_item );
1500  if (first > 0)
1502  LISTBOX_SelectItemRange( descr, last + 1, -1, FALSE );
1504  }
1505  }
1506  else if (!(descr->style & LBS_MULTIPLESEL))
1507  {
1508  /* Set selection to new caret item */
1510  }
1511 
1512  /* 4. repaint the new item with the focus */
1513  descr->focus_item = index;
1514  LISTBOX_MakeItemVisible( descr, index, fully_visible );
1516 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1432
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
POINT last
Definition: font.c:46
const GLint * first
Definition: glext.h:5794
int32_t INT
Definition: typedefs.h:56
static void LISTBOX_MakeItemVisible(LB_DESCR *descr, INT index, BOOL fully)
Definition: listbox.c:1328
static void LISTBOX_DrawFocusRect(LB_DESCR *descr, BOOL on)
Definition: listbox.c:684
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:1392
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 1020 of file listbox.c.

1021 {
1022  INT i, col_pos = descr->page_size - 1;
1023  RECT rect;
1024  RECT focusRect = {-1, -1, -1, -1};
1025  HFONT oldFont = 0;
1026  HBRUSH hbrush, oldBrush = 0;
1027 
1028  if (descr->style & LBS_NOREDRAW) return 0;
1029 
1030  SetRect( &rect, 0, 0, descr->width, descr->height );
1031  if (descr->style & LBS_MULTICOLUMN)
1032  rect.right = rect.left + descr->column_width;
1033  else if (descr->horz_pos)
1034  {
1035  SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
1036  rect.right += descr->horz_pos;
1037  }
1038 
1039  if (descr->font) oldFont = SelectObject( hdc, descr->font );
1040 #ifdef __REACTOS__
1042 #else
1043  hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
1044  (WPARAM)hdc, (LPARAM)descr->self );
1045 #endif
1046  if (hbrush) oldBrush = SelectObject( hdc, hbrush );
1048 
1049  if (!descr->nb_items && (descr->focus_item != -1) && descr->caret_on &&
1050  (descr->in_focus))
1051  {
1052  /* Special case for empty listbox: paint focus rect */
1053  rect.bottom = rect.top + descr->item_height;
1055  &rect, NULL, 0, NULL );
1056  LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, FALSE );
1057  rect.top = rect.bottom;
1058  }
1059 
1060  /* Paint all the item, regarding the selection
1061  Focus state will be painted after */
1062 
1063  for (i = descr->top_item; i < descr->nb_items; i++)
1064  {
1065  if (!(descr->style & LBS_OWNERDRAWVARIABLE))
1066  rect.bottom = rect.top + descr->item_height;
1067  else
1068  rect.bottom = rect.top + descr->items[i].height;
1069 
1070  /* keep the focus rect, to paint the focus item after */
1071  if (i == descr->focus_item)
1072  focusRect = rect;
1073 
1075  rect.top = rect.bottom;
1076 
1077  if ((descr->style & LBS_MULTICOLUMN) && !col_pos)
1078  {
1079  if (!IS_OWNERDRAW(descr))
1080  {
1081  /* Clear the bottom of the column */
1082  if (rect.top < descr->height)
1083  {
1084  rect.bottom = descr->height;
1086  &rect, NULL, 0, NULL );
1087  }
1088  }
1089 
1090  /* Go to the next column */
1091  rect.left += descr->column_width;
1092  rect.right += descr->column_width;
1093  rect.top = 0;
1094  col_pos = descr->page_size - 1;
1095  }
1096  else
1097  {
1098  col_pos--;
1099  if (rect.top >= descr->height) break;
1100  }
1101  }
1102 
1103  /* Paint the focus item now */
1104  if (focusRect.top != focusRect.bottom &&
1105  descr->caret_on && descr->in_focus)
1106  LISTBOX_PaintItem( descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS, FALSE );
1107 
1108  if (!IS_OWNERDRAW(descr))
1109  {
1110  /* Clear the remainder of the client area */
1111  if (rect.top < descr->height)
1112  {
1113  rect.bottom = descr->height;
1115  &rect, NULL, 0, NULL );
1116  }
1117  if (rect.right < descr->width)
1118  {
1119  rect.left = rect.right;
1120  rect.right = descr->width;
1121  rect.top = 0;
1122  rect.bottom = descr->height;
1124  &rect, NULL, 0, NULL );
1125  }
1126  }
1127  if (oldFont) SelectObject( hdc, oldFont );
1128  if (oldBrush) SelectObject( hdc, oldBrush );
1129  return 0;
1130 }
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 TRUE
Definition: types.h:120
static HBRUSH hbrush
#define IS_OWNERDRAW(descr)
Definition: listbox.c:91
LONG top
Definition: windef.h:292
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
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:56
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 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:294
static void LISTBOX_PaintItem(LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus)
Definition: listbox.c:515

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 515 of file listbox.c.

517 {
518  LB_ITEMDATA *item = NULL;
519  if (index < descr->nb_items) item = &descr->items[index];
520 
521  if (IS_OWNERDRAW(descr))
522  {
523  DRAWITEMSTRUCT dis;
524  RECT r;
525  HRGN hrgn;
526 
527  if (!item)
528  {
529  if (action == ODA_FOCUS)
530  { // REACTOS
531  if (!(descr->UIState & UISF_HIDEFOCUS))
532  DrawFocusRect( hdc, rect );
533  } //
534  else
535  ERR("called with an out of bounds index %d(%d) in owner draw, Not good.\n",index,descr->nb_items);
536  return;
537  }
538 
539  /* some programs mess with the clipping region when
540  drawing the item, *and* restore the previous region
541  after they are done, so a region has better to exist
542  else everything ends clipped */
543  GetClientRect(descr->self, &r);
545 
546  dis.CtlType = ODT_LISTBOX;
547  dis.CtlID = GetWindowLongPtrW( descr->self, GWLP_ID );
548  dis.hwndItem = descr->self;
549  dis.itemAction = action;
550  dis.hDC = hdc;
551  dis.itemID = index;
552  dis.itemState = 0;
553  if (item->selected) dis.itemState |= ODS_SELECTED;
554  if (!ignoreFocus && (descr->focus_item == index) &&
555  (descr->caret_on) &&
556  (descr->in_focus)) dis.itemState |= ODS_FOCUS;
557  if (!IsWindowEnabled(descr->self)) dis.itemState |= ODS_DISABLED;
558  dis.itemData = item->data;
559  dis.rcItem = *rect;
560  TRACE("[%p]: drawitem %d (%s) action=%02x state=%02x rect=%s\n",
561  descr->self, index, debugstr_w(item->str), action,
563  SendMessageW(descr->owner, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
564  SelectClipRgn( hdc, hrgn );
565  if (hrgn) DeleteObject( hrgn );
566  }
567  else
568  {
569  COLORREF oldText = 0, oldBk = 0;
570 
571  if (action == ODA_FOCUS)
572  {
573  if (!(descr->UIState & UISF_HIDEFOCUS)) // REACTOS
574  DrawFocusRect( hdc, rect );
575  return;
576  }
577  if (item && item->selected)
578  {
579  oldBk = SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
581  }
582 
583  TRACE("[%p]: painting %d (%s) action=%02x rect=%s\n",
584  descr->self, index, item ? debugstr_w(item->str) : "", action,
586  if (!item)
587  ExtTextOutW( hdc, rect->left + 1, rect->top,
588  ETO_OPAQUE | ETO_CLIPPED, rect, NULL, 0, NULL );
589  else if (!(descr->style & LBS_USETABSTOPS))
590  ExtTextOutW( hdc, rect->left + 1, rect->top,
591  ETO_OPAQUE | ETO_CLIPPED, rect, item->str,
592  strlenW(item->str), NULL );
593  else
594  {
595  /* Output empty string to paint background in the full width. */
596  ExtTextOutW( hdc, rect->left + 1, rect->top,
597  ETO_OPAQUE | ETO_CLIPPED, rect, NULL, 0, NULL );
598  TabbedTextOutW( hdc, rect->left + 1 , rect->top,
599  item->str, strlenW(item->str),
600  descr->nb_tabs, descr->tabs, 0);
601  }
602  if (item && item->selected)
603  {
604  SetBkColor( hdc, oldBk );
605  SetTextColor( hdc, oldText );
606  }
607  if (!ignoreFocus && (descr->focus_item == index) &&
608  (descr->caret_on) &&
609  (descr->in_focus) &&
610  !(descr->UIState & UISF_HIDEFOCUS)) DrawFocusRect( hdc, rect );
611  }
612 }
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:3067
#define ODS_FOCUS
Definition: winuser.h:2524
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GetWindowLongPtrW
Definition: winuser.h:4730
#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:975
#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:285
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:109
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 1684 of file listbox.c.

1685 {
1686  LB_ITEMDATA *item;
1687  INT max_items;
1688 
1689  if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1690 
1691  /* We need to invalidate the original rect instead of the updated one. */
1693 
1694  descr->nb_items--;
1696 
1697  if (!descr->nb_items) return LB_OKAY;
1698 
1699  /* Remove the item */
1700 
1701  item = &descr->items[index];
1702  if (index < descr->nb_items)
1703  RtlMoveMemory( item, item + 1,
1704  (descr->nb_items - index) * sizeof(LB_ITEMDATA) );
1705  if (descr->anchor_item == descr->nb_items) descr->anchor_item--;
1706 
1707  /* Shrink the item array if possible */
1708 
1709  max_items = HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(LB_ITEMDATA);
1710  if (descr->nb_items < max_items - 2*LB_ARRAY_GRANULARITY)
1711  {
1712  max_items -= LB_ARRAY_GRANULARITY;
1713  item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
1714  max_items * sizeof(LB_ITEMDATA) );
1715  if (item) descr->items = item;
1716  }
1717  /* Repaint the items */
1718 
1720  /* if we removed the scrollbar, reset the top of the list
1721  (correct for owner-drawn ???) */
1722  if (descr->nb_items == descr->page_size)
1723  LISTBOX_SetTopItem( descr, 0, TRUE );
1724 
1725  /* Move selection and focused item */
1726  if (!IS_MULTISELECT(descr))
1727  {
1728  if (index == descr->selected_item)
1729  descr->selected_item = -1;
1730  else if (index < descr->selected_item)
1731  {
1732  descr->selected_item--;
1733  if (ISWIN31) /* win 31 do not change the selected item number */
1734  LISTBOX_SetSelection( descr, descr->selected_item + 1, TRUE, FALSE);
1735  }
1736  }
1737 
1738  if (descr->focus_item >= descr->nb_items)
1739  {
1740  descr->focus_item = descr->nb_items - 1;
1741  if (descr->focus_item < 0) descr->focus_item = 0;
1742  }
1743  return LB_OKAY;
1744 }
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1432
#define TRUE
Definition: types.h:120
#define IS_MULTISELECT(descr)
Definition: listbox.c:98
static void LISTBOX_DeleteItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1648
static void LISTBOX_UpdateScroll(LB_DESCR *descr)
Definition: listbox.c:209
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
int32_t INT
Definition: typedefs.h:56
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define ISWIN31
Definition: listbox.c:106
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:292
#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:403
#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:401
static void LISTBOX_InvalidateItems(LB_DESCR *descr, INT index)
Definition: listbox.c:1139

Referenced by LISTBOX_SetCount(), and ListBoxWndProc_common().

◆ LISTBOX_RepaintItem()

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

Definition at line 647 of file listbox.c.

648 {
649  HDC hdc;
650  RECT rect;
651  HFONT oldFont = 0;
652  HBRUSH hbrush, oldBrush = 0;
653 
654  /* Do not repaint the item if the item is not visible */
655  if (!IsWindowVisible(descr->self)) return;
656  if (descr->style & LBS_NOREDRAW)
657  {
658  descr->style |= LBS_DISPLAYCHANGED;
659  return;
660  }
661  if (LISTBOX_GetItemRect( descr, index, &rect ) != 1) return;
662  if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
663  if (descr->font) oldFont = SelectObject( hdc, descr->font );
664 #ifdef __REACTOS__
666 #else
667  hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
668  (WPARAM)hdc, (LPARAM)descr->self );
669 #endif
670  if (hbrush) oldBrush = SelectObject( hdc, hbrush );
671  if (!IsWindowEnabled(descr->self))
673  SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
675  if (oldFont) SelectObject( hdc, oldFont );
676  if (oldBrush) SelectObject( hdc, oldBrush );
677  ReleaseDC( descr->self, hdc );
678 }
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define TRUE
Definition: types.h:120
static HBRUSH hbrush
#define LBS_DISPLAYCHANGED
Definition: listbox.c:47
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
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:515
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:410

Referenced by LISTBOX_SetSelection(), and ListBoxWndProc_common().

◆ LISTBOX_ResetContent()

static void LISTBOX_ResetContent ( LB_DESCR descr)
static

Definition at line 1750 of file listbox.c.

1751 {
1752  INT i;
1753 
1754  for(i = descr->nb_items - 1; i>=0; i--) LISTBOX_DeleteItem( descr, i);
1755  HeapFree( GetProcessHeap(), 0, descr->items );
1756  descr->nb_items = 0;
1757  descr->top_item = 0;
1758  descr->selected_item = -1;
1759  descr->focus_item = 0;
1760  descr->anchor_item = -1;
1761  descr->items = NULL;
1762 }
static void LISTBOX_DeleteItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1648
int32_t INT
Definition: typedefs.h:56
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:403
const char * descr
Definition: boot.c:45
#define HeapFree(x, y, z)
Definition: compat.h:402

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 1392 of file listbox.c.

1394 {
1395  INT i;
1396 
1397  /* A few sanity checks */
1398 
1399  if (descr->style & LBS_NOSEL) return LB_ERR;
1400  if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
1401 
1402  if (!descr->nb_items) return LB_OKAY;
1403 
1404  if (last == -1 || last >= descr->nb_items) last = descr->nb_items - 1;
1405  if (first < 0) first = 0;
1406  if (last < first) return LB_OKAY;
1407 
1408  if (on) /* Turn selection on */
1409  {
1410  for (i = first; i <= last; i++)
1411  {
1412  if (descr->items[i].selected) continue;
1413  descr->items[i].selected = TRUE;
1415  }
1416  }
1417  else /* Turn selection off */
1418  {
1419  for (i = first; i <= last; i++)
1420  {
1421  if (!descr->items[i].selected) continue;
1422  descr->items[i].selected = FALSE;
1424  }
1425  }
1426  return LB_OKAY;
1427 }
#define TRUE
Definition: types.h:120
POINT last
Definition: font.c:46
const GLint * first
Definition: glext.h:5794
int32_t INT
Definition: typedefs.h:56
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
#define LB_OKAY
Definition: winuser.h:2406
static void LISTBOX_InvalidateItemRect(LB_DESCR *descr, INT index)
Definition: listbox.c:1163
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 1367 of file listbox.c.

1368 {
1369  INT oldfocus = descr->focus_item;
1370 
1371  TRACE("old focus %d, index %d\n", oldfocus, index);
1372 
1373  if (descr->style & LBS_NOSEL) return LB_ERR;
1374  if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1375  if (index == oldfocus) return LB_OKAY;
1376 
1378  descr->focus_item = index;
1379 
1380  LISTBOX_MakeItemVisible( descr, index, fully_visible );
1382 
1383  return LB_OKAY;
1384 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
static void LISTBOX_MakeItemVisible(LB_DESCR *descr, INT index, BOOL fully)
Definition: listbox.c:1328
#define LB_ERR
Definition: winuser.h:2407
static void LISTBOX_DrawFocusRect(LB_DESCR *descr, BOOL on)
Definition: listbox.c:684
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 1282 of file listbox.c.

1283 {
1284  if (width == descr->column_width) return LB_OKAY;
1285  TRACE("[%p]: new column width = %d\n", descr->self, width );
1286  descr->column_width = width;
1288  return LB_OKAY;
1289 }
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:342

Referenced by ListBoxWndProc_common().

◆ LISTBOX_SetCount()

static LRESULT LISTBOX_SetCount ( LB_DESCR descr,
INT  count 
)
static

Definition at line 1768 of file listbox.c.

1769 {
1770  LRESULT ret;
1771 
1772  if (HAS_STRINGS(descr))
1773  {
1775  return LB_ERR;
1776  }
1777 
1778  /* FIXME: this is far from optimal... */
1779  if (count > descr->nb_items)
1780  {
1781  while (count > descr->nb_items)
1782  if ((ret = LISTBOX_InsertString( descr, -1, 0 )) < 0)
1783  return ret;
1784  }
1785  else if (count < descr->nb_items)
1786  {
1787  while (count < descr->nb_items)
1788  if ((ret = LISTBOX_RemoveItem( descr, (descr->nb_items - 1) )) < 0)
1789  return ret;
1790  }
1791 
1792  InvalidateRect( descr->self, NULL, TRUE );
1793  return LB_OKAY;
1794 }
#define TRUE
Definition: types.h:120
#define ERROR_SETCOUNT_ON_BAD_LB
Definition: winerror.h:914
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:1611
#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:417
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:1684

Referenced by ListBoxWndProc_common().

◆ LISTBOX_SetFont()

static INT LISTBOX_SetFont ( LB_DESCR descr,
HFONT  font 
)
static

Definition at line 1297 of file listbox.c.

1298 {
1299  HDC hdc;
1300  HFONT oldFont = 0;
1301  const char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1302  SIZE sz;
1303 
1304  descr->font = font;
1305 
1306  if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE )))
1307  {
1308  ERR("unable to get DC.\n" );
1309  return 16;
1310  }
1311  if (font) oldFont = SelectObject( hdc, font );
1312  GetTextExtentPointA( hdc, alphabet, 52, &sz);
1313  if (oldFont) SelectObject( hdc, oldFont );
1314  ReleaseDC( descr->self, hdc );
1315 
1316  descr->avg_char_width = (sz.cx / 26 + 1) / 2;
1317  if (!IS_OWNERDRAW(descr))
1318  LISTBOX_SetItemHeight( descr, 0, sz.cy, FALSE );
1319  return sz.cy;
1320 }
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:1497
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LONG cx
Definition: windef.h:319
const char * descr
Definition: boot.c:45
HDC hdc
Definition: main.c:9
#define ERR(fmt,...)
Definition: debug.h:109
#define DCX_CACHE
Definition: winuser.h:2096
static LRESULT LISTBOX_SetItemHeight(LB_DESCR *descr, INT index, INT height, BOOL repaint)
Definition: listbox.c:1192
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LONG cy
Definition: windef.h:320

Referenced by LISTBOX_Create(), and ListBoxWndProc_common().

◆ LISTBOX_SetHorizontalExtent()

static LRESULT LISTBOX_SetHorizontalExtent ( LB_DESCR descr,
INT  extent 
)
static

Definition at line 1256 of file listbox.c.

1257 {
1258  if (descr->style & LBS_MULTICOLUMN)
1259  return LB_OKAY;
1260  if (extent == descr->horz_extent) return LB_OKAY;
1261  TRACE("[%p]: new horz extent = %d\n", descr->self, extent );
1262  descr->horz_extent = extent;
1263  if (descr->style & WS_HSCROLL) {
1264  SCROLLINFO info;
1265  info.cbSize = sizeof(info);
1266  info.nMin = 0;
1267  info.nMax = descr->horz_extent ? descr->horz_extent - 1 : 0;
1268  info.fMask = SIF_RANGE;
1269  if (descr->style & LBS_DISABLENOSCROLL)
1270  info.fMask |= SIF_DISABLENOSCROLL;
1271  SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
1272  }
1273  if (descr->horz_pos > extent - descr->width)
1275  return LB_OKAY;
1276 }
#define TRUE
Definition: types.h:120
#define SIF_RANGE
Definition: winuser.h:1221
#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:1228
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 1228 of file listbox.c.

1229 {
1230  INT diff;
1231 
1232  if (pos > descr->horz_extent - descr->width)
1233  pos = descr->horz_extent - descr->width;
1234  if (pos < 0) pos = 0;
1235  if (!(diff = descr->horz_pos - pos)) return;
1236  TRACE("[%p]: new horz pos = %d\n", descr->self, pos );
1237  descr->horz_pos = pos;