1 /************************************************************************/
2 /*									*/
3 /*  Utility functionality for 'Inspector' like tools.			*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"appFrameConfig.h"
8 
9 #   include	<stddef.h>
10 #   include	<stdio.h>
11 
12 #   include	"appFrame.h"
13 #   include	"guiToolUtil.h"
14 #   include	"guiWidgetsImpl.h"
15 
16 #   include	<appDebugon.h>
17 
18 /************************************************************************/
19 /*									*/
20 /*  Make the form with the two buttons.					*/
21 /*									*/
22 /************************************************************************/
23 
guiToolMake2BottonRow(APP_WIDGET * pRow,APP_WIDGET parent,APP_WIDGET * pLeftButton,APP_WIDGET * pRightButton,const char * leftLabel,const char * rightLabel,APP_BUTTON_CALLBACK_T leftCallback,APP_BUTTON_CALLBACK_T rightCallback,void * through)24 void guiToolMake2BottonRow(	APP_WIDGET *		pRow,
25 				APP_WIDGET		parent,
26 				APP_WIDGET *		pLeftButton,
27 				APP_WIDGET *		pRightButton,
28 				const char *		leftLabel,
29 				const char *		rightLabel,
30 				APP_BUTTON_CALLBACK_T	leftCallback,
31 				APP_BUTTON_CALLBACK_T	rightCallback,
32 				void *			through )
33     {
34     const int	heightResizable= 0;
35     const int	showAsDefault= 0;
36     const int	colspan= 1;
37 
38     APP_WIDGET	row= appMakeRowInColumn( parent, 2, heightResizable );
39 
40     APP_WIDGET	leftButton;
41     APP_WIDGET	rightButton;
42 
43     appMakeButtonInRow( &leftButton, row, leftLabel, leftCallback, through,
44 						0, colspan, showAsDefault );
45     appMakeButtonInRow( &rightButton, row, rightLabel,rightCallback, through,
46 						1, colspan, showAsDefault );
47 
48     *pRow= row;
49     *pLeftButton= leftButton;
50     *pRightButton= rightButton;
51 
52     return;
53     }
54 
guiToolMake3ButtonRow(APP_WIDGET * pRow,APP_WIDGET parent,APP_WIDGET * pLeftButton,APP_WIDGET * pMiddleButton,APP_WIDGET * pRightButton,const char * leftLabel,const char * middleLabel,const char * rightLabel,APP_BUTTON_CALLBACK_T leftCallback,APP_BUTTON_CALLBACK_T middleCallback,APP_BUTTON_CALLBACK_T rightCallback,void * through)55 void guiToolMake3ButtonRow( APP_WIDGET *		pRow,
56 				APP_WIDGET		parent,
57 				APP_WIDGET *		pLeftButton,
58 				APP_WIDGET *		pMiddleButton,
59 				APP_WIDGET *		pRightButton,
60 				const char *		leftLabel,
61 				const char *		middleLabel,
62 				const char *		rightLabel,
63 				APP_BUTTON_CALLBACK_T	leftCallback,
64 				APP_BUTTON_CALLBACK_T	middleCallback,
65 				APP_BUTTON_CALLBACK_T	rightCallback,
66 				void *			through )
67     {
68     const int	heightResizable= 0;
69     const int	showAsDefault= 0;
70     const int	colspan= 1;
71 
72     APP_WIDGET	row= appMakeRowInColumn( parent, 3, heightResizable );
73 
74     APP_WIDGET	leftButton;
75     APP_WIDGET	middleButton;
76     APP_WIDGET	rightButton;
77 
78     appMakeButtonInRow( &leftButton, row, leftLabel, leftCallback, through,
79 						0, colspan, showAsDefault );
80     appMakeButtonInRow( &middleButton, row, middleLabel,middleCallback, through,
81 						1, colspan, showAsDefault );
82     appMakeButtonInRow( &rightButton, row, rightLabel,rightCallback, through,
83 						2, colspan, showAsDefault );
84 
85     *pRow= row;
86     *pLeftButton= leftButton;
87     *pMiddleButton= middleButton;
88     *pRightButton= rightButton;
89 
90     return;
91     }
92 
guiToolMake2ToggleRow(APP_WIDGET * pRow,APP_WIDGET parent,APP_WIDGET * pLeftToggle,APP_WIDGET * pRightToggle,const char * leftText,const char * rightText,APP_TOGGLE_CALLBACK_T leftCallback,APP_TOGGLE_CALLBACK_T rightCallback,void * leftThrough,void * rightThrough)93 void guiToolMake2ToggleRow(		APP_WIDGET *		pRow,
94 					APP_WIDGET		parent,
95 					APP_WIDGET *		pLeftToggle,
96 					APP_WIDGET *		pRightToggle,
97 					const char *		leftText,
98 					const char *		rightText,
99 					APP_TOGGLE_CALLBACK_T	leftCallback,
100 					APP_TOGGLE_CALLBACK_T	rightCallback,
101 					void *			leftThrough,
102 					void *			rightThrough )
103     {
104     const int	heightResizable= 0;
105     APP_WIDGET	row= appMakeRowInColumn( parent, 2, heightResizable );
106 
107     APP_WIDGET	leftToggle;
108     APP_WIDGET	rightToggle;
109 
110     const int	leftColumn= 0;
111     const int	rightColumn= 1;
112 
113     leftToggle= appMakeToggleInRow( row, leftText, leftCallback,
114 						leftThrough, leftColumn, 1 );
115     rightToggle= appMakeToggleInRow( row, rightText, rightCallback,
116 						rightThrough, rightColumn, 1 );
117     *pRow= row;
118     *pLeftToggle= leftToggle;
119     *pRightToggle= rightToggle;
120 
121     return;
122     }
123 
guiToolMake3ToggleRow(APP_WIDGET * pRow,APP_WIDGET parent,APP_WIDGET * pLeftToggle,APP_WIDGET * pMiddleToggle,APP_WIDGET * pRightToggle,const char * leftText,const char * middleText,const char * rightText,APP_TOGGLE_CALLBACK_T leftCallback,APP_TOGGLE_CALLBACK_T middleCallback,APP_TOGGLE_CALLBACK_T rightCallback,void * through)124 void guiToolMake3ToggleRow(		APP_WIDGET *		pRow,
125 					APP_WIDGET		parent,
126 					APP_WIDGET *		pLeftToggle,
127 					APP_WIDGET *		pMiddleToggle,
128 					APP_WIDGET *		pRightToggle,
129 					const char *		leftText,
130 					const char *		middleText,
131 					const char *		rightText,
132 					APP_TOGGLE_CALLBACK_T	leftCallback,
133 					APP_TOGGLE_CALLBACK_T	middleCallback,
134 					APP_TOGGLE_CALLBACK_T	rightCallback,
135 					void *			through )
136     {
137     const int	heightResizable= 0;
138     APP_WIDGET	row= appMakeRowInColumn( parent, 3, heightResizable );
139 
140     APP_WIDGET	leftToggle;
141     APP_WIDGET	middleToggle;
142     APP_WIDGET	rightToggle;
143 
144     const int	leftColumn= 0;
145     const int	middleColumn= 1;
146     const int	rightColumn= 2;
147 
148     leftToggle= appMakeToggleInRow( row, leftText, leftCallback,
149 						through, leftColumn, 1 );
150     middleToggle= appMakeToggleInRow( row, middleText, middleCallback,
151 						through, middleColumn, 1 );
152     rightToggle= appMakeToggleInRow( row, rightText, rightCallback,
153 						through, rightColumn, 1 );
154     *pRow= row;
155     *pLeftToggle= leftToggle;
156     *pMiddleToggle= middleToggle;
157     *pRightToggle= rightToggle;
158 
159     return;
160     }
161 
guiToolMakeToggleAndLabelRow(APP_WIDGET * pRow,APP_WIDGET parent,APP_WIDGET * pToggle,APP_WIDGET * pLabel,const char * toggleText,const char * labelText,APP_TOGGLE_CALLBACK_T toggleCallback,void * through)162 void guiToolMakeToggleAndLabelRow(	APP_WIDGET *		pRow,
163 					APP_WIDGET		parent,
164 					APP_WIDGET *		pToggle,
165 					APP_WIDGET *		pLabel,
166 					const char *		toggleText,
167 					const char *		labelText,
168 					APP_TOGGLE_CALLBACK_T	toggleCallback,
169 					void *			through )
170     {
171     const int	heightResizable= 0;
172     APP_WIDGET	row= appMakeRowInColumn( parent, 2, heightResizable );
173 
174     APP_WIDGET	toggle;
175     APP_WIDGET	label;
176 
177     const int	toggleColumn= 0;
178     const int	toggleColspan= 1;
179     const int	labelColumn= toggleColumn+ toggleColspan;
180     const int	labelColspan= 1;
181 
182     toggle= appMakeToggleInRow( row, toggleText, toggleCallback,
183 					through, toggleColumn, toggleColspan );
184     appMakeLabelInRow( &label, row, labelColumn, labelColspan, labelText );
185 
186     *pRow= row;
187     *pToggle= toggle;
188     *pLabel= label;
189 
190     return;
191     }
192 
guiToolMakeLabelAndToggleRow(APP_WIDGET * pRow,APP_WIDGET parent,APP_WIDGET * pLabel,APP_WIDGET * pToggle,const char * labelText,const char * toggleText,APP_TOGGLE_CALLBACK_T toggleCallback,void * through)193 void guiToolMakeLabelAndToggleRow(	APP_WIDGET *		pRow,
194 					APP_WIDGET		parent,
195 					APP_WIDGET *		pLabel,
196 					APP_WIDGET *		pToggle,
197 					const char *		labelText,
198 					const char *		toggleText,
199 					APP_TOGGLE_CALLBACK_T	toggleCallback,
200 					void *			through )
201     {
202     const int	heightResizable= 0;
203     APP_WIDGET	row= appMakeRowInColumn( parent, 2, heightResizable );
204 
205     APP_WIDGET	toggle;
206     APP_WIDGET	label;
207 
208     const int	labelColumn= 0;
209     const int	labelColspan= 1;
210     const int	toggleColumn= labelColumn+ labelColspan;
211     const int	toggleColspan= 1;
212 
213     appMakeLabelInRow( &label, row, labelColumn, labelColspan, labelText );
214     toggle= appMakeToggleInRow( row, toggleText, toggleCallback,
215 					through, toggleColumn, toggleColspan );
216 
217     *pRow= row;
218     *pLabel= label;
219     *pToggle= toggle;
220 
221     return;
222     }
223 
guiToolMakeLabelAndMenuRow(APP_WIDGET * pRow,AppOptionmenu * aom,APP_WIDGET * pLabel,APP_WIDGET parent,const char * labelText,OptionmenuCallback callBack,void * target)224 void guiToolMakeLabelAndMenuRow(	APP_WIDGET *		pRow,
225 					AppOptionmenu *		aom,
226 					APP_WIDGET *		pLabel,
227 					APP_WIDGET		parent,
228 					const char *		labelText,
229 					OptionmenuCallback	callBack,
230 					void *			target )
231     {
232     APP_WIDGET	row;
233     APP_WIDGET	label;
234 
235     const int	labelColumn= 0;
236     const int	labelColspan= 1;
237 
238     const int	menuColumn= labelColumn+ labelColspan;
239     const int	menuColspan= 1;
240     const int	heightResizable= 0;
241 
242     row= appMakeRowInColumn( parent, 2, heightResizable );
243 
244     /**************/
245     appMakeLabelInRow( &label, row, labelColumn, labelColspan, labelText );
246 
247     /**************/
248     appMakeOptionmenuInRow( aom, row, menuColumn, menuColspan,
249 							callBack, target );
250 
251     /**************/
252 
253     *pRow= row;
254     *pLabel= label;
255 
256     return;
257     }
258 
259 /************************************************************************/
260 /*									*/
261 /*  Fill an inspector menu.						*/
262 /*									*/
263 /************************************************************************/
264 
appFillInspectorMenu(int count,int current,APP_WIDGET * items,const char * const * texts,AppOptionmenu * aom)265 void appFillInspectorMenu(	int			count,
266 				int			current,
267 				APP_WIDGET *		items,
268 				const char * const *	texts,
269 				AppOptionmenu *		aom )
270     {
271     int			i;
272 
273     appEmptyOptionmenu( aom );
274 
275     for ( i= 0; i < count; i++ )
276 	{
277 	items[i]= appAddItemToOptionmenu( aom, texts[i] );
278 	}
279 
280     appSetOptionmenu( aom, current );
281 
282     appOptionmenuRefreshWidth( aom );
283 
284     return;
285     }
286 
287 /************************************************************************/
288 /*									*/
289 /*  Make a row consisting of a label and a text widget.			*/
290 /*									*/
291 /************************************************************************/
292 
guiToolMakeLabelAndTextRow(APP_WIDGET * pRow,APP_WIDGET * pLabel,APP_WIDGET * pText,APP_WIDGET column,const char * labelText,int textColumns,int textEnabled)293 void guiToolMakeLabelAndTextRow( APP_WIDGET *		pRow,
294 				APP_WIDGET *		pLabel,
295 				APP_WIDGET *		pText,
296 				APP_WIDGET		column,
297 				const char *		labelText,
298 				int			textColumns,
299 				int			textEnabled )
300     {
301     APP_WIDGET		label;
302     APP_WIDGET		text;
303     APP_WIDGET		row;
304 
305     const int		labelColumn= 0;
306     const int		labelColspan= 1;
307     const int		textColumn= 1;
308     const int		textColspan= 1;
309 
310     const int		columnCount= 2;
311     const int		heightResizable= 0;
312 
313     row= appMakeRowInColumn( column, columnCount, heightResizable );
314 
315     appMakeLabelInRow( &label, row, labelColumn, labelColspan, labelText );
316     appMakeTextInRow( &text, row, textColumn, textColspan,
317 						textColumns, textEnabled );
318 
319     if  ( pRow )
320 	{ *pRow= row;		}
321     if  ( pLabel )
322 	{ *pLabel= label;	}
323     if  ( pText )
324 	{ *pText= text;		}
325 
326     return;
327     }
328 
guiToolMakeToggleAndTextRow(APP_WIDGET * pRow,APP_WIDGET * pToggle,APP_WIDGET * pText,APP_WIDGET column,const char * labelText,APP_TOGGLE_CALLBACK_T callback,void * through,int textColumns,int textEnabled)329 void guiToolMakeToggleAndTextRow(	APP_WIDGET *		pRow,
330 					APP_WIDGET *		pToggle,
331 					APP_WIDGET *		pText,
332 					APP_WIDGET		column,
333 					const char *		labelText,
334 					APP_TOGGLE_CALLBACK_T	callback,
335 					void *			through,
336 					int			textColumns,
337 					int			textEnabled )
338     {
339     APP_WIDGET		toggle;
340     APP_WIDGET		text;
341     APP_WIDGET		row;
342 
343     const int		textColumn= 1;
344     const int		textColspan= 1;
345 
346     const int		columnCount= 2;
347     const int		heightResizable= 0;
348 
349     row= appMakeRowInColumn( column, columnCount, heightResizable );
350 
351     toggle= appMakeToggleInRow( row, labelText, callback, through, 0, 1 );
352     appMakeTextInRow( &text, row, textColumn, textColspan,
353 						    textColumns, textEnabled );
354 
355     *pRow= row; *pToggle= toggle; *pText= text; return;
356     }
357