Source code of Windows XP (NT5)
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.

698 lines
30 KiB

  1. // LISTVIEW PRIVATE DECLARATIONS
  2. #ifndef _INC_LISTVIEW
  3. #define _INC_LISTVIEW
  4. #include "selrange.h"
  5. #include <urlmon.h>
  6. #define COBJMACROS
  7. #include <iimgctx.h>
  8. //
  9. // Apps steal our userdata space so make sure we don't use it.
  10. //
  11. #undef GWLP_USERDATA
  12. #undef GWL_USERDATA
  13. // define this to get single click activate to activate immediately.
  14. // if a second click comes to the same window within a double-click-timeout
  15. // period, we blow it off. we try to keep focus on the app that launched,
  16. // but we can't figure out how to do that yet... with this not defined,
  17. // the single-click-activate waits a double-click-timeout before activating.
  18. //
  19. //#define ONECLICKHAPPENED
  20. // REVIEW: max items in a OWNERDATA listview
  21. // due to currently unknown reasons the listview will not handle much more
  22. // items than this. Since this number is very high, no time has yet been
  23. // spent on finding the reason(s).
  24. //
  25. #define MAX_LISTVIEWITEMS (100000000)
  26. #define CLIP_HEIGHT ( (plv->cyLabelChar * 2) + g_cyEdge)
  27. #define CLIP_HEIGHT_DI ( (plvdi->plv->cyLabelChar * 2) + g_cyEdge)
  28. // Timer IDs
  29. #define IDT_NAMEEDIT 42
  30. #define IDT_SCROLLWAIT 43
  31. #define IDT_MARQUEE 44
  32. #define IDT_ONECLICKOK 45
  33. #define IDT_ONECLICKHAPPENED 46
  34. //
  35. // use g_cxIconSpacing when you want the the global system metric
  36. // use lv_cxIconSpacing when you want the padded size of "icon" in a ListView
  37. //
  38. extern int g_cxIcon;
  39. extern int g_cyIcon;
  40. #define lv_cxIconSpacing plv->cxIconSpacing
  41. #define lv_cyIconSpacing plv->cyIconSpacing
  42. #define g_cxIconOffset ((g_cxIconSpacing - g_cxIcon) / 2)
  43. #define g_cyIconOffset (g_cyBorder * 2) // NOTE: Must be >= cyIconMargin!
  44. #define DT_LV (DT_CENTER | DT_SINGLELINE | DT_NOPREFIX | DT_EDITCONTROL)
  45. #define DT_LVWRAP (DT_CENTER | DT_WORDBREAK | DT_NOPREFIX | DT_EDITCONTROL)
  46. #define CCHLABELMAX MAX_PATH // BUGBUG dangerous???
  47. BOOL FAR ListView_Init(HINSTANCE hinst);
  48. LRESULT CALLBACK _export ListView_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  49. #define ListView_DefProc DefWindowProc
  50. typedef struct _IMAGE IMAGE;
  51. typedef struct _LISTITEM // li
  52. {
  53. LPTSTR pszText;
  54. POINT pt;
  55. short iImage;
  56. short cxSingleLabel;
  57. short cxMultiLabel;
  58. short cyFoldedLabel;
  59. short cyUnfoldedLabel;
  60. short iWorkArea; // Which workarea do I belong
  61. WORD state; // LVIS_*
  62. short iIndent;
  63. LPARAM lParam;
  64. // Region listview stuff
  65. HRGN hrgnIcon; // Region which describes the icon for this item
  66. POINT ptRgn; // Location that this item's hrgnIcon was calculated for
  67. RECT rcTextRgn;
  68. } LISTITEM;
  69. // Report view sub-item structure
  70. typedef struct _LISTSUBITEM
  71. {
  72. LPTSTR pszText;
  73. short iImage;
  74. WORD state;
  75. } LISTSUBITEM, *PLISTSUBITEM;
  76. #define COLUMN_VIEW
  77. #define LV_HDPA_GROW 16 // Grow chunk size for DPAs
  78. #define LV_HIML_GROW 8 // Grow chunk size for ImageLists
  79. typedef struct _LV
  80. {
  81. CONTROLINFO ci; // common control header info
  82. BOOL fNoDismissEdit:1; // don't dismiss in-place edit control
  83. BOOL fButtonDown:1; // we're tracking the mouse with a button down
  84. BOOL fOneClickOK:1; // true from creation to double-click-timeout
  85. BOOL fOneClickHappened:1; // true from item-activate to double-click-timeout
  86. BOOL fPlaceTooltip:1; // should we do the placement of tooltip over the text?
  87. BOOL fImgCtxComplete:1; // TRUE if we have complete bk image
  88. BOOL fNoEmptyText:1; // we don't have text for an empty view.
  89. HDPA hdpa; // item array structure
  90. DWORD flags; // LVF_ state bits
  91. DWORD exStyle; // the listview LVM_SETEXTENDEDSTYLE
  92. DWORD dwExStyle; // the windows ex style
  93. HFONT hfontLabel; // font to use for labels
  94. COLORREF clrBk; // Background color
  95. COLORREF clrBkSave; // Background color saved during disable
  96. COLORREF clrText; // text color
  97. COLORREF clrTextBk; // text background color
  98. HBRUSH hbrBk;
  99. HANDLE hheap; // The heap to use to allocate memory from.
  100. int cyLabelChar; // height of '0' in hfont
  101. int cxLabelChar; // width of '0'
  102. int cxEllipses; // width of "..."
  103. int iDrag; // index of item being dragged
  104. int iFocus; // index of currently-focused item
  105. int iMark; // index of "mark" for range selection
  106. int iItemDrawing; // item currently being drawn
  107. int iFirstChangedNoRedraw; // Index of first item added during no redraw.
  108. UINT stateCallbackMask; // item state callback mask
  109. SIZE sizeClient; // current client rectangle
  110. int nWorkAreas; // Number of workareas
  111. LPRECT prcWorkAreas; // The workarea rectangles -- nWorkAreas of them.
  112. UINT nSelected;
  113. UINT uDBCSChar; // DBCS character for incremental search
  114. int iPuntChar;
  115. HRGN hrgnInval;
  116. HWND hwndToolTips; // handle of the tooltip window for this view
  117. int iTTLastHit; // last item hit for text
  118. int iTTLastSubHit; // last subitem hit for text
  119. LPTSTR pszTip; // buffer for tip
  120. // Small icon view fields
  121. HIMAGELIST himlSmall; // small icons
  122. int cxSmIcon; // image list x-icon size
  123. int cySmIcon; // image list y-icon size
  124. int xOrigin; // Horizontal scroll posiiton
  125. int cxItem; // Width of small icon items
  126. int cyItem; // item height
  127. int cItemCol; // Number of items per column
  128. int cxIconSpacing;
  129. int cyIconSpacing;
  130. // Icon view fields
  131. HIMAGELIST himl;
  132. int cxIcon; // image list x-icon size
  133. int cyIcon; // image list y-icon size
  134. HDPA hdpaZOrder; // Large icon Z-order array
  135. POINT ptOrigin; // Scroll position
  136. RECT rcView; // Bounds of all icons (ptOrigin relative)
  137. int iFreeSlot; // Most-recently found free icon slot since last reposition (-1 if none)
  138. HWND hwndEdit; // edit field for edit-label-in-place
  139. int iEdit; // item being edited
  140. WNDPROC pfnEditWndProc; // edit field subclass proc
  141. NMITEMACTIVATE nmOneClickHappened;
  142. #define SMOOTHSCROLLLIMIT 10
  143. int iScrollCount; // how many times have we gotten scroll messages before an endscroll?
  144. // Report view fields
  145. int cCol;
  146. HDPA hdpaSubItems;
  147. HWND hwndHdr; // Header control
  148. int yTop; // First usable pixel (below header)
  149. int xTotalColumnWidth; // Total width of all columns
  150. POINTL ptlRptOrigin; // Origin of Report.
  151. int iSelCol; // to handle column width changing. changing col
  152. int iSelOldWidth; // to handle column width changing. changing col width
  153. int cyItemSave; // in ownerdrawfixed mode, we put the height into cyItem. use this to save the old value
  154. // state image stuff
  155. HIMAGELIST himlState;
  156. int cxState;
  157. int cyState;
  158. // OWNERDATA stuff
  159. ILVRange *plvrangeSel; // selection ranges
  160. ILVRange *plvrangeCut; // Cut Range
  161. int cTotalItems; // number of items in the ownerdata lists
  162. int iDropHilite; // which item is drop hilited, assume only 1
  163. int iMSAAMin, iMSAAMax; // keep track of what we told accessibility
  164. UINT uUnplaced; // items that have been added but not placed (pt.x == RECOMPUTE)
  165. int iHot; // which item is hot
  166. HFONT hFontHot; // the underlined font .. assume this has the same size metrics as hFont
  167. int iNoHover; // don't allow hover select on this guy because it's the one we just hover selected (avoids toggling)
  168. DWORD dwHoverTime; // Defaults to HOVER_DEFAULT
  169. HCURSOR hCurHot; // the cursor when we're over a hot item
  170. // BkImage stuff
  171. IImgCtx *pImgCtx; // Background image interface
  172. ULONG ulBkImageFlags; // LVBKIF_*
  173. HBITMAP hbmBkImage; // Background bitmap (LVBKIF_SOURCE_HBITMAP)
  174. LPTSTR pszBkImage; // Background URL (LVBKIF_SOURCE_URL)
  175. int xOffsetPercent; // X offset for LVBKIF_STYLE_NORMAL images
  176. int yOffsetPercent; // Y offset for LVBKIF_STYLE_NORMAL images
  177. HPALETTE hpalHalftone; // Palette for drawing bk images BUGBUG ImgCtx supposed to do this
  178. LPTSTR pszEmptyText; // buffer for empty view text.
  179. COLORREF clrHotlight; // Hot light color set explicitly for this listview.
  180. POINT ptCapture;
  181. //incremental search stuff
  182. ISEARCHINFO is;
  183. } LV;
  184. #define LV_StateImageValue(pitem) ((int)(((DWORD)((pitem)->state) >> 12) & 0xF))
  185. #define LV_StateImageIndex(pitem) (LV_StateImageValue(pitem) - 1)
  186. // listview flag values
  187. #define LVF_FOCUSED 0x0001
  188. #define LVF_VISIBLE 0x0002
  189. #define LVF_ERASE 0x0004 /* is hrgnInval to be erased? */
  190. #define LVF_NMEDITPEND 0x0008
  191. #define LVF_REDRAW 0x0010 /* Value from WM_SETREDRAW message */
  192. #define LVF_ICONPOSSML 0x0020 /* X, Y coords are in small icon view */
  193. #define LVF_INRECOMPUTE 0x0040 /* Check to make sure we are not recursing */
  194. #define LVF_UNFOLDED 0x0080
  195. #define LVF_FONTCREATED 0x0100 /* we created the LV font */
  196. #define LVF_SCROLLWAIT 0x0200 /* we're waiting to scroll */
  197. #define LVF_COLSIZESET 0x0400 /* Has the caller explictly set width for list view */
  198. #define LVF_USERBKCLR 0x0800 /* user set the bk color (don't follow syscolorchange) */
  199. #define LVF_ICONSPACESET 0x1000 /* the user has set the icon spacing */
  200. #define LVF_CUSTOMFONT 0x2000 /* there is at least one item with a custom font */
  201. #if defined(FE_IME) || !defined(WINNT)
  202. #define LVF_DONTDRAWCOMP 0x4000 /* do not draw IME composition if true */
  203. #define LVF_INSERTINGCOMP 0x8000 /* Avoid recursion */
  204. #endif
  205. #define LVF_INRECALCREGION 0x00010000 /* prevents recursion in RecalcRegion */
  206. #define ENTIRE_REGION 1
  207. // listview DrawItem flags
  208. #define LVDI_NOIMAGE 0x0001 // don't draw image
  209. #define LVDI_TRANSTEXT 0x0002 // draw text transparently in black
  210. #define LVDI_NOWAYFOCUS 0x0004 // don't allow focus to drawing
  211. #define LVDI_FOCUS 0x0008 // focus is set (for drawing)
  212. #define LVDI_SELECTED 0x0010 // draw selected text
  213. #define LVDI_SELECTNOFOCUS 0x0020
  214. #define LVDI_HOTSELECTED 0x0040
  215. #define LVDI_UNFOLDED 0x0080 // draw the item umfolded (forced)
  216. typedef struct {
  217. LV* plv;
  218. LPPOINT lpptOrg;
  219. LPRECT prcClip;
  220. UINT flags;
  221. LISTITEM FAR* pitem;
  222. DWORD dwCustom;
  223. NMLVCUSTOMDRAW nmcd;
  224. } LVDRAWITEM, *PLVDRAWITEM;
  225. // listview child control ids
  226. #define LVID_HEADER 0
  227. // Instance data pointer access functions
  228. #define ListView_GetPtr(hwnd) (LV*)GetWindowPtr(hwnd, 0)
  229. #define ListView_SetPtr(hwnd, p) (LV*)SetWindowPtr(hwnd, 0, p)
  230. // view type check functions
  231. #define ListView_IsIconView(plv) (((plv)->ci.style & (UINT)LVS_TYPEMASK) == (UINT)LVS_ICON)
  232. #define ListView_IsSmallView(plv) (((plv)->ci.style & (UINT)LVS_TYPEMASK) == (UINT)LVS_SMALLICON)
  233. #define ListView_IsListView(plv) (((plv)->ci.style & (UINT)LVS_TYPEMASK) == (UINT)LVS_LIST)
  234. #define ListView_IsReportView(plv) (((plv)->ci.style & (UINT)LVS_TYPEMASK) == (UINT)LVS_REPORT)
  235. #define ListView_IsOwnerData( plv ) (plv->ci.style & (UINT)LVS_OWNERDATA)
  236. #define ListView_CheckBoxes(plv) (plv->exStyle & LVS_EX_CHECKBOXES)
  237. #define ListView_FullRowSelect(plv) (plv->exStyle & LVS_EX_FULLROWSELECT)
  238. #define ListView_IsInfoTip(plv) (plv->exStyle & LVS_EX_INFOTIP)
  239. #define ListView_OwnerDraw(plv) (plv->ci.style & LVS_OWNERDRAWFIXED)
  240. #define ListView_IsLabelTip(plv) (plv->exStyle & LVS_EX_LABELTIP)
  241. // Some helper macros for checking some of the flags...
  242. #define ListView_RedrawEnabled(plv) ((plv->flags & (LVF_REDRAW | LVF_VISIBLE)) == (LVF_REDRAW|LVF_VISIBLE))
  243. // The hdpaZorder is acutally an array of DWORDS which contains the
  244. // indexes of the items and not actual pointers...
  245. // NOTE: linear search! this can be slow
  246. #define ListView_ZOrderIndex(plv, i) DPA_GetPtrIndex((plv)->hdpaZOrder, IntToPtr(i))
  247. // Message handler functions (listview.c):
  248. LRESULT CALLBACK _export ListView_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  249. BOOL NEAR ListView_NotifyCacheHint( LV* plv, int iFrom, int iTo );
  250. void NEAR ListView_NotifyRecreate(LV *plv);
  251. BOOL NEAR ListView_OnCreate(LV* plv, CREATESTRUCT FAR* lpCreateStruct);
  252. void NEAR ListView_OnNCDestroy(LV* plv);
  253. void NEAR ListView_OnPaint(LV* plv, HDC hdc);
  254. BOOL NEAR ListView_OnEraseBkgnd(LV* plv, HDC hdc);
  255. void NEAR ListView_OnCommand(LV* plv, int id, HWND hwndCtl, UINT codeNotify);
  256. void NEAR ListView_OnEnable(LV* plv, BOOL fEnable);
  257. BOOL NEAR ListView_OnWindowPosChanging(LV* plv, WINDOWPOS FAR* lpwpos);
  258. void NEAR ListView_OnWindowPosChanged(LV* plv, const WINDOWPOS FAR* lpwpos);
  259. void NEAR ListView_OnSetFocus(LV* plv, HWND hwndOldFocus);
  260. void NEAR ListView_OnKillFocus(LV* plv, HWND hwndNewFocus);
  261. void NEAR ListView_OnKey(LV* plv, UINT vk, BOOL fDown, int cRepeat, UINT flags);
  262. BOOL NEAR ListView_OnImeComposition(LV* plv, WPARAM wParam, LPARAM lParam);
  263. #ifndef UNICODE
  264. BOOL FAR PASCAL SameDBCSChars(LPTSTR lpsz, WORD w);
  265. #endif
  266. void NEAR ListView_OnChar(LV* plv, UINT ch, int cRepeat);
  267. void NEAR ListView_OnButtonDown(LV* plv, BOOL fDoubleClick, int x, int y, UINT keyFlags);
  268. void NEAR ListView_OnLButtonUp(LV* plv, int x, int y, UINT keyFlags);
  269. void NEAR ListView_OnCancelMode(LV* plv);
  270. void NEAR ListView_OnTimer(LV* plv, UINT id);
  271. void NEAR ListView_SetupPendingNameEdit(LV* plv);
  272. #define ListView_CancelPendingEdit(plv) ListView_CancelPendingTimer(plv, LVF_NMEDITPEND, IDT_NAMEEDIT)
  273. #define ListView_CancelScrollWait(plv) ListView_CancelPendingTimer(plv, LVF_SCROLLWAIT, IDT_SCROLLWAIT)
  274. BOOL NEAR ListView_CancelPendingTimer(LV* plv, UINT fFlag, int idTimer);
  275. void NEAR ListView_OnHScroll(LV* plv, HWND hwndCtl, UINT code, int pos);
  276. void NEAR ListView_OnVScroll(LV* plv, HWND hwndCtl, UINT code, int pos);
  277. BOOL NEAR ListView_CommonArrange(LV* plv, UINT style, HDPA hdpaSort);
  278. BOOL NEAR ListView_CommonArrangeEx(LV* plv, UINT style, HDPA hdpaSort, int iWorkArea);
  279. BOOL NEAR ListView_OnSetCursor(LV* plv, HWND hwndCursor, UINT codeHitTest, UINT msg);
  280. UINT NEAR ListView_OnGetDlgCode(LV* plv, MSG FAR* lpmsg);
  281. HBRUSH NEAR ListView_OnCtlColor(LV* plv, HDC hdc, HWND hwndChild, int type);
  282. void NEAR ListView_OnSetFont(LV* plvCtl, HFONT hfont, BOOL fRedraw);
  283. HFONT NEAR ListView_OnGetFont(LV* plv);
  284. void NEAR ListViews_OnTimer(LV* plv, UINT id);
  285. void NEAR ListView_OnWinIniChange(LV* plv, WPARAM wParam, LPARAM lParam);
  286. void NEAR PASCAL ListView_OnSysColorChange(LV* plv);
  287. void NEAR ListView_OnSetRedraw(LV* plv, BOOL fRedraw);
  288. HIMAGELIST NEAR ListView_OnCreateDragImage(LV *plv, int iItem, LPPOINT lpptUpLeft);
  289. BOOL FAR PASCAL ListView_ISetColumnWidth(LV* plv, int iCol, int cx, BOOL fExplicit);
  290. typedef void (FAR PASCAL *SCROLLPROC)(LV*, int dx, int dy, UINT uSmooth);
  291. void FAR PASCAL ListView_ComOnScroll(LV* plv, UINT code, int posNew, int sb,
  292. int cLine, int cPage);
  293. #ifdef UNICODE
  294. BOOL NEAR ListView_OnGetItemA(LV* plv, LV_ITEMA FAR* plvi);
  295. BOOL NEAR ListView_OnSetItemA(LV* plv, LV_ITEMA FAR* plvi);
  296. int NEAR ListView_OnInsertItemA(LV* plv, LV_ITEMA FAR* plvi);
  297. int NEAR ListView_OnFindItemA(LV* plv, int iStart, LV_FINDINFOA FAR* plvfi);
  298. int NEAR ListView_OnGetStringWidthA(LV* plv, LPCSTR psz, HDC hdc);
  299. BOOL NEAR ListView_OnGetColumnA(LV* plv, int iCol, LV_COLUMNA FAR* pcol);
  300. BOOL NEAR ListView_OnSetColumnA(LV* plv, int iCol, LV_COLUMNA FAR* pcol);
  301. int NEAR ListView_OnInsertColumnA(LV* plv, int iCol, LV_COLUMNA FAR* pcol);
  302. int NEAR PASCAL ListView_OnGetItemTextA(LV* plv, int i, LV_ITEMA FAR *lvitem);
  303. BOOL WINAPI ListView_OnSetItemTextA(LV* plv, int i, int iSubItem, LPCSTR pszText);
  304. BOOL WINAPI ListView_OnGetBkImageA(LV* plv, LPLVBKIMAGEA pbiA);
  305. BOOL WINAPI ListView_OnSetBkImageA(LV* plv, LPLVBKIMAGEA pbiA);
  306. #endif
  307. BOOL ListView_IsItemUnfolded2(LV* plv, int iItem, int iSubItem, LPTSTR pszText, int cchTextMax);
  308. BOOL WINAPI ListView_OnSetBkImage(LV* plv, LPLVBKIMAGE pbi);
  309. BOOL WINAPI ListView_OnGetBkImage(LV* plv, LPLVBKIMAGE pbi);
  310. BOOL NEAR ListView_OnSetBkColor(LV* plv, COLORREF clrBk);
  311. HIMAGELIST NEAR ListView_OnSetImageList(LV* plv, HIMAGELIST himl, BOOL fSmallImages);
  312. BOOL NEAR ListView_OnDeleteAllItems(LV* plv);
  313. int NEAR ListView_OnInsertItem(LV* plv, const LV_ITEM FAR* plvi);
  314. BOOL NEAR ListView_OnDeleteItem(LV* plv, int i);
  315. BOOL NEAR ListView_OnReplaceItem(LV* plv, const LV_ITEM FAR* plvi);
  316. int NEAR ListView_OnFindItem(LV* plv, int iStart, const LV_FINDINFO FAR* plvfi);
  317. BOOL NEAR ListView_OnSetItemPosition(LV* plv, int i, int x, int y);
  318. BOOL NEAR ListView_OnSetItem(LV* plv, const LV_ITEM FAR* plvi);
  319. BOOL NEAR ListView_OnGetItem(LV* plv, LV_ITEM FAR* plvi);
  320. BOOL NEAR ListView_OnGetItemPosition(LV* plv, int i, POINT FAR* ppt);
  321. BOOL NEAR ListView_OnEnsureVisible(LV* plv, int i, BOOL fPartialOK);
  322. BOOL NEAR ListView_OnScroll(LV* plv, int dx, int dy);
  323. int NEAR ListView_OnHitTest(LV* plv, LV_HITTESTINFO FAR* pinfo);
  324. int NEAR ListView_OnGetStringWidth(LV* plv, LPCTSTR psz, HDC hdc);
  325. BOOL NEAR ListView_OnGetItemRect(LV* plv, int i, RECT FAR* prc);
  326. int NEAR ListView_OnInsertItem(LV* plv, const LV_ITEM FAR* plvi);
  327. BOOL NEAR ListView_OnRedrawItems(LV* plv, int iFirst, int iLast);
  328. int NEAR ListView_OnGetNextItem(LV* plv, int i, UINT flags);
  329. BOOL NEAR ListView_OnSetColumnWidth(LV* plv, int iCol, int cx);
  330. int NEAR ListView_OnGetColumnWidth(LV* plv, int iCol);
  331. void NEAR ListView_OnStyleChanging(LV* plv, UINT gwl, LPSTYLESTRUCT pinfo);
  332. void NEAR ListView_OnStyleChanged(LV* plv, UINT gwl, LPSTYLESTRUCT pinfo);
  333. int NEAR ListView_OnGetTopIndex(LV* plv);
  334. int NEAR ListView_OnGetCountPerPage(LV* plv);
  335. BOOL NEAR ListView_OnGetOrigin(LV* plv, POINT FAR* ppt);
  336. int NEAR PASCAL ListView_OnGetItemText(LV* plv, int i, LV_ITEM FAR *lvitem);
  337. BOOL WINAPI ListView_OnSetItemText(LV* plv, int i, int iSubItem, LPCTSTR pszText);
  338. HIMAGELIST NEAR ListView_OnGetImageList(LV* plv, int iImageList);
  339. UINT NEAR PASCAL ListView_OnGetItemState(LV* plv, int i, UINT mask);
  340. BOOL NEAR PASCAL ListView_OnSetItemState(LV* plv, int i, UINT data, UINT mask);
  341. // Private functions (listview.c):
  342. BOOL NEAR ListView_Notify(LV* plv, int i, int iSubItem, int code);
  343. void NEAR ListView_GetRects(LV* plv, int i,
  344. RECT FAR* prcIcon, RECT FAR* prcLabel,
  345. RECT FAR* prcBounds, RECT FAR* prcSelectBounds);
  346. BOOL NEAR ListView_DrawItem(PLVDRAWITEM);
  347. #define ListView_InvalidateItem(p,i,s,r) ListView_InvalidateItemEx(p,i,s,r,0)
  348. void NEAR ListView_InvalidateItemEx(LV* plv, int i, BOOL fSelectionOnly,
  349. UINT fRedraw, UINT maskChanged);
  350. BOOL NEAR ListView_StartDrag(LV* plv, int iDrag, int x, int y);
  351. void NEAR ListView_TypeChange(LV* plv, DWORD styleOld);
  352. void NEAR PASCAL ListView_DeleteHrgnInval(LV* plv);
  353. void NEAR ListView_Redraw(LV* plv, HDC hdc, RECT FAR* prc);
  354. void NEAR ListView_RedrawSelection(LV* plv);
  355. BOOL NEAR ListView_FreeItem(LV* plv, LISTITEM FAR* pitem);
  356. void ListView_FreeSubItem(PLISTSUBITEM plsi);
  357. LISTITEM FAR* NEAR ListView_CreateItem(LV* plv, const LV_ITEM FAR* plvi);
  358. void NEAR ListView_UpdateScrollBars(LV* plv);
  359. int NEAR ListView_SetFocusSel(LV* plv, int iNewFocus, BOOL fSelect, BOOL fDeselectAll, BOOL fToggleSel);
  360. void NEAR ListView_GetRectsOwnerData(LV* plv, int iItem,
  361. RECT FAR* prcIcon, RECT FAR* prcLabel, RECT FAR* prcBounds,
  362. RECT FAR* prcSelectBounds, LISTITEM* pitem);
  363. void ListView_CalcMinMaxIndex( LV* plv, PRECT prcBounding, int* iMin, int* iMax );
  364. int ListView_LCalcViewItem( LV* plv, int x, int y );
  365. void LVSeeThruScroll(LV *plv, LPRECT lprcUpdate);
  366. BOOL NEAR ListView_UnfoldRects(LV* plv, int iItem,
  367. RECT FAR* prcIcon, RECT FAR* prcLabel,
  368. RECT FAR* prcBounds, RECT FAR* prcSelectBounds);
  369. __inline int ListView_Count(LV *plv)
  370. {
  371. ASSERT(ListView_IsOwnerData(plv) || plv->cTotalItems == DPA_GetPtrCount(plv->hdpa));
  372. return plv->cTotalItems;
  373. }
  374. // Forcing (i) to UINT lets us catch bogus negative numbers, too.
  375. #define ListView_IsValidItemNumber(plv, i) ((UINT)(i) < (UINT)ListView_Count(plv))
  376. #define ListView_GetItemPtr(plv, i) ((LISTITEM FAR*)DPA_GetPtr((plv)->hdpa, (i)))
  377. #ifdef DEBUG
  378. #define ListView_FastGetItemPtr(plv, i) ((LISTITEM FAR*)DPA_GetPtr((plv)->hdpa, (i)))
  379. #define ListView_FastGetZItemPtr(plv, i) ((LISTITEM FAR*)DPA_GetPtr((plv)->hdpa, \
  380. (int)OFFSETOF(DPA_GetPtr((plv)->hdpaZOrder, (i)))))
  381. #else
  382. #define ListView_FastGetItemPtr(plv, i) ((LISTITEM FAR*)DPA_FastGetPtr((plv)->hdpa, (i)))
  383. #define ListView_FastGetZItemPtr(plv, i) ((LISTITEM FAR*)DPA_FastGetPtr((plv)->hdpa, \
  384. (int)OFFSETOF(DPA_FastGetPtr((plv)->hdpaZOrder, (i)))))
  385. #endif
  386. BOOL NEAR ListView_CalcMetrics();
  387. void NEAR PASCAL ListView_ColorChange();
  388. void NEAR PASCAL ListView_DrawBackground(LV* plv, HDC hdc, RECT *prcClip);
  389. BOOL NEAR ListView_NeedsEllipses(HDC hdc, LPCTSTR pszText, RECT FAR* prc, int FAR* pcchDraw, int cxEllipses);
  390. int NEAR ListView_CompareString(LV* plv, int i, LPCTSTR pszFind, UINT flags, int iLen);
  391. int NEAR ListView_GetLinkedTextWidth(HDC hdc, LPCTSTR psz, UINT cch, BOOL bLink);
  392. int NEAR ListView_GetCxScrollbar(LV* plv);
  393. int NEAR ListView_GetCyScrollbar(LV* plv);
  394. DWORD NEAR ListView_GetWindowStyle(LV* plv);
  395. #define ListView_GetScrollInfo(plv, flag, lpsi) \
  396. ((plv)->exStyle & LVS_EX_FLATSB ? \
  397. FlatSB_GetScrollInfo((plv)->ci.hwnd, (flag), (lpsi)) : \
  398. GetScrollInfo((plv)->ci.hwnd, (flag), (lpsi)))
  399. int ListView_SetScrollInfo(LV *plv, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw);
  400. #define ListView_SetScrollRange(plv, flag, min, max, fredraw) \
  401. ((plv)->exStyle & LVS_EX_FLATSB ? \
  402. FlatSB_SetScrollRange((plv)->ci.hwnd, (flag), (min), (max), (fredraw)) : \
  403. SetScrollRange((plv)->ci.hwnd, (flag), (min), (max), (fredraw)))
  404. // lvicon.c functions
  405. BOOL NEAR ListView_OnArrange(LV* plv, UINT style);
  406. HWND NEAR ListView_OnEditLabel(LV* plv, int i, LPTSTR pszText);
  407. int ListView_IItemHitTest(LV* plv, int x, int y, UINT FAR* pflags, int *piSubItem);
  408. void NEAR ListView_IGetRects(LV* plv, LISTITEM FAR* pitem, RECT FAR* prcIcon,
  409. RECT FAR* prcLabel, LPRECT prcBounds);
  410. void NEAR ListView_ScaleIconPositions(LV* plv, BOOL fSmallIconView);
  411. void NEAR ListView_IGetRectsOwnerData(LV* plv, int iItem, RECT FAR* prcIcon,
  412. RECT FAR* prcLabel, LISTITEM* pitem, BOOL fUsepitem);
  413. void NEAR PASCAL _ListView_GetRectsFromItem(LV* plv, BOOL bSmallIconView,
  414. LISTITEM FAR *pitem,
  415. LPRECT prcIcon, LPRECT prcLabel, LPRECT prcBounds, LPRECT prcSelectBounds);
  416. __inline void ListView_SetSRecompute(LISTITEM *pitem)
  417. {
  418. pitem->cxSingleLabel = SRECOMPUTE;
  419. pitem->cxMultiLabel = SRECOMPUTE;
  420. pitem->cyFoldedLabel = SRECOMPUTE;
  421. pitem->cyUnfoldedLabel = SRECOMPUTE;
  422. }
  423. void NEAR ListView_Recompute(LV* plv);
  424. void NEAR ListView_RecomputeLabelSize(LV* plv, LISTITEM FAR* pitem, int i, HDC hdc, BOOL fUsepitem);
  425. BOOL NEAR ListView_SetIconPos(LV* plv, LISTITEM FAR* pitem, int iSlot, int cSlot);
  426. BOOL NEAR ListView_IsCleanRect(LV * plv, RECT * prc, int iExcept, BOOL * pfUpdate, HDC hdc);
  427. int NEAR ListView_FindFreeSlot(LV* plv, int i, int iSlot, int cSlot, BOOL FAR* pfUpdateSB, BOOL FAR* pfAppend, HDC hdc);
  428. int NEAR ListView_CalcHitSlot( LV* plv, POINT pt, int cslot );
  429. void NEAR ListView_GetViewRect2(LV* plv, RECT FAR* prcView, int cx, int cy);
  430. int CALLBACK ArrangeIconCompare(LISTITEM FAR* pitem1, LISTITEM FAR* pitem2, LPARAM lParam);
  431. int NEAR ListView_GetSlotCountEx(LV* plv, BOOL fWithoutScroll, int iWorkArea);
  432. int NEAR ListView_GetSlotCount(LV* plv, BOOL fWithoutScroll);
  433. void NEAR ListView_IUpdateScrollBars(LV* plv);
  434. DWORD NEAR ListView_GetClientRect(LV* plv, RECT FAR* prcClient, BOOL fSubScrolls, RECT FAR *prcViewRect);
  435. void NEAR ListView_SetEditSize(LV* plv);
  436. BOOL NEAR ListView_DismissEdit(LV* plv, BOOL fCancel);
  437. LRESULT CALLBACK _export ListView_EditWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  438. UINT NEAR PASCAL ListView_DrawImageEx(LV* plv, LV_ITEM FAR* pitem, HDC hdc, int x, int y, UINT fDraw, int xMax);
  439. #define ListView_DrawImage(plv, pitem, hdc, x, y, fDraw) \
  440. ListView_DrawImageEx(plv, pitem, hdc, x, y, fDraw, -1)
  441. #if defined(FE_IME) || !defined(WINNT)
  442. void NEAR PASCAL ListView_SizeIME(HWND hwnd);
  443. void NEAR PASCAL ListView_InsertComposition(HWND hwnd, WPARAM wParam, LPARAM lParam, LV *plv);
  444. void NEAR PASCAL ListView_PaintComposition(HWND hwnd, LV *plv);
  445. #endif
  446. // lvsmall.c functions:
  447. void NEAR ListView_SGetRects(LV* plv, LISTITEM FAR* pitem, RECT FAR* prcIcon,
  448. RECT FAR* prcLabel, LPRECT prcBounds);
  449. void NEAR ListView_SGetRectsOwnerData(LV* plv, int iItem, RECT FAR* prcIcon,
  450. RECT FAR* prcLabel, LISTITEM* pitem, BOOL fUsepitem);
  451. int ListView_SItemHitTest(LV* plv, int x, int y, UINT FAR* pflags, int *piSubItem);
  452. int NEAR ListView_LookupString(LV* plv, LPCTSTR lpszLookup, UINT flags, int iStart);
  453. // lvlist.c functions:
  454. void NEAR ListView_LGetRects(LV* plv, int i, RECT FAR* prcIcon,
  455. RECT FAR* prcLabel, RECT FAR *prcBounds, RECT FAR* prcSelectBounds);
  456. int ListView_LItemHitTest(LV* plv, int x, int y, UINT FAR* pflags, int *piSubItem);
  457. void NEAR ListView_LUpdateScrollBars(LV* plv);
  458. BOOL FAR PASCAL ListView_MaybeResizeListColumns(LV* plv, int iFirst, int iLast);
  459. // lvrept.c functions:
  460. int ListView_OnSubItemHitTest(LV* plv, LPLVHITTESTINFO lParam);
  461. void ListView_GetSubItem(LV* plv, int i, int iSubItem, PLISTSUBITEM plsi);
  462. BOOL LV_ShouldItemDrawGray(LV* plv, UINT fText);
  463. int NEAR ListView_OnInsertColumn(LV* plv, int iCol, const LV_COLUMN FAR* pcol);
  464. BOOL NEAR ListView_OnDeleteColumn(LV* plv, int iCol);
  465. BOOL NEAR ListView_OnGetColumn(LV* plv, int iCol, LV_COLUMN FAR* pcol);
  466. BOOL NEAR ListView_OnSetColumn(LV* plv, int iCol, const LV_COLUMN FAR* pcol);
  467. BOOL NEAR ListView_ROnEnsureVisible(LV* plv, int i, BOOL fPartialOK);
  468. void NEAR PASCAL ListView_RInitialize(LV* plv, BOOL fInval);
  469. BOOL ListView_OnGetSubItemRect(LV* plv, int i, LPRECT lprc);
  470. #define ListView_RYHitTest(plv, cy) ((int)(((cy) + plv->ptlRptOrigin.y - plv->yTop) / plv->cyItem))
  471. BOOL NEAR ListView_SetSubItem(LV* plv, const LV_ITEM FAR* plvi);
  472. void NEAR PASCAL ListView_RAfterRedraw(LV* plv, HDC hdc);
  473. int NEAR ListView_RGetColumnWidth(LV* plv, int iCol);
  474. BOOL NEAR ListView_RSetColumnWidth(LV* plv, int iCol, int cx);
  475. LPTSTR NEAR ListView_GetSubItemText(LV* plv, int i, int iCol);
  476. void NEAR ListView_RDestroy(LV* plv);
  477. LPTSTR NEAR ListView_RGetItemText(LV* plv, int i, int iCol);
  478. int ListView_RItemHitTest(LV* plv, int x, int y, UINT FAR* pflags, int *piSubItem);
  479. void NEAR ListView_RUpdateScrollBars(LV* plv);
  480. void NEAR ListView_RGetRects(LV* plv, int iItem, RECT FAR* prcIcon,
  481. RECT FAR* prcLabel, RECT FAR* prcBounds, RECT FAR* prcSelectBounds);
  482. LRESULT ListView_HeaderNotify(LV* plv, HD_NOTIFY *pnm);
  483. int NEAR ListView_FreeColumnData(LPVOID d, LPVOID p);
  484. BOOL FAR PASCAL SameChars(LPTSTR lpsz, TCHAR c);
  485. #define ListView_GetSubItemDPA(plv, idpa) \
  486. ((HDPA)DPA_GetPtr((plv)->hdpaSubItems, (idpa)))
  487. int NEAR ListView_Arrow(LV* plv, int iStart, UINT vk);
  488. BOOL ListView_IsItemUnfolded(LV *plv, int item);
  489. BOOL ListView_IsItemUnfoldedPtr(LV *plv, LISTITEM *pitem);
  490. // Fake customdraw. See comment block in lvrept.c
  491. typedef struct LVFAKEDRAW {
  492. NMLVCUSTOMDRAW nmcd;
  493. LV* plv;
  494. DWORD dwCustomPrev;
  495. DWORD dwCustomItem;
  496. DWORD dwCustomSubItem;
  497. LV_ITEM *pitem;
  498. HFONT hfontPrev;
  499. } LVFAKEDRAW, *PLVFAKEDRAW;
  500. void ListView_BeginFakeCustomDraw(LV* plv, PLVFAKEDRAW plvfd, LV_ITEM *pitem);
  501. DWORD ListView_BeginFakeItemDraw(PLVFAKEDRAW plvfd);
  502. void ListView_EndFakeItemDraw(PLVFAKEDRAW plvfd);
  503. void ListView_EndFakeCustomDraw(PLVFAKEDRAW plvfd);
  504. //============ External declarations =======================================
  505. //extern HFONT g_hfontLabel;
  506. extern HBRUSH g_hbrActiveLabel;
  507. extern HBRUSH g_hbrInactiveLabel;
  508. extern HBRUSH g_hbrBackground;
  509. // function tables
  510. #define LV_TYPEINDEX(plv) ((plv)->ci.style & (UINT)LVS_TYPEMASK)
  511. BOOL ListView_RDrawItem(PLVDRAWITEM);
  512. BOOL ListView_IDrawItem(PLVDRAWITEM);
  513. BOOL ListView_LDrawItem(PLVDRAWITEM);
  514. typedef BOOL (*PFNLISTVIEW_DRAWITEM)(PLVDRAWITEM);
  515. extern const PFNLISTVIEW_DRAWITEM pfnListView_DrawItem[4];
  516. #define _ListView_DrawItem(plvdi) \
  517. pfnListView_DrawItem[LV_TYPEINDEX(plvdi->plv)](plvdi)
  518. void NEAR ListView_RUpdateScrollBars(LV* plv);
  519. typedef void (*PFNLISTVIEW_UPDATESCROLLBARS)(LV* plv);
  520. extern const PFNLISTVIEW_UPDATESCROLLBARS pfnListView_UpdateScrollBars[4];
  521. #define _ListView_UpdateScrollBars(plv) \
  522. pfnListView_UpdateScrollBars[LV_TYPEINDEX(plv)](plv)
  523. typedef DWORD (*PFNLISTVIEW_APPROXIMATEVIEWRECT)(LV* plv, int, int, int);
  524. extern const PFNLISTVIEW_APPROXIMATEVIEWRECT pfnListView_ApproximateViewRect[4];
  525. #define _ListView_ApproximateViewRect(plv, iCount, iWidth, iHeight) \
  526. pfnListView_ApproximateViewRect[LV_TYPEINDEX(plv)](plv, iCount, iWidth, iHeight)
  527. typedef int (*PFNLISTVIEW_ITEMHITTEST)(LV* plv, int, int, UINT FAR *, int *);
  528. extern const PFNLISTVIEW_ITEMHITTEST pfnListView_ItemHitTest[4];
  529. #define _ListView_ItemHitTest(plv, x, y, pflags, piSubItem) \
  530. pfnListView_ItemHitTest[LV_TYPEINDEX(plv)](plv, x, y, pflags, piSubItem)
  531. void ListView_IOnScroll(LV* plv, UINT code, int posNew, UINT fVert);
  532. void ListView_LOnScroll(LV* plv, UINT code, int posNew, UINT sb);
  533. void ListView_ROnScroll(LV* plv, UINT code, int posNew, UINT sb);
  534. typedef void (*PFNLISTVIEW_ONSCROLL)(LV* plv, UINT, int, UINT );
  535. extern const PFNLISTVIEW_ONSCROLL pfnListView_OnScroll[4];
  536. #define _ListView_OnScroll(plv, x, y, pflags) \
  537. pfnListView_OnScroll[LV_TYPEINDEX(plv)](plv, x, y, pflags)
  538. void ListView_Scroll2(LV* plv, int dx, int dy);
  539. void ListView_IScroll2(LV* plv, int dx, int dy, UINT uSmooth);
  540. void ListView_LScroll2(LV* plv, int dx, int dy, UINT uSmooth);
  541. void ListView_RScroll2(LV* plv, int dx, int dy, UINT uSmooth);
  542. typedef void (*PFNLISTVIEW_SCROLL2)(LV* plv, int, int, UINT );
  543. extern const PFNLISTVIEW_SCROLL2 pfnListView_Scroll2[4];
  544. #define _ListView_Scroll2(plv, x, y, pflags) \
  545. pfnListView_Scroll2[LV_TYPEINDEX(plv)](plv, x, y, pflags)
  546. int ListView_IGetScrollUnitsPerLine(LV* plv, UINT sb);
  547. int ListView_LGetScrollUnitsPerLine(LV* plv, UINT sb);
  548. int ListView_RGetScrollUnitsPerLine(LV* plv, UINT sb);
  549. typedef int (*PFNLISTVIEW_GETSCROLLUNITSPERLINE)(LV* plv, UINT sb);
  550. extern const PFNLISTVIEW_GETSCROLLUNITSPERLINE pfnListView_GetScrollUnitsPerLine[4];
  551. #define _ListView_GetScrollUnitsPerLine(plv, sb) \
  552. pfnListView_GetScrollUnitsPerLine[LV_TYPEINDEX(plv)](plv, sb)
  553. #define LVMI_PLACEITEMS (WM_USER)
  554. #endif //!_INC_LISTVIEW