ReactOS  0.4.14-dev-599-g2d4d3f5
listbox.c File Reference
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "commctrl.h"
#include "uxtheme.h"
#include "vssym32.h"
#include "wine/unicode.h"
#include "wine/exception.h"
#include "wine/debug.h"
#include "comctl32.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 (listbox2)
 
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_NCPaint (LB_DESCR *descr, HRGN region)
 
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_Create (HWND hwnd, LPHEADCOMBO lphc)
 
static BOOL LISTBOX_Destroy (LB_DESCR *descr)
 
static LRESULT CALLBACK LISTBOX_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
void LISTBOX_Register (void)
 
void COMBOLBOX_Register (void)
 

Variables

static TIMER_DIRECTION LISTBOX_Timer = LB_TIMER_NONE
 

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

◆ IS_OWNERDRAW

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

Definition at line 97 of file listbox.c.

◆ ISWIN31

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

Definition at line 112 of file listbox.c.

◆ LB_ARRAY_GRANULARITY

#define LB_ARRAY_GRANULARITY   16

Definition at line 45 of file listbox.c.

◆ LB_SCROLL_TIMEOUT

#define LB_SCROLL_TIMEOUT   50

Definition at line 48 of file listbox.c.

◆ LB_TIMER_ID

#define LB_TIMER_ID   2

Definition at line 51 of file listbox.c.

◆ LBS_DISPLAYCHANGED

#define LBS_DISPLAYCHANGED   0x80000000

Definition at line 54 of file listbox.c.

◆ SEND_NOTIFICATION

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

Definition at line 108 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 115 of file listbox.c.

Function Documentation

◆ COMBOLBOX_Register()

void COMBOLBOX_Register ( void  )

Definition at line 3069 of file listbox.c.

3070 {
3071  static const WCHAR combolboxW[] = {'C','o','m','b','o','L','B','o','x',0};
3072  WNDCLASSW wndClass;
3073 
3074  memset(&wndClass, 0, sizeof(wndClass));
3076  wndClass.lpfnWndProc = LISTBOX_WindowProc;
3077  wndClass.cbClsExtra = 0;
3078  wndClass.cbWndExtra = sizeof(LB_DESCR *);
3079  wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
3080  wndClass.hbrBackground = NULL;
3081  wndClass.lpszClassName = combolboxW;
3082  RegisterClassW(&wndClass);
3083 }
static const WCHAR combolboxW[]
Definition: listbox.c:141
UINT style
Definition: winuser.h:3151
#define CS_DROPSHADOW
Definition: winuser.h:655
static LRESULT CALLBACK LISTBOX_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: listbox.c:2570
int cbClsExtra
Definition: winuser.h:3153
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
WNDPROC lpfnWndProc
Definition: winuser.h:3152
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszClassName
Definition: winuser.h:3160
int cbWndExtra
Definition: winuser.h:3154
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CS_GLOBALCLASS
Definition: winuser.h:647
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define CS_SAVEBITS
Definition: winuser.h:652
#define CS_DBLCLKS
Definition: winuser.h:646
HCURSOR hCursor
Definition: winuser.h:3157
HBRUSH hbrBackground
Definition: winuser.h:3158
#define IDC_ARROW
Definition: winuser.h:682
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39

Referenced by DllMain().

◆ LISTBOX_Create()

static BOOL LISTBOX_Create ( HWND  hwnd,
LPHEADCOMBO  lphc 
)
static

Definition at line 2473 of file listbox.c.

2474 {
2475  LB_DESCR *descr;
2476  MEASUREITEMSTRUCT mis;
2477  RECT rect;
2478 
2479  if (!(descr = HeapAlloc( GetProcessHeap(), 0, sizeof(*descr) )))
2480  return FALSE;
2481 
2482  GetClientRect( hwnd, &rect );
2483  descr->self = hwnd;
2484  descr->owner = GetParent( descr->self );
2485  descr->style = GetWindowLongW( descr->self, GWL_STYLE );
2486  descr->width = rect.right - rect.left;
2487  descr->height = rect.bottom - rect.top;
2488  descr->items = NULL;
2489  descr->nb_items = 0;
2490  descr->top_item = 0;
2491  descr->selected_item = -1;
2492  descr->focus_item = 0;
2493  descr->anchor_item = -1;
2494  descr->item_height = 1;
2495  descr->page_size = 1;
2496  descr->column_width = 150;
2497  descr->horz_extent = 0;
2498  descr->horz_pos = 0;
2499  descr->nb_tabs = 0;
2500  descr->tabs = NULL;
2501  descr->wheel_remain = 0;
2502  descr->caret_on = !lphc;
2503  if (descr->style & LBS_NOSEL) descr->caret_on = FALSE;
2504  descr->in_focus = FALSE;
2505  descr->captured = FALSE;
2506  descr->font = 0;
2507  descr->locale = GetUserDefaultLCID();
2508  descr->lphc = lphc;
2509 
2510  if( lphc )
2511  {
2512  TRACE("[%p]: resetting owner %p -> %p\n", descr->self, descr->owner, lphc->self );
2513  descr->owner = lphc->self;
2514  }
2515 
2516  SetWindowLongPtrW( descr->self, 0, (LONG_PTR)descr );
2517 
2518 /* if (wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) descr->style &= ~LBS_NOTIFY;
2519  */
2520  if (descr->style & LBS_EXTENDEDSEL) descr->style |= LBS_MULTIPLESEL;
2521  if (descr->style & LBS_MULTICOLUMN) descr->style &= ~LBS_OWNERDRAWVARIABLE;
2522  if (descr->style & LBS_OWNERDRAWVARIABLE) descr->style |= LBS_NOINTEGRALHEIGHT;
2523  descr->item_height = LISTBOX_SetFont( descr, 0 );
2524 
2525  if (descr->style & LBS_OWNERDRAWFIXED)
2526  {
2527  if( descr->lphc && (descr->lphc->dwStyle & CBS_DROPDOWN))
2528  {
2529  /* WinWord gets VERY unhappy if we send WM_MEASUREITEM from here */
2530  descr->item_height = lphc->fixedOwnerDrawHeight;
2531  }
2532  else
2533  {
2534  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
2535  mis.CtlType = ODT_LISTBOX;
2536  mis.CtlID = id;
2537  mis.itemID = -1;
2538  mis.itemWidth = 0;
2539  mis.itemData = 0;
2540  mis.itemHeight = descr->item_height;
2541  SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
2542  descr->item_height = mis.itemHeight ? mis.itemHeight : 1;
2543  }
2544  }
2545 
2546  OpenThemeData( descr->self, WC_LISTBOXW );
2547 
2548  TRACE("owner: %p, style: %08x, width: %d, height: %d\n", descr->owner, descr->style, descr->width, descr->height);
2549  return TRUE;
2550 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:768
#define GetWindowLongPtrW
Definition: winuser.h:4804
& rect
Definition: startmenu.cpp:1413
#define LBS_OWNERDRAWFIXED
Definition: pedump.c:682
INT fixedOwnerDrawHeight
Definition: comctl32.h:148
#define LBS_NOINTEGRALHEIGHT
Definition: pedump.c:686
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
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 WC_LISTBOXW
Definition: commctrl.h:4707
static INT LISTBOX_SetFont(LB_DESCR *descr, HFONT font)
Definition: listbox.c:1285
#define WM_MEASUREITEM
Definition: winuser.h:1628
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
ULONG_PTR itemData
Definition: winuser.h:3621
#define GWL_STYLE
Definition: winuser.h:846
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
HWND self
Definition: comctl32.h:137
#define CBS_DROPDOWN
Definition: winuser.h:283
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
#define ODT_LISTBOX
Definition: winuser.h:2513
#define LBS_MULTICOLUMN
Definition: pedump.c:687
GLenum GLuint id
Definition: glext.h:5579
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define LBS_NOSEL
Definition: winuser.h:316
#define GWLP_ID
Definition: winuser.h:854
#define LBS_MULTIPLESEL
Definition: pedump.c:681

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_DeleteItem()

static void LISTBOX_DeleteItem ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1634 of file listbox.c.

1635 {
1636  /* save the item data before it gets freed by LB_RESETCONTENT */
1637  ULONG_PTR item_data = descr->items[index].data;
1638  LPWSTR item_str = descr->items[index].str;
1639 
1640  if (!descr->nb_items)
1641  SendMessageW( descr->self, LB_RESETCONTENT, 0, 0 );
1642 
1643  /* Note: Win 3.1 only sends DELETEITEM on owner-draw items,
1644  * while Win95 sends it for all items with user data.
1645  * It's probably better to send it too often than not
1646  * often enough, so this is what we do here.
1647  */
1648  if (IS_OWNERDRAW(descr) || item_data)
1649  {
1650  DELETEITEMSTRUCT dis;
1651  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1652 
1653  dis.CtlType = ODT_LISTBOX;
1654  dis.CtlID = id;
1655  dis.itemID = index;
1656  dis.hwndItem = descr->self;
1657  dis.itemData = item_data;
1658  SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis );
1659  }
1660  if (HAS_STRINGS(descr))
1661  HeapFree( GetProcessHeap(), 0, item_str );
1662 }
#define GetWindowLongPtrW
Definition: winuser.h:4804
ULONG_PTR itemData
Definition: winuser.h:3019
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
#define IS_OWNERDRAW(descr)
Definition: listbox.c:97
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:100
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 2556 of file listbox.c.

2557 {
2558  HTHEME theme = GetWindowTheme( descr->self );
2559  CloseThemeData( theme );
2561  SetWindowLongPtrW( descr->self, 0, 0 );
2562  HeapFree( GetProcessHeap(), 0, descr );
2563  return TRUE;
2564 }
#define TRUE
Definition: types.h:120
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define GetProcessHeap()
Definition: compat.h:403
const char * descr
Definition: boot.c:45
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
static void LISTBOX_ResetContent(LB_DESCR *descr)
Definition: listbox.c:1736
#define SetWindowLongPtrW
Definition: winuser.h:5321
#define HeapFree(x, y, z)
Definition: compat.h:402
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_Directory()

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

Definition at line 1786 of file listbox.c.

