home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / windiff / table.h < prev    next >
Text File  |  1997-10-05  |  10KB  |  276 lines

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