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.

312 lines
10 KiB

  1. /*
  2. * table.h
  3. *
  4. * public interface definition for table window class.
  5. *
  6. * include after gutils.h and commdlg.h
  7. */
  8. /*
  9. * The table class communicates with its 'owner' window to
  10. * get the layout info and the data to display. The owner window handle
  11. * can be sent as the lParam in CreateWindow - if not, the parent window will
  12. * be used.
  13. *
  14. * After creating the window, send it a TM_NEWID message, with a 'data id'
  15. * as the lParam. This is any non-zero 32-bit value. The table will then call
  16. * back to its owner window to find out how many rows/columns, then to fetch
  17. * the name/properties of each column, and finally to get the data to display.
  18. *
  19. * Send TM_NEWID of 0 to close (or destroy the window) - wait for TQ_CLOSE
  20. * (in either case) before discarding data. Send
  21. * TM_REFRESH if data or row-count changes; send TM_NEWLAYOUT if column
  22. * properties or nr cols change etc - this is the same as sending TM_NEWID
  23. * except that no TQ_CLOSE happens on TM_NEWLAYOUT.
  24. *
  25. * TQ_SELECT is sent whenever the current selection changes. TQ_ENTER is sent
  26. * when enter or double-click occurs.
  27. */
  28. /* -------class and message names --------------------------------------*/
  29. /* create a window of this class */
  30. #define TableClassName "GTableClass"
  31. /* all messages to the owner window are sent with this message.
  32. * call RegisterWindowsMessage with this string for the message UINT.
  33. */
  34. #define TableMessage "GTableQuery"
  35. /* -------- messages to and from table class --------------------------*/
  36. /* messages to owner window are:
  37. * message: TableMessage
  38. * wParam: command code (below)
  39. * lParam: struct pointer according to code
  40. * below is list of wParam codes & associated lParam struct
  41. */
  42. #define TQ_GETSIZE 1 /* lParam: lpTableHdr */
  43. #define TQ_GETCOLPROPS 2 /* lParam: lpColPropList */
  44. #define TQ_GETDATA 3 /* lParam: lpCellDataList */
  45. #define TQ_PUTDATA 4 /* lParam: lpCellDataList */
  46. #define TQ_SELECT 5 /* lParam: lpTableSelection */
  47. #define TQ_ENTER 6 /* lParam: lpTableSelection */
  48. #define TQ_CLOSE 7 /* lParam: the data id to be closed */
  49. /* optional */
  50. #define TQ_SCROLL 8 /* lParam: the new top row nr */
  51. #define TQ_TABS 9 /* lParam: LONG *, write tab here */
  52. #define TQ_SHOWWHITESPACE 10 /* lParam: LONG *, write show_whitespace value here */
  53. /* messages to Table class */
  54. /* data, or nrows has changed wParam/lParam null*/
  55. #define TM_REFRESH (WM_USER)
  56. /* nr cols/props/layout has changed - wparam/lparam null */
  57. #define TM_NEWLAYOUT (WM_USER+1)
  58. /* close old id, and display new - wParam null, lParam has new id */
  59. #define TM_NEWID (WM_USER+2)
  60. /* select and show this area - wParam null, lParam is lpTableSelection */
  61. #define TM_SELECT (WM_USER+3)
  62. /* please print current table - wParam null, lParam either null
  63. * or lpPrintContext.
  64. */
  65. #define TM_PRINT (WM_USER+4)
  66. /* return the top row in the window. If wParam is TRUE, then set
  67. * lParam to be the new toprow. top row is the number of rows scrolled down
  68. * from the top. Thus the first visible non-fixed row is toprow+fixedrows
  69. */
  70. #define TM_TOPROW (WM_USER+5)
  71. /* return the end row visible. This is the 0-based rownr of the last
  72. * visible row in the window
  73. */
  74. #define TM_ENDROW (WM_USER+6)
  75. /* new rows have been added to the end of the table, but no other
  76. * rows or cols or properties have been changed.
  77. * wParam contains the new total nr of rows. lParam contains the id
  78. * in case this has changed.
  79. */
  80. #define TM_APPEND (WM_USER+7)
  81. /*
  82. * return the current selection - lParam is a lpTableSelection
  83. */
  84. #define TM_GETSELECTION (WM_USER+8)
  85. /*
  86. * set the tab width - wParam null, lParam is new tab width
  87. */
  88. #define TM_SETTABWIDTH (WM_USER+9)
  89. /*-----display properties -------------------------------------------------*/
  90. /*
  91. * display properties struct. can be set for whole table, for
  92. * each column, or for each cell. When looking for
  93. * a property, we search cell->column->table
  94. */
  95. typedef struct {
  96. UINT valid; /* flags (below) for what props we set */
  97. /* remaining fields only valid when corresponding flag set in valid */
  98. DWORD forecolour; /* RGB colour value */
  99. DWORD forecolourws; /* ditto */
  100. DWORD backcolour; /* ditto */
  101. /* font to use - also set through WM_SETFONT. owner application
  102. * is responsible for DeleteObject call when no longer used
  103. */
  104. HFONT hFont; /* handle to font - caller should delete*/
  105. UINT alignment; /* flags below */
  106. UINT box; /* whether cell boxed (see below) */
  107. /* width/height settings not valid at cell level - only table or col.*/
  108. int width; /* pixel width of this cell/column */
  109. int height; /* pixel cell height */
  110. } Props, FAR * lpProps;
  111. /* valid flags for fields that are changed in this Props struct */
  112. #define P_FCOLOUR 0x01
  113. #define P_FCOLOURWS 0x02
  114. #define P_BCOLOUR 0x04
  115. #define P_FONT 0x08
  116. #define P_ALIGN 0x10
  117. #define P_BOX 0x20
  118. #define P_WIDTH 0x40
  119. #define P_HEIGHT 0x80
  120. /* box settings or-ed together */
  121. #define P_BOXTOP 1
  122. #define P_BOXBOTTOM 2
  123. #define P_BOXLEFT 4
  124. #define P_BOXRIGHT 8
  125. #define P_BOXALL 0xF
  126. /* alignment settings (expand later to include various tab-align settings */
  127. #define P_LEFT 0
  128. #define P_RIGHT 1
  129. #define P_CENTRE 2
  130. /* default tab width in chars */
  131. #define TABWIDTH_DEFAULT 8
  132. /* --- main header -------------------------------------------------------*/
  133. /* this struct is the master information about a table. It is
  134. * passed to the owner window with the id field filled in; fill in
  135. * all remaining fields and return.
  136. */
  137. typedef struct {
  138. DWORD_PTR id; /* owner's data id */
  139. /* please fill in rest: */
  140. long nrows; /* how many rows ? TM_REFRESH to change */
  141. int ncols; /* how many columns ? TM_NEWLAYOUT to chg */
  142. int fixedrows; /* for headers - usually 0 or 1 */
  143. int fixedcols; /* for hdrs - 0 or 1 normally */
  144. BOOL fixedselectable; /* is fixed area selectable ? */
  145. BOOL hseparator; /* is there a horz. line after fixed rows */
  146. BOOL vseparator; /* is there a vert. line after fixed rows */
  147. UINT selectmode; /* multiple/single selection - flags below*/
  148. BOOL sendscroll; /* TRUE if TQ_SCROLL to be sent on scrolling*/
  149. Props props;
  150. } TableHdr, FAR * lpTableHdr;
  151. /*
  152. * selection mode;
  153. *
  154. * choose TM_CELL or TM_ROW, and TM_SINGLE or TM_MANY, and
  155. * TM_SOLID or TM_FOCUS and or them together.
  156. *
  157. */
  158. #define TM_ROW 1 /* selectable items are rows */
  159. #define TM_CELL 0 /* selectable items are cells */
  160. #define TM_MANY 2 /* multiple selects possible */
  161. #define TM_SINGLE 0 /* single item selectable at once only */
  162. #define TM_SOLID 0 /* (default) use a solid black for selection*/
  163. #define TM_FOCUS 4 /* use a dotted focus rect for selection */
  164. /* --------- column header structs --------------------------------------*/
  165. /*
  166. * this struct is sent to request column width and properties -
  167. * owner window must fill nchars and props.valid, at minimum.
  168. */
  169. typedef struct {
  170. int nchars; /* expected text width in chars */
  171. Props props;
  172. } ColProps, FAR * lpColProps;
  173. /* this is a set of column requests - owner should fill each one*/
  174. typedef struct {
  175. DWORD_PTR id; /* caller's id for data */
  176. int startcol; /* zero-based column nr of first request */
  177. int ncols; /* nr of columns in this set */
  178. lpColProps plist; /* ptr to _array_ of ColProps */
  179. } ColPropsList, FAR * lpColPropsList;
  180. /* --- cell data structs ---------------------------------------------*/
  181. /* this is the per-cell data struct.
  182. * When providing data (responding to TQ_GETDATA), fill out ptext[] and
  183. * props as appropriate. ptext will be pre-allocated with nchars bytes of
  184. * space. This may be larger than ColProps->nchars if the user has
  185. * stretched this column's width on screen
  186. *
  187. * don't re-alloc ptext, or change flags.
  188. */
  189. typedef struct {
  190. int nchars; /* space in buffer */
  191. LPSTR ptext; /* ptr to nchars of text space */
  192. Props props; /* per-cell props */
  193. DWORD flags; /* private table class flags */
  194. LPWSTR pwzText; /* ptr to nchars of WCHAR space */
  195. } CellData, FAR * lpCellData;
  196. /* list of cell data structures - please fill out all of these*/
  197. typedef struct {
  198. DWORD_PTR id; /* caller's id for data */
  199. long row; /* zero-based row nr to fetch */
  200. int startcell; /* zero-based cell nr on this row */
  201. int ncells; /* count of cells to fetch */
  202. lpCellData plist; /* ptr to array CellData[ncells] */
  203. } CellDataList, FAR * lpCellDataList;
  204. /*----- current selection----------------------------------------------*/
  205. /*
  206. * describes the current selection - a rectangular selection area
  207. *
  208. * Note that if the TM_MANY selection mode is used, startrow and startcell will
  209. * be the end-point (most recently selected end) of the selection, and
  210. * nrows, ncells may be positive or negative. +1 and -1 both mean just the
  211. * 1 row startrow, -2 means startrow and the one before, etc. 0 nrows means
  212. * no valid selection.
  213. */
  214. typedef struct {
  215. DWORD_PTR id; /* caller's id for data */
  216. long startrow; /* zero-based row nr of start of sel. */
  217. long startcell; /* zero-based col nr of start of sel */
  218. long nrows; /* vertical depth of selection */
  219. long ncells; /* horz width of selection */
  220. long dyRowsFromTop; /* -1 means used auto-center logic, otherwise put selection this many rows from top */
  221. } TableSelection, FAR * lpTableSelection;
  222. /*----- print context -----------------------------------------------*/
  223. /* describes the margin settings for the print job - these are in CMs*/
  224. typedef struct {
  225. int left; /* edge of paper to start of print area */
  226. int right; /* edge of paper to start of print area */
  227. int top; /* edge of paper to start of hdr */
  228. int bottom; /* end of hdr to end of paper */
  229. int topinner; /* start of hdr to start of data */
  230. int bottominner; /* end of data to start of hdr */
  231. } Margin, FAR * lpMargin;
  232. /* position and clipping info - only used by table class
  233. */
  234. typedef struct {
  235. int start; /* co-ord of cell start (left or top) */
  236. int clipstart; /* start of clipping (vis area) */
  237. int clipend; /* end of clipping (vis area) */
  238. int size; /* pixel size of cell (width or height) */
  239. } CellPos, FAR * lpCellPos;
  240. /* one of these for each header lines (top and bottom) */
  241. typedef struct {
  242. CellPos xpos, ypos; /* private: for table-class use only */
  243. Props props;
  244. LPSTR ptext;
  245. } Title, FAR * lpTitle;
  246. /* Print context data structure - any or all 4 pointers may be null */
  247. typedef struct {
  248. DWORD_PTR id; /* id of table to print */
  249. lpTitle head;
  250. lpTitle foot;
  251. lpMargin margin;
  252. PRINTDLG FAR * pd;
  253. } PrintContext, FAR * lpPrintContext;