1788 {
1789  HANDLE handle;
1790  LRESULT ret = LB_OKAY;
1792  int pos;
1793  LRESULT maxinsert = LB_ERR;
1794 
1795  /* don't scan directory if we just want drives exclusively */
1796  if (attrib != (DDL_DRIVES | DDL_EXCLUSIVE)) {
1797  /* scan directory */
1798  if ((handle = FindFirstFileW(filespec, &entry)) == INVALID_HANDLE_VALUE)
1799  {
1800  int le = GetLastError();
1801  if ((le != ERROR_NO_MORE_FILES) && (le != ERROR_FILE_NOT_FOUND)) return LB_ERR;
1802  }
1803  else
1804  {
1805  do
1806  {
1807  WCHAR buffer[270];
1808  if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1809  {
1810  static const WCHAR bracketW[] = { ']',0 };
1811  static const WCHAR dotW[] = { '.',0 };
1812  if (!(attrib & DDL_DIRECTORY) ||
1813  !strcmpW( entry.cFileName, dotW )) continue;
1814  buffer[0] = '[';
1815  if (!long_names && entry.cAlternateFileName[0])
1816  strcpyW( buffer + 1, entry.cAlternateFileName );
1817  else
1818  strcpyW( buffer + 1, entry.cFileName );
1819  strcatW(buffer, bracketW);
1820  }
1821  else /* not a directory */
1822  {
1823 #define ATTRIBS (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \
1824  FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE)
1825 
1826  if ((attrib & DDL_EXCLUSIVE) &&
1827  ((attrib & ATTRIBS) != (entry.dwFileAttributes & ATTRIBS)))
1828  continue;
1829 #undef ATTRIBS
1830  if (!long_names && entry.cAlternateFileName[0])
1831  strcpyW( buffer, entry.cAlternateFileName );
1832  else
1833  strcpyW( buffer, entry.cFileName );
1834  }
1835  if (!long_names) CharLowerW( buffer );
1837  if ((ret = LISTBOX_InsertString( descr, pos, buffer )) < 0)
1838  break;
1839  if (ret <= maxinsert) maxinsert++; else maxinsert = ret;
1840  } while (FindNextFileW( handle, &entry ));
1841  FindClose( handle );
1842  }
1843  }
1844  if (ret >= 0)
1845  {
1846  ret = maxinsert;
1847 
1848  /* scan drives */
1849  if (attrib & DDL_DRIVES)
1850  {
1851  WCHAR buffer[] = {'[','-','a','-',']',0};
1852  WCHAR root[] = {'A',':','\\',0};
1853  int drive;
1854  for (drive = 0; drive < 26; drive++, buffer[2]++, root[0]++)
1855  {
1856  if (GetDriveTypeW(root) <= DRIVE_NO_ROOT_DIR) continue;
1857  if ((ret = LISTBOX_InsertString( descr, -1, buffer )) < 0)
1858  break;
1859  }
1860  }
1861  }
1862  return ret;
1863 }
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
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
#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
static LRESULT LISTBOX_InsertString(LB_DESCR *descr, INT index, LPCWSTR str)
Definition: listbox.c:1599
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:833
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
#define ATTRIBS
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 LISTBOX_WindowProc().

◆ LISTBOX_DrawFocusRect()

static void LISTBOX_DrawFocusRect ( LB_DESCR descr,
BOOL  on 
)
static

Definition at line 646 of file listbox.c.

647 {
648  HDC hdc;
649  RECT rect;
650  HFONT oldFont = 0;
651 
652  /* Do not repaint the item if the item is not visible */
653  if (!IsWindowVisible(descr->self)) return;
654 
655  if (descr->focus_item == -1) return;
656  if (!descr->caret_on || !descr->in_focus) return;
657 
658  if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) != 1) return;
659  if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
660  if (descr->font) oldFont = SelectObject( hdc, descr->font );
661  if (!IsWindowEnabled(descr->self))
663  SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
664  LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, !on );
665  if (oldFont) SelectObject( hdc, oldFont );
666  ReleaseDC( descr->self, hdc );
667 }
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:381
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)
static void LISTBOX_PaintItem(LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus)
Definition: listbox.c:486
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)

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

◆ LISTBOX_FindFileStrPos()

static INT LISTBOX_FindFileStrPos ( LB_DESCR descr,
LPCWSTR  str 
)
static

Definition at line 833 of file listbox.c.

834 {
835  INT min, max, res;
836 
837  if (!HAS_STRINGS(descr))
838  return LISTBOX_FindStringPos( descr, str, FALSE );
839  min = 0;
840  max = descr->nb_items;
841  while (min != max)
842  {
843  INT index = (min + max) / 2;
844  LPCWSTR p = descr->items[index].str;
845  if (*p == '[') /* drive or directory */
846  {
847  if (*str != '[') res = -1;
848  else if (p[1] == '-') /* drive */
849  {
850  if (str[1] == '-') res = str[2] - p[2];
851  else res = -1;
852  }
853  else /* directory */
854  {
855  if (str[1] == '-') res = 1;
856  else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
857  }
858  }
859  else /* filename */
860  {
861  if (*str == '[') res = 1;
862  else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
863  }
864  if (!res) return index;
865  if (res < 0) max = index;
866  else min = index + 1;
867  }
868  return max;
869 }
#define max(a, b)
Definition: svc.c:63
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
Definition: listbox.c:772
int32_t INT
Definition: typedefs.h:56
const WCHAR * str
GLuint index
Definition: glext.h:6031
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
static INT LISTBOX_FindStringPos(LB_DESCR *descr, LPCWSTR str, BOOL exact)
Definition: listbox.c:790
#define min(a, b)
Definition: monoChain.cc:55
GLuint res
Definition: glext.h:9613
#define HAS_STRINGS(descr)
Definition: listbox.c:100
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by LISTBOX_Directory(), and LISTBOX_WindowProc().

◆ LISTBOX_FindString()

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

Definition at line 877 of file listbox.c.

878 {
879  INT i;
880  LB_ITEMDATA *item;
881 
882  if (start >= descr->nb_items) start = -1;
883  item = descr->items + start + 1;
884  if (HAS_STRINGS(descr))
885  {
886  if (!str || ! str[0] ) return LB_ERR;
887  if (exact)
888  {
889  for (i = start + 1; i < descr->nb_items; i++, item++)
890  if (!LISTBOX_lstrcmpiW( descr->locale, str, item->str )) return i;
891  for (i = 0, item = descr->items; i <= start; i++, item++)
892  if (!LISTBOX_lstrcmpiW( descr->locale, str, item->str )) return i;
893  }
894  else
895  {
896  /* Special case for drives and directories: ignore prefix */
897 #define CHECK_DRIVE(item) \
898  if ((item)->str[0] == '[') \
899  { \
900  if (!strncmpiW( str, (item)->str+1, len )) return i; \
901  if (((item)->str[1] == '-') && !strncmpiW(str, (item)->str+2, len)) \
902  return i; \
903  }
904 
905  INT len = strlenW(str);
906  for (i = start + 1; i < descr->nb_items; i++, item++)
907  {
908  if (!strncmpiW( str, item->str, len )) return i;
909  CHECK_DRIVE(item);
910  }
911  for (i = 0, item = descr->items; i <= start; i++, item++)
912  {
913  if (!strncmpiW( str, item->str, len )) return i;
914  CHECK_DRIVE(item);
915  }
916 #undef CHECK_DRIVE
917  }
918  }
919  else
920  {
921  if (exact && (descr->style & LBS_SORT))
922  /* If sorted, use a WM_COMPAREITEM binary search */
923  return LISTBOX_FindStringPos( descr, str, TRUE );
924 
925  /* Otherwise use a linear search */
926  for (i = start + 1; i < descr->nb_items; i++, item++)
927  if (item->data == (ULONG_PTR)str) return i;
928  for (i = 0, item = descr->items; i <= start; i++, item++)
929  if (item->data == (ULONG_PTR)str) return i;
930  }
931  return LB_ERR;
932 }
#define CHECK_DRIVE(item)
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define LBS_SORT
Definition: pedump.c:679
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
Definition: listbox.c:772
#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
const WCHAR * str
const char * descr
Definition: boot.c:45
GLenum GLsizei len
Definition: glext.h:6722
static ATOM item
Definition: dde.c:856
static INT LISTBOX_FindStringPos(LB_DESCR *descr, LPCWSTR str, BOOL exact)
Definition: listbox.c:790
GLuint start
Definition: gl.h:1545
#define HAS_STRINGS(descr)
Definition: listbox.c:100

Referenced by LISTBOX_HandleChar(), and LISTBOX_WindowProc().

◆ LISTBOX_FindStringPos()

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

Definition at line 790 of file listbox.c.

791 {
792  INT index, min, max, res;
793 
794  if (!(descr->style & LBS_SORT)) return -1; /* Add it at the end */
795  min = 0;
796  max = descr->nb_items;
797  while (min != max)
798  {
799  index = (min + max) / 2;
800  if (HAS_STRINGS(descr))
801  res = LISTBOX_lstrcmpiW( descr->locale, str, descr->items[index].str);
802  else
803  {
804  COMPAREITEMSTRUCT cis;
805  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
806 
807  cis.CtlType = ODT_LISTBOX;
808  cis.CtlID = id;
809  cis.hwndItem = descr->self;
810  /* note that some application (MetaStock) expects the second item
811  * to be in the listbox */
812  cis.itemID1 = -1;
813  cis.itemData1 = (ULONG_PTR)str;
814  cis.itemID2 = index;
815  cis.itemData2 = descr->items[index].data;
816  cis.dwLocaleId = descr->locale;
817  res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis );
818  }
819  if (!res) return index;
820  if (res < 0) max = index;
821  else min = index + 1;
822  }
823  return exact ? -1 : max;
824 }
#define max(a, b)
Definition: svc.c:63
#define LBS_SORT
Definition: pedump.c:679
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
Definition: listbox.c:772
ULONG_PTR itemData2
Definition: winuser.h:2971
#define GetWindowLongPtrW
Definition: winuser.h:4804
int32_t INT
Definition: typedefs.h:56
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
GLuint index
Definition: glext.h:6031
ULONG_PTR itemData1
Definition: winuser.h:2969
const char * descr
Definition: boot.c:45
#define index(s, c)
Definition: various.h:29
#define WM_COMPAREITEM
Definition: winuser.h:1637
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define ODT_LISTBOX
Definition: winuser.h:2513
GLuint res
Definition: glext.h:9613
GLenum GLuint id
Definition: glext.h:5579
#define ULONG_PTR
Definition: config.h:101
#define HAS_STRINGS(descr)
Definition: listbox.c:100
#define GWLP_ID
Definition: winuser.h:854

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

◆ LISTBOX_GetCurrentPageSize()

static INT LISTBOX_GetCurrentPageSize ( const LB_DESCR descr)
static

Definition at line 133 of file listbox.c.

134 {
135  INT i, height;
136  if (!(descr->style & LBS_OWNERDRAWVARIABLE)) return descr->page_size;
137  for (i = descr->top_item, height = 0; i < descr->nb_items; i++)
138  {
139  if ((height += descr->items[i].height) > descr->height) break;
140  }
141  if (i == descr->top_item) return 1;
142  else return i - descr->top_item;
143 }
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 439 of file listbox.c.

