MatrixP.h
16.4 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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
/*
* Copyright(c) 1992 Bell Communications Research, Inc. (Bellcore)
* All rights reserved
* Permission to use, copy, modify and distribute this material for
* any purpose and without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies, and that the name of Bellcore not be used in advertising
* or publicity pertaining to this material without the specific,
* prior written permission of an authorized representative of
* Bellcore.
*
* BELLCORE MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, EX-
* PRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST IN-
* FRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS. THE
* SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL BELLCORE OR
* ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY
* LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELAT-
* ING TO THE SOFTWARE.
*
* MatrixWidget Author: Andrew Wason, Bellcore, aw@bae.bellcore.com
*
* Revisions:
* 1/93: Added textBackground resource (create/set/get).
* 2/93: Added verticalScrollBar and horizontalScrollBar resources (get only).
* 9/94: Added selectScrollVisible resource
*/
/*
* MatrixP.h - Private definitions for Matrix widget
*/
#ifndef _Xbae_MatrixP_h
#define _Xbae_MatrixP_h
#if XmVersion <= 1001
# include <Xm/XmP.h>
#else
# include <Xm/ManagerP.h>
#endif
#include "Matrix.h"
#include <limits.h>
#ifndef P
#if defined(__STDC__) || defined (__cplusplus)
#define P(x) x
#else
#define P(x) ()
#define const
#define volatile
#endif
#endif
/*
* A few definitions we like to use, but those with R4 won't have.
* From Xfuncproto.h in R5.
*/
#ifndef XlibSpecificationRelease
# ifndef _XFUNCPROTOBEGIN
# ifdef __cplusplus /* for C++ V2.0 */
# define _XFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */
# define _XFUNCPROTOEND }
# else
# define _XFUNCPROTOBEGIN
# define _XFUNCPROTOEND
# endif
# endif /* _XFUNCPROTOBEGIN */
#endif
/*
* New types for the class methods
*/
_XFUNCPROTOBEGIN
typedef void (*XbaeMatrixSetCellProc) P((
XbaeMatrixWidget w, int row, int column, const String value,
Boolean update_text ));
typedef String (*XbaeMatrixGetCellProc) P((
XbaeMatrixWidget w, int row, int column ));
typedef void (*XbaeMatrixEditCellProc) P((
XbaeMatrixWidget w, int row, int column ));
typedef void (*XbaeMatrixSelectCellProc) P((
XbaeMatrixWidget w, int row, int column ));
typedef void (*XbaeMatrixSelectRowProc) P((
XbaeMatrixWidget w, int row ));
typedef void (*XbaeMatrixSelectColumnProc) P((
XbaeMatrixWidget w, int column ));
typedef void (*XbaeMatrixDeselectAllProc) P((
XbaeMatrixWidget w ));
typedef void (*XbaeMatrixSelectAllProc) P((
XbaeMatrixWidget w ));
typedef void (*XbaeMatrixDeselectCellProc) P((
XbaeMatrixWidget w, int row, int column ));
typedef void (*XbaeMatrixDeselectRowProc) P((
XbaeMatrixWidget w, int row ));
typedef void (*XbaeMatrixDeselectColumnProc) P((
XbaeMatrixWidget w, int column ));
typedef Boolean (*XbaeMatrixCommitEditProc) P((
XbaeMatrixWidget w, Boolean unmap ));
typedef void (*XbaeMatrixCancelEditProc) P((
XbaeMatrixWidget w, Boolean unmap ));
typedef void (*XbaeMatrixAddRowsProc) P((
XbaeMatrixWidget w, int position, String *rows, String *labels,
Pixel *colors, Pixel *backgrounds, int num_rows ));
typedef void (*XbaeMatrixDeleteRowsProc) P((
XbaeMatrixWidget w, int position, int num_rows ));
typedef void (*XbaeMatrixAddColumnsProc) P((
XbaeMatrixWidget w, int position, String *columns, String *labels,
short *widths, int *max_lengths, unsigned char* alignments,
unsigned char *label_alignments, Pixel *colors, Pixel *backgrounds,
int num_columns ));
typedef void (*XbaeMatrixDeleteColumnsProc) P((
XbaeMatrixWidget w, int position, int num_columns ));
typedef void (*XbaeMatrixSetRowColorsProc) P((
XbaeMatrixWidget w, int position, Pixel *colors, int num_colors,
Boolean bg ));
typedef void (*XbaeMatrixSetColumnColorsProc) P((
XbaeMatrixWidget w, int position, Pixel *colors, int num_colors,
Boolean bg ));
typedef void (*XbaeMatrixSetCellColorProc) P((
XbaeMatrixWidget w, int row, int column, Pixel color, Boolean bg ));
_XFUNCPROTOEND
/*
* Different than the traversal directions in Xm.h
*/
#define NOT_TRAVERSING -1
/*
* New fields for the Matrix widget class record
*/
typedef struct {
XbaeMatrixSetCellProc set_cell;
XbaeMatrixGetCellProc get_cell;
XbaeMatrixEditCellProc edit_cell;
XbaeMatrixSelectCellProc select_cell;
XbaeMatrixSelectRowProc select_row;
XbaeMatrixSelectColumnProc select_column;
XbaeMatrixDeselectAllProc deselect_all;
XbaeMatrixSelectAllProc select_all;
XbaeMatrixDeselectCellProc deselect_cell;
XbaeMatrixDeselectRowProc deselect_row;
XbaeMatrixDeselectColumnProc deselect_column;
XbaeMatrixCommitEditProc commit_edit;
XbaeMatrixCancelEditProc cancel_edit;
XbaeMatrixAddRowsProc add_rows;
XbaeMatrixDeleteRowsProc delete_rows;
XbaeMatrixAddColumnsProc add_columns;
XbaeMatrixDeleteColumnsProc delete_columns;
XbaeMatrixSetRowColorsProc set_row_colors;
XbaeMatrixSetColumnColorsProc set_column_colors;
XbaeMatrixSetCellColorProc set_cell_color;
XtPointer extension;
} XbaeMatrixClassPart;
/*
* Full class record declaration
*/
typedef struct _XbaeMatrixClassRec {
CoreClassPart core_class;
CompositeClassPart composite_class;
ConstraintClassPart constraint_class;
XmManagerClassPart manager_class;
XbaeMatrixClassPart matrix_class;
} XbaeMatrixClassRec;
externalref XbaeMatrixClassRec xbaeMatrixClassRec;
/*
* Inheritance constants for set/get/edit methods
*/
#define XbaeInheritGetCell ((XbaeMatrixGetCellProc) _XtInherit)
#define XbaeInheritSetCell ((XbaeMatrixSetCellProc) _XtInherit)
#define XbaeInheritEditCell ((XbaeMatrixEditCellProc) _XtInherit)
#define XbaeInheritSelectCell ((XbaeMatrixSelectCellProc) _XtInherit)
#define XbaeInheritSelectRow ((XbaeMatrixSelectRowProc) _XtInherit)
#define XbaeInheritSelectColumn ((XbaeMatrixSelectColumnProc) _XtInherit)
#if XmVersion >= 1002
#define XbaeInheritHighlightCell ((XbaeMatrixHighlightCellProc) _XtInherit)
#define XbaeInheritHighlightRow ((XbaeMatrixHighlightRowProc) _XtInherit)
#define XbaeInheritHighlightColumn ((XbaeMatrixHighlightColumnProc) _XtInherit)
#endif
#define XbaeInheritDeselectAll ((XbaeMatrixDeselectAllProc) _XtInherit)
#define XbaeInheritSelectAll ((XbaeMatrixSelectAllProc) _XtInherit)
#define XbaeInheritDeselectCell ((XbaeMatrixDeselectCellProc) _XtInherit)
#define XbaeInheritDeselectRow ((XbaeMatrixDeselectRowProc) _XtInherit)
#define XbaeInheritDeselectColumn ((XbaeMatrixDeselectColumnProc) _XtInherit)
#define XbaeInheritCommitEdit ((XbaeMatrixCommitEditProc) _XtInherit)
#define XbaeInheritCancelEdit ((XbaeMatrixCancelEditProc) _XtInherit)
#define XbaeInheritAddRows ((XbaeMatrixAddRowsProc) _XtInherit)
#define XbaeInheritDeleteRows ((XbaeMatrixDeleteRowsProc) _XtInherit)
#define XbaeInheritAddColumns ((XbaeMatrixAddColumnsProc) _XtInherit)
#define XbaeInheritDeleteColumns ((XbaeMatrixDeleteColumnsProc)_XtInherit)
#define XbaeInheritSetRowColors ((XbaeMatrixSetRowColorsProc)_XtInherit)
#define XbaeInheritSetColumnColors ((XbaeMatrixSetColumnColorsProc)_XtInherit)
#define XbaeInheritSetCellColor ((XbaeMatrixSetCellColorProc)_XtInherit)
/*
* New data structures for the ScrollMgr code
*/
typedef struct _SmScrollNode {
int x;
int y;
struct _SmScrollNode *next;
struct _SmScrollNode *prev;
} SmScrollNodeRec, *SmScrollNode;
typedef struct _SmScrollMgr {
int offset_x;
int offset_y;
int scroll_count;
SmScrollNode scroll_queue;
Boolean scrolling;
} SmScrollMgrRec, *SmScrollMgr;
/*
* Rectangle struct used for internal calculations. (x1,y1) are the upper
* left corner, (x2,y2) are the lower right.
*/
typedef struct _Rectangle
{
int x1, y1;
int x2, y2;
}
Rectangle;
/*
* Data structure for column labels
*/
typedef struct _ColumnLabelLines {
int lines;
int *lengths;
} ColumnLabelLinesRec, *ColumnLabelLines;
/*
* New fields for the Matrix widget record
*/
typedef struct {
/*
* resources
*/
Boolean fill; /* fill available space? */
Boolean bold_labels; /* draw bold row/column labels? */
Boolean button_labels; /* draw labels as buttons? */
Boolean allow_column_resize; /* can columns dynamically resize? */
Boolean **selected_cells; /* 2D array of selected cells */
Boolean scroll_select; /* flag to scroll a selected cell */
Boolean reverse_select; /* reverse colours - selected cells? */
unsigned char *column_alignments; /* alignment of each column */
unsigned char *column_label_alignments;/* alignment of each column label */
unsigned char row_label_alignment; /* alignment of row labels */
unsigned char vsb_display_policy; /* vert scroll bar display policy */
unsigned char hsb_display_policy; /* horiz scroll bar display policy */
unsigned char scrollbar_placement; /* placement of the scrollbars */
unsigned char cell_shadow_type; /* cell shadow type */
unsigned char shadow_type; /* matrix window shadow type */
unsigned char grid_type; /* shadowed in/shadowed out/plain */
unsigned char **cell_shadow_types; /* 2D array of per cell shadow type */
unsigned char *row_shadow_types; /* 1D array of per row shadow types */
unsigned char *column_shadow_types; /* 1D array of per col shadow types */
#if XmVersion >= 1002
unsigned char **highlighted_cells; /* 2D array of highlighted cells */
#endif
String **cells; /* 2D array of strings */
String *row_labels; /* array of labels next to each row */
String *column_labels; /* array of labels above each column */
XtPointer **cell_user_data; /* 2D array of per cell user data */
XtPointer *row_user_data; /* 1D array of per row user data */
XtPointer *column_user_data; /* 1D array of per column user data */
short *column_widths; /* width of each column in chars */
short row_label_width; /* max width of row labels in chars */
int rows; /* number of rows per column */
int columns; /* number of cells per column */
int alt_row_count; /* # of rows for e/o background */
int top_row; /* vertical origin (in row space) */
int left_column; /* horizontal origin (in col space) */
int double_click_interval; /* interval between clicks */
int *column_max_lengths; /* max length of each col in chars */
Dimension fixed_rows; /* number of leading fixed rows */
Dimension fixed_columns; /* number of leading fixed columns */
Dimension trailing_fixed_rows; /* number of trailing fixed rows */
Dimension trailing_fixed_columns; /* number of trailing fixed columns */
Dimension visible_columns; /* number of columns to make visible */
Dimension visible_rows; /* number of rows to make visible */
Dimension space; /* spacing for scrollbars */
Dimension cell_margin_width; /* margin width for textField */
Dimension cell_margin_height; /* margin height for textField */
Dimension cell_shadow_thickness; /* shadow thickness for each cell */
Dimension cell_highlight_thickness; /* hilite thickness for textField */
Pixel text_background; /* background for the "text" field */
Pixel **colors; /* 2D array of Pixels */
Pixel **cell_background; /* 2D array of Pixels */
Pixel row_label_color; /* color of row label */
Pixel column_label_color; /* color of column label */
Pixel button_label_background; /* color of button label background */
Pixel even_row_background; /* even row background color */
Pixel odd_row_background; /* odd row background color */
Pixel selected_foreground; /* foreground for selected cells */
Pixel selected_background; /* background for selected cells */
Pixel grid_line_color; /* color of grid, for XmGrid_LINE */
XtTranslations text_translations; /* translations for textField widget */
XtCallbackList modify_verify_callback; /* verify change to textField */
XtCallbackList enter_cell_callback; /* called when a cell is entered */
XtCallbackList leave_cell_callback; /* called when a cell is left */
XtCallbackList traverse_cell_callback; /* next cell to traverse to */
XtCallbackList select_cell_callback; /* called when cells are selected */
XtCallbackList draw_cell_callback; /* called when a cell is drawn */
XtCallbackList write_cell_callback; /* called when a cell needs to be set
and a draw_cell_callback is set */
XtCallbackList resize_callback; /* called when Matrix is resized */
XtCallbackList resize_column_callback; /* called when column is resized */
XtCallbackList default_action_callback; /* called for a double click */
XtCallbackList process_drag_callback; /* called when a drag is initiated */
XtCallbackList label_activate_callback; /* called when label pressed */
XmFontList font_list; /* fontList of widget and textField */
XmFontList label_font_list; /* fontList of labels */
Widget vertical_sb; /* the vertical scrollbar */
Widget horizontal_sb; /* the horizontal scrollbar */
Widget clip_window; /* the clip child */
Widget text_field; /* the text field */
#if CELL_WIDGETS
Widget **cell_widgets; /* array of widgets for cells */
#endif
/*
* private state
*/
#if XmVersion >= 1002
unsigned char highlight_location; /* What is being highlighted */
#endif
int horiz_origin; /* horiz origin (in pixel space) */
int current_row; /* row of the text field */
int current_column; /* column of the text field */
int text_baseline; /* baseline of text in each cell */
int label_baseline; /* baseline of label */
int cell_visible_height; /* height of visible cells in pixels */
int num_selected_cells; /* The number selected cells */
int traversing; /* direction we are traversing */
int column_label_maxlines; /* max # lines in column labels */
int last_row; /* The last selected row */
int last_column; /* The last selected column */
int *column_positions; /* pixel position of each column */
unsigned int cell_total_width; /* width of cell area in pixels */
unsigned int current_clip; /* current clip mask setting */
unsigned int disable_redisplay; /* disable redisplay counter */
Dimension desired_width; /* width widget wants to be */
Dimension desired_height; /* height widget wants to be */
Time last_click_time; /* when last ButtonPress occurred */
GC draw_gc; /* GC for drawing cells */
GC draw_clip_gc; /* GC for clipped cells */
GC label_gc; /* GC for drawing labels */
GC label_clip_gc; /* GC for clipped labels */
GC cell_top_shadow_clip_gc; /* GC for clipped top shadow */
GC cell_bottom_shadow_clip_gc; /* GC for clipped bottom shadow */
GC resize_top_shadow_gc;
GC resize_bottom_shadow_gc;
GC cell_grid_line_gc;
GC grid_line_gc; /* GC for grid line */
GC pixmap_gc; /* GC for drawing pixmap cells */
GC pixmap_clip_gc; /* GC for clipped pixmap cells */
#if XmVersion >= 1002
GC highlight_clip_gc; /* GC for clipped highlighting */
#endif
ColumnLabelLines column_label_lines; /* structs for multi line labels */
XFontStruct *font; /* fontStruct from fontList */
XFontStruct *label_font; /* fontStruct from fontList */
SmScrollMgr matrix_scroll_mgr; /* ScrollMgr for Matrix */
SmScrollMgr clip_scroll_mgr; /* ScrollMgr for Clip */
} XbaeMatrixPart;
/*
* Full instance record declaration
*/
typedef struct _XbaeMatrixRec {
CorePart core;
CompositePart composite;
ConstraintPart constraint;
XmManagerPart manager;
XbaeMatrixPart matrix;
} XbaeMatrixRec;
/* provide clean-up for those with R4 */
#ifndef XlibSpecificationRelease
# undef _Xconst
# undef _XFUNCPROTOBEGIN
# undef _XFUNCPROTOEND
#endif
#undef P
#endif /* _Xbae_MatrixP_h */