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.

692 lines
31 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)
  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. void NEAR ListView_OnChar(LV* plv, UINT ch, int cRepeat);
  264. void NEAR ListView_OnButtonDown(LV* plv, BOOL fDoubleClick, int x, int y, UINT keyFlags);
  265. void NEAR ListView_OnLButtonUp(LV* plv, int x, int y, UINT keyFlags);
  266. void NEAR ListView_OnCancelMode(LV* plv);
  267. void NEAR ListView_OnTimer(LV* plv, UINT id);
  268. void NEAR ListView_SetupPendingNameEdit(LV* plv);
  269. #define ListView_CancelPendingEdit(plv) ListView_CancelPendingTimer(plv, LVF_NMEDITPEND, IDT_NAMEEDIT)
  270. #define ListView_CancelScrollWait(plv) ListView_CancelPendingTimer(plv, LVF_SCROLLWAIT, IDT_SCROLLWAIT)
  271. BOOL NEAR ListView_CancelPendingTimer(LV* plv, UINT fFlag, int idTimer);
  272. void NEAR ListView_OnHScroll(LV* plv, HWND hwndCtl, UINT code, int pos);
  273. void NEAR ListView_OnVScroll(LV* plv, HWND hwndCtl, UINT code, int pos);
  274. BOOL NEAR ListView_CommonArrange(LV* plv, UINT style, HDPA hdpaSort);
  275. BOOL NEAR ListView_CommonArrangeEx(LV* plv, UINT style, HDPA hdpaSort, int iWorkArea);
  276. BOOL NEAR ListView_OnSetCursor(LV* plv, HWND hwndCursor, UINT codeHitTest, UINT msg);
  277. UINT NEAR ListView_OnGetDlgCode(LV* plv, MSG FAR* lpmsg);
  278. HBRUSH NEAR ListView_OnCtlColor(LV* plv, HDC hdc, HWND hwndChild, int type);
  279. void NEAR ListView_OnSetFont(LV* plvCtl, HFONT hfont, BOOL fRedraw);
  280. HFONT NEAR ListView_OnGetFont(LV* plv);
  281. void NEAR ListViews_OnTimer(LV* plv, UINT id);
  282. void NEAR ListView_OnWinIniChange(LV* plv, WPARAM wParam, LPARAM lParam);
  283. void NEAR PASCAL ListView_OnSysColorChange(LV* plv);
  284. void NEAR ListView_OnSetRedraw(LV* plv, BOOL fRedraw);
  285. HIMAGELIST NEAR ListView_OnCreateDragImage(LV *plv, int iItem, LPPOINT lpptUpLeft);
  286. BOOL FAR PASCAL ListView_ISetColumnWidth(LV* plv, int iCol, int cx, BOOL fExplicit);
  287. typedef void (FAR PASCAL *SCROLLPROC)(LV*, int dx, int dy, UINT uSmooth);
  288. void FAR PASCAL ListView_ComOnScroll(LV* plv, UINT code, int posNew, int sb,
  289. int cLine, int cPage);
  290. BOOL NEAR ListView_OnGetItemA(LV* plv, LV_ITEMA FAR* plvi);
  291. BOOL NEAR ListView_OnSetItemA(LV* plv, LV_ITEMA FAR* plvi);
  292. int NEAR ListView_OnInsertItemA(LV* plv, LV_ITEMA FAR* plvi);
  293. int NEAR ListView_OnFindItemA(LV* plv, int iStart, LV_FINDINFOA FAR* plvfi);
  294. int NEAR ListView_OnGetStringWidthA(LV* plv, LPCSTR psz, HDC hdc);
  295. BOOL NEAR ListView_OnGetColumnA(LV* plv, int iCol, LV_COLUMNA FAR* pcol);
  296. BOOL NEAR ListView_OnSetColumnA(LV* plv, int iCol, LV_COLUMNA FAR* pcol);
  297. int NEAR ListView_OnInsertColumnA(LV* plv, int iCol, LV_COLUMNA FAR* pcol);
  298. int NEAR PASCAL ListView_OnGetItemTextA(LV* plv, int i, LV_ITEMA FAR *lvitem);
  299. BOOL WINAPI ListView_OnSetItemTextA(LV* plv, int i, int iSubItem, LPCSTR pszText);
  300. BOOL WINAPI ListView_OnGetBkImageA(LV* plv, LPLVBKIMAGEA pbiA);
  301. BOOL WINAPI ListView_OnSetBkImageA(LV* plv, LPLVBKIMAGEA pbiA);
  302. BOOL ListView_IsItemUnfolded2(LV* plv, int iItem, int iSubItem, LPTSTR pszText, int cchTextMax);
  303. BOOL WINAPI ListView_OnSetBkImage(LV* plv, LPLVBKIMAGE pbi);
  304. BOOL WINAPI ListView_OnGetBkImage(LV* plv, LPLVBKIMAGE pbi);
  305. BOOL NEAR ListView_OnSetBkColor(LV* plv, COLORREF clrBk);
  306. HIMAGELIST NEAR ListView_OnSetImageList(LV* plv, HIMAGELIST himl, BOOL fSmallImages);
  307. BOOL NEAR ListView_OnDeleteAllItems(LV* plv);
  308. int NEAR ListView_OnInsertItem(LV* plv, const LV_ITEM FAR* plvi);
  309. BOOL NEAR ListView_OnDeleteItem(LV* plv, int i);
  310. BOOL NEAR ListView_OnReplaceItem(LV* plv, const LV_ITEM FAR* plvi);
  311. int NEAR ListView_OnFindItem(LV* plv, int iStart, const LV_FINDINFO FAR* plvfi);
  312. BOOL NEAR ListView_OnSetItemPosition(LV* plv, int i, int x, int y);
  313. BOOL NEAR ListView_OnSetItem(LV* plv, const LV_ITEM FAR* plvi);
  314. BOOL NEAR ListView_OnGetItem(LV* plv, LV_ITEM FAR* plvi);
  315. BOOL NEAR ListView_OnGetItemPosition(LV* plv, int i, POINT FAR* ppt);
  316. BOOL NEAR ListView_OnEnsureVisible(LV* plv, int i, BOOL fPartialOK);
  317. BOOL NEAR ListView_OnScroll(LV* plv, int dx, int dy);
  318. int NEAR ListView_OnHitTest(LV* plv, LV_HITTESTINFO FAR* pinfo);
  319. int NEAR ListView_OnGetStringWidth(LV* plv, LPCTSTR psz, HDC hdc);
  320. BOOL NEAR ListView_OnGetItemRect(LV* plv, int i, RECT FAR* prc);
  321. int NEAR ListView_OnInsertItem(LV* plv, const LV_ITEM FAR* plvi);
  322. BOOL NEAR ListView_OnRedrawItems(LV* plv, int iFirst, int iLast);
  323. int NEAR ListView_OnGetNextItem(LV* plv, int i, UINT flags);
  324. BOOL NEAR ListView_OnSetColumnWidth(LV* plv, int iCol, int cx);
  325. int NEAR ListView_OnGetColumnWidth(LV* plv, int iCol);
  326. void NEAR ListView_OnStyleChanging(LV* plv, UINT gwl, LPSTYLESTRUCT pinfo);
  327. void NEAR ListView_OnStyleChanged(LV* plv, UINT gwl, LPSTYLESTRUCT pinfo);
  328. int NEAR ListView_OnGetTopIndex(LV* plv);
  329. int NEAR ListView_OnGetCountPerPage(LV* plv);
  330. BOOL NEAR ListView_OnGetOrigin(LV* plv, POINT FAR* ppt);
  331. int NEAR PASCAL ListView_OnGetItemText(LV* plv, int i, LV_ITEM FAR *lvitem);
  332. BOOL WINAPI ListView_OnSetItemText(LV* plv, int i, int iSubItem, LPCTSTR pszText);
  333. HIMAGELIST NEAR ListView_OnGetImageList(LV* plv, int iImageList);
  334. UINT NEAR PASCAL ListView_OnGetItemState(LV* plv, int i, UINT mask);
  335. BOOL NEAR PASCAL ListView_OnSetItemState(LV* plv, int i, UINT data, UINT mask);
  336. // Private functions (listview.c):
  337. BOOL NEAR ListView_Notify(LV* plv, int i, int iSubItem, int code);
  338. void NEAR ListView_GetRects(LV* plv, int i,
  339. RECT FAR* prcIcon, RECT FAR* prcLabel,
  340. RECT FAR* prcBounds, RECT FAR* prcSelectBounds);
  341. BOOL NEAR ListView_DrawItem(PLVDRAWITEM);
  342. #define ListView_InvalidateItem(p,i,s,r) ListView_InvalidateItemEx(p,i,s,r,0)
  343. void NEAR ListView_InvalidateItemEx(LV* plv, int i, BOOL fSelectionOnly,
  344. UINT fRedraw, UINT maskChanged);
  345. BOOL NEAR ListView_StartDrag(LV* plv, int iDrag, int x, int y);
  346. void NEAR ListView_TypeChange(LV* plv, DWORD styleOld);
  347. void NEAR PASCAL ListView_DeleteHrgnInval(LV* plv);
  348. void NEAR ListView_Redraw(LV* plv, HDC hdc, RECT FAR* prc);
  349. void NEAR ListView_RedrawSelection(LV* plv);
  350. BOOL NEAR ListView_FreeItem(LV* plv, LISTITEM FAR* pitem);
  351. void ListView_FreeSubItem(PLISTSUBITEM plsi);
  352. LISTITEM FAR* NEAR ListView_CreateItem(LV* plv, const LV_ITEM FAR* plvi);
  353. void NEAR ListView_UpdateScrollBars(LV* plv);
  354. int NEAR ListView_SetFocusSel(LV* plv, int iNewFocus, BOOL fSelect, BOOL fDeselectAll, BOOL fToggleSel);
  355. void NEAR ListView_GetRectsOwnerData(LV* plv, int iItem,
  356. RECT FAR* prcIcon, RECT FAR* prcLabel, RECT FAR* prcBounds,
  357. RECT FAR* prcSelectBounds, LISTITEM* pitem);
  358. void ListView_CalcMinMaxIndex( LV* plv, PRECT prcBounding, int* iMin, int* iMax );
  359. int ListView_LCalcViewItem( LV* plv, int x, int y );
  360. void LVSeeThruScroll(LV *plv, LPRECT lprcUpdate);
  361. BOOL NEAR ListView_UnfoldRects(LV* plv, int iItem,
  362. RECT FAR* prcIcon, RECT FAR* prcLabel,
  363. RECT FAR* prcBounds, RECT FAR* prcSelectBounds);
  364. __inline int ListView_Count(LV *plv)
  365. {
  366. ASSERT(ListView_IsOwnerData(plv) || plv->cTotalItems == DPA_GetPtrCount(plv->hdpa));
  367. return plv->cTotalItems;
  368. }
  369. // Forcing (i) to UINT lets us catch bogus negative numbers, too.
  370. #define ListView_IsValidItemNumber(plv, i) ((UINT)(i) < (UINT)ListView_Count(plv))
  371. #define ListView_GetItemPtr(plv, i) ((LISTITEM FAR*)DPA_GetPtr((plv)->hdpa, (i)))
  372. #ifdef DEBUG
  373. #define ListView_FastGetItemPtr(plv, i) ((LISTITEM FAR*)DPA_GetPtr((plv)->hdpa, (i)))
  374. #define ListView_FastGetZItemPtr(plv, i) ((LISTITEM FAR*)DPA_GetPtr((plv)->hdpa, \
  375. (int)OFFSETOF(DPA_GetPtr((plv)->hdpaZOrder, (i)))))
  376. #else
  377. #define ListView_FastGetItemPtr(plv, i) ((LISTITEM FAR*)DPA_FastGetPtr((plv)->hdpa, (i)))
  378. #define ListView_FastGetZItemPtr(plv, i) ((LISTITEM FAR*)DPA_FastGetPtr((plv)->hdpa, \
  379. (int)OFFSETOF(DPA_FastGetPtr((plv)->hdpaZOrder, (i)))))
  380. #endif
  381. BOOL NEAR ListView_CalcMetrics();
  382. void NEAR PASCAL ListView_ColorChange();
  383. void NEAR PASCAL ListView_DrawBackground(LV* plv, HDC hdc, RECT *prcClip);
  384. BOOL NEAR ListView_NeedsEllipses(HDC hdc, LPCTSTR pszText, RECT FAR* prc, int FAR* pcchDraw, int cxEllipses);
  385. int NEAR ListView_CompareString(LV* plv, int i, LPCTSTR pszFind, UINT flags, int iLen);
  386. int NEAR ListView_GetLinkedTextWidth(HDC hdc, LPCTSTR psz, UINT cch, BOOL bLink);
  387. int NEAR ListView_GetCxScrollbar(LV* plv);
  388. int NEAR ListView_GetCyScrollbar(LV* plv);
  389. DWORD NEAR ListView_GetWindowStyle(LV* plv);
  390. #define ListView_GetScrollInfo(plv, flag, lpsi) \
  391. ((plv)->exStyle & LVS_EX_FLATSB ? \
  392. FlatSB_GetScrollInfo((plv)->ci.hwnd, (flag), (lpsi)) : \
  393. GetScrollInfo((plv)->ci.hwnd, (flag), (lpsi)))
  394. int ListView_SetScrollInfo(LV *plv, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw);
  395. #define ListView_SetScrollRange(plv, flag, min, max, fredraw) \
  396. ((plv)->exStyle & LVS_EX_FLATSB ? \
  397. FlatSB_SetScrollRange((plv)->ci.hwnd, (flag), (min), (max), (fredraw)) : \
  398. SetScrollRange((plv)->ci.hwnd, (flag), (min), (max), (fredraw)))
  399. // lvicon.c functions
  400. BOOL NEAR ListView_OnArrange(LV* plv, UINT style);
  401. HWND NEAR ListView_OnEditLabel(LV* plv, int i, LPTSTR pszText);
  402. int ListView_IItemHitTest(LV* plv, int x, int y, UINT FAR* pflags, int *piSubItem);
  403. void NEAR ListView_IGetRects(LV* plv, LISTITEM FAR* pitem, RECT FAR* prcIcon,
  404. RECT FAR* prcLabel, LPRECT prcBounds);
  405. void NEAR ListView_ScaleIconPositions(LV* plv, BOOL fSmallIconView);
  406. void NEAR ListView_IGetRectsOwnerData(LV* plv, int iItem, RECT FAR* prcIcon,
  407. RECT FAR* prcLabel, LISTITEM* pitem, BOOL fUsepitem);
  408. void NEAR PASCAL _ListView_GetRectsFromItem(LV* plv, BOOL bSmallIconView,
  409. LISTITEM FAR *pitem,
  410. LPRECT prcIcon, LPRECT prcLabel, LPRECT prcBounds, LPRECT prcSelectBounds);
  411. __inline void ListView_SetSRecompute(LISTITEM *pitem)
  412. {
  413. pitem->cxSingleLabel = SRECOMPUTE;
  414. pitem->cxMultiLabel = SRECOMPUTE;
  415. pitem->cyFoldedLabel = SRECOMPUTE;
  416. pitem->cyUnfoldedLabel = SRECOMPUTE;
  417. }
  418. void NEAR ListView_Recompute(LV* plv);
  419. void NEAR ListView_RecomputeLabelSize(LV* plv, LISTITEM FAR* pitem, int i, HDC hdc, BOOL fUsepitem);
  420. BOOL NEAR ListView_SetIconPos(LV* plv, LISTITEM FAR* pitem, int iSlot, int cSlot);
  421. BOOL NEAR ListView_IsCleanRect(LV * plv, RECT * prc, int iExcept, BOOL * pfUpdate, HDC hdc);
  422. int NEAR ListView_FindFreeSlot(LV* plv, int i, int iSlot, int cSlot, BOOL FAR* pfUpdateSB, BOOL FAR* pfAppend, HDC hdc);
  423. int NEAR ListView_CalcHitSlot( LV* plv, POINT pt, int cslot );
  424. void NEAR ListView_GetViewRect2(LV* plv, RECT FAR* prcView, int cx, int cy);
  425. int CALLBACK ArrangeIconCompare(LISTITEM FAR* pitem1, LISTITEM FAR* pitem2, LPARAM lParam);
  426. int NEAR ListView_GetSlotCountEx(LV* plv, BOOL fWithoutScroll, int iWorkArea);
  427. int NEAR ListView_GetSlotCount(LV* plv, BOOL fWithoutScroll);
  428. void NEAR ListView_IUpdateScrollBars(LV* plv);
  429. DWORD NEAR ListView_GetClientRect(LV* plv, RECT FAR* prcClient, BOOL fSubScrolls, RECT FAR *prcViewRect);
  430. void NEAR ListView_SetEditSize(LV* plv);
  431. BOOL NEAR ListView_DismissEdit(LV* plv, BOOL fCancel);
  432. LRESULT CALLBACK _export ListView_EditWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  433. UINT NEAR PASCAL ListView_DrawImageEx(LV* plv, LV_ITEM FAR* pitem, HDC hdc, int x, int y, UINT fDraw, int xMax);
  434. #define ListView_DrawImage(plv, pitem, hdc, x, y, fDraw) \
  435. ListView_DrawImageEx(plv, pitem, hdc, x, y, fDraw, -1)
  436. #if defined(FE_IME)
  437. void NEAR PASCAL ListView_SizeIME(HWND hwnd);
  438. void NEAR PASCAL ListView_InsertComposition(HWND hwnd, WPARAM wParam, LPARAM lParam, LV *plv);
  439. void NEAR PASCAL ListView_PaintComposition(HWND hwnd, LV *plv);
  440. #endif
  441. // lvsmall.c functions:
  442. void NEAR ListView_SGetRects(LV* plv, LISTITEM FAR* pitem, RECT FAR* prcIcon,
  443. RECT FAR* prcLabel, LPRECT prcBounds);
  444. void NEAR ListView_SGetRectsOwnerData(LV* plv, int iItem, RECT FAR* prcIcon,
  445. RECT FAR* prcLabel, LISTITEM* pitem, BOOL fUsepitem);
  446. int ListView_SItemHitTest(LV* plv, int x, int y, UINT FAR* pflags, int *piSubItem);
  447. int NEAR ListView_LookupString(LV* plv, LPCTSTR lpszLookup, UINT flags, int iStart);
  448. // lvlist.c functions:
  449. void NEAR ListView_LGetRects(LV* plv, int i, RECT FAR* prcIcon,
  450. RECT FAR* prcLabel, RECT FAR *prcBounds, RECT FAR* prcSelectBounds);
  451. int ListView_LItemHitTest(LV* plv, int x, int y, UINT FAR* pflags, int *piSubItem);
  452. void NEAR ListView_LUpdateScrollBars(LV* plv);
  453. BOOL FAR PASCAL ListView_MaybeResizeListColumns(LV* plv, int iFirst, int iLast);
  454. // lvrept.c functions:
  455. int ListView_OnSubItemHitTest(LV* plv, LPLVHITTESTINFO lParam);
  456. void ListView_GetSubItem(LV* plv, int i, int iSubItem, PLISTSUBITEM plsi);
  457. BOOL LV_ShouldItemDrawGray(LV* plv, UINT fText);
  458. int NEAR ListView_OnInsertColumn(LV* plv, int iCol, const LV_COLUMN FAR* pcol);
  459. BOOL NEAR ListView_OnDeleteColumn(LV* plv, int iCol);
  460. BOOL NEAR ListView_OnGetColumn(LV* plv, int iCol, LV_COLUMN FAR* pcol);
  461. BOOL NEAR ListView_OnSetColumn(LV* plv, int iCol, const LV_COLUMN FAR* pcol);
  462. BOOL NEAR ListView_ROnEnsureVisible(LV* plv, int i, BOOL fPartialOK);
  463. void NEAR PASCAL ListView_RInitialize(LV* plv, BOOL fInval);
  464. BOOL ListView_OnGetSubItemRect(LV* plv, int i, LPRECT lprc);
  465. #define ListView_RYHitTest(plv, cy) ((int)(((cy) + plv->ptlRptOrigin.y - plv->yTop) / plv->cyItem))
  466. BOOL NEAR ListView_SetSubItem(LV* plv, const LV_ITEM FAR* plvi);
  467. void NEAR PASCAL ListView_RAfterRedraw(LV* plv, HDC hdc);
  468. int NEAR ListView_RGetColumnWidth(LV* plv, int iCol);
  469. BOOL NEAR ListView_RSetColumnWidth(LV* plv, int iCol, int cx);
  470. LPTSTR NEAR ListView_GetSubItemText(LV* plv, int i, int iCol);
  471. void NEAR ListView_RDestroy(LV* plv);
  472. int ListView_RItemHitTest(LV* plv, int x, int y, UINT FAR* pflags, int *piSubItem);
  473. void NEAR ListView_RUpdateScrollBars(LV* plv);
  474. void NEAR ListView_RGetRects(LV* plv, int iItem, RECT FAR* prcIcon,
  475. RECT FAR* prcLabel, RECT FAR* prcBounds, RECT FAR* prcSelectBounds);
  476. LRESULT ListView_HeaderNotify(LV* plv, HD_NOTIFY *pnm);
  477. int NEAR ListView_FreeColumnData(LPVOID d, LPVOID p);
  478. BOOL FAR PASCAL SameChars(LPTSTR lpsz, TCHAR c);
  479. #define ListView_GetSubItemDPA(plv, idpa) \
  480. ((HDPA)DPA_GetPtr((plv)->hdpaSubItems, (idpa)))
  481. int NEAR ListView_Arrow(LV* plv, int iStart, UINT vk);
  482. BOOL ListView_IsItemUnfolded(LV *plv, int item);
  483. BOOL ListView_IsItemUnfoldedPtr(LV *plv, LISTITEM *pitem);
  484. // Fake customdraw. See comment block in lvrept.c
  485. typedef struct LVFAKEDRAW {
  486. NMLVCUSTOMDRAW nmcd;
  487. LV* plv;
  488. DWORD dwCustomPrev;
  489. DWORD dwCustomItem;
  490. DWORD dwCustomSubItem;
  491. LV_ITEM *pitem;
  492. HFONT hfontPrev;
  493. } LVFAKEDRAW, *PLVFAKEDRAW;
  494. void ListView_BeginFakeCustomDraw(LV* plv, PLVFAKEDRAW plvfd, LV_ITEM *pitem);
  495. DWORD ListView_BeginFakeItemDraw(PLVFAKEDRAW plvfd);
  496. void ListView_EndFakeItemDraw(PLVFAKEDRAW plvfd);
  497. void ListView_EndFakeCustomDraw(PLVFAKEDRAW plvfd);
  498. //============ External declarations =======================================
  499. //extern HFONT g_hfontLabel;
  500. extern HBRUSH g_hbrActiveLabel;
  501. extern HBRUSH g_hbrInactiveLabel;
  502. extern HBRUSH g_hbrBackground;
  503. // function tables
  504. #define LV_TYPEINDEX(plv) ((plv)->ci.style & (UINT)LVS_TYPEMASK)
  505. BOOL ListView_RDrawItem(PLVDRAWITEM);
  506. BOOL ListView_IDrawItem(PLVDRAWITEM);
  507. BOOL ListView_LDrawItem(PLVDRAWITEM);
  508. typedef BOOL (*PFNLISTVIEW_DRAWITEM)(PLVDRAWITEM);
  509. extern const PFNLISTVIEW_DRAWITEM pfnListView_DrawItem[4];
  510. #define _ListView_DrawItem(plvdi) \
  511. pfnListView_DrawItem[LV_TYPEINDEX(plvdi->plv)](plvdi)
  512. void NEAR ListView_RUpdateScrollBars(LV* plv);
  513. typedef void (*PFNLISTVIEW_UPDATESCROLLBARS)(LV* plv);
  514. extern const PFNLISTVIEW_UPDATESCROLLBARS pfnListView_UpdateScrollBars[4];
  515. #define _ListView_UpdateScrollBars(plv) \
  516. pfnListView_UpdateScrollBars[LV_TYPEINDEX(plv)](plv)
  517. typedef DWORD (*PFNLISTVIEW_APPROXIMATEVIEWRECT)(LV* plv, int, int, int);
  518. extern const PFNLISTVIEW_APPROXIMATEVIEWRECT pfnListView_ApproximateViewRect[4];
  519. #define _ListView_ApproximateViewRect(plv, iCount, iWidth, iHeight) \
  520. pfnListView_ApproximateViewRect[LV_TYPEINDEX(plv)](plv, iCount, iWidth, iHeight)
  521. typedef int (*PFNLISTVIEW_ITEMHITTEST)(LV* plv, int, int, UINT FAR *, int *);
  522. extern const PFNLISTVIEW_ITEMHITTEST pfnListView_ItemHitTest[4];
  523. #define _ListView_ItemHitTest(plv, x, y, pflags, piSubItem) \
  524. pfnListView_ItemHitTest[LV_TYPEINDEX(plv)](plv, x, y, pflags, piSubItem)
  525. void ListView_IOnScroll(LV* plv, UINT code, int posNew, UINT fVert);
  526. void ListView_LOnScroll(LV* plv, UINT code, int posNew, UINT sb);
  527. void ListView_ROnScroll(LV* plv, UINT code, int posNew, UINT sb);
  528. typedef void (*PFNLISTVIEW_ONSCROLL)(LV* plv, UINT, int, UINT );
  529. extern const PFNLISTVIEW_ONSCROLL pfnListView_OnScroll[4];
  530. #define _ListView_OnScroll(plv, x, y, pflags) \
  531. pfnListView_OnScroll[LV_TYPEINDEX(plv)](plv, x, y, pflags)
  532. void ListView_Scroll2(LV* plv, int dx, int dy);
  533. void ListView_IScroll2(LV* plv, int dx, int dy, UINT uSmooth);
  534. void ListView_LScroll2(LV* plv, int dx, int dy, UINT uSmooth);
  535. void ListView_RScroll2(LV* plv, int dx, int dy, UINT uSmooth);
  536. typedef void (*PFNLISTVIEW_SCROLL2)(LV* plv, int, int, UINT );
  537. extern const PFNLISTVIEW_SCROLL2 pfnListView_Scroll2[4];
  538. #define _ListView_Scroll2(plv, x, y, pflags) \
  539. pfnListView_Scroll2[LV_TYPEINDEX(plv)](plv, x, y, pflags)
  540. int ListView_IGetScrollUnitsPerLine(LV* plv, UINT sb);
  541. int ListView_LGetScrollUnitsPerLine(LV* plv, UINT sb);
  542. int ListView_RGetScrollUnitsPerLine(LV* plv, UINT sb);
  543. typedef int (*PFNLISTVIEW_GETSCROLLUNITSPERLINE)(LV* plv, UINT sb);
  544. extern const PFNLISTVIEW_GETSCROLLUNITSPERLINE pfnListView_GetScrollUnitsPerLine[4];
  545. #define _ListView_GetScrollUnitsPerLine(plv, sb) \
  546. pfnListView_GetScrollUnitsPerLine[LV_TYPEINDEX(plv)](plv, sb)
  547. #define LVMI_PLACEITEMS (WM_USER)
  548. #endif //!_INC_LISTVIEW