440 {
441  INT index = descr->top_item;
442 
443  if (!descr->nb_items) return -1; /* No items */
444  if (descr->style & LBS_OWNERDRAWVARIABLE)
445  {
446  INT pos = 0;
447  if (y >= 0)
448  {
449  while (index < descr->nb_items)
450  {
451  if ((pos += descr->items[index].height) > y) break;
452  index++;
453  }
454  }
455  else
456  {
457  while (index > 0)
458  {
459  index--;
460  if ((pos -= descr->items[index].height) <= y) break;
461  }
462  }
463  }
464  else if (descr->style & LBS_MULTICOLUMN)
465  {
466  if (y >= descr->item_height * descr->page_size) return -1;
467  if (y >= 0) index += y / descr->item_height;
468  if (x >= 0) index += (x / descr->column_width) * descr->page_size;
469  else index -= (((x + 1) / descr->column_width) - 1) * descr->page_size;
470  }
471  else
472  {
473  index += (y / descr->item_height);
474  }
475  if (index < 0) return 0;
476  if (index >= descr->nb_items) return -1;
477  return index;
478 }
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 LISTBOX_WindowProc().

◆ LISTBOX_GetItemHeight()

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

Definition at line 1162 of file listbox.c.

1163 {
1164  if (descr->style & LBS_OWNERDRAWVARIABLE && descr->nb_items > 0)
1165  {
1166  if ((index < 0) || (index >= descr->nb_items))
1167  {
1169  return LB_ERR;
1170  }
1171  return descr->items[index].height;
1172  }
1173  else return descr->item_height;
1174 }
#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 LISTBOX_WindowProc().

◆ LISTBOX_GetItemRect()

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

Definition at line 381 of file listbox.c.

382 {
383  /* Index <= 0 is legal even on empty listboxes */
384  if (index && (index >= descr->nb_items))
385  {
388  return LB_ERR;
389  }
390  SetRect( rect, 0, 0, descr->width, descr->height );
391  if (descr->style & LBS_MULTICOLUMN)
392  {
393  INT col = (index / descr->page_size) -
394  (descr->top_item / descr->page_size);
395  rect->left += col * descr->column_width;
396  rect->right = rect->left + descr->column_width;
397  rect->top += (index % descr->page_size) * descr->item_height;
398  rect->bottom = rect->top + descr->item_height;
399  }
400  else if (descr->style & LBS_OWNERDRAWVARIABLE)
401  {
402  INT i;
403  rect->right += descr->horz_pos;
404  if ((index >= 0) && (index < descr->nb_items))
405  {
406  if (index < descr->top_item)
407  {
408  for (i = descr->top_item-1; i >= index; i--)
409  rect->top -= descr->items[i].height;
410  }
411  else
412  {
413  for (i = descr->top_item; i < index; i++)
414  rect->top += descr->items[i].height;
415  }
416  rect->bottom = rect->top + descr->items[index].height;
417 
418  }
419  }
420  else
421  {
422  rect->top += (index - descr->top_item) * descr->item_height;
423  rect->bottom = rect->top + descr->item_height;
424  rect->right += descr->horz_pos;
425  }
426 
427  TRACE("item %d, rect %s\n", index, wine_dbgstr_rect(rect));
428 
429  return ((rect->left < descr->width) && (rect->right > 0) &&
430  (rect->top < descr->height) && (rect->bottom > 0));
431 }
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 SetRectEmpty(_Out_ LPRECT)
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

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

◆ LISTBOX_GetMaxTopIndex()

static INT LISTBOX_GetMaxTopIndex ( const LB_DESCR descr)
static

Definition at line 151 of file listbox.c.

152 {
153  INT max, page;
154 
155  if (descr->style & LBS_OWNERDRAWVARIABLE)
156  {
157  page = descr->height;
158  for (max = descr->nb_items - 1; max >= 0; max--)
159  if ((page -= descr->items[max].height) < 0) break;
160  if (max < descr->nb_items - 1) max++;
161  }
162  else if (descr->style & LBS_MULTICOLUMN)
163  {
164  if ((page = descr->width / descr->column_width) < 1) page = 1;
165  max = (descr->nb_items + descr->page_size - 1) / descr->page_size;
166  max = (max - page) * descr->page_size;
167  }
168  else
169  {
170  max = descr->nb_items - descr->page_size;
171  }
172  if (max < 0) max = 0;
173  return max;
174 }
#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 938 of file listbox.c.

939 {
940  INT i, count;
941  const LB_ITEMDATA *item = descr->items;
942 
943  if (!(descr->style & LBS_MULTIPLESEL) ||
944  (descr->style & LBS_NOSEL))
945  return LB_ERR;
946  for (i = count = 0; i < descr->nb_items; i++, item++)
947  if (item->selected) count++;
948  return count;
949 }
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 LISTBOX_WindowProc().

◆ LISTBOX_GetSelItems()

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

Definition at line 955 of file listbox.c.

956 {
957  INT i, count;
958  const LB_ITEMDATA *item = descr->items;
959 
960  if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
961  for (i = count = 0; (i < descr->nb_items) && (count < max); i++, item++)
962  if (item->selected) array[count++] = i;
963  return count;
964 }
#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 LISTBOX_WindowProc().

◆ LISTBOX_GetText()

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

Definition at line 734 of file listbox.c.

735 {
736  DWORD len;
737 
738  if ((index < 0) || (index >= descr->nb_items))
739  {
741  return LB_ERR;
742  }
743 
744  if (HAS_STRINGS(descr))
745  {
746  if (!buffer)
747  return strlenW(descr->items[index].str);
748 
749  TRACE("index %d (0x%04x) %s\n", index, index, debugstr_w(descr->items[index].str));
750 
751  __TRY /* hide a Delphi bug that passes a read-only buffer */
752  {
753  strcpyW( buffer, descr->items[index].str );
754  len = strlenW(buffer);
755  }
757  {
758  WARN( "got an invalid buffer (Delphi bug?)\n" );
760  return LB_ERR;
761  }
762  __ENDTRY
763  } else
764  {
765  if (buffer)
766  *((DWORD *)buffer) = *(DWORD *)&descr->items[index].data;
767  len = sizeof(DWORD);
768  }
769  return len;
770 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WARN(fmt,...)
Definition: debug.h:111
GLuint buffer
Definition: glext.h:5915
#define LB_ERR
Definition: winuser.h:2407
#define debugstr_w
Definition: kernel32.h:32
GLuint index
Definition: glext.h:6031
#define __TRY
Definition: compat.h:70
#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 __ENDTRY
Definition: compat.h:72
GLenum GLsizei len
Definition: glext.h:6722
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define ERROR_INVALID_INDEX
Definition: winerror.h:894
#define HAS_STRINGS(descr)
Definition: listbox.c:100
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:71

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_HandleChar()

static LRESULT LISTBOX_HandleChar ( LB_DESCR descr,
WCHAR  charW 
)
static

Definition at line 2441 of file listbox.c.

2442 {
2443  INT caret = -1;
2444  WCHAR str[2];
2445 
2446  str[0] = charW;
2447  str[1] = '\0';
2448 
2449  if (descr->style & LBS_WANTKEYBOARDINPUT)
2450  {
2451  caret = SendMessageW( descr->owner, WM_CHARTOITEM,
2452  MAKEWPARAM(charW, descr->focus_item),
2453  (LPARAM)descr->self );
2454  if (caret == -2) return 0;
2455  }
2456  if (caret == -1)
2457  caret = LISTBOX_FindString( descr, descr->focus_item, str, FALSE);
2458  if (caret != -1)
2459  {
2460  if ((!IS_MULTISELECT(descr)) && descr->selected_item == -1)
2461  LISTBOX_SetSelection( descr, caret, TRUE, FALSE);
2462  LISTBOX_MoveCaret( descr, caret, TRUE );
2463  if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2465  }
2466  return 0;
2467 }
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
#define IS_MULTISELECT(descr)
Definition: listbox.c:104
#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 SEND_NOTIFICATION(descr, code)
Definition: listbox.c:108
#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
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1420
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1463
#define LBS_NOTIFY
Definition: pedump.c:678
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:877

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_HandleHScroll()

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

Definition at line 1913 of file listbox.c.

1914 {
1915  SCROLLINFO info;
1916  INT page;
1917 
1918  if (descr->style & LBS_MULTICOLUMN)
1919  {
1920  switch(scrollReq)
1921  {
1922  case SB_LINELEFT:
1923  LISTBOX_SetTopItem( descr, descr->top_item-descr->page_size,
1924  TRUE );
1925  break;
1926  case SB_LINERIGHT:
1927  LISTBOX_SetTopItem( descr, descr->top_item+descr->page_size,
1928  TRUE );
1929  break;
1930  case SB_PAGELEFT:
1931  page = descr->width / descr->column_width;
1932  if (page < 1) page = 1;
1934  descr->top_item - page * descr->page_size, TRUE );
1935  break;
1936  case SB_PAGERIGHT:
1937  page = descr->width / descr->column_width;
1938  if (page < 1) page = 1;
1940  descr->top_item + page * descr->page_size, TRUE );
1941  break;
1942  case SB_THUMBPOSITION:
1943  LISTBOX_SetTopItem( descr, pos*descr->page_size, TRUE );
1944  break;
1945  case SB_THUMBTRACK:
1946  info.cbSize = sizeof(info);
1947  info.fMask = SIF_TRACKPOS;
1948  GetScrollInfo( descr->self, SB_VERT, &info );
1949  LISTBOX_SetTopItem( descr, info.nTrackPos*descr->page_size,
1950  TRUE );
1951  break;
1952  case SB_LEFT:
1953  LISTBOX_SetTopItem( descr, 0, TRUE );
1954  break;
1955  case SB_RIGHT:
1956  LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
1957  break;
1958  }
1959  }
1960  else if (descr->horz_extent)
1961  {
1962  switch(scrollReq)
1963  {
1964  case SB_LINELEFT:
1965  LISTBOX_SetHorizontalPos( descr, descr->horz_pos - 1 );
1966  break;
1967  case SB_LINERIGHT:
1968  LISTBOX_SetHorizontalPos( descr, descr->horz_pos + 1 );
1969  break;
1970  case SB_PAGELEFT:
1972  descr->horz_pos - descr->width );
1973  break;
1974  case SB_PAGERIGHT:
1976  descr->horz_pos + descr->width );
1977  break;
1978  case SB_THUMBPOSITION:
1980  break;
1981  case SB_THUMBTRACK:
1982  info.cbSize = sizeof(info);
1983  info.fMask = SIF_TRACKPOS;
1984  GetScrollInfo( descr->self, SB_HORZ, &info );
1985  LISTBOX_SetHorizontalPos( descr, info.nTrackPos );
1986  break;
1987  case SB_LEFT:
1989  break;
1990  case SB_RIGHT:
1992  descr->horz_extent - descr->width );
1993  break;
1994  }
1995  }
1996  return 0;
1997 }
#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
#define SB_THUMBPOSITION
Definition: winuser.h:572
Definition: module.h:566
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:266
#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
static void LISTBOX_SetHorizontalPos(LB_DESCR *descr, INT pos)
Definition: listbox.c:1216
#define LBS_MULTICOLUMN
Definition: pedump.c:687
#define SB_LINELEFT
Definition: winuser.h:566

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_HandleKeyDown()

static LRESULT LISTBOX_HandleKeyDown ( LB_DESCR descr,
DWORD  key 
)
static

