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.

456 lines
13 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. treeview.h
  5. Abstract:
  6. This module contains header definition for the treeview.c
  7. Author:
  8. 19-Jun-1995 Mon 11:52:01 created -by- Daniel Chou (danielc)
  9. [Environment:]
  10. NT Windows - Common Printer Driver UI DLL.
  11. [Notes:]
  12. Revision History:
  13. --*/
  14. #define COUNT_ARRAY(a) (sizeof(a) / sizeof(a[0]))
  15. #define MAX_COMPTRUI_TABS 2
  16. #define TWF_CAN_UPDATE 0x0001
  17. #define TWF_TVPAGE_CHK_DMPUB 0x0002
  18. #define TWF_TVPAGE_NODMPUB 0x0004
  19. #define TWF_ANSI_CALL 0x0008
  20. #define TWF_ONE_REVERT_ITEM 0x0010
  21. #define TWF_ADVDOCPROP 0x0020
  22. #define TWF_HAS_ADVANCED_PUSH 0x0040
  23. #define TWF_TV_BY_PUSH 0x0080
  24. #define TWF_APPLY_NO_NEWDEF 0x0100
  25. #define TWF_TVITEM_NOTYPE 0x0200
  26. #define TWF_IN_TVPAGE 0x0400
  27. #define ICONIDX_NONE 0xFFFF
  28. #define OTINTF_STATES_1 0x0001
  29. #define OTINTF_STATES_2 0x0002
  30. #define OTINTF_STATES_3 0x0004
  31. #define OTINTF_STATES_HIDE_MASK (OTINTF_STATES_1 | \
  32. OTINTF_STATES_2 | \
  33. OTINTF_STATES_3)
  34. #define OTINTF_STDPAGE_3STATES 0x0008
  35. #define OTINTF_ITEM_HAS_ICON16 0x0010
  36. #define OTINTF_TV_USE_2STATES 0x0020
  37. #define OTINTF_TV_USE_3STATES 0x0040
  38. #define OIDF_IN_EN_UPDATE 0x01
  39. #define OIDF_ZERO_SEL_LEN 0x02
  40. #define OIDF_SEL_LEN_SPACES 0x04
  41. typedef struct _OIDATA {
  42. BYTE IntFlags;
  43. BYTE TVLevel;
  44. WORD OIExtFlags;
  45. WORD LBCBSelIdx;
  46. WORD cbpDefSel;
  47. WORD cxExt;
  48. WORD cyExtAdd;
  49. HTREEITEM hItem;
  50. LPVOID pDefSel;
  51. LPVOID pDefSel2;
  52. DWORD DefOPTIF;
  53. DWORD DefOPTIF2;
  54. DWORD HelpIdx;
  55. HINSTANCE hInstCaller;
  56. LPTSTR pHelpFile;
  57. } OIDATA, *POIDATA;
  58. #define _OT_ORGLBCBCY(pOT) ((pOT)->wReserved[0])
  59. #define _OT_FLAGS(pOT) ((pOT)->wReserved[1])
  60. #define _OI_POIDATA(pItem) ((POIDATA)((pItem)->dwReserved[0]))
  61. #define _OI_INTFLAGS(pItem) (_OI_POIDATA(pItem)->IntFlags)
  62. #define _OI_TVLEVEL(pItem) (_OI_POIDATA(pItem)->TVLevel)
  63. #define _OI_EXTFLAGS(pItem) (_OI_POIDATA(pItem)->OIExtFlags)
  64. #define _OI_LBCBSELIDX(pItem) (_OI_POIDATA(pItem)->LBCBSelIdx)
  65. #define _OI_CBPDEFSEL(pItem) (_OI_POIDATA(pItem)->cbpDefSel)
  66. #define _OI_HELPIDX(pItem) (_OI_POIDATA(pItem)->HelpIdx)
  67. #define _OI_CXEXT(pItem) (_OI_POIDATA(pItem)->cxExt)
  68. #define _OI_CYEXTADD(pItem) (_OI_POIDATA(pItem)->cyExtAdd)
  69. #define _OI_HITEM(pItem) (_OI_POIDATA(pItem)->hItem)
  70. #define _OI_PDEFSEL(pItem) (_OI_POIDATA(pItem)->pDefSel)
  71. #define _OI_PDEFSEL2(pItem) (_OI_POIDATA(pItem)->pDefSel2)
  72. #define _OI_DEF_OPTIF(pItem) (_OI_POIDATA(pItem)->DefOPTIF)
  73. #define _OI_DEF_OPTIF2(pItem) (_OI_POIDATA(pItem)->DefOPTIF2)
  74. #define _OI_HINST(pItem) (_OI_POIDATA(pItem)->hInstCaller)
  75. #define _OI_PHELPFILE(pItem) (_OI_POIDATA(pItem)->pHelpFile)
  76. #define DO_IN_PLACE 1
  77. #define CPSUIPROP_WNDPROC (LPCTSTR)0xAFBEL
  78. #define CPSUIPROP_TABTABLE (LPCTSTR)0xAFBFL
  79. #define CPSUIPROP_PTVWND (LPCTSTR)0xAFC0L
  80. #define CPSUIPROP (LPCTSTR)0xAFC1L
  81. #define CPSUIPROP_LAYOUTPUSH (LPCTSTR)0xAFC2L
  82. #define CPSUIPROP_CBPRESEL (LPCTSTR)0xAFC3L
  83. #define ADD_PMYDLGPAGE(hDlg, p) SetProp(hDlg, CPSUIPROP, (HANDLE)(p))
  84. #define GET_PMYDLGPAGE(hDlg) ((PMYDLGPAGE)GetProp(hDlg, CPSUIPROP))
  85. #define DEL_PMYDLGPAGE(hDlg) RemoveProp(hDlg, CPSUIPROP)
  86. #define GET_PTVWND(hDlg) ((PTVWND)((GET_PMYDLGPAGE(hDlg))->pTVWnd))
  87. #define PAGEIDX_NONE 0xFF
  88. #define INTIDX_FIRST 0xFFFA
  89. #define INTIDX_TVROOT 0xFFFA
  90. #define INTIDX_PAPER 0xFFFB
  91. #define INTIDX_GRAPHIC 0xFFFC
  92. #define INTIDX_OPTIONS 0xFFFD
  93. #define INTIDX_ICM 0xFFFE
  94. #define INTIDX_ADVANCED 0xFFFF
  95. #define INTIDX_LAST 0xFFFF
  96. #define INTIDX_TOTAL (INTIDX_LAST - INTIDX_FIRST + 1)
  97. #define PIDX_INTOPTITEM(pTVWnd,i) (&((pTVWnd)->IntOptItem[i-INTIDX_FIRST]))
  98. #define PBEG_INTOPTITEM(pTVWnd) PIDX_INTOPTITEM((pTVWnd), INTIDX_FIRST)
  99. #define PEND_INTOPTITEM(pTVWnd) PIDX_INTOPTITEM((pTVWnd), INTIDX_LAST)
  100. #define IIDX_INTOPTITEM(pTVWnd,poi) (poi-PBEG_INTOPTITEM(pTVWnd)+INTIDX_FIRST)
  101. #define TVLPF_DISABLED 0x01
  102. #define TVLPF_WARNING 0x02
  103. #define TVLPF_CHANGEONCE 0x04
  104. #define TVLPF_STOP 0x08
  105. #define TVLPF_HAS_ANGLE 0x10
  106. #define TVLPF_ECBICON 0x20
  107. #define TVLPF_NO 0x40
  108. #define TVLPF_EMPTYICON 0x80
  109. typedef struct _TVLP {
  110. WORD ItemIdx;
  111. BYTE Flags;
  112. BYTE cName;
  113. } TVLP, *PTVLP;
  114. #define TVLP2LP(tvlp) ((LPARAM)*((DWORD *)&(tvlp)))
  115. #define GET_TVLP(l) (*((PTVLP)&(l)))
  116. #define DMPUB_HDR_FIRST DMPUB_USER
  117. #define DMPUB_HDR_TVROOT (DMPUB_USER + 0)
  118. #define DMPUB_HDR_PAPER (DMPUB_USER + 1)
  119. #define DMPUB_HDR_GRAPHIC (DMPUB_USER + 2)
  120. #define DMPUB_HDR_OPTIONS (DMPUB_USER + 3)
  121. #define DMPUB_HDR_ICM (DMPUB_USER + 4)
  122. #ifdef _WIN64
  123. #define LODWORD(u) (DWORD)((ULONG_PTR)(u) & 0xFFFFFFFF)
  124. #define HIDWORD(u) LOUINTPTR(u >> 32)
  125. #define MKUINTPTR(l,h) ((ULONG_PTR)(l) | ((ULONG_PTR)(h) << 32))
  126. #else
  127. #define LODWORD(u) (DWORD)(u)
  128. #define HIDWORD(u) (DWORD)(u)
  129. #define MKUINTPTR(l,h) (DWORD)(l)
  130. #endif
  131. #define ID_MASK (ULONG_PTR)0xFFFF
  132. #define PTR_MASK (ULONG_PTR)~ID_MASK
  133. #define VALID_PTR(p) ((ULONG_PTR)(p) & PTR_MASK)
  134. #define MKHICONID(id) ((VALID_PTR(id)) ? (id) : (id) | PTR_MASK)
  135. #define GET_HICON(id) (HICON)((((id) & PTR_MASK) == PTR_MASK) ? \
  136. ((id) & ID_MASK) : (id))
  137. #if 0
  138. #define MKHICONID(id) ((HIWORD(id))?(id):MAKELONG((id),0xFFFF))
  139. #define GET_HICON(id) (HICON)((HIWORD(id)==0xFFFF) ? LOWORD(id) : \
  140. (id))
  141. #endif
  142. #define GETSELICONID(p) (ULONG_PTR)(((p)->Flags&OPTIF_SEL_AS_HICON) \
  143. ? MKHICONID((ULONG_PTR)((p)->pSel)) : \
  144. (p)->Sel)
  145. #define GET_ICONID(p,f) (ULONG_PTR)(((p)->Flags & (f)) ? \
  146. MKHICONID((ULONG_PTR)((p)->IconID)) : \
  147. (p)->IconID)
  148. #define GET_PITEMDMPUB(p, i, Idx) \
  149. ((((i)<=DMPUB_LAST) && (((Idx)=(p)->DMPubIdx[(i)-DMPUB_FIRST])!=0xFFFF))\
  150. ? ((p)->ComPropSheetUI.pOptItem + (Idx)) : NULL)
  151. typedef struct _TVOTSTATESINFO {
  152. WORD Top;
  153. WORD Inc;
  154. } TVOTSTATESINFO, *PTVOTSTATESINFO;
  155. #define MYDPF_CHANGED 0x0001
  156. #define MYDPF_CHANGEONCE 0x0002
  157. #define MYDPF_REINIT 0x0004
  158. #define MYDPF_PAGE_ACTIVE 0x0008
  159. #define MYDP_ID 0x49555043
  160. typedef struct _MYDLGPAGE {
  161. DWORD ID;
  162. ULONG_PTR CPSUIUserData;
  163. HWND hDlgChild;
  164. HWND hWndFocus;
  165. PPSPINFO pPSPInfo;
  166. POPTITEM pCurItem;
  167. WORD Flags;
  168. BYTE PageIdx;
  169. BYTE NotUsed;
  170. DLGPAGE DlgPage;
  171. HICON hIcon;
  172. LPVOID pTVWnd;
  173. WORD cItem;
  174. WORD cHide;
  175. } MYDLGPAGE, *PMYDLGPAGE;
  176. typedef struct _TVWND {
  177. HWND hWndTV;
  178. WNDPROC TVWndProc;
  179. HFONT hBoldFont;
  180. HWND hDlgTV;
  181. #if DO_IN_PLACE
  182. POPTITEM pMouseItem;
  183. LPARAM MousePos;
  184. HFONT hTVFont[4];
  185. HWND hWndEdit[3];
  186. BYTE chWndEdit;
  187. BYTE cyImage;
  188. BYTE yLinesOff;
  189. BYTE bNotUsed;
  190. WORD cxEdit;
  191. WORD cxItem;
  192. WORD cxMaxItem;
  193. WORD cxMaxUDEdit;
  194. POINTL ptCur;
  195. HWND hWndExt;
  196. HDC hDCTVWnd;
  197. WORD cxCBAdd;
  198. WORD cxChkBoxAdd;
  199. WORD cxSelAdd;
  200. WORD cxExtAdd;
  201. WORD cxAveChar;
  202. WORD cxSpace;
  203. #endif
  204. HANDLE hCPSUIPage;
  205. LPDWORD pRootFlags;
  206. HINSTANCE hInstCaller;
  207. POPTITEM pCurTVItem;
  208. POPTITEM pLastItem;
  209. HIMAGELIST himi;
  210. PMYDLGPAGE pMyDlgPage;
  211. LPDWORD pIcon16ID;
  212. WORD Icon16Count;
  213. WORD Icon16Added;
  214. WORD Flags;
  215. WORD VKeyTV;
  216. WORD cxcyTVIcon;
  217. WORD cxcyECBIcon;
  218. BYTE TVPageIdx;
  219. BYTE StdPageIdx1;
  220. BYTE StdPageIdx2;
  221. BYTE cMyDlgPage;
  222. BYTE ActiveDlgPage;
  223. WORD xCtrls;
  224. WORD yECB;
  225. WORD IntTVOptIdx;
  226. WORD tLB;
  227. WORD yLB[2];
  228. TVOTSTATESINFO SI2[2];
  229. TVOTSTATESINFO SI3[2];
  230. WORD DMPubIdx[(DMPUB_LAST + 1) & ~1];
  231. OPTITEM IntOptItem[INTIDX_TOTAL];
  232. OIDATA IntOIData[INTIDX_TOTAL];
  233. OPTPARAM OptParamNone;
  234. BYTE cInitMyDlgPage;
  235. BYTE bReserved;
  236. BYTE cDMPub;
  237. BYTE OverlayIconBits;
  238. PCOMPROPSHEETUI pCPSUI;
  239. COMPROPSHEETUI ComPropSheetUI;
  240. } TVWND, *PTVWND;
  241. #define OPTIF_INT_ADDED 0x80000000L
  242. #define OPTIF_INT_CHANGED 0x40000000L
  243. #define OPTIF_INT_TV_CHANGED 0x20000000L
  244. #define OPTIF_INT_HIDE 0x10000000L
  245. #define OPTIF_INT_MASK 0xF0000000L
  246. #define OPTIF_ITEM_HIDE (OPTIF_HIDE | OPTIF_INT_HIDE)
  247. #define OPTIF_ENTER_MASK (OPTIF_CHANGED | \
  248. OPTIF_CHANGEONCE)
  249. #define OPTIF_EXIT_MASK OPTIF_CHANGED
  250. #define OPTIF_ECB_MASK (OPTIF_ECB_CHECKED | \
  251. OPTIF_EXT_HIDE | \
  252. OPTIF_EXT_DISABLED)
  253. #define IS_HDR_PUSH(po) (BOOL)((po) == &OptTypeHdrPush)
  254. #define GET_POPTTYPE(pi) (((pi)->pOptType) ? (pi)->pOptType : \
  255. &OptTypeHdrPush)
  256. //
  257. // This is used by the TreeViewChangeMode()
  258. //
  259. #define TVCM_TOGGLE 1
  260. #define TVCM_SELECT 2
  261. //
  262. // this is used for the treeview page initialization
  263. //
  264. typedef struct _TVDLGITEM {
  265. BYTE cItem; // count of item start from BegID
  266. BYTE NotUsed; // not used
  267. WORD BegID; // first control window ID
  268. } TVDLGITEM, *PTVDLGITEM;
  269. //
  270. // This is used to add the public header and order the DMPUB in the treeview
  271. //
  272. #define ITVG_LEVEL_MASK 0x0F
  273. #define ITVGF_COLLAPSE 0x80
  274. #define ITVGF_BOLD 0x40
  275. typedef struct _INTTVGRP {
  276. BYTE LevelFlags; // level/flags in the public treeview header
  277. BYTE DMPubID; // DMPUB_xxxx, DMPUB_HDR_xxxx
  278. } INTTVGRP, *PINTTVGRP;
  279. //
  280. // SKIP ITEM CHILDREN
  281. //
  282. //
  283. #define WHILE_SKIP_CHILDREN(pItem, pLastItem, ItemLevel) \
  284. while ((++(pItem) <= (pLastItem)) && ((pItem)->Level > ItemLevel))
  285. #define SKIP_CHILDREN(p,pl,l) WHILE_SKIP_CHILDREN(p,pl,l)
  286. #define SKIP_CHILDREN_ORFLAGS(pItem, pLastItem, ItemLevel, OrFlags) \
  287. do { \
  288. (pItem)->Flags |= (OrFlags); \
  289. } WHILE_SKIP_CHILDREN(pItem, pLastItem, ItemLevel)
  290. #define SKIP_CHILDREN_ANDFLAGS(pItem, pLastItem, ItemLevel, AndFlags) \
  291. do { \
  292. (pItem)->Flags &= (AndFlags); \
  293. } WHILE_SKIP_CHILDREN(pItem, pLastItem, ItemLevel)
  294. //
  295. // Prototypes
  296. //
  297. #define CROIF_DO_SIBLING 0x0001
  298. #define CROIF_REVERT 0x0002
  299. #define CROIF_REVERT_DEF2 0x0004
  300. VOID
  301. SetTVItemState(
  302. PTVWND pTVWnd,
  303. TV_INSERTSTRUCT *ptvins,
  304. POPTITEM pCurItem
  305. );
  306. POPTITEM
  307. SetupTVSelect(
  308. HWND hDlg,
  309. NM_TREEVIEW *pNMTV,
  310. DWORD STVSMode
  311. );
  312. UINT
  313. CountRevertOptItem(
  314. PTVWND pTVWnd,
  315. POPTITEM pOptItem,
  316. HTREEITEM hItem,
  317. DWORD Flags
  318. );
  319. POPTITEM
  320. GetOptions(
  321. PTVWND pTVWnd,
  322. LPARAM lParam
  323. );
  324. CPSUICALLBACK
  325. InternalRevertOptItem(
  326. PCPSUICBPARAM pCBParam
  327. );
  328. LONG
  329. UpdateTreeViewItem(
  330. HWND hDlg,
  331. PTVWND pTVWnd,
  332. POPTITEM pItem,
  333. BOOL ReInit
  334. );
  335. LONG
  336. UpdateTreeView(
  337. HWND hDlg,
  338. PMYDLGPAGE pMyDlgPage
  339. );
  340. POPTITEM
  341. TreeViewHitTest(
  342. PTVWND pTVWnd,
  343. LONG MousePos,
  344. UINT TVHTMask
  345. );
  346. VOID
  347. TreeViewChangeMode(
  348. PTVWND pTVWnd,
  349. POPTITEM pItem,
  350. UINT Mode
  351. );
  352. INT_PTR
  353. CALLBACK
  354. TreeViewProc(
  355. HWND hDlg,
  356. UINT Msg,
  357. WPARAM wParam,
  358. LPARAM lParam
  359. );