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