Definition at line 2329 of file listbox.c.

2330 {
2331  INT caret = -1;
2332  BOOL bForceSelection = TRUE; /* select item pointed to by focus_item */
2333  if ((IS_MULTISELECT(descr)) || (descr->selected_item == descr->focus_item))
2334  bForceSelection = FALSE; /* only for single select list */
2335 
2336  if (descr->style & LBS_WANTKEYBOARDINPUT)
2337  {
2338  caret = SendMessageW( descr->owner, WM_VKEYTOITEM,
2339  MAKEWPARAM(LOWORD(key), descr->focus_item),
2340  (LPARAM)descr->self );
2341  if (caret == -2) return 0;
2342  }
2343  if (caret == -1) switch(key)
2344  {
2345  case VK_LEFT:
2346  if (descr->style & LBS_MULTICOLUMN)
2347  {
2348  bForceSelection = FALSE;
2349  if (descr->focus_item >= descr->page_size)
2350  caret = descr->focus_item - descr->page_size;
2351  break;
2352  }
2353  /* fall through */
2354  case VK_UP:
2355  caret = descr->focus_item - 1;
2356  if (caret < 0) caret = 0;
2357  break;
2358  case VK_RIGHT:
2359  if (descr->style & LBS_MULTICOLUMN)
2360  {
2361  bForceSelection = FALSE;
2362  if (descr->focus_item + descr->page_size < descr->nb_items)
2363  caret = descr->focus_item + descr->page_size;
2364  break;
2365  }
2366  /* fall through */
2367  case VK_DOWN:
2368  caret = descr->focus_item + 1;
2369  if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2370  break;
2371 
2372  case VK_PRIOR:
2373  if (descr->style & LBS_MULTICOLUMN)
2374  {
2375  INT page = descr->width / descr->column_width;
2376  if (page < 1) page = 1;
2377  caret = descr->focus_item - (page * descr->page_size) + 1;
2378  }
2379  else caret = descr->focus_item-LISTBOX_GetCurrentPageSize(descr) + 1;
2380  if (caret < 0) caret = 0;
2381  break;
2382  case VK_NEXT:
2383  if (descr->style & LBS_MULTICOLUMN)
2384  {
2385  INT page = descr->width / descr->column_width;
2386  if (page < 1) page = 1;
2387  caret = descr->focus_item + (page * descr->page_size) - 1;
2388  }
2389  else caret = descr->focus_item + LISTBOX_GetCurrentPageSize(descr) - 1;
2390  if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2391  break;
2392  case VK_HOME:
2393  caret = 0;
2394  break;
2395  case VK_END:
2396  caret = descr->nb_items - 1;
2397  break;
2398  case VK_SPACE:
2399  if (descr->style & LBS_EXTENDEDSEL) caret = descr->focus_item;
2400  else if (descr->style & LBS_MULTIPLESEL)
2401  {
2402  LISTBOX_SetSelection( descr, descr->focus_item,
2403  !descr->items[descr->focus_item].selected,
2404  (descr->style & LBS_NOTIFY) != 0 );
2405  }
2406  break;
2407  default:
2408  bForceSelection = FALSE;
2409  }
2410  if (bForceSelection) /* focused item is used instead of key */
2411  caret = descr->focus_item;
2412  if (caret >= 0)
2413  {
2414  if (((descr->style & LBS_EXTENDEDSEL) &&
2415  !(GetKeyState( VK_SHIFT ) & 0x8000)) ||
2417  descr->anchor_item = caret;
2418  LISTBOX_MoveCaret( descr, caret, TRUE );
2419 
2420  if (descr->style & LBS_MULTIPLESEL)
2421  descr->selected_item = caret;
2422  else
2423  LISTBOX_SetSelection( descr, caret, TRUE, FALSE);
2424  if (descr->style & LBS_NOTIFY)
2425  {
2426  if (descr->lphc && IsWindowVisible( descr->self ))
2427  {
2428  /* make sure that combo parent doesn't hide us */
2429  descr->lphc->wState |= CBF_NOROLLUP;
2430  }
2431  if (descr->nb_items) SEND_NOTIFICATION( descr, LBN_SELCHANGE );
2432  }
2433  }
2434  return 0;
2435 }
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3984
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
#define IS_MULTISELECT(descr)
Definition: listbox.c:104
#define LBS_WANTKEYBOARDINPUT
Definition: pedump.c:688
#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 SEND_NOTIFICATION(descr, code)
Definition: listbox.c:108
#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
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1420
static INT LISTBOX_GetCurrentPageSize(const LB_DESCR *descr)
Definition: listbox.c:133
#define VK_RIGHT
Definition: winuser.h:2201
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1463
#define LBS_NOTIFY
Definition: pedump.c:678
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_SPACE
Definition: winuser.h:2194
#define LBS_MULTICOLUMN
Definition: pedump.c:687
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define LOWORD(l)
Definition: pedump.c:82
#define VK_END
Definition: winuser.h:2197
#define LBS_MULTIPLESEL
Definition: pedump.c:681
Definition: path.c:41

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_HandleLButtonDown()

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

Definition at line 2026 of file listbox.c.

2027 {
2029 
2030  TRACE("[%p]: lbuttondown %d,%d item %d, focus item %d\n",
2031  descr->self, x, y, index, descr->focus_item);
2032 
2033  if (!descr->caret_on && (descr->in_focus)) return 0;
2034 
2035  if (!descr->in_focus)
2036  {
2037  if( !descr->lphc ) SetFocus( descr->self );
2038  else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit : descr->lphc->self );
2039  }
2040 
2041  if (index == -1) return 0;
2042 
2043  if (!descr->lphc)
2044  {
2045  if (descr->style & LBS_NOTIFY )
2047  MAKELPARAM( x, y ) );
2048  }
2049 
2050  descr->captured = TRUE;
2051  SetCapture( descr->self );
2052 
2053  if (descr->style & (LBS_EXTENDEDSEL | LBS_MULTIPLESEL))
2054  {
2055  /* we should perhaps make sure that all items are deselected
2056  FIXME: needed for !LBS_EXTENDEDSEL, too ?
2057  if (!(keys & (MK_SHIFT|MK_CONTROL)))
2058  LISTBOX_SetSelection( descr, -1, FALSE, FALSE);
2059  */
2060 
2061  if (!(keys & MK_SHIFT)) descr->anchor_item = index;
2062  if (keys & MK_CONTROL)
2063  {
2066  !descr->items[index].selected,
2067  (descr->style & LBS_NOTIFY) != 0);
2068  }
2069  else
2070  {
2072 
2073  if (descr->style & LBS_EXTENDEDSEL)
2074  {
2076  descr->items[index].selected,
2077  (descr->style & LBS_NOTIFY) != 0 );
2078  }
2079  else
2080  {
2082  !descr->items[index].selected,
2083  (descr->style & LBS_NOTIFY) != 0 );
2084  }
2085  }
2086  }
2087  else
2088  {
2089  descr->anchor_item = index;
2092  TRUE, (descr->style & LBS_NOTIFY) != 0 );
2093  }
2094 
2095  if (!descr->lphc)
2096  {
2098  {
2099  POINT pt;
2100 
2101  pt.x = x;
2102  pt.y = y;
2103 
2104  if (DragDetect( descr->self, pt ))
2105  SendMessageW( descr->owner, WM_BEGINDRAG, 0, 0 );
2106  }
2107  }
2108  return 0;
2109 }
#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:3983
#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)
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1355
int32_t INT
Definition: typedefs.h:56
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
const char * descr
Definition: boot.c:45
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1420
static INT LISTBOX_GetItemFromPoint(const LB_DESCR *descr, INT x, INT y)
Definition: listbox.c:439
#define index(s, c)
Definition: various.h:29
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1463
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define LBS_NOTIFY
Definition: pedump.c:678
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 LISTBOX_WindowProc().

◆ LISTBOX_HandleLButtonDownCombo()

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

Definition at line 2131 of file listbox.c.

2132 {
2133  RECT clientRect, screenRect;
2134  POINT mousePos;
2135 
2136  mousePos.x = x;
2137  mousePos.y = y;
2138 
2139  GetClientRect(descr->self, &clientRect);
2140 
2141  if(PtInRect(&clientRect, mousePos))
2142  {
2143  /* MousePos is in client, resume normal processing */
2144  if (msg == WM_LBUTTONDOWN)
2145  {
2146  descr->lphc->droppedIndex = descr->nb_items ? descr->selected_item : -1;
2147  return LISTBOX_HandleLButtonDown( descr, keys, x, y);
2148  }
2149  else if (descr->style & LBS_NOTIFY)
2151  }
2152  else
2153  {
2154  POINT screenMousePos;
2155  HWND hWndOldCapture;
2156 
2157  /* Check the Non-Client Area */
2158  screenMousePos = mousePos;
2159  hWndOldCapture = GetCapture();
2160  ReleaseCapture();
2161  GetWindowRect(descr->self, &screenRect);
2162  ClientToScreen(descr->self, &screenMousePos);
2163 
2164  if(!PtInRect(&screenRect, screenMousePos))
2165  {
2166  LISTBOX_SetCaretIndex( descr, descr->lphc->droppedIndex, FALSE );
2167  LISTBOX_SetSelection( descr, descr->lphc->droppedIndex, FALSE, FALSE );
2168  COMBO_FlipListbox( descr->lphc, FALSE, FALSE );
2169  }
2170  else
2171  {
2172  /* Check to see the NC is a scrollbar */
2173  INT nHitTestType=0;
2174  LONG style = GetWindowLongW( descr->self, GWL_STYLE );
2175  /* Check Vertical scroll bar */
2176  if (style & WS_VSCROLL)
2177  {
2178  clientRect.right += GetSystemMetrics(SM_CXVSCROLL);
2179  if (PtInRect( &clientRect, mousePos ))
2180  nHitTestType = HTVSCROLL;
2181  }
2182  /* Check horizontal scroll bar */
2183  if (style & WS_HSCROLL)
2184  {
2185  clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL);
2186  if (PtInRect( &clientRect, mousePos ))
2187  nHitTestType = HTHSCROLL;
2188  }
2189  /* Windows sends this message when a scrollbar is clicked
2190  */
2191 
2192  if(nHitTestType != 0)
2193  {
2194  SendMessageW(descr->self, WM_NCLBUTTONDOWN, nHitTestType,
2195  MAKELONG(screenMousePos.x, screenMousePos.y));
2196  }
2197  /* Resume the Capture after scrolling is complete
2198  */
2199  if(hWndOldCapture != 0)
2200  SetCapture(hWndOldCapture);
2201  }
2202  }
2203  return 0;
2204 }
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1674
#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
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1355
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:56
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:108
long LONG
Definition: pedump.c:60
HWND WINAPI GetCapture(void)
Definition: message.c:2879
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define MAKELONG(a, b)
Definition: typedefs.h:248
const char * descr
Definition: boot.c:45
int WINAPI GetSystemMetrics(_In_ int)
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1420
#define LBN_DBLCLK
Definition: winuser.h:2053
#define WS_HSCROLL
Definition: pedump.c:628
#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
static LRESULT LISTBOX_HandleLButtonDown(LB_DESCR *descr, DWORD keys, INT x, INT y)
Definition: listbox.c:2026
#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:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
Arabic default style
Definition: afstyles.h:93

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_HandleLButtonUp()

