1 /*----------------------------------------------------------------------------
2 --
3 --  Module:           xitTools
4 --
5 --  Project:          xit  - X Internal Toolkit
6 --  System:           xit  - X Internal Toolkit
7 --    Subsystem:      <>
8 --    Function block: <>
9 --
10 --  Description:
11 --    Interface file for xitTools.c
12 --
13 --  Filename:         xitTools.h
14 --
15 --  Authors:          Roger Larsson, Ulrika Bornetun
16 --  Creation date:    1991-01-04
17 --
18 --
19 --  (C) Copyright Ulrika Bornetun, Roger Larsson (1995)
20 --      All rights reserved
21 --
22 --  Permission to use, copy, modify, and distribute this software and its
23 --  documentation for any purpose and without fee is hereby granted,
24 --  provided that the above copyright notice appear in all copies. Ulrika
25 --  Bornetun and Roger Larsson make no representations about the usability
26 --  of this software for any purpose. It is provided "as is" without express
27 --  or implied warranty.
28 ----------------------------------------------------------------------------*/
29 
30 /* SCCS module identifier. */
31 /* SCCSID = @(#) Module: xitTools.h, Version: 1.1, Date: 95/02/18 15:10:50 */
32 
33 
34 /* Only include this file once. */
35 #ifndef define_xitTools_h
36 #  define define_xitTools_h
37 
38 
39 /*----------------------------------------------------------------------------
40 --  Include files
41 ----------------------------------------------------------------------------*/
42 
43 #include <X11/Intrinsic.h>
44 
45 #include <Xm/Xm.h>
46 
47 #include "System.h"
48 
49 
50 /*----------------------------------------------------------------------------
51 --  Macro definitions
52 ----------------------------------------------------------------------------*/
53 
54 /* Short name for Motif default character set. */
55 #define CS    ((XmStringCharSet) XmSTRING_DEFAULT_CHARSET)
56 
57 /* Menu separator indicator. */
58 #define XIT_SEP   "-------"
59 
60 
61 /* Flags for fil;e select. */
62 #define XIT_FILE_SELECT_ONLY_DIRS   (1<<0)
63 #define XIT_FILE_SELECT_DIRS_OK     (2<<0)
64 
65 
66 /*----------------------------------------------------------------------------
67 --  Type declarations
68 ----------------------------------------------------------------------------*/
69 
70 /* Callback and callback reasons from the file selection. */
71 typedef enum {
72   XIT_FILE_SELECT_CANCEL,
73   XIT_FILE_SELECT_OK
74 } XIT_FILE_SEL_REASON;
75 
76 typedef void ( *XIT_FILE_SEL_CB ) ( XIT_FILE_SEL_REASON, char *, void * );
77 
78 
79 /* Description of one push button in the action area of a dialog. */
80 typedef struct {
81   char     *label;
82   void     (*callback)();
83   void     *data;
84 } XIT_ACTION_AREA_ITEM;
85 
86 
87 /* Description of a arrow push button. */
88 typedef struct  {
89   char     *name;
90   Boolean  sensitive;
91   int      direction;
92   void     (*callback) ();
93 } XIT_ARROW_STRUCT;
94 
95 
96 /* A cascade item in a menu bar. */
97 typedef struct {
98   char  *title;
99   char  *mnemonic;
100   char  *name;
101 } XIT_CASCADE_STRUCT;
102 
103 
104 /* Labels to use in the file selection window. */
105 typedef struct {
106   char  *dir_list_label;
107   char  *file_list_label;
108   char  *filter_label;
109   char  *selection_label;
110   char  *cancel_button;
111   char  *filter_button;
112   char  *ok_button;
113   char  *no_file_sel_msg;
114   char  *cannot_read_file_msg;
115 } XIT_FILE_SEL_LABELS;
116 
117 
118 /* Assign a pixmap to an icon window. */
119 typedef struct {
120   Pixmap      image;
121   Boolean     report_expose_events;
122   Pixel       icon_fg;
123   Pixel       icon_bg;
124   int         x_offset;
125   int         y_offset;
126   XmString    label;
127   XmFontList  font_list;
128   Pixel       label_fg;
129 } XIT_ICON_WINDOW;
130 
131 
132 /* An item in a menu pane. */
133 typedef struct  {
134   char     *title;
135   char     *mnemonic;
136   void     (*callback) ();
137   char     *name;
138   Boolean  sensitive;
139   Boolean  toggle_button;
140   Boolean  selected;
141 } XIT_MENU_BUTTON_STRUCT;
142 
143 
144 /* Description of a label. */
145 typedef struct {
146   char  *name;
147   char  *string;
148   int   alignment;
149 } XIT_LABEL_STRUCT;
150 
151 
152 /* Description of a push button. */
153 typedef struct  {
154   char     *name;
155   char     *title;
156   char     *mnemonic;
157   Boolean  sensitive;
158   void     (*callback) ();
159 } XIT_PUSH_STRUCT;
160 
161 
162 /* Description of a text field. */
163 typedef struct {
164   char     *name;
165   void     (*callback) ();
166   int      lines;
167   Boolean  editable;
168 } XIT_TEXT_STRUCT;
169 
170 
171 /*----------------------------------------------------------------------------
172 --  Global definitions
173 ----------------------------------------------------------------------------*/
174 
175 
176 /*----------------------------------------------------------------------------
177 --  Function prototypes
178 ----------------------------------------------------------------------------*/
179 
180 void
181   xitAddTabgroup( Widget          widget,
182                   XtTranslations  translations );
183 
184 Boolean
185   xitAllocNamedColor( Widget  widget,
186                       char    *color_string,
187                       Pixel   *color );
188 
189 void
190   xitAttachWidget( Widget  widget,
191                    int     action_top,
192                    Widget  top_widget,
193                    int     action_left,
194                    Widget  left_widget,
195                    int     action_right,
196                    Widget  right_widget,
197                    int     action_bottom,
198                    Widget  bottom_widget );
199 
200 Boolean
201   xitBusyDialogCancelled( Widget        workW,
202                           XtAppContext  context );
203 
204 void
205   xitBusyDialogRemove( Widget  workW );
206 
207 Widget
208   xitCreateArrowPushButton( Widget            parent,
209                             XIT_ARROW_STRUCT  *pb );
210 
211 Widget
212   xitCreateBusyDialog( Widget parent,
213                        char   *dialog_name,
214                        char   *title,
215                        char   *message );
216 
217 Widget
218   xitCreateCascadeButton( Widget              parent,
219                           Widget              submenu,
220                           XIT_CASCADE_STRUCT  *cascade );
221 
222 Widget
223   xitCreateDialogForm( Widget parent,
224                        char   *name,
225                        char   *ok_string,
226                        void   (*okCB) (),
227                        char   *cancel_string,
228                        void   (*cancelCB) (),
229                        char   *apply_string,
230                        void   (*applyCB) (),
231                        void   *client_data );
232 
233 Widget
234   xitCreateErrorDialog( Widget  parent,
235                         char   *dialog_name,
236                         char   *title,
237                         char   *message,
238                         void   (*okCB) (),
239                         void   *ok_client_data );
240 
241 Widget
242   xitCreateFileSelect( Widget               parent,
243                        char                 *name,
244                        UINT32               flags,
245                        char                 *source_dir,
246                        XIT_FILE_SEL_LABELS  *labels,
247                        XIT_FILE_SEL_CB      actionCB,
248                        void                 *user_data );
249 
250 Widget
251   xitCreateFormDialog( Widget                parent,
252                        char                  *name,
253                        int                   default_button_no,
254                        int                   tightness,
255                        XIT_ACTION_AREA_ITEM  *actions,
256                        int                   num_actions );
257 
258 Widget
259   xitCreateInformationDialog( Widget parent,
260                               char   *dialog_name,
261                               char   *title,
262                               char   *message,
263                               void   (*okCB) (),
264                               void   *ok_client_data );
265 
266 Widget
267   xitCreateLabel( Widget parent,
268                   char   *name,
269                   char   *string,
270                   int    alignment );
271 
272 Widget
273   xitCreateLabelStruct( Widget            parent,
274                         XIT_LABEL_STRUCT  *label_ref );
275 
276 Widget
277   xitCreateLabelWidget( Widget parent,
278                         char   *name,
279                         char   *string,
280                         int    alignment );
281 
282 Widget
283   xitCreateMenuPushButton( Widget                  parent,
284                            XIT_MENU_BUTTON_STRUCT  *menu );
285 
286 Widget
287   xitCreatePixmapDialog( Widget  parent,
288                          char    *dialog_name,
289                          char    *title,
290                          char    *message,
291                          Pixmap  pixmap,
292                          void    (*okCB) (),
293                          void    *ok_client_data );
294 
295 Widget
296   xitCreatePushButton( Widget           parent,
297                        XIT_PUSH_STRUCT  *pb );
298 
299 Widget
300   xitCreatePushButtonGadget( Widget           parent,
301                              XIT_PUSH_STRUCT  *pb );
302 
303 Widget
304   xitCreateQuestionDialog( Widget parent,
305                            char   *dialog_name,
306                            char   *title,
307                            char   *message,
308                            void   (*okCB) (),
309                            void   *ok_client_data,
310                            void   (*cancelCB) (),
311                            void   *cancel_client_data );
312 
313 Widget
314   xitCreateToggleButton( Widget   parent,
315                          char     *name,
316                          char     *label,
317                          Boolean  set );
318 
319 Widget
320   xitCreateToggleButtonGadget( Widget   parent,
321                                char     *name,
322                                char     *label,
323                                Boolean  set );
324 
325 Widget
326   xitCreateText( Widget           parent,
327                  XIT_TEXT_STRUCT  *edits );
328 
329 Widget
330   xitCreateTextCols( Widget           parent,
331                      XIT_TEXT_STRUCT  *edits,
332                      int              init_cols );
333 
334 Widget
335   xitCreateTextScrolled( Widget           parent,
336                          XIT_TEXT_STRUCT  *edits );
337 
338 Widget
339   xitCreateTextScrolledCols( Widget           parent,
340                              XIT_TEXT_STRUCT  *edits,
341                              int              init_cols );
342 
343 Widget
344   xitCreateToplevelDialog( Widget                parent,
345                            char                  *name,
346                            int                   default_button_no,
347                            int                   tightness,
348                            XIT_ACTION_AREA_ITEM  *actions,
349                            int                   num_actions );
350 
351 Widget
352   xitCreateWorkingDialog( Widget parent,
353                           char   *dialog_name,
354                           char   *title,
355                           char   *message,
356                           void   (*okCB) (),
357                           void   *ok_client_data,
358                           void   (*cancelCB) (),
359                           void   *cancel_client_data );
360 
361 void
362   xitDispatchXEvents( Widget        widget,
363                       XtAppContext  context );
364 
365 void
366   xitFileSelectDisplay( Widget  widget );
367 
368 void
369   xitFnGetCharMaxBounds( XmFontList  font_list,
370                          char        *use_char_set,
371                          Dimension   *width,
372                          Dimension   *height );
373 
374 Boolean
375   xitGetChildren( Widget      widget,
376                   Cardinal    *num_children,
377                   WidgetList  *children );
378 
379 Widget
380   xitGetParentWidget( Widget  child,
381                       char    *search_parent );
382 
383 Widget
384   xitGetToplevelWidget( Widget  widget );
385 
386 char
387   *xitGetWidgetName( Widget  widget );
388 
389 void
390   xitGrabFocus( Widget  focus_toW );
391 
392 void
393   xitIconify( Widget  widget );
394 
395 void
396   xitInformationDialogTimeout( Widget widget,
397                                int    secs );
398 
399 Boolean
400   xitIsRealized( Widget  widget );
401 
402 Boolean
403   xitIsTextEmpty( Widget  widget );
404 
405 void
406   xitManageChildren( Widget  widgets[],
407                      int     number );
408 
409 void
410   xitSetFocus( Widget  widget,
411                Widget  focus_toW );
412 
413 void
414   xitSetPositional( Widget widget,
415                     int    top,
416                     int    left,
417                     int    right,
418                     int    bottom );
419 
420 void
421   xitSetGeometryResources( Screen    *screen,
422                            char      *geometry_str,
423                            Arg       args[],
424                            Cardinal  *n );
425 
426 void
427   xitSetIconWindow( Widget           shell,
428                     XIT_ICON_WINDOW  *icon_win,
429                     Window           *window,
430                     GC               *gc );
431 
432 void
433   xitSetSizeFormDialog( Widget   toplevel,
434                         Boolean  tight );
435 
436 void
437   xitSetSizeToplevelDialog( Widget   toplevel,
438                             Boolean  tight );
439 
440 void
441   xitSortStringList( XmString  *list,
442                      int       elements );
443 
444 XmString
445   xitStringConcatAndFree( XmString  to_the_string,
446                           XmString  string );
447 
448 char
449   *xitStringGetLabel( Widget  widget );
450 
451 char
452   *xitStringGetString( XmString         xstr,
453                        XmStringCharSet  char_set );
454 
455 char
456   *xitStringGetText( Widget  widget );
457 
458 void
459   xitStringSetLabel( Widget  widget,
460                      char    *char_ref );
461 
462 void
463   xitStringSetTextFromFile( Widget  widget,
464                             char    *file_name );
465 
466 void
467   xitViewText( Widget  parent,
468                char    *text,
469                char    *title,
470                char    *close_button );
471 
472 #endif
473