Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / afsapplib / fastlist.h
blobd4fb69f53ae81d667c260b8260028426a4beb4a6
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
10 #ifndef FASTLIST_H
11 #define FASTLIST_H
13 #include <commctrl.h>
17 * DEFINITIONS ________________________________________________________________
21 #ifndef EXPORTED
22 #define EXPORTED
23 #endif
25 #ifndef THIS_HINST
26 #define THIS_HINST (HINSTANCE)GetModuleHandle(NULL)
27 #endif
29 #define WC_FASTLIST TEXT("OpenAFS_FastList")
31 #define FLM_FIRST 0x1400
33 #define FLN_FIRST (0U-880U)
34 #define FLN_LAST (0U-885U)
36 #define IMAGE_NOIMAGE ((int)(-1))
37 #define IMAGE_BLANKIMAGE ((int)(-2))
41 * WINDOW STYLES ______________________________________________________________
45 // The FLS_VIEW_* styles are used to indicate the format for
46 // displaying items in the FastList; either by Large Icons,
47 // Small Icons (equivalent to a ListView's "List" layout),
48 // in a List (equivalent to ListView's "Report" layout),
49 // in a Tree (equivalent to a TreeView), or as a tree/list hybrid--
50 // showing the Tree hierarchy as well as a header bar and
51 // details about each item.
53 #define FLS_VIEW_LARGE 0x0001
54 #define FLS_VIEW_SMALL 0x0002
55 #define FLS_VIEW_LIST 0x0003
56 #define FLS_VIEW_TREE 0x0004
57 #define FLS_VIEW_TREELIST (FLS_VIEW_TREE | FLS_VIEW_LIST)
58 #define FLS_VIEW_MASK (FLS_VIEW_LARGE | FLS_VIEW_SMALL | FLS_VIEW_TREE | FLS_VIEW_LIST)
60 // The FLS_NOSORTHEADER style causes the header bar (when visible)
61 // to be drawn "flat"--the buttons cannot be depressed. This style
62 // cannot be combined with FLS_AUTOSORTHEADER.
64 #define FLS_NOSORTHEADER 0x0008
66 // The FLS_SELECTION_MULTIPLE style indicates that more than one
67 // item in the list may be selected at any time. When combined with
68 // the FLS_SELECTION_SIBLING style, only direct siblings in the tree
69 // hierarchy may be selected at any time. When instead combined with
70 // the FLS_SELECTION_LEVEL style, only items at the same level from
71 // the root may be selected at any time. If these bits are not set,
72 // only one item may be selected at any time.
74 #define FLS_SELECTION_MULTIPLE 0x0010
75 #define FLS_SELECTION_SIBLING (0x0020 | FLS_SELECTION_MULTIPLE)
76 #define FLS_SELECTION_LEVEL (0x0040 | FLS_SELECTION_MULTIPLE)
78 // The FLS_LINESATROOT style causes root-level items in the tree
79 // to be prefixed by open/close boxes.
81 #define FLS_LINESATROOT 0x0080
83 // The FLS_LONGCOLUMNS style allows the right-most column containing
84 // text, if left-justified, to be drawn to the extent of the window
85 // regardless of column boundaries. It is particularly useful in
86 // Tree/List mode, where some entries may have long descriptions
87 // for the left-most column, and others may have several columns of
88 // data.
90 #define FLS_LONGCOLUMNS 0x0100
92 // The FLS_HIT_TEXTONLY style allows the user to de-select all
93 // items by left- or right-clicking on the whitespace between
94 // columns of data in List mode. (It has no effect in other modes.)
95 // If this bit is not set, clicking on this whitespace causes
96 // that item to be selected.
98 #define FLS_HIT_TEXTONLY 0x0200
100 // The FLS_AUTOSORTHEADER style allows the user to sort on any
101 // column by clicking on the column, or to reverse the sort on
102 // a column by clicking it twice. This style cannot be combined
103 // with the FLS_NOSORTHEADER style.
105 #define FLS_AUTOSORTHEADER 0x0400
108 * STRUCTURES _________________________________________________________________
112 typedef struct _FASTLISTITEM *HLISTITEM;
114 typedef struct FASTLISTADDITEM
116 HLISTITEM hParent; // parent item or NULL
117 int iFirstImage; // primary icon or imageNO_IMAGE
118 int iSecondImage; // secondary icon or imageNO_IMAGE
119 LPTSTR pszText; // text for column 0
120 LPARAM lParam; // user-supplied cookie
121 DWORD dwFlags; // combination of FLIF_* flags
122 } FASTLISTADDITEM, *LPFASTLISTADDITEM;
124 #define FLIF_TREEVIEW_ONLY 0x0001 // hide item unless in tree view
125 #define FLIF_DROPHIGHLIGHT 0x0002 // draw item as if it were selected
126 #define FLIF_DISALLOW_COLLAPSE 0x0004 // don't allow this item to collapse
127 #define FLIF_DISALLOW_SELECT 0x0008 // don't allow this item to be selected
129 typedef struct FASTLISTITEMREGIONS
131 RECT rItem; // OUT: overall rectangle for item
132 RECT rImage; // OUT: rect of item's images
133 RECT rLabel; // OUT: rect of item's label
134 RECT rHighlight; // OUT: rect that inverts on selection
135 RECT rButton; // OUT: rect of tree open/close button
136 RECT rSelect; // OUT: union of rHighlight+rImage
137 } FASTLISTITEMREGIONS, *LPFASTLISTITEMREGIONS;
139 typedef struct FASTLISTDRAWITEM
141 HDC hdc; // IN: target or template HDC
142 BOOL fDraw; // IN: TRUE if should render to hdc
143 BOOL fDragImage; // IN: TRUE if want drag image only
144 HWND hWnd; // IN: handle of fastlist window
145 HLISTITEM hItem; // IN: item to be drawn
146 LPARAM lParam; // IN: user-supplied lparam for item
147 RECT rItem; // IN: overall rectangle for item
148 POINT ptTextTest; // IN: client coords of point to test
149 BOOL fTextTestHit; // OUT: TRUE if point is within text
150 FASTLISTITEMREGIONS reg; // OUT: information about item image
151 } FASTLISTDRAWITEM, *LPFASTLISTDRAWITEM;
153 typedef struct FLN_GETITEMTEXT_PARAMS
155 NMHDR hdr; // IN: typical notification header
156 struct
158 HLISTITEM hItem; // IN: item for which to obtain text
159 int icol; // IN: 0-based column of text to get
160 LPARAM lParam; // IN: user-supplied lparam for item
161 LPTSTR pszText; // IN: buffer in which to place text
162 size_t cchTextMax; // IN: size of buffer; OUT: required
163 } item;
164 } FLN_GETITEMTEXT_PARAMS, *LPFLN_GETITEMTEXT_PARAMS;
166 typedef struct FLN_ITEMCHANGED_PARAMS
168 NMHDR hdr; // IN: typical notification header
169 HLISTITEM hItem; // IN: item whose data has changed
170 } FLN_ITEMCHANGED_PARAMS, *LPFLN_ITEMCHANGED_PARAMS;
172 typedef struct FLN_ADDITEM_PARAMS
174 NMHDR hdr; // IN: typical notification header
175 HLISTITEM hItem; // IN: item which was added
176 } FLN_ADDITEM_PARAMS, *LPFLN_ADDITEM_PARAMS;
178 typedef struct FLN_REMOVEITEM_PARAMS
180 NMHDR hdr; // IN: typical notification header
181 HLISTITEM hItem; // IN: item which was removed
182 } FLN_REMOVEITEM_PARAMS, *LPFLN_REMOVEITEM_PARAMS;
184 typedef struct FLN_COLUMNCLICK_PARAMS
186 NMHDR hdr; // IN: typical notification header
187 int icol; // IN: 0-based column that was clicked
188 BOOL fDouble; // IN: TRUE if 'twas a double-click
189 } FLN_COLUMNCLICK_PARAMS, *LPFLN_COLUMNCLICK_PARAMS;
191 typedef struct FLN_COLUMNRESIZE_PARAMS
193 NMHDR hdr; // IN: typical notification header
194 int icol; // IN: 0-based column that was resized
195 LONG cxWidth; // IN: new width of the column
196 } FLN_COLUMNRESIZE_PARAMS, *LPFLN_COLUMNRESIZE_PARAMS;
198 typedef struct FLN_ITEMSELECT_PARAMS
200 NMHDR hdr; // IN: typical notification header
201 HLISTITEM hItem; // IN: first item which is now selected
202 } FLN_ITEMSELECT_PARAMS, *LPFLN_ITEMSELECT_PARAMS;
204 typedef struct FLN_ITEMEXPAND_PARAMS
206 NMHDR hdr; // IN: typical notification header
207 HLISTITEM hItem; // IN: item which was expanded/collapsed
208 BOOL fExpanded; // IN: TRUE if item is now expanded
209 } FLN_ITEMEXPAND_PARAMS, *LPFLN_ITEMEXPAND_PARAMS;
211 typedef struct FLN_DRAG_PARAMS
213 NMHDR hdr; // IN: typical notification header
214 HLISTITEM hFirst; // IN: first (of perhaps many) selected
215 POINT ptScreenFrom; // IN: screen coordinates of button-down
216 POINT ptScreenTo; // IN: final screen coordinates
217 BOOL fRightButton; // IN: TRUE if right-button drag
218 BOOL fShift; // IN: TRUE if shift is down
219 BOOL fControl; // IN: TRUE if control is down
220 } FLN_DRAG_PARAMS, *LPFLN_DRAG_PARAMS;
222 typedef struct FASTLISTCOLUMN
224 DWORD dwFlags;
225 LONG cxWidth;
226 TCHAR szText[ 256 ];
227 } FASTLISTCOLUMN, *LPFASTLISTCOLUMN;
229 #define FLCF_JUSTIFY_LEFT 0x0001
230 #define FLCF_JUSTIFY_RIGHT 0x0002
231 #define FLCF_JUSTIFY_CENTER 0x0003
232 #define FLCF_JUSTIFY_MASK 0x0003
234 typedef struct FASTLISTITEMCOLUMN
236 HLISTITEM hItem;
237 int icol;
238 } FASTLISTITEMCOLUMN, *LPFASTLISTITEMCOLUMN;
240 typedef struct FASTLISTITEMIMAGE
242 HLISTITEM hItem;
243 int iImage;
244 } FASTLISTITEMIMAGE, *LPFASTLISTITEMIMAGE;
246 typedef int (CALLBACK * LPFASTLISTSORTFUNC)( HWND hList, HLISTITEM hItem1, LPARAM lpItem1, HLISTITEM hItem2, LPARAM lpItem2 );
248 typedef BOOL (CALLBACK * LPFASTLISTTEXTCALLBACK)( HWND hList, LPFLN_GETITEMTEXT_PARAMS pfln, DWORD dwCookie );
252 * NOTIFICATIONS ______________________________________________________________
254 * All notifications come via a WM_NOTIFY message to the FastList window's
255 * parent window. The message handler should be of the form:
257 * switch (msg) {
258 * case WM_NOTIFY: {
259 * switch (((LPNMHDR)lp)->code) {
260 * case FLN_GETITEMTEXT: {
261 * LPFLN_GETITEMTEXT_PARAMS pParams = (LPFLN_GETITEMTEXT_PARAMS)lp;
262 * lstrcpy (pParams->pszText, ...);
263 * return TRUE;
265 * case FLN_ITEMEXPAND: {
266 * ...
267 * return TRUE;
273 * The LPARAM associated with a WM_NOTIFY message is always (for notifications
274 * from any window, not just FastLists) a structure consisting of:
275 * struct {
276 * NMHDR hdr;
277 * // window- and message-specific elements ...
279 * Thus, by casing the LPARAM value to LPNMHDR, information about the
280 * notification can be obtained from any notification structure.
281 * If a notification message is handled, the handler must return TRUE.
285 #define FLN_GETITEMTEXT (FLN_FIRST-0) // lp = LPFLN_GETITEMTEXT_PARAMS
286 #define FLN_ITEMCHANGED (FLN_FIRST-1) // lp = LPFLN_ITEMCHANGED_PARAMS
287 #define FLN_ADDITEM (FLN_FIRST-2) // lp = LPFLN_ADDITEM_PARAMS
288 #define FLN_REMOVEITEM (FLN_FIRST-3) // lp = LPFLN_REMOVEITEM_PARAMS
289 #define FLN_COLUMNCLICK (FLN_FIRST-4) // lp = LPFLN_COLUMNCLICK_PARAMS
290 #define FLN_COLUMNRESIZE (FLN_FIRST-5) // lp = LPFLN_COLUMNRESIZE_PARAMS
291 #define FLN_ITEMSELECT (FLN_FIRST-6) // lp = LPFLN_ITEMSELECT_PARAMS
292 #define FLN_ITEMEXPAND (FLN_FIRST-7) // lp = LPFLN_ITEMEXPAND_PARAMS
293 #define FLN_LCLICK (FLN_FIRST-8) // lp = LPNMHDR
294 #define FLN_RCLICK (FLN_FIRST-9) // lp = LPNMHDR
295 #define FLN_LDBLCLICK (FLN_FIRST-10) // lp = LPNMHDR
296 #define FLN_BEGINDRAG (FLN_FIRST-11) // lp = LPFLN_DRAG_PARAMS, rc = fDrag
297 #define FLN_DRAG (FLN_FIRST-12) // lp = LPFLN_DRAG_PARAMS
298 #define FLN_ENDDRAG (FLN_FIRST-13) // lp = LPFLN_DRAG_PARAMS
302 * MESSAGES ___________________________________________________________________
307 * TASK GROUPING
309 * Calling FastList_Begin() suspends sorting, repainting and other display-
310 * oriented operations until a matching call to FastList_End(). By surrounding
311 * multiple operations with an initial call to _Begin() and a final call to
312 * _End(), the operations can proceed (potentially much) more quickly, and
313 * without flicker as items are added, updated or removed. Calls to _Begin()
314 * and _End() nest: if _Begin() is called twice, two calls to _End() are
315 * required to finally cause the display to be repainted and resume normal
316 * operation. (A call to FastList_EndAll() ignores all nesting and enables
317 * redraw as if the proper number of calls to _End() had been made.)
321 // void FastList_Begin (HWND hList);
323 #define FastList_Begin(_hList) \
324 (void)SendMessage (_hList, FLM_BEGIN, 0, 0)
325 #define FLM_BEGIN (FLM_FIRST + 0x0000)
327 // void FastList_End (HWND hList);
328 // void FastList_EndAll (HWND hList);
330 #define FastList_End(_hList) \
331 (void)SendMessage (_hList, FLM_END, 0, 0)
332 #define FastList_EndAll(_hList) \
333 (void)SendMessage (_hList, FLM_END, 1, 0)
334 #define FLM_END (FLM_FIRST + 0x0001)
337 * ADD/REMOVE ITEMS
339 * These operations add and remove items to the list, and affect items'
340 * properties.
344 // HLISTITEM FastList_AddItem (HWND hList, LPFASTLISTADDITEM pai);
346 #define FastList_AddItem(_hList,_pai) \
347 (HLISTITEM)SendMessage (_hList, FLM_ADDITEM, 0, (LPARAM)(_pai))
348 #define FLM_ADDITEM (FLM_FIRST + 0x0002)
350 // void FastList_RemoveAll (HWND hList)
351 // void FastList_RemoveItem (HWND hList, HLISTITEM hItem)
353 #define FastList_RemoveAll(_hList) \
354 FastList_RemoveItem(_hList,0)
355 #define FastList_RemoveItem(_hList,_hItem) \
356 (void)SendMessage (_hList, FLM_REMOVEITEM, (WPARAM)(_hItem), 0)
357 #define FLM_REMOVEITEM (FLM_FIRST + 0x0003)
359 // LPCTSTR FastList_GetItemText (HWND hList, HLISTITEM hItem, int icol);
360 // void FastList_SetItemText (HWND hList, HLISTITEM hItem, int icol, LPCTSTR pszText);
362 #define FastList_GetItemText(_hList,_hItem,_iCol) \
363 (LPCTSTR)SendMessage (_hList, FLM_GETITEMTEXT, (WPARAM)(_hItem), (LPARAM)(_iCol))
364 #define FastList_SetItemText(_hList,_hItem,_iCol,_psz) \
365 do { FASTLISTITEMCOLUMN _flic; \
366 _flic.hItem = _hItem; \
367 _flic.icol = _iCol; \
368 (void)SendMessage (_hList, FLM_SETITEMTEXT, (WPARAM)&_flic, (LPARAM)(_psz)); } while (0)
369 #define FLM_GETITEMTEXT (FLM_FIRST + 0x0004)
370 #define FLM_SETITEMTEXT (FLM_FIRST + 0x0005)
372 // LPARAM FastList_GetItemParam (HWND hList, HLISTITEM hItem);
373 // void FastList_SetItemParam (HWND hList, HLISTITEM hItem, LPARAM lParam);
375 #define FastList_GetItemParam(_hList,_hItem) \
376 (LPARAM)SendMessage (_hList, FLM_GETITEMPARAM, (WPARAM)(_hItem), 0)
377 #define FastList_SetItemParam(_hList,_hItem,_lp) \
378 (void)SendMessage (_hList, FLM_SETITEMPARAM, (WPARAM)(_hItem), (LPARAM)(_lp))
379 #define FLM_GETITEMPARAM (FLM_FIRST + 0x0006)
380 #define FLM_SETITEMPARAM (FLM_FIRST + 0x0007)
382 // DWORD FastList_GetItemFlags (HWND hList, HLISTITEM hItem);
383 // void FastList_SetItemFlags (HWND hList, HLISTITEM hItem, DWORD dwFlags);
385 #define FastList_GetItemFlags(_hList,_hItem) \
386 (LPARAM)SendMessage (_hList, FLM_GETITEMFLAGS, (WPARAM)(_hItem), 0)
387 #define FastList_SetItemFlags(_hList,_hItem,_dw) \
388 (void)SendMessage (_hList, FLM_SETITEMFLAGS, (WPARAM)(_hItem), (LPARAM)(_dw))
389 #define FLM_GETITEMFLAGS (FLM_FIRST + 0x0008)
390 #define FLM_SETITEMFLAGS (FLM_FIRST + 0x0009)
392 // int FastList_GetItemFirstImage (HWND hList, HLISTITEM hItem);
393 // int FastList_GetItemSecondImage (HWND hList, HLISTITEM hItem);
394 // void FastList_SetItemFirstImage (HWND hList, HLISTITEM hItem, int image);
395 // void FastList_SetItemSecondImage (HWND hList, HLISTITEM hItem, int image);
397 #define FastList_GetItemFirstImage(_hList,_hItem) \
398 FastList_GetItemImage(_hList,_hItem,0)
399 #define FastList_GetItemSecondImage(_hList,_hItem) \
400 FastList_GetItemImage(_hList,_hItem,1)
401 #define FastList_SetItemFirstImage(_hList,_hItem,_image) \
402 FastList_SetItemImage(_hList,_hItem,0,_image)
403 #define FastList_SetItemSecondImage(_hList,_hItem,_image) \
404 FastList_SetItemImage(_hList,_hItem,1,_image)
405 #define FastList_GetItemImage(_hList,_hItem,_iImage) \
406 (int)SendMessage (_hList, FLM_GETITEMIMAGE, (WPARAM)(_hItem), (LPARAM)(_iImage))
407 #define FastList_SetItemImage(_hList,_hItem,_iImage,_image) \
408 do { FASTLISTITEMIMAGE _flii; \
409 _flii.hItem = _hItem; \
410 _flii.iImage = _iImage; \
411 (void)SendMessage (_hList, FLM_SETITEMIMAGE, (WPARAM)&_flii, (LPARAM)(_image)); } while (0)
412 #define FLM_GETITEMIMAGE (FLM_FIRST + 0x000A)
413 #define FLM_SETITEMIMAGE (FLM_FIRST + 0x000B)
415 // BOOL FastList_IsExpanded (HWND hList, HLISTITEM hItem);
416 // void FastList_Expand (HWND hList, HLISTITEM hItem);
417 // void FastList_Collapse (HWND hList, HLISTITEM hItem);
418 // void FastList_SetExpanded (HWND hList, HLISTITEM hItem, BOOL fExpand);
420 #define FastList_IsExpanded(_hList,_hItem) \
421 (BOOL)SendMessage (_hList, FLM_ISEXPANDED, (WPARAM)(_hItem), 0)
422 #define FastList_Expand(_hList,_hItem) \
423 FastList_SetExpanded(_hList,_hItem,TRUE)
424 #define FastList_Collapse(_hList,_hItem) \
425 FastList_SetExpanded(_hList,_hItem,FALSE)
426 #define FastList_SetExpanded(_hList,_hItem,_fExpand) \
427 (BOOL)SendMessage (_hList, FLM_EXPAND, (WPARAM)(_hItem), (LPARAM)(_fExpand))
428 #define FLM_ISEXPANDED (FLM_FIRST + 0x000C)
429 #define FLM_EXPAND (FLM_FIRST + 0x000D)
431 // BOOL FastList_IsVisible (HWND hList, HLISTITEM hItem);
432 // void FastList_EnsureVisible (HWND hList, HLISTITEM hItem);
434 #define FastList_IsVisible(_hList,_hItem) \
435 (BOOL)SendMessage (_hList, FLM_ITEMVISIBLE, (WPARAM)(_hItem), 0)
436 #define FastList_EnsureVisible(_hList,_hItem) \
437 (BOOL)SendMessage (_hList, FLM_ITEMVISIBLE, (WPARAM)(_hItem), 1)
438 #define FLM_ITEMVISIBLE (FLM_FIRST + 0x000E)
440 // HLISTITEM FastList_GetFocus (HWND hList);
441 // BOOL FastList_IsFocused (HWND hList, HLISTITEM hItem);
442 // void FastList_SetFocus (HWND hList, HLISTITEM hItem);
444 #define FastList_GetFocus(_hList) \
445 (HLISTITEM)SendMessage (_hList, FLM_ITEMFOCUS, 0, 0)
446 #define FastList_IsFocused(_hList,_hItem) \
447 (BOOL)SendMessage (_hList, FLM_ITEMFOCUS, (WPARAM)(_hItem), 0)
448 #define FastList_SetFocus(_hList,_hItem) \
449 (void)SendMessage (_hList, FLM_ITEMFOCUS, (WPARAM)(_hItem), 1)
450 #define FLM_ITEMFOCUS (FLM_FIRST + 0x000F)
454 * IMAGE LIST SUPPORT
456 * A FastList may have two separate IMAGELISTs associated with it--one for
457 * 32x32 icons (used only in Large mode), and one for 16x16 icons (used in
458 * all other display modes). Use COMMCTRL.H's ImageList_Create() to create
459 * imagelists for use with a FastList.
463 // void FastList_GetImageLists (HWND hList, HIMAGELIST *phiSmall, HIMAGELIST *phiLarge)
465 #define FastList_GetImageLists(_hList,_phiSmall,_phiLarge) \
466 (void)SendMessage (_hList, FLM_GETIMAGELISTS, (WPARAM)(_phiSmall), (LPARAM)(_phiLarge))
467 #define FLM_GETIMAGELISTS (FLM_FIRST + 0x0010)
469 // void FastList_SetImageLists (HWND hList, HIMAGELIST hiSmall, HIMAGELIST hiLarge)
471 #define FastList_SetImageLists(_hList,_hiSmall,_hiLarge) \
472 (void)SendMessage (_hList, FLM_SETIMAGELISTS, (WPARAM)(_hiSmall), (LPARAM)(_hiLarge))
473 #define FLM_SETIMAGELISTS (FLM_FIRST + 0x0011)
475 // HIMAGELIST FastList_CreateDragImage (HWND hList, HLISTITEM hItem)
477 #define FastList_CreateDragImage(_hList,_hItem) \
478 (HIMAGELIST)SendMessage (_hList, FLM_CREATEDRAGIMAGE, (WPARAM)(_hItem), 0)
479 #define FLM_CREATEDRAGIMAGE (FLM_FIRST + 0x0012)
482 * SORTING
484 * The contents of a FastList are always kept sorted; they will never be
485 * displayed out-of-sort. The function used to sort items may be replaced
486 * by calling the FastList_SetSortFunction() method, and parameters
487 * regarding the sort may be changed by calling the FastList_SetSortStyle()
488 * function. The default sorting parameters are:
490 * Function: FastList_SortFunc_AlphaNumeric() [declared way down below]
491 * Column: Sorted on column 0
492 * Reverse: No; items ascending-sorted
494 * The FastList_Sort() function may be called to initiate a re-sort;
495 * however, doing so is unnecessary (as the list is automatically re-sorted
496 * when necessary). When displaying items in a tree, sorting is performed
497 * between sibling items only.
501 // LPFASTLISTSORTFUNC FastList_GetSortFunction (HWND hList)
503 #define FastList_GetSortFunction(_hList,_pfn) \
504 (LPFASTLISTSORTFUNC)SendMessage (_hList, FLM_GETSORTFUNC, 0, 0)
505 #define FLM_GETSORTFUNC (FLM_FIRST + 0x0013)
507 // void FastList_SetSortFunction (HWND hList, LPFASTLISTSORTFUNC pfn)
509 #define FastList_SetSortFunction(_hList,_pfn) \
510 (void)SendMessage (_hList, FLM_SETSORTFUNC, 0, (LPARAM)(_pfn))
511 #define FLM_SETSORTFUNC (FLM_FIRST + 0x0014)
513 // void FastList_GetSortStyle (HWND hList, int *piColumn, BOOL *pfReverse)
515 #define FastList_GetSortStyle(_hList,_piCol,_pfRev) \
516 (void)SendMessage (_hList, FLM_GETSORTSTYLE, (WPARAM)(_piCol), (LPARAM)(_pfRev))
517 #define FLM_GETSORTSTYLE (FLM_FIRST + 0x0015)
519 // void FastList_SetSortStyle (HWND hList, int iColumn, BOOL fReverse)
521 #define FastList_SetSortStyle(_hList,_iCol,_fRev) \
522 (void)SendMessage (_hList, FLM_SETSORTSTYLE, (WPARAM)(_iCol), (LPARAM)(_fRev))
523 #define FLM_SETSORTSTYLE (FLM_FIRST + 0x0016)
525 // void FastList_Sort (HWND hList)
527 #define FastList_Sort(_hList) \
528 (void)SendMessage (_hList, FLM_SORT, 0, 0)
529 #define FLM_SORT (FLM_FIRST + 0x0017)
532 * COLUMNS
534 * In List and TreeList mode, a FastList can be caused to display a column
535 * header and the associated multiple columns of information for each item.
536 * FastList_AddItem() supplies only a place for the item's column-0 text
537 * to be specified; other columns may be specified by FastList_SetItemText(),
538 * but if not, the FastList will call back to its parent window via the
539 * WM_NOTIFY/FLN_GETITEMTEXT notification to obtain text for the items'
540 * unspecified columns.
544 // int FastList_GetColumnCount (HWND hList)
546 #define FastList_GetColumnCount(_hList) \
547 (int)SendMessage (_hList, FLM_GETCOLUMNCOUNT, 0, 0)
548 #define FLM_GETCOLUMNCOUNT (FLM_FIRST + 0x0018)
550 // BOOL FastList_GetColumn (HWND hList, int iColumn, LPFASTLISTCOLUMN pcol)
552 #define FastList_GetColumn(_hList,_iCol,_pCol) \
553 (BOOL)SendMessage (_hList, FLM_GETCOLUMN, (WPARAM)(_iCol), (LPARAM)(_pCol))
554 #define FLM_GETCOLUMN (FLM_FIRST + 0x0019)
556 // void FastList_SetColumn (HWND hList, int iColumn, LPFASTLISTCOLUMN pcol)
557 // void FastList_RemoveColumn (HWND hList, int iColumn)
559 #define FastList_SetColumn(_hList,_iCol,_pCol) \
560 (void)SendMessage (_hList, FLM_SETCOLUMN, (WPARAM)(_iCol), (LPARAM)(_pCol))
561 #define FastList_RemoveColumn(_hList,_iCol) \
562 FastList_SetColumn (_hList, _iCol, NULL)
563 #define FLM_SETCOLUMN (FLM_FIRST + 0x001A)
566 * SELECTION
568 * A FastList supports several types of selection. Single Selection causes
569 * any current selection to be cleared before a new item can be selected,
570 * either programmatically or by user action. Multiple Selection
571 * indiscriminately allows any items to be selected or deselected at
572 * the same time. Multiple/Sibling Selection requires that, if an item
573 * is selected which is not a sibling of any currently-selected items,
574 * the current selection is cleared first. Multiple/Level Selection requires
575 * that, if an item is selected which is at a different level from the root
576 * than any currently-selected item, the current selection is cleared first.
580 // BOOL FastList_IsSelected (HWND hList, HLISTITEM hItem)
582 #define FastList_IsSelected(_hList,_hItem) \
583 (BOOL)SendMessage (_hList, FLM_ISSELECTED, (WPARAM)(_hItem), 0)
584 #define FLM_ISSELECTED (FLM_FIRST + 0x001B)
586 // void FastList_SelectAll (HWND hList)
587 // void FastList_SelectNone (HWND hList)
588 // void FastList_SelectItem (HWND hList, HLISTITEM hItem, BOOL fSelect)
590 #define FastList_SelectAll(_hList) \
591 FastList_SelectItem(_hList,0,TRUE)
592 #define FastList_SelectNone(_hList) \
593 FastList_SelectItem(_hList,0,FALSE)
594 #define FastList_SelectItem(_hList,_hItem,_fSel) \
595 (void)SendMessage (_hList, FLM_SELECTITEM, (WPARAM)(_hItem), (LPARAM)(_fSel))
596 #define FLM_SELECTITEM (FLM_FIRST + 0x001C)
599 * ENUMERATION
601 * A FastList provides multiple methods for enumeration. Items in the list
602 * may be enumerated as members of a hierarchy, or as members of a list.
603 * Additionally, the items in a FastList are hashed across their lParam
604 * values, so the FastList item matching a given lParam value can quickly
605 * be found. All enumeration functions are either constant time, or (as
606 * in the case of lParam-to-HLISTITEM lookups) extremely close to it.
608 * A typical enumeration will look like this:
609 * for (HLISTITEM hItem = FastList_FindFirst (hList);
610 * hItem != NULL;
611 * hItem = FastList_FindNext (hList, hItem))
613 * // ...
616 * Or, equivalently:
617 * HLISTITEM hItem = NULL;
618 * while ((hItem = FastList_FindNext (hList, hItem)) != NULL)
620 * // ...
623 * If an enumeration involving an LPENUM pointer is terminated without
624 * having enumerated all items in the list, the loop must be followed
625 * by a FastList_FindClose() statement. (This statement is optional
626 * otherwise.) If the state of the list or tree is updated, the enumeration
627 * should be stopped.
631 // HLISTITEM FastList_FindFirst (HWND hList)
632 // HLISTITEM FastList_FindNext (HWND hList, HLISTITEM hItem)
633 // HLISTITEM FastList_FindPrevious (HWND hList, HLISTITEM hItem)
635 #define FastList_FindFirst(_hList) \
636 FastList_FindList(_hList,0,FLM_FINDLIST_FIRST)
637 #define FastList_FindNext(_hList,_hItem) \
638 FastList_FindList(_hList,_hItem,FLM_FINDLIST_NEXT)
639 #define FastList_FindPrevious(_hList,_hItem) \
640 FastList_FindList(_hList,_hItem,FLM_FINDLIST_PREVIOUS)
641 #define FastList_FindList(_hList,_hItem,_dwCode) \
642 (HLISTITEM)SendMessage (_hList, FLM_FINDLIST, (WPARAM)(_hItem), (LPARAM)(_dwCode))
643 #define FLM_FINDLIST (FLM_FIRST + 0x001D)
644 #define FLM_FINDLIST_FIRST 0
645 #define FLM_FINDLIST_PREVIOUS 1
646 #define FLM_FINDLIST_NEXT 2
648 // HLISTITEM FastList_FindFirstInRoot (HWND hList)
649 // HLISTITEM FastList_FindParent (HWND hList, HLISTITEM hItem)
650 // HLISTITEM FastList_FindFirstChild (HWND hList, HLISTITEM hItem)
651 // HLISTITEM FastList_FindPreviousSibling (HWND hList, HLISTITEM hItem)
652 // HLISTITEM FastList_FindNextSibling (HWND hList, HLISTITEM hItem)
654 #define FastList_FindFirstInRoot(_hList) \
655 FastList_FindTree(_hList,0,FLM_FINDTREE_CHILD)
656 #define FastList_FindParent(_hList,_hItem) \
657 FastList_FindTree(_hList,_hItem,FLM_FINDTREE_PARENT)
658 #define FastList_FindFirstChild(_hList,_hItem) \
659 FastList_FindTree(_hList,_hItem,FLM_FINDTREE_CHILD)
660 #define FastList_FindPreviousSibling(_hList,_hItem) \
661 FastList_FindTree(_hList,_hItem,FLM_FINDTREE_PREVIOUS)
662 #define FastList_FindNextSibling(_hList,_hItem) \
663 FastList_FindTree(_hList,_hItem,FLM_FINDTREE_NEXT)
664 #define FastList_FindTree(_hList,_hItem,_dwCode) \
665 (HLISTITEM)SendMessage (_hList, FLM_FINDTREE, (WPARAM)(_hItem), (LPARAM)(_dwCode))
666 #define FLM_FINDTREE (FLM_FIRST + 0x001E)
667 #define FLM_FINDTREE_PARENT 0
668 #define FLM_FINDTREE_CHILD 1
669 #define FLM_FINDTREE_PREVIOUS 2
670 #define FLM_FINDTREE_NEXT 3
672 // HLISTITEM FastList_FindFirstSelected (HWND hList)
673 // HLISTITEM FastList_FindNextSelected (HWND hList, HLISTITEM hItemPrevious)
675 #define FastList_FindFirstSelected(_hList) \
676 FastList_FindNextSelected(_hList,0)
677 #define FastList_FindNextSelected(_hList,_hItem) \
678 (HLISTITEM)SendMessage (_hList, FLM_FINDSELECTED, (WPARAM)(_hItem), 0)
679 #define FLM_FINDSELECTED (FLM_FIRST + 0x001F)
681 // HLISTITEM FastList_FindItem (HWND hList, LPARAM lParam)
682 // HLISTITEM FastList_FindFirstItem (HWND hList, LPENUM *ppEnum, LPARAM lParam)
683 // HLISTITEM FastList_FindNextItem (HWND hList, LPENUM *ppEnum)
684 // void FastList_FindClose (HWND hList, LPENUM *ppEnum)
686 #define FastList_FindItem(_hList,_lp) \
687 (HLISTITEM)SendMessage (_hList, FLM_FINDITEM, 0, (LPARAM)(_lp))
688 #define FastList_FindFirstItem(_hList,_ppEnum,_lp) \
689 (HLISTITEM)SendMessage (_hList, FLM_FINDITEM, (WPARAM)(_ppEnum), (LPARAM)(_lp))
690 #define FastList_FindNextItem(_hList,_ppEnum) \
691 (HLISTITEM)SendMessage (_hList, FLM_FINDNEXTITEM, (WPARAM)(_ppEnum), 0)
692 #define FastList_FindClose(_hList,_ppEnum) \
693 (void)SendMessage (_hList, FLM_FINDCLOSE, (WPARAM)(_ppEnum), 0)
694 #define FLM_FINDITEM (FLM_FIRST + 0x0020)
695 #define FLM_FINDNEXTITEM (FLM_FIRST + 0x0021)
696 #define FLM_FINDCLOSE (FLM_FIRST + 0x0022)
698 // int FastList_GetItemCount (HWND hList)
699 // int FastList_GetVisibleItemCount (HWND hList)
701 #define FastList_GetItemCount(_hList) \
702 (int)SendMessage (_hList, FLM_GETITEMCOUNT, 0, 0)
703 #define FastList_GetVisibleItemCount(_hList) \
704 (int)SendMessage (_hList, FLM_GETITEMCOUNT, 1, 0)
705 #define FLM_GETITEMCOUNT (FLM_FIRST + 0x0023)
707 // HLISTITEM FastList_FindFirstVisible (HWND hList)
708 // HLISTITEM FastList_FindNextVisible (HWND hList, HLISTITEM hItem)
710 #define FastList_FindFirstVisible(_hList) \
711 FastList_FindVisible(_hList,0,FLM_FINDVISIBLE_FIRST)
712 #define FastList_FindNextVisible(_hList,_hItem) \
713 FastList_FindVisible(_hList,_hItem,FLM_FINDVISIBLE_NEXT)
714 #define FastList_FindVisible(_hList,_hItem,_dwCode) \
715 (HLISTITEM)SendMessage (_hList, FLM_FINDVISIBLE, (WPARAM)(_hItem), (LPARAM)(_dwCode))
716 #define FLM_FINDVISIBLE (FLM_FIRST + 0x0024)
717 #define FLM_FINDVISIBLE_FIRST 0
718 #define FLM_FINDVISIBLE_NEXT 1
721 * ITEM DISPLAY
723 * Like any other control, a FastList can tell you which item is underneath
724 * a particular point, and can tell you what RECTs an item uses for what
725 * purposes on the display.
727 * There are style bits which can be set to affect hit-testing on
728 * a FastList. Notably, the FLS_HIT_TEXTONLY bit prevents left- or right-
729 * clicking in whitespace to select an item (in list mode).
733 // HLISTITEM FastList_ItemFromPoint (HWND hList, POINT *pptClient, BOOL fStrict)
735 #define FastList_ItemFromPoint(_hList,_pptClient,_fStrict) \
736 (HLISTITEM)SendMessage (_hList, FLM_ITEMFROMPOINT, (WPARAM)(_pptClient), (LPARAM)(_fStrict))
737 #define FLM_ITEMFROMPOINT (FLM_FIRST + 0x0025)
739 // void FastList_GetItemRegions (HWND hList, HLISTITEM hItem, LPFASTLISTITEMREGIONS pReg)
741 #define FastList_GetItemRegions(_hList,_hItem,_pReg) \
742 (HLISTITEM)SendMessage (_hList, FLM_GETITEMREGIONS, (WPARAM)(_hItem), (LPARAM)(_pReg))
743 #define FLM_GETITEMREGIONS (FLM_FIRST + 0x0026)
745 // LPFASTLISTTEXTCALLBACK FastList_GetTextCallback (HWND hList)
746 // void FastList_SetTextCallback (HWND hList, LPFASTLISTTEXTCALLBACK pfn, DWORD dwCookie)
748 #define FastList_GetTextCallback(_hList) \
749 (LPFASTLISTTEXTCALLBACK)SendMessage (_hList, FLM_GETTEXTCALLBACK, 0, 0)
750 #define FastList_SetTextCallback(_hList,_pfn,_dwCookie) \
751 (void)SendMessage (_hList, FLM_SETTEXTCALLBACK, (WPARAM)(_pfn), (LPARAM)(_dwCookie))
752 #define FLM_GETTEXTCALLBACK (FLM_FIRST + 0x0027)
753 #define FLM_SETTEXTCALLBACK (FLM_FIRST + 0x0028)
757 * PROTOTYPES _________________________________________________________________
761 EXPORTED BOOL RegisterFastListClass (void);
762 EXPORTED BOOL fIsFastList (HWND hList);
764 EXPORTED void FastList_Enter (HWND hList);
765 EXPORTED void FastList_Leave (HWND hList);
767 EXPORTED int CALLBACK FastList_SortFunc_Alphabetic (HWND hList, HLISTITEM hItem1, LPARAM lpItem1, HLISTITEM hItem2, LPARAM lpItem2);
768 EXPORTED int CALLBACK FastList_SortFunc_Numeric (HWND hList, HLISTITEM hItem1, LPARAM lpItem1, HLISTITEM hItem2, LPARAM lpItem2);
769 EXPORTED int CALLBACK FastList_SortFunc_AlphaNumeric (HWND hList, HLISTITEM hItem1, LPARAM lpItem1, HLISTITEM hItem2, LPARAM lpItem2);
772 #endif