1 /************************************************************************/
2 /*									*/
3 /*  Basic structures for a Gui document manipulator application.	*/
4 /*									*/
5 /************************************************************************/
6 
7 #   ifndef	GUI_WIDGETS_H
8 #   define	GUI_WIDGETS_H
9 
10 #   include	<stdio.h>
11 
12 #   include	"appGuiBase.h"
13 
14 # ifdef __cplusplus
15 extern "C"
16     {
17 # endif
18 
19 /************************************************************************/
20 /*									*/
21 /*  A menu, menu item in an application.				*/
22 /*									*/
23 /************************************************************************/
24 
25 typedef enum MenuItemType
26     {
27     ITEMtyOPTION= 0,
28     ITEMtyTOGGLE_OFF,
29     ITEMtyTOGGLE_ON,
30     ITEMtySEPARATOR
31     } MenuItemType;
32 
33 /************************************************************************/
34 /*									*/
35 /*  Possible responses in one of Question dialogs.			*/
36 /*									*/
37 /************************************************************************/
38 
39 typedef enum DialogResponse
40     {
41     AQDrespFAILURE= -1,
42     AQDrespNONE= 0,
43     AQDrespYES,
44     AQDrespNO,
45     AQDrespCANCEL,
46     AQDrespCLOSED,	/*  Cancel, but dialog is closed by the user */
47     AQDrespOK,
48     AQDresp_COUNT
49     } DialogResponse;
50 
51 /************************************************************************/
52 /*									*/
53 /*  Describes a document generically.					*/
54 /*									*/
55 /************************************************************************/
56 
57 typedef struct DocumentWidget
58     {
59     APP_WIDGET			dwWidget;
60     APP_INPUT_CONTEXT		dwInputContext;
61 
62 				/****************************************/
63 				/*  Event handling.			*/
64 				/*  Note that this is not a full GUI	*/
65 				/*  toolkit!				*/
66 				/****************************************/
67     void *			dwOwner;
68     void			(*dwGotString)(	void *		owner,
69 						const char *	value,
70 						int		length );
71     void			(*dwGotKey)(	void *		owner,
72 						int		key,
73 						unsigned int	state );
74     } DocumentWidget;
75 
76 /************************************************************************/
77 /*									*/
78 /*  Routine declarations.						*/
79 /*									*/
80 /************************************************************************/
81 
82 extern void appMakeButtonInRow(	APP_WIDGET *		pButton,
83 				APP_WIDGET		buttonRow,
84 				const char *		text,
85 				APP_BUTTON_CALLBACK_T	callback,
86 				void *			through,
87 				int			position,
88 				int			colspan,
89 				int			showAsDefault );
90 
91 extern void appMakeButtonInColumn(
92 				APP_WIDGET *		pButton,
93 				APP_WIDGET		column,
94 				const char *		buttonText,
95 				APP_BUTTON_CALLBACK_T	callback,
96 				void *			through,
97 				int			showAsDefault );
98 
99 extern void appMakeLabelInRow(		APP_WIDGET *		pLabel,
100 					APP_WIDGET		row,
101 					int			column,
102 					int			colspan,
103 					const char *		labelText );
104 
105 extern void appMakeLabelInHBox(		APP_WIDGET *		pLabel,
106 					APP_WIDGET		hbox,
107 					const char *		labelText );
108 
109 extern void appMakeTextInRow(		APP_WIDGET *		pText,
110 					APP_WIDGET		row,
111 					int			column,
112 					int			colspan,
113 					int			textColumns,
114 					int			textEnabled );
115 
116 extern void appMakeTextInHBox(		APP_WIDGET *		pText,
117 					APP_WIDGET		hbox,
118 					int			textColumns,
119 					int			textEnabled );
120 
121 extern APP_WIDGET appMakeToggleInRow(	APP_WIDGET		buttonRow,
122 					const char *		text,
123 					APP_TOGGLE_CALLBACK_T	callback,
124 					void *			through,
125 					int			col,
126 					int			colspan );
127 
128 extern void appMakeColumnFrameInColumn(	APP_WIDGET *		pFrame,
129 					APP_WIDGET *		pPaned,
130 					APP_WIDGET		parent,
131 					const char *		title );
132 
133 extern void appMakeLabelInColumn(	APP_WIDGET *		pLabel,
134 					APP_WIDGET		row,
135 					const char *		labelText );
136 
137 extern void appMakeTextInColumn(	APP_WIDGET *	pText,
138 					APP_WIDGET	column,
139 					int		textColumns,
140 					int		textEnabled );
141 
142 extern void appMakeColumnToggle(	APP_WIDGET *		pToggle,
143 					APP_WIDGET		column,
144 					APP_TOGGLE_CALLBACK_T	callback,
145 					void *			through,
146 					const char *		labelText,
147 					int			set );
148 
149 extern void appMakeColumnDrawing(	APP_WIDGET *		pButton,
150 					APP_WIDGET		column,
151 					APP_DRAW_BUTTON_CALLBACK exposeCallback,
152 					APP_BUTTON_CALLBACK_T	pushedCallback,
153 					void *			through,
154 					int			width );
155 
156 extern char * 	appWidgetName(		char *			file,
157 					int			line );
158 
159 extern void guiEnableText(		APP_WIDGET	text,
160 					int		enabled );
161 
162 extern char *	appGetStringFromTextWidget(	APP_WIDGET	w );
163 extern void	appFreeStringFromTextWidget(	char *		s );
164 
165 extern char *	appGetTextFromMenuOption(	APP_WIDGET	w );
166 extern void	appFreeTextFromMenuOption(	char *		s );
167 
168 extern void appStringToTextWidget(	APP_WIDGET		w,
169 					const char *		s );
170 
171 extern void appGuiChangeButtonText(	APP_WIDGET		button,
172 					const char *		label );
173 
174 extern APP_WIDGET appMakeRowInColumn(	APP_WIDGET	parent,
175 					int		columnCount,
176 					int		heightResizable );
177 
178 extern void appMakeColumnInRow(		APP_WIDGET *	pColumn,
179 					APP_WIDGET	row,
180 					int		position,
181 					int		colspan );
182 
183 extern void appMakeHBoxInRow(		APP_WIDGET *	pHbox,
184 					APP_WIDGET	row,
185 					int		position,
186 					int		colspan );
187 
188 extern void appMakeRowFrameInColumn(	APP_WIDGET *		pFrame,
189 					APP_WIDGET *		pRow,
190 					APP_WIDGET		parent,
191 					int			columnCount,
192 					const char *		title );
193 
194 extern void appTextSelectContents(	APP_WIDGET	w,
195 					int		from,
196 					int		upto );
197 
198 extern void appGuiMakeDrawingAreaInColumn( APP_WIDGET *		pDrawing,
199 				APP_WIDGET			column,
200 				int				wide,
201 				int				high,
202 				int				heightResizable,
203 				APP_EVENT_HANDLER_T		redraw,
204 				void *				through );
205 
206 extern void appGuiChangeLabelText( APP_WIDGET			w,
207 				const char *			labelt );
208 
209 extern void appDocumentSetInputContext(		APP_INPUT_METHOD	im,
210 						DocumentWidget *	dw );
211 
212 # ifdef USE_GTK
213     extern int appGuiGetMenuToggleStateFromCallbackGtk(
214 					APP_WIDGET		toggle );
215     # define appGuiGetMenuToggleStateFromCallback( t, e ) \
216 			    appGuiGetMenuToggleStateFromCallbackGtk( (t) )
217 # else
218     extern int appGuiGetMenuToggleStateFromCallback(
219 					APP_WIDGET		toggle,
220 					void *			voidcbs );
221 # endif
222 
223 # ifdef USE_GTK
224     extern int appGuiGetScrollbarValueFromCallbackGtk(
225 					APP_WIDGET		scrollbar );
226 
227     # define appGuiGetScrollbarValueFromCallback( bar, e ) \
228 			    appGuiGetScrollbarValueFromCallbackGtk( (bar) )
229 # else
230     extern int appGuiGetScrollbarValueFromCallback(
231 					APP_WIDGET		scrollbar,
232 					void *			e );
233 # endif
234 
235 /**
236  *  Construct a list of values in the column
237  *
238  *  @param visibleItems: The number of items to display.
239  *	if visibleItems > 0: Allocate sufficient space for this many items.
240  *		and use a scrollbar if there are items more in the list.
241  *	if visibleItems == 0: Adapt to the available space in the parent.
242  *		Use a scrollbar if there are more items in the list than fit
243  *		in the assigned space.
244  *	if visibleItems < 0: Resize with the number of itemsd in the list.
245  *
246  */
247 extern void appGuiMakeListInColumn(	APP_WIDGET *		pList,
248 					APP_WIDGET		column,
249 					int			visibleItems,
250 					APP_LIST_CALLBACK_T	listCallback,
251 					APP_BUTTON_CALLBACK_T	actionCallback,
252 					void *			through );
253 
254 extern void appGuiSetTypingCallbackForText(
255 					APP_WIDGET		text,
256 					APP_TXTYPING_CALLBACK_T	callBack,
257 					void *			through );
258 
259 extern void appGuiSetGotValueCallbackForText(
260 				    APP_WIDGET			text,
261 				    APP_TXACTIVATE_CALLBACK_T	callBack,
262 				    void *			through );
263 
264 extern void appGuiGetScrollbarValues(	int *		pValue,
265 					int *		pSliderSize,
266 					APP_WIDGET	scrollbar );
267 
268 extern void appGuiSetScrollbarValues(	APP_WIDGET	scrollbar,
269 					int		value,
270 					int		sliderSize );
271 
272 extern void appGuiEmptyListWidget(	APP_WIDGET		list );
273 
274 extern void appGuiAddValueToListWidget(	APP_WIDGET		list,
275 					int			pos,
276 					const char *		value );
277 
278 extern void appGuiReplaceValueInListWidget(
279 					APP_WIDGET		list,
280 					int			pos,
281 					const char *		value );
282 
283 extern void appGuiDeletePositionFromListWidget(
284 					APP_WIDGET		list,
285 					int			pos );
286 
287 extern void appGuiSelectPositionInListWidget(	APP_WIDGET	list,
288 						int		position );
289 extern void appGuiSelectValueInListWidget(	APP_WIDGET	list,
290 						const char *	value );
291 
292 extern void appGuiRemoveSelectionFromListWidget(	APP_WIDGET	list );
293 
294 extern void appGuiMakeSliderInRow(	APP_WIDGET *		pSlider,
295 					APP_WIDGET		row,
296 					int			column,
297 					int			colspan,
298 					APP_BUTTON_CALLBACK_T	callback,
299 					void *			through );
300 
301 extern void appGuiSetSlider(		APP_WIDGET		slider,
302 					int			minVal,
303 					int			maxVal,
304 					int			curVal );
305 
306 extern void appGuiSetSliderValue(	APP_WIDGET		slider,
307 					int			curVal );
308 
309 extern int appGuiGetValueFromSliderCallback(	int *		pValue,
310 						APP_WIDGET	w,
311 						void *		voidscs );
312 
313 extern int appGuiGetPositionFromListCallback(
314 					    APP_WIDGET		list,
315 					    APP_LIST_CHOICE *	voidlcs );
316 
317 extern char * appGuiGetStringFromListCallback(
318 					    APP_WIDGET		list,
319 					    APP_LIST_CHOICE *	voidlcs );
320 
321 extern void appFreeStringFromListCallback(	char *		s );
322 
323 extern void appGuiInsertSeparatorInColumn(	APP_WIDGET *	pSeparator,
324 						APP_WIDGET	parent );
325 
326 extern void appSetShellTitle(		APP_WIDGET		shell,
327 					APP_WIDGET		option,
328 					const char *		title );
329 
330 extern void appGuiInsertColumnInWindow(	APP_WIDGET *	pColumn,
331 					APP_WIDGET	parent );
332 
333 extern void appGuiInsertMenubarInColumn( APP_WIDGET *	pMenubar,
334 					APP_WIDGET	parent );
335 
336 extern void appMakeImageInColumn(	APP_WIDGET *		pLabel,
337 					APP_WIDGET		column,
338 					APP_BITMAP_IMAGE	pixmap,
339 					APP_BITMAP_MASK		mask );
340 
341 extern void appGuiSetToggleLabel(	APP_WIDGET		toggle,
342 					const char *		text );
343 
344 extern void appGuiSetToggleState(	APP_WIDGET		toggle,
345 					int			set );
346 
347 extern int appGuiGetToggleState(	APP_WIDGET		toggle );
348 
349 extern void guiEnableWidget(		APP_WIDGET		w,
350 					int			on_off );
351 
352 extern void appGuiSetWidgetVisible(	APP_WIDGET		w,
353 					int			on_off );
354 
355 extern void appHideShellWidget(		APP_WIDGET		shell );
356 extern void appDestroyShellWidget(	APP_WIDGET		shell );
357 
358 extern void appRefuseTextValue(		APP_WIDGET	w );
359 
360 # ifdef __cplusplus
361     }
362 # endif
363 
364 #   endif
365