UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dialogs.h
1 /* dialogs.h */
2 /* $Id: dialogs.h,v 1.23 2006/10/18 10:58:57 vlad Exp $ */
3 #ifndef __dialogs_h
4 #define __dialogs_h
5 
6 #include <stdio.h>
7 #include <X11/Intrinsic.h>
8 #include <ldb/dbtools.h>
9 
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif /* __cplusplus */
14 
15 /* Width limit width of dbt dialogs to prevent too width selection box. */
16 #define ZM_MAX_DBT_DIALOG_WIDTH 120
17 
18 /* Special codes which can be returned by Zm* functions in emergency. */
19 #define ZM_CANCEL (-1)
20 #define ZM_BAD_CALL (-2)
21 
22 
23 /***********************************************************************
24  * Generic list dialog. Can select one item from pointed string
25  * item set. Returns index of selected string in set (0..) or
26  * -1 if cancel is pressed.
27  * Input:
28  * Widget parent -- parent widget;
29  * const char* name -- dialog name (NULL=>"LSB");
30  * const char* title -- dialog WM title (NULL=>"Single Selection");
31  * const char* lhead -- title of list (NULL=>"List");
32  * char** sset -- selectable set;
33  * int sset_n -- number of items in sset;
34  * Return values:
35  * 0 .. sset_n-1 -- index of selected item by Ok;
36  * -1 -- Cancel is pressed;
37  * -2 -- bad primary parameters.
38  */
39 int
40 ZmListSelectionBox (Widget parent, /* parent widget */
41  const char* name, /* dialog name */
42  const char* title, /* dialog WM title */
43  const char* lhead, /* title of list */
44  char** sset, /* selectable set */
45  int sset_n); /* number of items in sset */
46 
47 
48 /***********************************************************************
49  * Generic multiple selection list dialog. Can select one or any number
50  * of items from pointed string item set. Returns numner of selected
51  * indeces in set (1..max_sel) or 0 if Cancel is pressed or zero items
52  * were selected.
53  * Input:
54  * Widget parent -- parent widget;
55  * const char* name -- dialog name (NULL=>"MSB");
56  * const char* title -- dialog WM title (NULL=>"Multiple Selection");
57  * const char* lhead -- title of list (NULL=>"List");
58  * char** sset -- selectable set;
59  * int sset_n -- number of items in sset;
60  * int max_sel -- max number of items or 0;
61  * int** sel_items -- array of selected indeces in order
62  * of selection (dyn. allocated);
63  * Return values:
64  * number of items in sel_items
65  * 0 -- no items were selected;
66  * -1 -- Cancel is pressed;
67  * -2 -- bad primary parameters.
68  */
69 int
70 ZmListMultipleSelectionBox (Widget parent, /* parent widget */
71  const char* name, /* dialog name */
72  const char* title, /* dialog WM title */
73  const char* lhead, /* title of list */
74  char** sset, /* selectable set */
75  int sset_n, /* number of items in sset */
76  int max_sel, /* max number of items or 0 */
77  int** sel_items); /* array of sel.item indeces */
78 
79 
80 /***********************************************************************
81  * Generic list dialog with enter feature. Can select one
82  * item from pointed string item set. Returns index of
83  * selected string in set (0..) or -1 if cancel is pressed.
84  * Input:
85  * Widget parent -- parent widget;
86  * const char* name -- dialog name (NULL=>"LEB");
87  * const char* title -- dialog WM title (NULL=>"Single Enter");
88  * const char* lhead -- title of list (NULL=>"List");
89  * char** sset -- selectable set;
90  * int sset_n -- number of items in sset;
91  * char** enter -- non-matched entered item free(*enter);
92  * Return values:
93  * 0 .. sset_n-1 -- index of selected item by Ok;
94  * sset_n -- means new value entered in enter;
95  * -1 -- Cancel is pressed;
96  * -2 -- bad primary parameters.
97  */
98 int
99 ZmListEnterBox (Widget parent, /* parent widget */
100  const char* name, /* dialog name */
101  const char* title, /* dialog WM title */
102  const char* lhead, /* title of list */
103  char** sset, /* selectable set */
104  int sset_n, /* number of items in sset */
105  char** enter); /* non-matched entered item */
106 
107 
108 /***********************************************************************
109  * Project selection dialog. Project is selected from DATA
110  * directory. If selection is OK project is checked for JOBS
111  * and LOG existance with EL_WARNING alarm if are not exist.
112  * Memory is allocated for selected project by malloc().
113  * If no project is selected NULL will be returned.
114  */
115 char*
116 ZmProjectSelectionBox (Widget parent); /* parent widget */
117 
118 
119 /***********************************************************************
120  * Data selection dialog. Data modification is a four chars
121  * name that begins with D,R,S. Other three chars is number
122  * xxx. So, D123, R000, S987 are correct modification names.
123  * Filename is mod.name with .dat suffix: D678.dat for example.
124  * Modification is two files: Mxxx.tab and [DRS]xxx.dat.
125  * Mxxx.dat contains pointer at *.dat file, so xxx must be the
126  * same to provide bidirectional relation between them.
127  * The function returns [DRS]xxx string. If Mxxx.tab is not
128  * exist or bad, EL_WARNING alarmed through wePutMsg. So will
129  * be if Mxxx.tab does not point to selected string.
130  * Memory for returned string is allocated by malloc().
131  * If project is NULL current one will be used.
132  */
133 char*
134 ZmDataSelectionBox (Widget parent, /* parent widget */
135  const char* project); /* project to select from */
136 
137 
138 /***********************************************************************
139  * Data enter dialog. Data modification is a four chars
140  * name that begins with D,R,S. Other three chars is number
141  * xxx. So, D123, R000, S987 are correct modification names.
142  * Filename is mod.name with .dat suffix: D678.dat for example.
143  * Modification is two files: Mxxx.tab and [DRS]xxx.dat.
144  * Mxxx.dat contains pointer at *.dat file, so xxx must be the
145  * same to provide bidirectional relation between them.
146  * The function returns [DRS]xxx string.
147  * Memory for returned string is allocated by malloc().
148  * If project is NULL current one will be used.
149  * def_nmod can be used for default value assignment. def_nmod
150  * can be NULL.
151  * */
152 char*
153 ZmDataEnterBox (Widget parent, /* parent widget */
154  const char* project, /* project to select from */
155  const char* def_nmod); /* default value */
156 
157 
158 /***********************************************************************
159  * Data base table selection dialog form db list table. Any
160  * data base list can be used. It must have "DTBSPTR" domain
161  * to store db pointer. If this domain is not found, NULL will
162  * be returned. dbname must be not null pointer at storage for
163  * result db name.
164  */
166 ZmDbtListSelectionBox (Widget parent, /* parent widget */
167  const char* project, /* project to select from */
168  const char* dblist, /* db list to select from */
169  dbNameStruct* dbname); /* place for selected dbtable */
170 
171 
172 /***********************************************************************
173  * Data base table selection dialog from project DATA directory.
174  * If dbmask contains right dbt name it is used as filter for
175  * directory entries. For example if dbmask.mask=DB_TABLE and
176  * dbmask.table="FBINFO", all files VSP.*.*.FBINFO.* will be
177  * placed in selection list.
178  * To select all data tables: dbmask.mask=0.
179  * To select only db lists: dbmask.mask=DB_LIST.
180  * Selected table will be placed in dbmask
181  * If project is NULL current one will be used.
182  * */
184 ZmDbtFileSelectionBox (Widget parent, /* parent widget */
185  const char* project, /* project to select from */
186  dbNameStruct* dbmask); /* mask to filter result */
187 
188 
189 /***********************************************************************
190  * Data base table enter dialog from project DATA directory.
191  * If dbmask contains right dbt name it is used as filter for
192  * directory entries. For example if dbmask.mask=DB_TABLE and
193  * dbmask.table="FBINFO", all files VSP.*.*.FBINFO.* will be
194  * placed in selection list. If user entered db name that does
195  * not correcpond to dbmask, cancel with EL_ERROR message will
196  * be.
197  * To select all data tables: dbmask.mask=0.
198  * To select only db lists: dbmask.mask=DB_LIST.
199  * Selected or entered table will be placed in dbmask
200  * If project is NULL current one will be used.
201  */
203 ZmDbtFileEnterBox (Widget parent, /* parent widget */
204  const char* project, /* project to select from */
205  dbNameStruct* dbmask); /* mask to filter result */
206 
207 
208 /***********************************************************************
209  * Data base line selection from dbfrom table. Selected line
210  * passed as dbwhere dbItem (dbfrom table and index of line in
211  * it). dbfrom table can be of any type. Selected item is
212  * returned by function or NULL if some errors took place.
213  * NULL will be returned if cancel was pressed. If flag
214  * is equal to NEW_DB_ITEM, user can select one additional line
215  * that is new item. Such selection is represented by number
216  * of line = -1.
217  */
218 #define ZM_NEW_DB_ITEM 1
219 dbItem*
220 ZmDbtItemSelectionBox (Widget parent, /* parent widget */
221  const char* project, /* project to select from */
222  dbNameStruct* dbfrom, /* db table to select from */
223  dbItem* dbwhere, /* place for selected line */
224  int flag); /* NEW_DB_ITEM or 0 */
225 
226 
227 /***********************************************************************
228  * Generic file selection dialog. Can select or enter one file
229  * with full path. There are some "standard" start directories
230  * to provide easy access to project and user directories.
231  * Input:
232  * Widget parent -- parent widget;
233  * const char* name -- dialog name (NULL=>"FSB");
234  * const char* title -- dialog WM title (NULL=>"File Selection");
235  * const char* dirspec -- directory (ZM_CURRENT_DIR,ZM_PROJECT_LOGS,
236  * ZM_PROJECT_JOBS,ZM_PROJECT_DATA,ZM_USER_DEFAULTS or any string);
237  * const char* fmask -- file mask (* and ? are special) or NULL;
238  * Return values:
239  * NULL -- cancel or bad parameters;
240  * non-NULL -- pointer at full path to selected file to free();
241  */
242 #define ZM_CURRENT_DIR ((char*)0)
243 #define ZM_USER_DEFAULTS ((char*)1)
244 #define ZM_PROJECT_LOGS ((char*)2)
245 #define ZM_PROJECT_JOBS ((char*)3)
246 #define ZM_PROJECT_DATA ((char*)4)
247 #define ZM_PROJECT_REPORT ((char*)5)
248 #define ZM_PROJECT_HCOPIES ((char*)6)
249 #define ZM_PROJECT_ARCHIVE ((char*)7)
250 #define ZM_USER_HOME ((char*)8)
251 #define ZM_SYSTEM_ETC ((char*)9)
252 char*
253 ZmFileSelectionBox (Widget parent, /* parent widget */
254  const char* name, /* dialog name */
255  const char* title, /* dialog WM title */
256  const char* dirspec,/* directory */
257  const char* fmask); /* file mask */
258 
264 char*
265 ZmPathSpecToPath (const char* szPathSpec);
266 
267 
268 
269 /***********************************************************************
270  * Enter dbt name by parts.
271  * Input:
272  * Widget parent -- parent widget;
273  * const char* name -- dialog name (NULL=>"DBTNB");
274  * const char* title -- dialog WM title (NULL=>"Data base table naming");
275  * dbNameStruct* dbns -- partially defined dbt name; user needs
276  * to define (or redefine) parts of name;
277  * int fixed_mask -- parts of name not to edit;
278  * int oblig_mask -- obligatory parts of name to define;
279  * Output:
280  * NULL -- cancel pressed;
281  * non-NULL -- pointer dbns but with defined parts;
282  */
284 ZmDbtNamingBox (Widget parent, /* parent widget */
285  const char* name, /* dialog name */
286  const char* title, /* dialog WM title */
287  dbNameStruct* dbns, /* partially defined dbt name */
288  int fixed_mask, /* parts of name not to edit */
289  int oblig_mask); /* parts of name to define */
290 
291 
292 /***********************************************************************
293  * Palette selection dialog by name. Returns dynamically allocated
294  * name of the palette which can be used in zcp_get_palette()
295  * regarding leading '-' in case of reverted color's order is
296  * requested. Needs zcp_init() called before. Returns NULL on error.
297  */
298 char*
299 ZmPaletteSelectionBox (Widget parent, /* parent widget */
300  const char* szDefaultPalette); /* may be NULL */
301 
302 
303 /***********************************************************************
304  * Color name selection dialog. Returns name of selected color.
305  * Needs zcp_init() called before. Returns NULL on error. Returned
306  * string is dynamically allocated and must be free() if unused.
307  */
308 char*
309 ZmColorNameSelectionBox (Widget parent,
310  const char* szDefaultColor);
311 
312 
313 /* Value for dialog type */
314 typedef enum
315 {
316  ZmDialogSingleSelectionList = 0,
317  ZmDialogMultipleSelectionList
318 
319 } ZmDialogType;
320 
321 /* Value for preselect_kind */
322 typedef enum
323 {
324  ZmPreselectByPos = 0, /* line index: 0..sset_n-1 */
325  ZmPreselectByString, /* whole line match */
326  ZmPreselectByTaggedDbtName /* match only tagged column */
327 
328 } ZmDialogPreselectKind;
329 
330 /* Custom final widget processing procedure. */
331 typedef void (*ZmCustomWidgetProc) (Widget wParent, Widget wTarget);
332 
333 /* Structure to store customized options */
334 typedef struct
335 {
336  int mask; /* ORed options: ZmDM_* */
337  char *help_section;
338  char *title_string;
339  char *resource_name;
340  ZmDialogPreselectKind preselect_kind;
341  int preselect_pos;
342  char *preselect_tag;
343  char *preselect_string;
344  dbNameStruct preselect_dbtname;
345  char *dialog_id; /* id string for this dialog */
346  ZmDialogType dialog_type;
347  int multselect_max; /* max number of selected lines */
348  int *multselect_num;/* number of selected lines */
349  void *multselect_list;/* resulting array of selected items */
350  ZmCustomWidgetProc custom_selbox_proc;/* for SelBox */
351 
353 
354 /* Mask for selected customized options */
355 #define ZmDM_HELP_SECTION (1<<0)
356 #define ZmDM_TITLE_STRING (1<<1)
357 #define ZmDM_RESOURCE_NAME (1<<2)
358 #define ZmDM_PRESELECT_KIND (1<<3)
359 #define ZmDM_PRESELECT_POS (1<<4)
360 #define ZmDM_PRESELECT_TAG (1<<5)
361 #define ZmDM_PRESELECT_STRING (1<<6)
362 #define ZmDM_PRESELECT_DBTNAME (1<<7)
363 #define ZmDM_DIALOG_ID (1<<8)
364 #define ZmDM_DIALOG_TYPE (1<<9)
365 #define ZmDM_MULTSELECT_MAX (1<<10)
366 #define ZmDM_MULTSELECT_NUM (1<<11)
367 #define ZmDM_MULTSELECT_LIST (1<<12)
368 #define ZmDM_CUSTOM_SELBOX_PROC (1<<13)
369 
370 /* Identifiers for customizable options */
371 typedef enum {
372  ZmD_End = 0, /* end-of-list option */
373  ZmD_HelpSection, /* setup help section */
374  ZmD_TitleString, /* setup window title (English) */
375  ZmD_ResourceName, /* setup resource name */
376  ZmD_PreselectKind, /* what type of preselect?
377  * no preselect by default! */
378  ZmD_PreselectTag, /* match something in column tag */
379  ZmD_PreselectPos, /* preselect line # pos or number of lines */
380  ZmD_PreselectString, /* preselect line which match string */
381  ZmD_PreselectDbtName, /* preselect line which match dbt name */
382  ZmD_DialogId, /* N/A - dialog_id to store state between sessions */
383  ZmD_DialogType, /* single or multiple selection? */
384  ZmD_MultselectMax, /* max number of selected lines */
385  ZmD_MultselectNum, /* number of selected lines */
386  ZmD_MultselectList, /* resulting array of selected items */
387  ZmD_CustomSelBoxProc /* ptr to function called on created SelBox */
388 
389 } ZmDialogCustomOptionName;
390 
391 
392 /* Setup additional parameters for the nearest dialog call.
393  * For example, context help facility, customized title etc.
394  * Programmer may call this function just before dialog call.
395  * WARNING! Not for multithreaded applications! */
396 void ZmCustomizeDialog (ZmDialogCustomOptionName dco1, ...);
397 
398 
399 /* Clear all previous customizable options.
400  * For internal usage. */
401 void ZmClearCustomOptions ();
402 
403 
404 /* Get resource name. */
405 const char* ZmDialogGetResourceName (const char* szGivenRes,
406  const char* szDefaultRes);
407 
408 /* Setup help. Return TRUE on success (help is defined) and FALSE
409  * otherwise. */
410 Logic ZmDialogSetupHelp (Widget wSelBox);
411 
412 /* Setup title. */
413 void ZmDialogSetupTitle (Widget wShell,
414  const char* szGivenTitle,
415  const char* szDefaultTitle);
416 
417 /* N/A - Prepare (open) file for dialog state saving/retrieving */
418 FILE* ZmDialogStateFile (const char* szDialogId,
419  const char* szMode); /* "r" or "w" */
420 
421 
422 #ifdef __CustomOptionVariable
423 #define EXTERN
424 #else /* __CustomOptionVariable */
425 #define EXTERN extern
426 #endif /* __CustomOptionVariable */
427 EXTERN ZmDialogCustomOptions rCustomOpt;
428 #undef EXTERN
429 
430 
431 #ifdef __cplusplus
432 };
433 #endif /* __cplusplus */
434 
435 #endif /* dialogs.h */
Definition: dbnamedefs.h:67
Definition: dialogs.h:334
Definition: dbnamedefs.h:85