Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

324 lines
13 KiB

  1. #ifndef __LISTBOX_H__
  2. #define __LISTBOX_H__
  3. #include "combo.h" // for CBOX defn
  4. //
  5. // Return Values
  6. //
  7. #define EQ 0
  8. #define PREFIX 1
  9. #define LT 2
  10. #define GT 3
  11. #define SINGLESEL 0
  12. #define MULTIPLESEL 1
  13. #define EXTENDEDSEL 2
  14. #define LBI_ADD 0x0004
  15. //
  16. // The various bits of wFileDetails field are used as mentioned below:
  17. // 0x0001 Should the file name be in upper case.
  18. // 0x0002 Should the file size be shown.
  19. // 0x0004 Date stamp of the file to be shown ?
  20. // 0x0008 Time stamp of the file to be shown ?
  21. // 0x0010 The dos attributes of the file ?
  22. // 0x0020 In DlgDirSelectEx(), along with file name
  23. // all other details also will be returned
  24. //
  25. #define LBUP_RELEASECAPTURE 0x0001
  26. #define LBUP_RESETSELECTION 0x0002
  27. #define LBUP_NOTIFY 0x0004
  28. #define LBUP_SUCCESS 0x0008
  29. #define LBUP_SELCHANGE 0x0010
  30. //
  31. // System timer IDs used be listbox
  32. //
  33. #define IDSYS_LBSEARCH 0x0000FFFCL
  34. #define IDSYS_SCROLL 0x0000FFFEL
  35. #define IDSYS_CARET 0x0000FFFFL
  36. //
  37. // Parameter for AlterHilite()
  38. //
  39. #define HILITEONLY 0x0001
  40. #define SELONLY 0x0002
  41. #define HILITEANDSEL (HILITEONLY + SELONLY)
  42. #define HILITE 1
  43. //
  44. // Listbox macros
  45. //
  46. #define IsLBoxVisible(plb) \
  47. (plb->fRedraw && IsWindowVisible(plb->hwnd))
  48. #define CaretCreate(plb) \
  49. ((plb)->fCaret = TRUE)
  50. //
  51. //from sysmet.c
  52. //
  53. #define SCROLL_TIMEOUT() \
  54. ((GetDoubleClickTime()*4)/5)
  55. //
  56. // We don't need 64-bit intermediate precision so we use this macro
  57. // instead of calling MulDiv.
  58. //
  59. #define MultDiv(x, y, z) \
  60. (((INT)(x) * (INT)(y) + (INT)(z) / 2) / (INT)(z))
  61. //
  62. // Instance data pointer access functions
  63. //
  64. #define ListBox_GetPtr(hwnd) \
  65. (PLBIV)GetWindowPtr(hwnd, 0)
  66. #define ListBox_SetPtr(hwnd, p) \
  67. (PLBIV)SetWindowPtr(hwnd, 0, p)
  68. //
  69. // List Box
  70. //
  71. typedef struct tagSCROLLPOS
  72. {
  73. INT cItems;
  74. UINT iPage;
  75. INT iPos;
  76. UINT fMask;
  77. INT iReturn;
  78. } SCROLLPOS, *PSCROLLPOS;
  79. typedef struct tagLBIV
  80. {
  81. HWND hwnd; // lbox ctl window
  82. HWND hwndParent; // lbox parent
  83. HTHEME hTheme; // Handle to the theme manager
  84. PWW pww; // RO pointer into the pwnd to ExStyle, Style, State, State2
  85. INT iTop; // index of top item displayed
  86. INT iSel; // index of current item selected
  87. INT iSelBase; // base sel for multiple selections
  88. INT cItemFullMax; // cnt of Fully Visible items. Always contains
  89. // result of ListBox_CItemInWindow(plb, FALSE) for fixed
  90. // height listboxes. Contains 1 for var height
  91. // listboxes.
  92. INT cMac; // cnt of items in listbox
  93. INT cMax; // cnt of total # items allocated for rgpch.
  94. // Not all are necessarly in use
  95. PBYTE rgpch; // pointer to array of string offsets
  96. LPWSTR hStrings; // string storage handle
  97. INT cchStrings; // Size in bytes of hStrings
  98. INT ichAlloc; // Pointer to end of hStrings (end of last valid
  99. // string)
  100. INT cxChar; // Width of a character
  101. INT cyChar; // height of line
  102. INT cxColumn; // width of a column in multicolumn listboxes
  103. INT itemsPerColumn; // for multicolumn listboxes
  104. INT numberOfColumns;// for multicolumn listboxes
  105. POINT ptPrev; // coord of last tracked mouse pt. used for auto
  106. // scrolling the listbox during timer's
  107. UINT OwnerDraw:2; // Owner draw styles. Non-zero if ownerdraw.
  108. UINT fRedraw:1; // if TRUE then do repaints
  109. UINT fDeferUpdate:1;
  110. UINT wMultiple:2; // SINGLESEL allows a single item to be selected.
  111. // MULTIPLESEL allows simple toggle multi-selection
  112. // EXTENDEDSEL allows extended multi selection;
  113. UINT fSort:1; // if TRUE the sort list
  114. UINT fNotify:1; // if TRUE then Notify parent
  115. UINT fMouseDown:1; // if TRUE then process mouse moves/mouseup
  116. UINT fCaptured:1; // if TRUE then process mouse messages
  117. UINT fCaret:1; // flashing caret allowed
  118. UINT fDoubleClick:1; // mouse down in double click
  119. UINT fCaretOn:1; // if TRUE then caret is on
  120. UINT fAddSelMode:1; // if TRUE, then it is in ADD selection mode */
  121. UINT fHasStrings:1; // True if the listbox has a string associated
  122. // with each item else it has an app suppled LONG
  123. // value and is ownerdraw
  124. UINT fHasData:1; // if FALSE, then lb doesn't keep any line data
  125. // beyond selection state, but instead calls back
  126. // to the client for each line's definition.
  127. // Forces OwnerDraw==OWNERDRAWFIXED, !fSort,
  128. // and !fHasStrings.
  129. UINT fNewItemState:1;// select/deselect mode? for multiselection lb
  130. UINT fUseTabStops:1; // True if the non-ownerdraw listbox should handle tabstops
  131. UINT fMultiColumn:1; // True if this is a multicolumn listbox
  132. UINT fNoIntegralHeight:1; // True if we don't want to size the listbox
  133. // an integral lineheight
  134. UINT fWantKeyboardInput:1; // True if we should pass on WM_KEY & CHAR
  135. // so that the app can go to special items
  136. // with them.
  137. UINT fDisableNoScroll:1; // True if the listbox should
  138. // automatically Enable/disable
  139. // it's scroll bars. If false, the scroll
  140. // bars will be hidden/Shown automatically
  141. // if they are present.
  142. UINT fHorzBar:1; // TRUE if WS_HSCROLL specified at create time
  143. UINT fVertBar:1; // TRUE if WS_VSCROLL specified at create time
  144. UINT fFromInsert:1; // TRUE if client drawing should be deferred during delete/insert ops
  145. UINT fNoSel:1;
  146. UINT fHorzInitialized : 1; // Horz scroll cache initialized
  147. UINT fVertInitialized : 1; // Vert scroll cache initialized
  148. UINT fSized : 1; // Listbox was resized.
  149. UINT fIgnoreSizeMsg : 1; // If TRUE, ignore WM_SIZE message
  150. UINT fInitialized : 1;
  151. UINT fRightAlign:1; // used primarily for MidEast right align
  152. UINT fRtoLReading:1; // used only for MidEast, text rtol reading order
  153. UINT fSmoothScroll:1;// allow just one smooth-scroll per scroll cycle
  154. int xRightOrigin; // For horizontal scrolling. The current x origin
  155. INT iLastSelection; // Used for cancelable selection. Last selection
  156. // in listbox for combo box support
  157. INT iMouseDown; // For multiselection mouse click & drag extended
  158. // selection. It is the ANCHOR point for range selections
  159. INT iLastMouseMove; // selection of listbox items
  160. // IanJa/Win32: Tab positions remain int for 32-bit API ??
  161. LPINT iTabPixelPositions; // List of positions for tabs
  162. HANDLE hFont; // User settable font for listboxes
  163. int xOrigin; // For horizontal scrolling. The current x origin
  164. int maxWidth; // Maximum width of listbox in pixels for
  165. // horizontal scrolling purposes
  166. PCBOX pcbox; // Combo box pointer
  167. HDC hdc; // hdc currently in use
  168. DWORD dwLocaleId; // Locale used for sorting strings in list box
  169. int iTypeSearch;
  170. LPWSTR pszTypeSearch;
  171. SCROLLPOS HPos;
  172. SCROLLPOS VPos;
  173. } LBIV, *PLBIV;
  174. //
  175. // rgpch is set up as follows: First there are cMac 2 byte pointers to the
  176. // start of the strings in hStrings or if ownerdraw, it is 4 bytes of data
  177. // supplied by the app and hStrings is not used. Then if multiselection
  178. // listboxes, there are cMac 1 byte selection state bytes (one for each item
  179. // in the list box). If variable height owner draw, there will be cMac 1 byte
  180. // height bytes (once again, one for each item in the list box.).
  181. //
  182. // CHANGES DONE BY SANKAR:
  183. // The selection byte in rgpch is divided into two nibbles. The lower
  184. // nibble is the selection state (1 => Selected; 0 => de-selected)
  185. // and higher nibble is the display state(1 => Hilited and 0 => de-hilited).
  186. // You must be wondering why on earth we should store this selection state and
  187. // the display state seperately.Well! The reason is as follows:
  188. // While Ctrl+Dragging or Shift+Ctrl+Dragging, the user can adjust the
  189. // selection before the mouse button is up. If the user enlarges a range and
  190. // and before the button is up if he shrinks the range, then the old selection
  191. // state has to be preserved for the individual items that do not fall in the
  192. // range finally.
  193. // Please note that the display state and the selection state for an item
  194. // will be the same except when the user is dragging his mouse. When the mouse
  195. // is dragged, only the display state is updated so that the range is hilited
  196. // or de-hilited) but the selection state is preserved. Only when the button
  197. // goes up, for all the individual items in the range, the selection state is
  198. // made the same as the display state.
  199. //
  200. typedef struct tagLBItem
  201. {
  202. LONG offsz;
  203. ULONG_PTR itemData;
  204. } LBItem, *lpLBItem;
  205. typedef struct tagLBODItem
  206. {
  207. ULONG_PTR itemData;
  208. } LBODItem, *lpLBODItem;
  209. extern WORD DbcsCombine(HWND hwnd, WORD ch);
  210. extern VOID GetCharDimensions(HDC hDC, SIZE *psiz);
  211. //
  212. // Listbox function prototypes
  213. //
  214. extern LRESULT ListBox_WndProc(
  215. HWND hwnd,
  216. UINT msg,
  217. WPARAM wParam,
  218. LPARAM lParam);
  219. // in listbox.c
  220. LPWSTR GetLpszItem(PLBIV, INT);
  221. VOID ListBox_HSrollMultiColumn(PLBIV, INT, INT);
  222. INT ListBox_GetVarHeightItemHeight(PLBIV, INT);
  223. INT ListBox_VisibleItemsVarOwnerDraw(PLBIV, BOOL);
  224. INT ListBox_Page(PLBIV, INT, BOOL);
  225. INT ListBox_CalcVarITopScrollAmt(PLBIV, INT, INT);
  226. VOID ListBox_SetCItemFullMax(PLBIV);
  227. VOID ListBox_DoDeleteItems(PLBIV);
  228. void ListBox_InitHStrings(PLBIV);
  229. VOID ListBox_Event(PLBIV, UINT, int);
  230. // in listbox_ctl1.c
  231. int ListBox_SetScrollParms(PLBIV plb, int nCtl);
  232. VOID ListBox_ShowHideScrollBars(PLBIV);
  233. LONG_PTR ListBox_GetItemDataHandler(PLBIV, INT);
  234. INT ListBox_GetTextHandler(PLBIV, BOOL, BOOL, INT, LPWSTR);
  235. LONG ListBox_InitStorage(PLBIV plb, BOOL fAnsi, INT cItems, INT cb);
  236. int ListBox_InsertItem(PLBIV, LPWSTR, int, UINT);
  237. BOOL ListBox_ResetContentHandler(PLBIV plb);
  238. INT ListBox_DeleteStringHandler(PLBIV, INT);
  239. VOID ListBox_DeleteItem(PLBIV, INT);
  240. INT ListBox_SetCount(PLBIV, INT);
  241. // in listbox_ctl2.c
  242. BOOL ListBox_InvalidateRect(PLBIV plb, LPRECT lprc, BOOL fErase);
  243. HBRUSH ListBox_GetBrush(PLBIV plb, HBRUSH *phbrOld);
  244. BOOL ListBox_GetItemRectHandler(PLBIV, INT, LPRECT);
  245. VOID ListBox_SetCaret(PLBIV, BOOL);
  246. BOOL ListBox_IsSelected(PLBIV, INT, UINT);
  247. INT ListBox_CItemInWindow(PLBIV, BOOL);
  248. VOID ListBox_VScroll(PLBIV, INT, INT);
  249. VOID ListBox_HScroll(PLBIV, INT, INT);
  250. VOID ListBox_Paint(PLBIV, HDC, LPRECT);
  251. BOOL ListBox_ISelFromPt(PLBIV, POINT, LPDWORD);
  252. VOID ListBox_InvertItem(PLBIV, INT, BOOL);
  253. VOID ListBox_NotifyOwner(PLBIV, INT);
  254. VOID ListBox_SetISelBase(PLBIV, INT);
  255. VOID ListBox_TrackMouse(PLBIV, UINT, POINT);
  256. void ListBox_ButtonUp(PLBIV plb, UINT uFlags);
  257. VOID ListBox_NewITop(PLBIV, INT);
  258. VOID ListBox_InsureVisible(PLBIV, INT, BOOL);
  259. VOID ListBox_KeyInput(PLBIV, UINT, UINT);
  260. int Listbox_FindStringHandler(PLBIV, LPWSTR, INT, INT, BOOL);
  261. VOID ListBox_CharHandler(PLBIV, UINT, BOOL);
  262. INT ListBox_GetSelItemsHandler(PLBIV, BOOL, INT, LPINT);
  263. VOID ListBox_SetRedraw(PLBIV plb, BOOL fRedraw);
  264. VOID ListBox_SetRange(PLBIV, INT, INT, BOOL);
  265. INT ListBox_SetCurSelHandler(PLBIV, INT);
  266. int ListBox_SetItemDataHandler(PLBIV, INT, LONG_PTR);
  267. VOID ListBox_CheckRedraw(PLBIV, BOOL, INT);
  268. VOID ListBox_CaretDestroy(PLBIV);
  269. LONG ListBox_SetSelHandler(PLBIV, BOOL, INT);
  270. // in listbox_ctl3.c
  271. INT ListBox_DirHandler(PLBIV, UINT, LPWSTR);
  272. INT ListBox_InsertFile(PLBIV, LPWSTR);
  273. #endif // __LISTBOX_H__