1 | #ifndef _XmpTableP_h |
---|
2 | #define _XmpTableP_h |
---|
3 | #include <X11/Xmp/COPY.h> |
---|
4 | |
---|
5 | /* |
---|
6 | * SCCS_data: %Z% %M% %I% %E% %U% |
---|
7 | * |
---|
8 | * XmpTable - Forms-based composite widget/geometry manager derived from |
---|
9 | * Motif manager widgets. Class heirarchy: |
---|
10 | * Core |
---|
11 | * Composite |
---|
12 | * Constraint |
---|
13 | * XmManager |
---|
14 | * XmBulletinBoard |
---|
15 | * XmpTable |
---|
16 | * |
---|
17 | * Originally implemented by: |
---|
18 | * David Harrison |
---|
19 | * University of California, Berkeley |
---|
20 | * 1989 |
---|
21 | * |
---|
22 | * Many bug fixes and enhancements provided by |
---|
23 | * marbru@auto-trol.com Martin Brunecky |
---|
24 | * nazgul@alphalpha.com Kee Hinckley |
---|
25 | * pastor@PRC.Unisys.COM Jon A. Pastor |
---|
26 | * |
---|
27 | * Completely re-implemented by: |
---|
28 | * David.Smyth@SniAP.MchP.SNI.De |
---|
29 | */ |
---|
30 | |
---|
31 | #include <X11/Xmp/Table.h> |
---|
32 | #include <Xm/XmP.h> |
---|
33 | #include <Xm/BulletinBP.h> |
---|
34 | |
---|
35 | BEGIN_NOT_Cxx |
---|
36 | |
---|
37 | /* Method definitions |
---|
38 | **====================** |
---|
39 | No new methods. I can't imagine how anyone is going to sub-class |
---|
40 | THIS Widget, as the coupling between the behavior and the instance |
---|
41 | members is rather intense! |
---|
42 | */ |
---|
43 | |
---|
44 | /* Table Class Part: Information kept in class record |
---|
45 | **====================================================** |
---|
46 | */ |
---|
47 | |
---|
48 | typedef struct _XmpTableClassPart { |
---|
49 | caddr_t extension; |
---|
50 | } XmpTableClassPart; |
---|
51 | |
---|
52 | /* Class hierarchy |
---|
53 | **=================** |
---|
54 | */ |
---|
55 | |
---|
56 | typedef struct _XmpTableClassRec { |
---|
57 | CoreClassPart core_class; |
---|
58 | CompositeClassPart composite_class; |
---|
59 | ConstraintClassPart constraint_class; |
---|
60 | XmManagerClassPart manager_class; |
---|
61 | XmBulletinBoardClassPart bulletin_class; |
---|
62 | XmpTableClassPart table_class; |
---|
63 | } XmpTableClassRec; |
---|
64 | |
---|
65 | extern XmpTableClassRec xmpTableClassRec; |
---|
66 | |
---|
67 | |
---|
68 | /* Private data types |
---|
69 | **====================** |
---|
70 | All of these structures are often used as elements of null terminated arrays. |
---|
71 | */ |
---|
72 | |
---|
73 | /* Table Location structs. |
---|
74 | **========================** |
---|
75 | These are used to describe each widget location, in both the |
---|
76 | default_layout and the real_layout. In the default_layout, the |
---|
77 | location structs contain a quark, in the real_layout they contain the |
---|
78 | actual widget and the orig* fields are set. |
---|
79 | */ |
---|
80 | typedef struct _XmpTableLoc { |
---|
81 | XrmQuark w_quark; /* Widget name quark */ |
---|
82 | Widget w; /* actual widget */ |
---|
83 | int col, row; /* Position in table */ |
---|
84 | int col_span, row_span; /* Positions spanned */ |
---|
85 | int orig_width, orig_height;/* Childs orig size ... */ |
---|
86 | int orig_border_width; /* ... and border width */ |
---|
87 | int same_width, same_height;/* Childs pref size if */ |
---|
88 | int same_border; /* in a SameSize list */ |
---|
89 | XmpTableOpts options; /* Child layout options */ |
---|
90 | } XmpTableLocRec; /* *XmpTableLoc */ |
---|
91 | |
---|
92 | /* TableLoc Methods |
---|
93 | **==================** |
---|
94 | */ |
---|
95 | #define TABLE XmpTableWidget |
---|
96 | |
---|
97 | extern XmpTableLoc XmpTableLocNew _(( int /*count*/ )); |
---|
98 | extern XmpTableLoc XmpTableLocParse _(( char* /*layout*/ )); |
---|
99 | extern XmpTableLoc XmpTableLocGrow _(( XmpTableLoc )); |
---|
100 | extern XmpTableLoc XmpTableLocCopy _(( XmpTableLoc )); |
---|
101 | extern XmpTableLoc XmpTableLocFind _(( XmpTableLoc, Widget )); |
---|
102 | extern XmpTableLoc XmpTableLocFindDefault _(( XmpTableLoc, Widget )); |
---|
103 | extern XmpTableLoc XmpTableLocFindAtPosition _(( XmpTableLoc, int, int )); |
---|
104 | extern int XmpTableLocLen _(( XmpTableLoc )); |
---|
105 | extern int XmpTableLocPreferredWidth _(( XmpTableLoc, TABLE )); |
---|
106 | extern int XmpTableLocPreferredHeight _(( XmpTableLoc, TABLE )); |
---|
107 | extern int XmpTableLocNumCols _(( XmpTableLoc )); |
---|
108 | extern int XmpTableLocNumRows _(( XmpTableLoc )); |
---|
109 | extern int XmpTableLocCompareColSpan _(( XmpTableLoc, XmpTableLoc )); |
---|
110 | extern int XmpTableLocCompareRowSpan _(( XmpTableLoc, XmpTableLoc )); |
---|
111 | extern void XmpTableLocFree _(( XmpTableLoc )); |
---|
112 | |
---|
113 | /* Table Vector Structs |
---|
114 | **======================** |
---|
115 | A table has two of these vectors: one for columns, and one for rows. |
---|
116 | */ |
---|
117 | typedef int XmpTableVectorOpts; |
---|
118 | #define TBL_VEC_MINIMIZE 0x01 |
---|
119 | #define TBL_VEC_LOCK 0x02 |
---|
120 | #define TBL_VEC_NOGROW (TBL_VEC_MINIMIZE | TBL_VEC_LOCK) |
---|
121 | |
---|
122 | typedef struct _XmpTableVector { |
---|
123 | XmpTableVectorOpts options; /* Apply to entire col or row */ |
---|
124 | int value; /* width of col, hieght of row */ |
---|
125 | int pref_value; /* minimum or preferred value */ |
---|
126 | int offset; /* of upper left corner of cell */ |
---|
127 | } XmpTableVectorRec, *XmpTableVector; |
---|
128 | |
---|
129 | /* TableVector Methods |
---|
130 | **=====================** |
---|
131 | */ |
---|
132 | #define DO_COL (int)1 |
---|
133 | #define DO_ROW (int)0 |
---|
134 | |
---|
135 | extern XmpTableVector XmpTableVectorNew _(( int, TABLE, int )); |
---|
136 | extern void XmpTableVectorFree _(( XmpTableVector )); |
---|
137 | extern void XmpTableVectorMinimize _(( XmpTableVector, int, TABLE, int)); |
---|
138 | extern int XmpTableVectorTotalSize _(( XmpTableVector, int, TABLE, int)); |
---|
139 | extern int XmpTableVectorPreferredSize _(( XmpTableVector, int, TABLE, int)); |
---|
140 | extern void XmpTableVectorAdjust _(( XmpTableVector, int, int )); |
---|
141 | extern void XmpTableVectorComputeOffsets _(( XmpTableVector, int, int, int )); |
---|
142 | |
---|
143 | #undef TABLE |
---|
144 | |
---|
145 | typedef enum _ResizeStatus { RSinit, RSdone, RSdueToRequest } ResizeStatus; |
---|
146 | |
---|
147 | /* Table Part: Information kept in instance record |
---|
148 | **=================================================** |
---|
149 | */ |
---|
150 | |
---|
151 | typedef struct _XmpTablePart { |
---|
152 | /* controlling members, set by SetValues or from resource database |
---|
153 | */ |
---|
154 | Boolean force_shrink; /* Shrink smaller than pref'd */ |
---|
155 | Boolean shrink_simple; /* obsolete: will be removed */ |
---|
156 | int col_spacing; /* Space between columns */ |
---|
157 | int row_spacing; /* Space between rows */ |
---|
158 | XmpTableOpts default_options;/* Default child layout options */ |
---|
159 | XmpTableLoc default_layout; /* Layout spec (orig from xrdb) */ |
---|
160 | |
---|
161 | /* Lists of lists of XrmNames of child widgets whose preferred dimensions |
---|
162 | * should be considered to be the maximum of any individual named on the |
---|
163 | * lists. These lists can be changed via SetValues or the xrdb. |
---|
164 | * same_width[0] is a list of names of kids, each of which gets a |
---|
165 | * preferred width which is equal to the width of the widest kid on |
---|
166 | * the list. |
---|
167 | * Note: many child widgets may have the same name - that's OK) |
---|
168 | */ |
---|
169 | XrmName** same_width; /* kids with same width */ |
---|
170 | XrmName** same_height; /* kids with same height */ |
---|
171 | XrmName** same_border; /* kids with same border */ |
---|
172 | |
---|
173 | /* internally computed members |
---|
174 | */ |
---|
175 | XmpTableLoc real_layout; /* Computed current layout */ |
---|
176 | int num_cols; /* Number of columns */ |
---|
177 | XmpTableVector cols; /* Widths and opts of each col */ |
---|
178 | int num_rows; /* Number of rows */ |
---|
179 | XmpTableVector rows; /* Heights and opts of each row */ |
---|
180 | |
---|
181 | /* State indications |
---|
182 | */ |
---|
183 | ResizeStatus resize_status; /* if Resize was invoked*/ |
---|
184 | |
---|
185 | /* Makes geometry management more efficient |
---|
186 | */ |
---|
187 | Boolean requesting_resize; |
---|
188 | Dimension requesting_width, requesting_height; |
---|
189 | |
---|
190 | /* Geometry data to support child resize request: |
---|
191 | * resize_* These fields are the values the child is asking for. |
---|
192 | * approved_* These fields are computed by table and returned to |
---|
193 | * the child. |
---|
194 | * current_* These fields are placeholders to save the current |
---|
195 | * vectors when computing the proposed vectors. |
---|
196 | * query_* These fields are for the table, obtained by a query |
---|
197 | * to the table's parent. |
---|
198 | */ |
---|
199 | Widget resize_child; |
---|
200 | XtGeometryMask resize_mode; |
---|
201 | Dimension resize_width, resize_height, resize_border_width; |
---|
202 | Widget approved_child; |
---|
203 | XtGeometryMask approved_mode; |
---|
204 | Dimension approved_width, approved_height, approved_border_width; |
---|
205 | XmpTableVector approved_cols, approved_rows; |
---|
206 | XmpTableVector current_cols, current_rows; |
---|
207 | XtGeometryMask query_mode; |
---|
208 | Dimension query_width, query_height; |
---|
209 | Boolean resize_table_to_size_pre_approved_by_parent; |
---|
210 | |
---|
211 | } XmpTablePart; |
---|
212 | |
---|
213 | /* Instance hierarchy |
---|
214 | **====================** |
---|
215 | */ |
---|
216 | |
---|
217 | typedef struct _XmpTableRec { |
---|
218 | CorePart core; |
---|
219 | CompositePart composite; |
---|
220 | ConstraintPart constraint; |
---|
221 | XmManagerPart manager; |
---|
222 | XmBulletinBoardPart bulletin_board; |
---|
223 | XmpTablePart table; |
---|
224 | } XmpTableRec; |
---|
225 | |
---|
226 | /* Geometry Management Support Methods |
---|
227 | **=====================================** |
---|
228 | */ |
---|
229 | extern void XmpTableNewLayout _(( XmpTableWidget )); |
---|
230 | extern void XmpTableRecomputeLayout _(( XmpTableWidget )); |
---|
231 | extern void XmpTableNewProposedLayout _(( XmpTableWidget )); |
---|
232 | extern void XmpTableUseProposedLayout _(( XmpTableWidget )); |
---|
233 | extern void XmpTableResizeLayout _(( XmpTableWidget )); |
---|
234 | |
---|
235 | extern void XmpTableSaveProposedLayout _(( XmpTableWidget )); |
---|
236 | extern void XmpTableGetProposedLayout _(( XmpTableWidget )); |
---|
237 | extern void XmpTableForgetProposedLayout _(( XmpTableWidget )); |
---|
238 | extern void XmpTableForgetResizeChild _(( XmpTableWidget )); |
---|
239 | extern void XmpTableNewRealLayout _(( XmpTableWidget )); |
---|
240 | extern void XmpTableAppendToDefaultLayout _(( XmpTableWidget, XmpTableLoc )); |
---|
241 | extern void XmpTableConsiderSameSize _(( XmpTableWidget )); |
---|
242 | extern void XmpTableNewColsAndRows _(( XmpTableWidget )); |
---|
243 | extern void XmpTableProposedColsAndRows _(( XmpTableWidget )); |
---|
244 | extern void XmpTableMakeColsFitWidth _(( XmpTableWidget )); |
---|
245 | extern void XmpTableMakeColsFitQueryWidth _(( XmpTableWidget )); |
---|
246 | extern void XmpTableMakeRowsFitHeight _(( XmpTableWidget )); |
---|
247 | extern void XmpTableMakeRowsFitQueryHeight _(( XmpTableWidget )); |
---|
248 | extern void XmpTableFitThis _(( XmpTableWidget, int, int )); |
---|
249 | extern int XmpTablePreferredWidth _(( XmpTableWidget )); |
---|
250 | extern int XmpTablePreferredHeight _(( XmpTableWidget )); |
---|
251 | extern void XmpTableRequestResize _(( XmpTableWidget )); |
---|
252 | extern void XmpTableQueryParentForResize _(( XmpTableWidget )); |
---|
253 | extern void XmpTableGetProposedChildSize _(( XmpTableWidget )); |
---|
254 | extern void XmpTableApproveGeometryChanges _(( XmpTableWidget, Widget, |
---|
255 | int, int, int )); |
---|
256 | extern void XmpTableSetGeometryOfChildren _(( XmpTableWidget )); |
---|
257 | extern void XmpTableComputeChildSize _(( XmpTableWidget, XmpTableLoc, |
---|
258 | int*, int*, int*, int*, int* )); |
---|
259 | |
---|
260 | END_NOT_Cxx |
---|
261 | |
---|
262 | #endif /* _XmpTableP_h */ |
---|