static LRESULT LISTBOX_HandleLButtonUp ( LB_DESCR descr)
static

Definition at line 2209 of file listbox.c.

2210 {
2212  KillSystemTimer( descr->self, LB_TIMER_ID );
2214  if (descr->captured)
2215  {
2216  descr->captured = FALSE;
2217  if (GetCapture() == descr->self) ReleaseCapture();
2218  if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2220  }
2221  return 0;
2222 }
#define LBN_SELCHANGE
Definition: winuser.h:2057
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:108
HWND WINAPI GetCapture(void)
Definition: message.c:2879
const char * descr
Definition: boot.c:45
BOOL WINAPI KillSystemTimer(HWND, UINT_PTR)
Definition: timer.c:35
#define LBS_NOTIFY
Definition: pedump.c:678
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
static TIMER_DIRECTION LISTBOX_Timer
Definition: listbox.c:124
#define LB_TIMER_ID
Definition: listbox.c:51

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_HandleMouseMove()

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

Definition at line 2281 of file listbox.c.

2283 {
2284  INT index;
2286 
2287  if (!descr->captured) return;
2288 
2289  if (descr->style & LBS_MULTICOLUMN)
2290  {
2291  if (y < 0) y = 0;
2292  else if (y >= descr->item_height * descr->page_size)
2293  y = descr->item_height * descr->page_size - 1;
2294 
2295  if (x < 0)
2296  {
2297  dir = LB_TIMER_LEFT;
2298  x = 0;
2299  }
2300  else if (x >= descr->width)
2301  {
2302  dir = LB_TIMER_RIGHT;
2303  x = descr->width - 1;
2304  }
2305  }
2306  else
2307  {
2308  if (y < 0) dir = LB_TIMER_UP; /* above */
2309  else if (y >= descr->height) dir = LB_TIMER_DOWN; /* below */
2310  }
2311 
2313  if (index == -1) index = descr->focus_item;
2315 
2316  /* Start/stop the system timer */
2317 
2318  if (dir != LB_TIMER_NONE)
2320  else if (LISTBOX_Timer != LB_TIMER_NONE)
2321  KillSystemTimer( descr->self, LB_TIMER_ID );
2322  LISTBOX_Timer = dir;
2323 }
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
TIMER_DIRECTION
Definition: listbox.c:115
int32_t INT
Definition: typedefs.h:56
static LRESULT LISTBOX_HandleTimer(LB_DESCR *descr, INT index, TIMER_DIRECTION dir)
Definition: listbox.c:2231
#define LB_SCROLL_TIMEOUT
Definition: listbox.c:48
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:439
#define index(s, c)
Definition: various.h:29
BOOL WINAPI KillSystemTimer(HWND, UINT_PTR)
Definition: timer.c:35
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static TIMER_DIRECTION LISTBOX_Timer
Definition: listbox.c:124
#define LBS_MULTICOLUMN
Definition: pedump.c:687
#define LB_TIMER_ID
Definition: listbox.c:51

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_HandleMouseWheel()

static LRESULT LISTBOX_HandleMouseWheel ( LB_DESCR descr,
SHORT  delta 
)
static

Definition at line 1999 of file listbox.c.

