Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / prop.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23
24 /*
25  *      $XConsortium: prop.h /main/5 1996/08/08 17:58:47 mustafa $
26  *
27  * @(#)prop.h   1.75 95/04/20 Copyright 1993 Sun Microsystems
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement between
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
35  *      Sun's specific written approval.  This document and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  */
42
43 /*
44  * prop.h - defines structures/routines required for property sheets
45  */
46 #ifndef _PROPS_H_
47 #define _PROPS_H_
48
49 #include <X11/Intrinsic.h>
50 #include <values.h>
51 #include <limits.h>
52 #include <ab_private/obj.h>
53 #include <ab_private/pal.h>
54 #include <ab_private/abobj_edit.h>
55 #include "revolv_ui.h"
56
57 #define SIZE_OF_CONTENTS_KEY    -1
58 #define SIZE_FIXED_KEY          0
59 #define SIZE_IN_CHARS_KEY       88
60 #define SIZE_IN_PIXELS_KEY      99
61 #define EDIT_CHANGE             111
62 #define HELP_ITEM_KEY           222
63 #define DISMISS_ITEM_KEY        333
64 #define ACTION1_ITEM_KEY        444
65 #define ACTION2_ITEM_KEY        555
66 #define ACTION3_ITEM_KEY        777
67 #define CANCEL_ITEM_KEY         888
68 #define SHOW_VALUE_KEY          999
69
70 /*
71  * Load Flags - defines which attributes need to be loaded
72  */
73 #define LoadClear               0x0000
74 #define LoadAll                 0x0001
75 #define LoadName                0x0002
76 #define LoadPosition            0x0004
77 #define LoadSize                0x0008
78
79 /*
80  * Enum values for Changebar State
81  */
82 typedef enum
83 {
84         PROP_CB_OFF,
85         PROP_CB_ON,
86         PROP_CB_NUM_VALUES
87 } PROP_CB_STATE;
88
89 #define ERR_ATOI        MAXINT
90
91 /*
92  * Item Editing Insert choices
93  */
94 typedef enum
95 {
96         INSERT_AFTER = 6, /* prevent conflict with AB_EDIT_ enums */
97         INSERT_BEFORE,
98         INSERT_TOP,
99         INSERT_BOTTOM,
100         INSERT_NUM_VALUES
101 } INSERT_TYPE;
102
103 /*
104  * Geometry Keys
105  */
106 typedef enum
107 {
108         GEOM_X,
109         GEOM_Y,
110         GEOM_WIDTH,
111         GEOM_HEIGHT,
112         GEOM_NUM_VALUES
113 } GEOM_KEY;
114
115 extern char *LabelForString;
116 extern char *LabelForGraphic;
117 extern char *NoneItem;
118 extern char *XFieldStr;
119 extern char *YFieldStr;
120 extern char *WFieldStr;
121 extern char *HFieldStr;
122 extern char *OffsetFieldStr;
123 extern char *PercentageFieldStr;
124 extern char *RowColFieldStr;
125 extern char *VertSpacingFieldStr;
126 extern char *HorizSpacingFieldStr;
127
128 /*
129  * Structures to store Prop Sheet Setting Widgets
130  */
131 typedef struct _PROP_CHECKBOX_SETTING {
132     Widget      label;
133     Widget      checkbox;
134     Widget      changebar;
135 } PropCheckboxSettingRec, *PropCheckboxSetting;
136
137 typedef struct _PROP_COLOR_SETTING {
138     Widget      label;
139     Widget      menubutton;
140     Widget      swatch;
141     Widget      field;
142     Widget      changebar;
143 } PropColorSettingRec, *PropColorSetting;
144
145 typedef struct _PROP_OBJ_COMBOBOX_SETTING {
146     Widget      label;
147     Widget      combobox;
148     Widget      list;
149     Widget      changebar;
150     ABObj       *current_obj_ptr;
151 } PropObjComboboxSettingRec, *PropObjComboboxSetting;
152
153 typedef struct _PROP_FIELD_SETTING {
154     Widget      label;
155     Widget      field;
156     Widget      changebar;
157 } PropFieldSettingRec, *PropFieldSetting;
158
159 typedef struct _PROP_FOOTER_SETTING {
160     Widget      label;
161     Widget      checkbox;
162     Widget      field;
163     Widget      changebar;
164 } PropFooterSettingRec, *PropFooterSetting;
165
166 typedef struct _PROP_GEOMETRY_SETTING {
167     Widget      label;
168     Widget      x_label;
169     Widget      x_field;
170     Widget      y_label;
171     Widget      y_field;
172     Widget      w_label;
173     Widget      w_field;
174     Widget      h_label;
175     Widget      h_field;
176     Widget      changebar;
177 } PropGeometrySettingRec, *PropGeometrySetting;
178
179 typedef struct _PROP_MENUNAME_SETTING {
180     AB_PROP_TYPE prop_type;
181     Widget      label;
182     Widget      menubutton;
183     Widget      field;
184     Widget      owner_name_field;
185     Widget      changebar;
186     PropFieldSetting menu_title_pfs;
187     ABObj       *current_obj_ptr;
188 } PropMenunameSettingRec, *PropMenunameSetting;
189
190 typedef struct _PROP_OPTIONS_SETTING {
191     Widget      label;
192     Widget      optionbox;
193     Widget      menu;
194     Widget      changebar;
195 } PropOptionsSettingRec, *PropOptionsSetting;
196
197 typedef struct _PROP_OBJ_OPTIONS_SETTING {
198     PropOptionsSettingRec       options;
199     BOOL                        display_module;
200     ABObj                       *current_obj_ptr;
201     ABObjTestFunc               obj_test_func;
202     ABObj                       search_root;
203 } PropObjOptionsSettingRec, *PropObjOptionsSetting;
204
205 typedef struct _PROP_RADIO_SETTING {
206     Widget      label;
207     Widget      radiobox;
208     Widget      changebar;
209 } PropRadioSettingRec, *PropRadioSetting;
210
211 typedef struct _PROP_ITEMS_SETTING {
212     AB_ITEM_TYPE          item_type;
213     Widget                item_list;
214     Widget                item_menu;
215     PropFieldSetting      item_label_pfs;
216     PropOptionsSetting    item_label_type_pos;
217     PropFieldSetting      item_mnemonic_pfs;
218     PropFieldSetting      item_accel_pfs;
219     PropOptionsSetting    item_line_style_pos;
220     PropCheckboxSetting   item_state_pcs;
221     PropMenunameSetting   item_menuname_pms;
222     Widget                changebar;
223     ABObj                 current_item;
224     ABObj                 clipboard_item;
225     ABObj                 *current_obj_ptr;
226 } PropItemsSettingRec, *PropItemsSetting;
227
228 /*
229  * Prop Dialog Management Functions
230  */
231                 /* Prop module Initialization
232                  */
233 extern void     prop_init(
234                     Widget toplevel
235                 );
236
237                 /* Property Dialog "Popup" routines
238                  */
239 extern void     prop_show_dialog(
240                     Widget      w,
241                     XtPointer   client_data,
242                     XtPointer   call_data
243                 );
244 extern void     prop_show_fixed(
245                     PalItemInfo *palitem
246                 );
247 extern void     prop_show_menu_props(
248                     Widget      w,
249                     XtPointer   client_data,
250                     XtPointer   call_data
251                 );
252 extern void     prop_show_group_props(
253                     Widget      w,
254                     XtPointer   client_data,
255                     XtPointer   call_data
256                 );
257 extern void     prop_load_obj(
258                     ABObj        obj,
259                     AB_PROP_TYPE ptype
260                 );
261                 /* Prop Dialog Initialization Functions
262                  */
263 extern void     prop_activate_panel_init(
264                     AB_PROP_TYPE type,
265                     PalItemInfo *palitem,
266                     Widget      ok_button,
267                     Widget      apply_button,
268                     Widget      reset_button,
269                     Widget      cancel_button,
270                     Widget      help_button
271                 );
272 extern void     prop_editors_panel_init(
273                     AB_PROP_TYPE type,
274                     PalItemInfo *palitem,
275                     Widget      attach_ed_button,
276                     Widget      conn_ed_button,
277                     Widget      help_ed_button
278                 );
279 extern void     prop_fixed_dialog_init(
280                     PalItemInfo         *palitem,
281                     Widget              dialog,
282                     Widget              list
283                 );
284
285                 /* Checkbox Setting Functions
286                  */
287 extern void     prop_checkbox_init(
288                     PropCheckboxSetting pcs,
289                     Widget              label,
290                     Widget              checkbox,
291                     int                 num_items,
292                     WidgetList          items,
293                     int                 *item_keys,
294                     Widget              changebar
295                 );
296 extern BOOL     prop_checkbox_get_value(
297                     PropCheckboxSetting pcs,
298                     int                 itemkey
299                 );
300 extern int      prop_checkbox_set_value(
301                     PropCheckboxSetting pcs,
302                     int                 itemkey,
303                     BOOL                value,
304                     BOOL                trip_changebar
305                 );
306
307                 /* Color Field Functions
308                  */
309 extern void     prop_colorfield_init(
310                     PropColorSetting    pcs,
311                     Widget              menubutton,
312                     Widget              none_item,
313                     Widget              chooser_item,
314                     Widget              swatch,
315                     Widget              field,
316                     Widget              changebar
317                 );
318 extern int      prop_colorfield_set_value(
319                     PropColorSetting    pcs,
320                     STRING              colorname, /* NULL clears swatch */
321                     BOOL                trip_changebar
322                 );
323                 /* Caller must free memory allocated for return String */
324 extern STRING   prop_colorfield_get_value(
325                     PropColorSetting    pcs
326                 );
327
328 /* REMIND: ComboBox has too many bugs to use right now; if
329  *         we never revert back to using it, delete these functions
330  */
331                 /* Object Combobox Functions
332                  */
333 extern void     prop_obj_combobox_init(
334                     PropObjComboboxSetting      pcs,
335                     Widget                      label,
336                     Widget                      combobox,
337                     Widget                      changebar,
338                     ABObj                       *current_obj_ptr
339                 );
340
341 extern ABObj    prop_obj_combobox_get_value(
342                     PropObjComboboxSetting      pcs
343                 );
344
345 extern int      prop_obj_combobox_set_value(
346                     PropObjComboboxSetting      pcs,
347                     ABObj                       obj,
348                     BOOL                        trip_changebar
349                 );
350
351 extern void     prop_obj_combobox_load(
352                     PropObjComboboxSetting      pcs,
353                     ABObj                       root,
354                     ABObjTestFunc               obj_test_func
355                 );
356
357
358                 /* TextField Functions
359                  */
360 extern void     prop_field_init(
361                     PropFieldSetting    pfs,
362                     Widget              label,
363                     Widget              field,
364                     Widget              changebar
365                 );
366                 /* Caller must free memory allocated for return String */
367 extern STRING   prop_field_get_value(
368                     PropFieldSetting    pfs
369                 );
370 extern int      prop_field_get_numeric_value(
371                     PropFieldSetting    pfs
372                 );
373 extern int      prop_field_set_value(
374                     PropFieldSetting    pfs,
375                     STRING              value,
376                     BOOL                trip_changebar
377                 );
378 extern int      prop_field_set_numeric_value(
379                     PropFieldSetting    pfs,
380                     int                 value,
381                     BOOL                trip_changebar
382                 );
383
384                 /* Footer Setting Functions
385                  */
386 extern void     prop_footer_init(
387                     PropFooterSetting    pfs,
388                     Widget              label,
389                     Widget              checkbox,
390                     int                 num_items,
391                     WidgetList          items,
392                     int                *item_keys,
393                     Widget              field,
394                     Widget              changebar
395                 );
396
397                 /* Item Editor Functions
398                  */
399 extern void     prop_item_editor_init(
400                     PropItemsSetting    pis,
401                     AB_ITEM_TYPE        type,
402                     Widget              list,
403                     Widget              changebar,
404                     Widget              add_button,
405                     int                 insert_count,
406                     WidgetList          insert_items,
407                     int                 *insert_enums,
408                     int                 edit_count,
409                     WidgetList          edit_items,
410                     int                 *edit_enums,
411                     PropFieldSetting    label_pfs,
412                     PropOptionsSetting  label_type_pos,
413                     Widget              label_graphic_hint,
414                     PropFieldSetting    mnemonic_pfs,
415                     PropFieldSetting    accel_pfs,
416                     PropOptionsSetting  line_style_pos,
417                     PropCheckboxSetting state_pcs,
418                     PropMenunameSetting menuname_pms,
419                     ABObj               *current_obj_ptr
420                 );
421 extern void     prop_item_editor_apply(
422                     PropItemsSetting    pis
423                 );
424 extern void     prop_item_editor_clear(
425                     PropItemsSetting    pis
426                 );
427 extern void     prop_item_editor_load(
428                     PropItemsSetting    pis,
429                     ABObj               obj
430                 );
431 extern void     prop_item_change(
432                     PropItemsSetting    pis,
433                     BOOL                reselect
434                 );
435 extern void     prop_item_edit(
436                     PropItemsSetting    pis,
437                     AB_EDIT_TYPE        etype
438                 );
439 extern STRING   prop_item_get_namebase(
440                     ABObj               iobj
441                 );
442 extern int      prop_item_insert(
443                     PropItemsSetting    pis,
444                     INSERT_TYPE         itype,
445                     ABObj               iobj
446                 );
447 extern void     prop_item_labeltypeCB(
448                     Widget              w,
449                     XtPointer           client_data,
450                     XtPointer           call_data
451                 );
452
453                 /* Geometry Field Functions
454                  */
455 extern void     prop_geomfield_init(
456                     PropGeometrySetting pgs,
457                     Widget              label,
458                     Widget              x_label,
459                     Widget              x_field,
460                     Widget              y_label,
461                     Widget              y_field,
462                     Widget              w_label,
463                     Widget              w_field,
464                     Widget              h_label,
465                     Widget              h_field,
466                     Widget              changebar
467                 );
468 extern int      prop_geomfield_get_value(
469                     PropGeometrySetting pgs,
470                     GEOM_KEY            gkey
471                 );
472 extern int      prop_geomfield_set_value(
473                     PropGeometrySetting pgs,
474                     GEOM_KEY            gkey,
475                     int                 gvalue,
476                     BOOL                trip_changebar
477                 );
478
479 extern int      prop_geomfield_clear(
480                     PropGeometrySetting pgs,
481                     GEOM_KEY            gkey
482                 );
483
484 extern void     prop_size_policyCB(
485                     Widget              w,
486                     XtPointer           client_data,
487                     XtPointer           call_data
488                 );
489
490 extern void     prop_load_obj_position(
491                     ABObj               obj,
492                     PropGeometrySetting pgs
493                 );
494
495 extern void     prop_load_obj_size(
496                     ABObj               obj,
497                     PropGeometrySetting pgs
498                 );
499
500                 /* Menu Name Field Functions
501                  */
502 extern void     prop_menuname_init(
503                     PropMenunameSetting pms,
504                     AB_PROP_TYPE        ptype,
505                     Widget              label,
506                     Widget              menubutton,
507                     Widget              field,
508                     Widget              owner_name_field,
509                     Widget              changebar,
510                     PropFieldSetting    menu_title_pfs,
511                     ABObj               *current_obj_ptr,
512                     BOOL                new_item_ok
513                 );
514                 /* Caller must free memory allocated for return String */
515 extern STRING   prop_menuname_get_value(
516                     PropMenunameSetting pms
517                 );
518 extern int      prop_menuname_set_value(
519                     PropMenunameSetting pms,
520                     STRING              value,
521                     BOOL                trip_changebar
522                 );
523
524                 /* Option Menu Functions
525                  */
526 extern void     prop_options_init(
527                     PropOptionsSetting  pos,
528                     Widget              label,
529                     Widget              optionbox,
530                     Widget              menu,
531                     int                 num_items,
532                     WidgetList          items,
533                     XtPointer           *item_vals,
534                     Widget              changebar
535                 );
536 extern XtPointer    prop_options_get_value(
537                     PropOptionsSetting  pos
538                 );
539 extern int      prop_options_set_value(
540                     PropOptionsSetting  pos,
541                     XtPointer           value,
542                     BOOL                trip_changebar
543                 );
544 extern int      prop_options_remove_value(
545                     PropOptionsSetting  pos,
546                     XtPointer           value,
547                     BOOL                trip_changebar
548                 );
549
550                 /* Object OptionMenu Functions
551                  */
552 extern void     prop_obj_options_init(
553                     PropObjOptionsSetting       pos,
554                     Widget                      label,
555                     Widget                      optionbox,
556                     Widget                      menu,
557                     int                         num_items,
558                     WidgetList                  items,
559                     XtPointer                   *item_vals,
560                     Widget                      changebar,
561                     BOOL                        display_module,
562                     ABObj                       *current_obj_ptr,
563                     ABObjTestFunc               obj_test_func
564                 );
565
566 extern ABObj    prop_obj_options_get_value(
567                     PropObjOptionsSetting       pos
568                 );
569
570 extern int      prop_obj_options_set_value(
571                     PropObjOptionsSetting       pos,
572                     ABObj                       obj,
573                     BOOL                        trip_changebar
574                 );
575
576 extern void     prop_obj_options_load(
577                     PropObjOptionsSetting       pos,
578                     ABObj                       search_root
579                 );
580
581                 /* Radiobox Functions
582                  */
583 extern void     prop_radiobox_init(
584                     PropRadioSetting    prs,
585                     Widget              label,
586                     Widget              radiobox,
587                     int                 num_items,
588                     WidgetList          items,
589                     XtPointer           *item_vals,
590                     Widget              changebar
591                 );
592 extern int      prop_radiobox_get_value(
593                     PropRadioSetting    prs
594                 );
595 extern int      prop_radiobox_set_value(
596                     PropRadioSetting    prs,
597                     XtPointer           value,
598                     BOOL                trip_changebar
599                 );
600
601 extern void     prop_label_field_init(
602                     PropFieldSetting    label_pfs,
603                     Widget              graphic_hint,
604                     WidgetList          labeltype_items,
605                     int                 num_items
606                 );
607 extern void     prop_setup_label_field(
608                     PropFieldSetting    label_pfs,
609                     PropOptionsSetting  label_line_style_pos,
610                     AB_LABEL_TYPE       ltype,
611                     STRING              label,
612                     AB_LINE_TYPE        line_style
613                 );
614
615                 /*
616                  * Changebar Management Routines
617                  */
618 extern BOOL     prop_changed(
619                     Widget      changebar
620                 );
621 extern BOOL     prop_changebars_pending(
622                     Widget      prop_form
623                 );
624 extern void     prop_changebars_cleared(
625                     Widget      prop_form
626                 );
627 extern void     prop_set_changebar(
628                     Widget      changebar,
629                     int         state
630                 );
631
632                 /*
633                  * Prop Setting Verification Routines
634                  */
635 extern int      prop_str_to_int(
636                     STRING      str
637                 );
638
639 extern BOOL     prop_string_ok(
640                     Widget      field,
641                     const char *chars,
642                     BOOL        display_notice
643                 );
644
645 extern BOOL     prop_identifier_ok(
646                     Widget      field
647                 );
648
649 extern BOOL     prop_name_ok(
650                     ABObj       obj,
651                     Widget      field
652                 );
653
654 extern BOOL     prop_graphic_filename_ok(
655                     Widget      field,
656                     BOOL        empty_ok
657                 );
658
659 extern BOOL     prop_obj_name_ok(
660                     Widget      field,
661                     ABObj       root,
662                     AB_OBJECT_TYPE objtype,
663                     STRING      objtype_name
664                 );
665
666 extern BOOL     prop_submenu_name_ok(
667                     Widget      field,
668                     ABObj       owner
669                 );
670
671 extern BOOL     prop_color_ok(
672                     Widget      field
673                 );
674
675 extern BOOL     prop_number_ok(
676                     Widget      field,
677                     STRING      field_name,
678                     int         min,
679                     int         max
680                 );
681
682 extern BOOL     prop_help_item_ok(
683                     Widget      list,
684                     ABObj       item_obj
685                 );
686
687
688 #endif /* _PROP_H_ */