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.

466 lines
17 KiB

  1. #ifndef _PAD_LIST_VIEW_H_
  2. #define _PAD_LIST_VIEW_H_
  3. #ifndef WIN32_LEAN_AND_MEAN
  4. #define WIN32_LEAN_AND_MEAN
  5. #endif
  6. #include <windows.h>
  7. #include <commctrl.h>
  8. #define WC_PADLISTVIEW TEXT("PadListView")
  9. //----------------------------------------------------------------
  10. //PadListView's style. it is not compatible to WS_XXXX
  11. //----------------------------------------------------------------
  12. #define PLVSTYLE_ICON 0x0001
  13. #define PLVSTYLE_REPORT 0x0002
  14. //----------------------------------------------------------------
  15. // PadListView display data's format
  16. //----------------------------------------------------------------
  17. #define PLVFMT_TEXT 0x0001 // Unicode string(NULL terminate)
  18. #define PLVFMT_BITMAP 0x0002 // Bitmap
  19. typedef struct tagPLVITEM {
  20. INT fmt; // PLVFMT_TEXT or PLVFMT_BITMAP. cannot set combination.
  21. union {
  22. LPWSTR lpwstr;
  23. HBITMAP hBitmap;
  24. };
  25. }PLVITEM, *LPPLVITEM;
  26. //----------------------------------------------------------------
  27. // commctrl.h's LV_COLUMNA
  28. //----------------------------------------------------------------
  29. #if 0
  30. typedef struct _LV_COLUMNA
  31. {
  32. UINT mask; //LVCF_FMT, LVCF_WIDTH, LVCF_TEXT, LVCF_SUBITEM;
  33. int fmt;
  34. int cx;
  35. LPSTR pszText;
  36. int cchTextMax;
  37. int iSubItem;
  38. } LV_COLUMNA;
  39. #endif
  40. //----------------------------------------------------------------
  41. // PLV_COLUMN is same as LV_COLMUNA
  42. // to insert header control to PadListView.
  43. // PadListView uses Header contorol as child window.
  44. // Interface (PadListView_Insert(Delete)Column uses common control
  45. // (commctrl.h)'s LV_COLUMNA structure.
  46. //----------------------------------------------------------------
  47. #ifndef UNDER_CE // always Unicode
  48. #define PLV_COLUMN LV_COLUMNA
  49. #else // UNDER_CE
  50. #define PLV_COLUMN LV_COLUMNW
  51. #endif // UNDER_CE
  52. #define PLVCF_FMT LVCF_FMT
  53. #define PLVCF_WIDTH LVCF_WIDTH
  54. #define PLVCF_TEXT LVCF_TEXT
  55. #define PLVCF_SUBITEM LVCF_SUBITEM
  56. #define PLVCF_SEPARATER 0x1000 // new define.
  57. #define PLVCFMT_LEFT LVCFMT_LEFT
  58. #define PLVCFMT_RIGHT LVCFMT_RIGHT
  59. #define PLVCFMT_CENTER LVCFMT_CENTER
  60. #define PLVCFMT_JUSTIFYMASK LVCFMT_JUSTIFYMASK
  61. //----------------------------------------------------------------
  62. //callback function's prototype declaration.
  63. //----------------------------------------------------------------
  64. // this is for PadListView's ICON VIEW callback to retrieve
  65. // display item data by INDEX
  66. //----------------------------------------------------------------
  67. typedef INT (WINAPI *LPFNPLVICONITEMCALLBACK)(LPARAM lParam, INT index, LPPLVITEM lpPlvItem);
  68. //----------------------------------------------------------------
  69. //970705 spec changed, to performance up.
  70. //----------------------------------------------------------------
  71. // This is for PadListView's REPORT VIEW callback to retrieve
  72. // display item data by INDEX.
  73. // you can specify data with index and column in lpPlvItemList.
  74. // so, lpPlvItemList is PLVITEM's array pointer.
  75. // array count is colCount, that is inserted by user.
  76. #if 0
  77. +-----------+-----------+-----------+-----------+-----------+-----------+
  78. header | Column0 | Column1 | Column2 | Column3 | Colmun4 | |
  79. +-----------+-----------+-----------+-----------+-----------+-----------+
  80. index-9 |AAAA BBBB CCCC DDDD EEEE |
  81. |-----------------------------------------------------------------------|
  82. | |
  83. |-----------------------------------------------------------------------|
  84. |
  85. in this case to draw top line of report view, PadListView call report view's call back function
  86. like this.
  87. LPARAM lParam = user defined data.
  88. INT index = 9;
  89. INT colCount = 5;
  90. // create
  91. LPPLVITEM lpPlvItem = (LPPLVITEM)MemAlloc(sizeof(PLVITEM)* colCount);
  92. ZeroMemory(lpPlvItem, sizeof(PLVITEM)*colCount);
  93. (*lpfnCallback)(lParam, //user defined data.
  94. index, //line index,
  95. colCount, //column count,
  96. lpPlvItem); //display item data array.
  97. in your call back function, you can specify data like this.
  98. INT WINAPI UserReportViewCallback(LPARAM lParam, INT index, INT colCount, LPPLVITEM lpPlvItemList)
  99. {
  100. // get line data with index.
  101. UserGetLineDataWithIndex(index, &someStructure);
  102. for(i = 0; i < colCount, i++) {
  103. switch(i) {
  104. case 0: // first column data.
  105. lpPlvItem[i].fmt = PLVFMT_TEXT; // or PLVFMT_BITMAP.
  106. lpPlvItem[i].lpwst = someStructure.lpwstr[i];
  107. break;
  108. case 1: // second column data.
  109. lpPlvItem[i].fmt = PLVFMT_TEXT; // or PLVFMT_BITMAP.
  110. lpPlvItem[i].lpwst = someStructure.lpwstr[i];
  111. break;
  112. :
  113. :
  114. }
  115. }
  116. return 0;
  117. }
  118. #endif
  119. //----------------------------------------------------------------
  120. typedef INT (WINAPI *LPFNPLVREPITEMCALLBACK)(LPARAM lParam,
  121. INT index,
  122. INT colCount,
  123. LPPLVITEM lpPlvItemList);
  124. //----------------------------------------------------------------
  125. // PadListView Notify code, data
  126. // Notify message will be send to PadListView's parent window.
  127. // user can specify their own Message Id when it created.
  128. // see PadListView_CreateWindow().
  129. // Notify message data is as follow's
  130. // User Defined message.
  131. // wID = (INT)Window Id of PadListView.
  132. // lpPlvInfo = (LPPLVINFO)lParam. notify Info structure data pointer
  133. //----------------------------------------------------------------
  134. #define PLVN_ITEMPOPED (WORD)1 //item data is poped image.
  135. //in icon view, all item notify come,
  136. //in report view, only first column.
  137. #define PLVN_ITEMPUSHED (WORD)2 //
  138. #define PLVN_ITEMCLICKED (WORD)3 //item data is clicked.
  139. #define PLVN_ITEMDBLCLICKED (WORD)4 //item data is double clicked
  140. #define PLVN_ITEMCOLUMNCLICKED (WORD)5 //not item but column is clicked(only in report view)
  141. #define PLVN_ITEMCOLUMNDBLCLICKED (WORD)6 //not item is column is clicked(only in report view)
  142. #define PLVN_R_ITEMCLICKED (WORD)7 //item data is clicked.
  143. #define PLVN_R_ITEMDBLCLICKED (WORD)8 //item data is double clicked
  144. #define PLVN_R_ITEMCOLUMNCLICKED (WORD)9 //not item but column is clicked(only in report view)
  145. #define PLVN_R_ITEMCOLUMNDBLCLICKED (WORD)10 //not item is column is clicked(only in report view)
  146. #define PLVN_HDCOLUMNCLICKED (WORD)20 //in Report view, header clicked.
  147. //in this case PLVINFO's colIndex is valid.
  148. #define PLVN_VSCROLLED (WORD)30 //970810: new.
  149. #ifdef UNDER_CE // Windows CE used ButtonDown/Up Event for ToolTip
  150. #define PLVN_ITEMDOWN (WORD)41 //item data is downed.
  151. #define PLVN_ITEMUP (WORD)42 //item data is upped.
  152. #endif // UNDER_CE
  153. typedef struct tagPLVINFO {
  154. INT code; //PLVN_XXXX
  155. INT index; //selected, or on item's index. it is same as wParam data.
  156. POINT pt; //mouse point in Pad listview client area
  157. RECT itemRect; //item's rectangle,
  158. INT colIndex; //if style is report view, column index is specifed.
  159. RECT colItemRect;//if style is report view column rectangle is specified.
  160. }PLVINFO, *LPPLVINFO;
  161. //////////////////////////////////////////////////////////////////
  162. // Function : PadListView_CreateWindow
  163. // Type : HWND
  164. // Purpose : Create PadListView control window.
  165. // Args :
  166. // : HINSTANCE hInst //instance handle
  167. // : HWND hwndParent //Parent window handle
  168. // : INT wID //ChildWindow's Identifier.
  169. // : INT x //horizontal position of window
  170. // : INT y //vertical position of window
  171. // : INT width //window width
  172. // : INT height //window height
  173. // : UINT uNotifyMsg //notify message. it should be Greater than WM_USER
  174. // Return : PadListView's window handle
  175. //////////////////////////////////////////////////////////////////
  176. extern HWND WINAPI PadListView_CreateWindow(HINSTANCE hInst,
  177. HWND hwndParent,
  178. INT wID,
  179. INT x,
  180. INT y,
  181. INT width,
  182. INT height,
  183. UINT uNotifyMsg);
  184. //////////////////////////////////////////////////////////////////
  185. // Function : PadListView_GetItemCount
  186. // Type : INT
  187. // Purpose : Get item count that was specified by user.
  188. // Args :
  189. // : HWND hwnd
  190. // Return : item count.(0<=)
  191. // DATE :
  192. //////////////////////////////////////////////////////////////////
  193. extern INT WINAPI PadListView_GetItemCount(HWND hwnd);
  194. //////////////////////////////////////////////////////////////////
  195. // Function : PadListView_SetItemCount
  196. // Type : INT
  197. // Purpose : Set total Item's count to PadListView.
  198. // : it effect's scroll bar.
  199. // Args :
  200. // : HWND hwnd
  201. // : INT itemCount
  202. // Return :
  203. // DATE :
  204. //////////////////////////////////////////////////////////////////
  205. extern INT WINAPI PadListView_SetItemCount(HWND hwnd, INT itemCount);
  206. //////////////////////////////////////////////////////////////////
  207. // Function : PadListView_SetTopIndex
  208. // Type : INT
  209. // Purpose : Set top index. Top index is left-top corner data(ICON VIEW)
  210. // : or top line(REPORT VIEW). index is ZERO-BASED. If top index is set as 10,
  211. // : PadListView display index 10's item at left-top or top in client area.
  212. // : It means scroll bar is automatically scrolled.
  213. // : In ICON VIEW, PadListView re-calc top index. because,
  214. // : top index should be Column data count * N.
  215. // : ICONV VIEW calc Column count from client width and item width.
  216. // : 100 item is set to PadListView, column count is 10,
  217. // : if user set top index as 5, it is re-calc to 0.
  218. // : if user set top index as 47, it is re-calc to 40.
  219. // Args :
  220. // : HWND hwnd
  221. // : INT indexTop
  222. // Return :
  223. // DATE :
  224. //////////////////////////////////////////////////////////////////
  225. extern INT WINAPI PadListView_SetTopIndex(HWND hwnd, INT indexTop);
  226. //////////////////////////////////////////////////////////////////
  227. // Function : PadListView_GetTopIndex
  228. // Type : INT
  229. // Purpose :
  230. // Args :
  231. // : HWND hwnd
  232. // Return : Top item index.
  233. // DATE :
  234. //////////////////////////////////////////////////////////////////
  235. extern INT WINAPI PadListView_GetTopIndex(HWND hwnd);
  236. //////////////////////////////////////////////////////////////////
  237. // Function : PadListView_SetIconItemCallback
  238. // Type : INT
  239. // Purpose : Set user defined Function that gets each Item's data
  240. // : in ICON VIEW
  241. // : PadListView call this function, when redraw client area.
  242. // : User must manage display data with index.
  243. // Args :
  244. // : HWND hwnd
  245. // : LPARAM lParam
  246. // : LPFNPLVITEMCALLBACK lpfnPlvItemCallback
  247. // Return :
  248. // DATE :
  249. //////////////////////////////////////////////////////////////////
  250. extern INT WINAPI PadListView_SetIconItemCallback(HWND hwnd, LPARAM lParam, LPFNPLVICONITEMCALLBACK lpfnIconItemCallback);
  251. //////////////////////////////////////////////////////////////////
  252. // Function : PadListView_SetReportItemCallback
  253. // Type : INT
  254. // Purpose : Set user defined Function that gets each column's data
  255. // : in Report view.
  256. // : User must manage display data with index and column index.
  257. // Args :
  258. // : HWND hwnd
  259. // : LPFNPLVCOLITEMCALLBACK lpfnColItemCallback
  260. // Return :
  261. // DATE :
  262. //////////////////////////////////////////////////////////////////
  263. extern INT WINAPI PadListView_SetReportItemCallback(HWND hwnd, LPARAM lParam, LPFNPLVREPITEMCALLBACK lpfnRepItemCallback);
  264. //////////////////////////////////////////////////////////////////
  265. // Function : PadListView_SetIconFont
  266. // Type : INT
  267. // Purpose : Set specifed Font for ICON View.
  268. // Args :
  269. // : HWND hwnd
  270. // : LPSTR lpstrFontName: NULL terminated font name.
  271. // : INT point: font point count.
  272. // Return :
  273. // DATE :
  274. //////////////////////////////////////////////////////////////////
  275. extern INT WINAPI PadListView_SetIconFont(HWND hwnd, LPTSTR lpstrFontName, INT point);
  276. //////////////////////////////////////////////////////////////////
  277. // Function : PadListView_SetReportFont
  278. // Type : INT
  279. // Purpose : Set specifed Font for REPORT VIEW.
  280. // Args :
  281. // : HWND hwnd
  282. // : LPSTR lpstrFontName
  283. // : INT point
  284. // Return :
  285. // DATE :
  286. //////////////////////////////////////////////////////////////////
  287. extern INT WINAPI PadListView_SetReportFont(HWND hwnd, LPTSTR lpstrFontName, INT point);
  288. //////////////////////////////////////////////////////////////////
  289. // Function : PadListView_GetStyle
  290. // Type : INT
  291. // Purpose : return current PadListView's style
  292. // Args :
  293. // : HWND hwnd
  294. // Return : PLVSTYLE_ICON or PLVSTYLE_REPORT
  295. // DATE :
  296. //////////////////////////////////////////////////////////////////
  297. extern INT WINAPI PadListView_GetStyle(HWND hwnd);
  298. //////////////////////////////////////////////////////////////////
  299. // Function : PadListView_SetStyle
  300. // Type : INT
  301. // Purpose : set the PadListView's style.
  302. // style is PLVSTYLE_LIST or PLVSTYLE_REPORT
  303. // Args :
  304. // : HWND hwnd
  305. // : INT style
  306. // Return :
  307. // DATE :
  308. //////////////////////////////////////////////////////////////////
  309. extern INT WINAPI PadListView_SetStyle(HWND hwnd, INT style);
  310. //////////////////////////////////////////////////////////////////
  311. // Function : PadListView_Update
  312. // Type : INT
  313. // Purpose : Repaint PadListView.
  314. // Args :
  315. // : HWND hwnd
  316. // Return :
  317. // DATE :
  318. //////////////////////////////////////////////////////////////////
  319. extern INT WINAPI PadListView_Update(HWND hwnd);
  320. //////////////////////////////////////////////////////////////////
  321. // Function : PadListView_InsertColumn
  322. // Type : INT
  323. // Purpose : Set header control's column data.
  324. // : most of feature is same as LVM_INSERTCOLUMN message.
  325. // Args :
  326. // : HWND hwnd
  327. // : INT index
  328. // : PLV_COLUMN * lpPlvCol
  329. // Return :
  330. // DATE :
  331. //////////////////////////////////////////////////////////////////
  332. extern INT WINAPI PadListView_InsertColumn(HWND hwnd, INT index, PLV_COLUMN *lpPlvCol);
  333. //extern INT WINAPI PadListView_DeleteColumn(HWND hwnd, INT index);
  334. //////////////////////////////////////////////////////////////////
  335. // Function : PadListView_SetExplanationText
  336. // Type : INT
  337. // Purpose : set the PadListView's text .
  338. // Args :
  339. // : HWND hwnd
  340. // : LPSTR lpText
  341. // Return :
  342. // DATE :
  343. //////////////////////////////////////////////////////////////////
  344. extern INT WINAPI PadListView_SetExplanationText(HWND hwnd, LPSTR lpText);
  345. extern INT WINAPI PadListView_SetExplanationTextW(HWND hwnd, LPWSTR lpText);
  346. //////////////////////////////////////////////////////////////////
  347. // Function : PadListView_SetCurSel
  348. // Type : INT
  349. // Purpose : set cur selection. Move cursor to specified index.
  350. // :
  351. // Args :
  352. // : HWND hwnd
  353. // : LPSTR lpText
  354. // Return :
  355. // DATE :
  356. //////////////////////////////////////////////////////////////////
  357. extern INT WINAPI PadListView_SetCurSel(HWND hwnd, INT index);
  358. extern INT WINAPI PadListView_SetExtendStyle(HWND hwnd, INT style);
  359. //////////////////////////////////////////////////////////////////
  360. // Function : PadListView_GetWidthByColumn
  361. // Type : INT WINAPI
  362. // Purpose : Calc PLV's window width by specified Column count
  363. // : This is PLVS_ICONVIEW style only.
  364. // Args :
  365. // : HWND hwnd PadListView window handle
  366. // : INT col column count
  367. // Return : width by pixel.
  368. // DATE : 971120
  369. //////////////////////////////////////////////////////////////////
  370. extern INT WINAPI PadListView_GetWidthByColumn(HWND hwnd, INT col);
  371. //////////////////////////////////////////////////////////////////
  372. // Function : PadListView_GetHeightByRow
  373. // Type : INT WINAPI
  374. // Purpose : Calc PLV's window height
  375. // by specified Row count.
  376. // This is PLVS_ICONVIEW style only.
  377. // Args :
  378. // : HWND hwnd PLV's window handle
  379. // : INT row row count
  380. // Return : height in pixel
  381. // DATE : 971120
  382. //////////////////////////////////////////////////////////////////
  383. extern INT WINAPI PadListView_GetHeightByRow(HWND hwnd, INT row);
  384. //////////////////////////////////////////////////////////////////
  385. // Function : PadListView_SetHeaderFont
  386. // Type : INT WINAPI
  387. // Purpose :
  388. // Args :
  389. // : HWND hwnd
  390. // : LPSTR lpstrFontName
  391. // Return :
  392. // DATE : Tue Jul 28 08:58:06 1998
  393. // Histroy :
  394. //////////////////////////////////////////////////////////////////
  395. extern INT WINAPI PadListView_SetHeaderFont(HWND hwnd, LPTSTR lpstrFontName);
  396. //////////////////////////////////////////////////////////////////
  397. // Function : PadListView_SetCodePage
  398. // Type : INT WINAPI
  399. // Purpose :
  400. // Args :
  401. // : HWND hwnd
  402. // : INT codePage
  403. // Return :
  404. // DATE : Tue Jul 28 08:59:35 1998
  405. // Histroy :
  406. //////////////////////////////////////////////////////////////////
  407. extern INT WINAPI PadListView_SetCodePage(HWND hwnd, INT codePage);
  408. extern INT WINAPI PadListView_SetIconFontEx(HWND hwnd,
  409. LPTSTR lpstrFontName,
  410. INT charSet,
  411. INT point);
  412. extern INT WINAPI PadListView_SetReportFontEx(HWND hwnd,
  413. LPTSTR lpstrFontName,
  414. INT charSet,
  415. INT point);
  416. #ifdef UNDER_CE // In Windows CE, all window classes are process global.
  417. extern BOOL PadListView_UnregisterClass(HINSTANCE hInst);
  418. #endif // UNDER_CE
  419. #endif //_PAD_LIST_VIEW_H_