2000 {
2001  UINT pulScrollLines = 3;
2002 
2003  SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
2004 
2005  /* if scrolling changes direction, ignore left overs */
2006  if ((delta < 0 && descr->wheel_remain < 0) ||
2007  (delta > 0 && descr->wheel_remain > 0))
2008  descr->wheel_remain += delta;
2009  else
2010  descr->wheel_remain = delta;
2011 
2012  if (descr->wheel_remain && pulScrollLines)
2013  {
2014  int cLineScroll;
2015  pulScrollLines = min((UINT) descr->page_size, pulScrollLines);
2016  cLineScroll = pulScrollLines * (float)descr->wheel_remain / WHEEL_DELTA;
2017  descr->wheel_remain -= WHEEL_DELTA * cLineScroll / (int)pulScrollLines;
2018  LISTBOX_SetTopItem( descr, descr->top_item - cLineScroll, TRUE );
2019  }
2020  return 0;
2021 }
#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:266
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
const char * descr
Definition: boot.c:45
static float(__cdecl *square_half_float)(float x
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_HandleSystemTimer()

static LRESULT LISTBOX_HandleSystemTimer ( LB_DESCR descr)
static

Definition at line 2265 of file listbox.c.

2266 {
2267  if (!LISTBOX_HandleTimer( descr, descr->focus_item, LISTBOX_Timer ))
2268  {
2269  KillSystemTimer( descr->self, LB_TIMER_ID );
2271  }
2272  return 0;
2273 }
static LRESULT LISTBOX_HandleTimer(LB_DESCR *descr, INT index, TIMER_DIRECTION dir)
Definition: listbox.c:2231
const char * descr
Definition: boot.c:45
BOOL WINAPI KillSystemTimer(HWND, UINT_PTR)
Definition: timer.c:35
static TIMER_DIRECTION LISTBOX_Timer
Definition: listbox.c:124
#define LB_TIMER_ID
Definition: listbox.c:51

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_HandleTimer()

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

Definition at line 2231 of file listbox.c.

2232 {
2233  switch(dir)
2234  {
2235  case LB_TIMER_UP:
2236  if (descr->top_item) index = descr->top_item - 1;
2237  else index = 0;
2238  break;
2239  case LB_TIMER_LEFT:
2240  if (descr->top_item) index -= descr->page_size;
2241  break;
2242  case LB_TIMER_DOWN:
2243  index = descr->top_item + LISTBOX_GetCurrentPageSize( descr );
2244  if (index == descr->focus_item) index++;
2245  if (index >= descr->nb_items) index = descr->nb_items - 1;
2246  break;
2247  case LB_TIMER_RIGHT:
2248  if (index + descr->page_size < descr->nb_items)
2249  index += descr->page_size;
2250  break;
2251  case LB_TIMER_NONE:
2252  break;
2253  }
2254  if (index == descr->focus_item) return FALSE;
2256  return TRUE;
2257 }
#define TRUE
Definition: types.h:120
GLuint index
Definition: glext.h:6031
unsigned int dir
Definition: maze.c:112
const char * descr
Definition: boot.c:45
static INT LISTBOX_GetCurrentPageSize(const LB_DESCR *descr)
Definition: listbox.c:133
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1463

Referenced by LISTBOX_HandleMouseMove(), and LISTBOX_HandleSystemTimer().

◆ LISTBOX_HandleVScroll()

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

Definition at line 1869 of file listbox.c.

1870 {
1871  SCROLLINFO info;
1872 
1873  if (descr->style & LBS_MULTICOLUMN) return 0;
1874  switch(scrollReq)
1875  {
1876  case SB_LINEUP:
1877  LISTBOX_SetTopItem( descr, descr->top_item - 1, TRUE );
1878  break;
1879  case SB_LINEDOWN:
1880  LISTBOX_SetTopItem( descr, descr->top_item + 1, TRUE );
1881  break;
1882  case SB_PAGEUP:
1883  LISTBOX_SetTopItem( descr, descr->top_item -
1885  break;
1886  case SB_PAGEDOWN:
1887  LISTBOX_SetTopItem( descr, descr->top_item +
1889  break;
1890  case SB_THUMBPOSITION:
1892  break;
1893  case SB_THUMBTRACK:
1894  info.cbSize = sizeof(info);
1895  info.fMask = SIF_TRACKPOS;
1896  GetScrollInfo( descr->self, SB_VERT, &info );
1897  LISTBOX_SetTopItem( descr, info.nTrackPos, TRUE );
1898  break;
1899  case SB_TOP:
1900  LISTBOX_SetTopItem( descr, 0, TRUE );
1901  break;
1902  case SB_BOTTOM:
1903  LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
1904  break;
1905  }
1906  return 0;
1907 }
#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
struct _test_info info[]
Definition: SetCursorPos.c:19
#define SB_THUMBPOSITION
Definition: winuser.h:572
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:266
#define SB_THUMBTRACK
Definition: winuser.h:573
const char * descr
Definition: boot.c:45
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
static INT LISTBOX_GetCurrentPageSize(const LB_DESCR *descr)
Definition: listbox.c:133
#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 LISTBOX_WindowProc().

◆ LISTBOX_InitStorage()

static LRESULT LISTBOX_InitStorage ( LB_DESCR descr,
INT  nb_items 
)
static

Definition at line 673 of file listbox.c.

674 {
675  LB_ITEMDATA *item;
676 
677  nb_items += LB_ARRAY_GRANULARITY - 1;
678  nb_items -= (nb_items % LB_ARRAY_GRANULARITY);
679  if (descr->items) {
680  nb_items += HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(*item);
681  item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
682  nb_items * sizeof(LB_ITEMDATA));
683  }
684  else {
685  item = HeapAlloc( GetProcessHeap(), 0,
686  nb_items * sizeof(LB_ITEMDATA));
687  }
688 
689  if (!item)
690  {
692  return LB_ERRSPACE;
693  }
694  descr->items = item;
695  return LB_OKAY;
696 }
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:108
#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 LB_ARRAY_GRANULARITY
Definition: listbox.c:45
static ATOM item
Definition: dde.c:856
#define HeapReAlloc
Definition: compat.h:401

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_InsertItem()

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

Definition at line 1510 of file listbox.c.

1512 {
1513  LB_ITEMDATA *item;
1514  INT max_items;
1515  INT oldfocus = descr->focus_item;
1516 
1517  if (index == -1) index = descr->nb_items;
1518  else if ((index < 0) || (index > descr->nb_items)) return LB_ERR;
1519  if (!descr->items) max_items = 0;
1520  else max_items = HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(*item);
1521  if (descr->nb_items == max_items)
1522  {
1523  /* We need to grow the array */
1524  max_items += LB_ARRAY_GRANULARITY;
1525  if (descr->items)
1526  item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
1527  max_items * sizeof(LB_ITEMDATA) );
1528  else
1529  item = HeapAlloc( GetProcessHeap(), 0,
1530  max_items * sizeof(LB_ITEMDATA) );
1531  if (!item)
1532  {
1534  return LB_ERRSPACE;
1535  }
1536  descr->items = item;
1537  }
1538 
1539  /* Insert the item structure */
1540 
1541  item = &descr->items[index];
1542  if (index < descr->nb_items)
1543  RtlMoveMemory( item + 1, item,
1544  (descr->nb_items - index) * sizeof(LB_ITEMDATA) );
1545  item->str = str;
1546  item->data = HAS_STRINGS(descr) ? 0 : data;
1547  item->height = 0;
1548  item->selected = FALSE;
1549  descr->nb_items++;
1550 
1551  /* Get item height */
1552 
1553  if (descr->style & LBS_OWNERDRAWVARIABLE)
1554  {
1555  MEASUREITEMSTRUCT mis;
1556  UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1557 
1558  mis.CtlType = ODT_LISTBOX;
1559  mis.CtlID = id;
1560  mis.itemID = index;
1561  mis.itemData = data;
1562  mis.itemHeight = descr->item_height;
1563  SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
1564  item->height = mis.itemHeight ? mis.itemHeight : 1;
1565  TRACE("[%p]: measure item %d (%s) = %d\n",
1566  descr->self, index, str ? debugstr_w(str) : "", item->height );
1567  }
1568 
1569  /* Repaint the items */
1570 
1573 
1574  /* Move selection and focused item */
1575  /* If listbox was empty, set focus to the first item */
1576  if (descr->nb_items == 1)
1578  /* single select don't change selection index in win31 */
1579  else if ((ISWIN31) && !(IS_MULTISELECT(descr)))
1580  {
1581  descr->selected_item++;
1582  LISTBOX_SetSelection( descr, descr->selected_item-1, TRUE, FALSE );
1583  }
1584  else
1585  {
1586  if (index <= descr->selected_item)
1587  {
1588  descr->selected_item++;
1589  descr->focus_item = oldfocus; /* focus not changed */
1590  }
1591  }
1592  return LB_OKAY;
1593 }
#define ISWIN31
Definition: listbox.c:112
#define TRUE
Definition: types.h:120
#define IS_MULTISELECT(descr)
Definition: listbox.c:104
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1355
#define GetWindowLongPtrW
Definition: winuser.h:4804
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
int32_t INT
Definition: typedefs.h:56
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:108
#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 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
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1420
static void LISTBOX_UpdateScroll(LB_DESCR *descr)
Definition: listbox.c:183
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define LB_ERRSPACE
Definition: winuser.h:2408
static void LISTBOX_InvalidateItems(LB_DESCR *descr, INT index)
Definition: listbox.c:1127
#define index(s, c)
Definition: various.h:29
ULONG_PTR itemData
Definition: winuser.h:3621
#define LB_ARRAY_GRANULARITY
Definition: listbox.c:45
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 HAS_STRINGS(descr)
Definition: listbox.c:100
#define GWLP_ID
Definition: winuser.h:854

Referenced by LISTBOX_InsertString().

◆ LISTBOX_InsertString()

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

Definition at line 1599 of file listbox.c.

1600 {
1601  LPWSTR new_str = NULL;
1602  LRESULT ret;
1603 
1604  if (HAS_STRINGS(descr))
1605  {
1606  static const WCHAR empty_stringW[] = { 0 };
1607  if (!str) str = empty_stringW;
1608  if (!(new_str = HeapAlloc( GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(WCHAR) )))
1609  {
1611  return LB_ERRSPACE;
1612  }
1613  strcpyW(new_str, str);
1614  }
1615 
1616  if (index == -1) index = descr->nb_items;
1617  if ((ret = LISTBOX_InsertItem( descr, index, new_str, (ULONG_PTR)str )) != 0)
1618  {
1619  HeapFree( GetProcessHeap(), 0, new_str );
1620  return ret;
1621  }
1622 
1623  TRACE("[%p]: added item %d %s\n",
1624  descr->self, index, HAS_STRINGS(descr) ? debugstr_w(new_str) : "" );
1625  return index;
1626 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:108
#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
#define LB_ERRSPACE
Definition: winuser.h:2408
int ret
#define index(s, c)
Definition: various.h:29
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static LRESULT LISTBOX_InsertItem(LB_DESCR *descr, INT index, LPWSTR str, ULONG_PTR data)
Definition: listbox.c:1510
#define HAS_STRINGS(descr)
Definition: listbox.c:100
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 LISTBOX_WindowProc().

◆ LISTBOX_InvalidateItemRect()

static void LISTBOX_InvalidateItemRect ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1151 of file listbox.c.

1152 {
1153  RECT rect;
1154 
1155  if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1156  InvalidateRect( descr->self, &rect, TRUE );
1157 }
#define TRUE
Definition: types.h:120
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:381
& 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)

Referenced by LISTBOX_SelectItemRange().

◆ LISTBOX_InvalidateItems()

static void LISTBOX_InvalidateItems ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1127 of file listbox.c.

1128 {
1129  RECT rect;
1130 
1131  if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1132  {
1133  if (descr->style & LBS_NOREDRAW)
1134  {
1135  descr->style |= LBS_DISPLAYCHANGED;
1136  return;
1137  }
1138  rect.bottom = descr->height;
1139  InvalidateRect( descr->self, &rect, TRUE );
1140  if (descr->style & LBS_MULTICOLUMN)
1141  {
1142  /* Repaint the other columns */
1143  rect.left = rect.right;
1144  rect.right = descr->width;
1145  rect.top = 0;
1146  InvalidateRect( descr->self, &rect, TRUE );
1147  }
1148  }
1149 }
#define TRUE
Definition: types.h:120
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:381
& 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_DISPLAYCHANGED
Definition: listbox.c:54
#define LBS_MULTICOLUMN
Definition: pedump.c:687

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

773 {
774  INT ret = CompareStringW( lcid, NORM_IGNORECASE, str1, -1, str2, -1 );
775  if (ret == CSTR_LESS_THAN)
776  return -1;
777  if (ret == CSTR_EQUAL)
778  return 0;
779  if (ret == CSTR_GREATER_THAN)
780  return 1;
781  return -1;
782 }
#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 1316 of file listbox.c.

1317 {
1318  INT top;
1319 
1320  TRACE("current top item %d, index %d, fully %d\n", descr->top_item, index, fully);
1321 
1322  if (index <= descr->top_item) top = index;
1323  else if (descr->style & LBS_MULTICOLUMN)
1324  {
1325  INT cols = descr->width;
1326  if (!fully) cols += descr->column_width - 1;
1327  if (cols >= descr->column_width) cols /= descr->column_width;
1328  else cols = 1;
1329  if (index < descr->top_item + (descr->page_size * cols)) return;
1330  top = index - descr->page_size * (cols - 1);
1331  }
1332  else if (descr->style & LBS_OWNERDRAWVARIABLE)
1333  {
1334  INT height = fully ? descr->items[index].height : 1;
1335  for (top = index; top > descr->top_item; top--)
1336  if ((height += descr->items[top-1].height) > descr->height) break;
1337  }
1338  else
1339  {
1340  if (index < descr->top_item + descr->page_size) return;
1341  if (!fully && (index == descr->top_item + descr->page_size) &&
1342  (descr->height > (descr->page_size * descr->item_height))) return;
1343  top = index - descr->page_size + 1;
1344  }
1346 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
GLuint index
Definition: glext.h:6031
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:266
#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 1463 of file listbox.c.

1464 {
1465  TRACE("old focus %d, index %d\n", descr->focus_item, index);
1466 
1467  if ((index < 0) || (index >= descr->nb_items))
1468  return;
1469 
1470  /* Important, repaint needs to be done in this order if
1471  you want to mimic Windows behavior:
1472  1. Remove the focus and paint the item
1473  2. Remove the selection and paint the item(s)
1474  3. Set the selection and repaint the item(s)
1475  4. Set the focus to 'index' and repaint the item */
1476 
1477  /* 1. remove the focus and repaint the item */
1479 
1480  /* 2. then turn off the previous selection */
1481  /* 3. repaint the new selected item */
1482  if (descr->style & LBS_EXTENDEDSEL)
1483  {
1484  if (descr->anchor_item != -1)
1485  {
1486  INT first = min( index, descr->anchor_item );
1487  INT last = max( index, descr->anchor_item );
1488  if (first > 0)
1490  LISTBOX_SelectItemRange( descr, last + 1, -1, FALSE );
1492  }
1493  }
1494  else if (!(descr->style & LBS_MULTIPLESEL))
1495  {
1496  /* Set selection to new caret item */
1498  }
1499 
1500  /* 4. repaint the new item with the focus */
1501  descr->focus_item = index;
1502  LISTBOX_MakeItemVisible( descr, index, fully_visible );
1504 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
static void LISTBOX_MakeItemVisible(LB_DESCR *descr, INT index, BOOL fully)
Definition: listbox.c:1316
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
POINT last
Definition: font.c:46
const GLint * first
Definition: glext.h:5794
static void LISTBOX_DrawFocusRect(LB_DESCR *descr, BOOL on)
Definition: listbox.c:646
int32_t INT
Definition: typedefs.h:56
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
const char * descr
Definition: boot.c:45
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1420
#define index(s, c)
Definition: various.h:29
#define min(a, b)
Definition: monoChain.cc:55
static LRESULT LISTBOX_SelectItemRange(LB_DESCR *descr, INT first, INT last, BOOL on)
Definition: listbox.c:1380
#define LBS_MULTIPLESEL
Definition: pedump.c:681

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

◆ LISTBOX_NCPaint()

static void LISTBOX_NCPaint ( LB_DESCR descr,
HRGN  region 
)
static

Definition at line 1078 of file listbox.c.

1079 {
1080  DWORD exstyle = GetWindowLongW( descr->self, GWL_EXSTYLE);
1081  HTHEME theme = GetWindowTheme( descr->self );
1082  HRGN cliprgn = region;
1083  int cxEdge, cyEdge;
1084  HDC hdc;
1085  RECT r;
1086 
1087  if (!theme || !(exstyle & WS_EX_CLIENTEDGE))
1088  return;
1089 
1090  cxEdge = GetSystemMetrics(SM_CXEDGE),
1091  cyEdge = GetSystemMetrics(SM_CYEDGE);
1092 
1093  GetWindowRect(descr->self, &r);
1094 
1095  /* New clipping region passed to default proc to exclude border */
1096  cliprgn = CreateRectRgn(r.left + cxEdge, r.top + cyEdge,
1097  r.right - cxEdge, r.bottom - cyEdge);
1098  if (region != (HRGN)1)
1099  CombineRgn(cliprgn, cliprgn, region, RGN_AND);
1100  OffsetRect(&r, -r.left, -r.top);
1101 
1102 #ifdef __REACTOS__ /* r73789 */
1103  hdc = GetWindowDC(descr->self);
1104  /* Exclude client part */
1106  r.left + cxEdge,
1107  r.top + cyEdge,
1108  r.right - cxEdge,
1109  r.bottom -cyEdge);
1110 #else
1111  hdc = GetDCEx(descr->self, region, DCX_WINDOW|DCX_INTERSECTRGN);
1112  OffsetRect(&r, -r.left, -r.top);
1113 #endif
1114 
1115  if (IsThemeBackgroundPartiallyTransparent (theme, 0, 0))
1117  DrawThemeBackground (theme, hdc, 0, 0, &r, 0);
1118  ReleaseDC(descr->self, hdc);
1119 }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static HDC
Definition: imagelist.c:92
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define GWL_EXSTYLE
Definition: winuser.h:845
#define SM_CXEDGE
Definition: winuser.h:998
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
#define DCX_INTERSECTRGN
Definition: winuser.h:2104
#define DCX_WINDOW
Definition: winuser.h:2095
#define RGN_AND
Definition: wingdi.h:355
BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId)
Definition: draw.c:1883
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SM_CYEDGE
Definition: winuser.h:999
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
const char * descr
Definition: boot.c:45
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
HDC hdc
Definition: main.c:9
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HDC WINAPI GetWindowDC(_In_opt_ HWND)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_Paint()

static LRESULT LISTBOX_Paint ( LB_DESCR descr,
HDC  hdc 
)
static

Definition at line 970 of file listbox.c.

971 {
972  INT i, col_pos = descr->page_size - 1;
973  RECT rect;
974  RECT focusRect = {-1, -1, -1, -1};
975  HFONT oldFont = 0;
976  HBRUSH hbrush, oldBrush = 0;
977 
978  if (descr->style & LBS_NOREDRAW) return 0;
979 
980  SetRect( &rect, 0, 0, descr->width, descr->height );
981  if (descr->style & LBS_MULTICOLUMN)
982  rect.right = rect.left + descr->column_width;
983  else if (descr->horz_pos)
984  {
985  SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
986  rect.right += descr->horz_pos;
987  }
988 
989  if (descr->font) oldFont = SelectObject( hdc, descr->font );
990  hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
991  (WPARAM)hdc, (LPARAM)descr->self );
992  if (hbrush) oldBrush = SelectObject( hdc, hbrush );
994 
995  if (!descr->nb_items && (descr->focus_item != -1) && descr->caret_on &&
996  (descr->in_focus))
997  {
998  /* Special case for empty listbox: paint focus rect */
999  rect.bottom = rect.top + descr->item_height;
1001  &rect, NULL, 0, NULL );
1002  LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, FALSE );
1003  rect.top = rect.bottom;
1004  }
1005 
1006  /* Paint all the item, regarding the selection
1007  Focus state will be painted after */
1008 
1009  for (i = descr->top_item; i < descr->nb_items; i++)
1010  {
1011  if (!(descr->style & LBS_OWNERDRAWVARIABLE))
1012  rect.bottom = rect.top + descr->item_height;
1013  else
1014  rect.bottom = rect.top + descr->items[i].height;
1015 
1016  /* keep the focus rect, to paint the focus item after */
1017  if (i == descr->focus_item)
1018  focusRect = rect;
1019 
1021  rect.top = rect.bottom;
1022 
1023  if ((descr->style & LBS_MULTICOLUMN) && !col_pos)
1024  {
1025  if (!IS_OWNERDRAW(descr))
1026  {
1027  /* Clear the bottom of the column */
1028  if (rect.top < descr->height)
1029  {
1030  rect.bottom = descr->height;
1032  &rect, NULL, 0, NULL );
1033  }
1034  }
1035 
1036  /* Go to the next column */
1037  rect.left += descr->column_width;
1038  rect.right += descr->column_width;
1039  rect.top = 0;
1040  col_pos = descr->page_size - 1;
1041  }
1042  else
1043  {
1044  col_pos--;
1045  if (rect.top >= descr->height) break;
1046  }
1047  }
1048 
1049  /* Paint the focus item now */
1050  if (focusRect.top != focusRect.bottom &&
1051  descr->caret_on && descr->in_focus)
1052  LISTBOX_PaintItem( descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS, FALSE );
1053 
1054  if (!IS_OWNERDRAW(descr))
1055  {
1056  /* Clear the remainder of the client area */
1057  if (rect.top < descr->height)
1058  {
1059  rect.bottom = descr->height;
1061  &rect, NULL, 0, NULL );
1062  }
1063  if (rect.right < descr->width)
1064  {
1065  rect.left = rect.right;
1066  rect.right = descr->width;
1067  rect.top = 0;
1068  rect.bottom = descr->height;
1070  &rect, NULL, 0, NULL );
1071  }
1072  }
1073  if (oldFont) SelectObject( hdc, oldFont );
1074  if (oldBrush) SelectObject( hdc, oldBrush );
1075  return 0;
1076 }
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
LONG top
Definition: windef.h:307
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
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
static void LISTBOX_PaintItem(LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus)
Definition: listbox.c:486
#define IS_OWNERDRAW(descr)
Definition: listbox.c:97
const char * descr
Definition: boot.c:45
#define COLOR_GRAYTEXT
Definition: winuser.h:922
HDC hdc
Definition: main.c:9
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define LBS_MULTICOLUMN
Definition: pedump.c:687
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
LONG bottom
Definition: windef.h:309

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_PaintItem()

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

Definition at line 486 of file listbox.c.

488 {
489  LB_ITEMDATA *item = NULL;
490  if (index < descr->nb_items) item = &descr->items[index];
491 
492  if (IS_OWNERDRAW(descr))
493  {
494  DRAWITEMSTRUCT dis;
495  RECT r;
496  HRGN hrgn;
497 
498  if (!item)
499  {
500  if (action == ODA_FOCUS)
501  DrawFocusRect( hdc, rect );
502  else
503  ERR("called with an out of bounds index %d(%d) in owner draw, Not good.\n",index,descr->nb_items);
504  return;
505  }
506 
507  /* some programs mess with the clipping region when
508  drawing the item, *and* restore the previous region
509  after they are done, so a region has better to exist
510  else everything ends clipped */
511  GetClientRect(descr->self, &r);
513 
514  dis.CtlType = ODT_LISTBOX;
515  dis.CtlID = GetWindowLongPtrW( descr->self, GWLP_ID );
516  dis.hwndItem = descr->self;
517  dis.itemAction = action;
518  dis.hDC = hdc;
519  dis.itemID = index;
520  dis.itemState = 0;
521  if (item->selected) dis.itemState |= ODS_SELECTED;
522  if (!ignoreFocus && (descr->focus_item == index) &&
523  (descr->caret_on) &&
524  (descr->in_focus)) dis.itemState |= ODS_FOCUS;
525  if (!IsWindowEnabled(descr->self)) dis.itemState |= ODS_DISABLED;
526  dis.itemData = item->data;
527  dis.rcItem = *rect;
528  TRACE("[%p]: drawitem %d (%s) action=%02x state=%02x rect=%s\n",
529  descr->self, index, debugstr_w(item->str), action,
531  SendMessageW(descr->owner, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
532  SelectClipRgn( hdc, hrgn );
533  if (hrgn) DeleteObject( hrgn );
534  }
535  else
536  {
537  COLORREF oldText = 0, oldBk = 0;
538 
539  if (action == ODA_FOCUS)
540  {
541  DrawFocusRect( hdc, rect );
542  return;
543  }
544  if (item && item->selected)
545  {
546  oldBk = SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
548  }
549 
550  TRACE("[%p]: painting %d (%s) action=%02x rect=%s\n",
551  descr->self, index, item ? debugstr_w(item->str) : "", action,
553  if (!item)
554  ExtTextOutW( hdc, rect->left + 1, rect->top,
555  ETO_OPAQUE | ETO_CLIPPED, rect, NULL, 0, NULL );
556  else if (!(descr->style & LBS_USETABSTOPS))
557  ExtTextOutW( hdc, rect->left + 1, rect->top,
558  ETO_OPAQUE | ETO_CLIPPED, rect, item->str,
559  strlenW(item->str), NULL );
560  else
561  {
562  /* Output empty string to paint background in the full width. */
563  ExtTextOutW( hdc, rect->left + 1, rect->top,
564  ETO_OPAQUE | ETO_CLIPPED, rect, NULL, 0, NULL );
565  TabbedTextOutW( hdc, rect->left + 1 , rect->top,
566  item->str, strlenW(item->str),
567  descr->nb_tabs, descr->tabs, 0);
568  }
569  if (item && item->selected)
570  {
571  SetBkColor( hdc, oldBk );
572  SetTextColor( hdc, oldText );
573  }
574  if (!ignoreFocus && (descr->focus_item == index) &&
575  (descr->caret_on) &&
576  (descr->in_focus)) DrawFocusRect( hdc, rect );
577  }
578 }
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)
ULONG_PTR itemData
Definition: winuser.h:3068
#define ODS_FOCUS
Definition: winuser.h:2524
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define GetWindowLongPtrW
Definition: winuser.h:4804
#define ODA_FOCUS
Definition: winuser.h:2519
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:239
DWORD WINAPI GetSysColor(_In_ int)
& rect
Definition: startmenu.cpp:1413
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c: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:300
#define IS_OWNERDRAW(descr)
Definition: listbox.c:97
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_Register()

void LISTBOX_Register ( void  )

Definition at line 3054 of file listbox.c.

3055 {
3056  WNDCLASSW wndClass;
3057 
3058  memset(&wndClass, 0, sizeof(wndClass));
3059  wndClass.style = CS_PARENTDC | CS_DBLCLKS | CS_GLOBALCLASS;
3060  wndClass.lpfnWndProc = LISTBOX_WindowProc;
3061  wndClass.cbClsExtra = 0;
3062  wndClass.cbWndExtra = sizeof(LB_DESCR *);
3063  wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
3064  wndClass.hbrBackground = NULL;
3065  wndClass.lpszClassName = WC_LISTBOXW;
3066  RegisterClassW(&wndClass);
3067 }
UINT style
Definition: winuser.h:3151
static LRESULT CALLBACK LISTBOX_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: listbox.c:2570
int cbClsExtra
Definition: winuser.h:3153
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
WNDPROC lpfnWndProc
Definition: winuser.h:3152
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszClassName
Definition: winuser.h:3160
int cbWndExtra
Definition: winuser.h:3154
#define CS_GLOBALCLASS
Definition: winuser.h:647
#define WC_LISTBOXW
Definition: commctrl.h:4707
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define CS_DBLCLKS
Definition: winuser.h:646
HCURSOR hCursor
Definition: winuser.h:3157
HBRUSH hbrBackground
Definition: winuser.h:3158
#define IDC_ARROW
Definition: winuser.h:682
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define memset(x, y, z)
Definition: compat.h:39
#define CS_PARENTDC
Definition: winuser.h:651

Referenced by DllMain().

◆ LISTBOX_RemoveItem()

static LRESULT LISTBOX_RemoveItem ( LB_DESCR descr,
INT  index 
)
static

Definition at line 1670 of file listbox.c.

1671 {
1672  LB_ITEMDATA *item;
1673  INT max_items;
1674 
1675  if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1676 
1677  /* We need to invalidate the original rect instead of the updated one. */
1679 
1680  descr->nb_items--;
1682 
1683  if (!descr->nb_items) return LB_OKAY;
1684 
1685  /* Remove the item */
1686 
1687  item = &descr->items[index];
1688  if (index < descr->nb_items)
1689  RtlMoveMemory( item, item + 1,
1690  (descr->nb_items - index) * sizeof(LB_ITEMDATA) );
1691  if (descr->anchor_item == descr->nb_items) descr->anchor_item--;
1692 
1693  /* Shrink the item array if possible */
1694 
1695  max_items = HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(LB_ITEMDATA);
1696  if (descr->nb_items < max_items - 2*LB_ARRAY_GRANULARITY)
1697  {
1698  max_items -= LB_ARRAY_GRANULARITY;
1699  item = HeapReAlloc( GetProcessHeap(), 0, descr->items,
1700  max_items * sizeof(LB_ITEMDATA) );
1701  if (item) descr->items = item;
1702  }
1703  /* Repaint the items */
1704 
1706  /* if we removed the scrollbar, reset the top of the list
1707  (correct for owner-drawn ???) */
1708  if (descr->nb_items == descr->page_size)
1709  LISTBOX_SetTopItem( descr, 0, TRUE );
1710 
1711  /* Move selection and focused item */
1712  if (!IS_MULTISELECT(descr))
1713  {
1714  if (index == descr->selected_item)
1715  descr->selected_item = -1;
1716  else if (index < descr->selected_item)
1717  {
1718  descr->selected_item--;
1719  if (ISWIN31) /* win 31 do not change the selected item number */
1720  LISTBOX_SetSelection( descr, descr->selected_item + 1, TRUE, FALSE);
1721  }
1722  }
1723 
1724  if (descr->focus_item >= descr->nb_items)
1725  {
1726  descr->focus_item = descr->nb_items - 1;
1727  if (descr->focus_item < 0) descr->focus_item = 0;
1728  }
1729  return LB_OKAY;
1730 }
#define ISWIN31
Definition: listbox.c:112
#define TRUE
Definition: types.h:120
#define IS_MULTISELECT(descr)
Definition: listbox.c:104
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
int32_t INT
Definition: typedefs.h:56
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
static void LISTBOX_DeleteItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1634
#define LB_ERR
Definition: winuser.h:2407
GLuint index
Definition: glext.h:6031
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:266
#define GetProcessHeap()
Definition: compat.h:403
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1420
static void LISTBOX_UpdateScroll(LB_DESCR *descr)
Definition: listbox.c:183
static void LISTBOX_InvalidateItems(LB_DESCR *descr, INT index)
Definition: listbox.c:1127
#define index(s, c)
Definition: various.h:29
#define LB_ARRAY_GRANULARITY
Definition: listbox.c:45
static ATOM item
Definition: dde.c:856
#define HeapReAlloc
Definition: compat.h:401

Referenced by LISTBOX_SetCount(), and LISTBOX_WindowProc().

◆ LISTBOX_RepaintItem()

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

Definition at line 613 of file listbox.c.

614 {
615  HDC hdc;
616  RECT rect;
617  HFONT oldFont = 0;
618  HBRUSH hbrush, oldBrush = 0;
619 
620  /* Do not repaint the item if the item is not visible */
621  if (!IsWindowVisible(descr->self)) return;
622  if (descr->style & LBS_NOREDRAW)
623  {
624  descr->style |= LBS_DISPLAYCHANGED;
625  return;
626  }
627  if (LISTBOX_GetItemRect( descr, index, &rect ) != 1) return;
628  if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
629  if (descr->font) oldFont = SelectObject( hdc, descr->font );
630  hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
631  (WPARAM)hdc, (LPARAM)descr->self );
632  if (hbrush) oldBrush = SelectObject( hdc, hbrush );
633  if (!IsWindowEnabled(descr->self))
635  SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
637  if (oldFont) SelectObject( hdc, oldFont );
638  if (oldBrush) SelectObject( hdc, oldBrush );
639  ReleaseDC( descr->self, hdc );
640 }
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define TRUE
Definition: types.h:120
static HBRUSH hbrush
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:381
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
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
static void LISTBOX_PaintItem(LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus)
Definition: listbox.c:486
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
#define LBS_DISPLAYCHANGED
Definition: listbox.c:54
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)

Referenced by LISTBOX_SetSelection(), and LISTBOX_WindowProc().

◆ LISTBOX_ResetContent()

static void LISTBOX_ResetContent ( LB_DESCR descr)
static

Definition at line 1736 of file listbox.c.

1737 {
1738  INT i;
1739 
1740  for(i = descr->nb_items - 1; i>=0; i--) LISTBOX_DeleteItem( descr, i);
1741  HeapFree( GetProcessHeap(), 0, descr->items );
1742  descr->nb_items = 0;
1743  descr->top_item = 0;
1744  descr->selected_item = -1;
1745  descr->focus_item = 0;
1746  descr->anchor_item = -1;
1747  descr->items = NULL;
1748 }
int32_t INT
Definition: typedefs.h:56
static void LISTBOX_DeleteItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1634
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 LISTBOX_WindowProc().

◆ LISTBOX_SelectItemRange()

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

Definition at line 1380 of file listbox.c.

1382 {
1383  INT i;
1384 
1385  /* A few sanity checks */
1386 
1387  if (descr->style & LBS_NOSEL) return LB_ERR;
1388  if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
1389 
1390  if (!descr->nb_items) return LB_OKAY;
1391 
1392  if (last == -1 || last >= descr->nb_items) last = descr->nb_items - 1;
1393  if (first < 0) first = 0;
1394  if (last < first) return LB_OKAY;
1395 
1396  if (on) /* Turn selection on */
1397  {
1398  for (i = first; i <= last; i++)
1399  {
1400  if (descr->items[i].selected) continue;
1401  descr->items[i].selected = TRUE;
1403  }
1404  }
1405  else /* Turn selection off */
1406  {
1407  for (i = first; i <= last; i++)
1408  {
1409  if (!descr->items[i].selected) continue;
1410  descr->items[i].selected = FALSE;
1412  }
1413  }
1414  return LB_OKAY;
1415 }
#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
const char * descr
Definition: boot.c:45
static void LISTBOX_InvalidateItemRect(LB_DESCR *descr, INT index)
Definition: listbox.c:1151
#define LBS_NOSEL
Definition: winuser.h:316
#define LBS_MULTIPLESEL
Definition: pedump.c:681

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

◆ LISTBOX_SetCaretIndex()

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

Definition at line 1355 of file listbox.c.

1356 {
1357  INT oldfocus = descr->focus_item;
1358 
1359  TRACE("old focus %d, index %d\n", oldfocus, index);
1360 
1361  if (descr->style & LBS_NOSEL) return LB_ERR;
1362  if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1363  if (index == oldfocus) return LB_OKAY;
1364 
1366  descr->focus_item = index;
1367 
1368  LISTBOX_MakeItemVisible( descr, index, fully_visible );
1370 
1371  return LB_OKAY;
1372 }
#define TRUE
Definition: types.h:120
static void LISTBOX_MakeItemVisible(LB_DESCR *descr, INT index, BOOL fully)
Definition: listbox.c:1316
static void LISTBOX_DrawFocusRect(LB_DESCR *descr, BOOL on)
Definition: listbox.c:646
int32_t INT
Definition: typedefs.h:56
#define LB_ERR
Definition: winuser.h:2407
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 LISTBOX_WindowProc().

◆ LISTBOX_SetColumnWidth()

static LRESULT LISTBOX_SetColumnWidth ( LB_DESCR descr,
INT  width 
)
static

Definition at line 1270 of file listbox.c.

1271 {
1272  if (width == descr->column_width) return LB_OKAY;
1273  TRACE("[%p]: new column width = %d\n", descr->self, width );
1274  descr->column_width = width;
1276  return LB_OKAY;
1277 }
GLint GLint GLsizei width
Definition: gl.h:1546
static void LISTBOX_UpdatePage(LB_DESCR *descr)
Definition: listbox.c:316
#define TRACE(s)
Definition: solgame.cpp:4
#define LB_OKAY
Definition: winuser.h:2406
const char * descr
Definition: boot.c:45

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_SetCount()

static LRESULT LISTBOX_SetCount ( LB_DESCR descr,
INT  count 
)
static

Definition at line 1754 of file listbox.c.

1755 {
1756  LRESULT ret;
1757 
1758  if (HAS_STRINGS(descr))
1759  {
1761  return LB_ERR;
1762  }
1763 
1764  /* FIXME: this is far from optimal... */
1765  if (count > descr->nb_items)
1766  {
1767  while (count > descr->nb_items)
1768  if ((ret = LISTBOX_InsertString( descr, -1, 0 )) < 0)
1769  return ret;
1770  }
1771  else if (count < descr->nb_items)
1772  {
1773  while (count < descr->nb_items)
1774  if ((ret = LISTBOX_RemoveItem( descr, (descr->nb_items - 1) )) < 0)
1775  return ret;
1776  }
1777 
1778  InvalidateRect( descr->self, NULL, TRUE );
1779  return LB_OKAY;
1780 }
#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_RemoveItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1670
#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
static LRESULT LISTBOX_InsertString(LB_DESCR *descr, INT index, LPCWSTR str)
Definition: listbox.c:1599
#define HAS_STRINGS(descr)
Definition: listbox.c:100
LONG_PTR LRESULT
Definition: windef.h:209

Referenced by LISTBOX_WindowProc().

◆ LISTBOX_SetFont()

static INT LISTBOX_SetFont ( LB_DESCR descr,
HFONT  font 
)
static

Definition at line 1285 of file listbox.c.

1286 {
1287  HDC hdc;
1288  HFONT oldFont = 0;
1289  const char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1290  SIZE sz;
1291 
1292  descr->font = font;
1293 
1294  if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE )))
1295  {
1296  ERR("unable to get DC.\n" );
1297  return 16;
1298  }
1299  if (font) oldFont = SelectObject( hdc, font );
1300  GetTextExtentPointA( hdc, alphabet, 52, &sz);
1301  if (oldFont) SelectObject( hdc, oldFont );
1302  ReleaseDC( descr->self, hdc );
1303 
1304  descr->avg_char_width = (sz.cx / 26 + 1) / 2;
1305  if (!IS_OWNERDRAW(descr))
1306  LISTBOX_SetItemHeight( descr, 0, sz.cy, FALSE );
1307  return sz.cy;
1308 }
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
static LRESULT LISTBOX_SetItemHeight(LB_DESCR *descr, INT index, INT height, BOOL repaint)
Definition: listbox.c:1180
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
LONG cx
Definition: windef.h:334
#define IS_OWNERDRAW(descr)
Definition: listbox.c:97
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 DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LONG cy
Definition: windef.h:335

Referenced by LISTBOX_Create(), and LISTBOX_WindowProc().

◆ LISTBOX_SetHorizontalExtent()

static LRESULT LISTBOX_SetHorizontalExtent ( LB_DESCR descr,
INT  extent 
)
static

Definition at line 1244 of file listbox.c.

1245 {
1246  if (descr->style & LBS_MULTICOLUMN)
1247  return LB_OKAY;
1248  if (extent ==