Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / libABobj / obj_fields.c
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: obj_fields.c /main/4 1996/10/29 15:20:22 mustafa $
26  * 
27  * @(#)obj_fields.c     3.72 15 Feb 1994        cde_app_builder/src/libABobj
28  * 
29  * RESTRICTED CONFIDENTIAL INFORMATION:
30  * 
31  * The information in this document is subject to special restrictions in a
32  * confidential disclosure agreement between HP, IBM, Sun, USL, SCO and
33  * Univel.  Do not distribute this document outside HP, IBM, Sun, USL, SCO,
34  * or Univel without Sun's specific written approval.  This document and all
35  * copies and derivative works thereof must be returned or destroyed at Sun's
36  * request.
37  * 
38  * Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
39  * 
40  */
41
42
43 /*
44  * fields.c - set and get fields of the gobj structure
45  */
46
47 #include <stdio.h>
48 #include <string.h>
49 #include "objP.h"
50 #include "obj_notifyP.h"
51 #include "obj_names_listP.h"
52 #include <ab_private/util.h>
53
54 /*
55  * This function verifies the integrity of the object, and is called at the
56  * beginning of each field access, when debugging
57  */
58 static int          verify_for_write(ABObj obj);
59 static int          verify_for_read(ABObj obj);
60
61 /*
62  * If a bad field (member) access is attempted, use member_error() to report
63  * the error. E.g.: member_error(obj, "bg_color"). It's automatically removed
64  * from non-debugging builds.
65  */
66 static int          member_error(ABObj obj, STRING member_name);
67
68 /*
69  * Define our local debugging routines
70  */
71 #ifdef DEBUG
72 static int 
73 member_error_impl(
74                   ABObj obj, STRING member_name, STRING file, int line);
75 #define member_error(obj, member_name) \
76             (member_error_impl(obj, member_name, __FILE__, __LINE__))
77 #else
78 #define member_error(obj, member_name)  /* ignore this! */
79 #endif
80
81 #ifdef DEBUG
82 static int          verify_for_read_impl(ABObj obj, STRING file, int line);
83 static int          verify_for_write_impl(ABObj obj, STRING file, int line);
84 #define verify_for_read(obj) (verify_for_read_impl(obj, __FILE__, __LINE__))
85 #define verify_for_write(obj) (verify_for_write_impl(obj, __FILE__, __LINE__))
86 #else
87 #define verify_for_read(obj)            /* ignore this! */
88 #define verify_for_write(obj)           /* ignore this! */
89 #endif
90
91
92
93 int
94 obj_set_file(ABObj obj, STRING file)
95 {
96     int                 iRet = 0;
97     ISTRING            *old_name = NULL;
98
99     verify_for_write(obj);
100     switch (obj->type)
101     {
102     case AB_TYPE_FILE:
103         iRet = obj_set_name(obj, file);         /* use name field */
104         break;
105
106     case AB_TYPE_MODULE:
107         old_name = &(obj->info.module.file);
108         break;
109
110     case AB_TYPE_PROJECT:
111         old_name = &(obj->info.project.file);
112         break;
113
114     default:
115         member_error(obj, "file");
116         iRet = -1;
117         break;
118     }
119     if (old_name != NULL)
120     {
121         istr_destroy(*old_name);
122         *old_name = istr_create(file);
123     }
124     return iRet;
125 }
126
127 /*
128  * Note - obj_get_file is more complex and is in utils.c
129  */
130
131 int
132 obj_set_has_border(ABObj obj, BOOL has_border)
133 {
134     verify_for_write(obj);
135     switch (obj->type)
136     {
137     case AB_TYPE_CONTAINER:
138         obj->info.container.has_border = has_border;
139         return 0;
140
141     case AB_TYPE_TEXT_FIELD:
142     case AB_TYPE_TEXT_PANE:
143         obj->info.text.has_border = TRUE;
144         return 0;
145
146     default:
147         member_error(obj, "has_border");
148     }
149     return -1;
150 }
151
152 int
153 obj_set_hscrollbar_policy(ABObj obj, AB_SCROLLBAR_POLICY hscrollbar)
154 {
155     verify_for_write(obj);
156     switch (obj->type)
157     {
158     case AB_TYPE_DRAWING_AREA:
159         obj->info.drawing_area.hscrollbar = hscrollbar;
160         break;
161     case AB_TYPE_TEXT_PANE:
162         obj->info.text.hscrollbar = hscrollbar;
163         break;
164     }
165
166     return 0;
167 }
168
169
170 BOOL
171 obj_has_border(ABObj obj)
172 {
173     verify_for_read(obj);
174     switch (obj->type)
175     {
176     case AB_TYPE_CONTAINER:
177         return obj->info.container.has_border;
178
179     case AB_TYPE_TEXT_FIELD:
180         return obj->info.text.has_border;
181     }
182     return FALSE;
183 }
184
185 int
186 obj_get_increment(ABObj obj)
187 {
188     verify_for_read(obj);
189     if (obj_is_spin_box(obj))
190         return(obj->info.spin_box.increment);
191     else if (obj_is_scale(obj))
192         return(obj->info.scale.increment);
193  
194     return -1; 
195
196  
197 int
198 obj_set_increment(ABObj obj, int incr)
199 {
200     verify_for_write(obj);
201     if (obj_is_spin_box(obj))
202     {
203         obj->info.spin_box.increment = incr;
204         return 0;
205     }
206     else if (obj_is_scale(obj))
207     {
208         obj->info.scale.increment = incr;
209         return 0;
210     }
211     member_error(obj, "increment");
212     return -1;
213 }
214
215 int
216 obj_set_is_default(ABObj obj, BOOL is_default)
217 {
218     verify_for_write(obj);
219     if (obj->type == AB_TYPE_PROJECT)
220     {
221         obj->info.project.is_default = is_default;
222         return 0;
223     }
224     member_error(obj, "is_default");
225     return -1;
226 }
227
228
229 BOOL
230 obj_is_default(ABObj obj)
231 {
232     verify_for_read(obj);
233     if (obj->type == AB_TYPE_PROJECT)
234     {
235         return obj->info.project.is_default;
236     }
237     return FALSE;
238 }
239
240
241 int
242 obj_set_is_defined(ABObj obj, BOOL is_defined)
243 {
244     verify_for_write(obj);
245     if (is_defined)
246     {
247         obj_set_impl_flags(obj, ObjFlagIsDefined);
248     }
249     else
250     {
251         obj_clear_impl_flags(obj, ObjFlagIsDefined);
252     }
253     return 0;
254 }
255
256 BOOL
257 obj_is_defined(ABObj obj)
258 {
259     verify_for_read(obj);
260     return obj_has_impl_flags(obj, ObjFlagIsDefined);
261 }
262
263 int
264 obj_set_is_help_item(
265                      ABObj obj,
266                      BOOL is_help_item
267 )
268 {
269     verify_for_write(obj);
270     if (obj_is_item(obj))
271     {
272         /* Only Settable for Cascade Items */
273         if (obj->info.item.type == AB_ITEM_FOR_MENUBAR)
274             obj->info.item.is_help_item = is_help_item;
275         return 0;
276     }
277     member_error(obj, "is_help_item");
278     return -1;
279 }
280
281 BOOL
282 obj_is_help_item(
283                  ABObj obj
284 )
285 {
286     verify_for_read(obj);
287     if (obj_is_item(obj))
288     {
289         return obj->info.item.is_help_item;
290     }
291     return FALSE;
292 }
293
294 int
295 obj_set_accelerator(ABObj obj, STRING accel)
296 {
297     verify_for_write(obj);
298     if (!obj_is_item(obj))
299     {
300         member_error(obj, "accelerator");
301         return -1;
302     }
303     istr_destroy(obj->info.item.accelerator);
304     obj->info.item.accelerator = istr_create(accel);
305     return 0;
306 }
307
308 int
309 obj_set_bg_color(ABObj obj, STRING bg_color)
310 {
311     verify_for_write(obj);
312     istr_destroy(obj->bg_color);
313     obj->bg_color = istr_create(bg_color);
314     return 0;
315 }
316
317 int
318 obj_set_fg_color(ABObj obj, STRING fg_color)
319 {
320     verify_for_write(obj);
321     istr_destroy(obj->fg_color);
322     obj->fg_color = istr_create(fg_color);
323     return 0;
324 }
325
326 int
327 obj_set_filter_pattern(ABObj obj, STRING filter_pattern)
328 {
329     verify_for_write(obj);
330     if (!obj_is_file_chooser(obj))
331     {
332         member_error(obj, "filter_pattern");
333         return -1;
334     }
335     istr_destroy(obj->info.file_chooser.filter_pattern);
336     obj->info.file_chooser.filter_pattern = istr_create(filter_pattern);
337     return 0;
338 }
339
340 STRING
341 obj_get_filter_pattern( ABObj obj)
342 {
343     STRING              pattern = NULL;
344
345     verify_for_read(obj);
346     pattern = istr_string(obj->info.file_chooser.filter_pattern);
347     return (pattern);
348 }
349
350 int
351 obj_set_icon(ABObj obj, STRING icon)
352 {
353     verify_for_write(obj);
354     if (obj_is_window(obj) && !obj_is_file_chooser(obj))
355     {
356         istr_destroy(obj->info.window.icon);
357         obj->info.window.icon = istr_create(icon);
358         return 0;
359     }
360     member_error(obj, "icon");
361     return -1;
362 }
363
364 STRING
365 obj_get_icon(ABObj obj)
366 {
367     verify_for_read(obj);
368     if (obj_is_window(obj) && !obj_is_file_chooser(obj))
369         return istr_string(obj->info.window.icon);
370
371     return NULL;
372 }
373
374 int
375 obj_set_icon_label(ABObj obj, STRING icon_label)
376 {
377     verify_for_write(obj);
378     if (obj_is_window(obj) && !obj_is_file_chooser(obj))
379     {
380         istr_destroy(obj->info.window.icon_label);
381         obj->info.window.icon_label = istr_create(icon_label);
382         return 0;
383     }
384     member_error(obj, "icon_label");
385     return -1;
386 }
387
388 STRING
389 obj_get_icon_label(ABObj obj)
390 {
391     verify_for_read(obj);
392     if (obj_is_window(obj) && !obj_is_file_chooser(obj))
393         return istr_string(obj->info.window.icon_label);
394
395     return NULL;
396 }
397 int
398 obj_set_icon_mask(ABObj obj, STRING icon_mask)
399 {
400     verify_for_write(obj);
401     if (obj_is_window(obj) && !obj_is_file_chooser(obj))
402     {
403         istr_destroy(obj->info.window.icon_mask);
404         obj->info.window.icon_mask = istr_create(icon_mask);
405         return 0;
406     }   
407     member_error(obj, "icon_mask");
408     return -1;
409 }
410  
411 STRING
412 obj_get_icon_mask(ABObj obj)
413 {
414     verify_for_read(obj);
415     if (obj_is_window(obj) && !obj_is_file_chooser(obj))
416         return istr_string(obj->info.window.icon_mask);
417  
418     return NULL;
419 }
420
421 int
422 obj_set_initial_value_string(ABObj obj, STRING val)
423 {
424     verify_for_write(obj);
425     if (obj_is_text(obj))
426     {
427         istr_destroy(obj->info.text.initial_value_string);
428         obj->info.text.initial_value_string = istr_create(val);
429         return 0;
430     }
431     member_error(obj, "initial_value_string");
432     return -1;
433 }
434
435 STRING
436 obj_get_initial_value_string(ABObj obj)
437 {
438     verify_for_read(obj);
439     if (obj_is_text(obj))
440     {
441         return (istr_string(obj->info.text.initial_value_string));
442     }
443     return NULL;
444 }
445
446 /*
447  * REMIND: FIND AND CHANGE ALL BY-NAME REFERENCES TO THIS OBJECT!!!
448  *
449  * NOTE: don't verify at the top of the function - the indexes may be 
450  *       out-of-sync until we update them (i.e., the object is temporarily
451  *       invalid).
452  */
453 int
454 obj_set_name_istr(ABObj obj, ISTRING new_name)
455 {
456     ISTRING             old_name = NULL;
457     StringList          names = NULL;
458     ABObj               oldNameObj = NULL;
459
460     if (istr_equal(new_name, obj->name))
461     {
462         /* no change! */
463         return 0;
464     }
465     if ((names = objP_get_names_scope(obj)) != NULL)
466     {
467         oldNameObj = (ABObj)strlist_get_istr_data(names, new_name);
468         if (oldNameObj != NULL) 
469         {
470             if (oldNameObj == obj)
471             {
472                 strlist_remove_istr(names, new_name);
473             }
474             else
475             {
476                 /* it's not unique! */
477                 #ifdef DEBUG
478                     util_dprintf(1, "ERROR: duplicate name rejected: %s\n",
479                         istr_string_safe(new_name));
480                 #endif /* DEBUG */
481                 return ERR_DUPLICATE_KEY;
482             }
483         }
484     }
485
486     old_name = istr_dup(obj->name);
487     istr_destroy(obj->name);
488     obj->name = istr_dup(new_name);
489
490 #ifdef DEBUG
491     obj->debug_name = istr_string(obj->name);
492 #endif
493
494     /*
495      * Update the names list
496      */
497     if ((names = objP_get_names_scope(obj)) != NULL)
498     {
499         if (strlist_get_istr_data(names, old_name) == ((void*)obj))
500         {
501             /* this was probably called during a reparent, so the */
502             /* old_name is actuall from a different names list */
503             strlist_remove_istr(names, old_name);
504         }
505         strlist_add_istr(names, new_name, (void *)obj);
506     }
507
508     /*
509      * The indexes are up-to-date - verify everything
510      */
511     verify_for_write(obj);
512
513     objP_notify_send_name_change(obj, old_name);
514     istr_destroy(old_name);
515
516     return 0;
517 }
518
519
520 int
521 obj_set_name(ABObj obj, STRING strName)
522 {
523     int         return_value = 0;
524     ISTRING     name = istr_create(strName);
525     return_value = obj_set_name_istr(obj, name);
526     istr_destroy(name);
527     return return_value;
528 }
529
530
531 #ifndef obj_get_name
532 STRING
533 obj_get_name(ABObj obj)
534 {
535     verify_for_read(obj);
536     return istr_string(obj->name);
537 }
538 #endif /* !obj_get_name */
539
540 #ifndef obj_get_name_istr
541 ISTRING
542 obj_get_name_istr(ABObj obj)
543 {
544     verify_for_read(obj);
545     return obj->name;
546 }
547 #endif /* !obj_get_name_istr */
548
549
550 int
551 obj_set_num_columns(ABObj obj, int num_columns)
552 {
553     int old_num_cols;
554     int iRet = -1;
555
556     verify_for_write(obj);
557     switch (obj->type)
558     {
559     case AB_TYPE_CONTAINER:
560         old_num_cols = obj->info.container.num_columns;
561         obj->info.container.num_columns = num_columns;
562         iRet = 0;
563         break;
564     case AB_TYPE_CHOICE:
565         old_num_cols = obj->info.choice.num_columns;
566         obj->info.choice.num_columns = num_columns;
567         iRet = 0;
568         break;
569     case AB_TYPE_TERM_PANE:
570         old_num_cols = obj->info.term.num_columns; 
571         obj->info.term.num_columns = num_columns;
572         iRet = 0;
573     }
574     if (obj_is_text(obj))
575     {
576         old_num_cols = obj->info.text.num_columns; 
577         obj->info.text.num_columns = num_columns;
578         iRet = 0;
579     }
580     if (iRet == -1)
581         member_error(obj, "num_columns");
582
583     else if (old_num_cols != num_columns)
584         iRet= objP_notify_send_rc_geometry_change(obj);
585
586     return iRet;
587 }
588
589
590 int
591 obj_get_num_columns(ABObj obj)
592 {
593     verify_for_read(obj);
594     switch (obj->type)
595     {
596     case AB_TYPE_CONTAINER:
597         return obj->info.container.num_columns;
598
599     case AB_TYPE_CHOICE:
600         return obj->info.choice.num_columns;
601
602     case AB_TYPE_TERM_PANE:
603         return obj->info.term.num_columns;
604     }
605     if (obj_is_text(obj))
606     {
607         return obj->info.text.num_columns;
608     }
609     return 0;
610 }
611
612
613 int
614 obj_set_num_rows(ABObj obj, int num_rows)
615 {
616     int old_num_rows;
617     int iRet = -1;
618
619     verify_for_write(obj);
620     switch (obj->type)
621     {
622     case AB_TYPE_CONTAINER:
623         old_num_rows = obj->info.container.num_rows;
624         obj->info.container.num_rows = num_rows;
625         iRet = 0;
626         break;
627     case AB_TYPE_LIST:
628         old_num_rows = obj->info.list.num_rows;
629         obj->info.list.num_rows = num_rows;
630         iRet = 0;
631         break;
632     case AB_TYPE_TERM_PANE:
633         old_num_rows = obj->info.term.num_rows;
634         obj->info.term.num_rows = num_rows;
635         iRet = 0;
636         break;
637     }
638     if (obj_is_text(obj))
639     {
640         old_num_rows = obj->info.text.num_rows;
641         obj->info.text.num_rows = num_rows;
642         iRet = 0;
643     }
644     if (iRet == -1)
645         member_error(obj, "num_rows");
646
647     else if (old_num_rows != num_rows)
648         iRet= objP_notify_send_rc_geometry_change(obj);
649         
650     return iRet;
651 }
652
653
654 int
655 obj_get_num_rows(ABObj obj)
656 {
657     verify_for_read(obj);
658     switch (obj->type)
659     {
660     case AB_TYPE_CONTAINER:
661         return obj->info.container.num_rows;
662     case AB_TYPE_LIST:
663         return obj->info.list.num_rows;
664     case AB_TYPE_TERM_PANE:
665         return obj->info.term.num_rows;
666     }
667     if (obj_is_text(obj))
668     {
669         return obj->info.text.num_rows;
670     }
671     return 0;
672 }
673
674
675 int
676 obj_set_orientation(ABObj obj, AB_ORIENTATION orientation)
677 {
678     verify_for_write(obj);
679     switch (obj->type)
680     {
681     case AB_TYPE_SEPARATOR:
682         obj->info.separator.orientation = orientation;
683         return 0;
684     case AB_TYPE_SCALE:
685         obj->info.scale.orientation = orientation;
686         return 0;
687
688     case AB_TYPE_CHOICE:
689         obj->info.choice.orientation = orientation;
690         return 0;
691     }
692     member_error(obj, "orientation");
693     return -1;
694 }
695
696
697 AB_ORIENTATION
698 obj_get_orientation(ABObj obj)
699 {
700     verify_for_read(obj);
701     switch (obj->type)
702     {
703     case AB_TYPE_SEPARATOR:
704         return obj->info.separator.orientation;
705
706     case AB_TYPE_SCALE:
707         return obj->info.scale.orientation;
708
709     case AB_TYPE_CHOICE:
710         return obj->info.choice.orientation;
711     }
712     return AB_ORIENT_HORIZONTAL;
713 }
714
715 int
716 obj_set_label(ABObj obj, STRING label)
717 {
718     verify_for_write(obj);
719     istr_destroy(obj->label);
720     obj->label = istr_create(label);
721     return 0;
722 }
723
724 #ifndef obj_get_label
725 STRING
726 obj_get_label(ABObj obj)
727 {
728     verify_for_read(obj);
729     return istr_string(obj->label);
730 }
731 #endif                          /* !obj_get_label */
732
733 int
734 obj_set_label_type(ABObj obj, AB_LABEL_TYPE label_type)
735 {
736     verify_for_write(obj);
737     obj->label_type = label_type;
738     return 0;
739 }
740
741 #ifndef obj_get_label_type
742 AB_LABEL_TYPE
743 obj_get_label_type(ABObj obj)
744 {
745     verify_for_read(obj);
746     return obj->label_type;
747 }
748 #endif /* !obj_get_label_typ */
749
750 int
751 obj_set_label_alignment(ABObj obj, AB_ALIGNMENT type)
752 {
753     verify_for_write(obj);
754
755     switch (obj->type)
756     {
757     case AB_TYPE_BUTTON:
758         obj->info.button.label_alignment = type;
759         return 0;
760
761     case AB_TYPE_LABEL:
762         obj->info.label.label_alignment = type;
763         return 0;
764     }
765     member_error(obj, "label_alignment");
766     return -1;
767
768 }
769
770 AB_ALIGNMENT
771 obj_get_label_alignment(ABObj obj)
772 {
773     verify_for_read(obj);
774     switch (obj->type)
775     {
776     case AB_TYPE_BUTTON:
777         return (obj->info.button.label_alignment);
778
779     case AB_TYPE_LABEL:
780         return (obj->info.label.label_alignment);
781     }
782     return (AB_ALIGNMENT) - 1;
783
784 }
785
786 int
787 obj_set_label_position(ABObj obj, AB_COMPASS_POINT pos)
788 {
789     verify_for_write(obj);
790
791     switch (obj->type)
792     {
793     case AB_TYPE_TEXT_FIELD:
794         obj->info.text.label_position = pos;
795         return 0;
796     case AB_TYPE_CHOICE:
797         obj->info.choice.label_position = pos;
798         return 0;
799     case AB_TYPE_COMBO_BOX:
800         obj->info.combo_box.label_position = pos;
801         return 0;
802     case AB_TYPE_LIST:
803         obj->info.list.label_position = pos;
804         return 0;
805     case AB_TYPE_SCALE:
806         obj->info.scale.label_position = pos;
807         return 0;
808     case AB_TYPE_SPIN_BOX:
809         obj->info.spin_box.label_position = pos;
810         return 0;
811     }
812     member_error(obj, "label_position");
813     return -1;
814 }
815
816 AB_COMPASS_POINT
817 obj_get_label_position(ABObj obj)
818 {
819     verify_for_read(obj);
820
821     switch (obj->type)
822     {
823     case AB_TYPE_TEXT_PANE:
824     case AB_TYPE_TEXT_FIELD:
825         return (obj->info.text.label_position);
826
827     case AB_TYPE_CHOICE:
828         return (obj->info.choice.label_position);
829
830     case AB_TYPE_COMBO_BOX:
831         return (obj->info.combo_box.label_position);
832
833     case AB_TYPE_LIST:
834         return (obj->info.list.label_position);
835
836     case AB_TYPE_SCALE:
837         return (obj->info.scale.label_position);
838
839     case AB_TYPE_SPIN_BOX:
840         return (obj->info.spin_box.label_position);
841     }
842     return (AB_COMPASS_POINT) - 1;
843
844 }
845
846 STRING
847 obj_get_bg_color(ABObj obj)
848 {
849     verify_for_read(obj);
850     return istr_string(obj->bg_color);
851 }
852
853 STRING
854 obj_get_fg_color(ABObj obj)
855 {
856     verify_for_read(obj);
857     return istr_string(obj->fg_color);
858 }
859
860 int
861 obj_set_menu_name(ABObj obj, STRING menu_name)
862 {
863     verify_for_write(obj);
864
865     istr_destroy(obj->menu_name);
866     obj->menu_name = istr_create(menu_name);
867     return 0;
868 }
869
870 STRING
871 obj_get_menu_name(ABObj obj)
872 {
873     verify_for_read(obj);
874
875     return istr_string(obj->menu_name);
876
877 }
878
879 int
880 obj_set_menu_title(ABObj obj, STRING menu_title)
881 {
882     verify_for_write(obj);
883
884     switch(obj->type)
885     {
886         case AB_TYPE_CONTAINER:
887             istr_destroy(obj->info.container.menu_title);
888             obj->info.container.menu_title = istr_create(menu_title);
889             break;
890         case AB_TYPE_DRAWING_AREA:
891             istr_destroy(obj->info.drawing_area.menu_title);
892             obj->info.drawing_area.menu_title = istr_create(menu_title);
893             break;
894         case AB_TYPE_LIST:
895             istr_destroy(obj->info.list.menu_title);
896             obj->info.list.menu_title = istr_create(menu_title);
897             break;
898         case AB_TYPE_TEXT_FIELD:
899         case AB_TYPE_TEXT_PANE:
900             istr_destroy(obj->info.text.menu_title);
901             obj->info.text.menu_title = istr_create(menu_title);
902             break;
903         case AB_TYPE_TERM_PANE:
904             istr_destroy(obj->info.term.menu_title);
905             obj->info.term.menu_title = istr_create(menu_title);
906             break;
907         default:
908             return -1;
909     }
910     return 0;
911 }
912
913 STRING
914 obj_get_menu_title(ABObj obj)
915 {
916     verify_for_read(obj);
917
918     switch(obj->type)
919     {
920         case AB_TYPE_CONTAINER:
921             return(istr_string(obj->info.container.menu_title));
922         case AB_TYPE_DRAWING_AREA:
923             return(istr_string(obj->info.drawing_area.menu_title));
924         case AB_TYPE_LIST:
925             return(istr_string(obj->info.list.menu_title));
926         case AB_TYPE_TEXT_FIELD:
927         case AB_TYPE_TEXT_PANE:
928             return(istr_string(obj->info.text.menu_title));
929         case AB_TYPE_TERM_PANE:
930             return(istr_string(obj->info.term.menu_title));
931         default:
932             return NULL;
933     }
934 }
935
936 STRING
937 obj_get_mnemonic(ABObj obj)
938 {
939     verify_for_read(obj);
940     if (obj_is_item(obj) && (obj->info.item.mnemonic))
941     {
942         return (istr_string(obj->info.item.mnemonic));
943     }
944     return ((STRING) NULL);
945 }
946
947 int
948 obj_set_mnemonic(ABObj obj, STRING mnem)
949 {
950     verify_for_write(obj);
951     if (!obj_is_item(obj))
952     {
953         member_error(obj, "mnemonic");
954         return -1;
955     }   
956     istr_destroy(obj->info.item.mnemonic);
957     obj->info.item.mnemonic = istr_create(mnem);
958     return 0;
959 }
960
961 /*
962  * Make this object actually refer to another object
963  */
964 int
965 obj_cvt_to_ref(
966                  ABObj obj,
967                  ABObj ref_obj
968 )
969 {
970     if (obj == NULL)
971     {
972         return (ref_obj == NULL? 0:-1);         /* NULL can only ref NULL */
973     }
974     verify_for_write(obj);
975
976     /*
977      * The types must match!
978      */
979     if (ref_obj != NULL)
980     {
981         obj_set_type(obj, obj_get_type(ref_obj));
982     }
983     obj->ref_to= ref_obj;
984     return 0;
985 }
986
987 ABObj
988 obj_get_actual_obj(
989                  ABObj obj
990 )
991 {
992     if (obj == NULL)
993     {
994         return NULL;
995     }
996     verify_for_read(obj);
997
998     return (obj->ref_to == NULL? obj:obj->ref_to);
999 }
1000
1001 int
1002 obj_set_min_value(ABObj obj, int minval)
1003 {
1004     int                 iRet = 0;
1005     verify_for_write(obj);
1006
1007     switch (obj->type)
1008     {
1009     case AB_TYPE_SCALE:
1010         obj->info.scale.min_value = minval;
1011         break;
1012     case AB_TYPE_SPIN_BOX:
1013         obj->info.spin_box.min_value = minval;
1014         break;
1015
1016     default:
1017         iRet = -1;
1018         member_error(obj, "min_value");
1019         break;
1020     }
1021     return iRet;
1022 }
1023
1024
1025 int
1026 obj_get_min_value(ABObj obj)
1027 {
1028     int                 iValue = 0;
1029     verify_for_read(obj);
1030
1031     switch (obj->type)
1032     {
1033     case AB_TYPE_SCALE:
1034         iValue = obj->info.scale.min_value;
1035         break;
1036
1037     case AB_TYPE_SPIN_BOX:
1038         iValue = obj->info.spin_box.min_value;
1039         break;
1040
1041     default:
1042         iValue = -1;
1043         break;
1044     }
1045     return iValue;
1046 }
1047
1048 int
1049 obj_set_max_value(ABObj obj, int maxval)
1050 {
1051     int                 iRet = 0;
1052     verify_for_write(obj);
1053
1054     switch (obj->type)
1055     {
1056     case AB_TYPE_SCALE:
1057         obj->info.scale.max_value = maxval;
1058         break;
1059     case AB_TYPE_SPIN_BOX:
1060         obj->info.spin_box.max_value = maxval;
1061         break;
1062
1063     default:
1064         iRet = -1;
1065         member_error(obj, "max_value");
1066         break;
1067     }
1068     return iRet;
1069 }
1070
1071 int
1072 obj_get_max_value(ABObj obj)
1073 {
1074     int                 iValue = 0;
1075     verify_for_read(obj);
1076
1077     switch (obj->type)
1078     {
1079     case AB_TYPE_SCALE:
1080         iValue = obj->info.scale.max_value;
1081         break;
1082
1083     case AB_TYPE_SPIN_BOX:
1084         iValue = obj->info.spin_box.max_value;
1085         break;
1086
1087     default:
1088         iValue = -1;
1089         break;
1090     }
1091     return iValue;
1092 }
1093
1094 int
1095 obj_set_res_file_arg_classes(ABObj obj, AB_ARG_CLASS_FLAGS argClasses)
1096 {
1097     if (obj->type == AB_TYPE_PROJECT)
1098     {
1099         obj->info.project.res_file_arg_classes = argClasses;
1100         return 0;
1101     }
1102     return ERR_NOT_FOUND;
1103 }
1104
1105 AB_ARG_CLASS_FLAGS
1106 obj_get_res_file_arg_classes(ABObj obj)
1107 {
1108     if (obj->type == AB_TYPE_PROJECT)
1109     {
1110         return obj->info.project.res_file_arg_classes;
1111     }
1112     return AB_ARG_CLASS_FLAGS_NONE;
1113 }
1114
1115
1116 int
1117 obj_set_resizable(ABObj obj, BOOL resizable)
1118 {
1119     verify_for_write(obj);
1120     switch (obj->type)
1121     {
1122     case AB_TYPE_BASE_WINDOW:
1123     case AB_TYPE_DIALOG:
1124         obj->info.window.resizable = resizable;
1125         return 0;
1126     }
1127     member_error(obj, "resizeable");
1128     return -1;
1129 }
1130
1131
1132 BOOL
1133 obj_get_resizable(ABObj obj)
1134 {
1135     verify_for_read(obj);
1136     switch (obj->type)
1137     {
1138     case AB_TYPE_BASE_WINDOW:
1139     case AB_TYPE_DIALOG:
1140         return obj->info.window.resizable;
1141     }
1142     return TRUE;
1143 }
1144
1145 AB_SELECT_TYPE
1146 obj_get_selection_mode(ABObj obj)
1147 {
1148     verify_for_read(obj);
1149
1150     if (obj->type == AB_TYPE_LIST)
1151         return obj->info.list.selection_mode;
1152
1153     return AB_SELECT_UNDEF;
1154
1155 }
1156 int
1157 obj_set_selection_mode(ABObj obj, AB_SELECT_TYPE sel)
1158 {
1159     int iRet = 0;
1160     verify_for_write(obj);
1161
1162     if (obj->type == AB_TYPE_LIST)
1163         obj->info.list.selection_mode = sel;
1164
1165     return iRet;
1166 }
1167
1168
1169 int
1170 obj_set_selection_required(ABObj obj, BOOL selreq)
1171 {
1172     int                 iRet = 0;
1173     verify_for_write(obj);
1174
1175     switch (obj->type)
1176     {
1177     case AB_TYPE_LIST:
1178         obj->info.list.selection_required = selreq;
1179         break;
1180
1181     case AB_TYPE_CHOICE:
1182         obj->info.choice.selection_required = selreq;
1183         break;
1184
1185     default:
1186         iRet = -1;
1187         member_error(obj, "selection_required");
1188         break;
1189     }
1190     return iRet;
1191 }
1192
1193 BOOL
1194 obj_get_selection_required(ABObj obj)
1195 {
1196     BOOL                bRet = FALSE;
1197     verify_for_read(obj);
1198
1199     switch (obj->type)
1200     {
1201     case AB_TYPE_CHOICE:
1202         bRet = obj->info.choice.selection_required;
1203         break;
1204     case AB_TYPE_LIST:
1205         bRet = obj->info.list.selection_required;
1206         break;
1207     }
1208     return bRet;
1209 }
1210
1211
1212 int
1213 obj_set_type(ABObj obj, AB_OBJECT_TYPE new_type)
1214 {
1215     verify_for_write(obj);
1216
1217     if (obj_get_type(obj) != new_type)
1218     {
1219         /* only clear out the data if the type has changed */
1220         obj_destruct_type_specific_info(obj);
1221         obj->type = new_type;
1222         obj_construct_type_specific_info(obj);
1223     }
1224     return 0;
1225 }
1226
1227 int
1228 obj_set_subtype(ABObj obj, int subtype)
1229 {
1230     verify_for_write(obj);
1231
1232     if (obj_is_choice(obj))
1233         obj->info.choice.type = (AB_CHOICE_TYPE) subtype;
1234
1235     else if (obj_is_message(obj)) 
1236         obj->info.message.type = (AB_MESSAGE_TYPE)subtype;
1237
1238     else if (obj_is_container(obj))
1239         obj->info.container.type = (AB_CONTAINER_TYPE) subtype;
1240
1241     else if (obj_is_item(obj))
1242         obj->info.item.type = (AB_ITEM_TYPE) subtype;
1243
1244     else if (obj_is_button(obj))
1245         obj->info.button.type = (AB_BUTTON_TYPE) subtype;
1246
1247     else if (obj_is_menu(obj))
1248         obj->info.menu.type = (AB_MENU_TYPE) subtype;
1249
1250     /*
1251      * else if (obj_is_dialog(obj)) obj->info.dialog.type =
1252      * (AB_DIALOG_TYPE)subtype;
1253      */
1254
1255     return 0;
1256
1257 }
1258
1259
1260
1261 #ifndef obj_get_type
1262 AB_OBJECT_TYPE
1263 obj_get_type(ABObj obj)
1264 {
1265     verify_for_read(obj);
1266     return obj->type;
1267 }
1268
1269 #endif                          /* !obj_get_type */
1270
1271 int
1272 obj_get_subtype(ABObj obj)
1273 {
1274     verify_for_read(obj);
1275
1276     if (obj_is_choice(obj))
1277         return ((int) obj->info.choice.type);
1278
1279     else if (obj_is_message(obj)) 
1280         return((int)obj->info.message.type);
1281
1282     else if (obj_is_button(obj))
1283         return ((int) obj->info.button.type);
1284
1285     else if (obj_is_container(obj))
1286         return ((int) obj->info.container.type);
1287
1288     else if (obj_is_item(obj))
1289         return ((int) obj->info.item.type);
1290
1291     else if (obj_is_menu(obj))
1292         return ((int) obj->info.menu.type);
1293
1294     return (AB_NO_SUBTYPE);
1295
1296 }
1297
1298 STRING
1299 obj_get_process_string(
1300                        ABObj obj
1301 )
1302 {
1303     verify_for_read(obj);
1304     if (obj->type == AB_TYPE_TERM_PANE)
1305         return (istr_string(obj->info.term.process_string));
1306
1307     return NULL;
1308
1309 }
1310
1311 int
1312 obj_set_process_string(
1313                        ABObj obj,
1314                        STRING subproc
1315 )
1316 {
1317     verify_for_write(obj);
1318     if (obj->type == AB_TYPE_TERM_PANE)
1319     {
1320         istr_destroy(obj->info.term.process_string);
1321         obj->info.term.process_string = istr_create(subproc);
1322     }
1323     return 0;
1324 }
1325
1326 int
1327 obj_set_was_written(ABObj obj, BOOL was_written)
1328 {
1329     verify_for_write(obj);
1330     if (was_written)
1331         obj_set_impl_flags(obj, ObjFlagWasWritten);
1332     else
1333         obj_clear_impl_flags(obj, ObjFlagWasWritten);
1334     return 0;
1335 }
1336
1337 BOOL
1338 obj_was_written(ABObj obj)
1339 {
1340     verify_for_read(obj);
1341     return obj_has_impl_flags(obj, ObjFlagWasWritten);
1342 }
1343
1344 int
1345 obj_set_win_parent(
1346     ABObj obj,
1347     ABObj wparent
1348 )
1349 {
1350     AB_OBJECT_TYPE      type = AB_TYPE_UNDEF;
1351
1352     if (!obj_is_window(obj))
1353         return -1;
1354
1355     verify_for_write(obj);
1356     type = obj_get_type(obj);
1357     switch (type)
1358     {
1359         case AB_TYPE_BASE_WINDOW:
1360         case AB_TYPE_DIALOG:
1361             obj->info.window.win_parent = wparent;
1362             break;
1363         case AB_TYPE_FILE_CHOOSER:
1364             obj->info.file_chooser.win_parent = wparent;
1365             break;
1366         default:
1367             break;
1368     }
1369
1370     return 0;
1371 }
1372
1373 ABObj
1374 obj_get_win_parent(
1375     ABObj obj
1376 )
1377 {
1378     ABObj               wparent = NULL;
1379     AB_OBJECT_TYPE      type = AB_TYPE_UNDEF; 
1380  
1381     if (!obj_is_window(obj))
1382         return NULL;
1383
1384     verify_for_read(obj);
1385     type = obj_get_type(obj);
1386     switch (type) 
1387     { 
1388         case AB_TYPE_BASE_WINDOW:
1389         case AB_TYPE_DIALOG:
1390             wparent = obj->info.window.win_parent;
1391             break;
1392         case AB_TYPE_FILE_CHOOSER: 
1393             wparent = obj->info.file_chooser.win_parent;
1394             break;
1395         default: 
1396             break; 
1397     }    
1398
1399     return (wparent);
1400 }
1401
1402 int
1403 obj_set_write_me(ABObj obj, BOOL write_me)
1404 {
1405     verify_for_write(obj);
1406     if (write_me)
1407     {
1408         obj_set_impl_flags(obj, ObjFlagWriteMe);
1409     }
1410     else
1411     {
1412         obj_clear_impl_flags(obj, ObjFlagWriteMe);
1413     }
1414     return 0;
1415 }
1416
1417 BOOL
1418 obj_get_write_me(ABObj obj)
1419 {
1420     verify_for_read(obj);
1421     return obj_has_impl_flags(obj, ObjFlagWriteMe);
1422 }
1423
1424 int
1425 obj_set_value_x(ABObj obj, int valx)
1426 {
1427     int                 iRet = 0;
1428     verify_for_write(obj);
1429
1430     switch (obj->type)
1431     {
1432     case AB_TYPE_CHOICE:
1433         obj->info.choice.value_x = valx;
1434         break;
1435
1436     default:
1437         iRet = -1;
1438         member_error(obj, "value_x");
1439         break;
1440     }
1441     return iRet;
1442 }
1443
1444
1445 int
1446 obj_get_value_x(ABObj obj)
1447 {
1448     int                 iRet = 0;
1449     verify_for_read(obj);
1450
1451     switch (obj->type)
1452     {
1453     case AB_TYPE_CHOICE:
1454         iRet = obj->info.choice.value_x;
1455         break;
1456     default:
1457         iRet = -1;
1458         break;
1459     }
1460     return iRet;
1461 }
1462
1463
1464 int
1465 obj_set_value_y(ABObj obj, int valy)
1466 {
1467     int                 iRet = 0;
1468     verify_for_write(obj);
1469
1470     switch (obj->type)
1471     {
1472     case AB_TYPE_CHOICE:
1473         obj->info.choice.value_y = valy;
1474         break;
1475
1476     default:
1477         iRet = -1;
1478         member_error(obj, "value_y");
1479         break;
1480     }
1481     return iRet;
1482 }
1483
1484
1485 int
1486 obj_get_value_y(ABObj obj)
1487 {
1488     int                 iRet = 0;
1489     verify_for_read(obj);
1490
1491     switch (obj->type)
1492     {
1493     case AB_TYPE_CHOICE:
1494         iRet = obj->info.choice.value_y;
1495         break;
1496     default:
1497         iRet = -1;
1498         break;
1499     }
1500     return iRet;
1501 }
1502
1503 int
1504 obj_set_vscrollbar_policy(ABObj obj, AB_SCROLLBAR_POLICY vscrollbar)
1505 {
1506     verify_for_write(obj);
1507     switch (obj->type)
1508     {
1509     case AB_TYPE_DRAWING_AREA:
1510         obj->info.drawing_area.vscrollbar = vscrollbar;
1511         break;
1512     case AB_TYPE_TEXT_PANE:
1513         obj->info.text.vscrollbar = vscrollbar;
1514         break;
1515     case AB_TYPE_TERM_PANE:
1516         obj->info.term.vscrollbar = vscrollbar;
1517         break;
1518     }
1519
1520     return 0;
1521 }
1522
1523 int
1524 obj_set_tearoff(ABObj obj, BOOL tearoff)
1525 {
1526     verify_for_write(obj);
1527     switch (obj->type)
1528     {
1529     case AB_TYPE_MENU:
1530         obj->info.menu.tear_off = tearoff;
1531         return 0;
1532     }
1533     member_error(obj, "tear_off");
1534     return -1;
1535 }
1536
1537 int
1538 obj_set_vendor(ABObj obj, STRING vendor)
1539 {
1540     verify_for_write(obj);
1541     if (!obj_is_project(obj))
1542     {
1543         member_error(obj, "vendor");
1544         return -1;
1545     }
1546     istr_destroy(obj->info.project.vendor);
1547     obj->info.project.vendor = istr_create(vendor);
1548     return 0;
1549 }
1550
1551 STRING
1552 obj_get_vendor(ABObj obj)
1553 {
1554     verify_for_read(obj);
1555     if (!obj_is_project(obj))
1556     {
1557         member_error(obj, "vendor");
1558         return NULL;
1559     }
1560     return (istr_string(obj->info.project.vendor));
1561 }
1562
1563 int
1564 obj_set_version(ABObj obj, STRING version)
1565 {
1566     verify_for_write(obj);
1567     if (!obj_is_project(obj))
1568     {
1569         member_error(obj, "version");
1570         return -1;
1571     }
1572     istr_destroy(obj->info.project.version);
1573     obj->info.project.version = istr_create(version);
1574     return 0;
1575 }
1576
1577 STRING 
1578 obj_get_version(ABObj obj) 
1579
1580     verify_for_read(obj); 
1581     if (!obj_is_project(obj)) 
1582     { 
1583         member_error(obj, "version");
1584         return NULL;
1585     }
1586     return (istr_string(obj->info.project.version));
1587
1588
1589
1590 int
1591 obj_set_root_window(ABObj obj, ABObj root_window)
1592 {
1593     verify_for_write(obj);
1594     if (!obj_is_project(obj))
1595     {
1596         member_error(obj, "root_window");
1597         return -1;
1598     }
1599     obj->info.project.root_window = root_window;
1600     return 0;
1601 }
1602
1603
1604 ABObj
1605 obj_get_root_window(ABObj obj)
1606 {
1607     verify_for_read(obj);
1608     if (!obj_is_project(obj))
1609     {
1610         member_error(obj, "root_window");
1611         return NULL;
1612     }
1613     return (obj->info.project.root_window);
1614 }
1615
1616 int
1617 obj_set_height_is_resizable(ABObj obj, BOOL resizable)
1618 {
1619     verify_for_write(obj);
1620     if (resizable)
1621         obj_set_impl_flags(obj, ObjFlagHeightIsResizable);
1622     else
1623         obj_clear_impl_flags(obj, ObjFlagHeightIsResizable);
1624     return 0;
1625 }
1626
1627 BOOL
1628 obj_get_height_is_resizable(ABObj obj)
1629 {
1630     verify_for_read(obj);
1631     return obj_has_impl_flags(obj, ObjFlagHeightIsResizable);
1632 }
1633
1634 int
1635 obj_set_hoffset(ABObj obj, int hoffset)
1636 {
1637     verify_for_write(obj);
1638     if (obj_is_container(obj))
1639     {
1640         return (obj->info.container.hoffset = hoffset);
1641     }
1642     return ERR_BAD_PARAM1;
1643 }
1644
1645 int
1646 obj_get_hoffset(ABObj obj)
1647 {
1648     verify_for_read(obj);
1649     if (obj_is_container(obj))
1650     {
1651         return (obj->info.container.hoffset);
1652     }
1653     return ERR_BAD_PARAM1;
1654 }
1655
1656 int
1657 obj_set_voffset(ABObj obj, int voffset)
1658 {
1659     verify_for_write(obj);
1660     if (obj_is_container(obj))
1661     {
1662         return (obj->info.container.voffset = voffset);
1663     }
1664     return ERR_BAD_PARAM1;
1665 }
1666
1667 int
1668 obj_get_voffset(ABObj obj)
1669 {
1670     verify_for_read(obj);
1671     if (obj_is_container(obj))
1672     {
1673         return (obj->info.container.voffset);
1674     }
1675     else
1676     {
1677
1678         /*
1679          * REMIND: Not sure what to return when an ABObj is not a container
1680          * type.
1681          */
1682         return (0);
1683     }
1684 }
1685
1686 int
1687 obj_set_hspacing(ABObj obj, int hspacing)
1688 {
1689     verify_for_write(obj);
1690     if (obj_is_container(obj))
1691     {
1692         return (obj->info.container.hspacing = hspacing);
1693     }
1694     return ERR_BAD_PARAM1;
1695 }
1696
1697 int
1698 obj_get_hspacing(ABObj obj)
1699 {
1700     verify_for_read(obj);
1701     if (obj_is_container(obj))
1702     {
1703         return (obj->info.container.hspacing);
1704     }
1705     else
1706     {
1707
1708         /*
1709          * REMIND: Not sure what to return when an ABObj is not a container
1710          * type.
1711          */
1712         return (0);
1713     }
1714 }
1715
1716 int
1717 obj_set_vspacing(ABObj obj, int vspacing)
1718 {
1719     verify_for_write(obj);
1720     if (obj_is_container(obj))
1721     {
1722         return (obj->info.container.vspacing = vspacing);
1723     }
1724     return ERR_BAD_PARAM1;
1725 }
1726
1727 int
1728 obj_get_vspacing(ABObj obj)
1729 {
1730     verify_for_read(obj);
1731     if (obj_is_container(obj))
1732     {
1733         return (obj->info.container.vspacing);
1734     }
1735     else
1736     {
1737
1738         /*
1739          * REMIND: Not sure what to return when an ABObj is not a container
1740          * type.
1741          */
1742         return (0);
1743     }
1744 }
1745
1746 int
1747 obj_set_ref_point(ABObj obj, AB_COMPASS_POINT ref_point)
1748 {
1749     verify_for_write(obj);
1750     if (obj_is_container(obj))
1751     {
1752         return (obj->info.container.ref_point = ref_point);
1753     }
1754     return ERR_BAD_PARAM1;
1755 }
1756
1757 AB_COMPASS_POINT
1758 obj_get_ref_point(ABObj obj)
1759 {
1760     verify_for_read(obj);
1761     if (obj_is_container(obj))
1762     {
1763         return obj->info.container.ref_point;
1764     }
1765     else
1766     {
1767
1768         /*
1769          * REMIND: Not sure if I should use obj_get_label_position() or if I
1770          * should do my own switch statement.
1771          */
1772
1773         return (obj_get_label_position(obj));
1774     }
1775 }
1776
1777 int
1778 obj_set_hattach_type(ABObj obj, AB_ATTACH_TYPE hattach_type)
1779 {
1780     verify_for_write(obj);
1781     if (obj_is_container(obj))
1782     {
1783         return (obj->info.container.hattach_type = hattach_type);
1784     }
1785     return ERR_BAD_PARAM1;
1786 }
1787
1788 AB_ATTACH_TYPE
1789 obj_get_hattach_type(ABObj obj)
1790 {
1791     AB_ATTACH_TYPE      attach_type = AB_ATTACH_UNDEF;
1792     verify_for_read(obj);
1793
1794     if (obj_is_container(obj))
1795     {
1796         attach_type = (obj->info.container.hattach_type);
1797     }
1798
1799     return attach_type;
1800 }
1801
1802 int
1803 obj_set_vattach_type(ABObj obj, AB_ATTACH_TYPE vattach_type)
1804 {
1805     verify_for_write(obj);
1806     if (obj_is_container(obj))
1807     {
1808         return (obj->info.container.vattach_type = vattach_type);
1809     }
1810     return ERR_BAD_PARAM1;
1811 }
1812
1813 AB_ATTACH_TYPE
1814 obj_get_vattach_type(ABObj obj)
1815 {
1816     AB_ATTACH_TYPE      attach_type = AB_ATTACH_UNDEF;
1817     verify_for_read(obj);
1818
1819     if (obj_is_container(obj))
1820     {
1821         attach_type = (obj->info.container.vattach_type);
1822     }
1823
1824     return attach_type;
1825 }
1826
1827 AB_BUTTON_TYPE
1828 obj_get_button_type(ABObj obj)
1829 {
1830     verify_for_read(obj);
1831     if (obj_is_button(obj))
1832     {
1833         return (obj->info.button.type);
1834     }
1835     return (AB_BUT_UNDEF);
1836 }
1837
1838 int
1839 obj_set_item_type(ABObj obj, AB_ITEM_TYPE item_type)
1840 {
1841     verify_for_write(obj);
1842     if (obj_is_item(obj))
1843     {
1844         return (obj->info.item.type = item_type);
1845     }
1846     return ERR_BAD_PARAM1;
1847 }
1848
1849
1850 AB_ITEM_TYPE
1851 obj_get_item_type(ABObj obj)
1852 {
1853     verify_for_read(obj);
1854     if (obj_is_item(obj))
1855     {
1856         return (obj->info.item.type);
1857     }
1858     return (AB_ITEM_FOR_UNDEF);
1859 }
1860
1861 int
1862 obj_set_group_type(ABObj obj, AB_GROUP_TYPE group_type)
1863 {
1864     verify_for_write(obj);
1865     if (obj_is_container(obj))
1866     {
1867         return (obj->info.container.group_type = group_type);
1868     }
1869     return ERR_BAD_PARAM1;
1870 }
1871
1872 AB_GROUP_TYPE
1873 obj_get_group_type(ABObj obj)
1874 {
1875     verify_for_read(obj);
1876     if ((obj != NULL) && obj_is_container(obj))
1877     {
1878         return (obj->info.container.group_type);
1879     }
1880     return (AB_GROUP_UNDEF);
1881 }
1882
1883
1884 int
1885 obj_set_row_align(ABObj obj, AB_ALIGNMENT row_align)
1886 {
1887     verify_for_write(obj);
1888     if (obj_is_container(obj))
1889     {
1890         return (obj->info.container.row_align = row_align);
1891     }
1892     return ERR_BAD_PARAM1;
1893 }
1894
1895 AB_ALIGNMENT
1896 obj_get_row_align(ABObj obj)
1897 {
1898     verify_for_read(obj);
1899     if (obj_is_container(obj))
1900     {
1901         return (obj->info.container.row_align);
1902     }
1903     return (AB_ALIGN_UNDEF);
1904 }
1905
1906 int
1907 obj_set_class_name(ABObj obj, STRING cname)
1908 {
1909     verify_for_write(obj);
1910     istr_destroy(obj->class_name);
1911     obj->class_name = istr_create(cname);
1912     return 0;
1913 }
1914
1915 STRING
1916 obj_get_class_name(ABObj obj)
1917 {
1918     verify_for_read(obj);
1919     return istr_string(obj->class_name);
1920 }
1921
1922 int
1923 obj_set_col_align(ABObj obj, AB_ALIGNMENT col_align)
1924 {
1925     verify_for_write(obj);
1926     if (obj_is_container(obj))
1927     {
1928         return (obj->info.container.col_align = col_align);
1929     }
1930     return ERR_BAD_PARAM1;
1931 }
1932
1933 AB_ALIGNMENT
1934 obj_get_col_align(ABObj obj)
1935 {
1936     verify_for_read(obj);
1937     if (obj_is_container(obj))
1938     {
1939         return (obj->info.container.col_align);
1940     }
1941     return (AB_ALIGN_UNDEF);
1942 }
1943
1944 int
1945 obj_set_container_type(ABObj obj, AB_CONTAINER_TYPE cont_type)
1946 {
1947     verify_for_write(obj);
1948     if (obj_is_container(obj))
1949     {
1950         return (obj->info.container.type = cont_type);
1951     }
1952     return ERR_BAD_PARAM1;
1953 }
1954
1955 AB_CONTAINER_TYPE
1956 obj_get_container_type(ABObj obj)
1957 {
1958     verify_for_read(obj);
1959     if (obj_is_container(obj))
1960     {
1961         return obj->info.container.type;
1962     }
1963     return AB_CONT_UNDEF;
1964 }
1965
1966 int
1967 obj_get_decimal_points(ABObj obj)
1968 {
1969     verify_for_read(obj);
1970     if (obj_is_spin_box(obj))
1971         return(obj->info.spin_box.decimal_points);
1972     else if (obj_is_scale(obj))
1973         return(obj->info.scale.decimal_points);
1974
1975     return -1;
1976 }
1977
1978 int
1979 obj_set_decimal_points(ABObj obj, int dec_points)
1980 {
1981     verify_for_write(obj);
1982     if (obj_is_spin_box(obj))
1983     {
1984         obj->info.spin_box.decimal_points = dec_points;
1985         return 0;
1986     }
1987     else if (obj_is_scale(obj))
1988     {
1989         obj->info.scale.decimal_points = dec_points;
1990         return 0;
1991     }
1992     member_error(obj, "decimal_points");
1993     return -1;
1994 }
1995
1996 int
1997 obj_set_default_act_button(
1998     ABObj obj,
1999     ABObj defaultb 
2000 )
2001 {
2002     if (!obj_is_window(obj))
2003         return -1;
2004
2005     verify_for_write(obj);
2006
2007     obj->info.window.default_act_button= defaultb;
2008
2009     return 0;
2010 }
2011
2012 ABObj
2013 obj_get_default_act_button(
2014     ABObj obj
2015 )
2016 {
2017     ABObj               defaultb = NULL;
2018  
2019     if (!obj_is_window(obj))
2020         return NULL;
2021  
2022     verify_for_read(obj);
2023
2024     return(obj->info.window.default_act_button);
2025 }
2026
2027 AB_DIRECTION
2028 obj_get_direction(ABObj obj)
2029 {
2030     verify_for_read(obj);
2031     if (obj_is_scale(obj))
2032         return(obj->info.scale.direction);
2033
2034     return AB_DIR_UNDEF;
2035 }
2036
2037 int
2038 obj_set_direction(ABObj obj, AB_DIRECTION dir)
2039 {
2040     verify_for_write(obj);
2041     if (obj_is_scale(obj))
2042     {
2043         obj->info.scale.direction= dir;
2044         return 0;
2045     }   
2046     member_error(obj, "direction");
2047     return -1;
2048 }
2049
2050 int
2051 obj_set_drawarea_width(
2052                        ABObj obj,
2053                        int width
2054 )
2055 {
2056     verify_for_write(obj);
2057     if (obj_is_drawing_area(obj))
2058     {
2059         obj->info.drawing_area.drawarea_width = width;
2060         return 0;
2061     }
2062     member_error(obj, "drawarea_width");
2063     return -1;
2064 }
2065
2066 int
2067 obj_set_drawarea_height(
2068                         ABObj obj,
2069                         int height
2070 )
2071 {
2072     verify_for_write(obj);
2073     if (obj_is_drawing_area(obj))
2074     {
2075         obj->info.drawing_area.drawarea_height = height;
2076         return 0;
2077     }
2078     member_error(obj, "drawarea_height");
2079     return -1;
2080 }
2081
2082 int
2083 obj_get_drawarea_width(
2084                        ABObj obj
2085 )
2086 {
2087     verify_for_read(obj);
2088     if (obj_is_drawing_area(obj))
2089         return (obj->info.drawing_area.drawarea_width);
2090
2091     return -1;
2092 }
2093
2094 int
2095 obj_get_drawarea_height(
2096                         ABObj obj
2097 )
2098 {
2099     verify_for_read(obj);
2100     if (obj_is_drawing_area(obj))
2101         return (obj->info.drawing_area.drawarea_height);
2102
2103     return -1;
2104 }
2105
2106 int
2107 obj_set_textpane_width(ABObj obj,
2108                        int width)
2109 {
2110     if (obj_is_text_pane(obj))
2111     {
2112         obj->info.text.textpane_width = width;
2113         return 0;
2114     }
2115
2116     return -1;
2117 }
2118
2119 int
2120 obj_set_textpane_height(ABObj obj,
2121                         int height)
2122 {
2123     if (obj_is_text_pane(obj))
2124     {
2125         obj->info.text.textpane_height = height;
2126         return 0;
2127     }
2128
2129     return -1;
2130 }
2131
2132 int
2133 obj_get_textpane_width(ABObj obj)
2134 {
2135     if (obj_is_text_pane(obj))
2136         return (obj->info.text.textpane_width);
2137     else
2138         return -1;
2139 }
2140
2141 int
2142 obj_get_textpane_height(ABObj obj)
2143 {
2144     if (obj_is_text_pane(obj))
2145         return (obj->info.text.textpane_height);
2146     else
2147         return -1;
2148 }
2149
2150
2151 AB_SCROLLBAR_POLICY
2152 obj_get_hscrollbar_policy(ABObj obj)
2153 {
2154     verify_for_read(obj);
2155     switch (obj->type)
2156     {
2157     case AB_TYPE_LIST:
2158         return (obj->info.list.hscrollbar);
2159     case AB_TYPE_DRAWING_AREA:
2160         return (obj->info.drawing_area.hscrollbar);
2161     case AB_TYPE_TEXT_PANE:
2162         return (obj->info.text.hscrollbar);
2163     }
2164     return AB_SCROLLBAR_UNDEF;
2165 }
2166
2167 AB_SCROLLBAR_POLICY
2168 obj_get_vscrollbar_policy(ABObj obj)
2169 {
2170     verify_for_read(obj);
2171     switch (obj->type)
2172     {
2173     case AB_TYPE_LIST:
2174         return (obj->info.list.vscrollbar);
2175     case AB_TYPE_DRAWING_AREA:
2176         return (obj->info.drawing_area.vscrollbar);
2177     case AB_TYPE_TEXT_PANE:
2178         return (obj->info.text.vscrollbar);
2179     case AB_TYPE_TERM_PANE:
2180         return (obj->info.term.vscrollbar);
2181     }
2182     return AB_SCROLLBAR_UNDEF;
2183 }
2184
2185 STRING
2186 obj_get_accelerator(ABObj obj)
2187 {
2188     verify_for_read(obj);
2189     if (obj_is_item(obj) && (obj->info.item.accelerator))
2190     {
2191         return (istr_string(obj->info.item.accelerator));
2192     }
2193     return ((STRING) NULL);
2194 }
2195
2196 int
2197 obj_get_max_length(ABObj obj)
2198 {
2199     verify_for_read(obj);
2200     if (obj_is_text(obj))
2201     {
2202         return (obj->info.text.max_length);
2203     }
2204     return (0);
2205 }
2206
2207 int
2208 obj_set_max_length(ABObj obj, int max_len)
2209 {
2210     verify_for_write(obj);
2211     if (obj_is_text(obj))
2212     {
2213         obj->info.text.max_length = max_len;
2214         return 0;
2215     }
2216     member_error(obj, "max_length");
2217     return -1;
2218
2219 }
2220
2221 int
2222 obj_set_initial_value_int(ABObj obj, int ival)
2223 {
2224     verify_for_write(obj);
2225     switch (obj->type)
2226     {
2227     case AB_TYPE_SCALE:
2228         obj->info.scale.initial_value = ival;
2229         break;
2230     case AB_TYPE_SPIN_BOX:
2231         obj->info.spin_box.initial_value = ival;
2232         break;
2233     case AB_TYPE_TEXT_FIELD:
2234     case AB_TYPE_TEXT_PANE:
2235         obj->info.text.initial_value_int = ival;
2236         break;
2237     }
2238     return (0);
2239 }
2240
2241 int
2242 obj_get_initial_value_int(ABObj obj)
2243 {
2244     verify_for_read(obj);
2245     switch (obj->type)
2246     {
2247     case AB_TYPE_SCALE:
2248         return (obj->info.scale.initial_value);
2249     case AB_TYPE_SPIN_BOX:
2250         return (obj->info.spin_box.initial_value);
2251     case AB_TYPE_TEXT_FIELD:
2252     case AB_TYPE_TEXT_PANE:
2253         return (obj->info.text.initial_value_int);
2254     }
2255     return (0);
2256 }
2257
2258 AB_TEXT_TYPE
2259 obj_get_text_type(ABObj obj)
2260 {
2261     verify_for_read(obj);
2262
2263     if (obj_is_text(obj))
2264         return (obj->info.text.type);
2265
2266     if (obj_is_spin_box(obj))
2267         return (obj->info.spin_box.type);
2268
2269     return (AB_TEXT_UNDEF);
2270 }
2271 int
2272 obj_set_text_type(ABObj obj, AB_TEXT_TYPE type)
2273 {
2274     verify_for_write(obj);
2275
2276     if (obj_is_text(obj))
2277         obj->info.text.type = type;
2278
2279     else if (obj_is_spin_box(obj))
2280         obj->info.spin_box.type = type;
2281
2282     else
2283     {
2284         member_error(obj, "text_type");
2285         return ERR;
2286     }
2287     return 0; 
2288 }
2289
2290 AB_MENU_TYPE
2291 obj_get_menu_type(ABObj obj)
2292 {
2293     verify_for_read(obj);
2294     if (obj_is_menu(obj))
2295     {
2296         return (obj->info.menu.type);
2297     }
2298     return (AB_MENU_UNDEF);
2299 }
2300
2301 AB_PACKING
2302 obj_get_packing(ABObj obj)
2303 {
2304     verify_for_read(obj);
2305     if (obj_is_container(obj))
2306     {
2307         return (obj->info.container.packing);
2308     }
2309     return (AB_PACK_UNDEF);
2310 }
2311
2312 AB_CHOICE_TYPE
2313 obj_get_choice_type(ABObj obj)
2314 {
2315     verify_for_read(obj);
2316     if (obj_is_choice(obj))
2317     {
2318         return (obj->info.choice.type);
2319     }
2320     return (AB_CHOICE_UNDEF);
2321 }
2322
2323 int
2324 obj_set_is_initially_active(ABObj obj, BOOL active)
2325 {
2326     verify_for_write(obj);
2327     if (active)
2328         obj_set_impl_flags(obj, ObjFlagIsInitiallyActive);
2329     else
2330         obj_clear_impl_flags(obj, ObjFlagIsInitiallyActive);
2331     return 0;
2332 }
2333
2334 BOOL
2335 obj_is_initially_active(ABObj obj)
2336 {
2337     verify_for_read(obj);
2338     return obj_has_impl_flags(obj, ObjFlagIsInitiallyActive);
2339 }
2340
2341 int
2342 obj_set_is_initially_iconic(ABObj obj, BOOL iconic)
2343 {
2344     int                 return_value = 0;
2345     verify_for_write(obj);
2346
2347     if (obj_is_window(obj) && !obj_is_file_chooser(obj))
2348     {
2349         obj->info.window.is_initially_iconic = iconic;
2350     }
2351     else
2352     {
2353         member_error(obj, "is_initially_iconic");
2354         return_value = ERR;
2355     }
2356     return return_value;
2357 }
2358
2359 BOOL
2360 obj_is_initially_iconic(ABObj obj)
2361 {
2362     verify_for_read(obj);
2363     if (obj_is_window(obj) && !obj_is_file_chooser(obj))
2364     {
2365         return (obj->info.window.is_initially_iconic);
2366     }
2367     return FALSE;
2368 }
2369
2370 int
2371 obj_set_is_initially_selected(ABObj obj, BOOL selected)
2372 {
2373     int                 return_value = 0;
2374     verify_for_write(obj);
2375
2376     if (obj_is_item(obj))
2377     {
2378         obj->info.item.is_initially_selected = selected;
2379     }
2380     else
2381     {
2382         member_error(obj, "is_initially_selected");
2383         return_value = ERR;
2384     }
2385     return return_value;
2386 }
2387
2388 BOOL
2389 obj_is_initially_selected(ABObj obj)
2390 {
2391     verify_for_read(obj);
2392     if (obj_is_item(obj))
2393     {
2394         return (obj->info.item.is_initially_selected);
2395     }
2396     return FALSE;
2397 }
2398
2399 int
2400 obj_set_is_initially_visible(ABObj obj, BOOL visible)
2401 {
2402     verify_for_write(obj);
2403     if (visible)
2404         obj_set_impl_flags(obj, ObjFlagIsInitiallyVisible);
2405     else
2406         obj_clear_impl_flags(obj, ObjFlagIsInitiallyVisible);
2407     return 0;
2408 }
2409
2410 BOOL
2411 obj_is_initially_visible(ABObj obj)
2412 {
2413     verify_for_read(obj);
2414     return obj_has_impl_flags(obj, ObjFlagIsInitiallyVisible);
2415 }
2416
2417 BOOL
2418 obj_get_tearoff(ABObj obj)
2419 {
2420     verify_for_read(obj);
2421     if (obj_is_menu(obj))
2422     {
2423         return (obj->info.menu.tear_off);
2424     }
2425     return (0);
2426 }
2427
2428 BOOL
2429 obj_get_exclusive(ABObj obj)
2430 {
2431     verify_for_read(obj);
2432     if (obj_is_menu(obj))
2433     {
2434         return (obj->info.menu.exclusive);
2435     }
2436     return (0);
2437 }
2438
2439 int
2440 obj_set_to(ABObj obj, ABObj to)
2441 {
2442     verify_for_write(obj);
2443     if (!obj_is_action(obj))
2444     {
2445         member_error(obj, "to");
2446         return NULL;
2447     }
2448     obj->info.action.to = to;
2449     return 0;
2450 }
2451
2452 ABObj
2453 obj_get_to(ABObj obj)
2454 {
2455     verify_for_read(obj);
2456     if (!obj_is_action(obj))
2457     {
2458         member_error(obj, "to");
2459         return NULL;
2460     }
2461     return obj->info.action.to;
2462 }
2463
2464 int
2465 obj_set_from(ABObj obj, ABObj from)
2466 {
2467     verify_for_write(obj);
2468     if (!obj_is_action(obj))
2469     {
2470         member_error(obj, "from");
2471         return NULL;
2472     }
2473     obj->info.action.from = from;
2474     return 0;
2475 }
2476
2477 ABObj
2478 obj_get_from(ABObj obj)
2479 {
2480     verify_for_read(obj);
2481     if (!obj_is_action(obj))
2482     {
2483         member_error(obj, "from");
2484         return NULL;
2485     }
2486     return obj->info.action.from;
2487 }
2488
2489 int
2490 obj_set_func_type(ABObj obj, AB_FUNC_TYPE new_func_type)
2491 {
2492     verify_for_write(obj);
2493     if (!obj_is_action(obj))
2494     {
2495         member_error(obj, "func_type");
2496         return -1;
2497     }
2498     if (obj->info.action.func_type == new_func_type)
2499     {
2500         return 0;
2501     }
2502
2503     /*
2504      * Free the old type's data
2505      */
2506     switch (obj->info.action.func_type)
2507     {
2508     case AB_FUNC_CODE_FRAG:
2509         istr_destroy(obj->info.action.func_value.code_frag);
2510         break;
2511
2512     case AB_FUNC_USER_DEF:
2513         istr_destroy(obj->info.action.func_value.func_name);
2514         break;
2515
2516     case AB_FUNC_ON_ITEM_HELP:
2517         break;
2518
2519     case AB_FUNC_HELP_VOLUME:
2520         istr_destroy(obj->info.action.volume_id);
2521         istr_destroy(obj->info.action.location);
2522         break;
2523
2524     default:
2525         break;
2526     }
2527
2528     /*
2529      * Set default value for new type
2530      */
2531     obj->info.action.func_type = new_func_type;
2532     switch (obj->info.action.func_type)
2533     {
2534     case AB_FUNC_UNDEF:
2535         break;
2536
2537     case AB_FUNC_CODE_FRAG:
2538         obj->info.action.func_value.code_frag = NULL;
2539         break;
2540
2541     case AB_FUNC_USER_DEF:
2542         obj->info.action.func_value.func_name = NULL;
2543         break;
2544
2545     case AB_FUNC_HELP_VOLUME:
2546         obj->info.action.volume_id = NULL;
2547         obj->info.action.location = NULL;
2548         break;
2549
2550     default:
2551         break;
2552     }
2553
2554     return 0;
2555 }
2556
2557 AB_FUNC_TYPE
2558 obj_get_func_type(ABObj obj)
2559 {
2560     verify_for_read(obj);
2561     if (obj_is_action(obj))
2562     {
2563         return (obj->info.action.func_type);
2564     }
2565     return (AB_FUNC_UNDEF);
2566 }
2567
2568 int
2569 obj_set_func_name(ABObj obj, STRING func_name)
2570 {
2571     verify_for_write(obj);
2572     if (!(obj_is_action(obj)
2573           && (obj->info.action.func_type == AB_FUNC_USER_DEF)))
2574     {
2575         member_error(obj, "func_name");
2576         return -1;
2577     }
2578     istr_destroy(obj->info.action.func_value.func_name);
2579     obj->info.action.func_value.func_name = istr_create(func_name);
2580     return 0;
2581 }
2582
2583 STRING
2584 obj_get_func_name(ABObj obj)
2585 {
2586     verify_for_read(obj);
2587     if (!(obj_is_action(obj)
2588           && (obj->info.action.func_type == AB_FUNC_USER_DEF)))
2589     {
2590         return NULL;
2591     }
2592     return (istr_string(obj->info.action.func_value.func_name));
2593 }
2594
2595 int
2596 obj_set_func_name_suffix(ABObj obj, STRING suffix)
2597 {
2598     verify_for_write(obj);
2599     if (!obj_is_action(obj))
2600     {
2601         member_error(obj, "func_name_suffix");
2602         return -1;
2603     }
2604     istr_destroy(obj->info.action.func_name_suffix);
2605     obj->info.action.func_name_suffix = istr_create(suffix);
2606     return 0;
2607 }
2608
2609 STRING
2610 obj_get_func_name_suffix(ABObj obj)
2611 {
2612     verify_for_read(obj);
2613     if (!obj_is_action(obj))
2614     {
2615         member_error(obj, "func_name_suffix");
2616         return NULL;
2617     }
2618     return istr_string(obj->info.action.func_name_suffix);
2619 }
2620
2621 int
2622 obj_set_func_code(ABObj obj, STRING code)
2623 {
2624     verify_for_write(obj);
2625     if (!(obj_is_action(obj)
2626           && (obj->info.action.func_type == AB_FUNC_CODE_FRAG)))
2627     {
2628         member_error(obj, "func_code");
2629         return -1;
2630     }
2631     istr_destroy(obj->info.action.func_value.code_frag);
2632     obj->info.action.func_value.code_frag = istr_create(code);
2633     return 0;
2634 }
2635
2636 STRING
2637 obj_get_func_code(ABObj obj)
2638 {
2639     verify_for_read(obj);
2640     if (obj_is_action(obj))
2641     {
2642         return (istr_string(obj->info.action.func_value.code_frag));
2643     }
2644     member_error(obj, "func_code");
2645     return ("nil");
2646 }
2647
2648 AB_BUILTIN_ACTION
2649 obj_get_func_builtin(ABObj obj)
2650 {
2651     verify_for_read(obj);
2652     if (!(obj_is_action(obj) && (obj_get_func_type(obj) == AB_FUNC_BUILTIN)))
2653     {
2654         return AB_STDACT_UNDEF;
2655     }
2656     return (obj->info.action.func_value.builtin);
2657 }
2658
2659 int
2660 obj_set_func_builtin(ABObj obj, AB_BUILTIN_ACTION act)
2661 {
2662     verify_for_write(obj);
2663     if (obj_is_action(obj) && (obj_get_func_type(obj) == AB_FUNC_BUILTIN))
2664     {
2665         obj->info.action.func_value.builtin = act;
2666         return 0;
2667     }
2668     return -1;
2669 }
2670
2671 AB_WHEN
2672 obj_get_when(ABObj obj)
2673 {
2674     verify_for_read(obj);
2675     if (obj_is_action(obj))
2676     {
2677         return (obj->info.action.when);
2678     }
2679     return AB_WHEN_UNDEF;
2680 }
2681
2682 int
2683 obj_set_when(ABObj obj, AB_WHEN when)
2684 {
2685     verify_for_write(obj);
2686     if (obj->type != AB_TYPE_ACTION)
2687     {
2688         member_error(obj, "when");
2689         return NULL;
2690     }
2691     obj->info.action.when = when;
2692     return 0;
2693 }
2694
2695 int
2696 obj_set_width_is_resizable(ABObj obj, BOOL resizable)
2697 {
2698     verify_for_write(obj);
2699     if (resizable)
2700         obj_set_impl_flags(obj, ObjFlagWidthIsResizable);
2701     else
2702         obj_clear_impl_flags(obj, ObjFlagWidthIsResizable);
2703     return 0;
2704 }
2705
2706 BOOL
2707 obj_get_width_is_resizable(ABObj obj)
2708 {
2709     verify_for_read(obj);
2710     return obj_has_impl_flags(obj, ObjFlagWidthIsResizable);
2711 }
2712
2713 int
2714 obj_set_arg_type(ABObj obj, AB_ARG_TYPE arg_type)
2715 {
2716     verify_for_write(obj);
2717     if (!obj_is_action(obj))
2718     {
2719         member_error(obj, "arg_type");
2720         return -1;
2721     }
2722     if (arg_type == obj->info.action.arg_type)
2723     {
2724         return 0;
2725     }
2726
2727     /*
2728      * Free old data type
2729      */
2730     if (obj->info.action.arg_type == AB_ARG_STRING)
2731     {
2732         istr_destroy(obj->info.action.arg_value.sval);
2733     }
2734
2735     /*
2736      * Set initial value for new data type
2737      */
2738     obj->info.action.arg_type = arg_type;
2739     switch (obj->info.action.arg_type)
2740     {
2741     case AB_ARG_UNDEF:
2742     case AB_ARG_VOID_PTR:
2743         break;
2744
2745     case AB_ARG_FLOAT:
2746         obj->info.action.arg_value.fval = 0.0;
2747         break;
2748
2749     case AB_ARG_INT:
2750         obj->info.action.arg_value.fval = 0;
2751         break;
2752
2753     case AB_ARG_STRING:
2754         obj->info.action.arg_value.sval = NULL;
2755         break;
2756     }
2757     return 0;
2758 }
2759
2760 AB_ARG_TYPE
2761 obj_get_arg_type(ABObj obj)
2762 {
2763     verify_for_read(obj);
2764     if (obj_is_action(obj))
2765     {
2766         return (obj->info.action.arg_type);
2767     }
2768     return AB_ARG_UNDEF;
2769 }
2770
2771 #ifdef BOGUS
2772 AB_ARG_VALUE
2773 obj_get_arg_value(ABObj obj)
2774 {
2775     verify_for_read(obj);
2776     AB_ARG_VALUE        value;
2777     value.ival = 0;
2778     if (obj_is_action(obj))
2779     {
2780         return (obj->info.action.arg_value);
2781     }
2782     return value;
2783 }
2784
2785 #endif                          /* BOGUS */
2786
2787 int
2788 obj_set_arg_float(ABObj obj, double float_val)
2789 {
2790     verify_for_write(obj);
2791     if (!(obj_is_action(obj) && (obj_get_arg_type(obj) == AB_ARG_FLOAT)))
2792     {
2793         member_error(obj, "arg_float");
2794         return -1;
2795     }
2796     obj->info.action.arg_value.fval = float_val;
2797     return 0;
2798 }
2799
2800 double
2801 obj_get_arg_float(ABObj obj)
2802 {
2803     verify_for_read(obj);
2804     if (!(obj_is_action(obj) && (obj_get_arg_type(obj) == AB_ARG_FLOAT)))
2805     {
2806         member_error(obj, "arg_float");
2807         return 0.0;
2808     }
2809     return (obj->info.action.arg_value.fval);
2810 }
2811
2812 int
2813 obj_set_arg_int(ABObj obj, int int_value)
2814 {
2815     verify_for_write(obj);
2816     if (!(obj_is_action(obj) && (obj->info.action.arg_type == AB_ARG_INT)))
2817     {
2818         member_error(obj, "arg_int");
2819         return -1;
2820     }
2821     obj->info.action.arg_value.ival = int_value;
2822     return 0;
2823 }
2824
2825
2826 int
2827 obj_get_arg_int(ABObj obj)
2828 {
2829     verify_for_read(obj);
2830     if (!(obj_is_action(obj) && (obj->info.action.arg_type == AB_ARG_INT)))
2831     {
2832         member_error(obj, "arg_int");
2833         return 0;
2834     }
2835     return (obj->info.action.arg_value.ival);
2836 }
2837
2838 int
2839 obj_set_arg_string(ABObj obj, STRING argString)
2840 {
2841     verify_for_write(obj);
2842     if (!(obj_is_action(obj) && (obj->info.action.arg_type == AB_ARG_STRING)))
2843     {
2844         member_error(obj, "arg_string");
2845         return -1;
2846     }
2847     istr_destroy(obj->info.action.arg_value.sval);
2848     obj->info.action.arg_value.sval = istr_create(argString);
2849     return 0;
2850 }
2851
2852 STRING
2853 obj_get_arg_string(ABObj obj)
2854 {
2855     verify_for_read(obj);
2856     if (obj_is_action(obj))
2857     {
2858         return (istr_string(obj->info.action.arg_value.sval));
2859     }
2860     return NULL;
2861 }
2862
2863 ABAttachment       *
2864 obj_get_attachment(
2865                    ABObj obj,
2866                    AB_COMPASS_POINT dir
2867 )
2868 {
2869     ABAttachment       *attach = NULL;
2870     verify_for_read(obj);
2871
2872     if (obj->attachments == NULL)
2873     {
2874         goto epilogue;
2875     }
2876
2877     switch (dir)
2878     {
2879     case AB_CP_NORTH:
2880         attach = (&(obj->attachments->north));
2881         break;
2882     case AB_CP_SOUTH:
2883         attach = (&(obj->attachments->south));
2884         break;
2885     case AB_CP_EAST:
2886         attach = (&(obj->attachments->east));
2887         break;
2888     case AB_CP_WEST:
2889         attach = (&(obj->attachments->west));
2890         break;
2891     default:
2892         if (util_get_verbosity() >= 3)
2893             fprintf(stderr, "obj_get_attachment: invalid direction\n");
2894         attach = NULL;
2895         break;
2896     }
2897
2898 epilogue:
2899     return attach;
2900 }
2901
2902 AB_ATTACH_TYPE
2903 obj_get_attach_type(
2904                     ABObj obj,
2905                     AB_COMPASS_POINT dir
2906 )
2907 {
2908     verify_for_read(obj);
2909     if (obj->attachments == NULL)
2910         return AB_ATTACH_UNDEF;
2911
2912     switch (dir)
2913     {
2914     case AB_CP_NORTH:
2915         return (obj->attachments->north.type);
2916     case AB_CP_SOUTH:
2917         return (obj->attachments->south.type);
2918     case AB_CP_EAST:
2919         return (obj->attachments->east.type);
2920     case AB_CP_WEST:
2921         return (obj->attachments->west.type);
2922     default:
2923         if (util_get_verbosity() > 0)
2924             fprintf(stderr, "obj_get_attach_type: invalid direction\n");
2925         return AB_ATTACH_UNDEF;
2926
2927     }
2928 }
2929
2930 void               *
2931 obj_get_attach_value(
2932                      ABObj obj,
2933                      AB_COMPASS_POINT dir
2934 )
2935 {
2936     verify_for_read(obj);
2937     if (obj->attachments == NULL)
2938         return NULL;
2939
2940     switch (dir)
2941     {
2942     case AB_CP_NORTH:
2943         return (obj->attachments->north.value);
2944     case AB_CP_SOUTH:
2945         return (obj->attachments->south.value);
2946     case AB_CP_EAST:
2947         return (obj->attachments->east.value);
2948     case AB_CP_WEST:
2949         return (obj->attachments->west.value);
2950     default:
2951         if (util_get_verbosity() > 0)
2952             fprintf(stderr, "obj_get_attach_value: invalid direction\n");
2953         return NULL;
2954
2955     }
2956 }
2957
2958 int
2959 obj_get_attach_offset(
2960                       ABObj obj,
2961                       AB_COMPASS_POINT dir
2962 )
2963 {
2964     verify_for_read(obj);
2965     if (obj->attachments == NULL)
2966         return 0;
2967
2968     switch (dir)
2969     {
2970     case AB_CP_NORTH:
2971         return (obj->attachments->north.offset);
2972     case AB_CP_SOUTH:
2973         return (obj->attachments->south.offset);
2974     case AB_CP_EAST:
2975         return (obj->attachments->east.offset);
2976     case AB_CP_WEST:
2977         return (obj->attachments->west.offset);
2978     default:
2979         if (util_get_verbosity() > 0)
2980             fprintf(stderr, "obj_get_attach_offset: invalid direction\n");
2981         return NULL;
2982
2983     }
2984 }
2985
2986 int
2987 obj_set_attachment(
2988                    ABObj obj,
2989                    AB_COMPASS_POINT dir,
2990                    AB_ATTACH_TYPE type,
2991                    void *value,
2992                    int offset
2993 )
2994 {
2995     ABAttachment       *attachment;
2996     verify_for_write(obj);
2997
2998     if (obj->attachments == NULL)
2999         obj_init_attachments(obj);
3000
3001     switch (dir)
3002     {
3003     case AB_CP_NORTH:
3004         attachment = &(obj->attachments->north);
3005         break;
3006     case AB_CP_WEST:
3007         attachment = &(obj->attachments->west);
3008         break;
3009     case AB_CP_SOUTH:
3010         attachment = &(obj->attachments->south);
3011         break;
3012     case AB_CP_EAST:
3013         attachment = &(obj->attachments->east);
3014         break;
3015     }
3016     attachment->type = type;
3017     attachment->value = value;
3018     attachment->offset = offset;
3019
3020     return 0;
3021 }
3022
3023 int
3024 obj_set_attach_type(
3025                     ABObj obj,
3026                     AB_COMPASS_POINT dir,
3027                     AB_ATTACH_TYPE type
3028 )
3029 {
3030     verify_for_write(obj);
3031     if (obj->attachments == NULL)
3032         obj_init_attachments(obj);
3033
3034     switch (dir)
3035     {
3036     case AB_CP_NORTH:
3037         obj->attachments->north.type = type;
3038         break;
3039     case AB_CP_WEST:
3040         obj->attachments->west.type = type;
3041         break;
3042     case AB_CP_SOUTH:
3043         obj->attachments->south.type = type;
3044         break;
3045     case AB_CP_EAST:
3046         obj->attachments->east.type = type;
3047         break;
3048     }
3049     return 0;
3050 }
3051
3052 int
3053 obj_set_attach_value(
3054                      ABObj obj,
3055                      AB_COMPASS_POINT dir,
3056                      void *value
3057 )
3058 {
3059     verify_for_write(obj);
3060     if (obj->attachments == NULL)
3061         obj_init_attachments(obj);
3062
3063     switch (dir)
3064     {
3065     case AB_CP_NORTH:
3066         obj->attachments->north.value = value;
3067         break;
3068     case AB_CP_WEST:
3069         obj->attachments->west.value = value;
3070         break;
3071     case AB_CP_SOUTH:
3072         obj->attachments->south.value = value;
3073         break;
3074     case AB_CP_EAST:
3075         obj->attachments->east.value = value;
3076         break;
3077     }
3078     return 0;
3079 }
3080
3081 int
3082 obj_set_attach_offset(
3083                       ABObj obj,
3084                       AB_COMPASS_POINT dir,
3085                       int offset
3086 )
3087 {
3088     verify_for_write(obj);
3089     if (obj->attachments == NULL)
3090         obj_init_attachments(obj);
3091
3092     switch (dir)
3093     {
3094     case AB_CP_NORTH:
3095         obj->attachments->north.offset = offset;
3096         break;
3097     case AB_CP_WEST:
3098         obj->attachments->west.offset = offset;
3099         break;
3100     case AB_CP_SOUTH:
3101         obj->attachments->south.offset = offset;
3102         break;
3103     case AB_CP_EAST:
3104         obj->attachments->east.offset = offset;
3105         break;
3106     }
3107     return 0;
3108 }
3109
3110 int
3111 obj_set_button_type(ABObj obj, AB_BUTTON_TYPE type)
3112 {
3113     verify_for_write(obj);
3114     if (!obj_is_button(obj))
3115         return -1;
3116
3117     obj->info.button.type = type;
3118     return 0;
3119 }
3120
3121
3122 int
3123 obj_set_help_act_button(
3124     ABObj obj,
3125     ABObj helpb 
3126 )
3127 {
3128     if (!obj_is_window(obj))
3129         return -1;
3130
3131     verify_for_write(obj);
3132     obj->info.window.help_act_button= helpb;
3133     return 0;
3134 }
3135
3136 ABObj
3137 obj_get_help_act_button(
3138     ABObj obj
3139 )
3140 {
3141     ABObj               defaultb = NULL;
3142  
3143     if (!obj_is_window(obj))
3144         return NULL;
3145
3146     verify_for_read(obj);
3147     return(obj->info.window.help_act_button);
3148 }
3149
3150 /*
3151 ** Indicate whether a particular object has help data set.  This is used
3152 ** by the front end to set-up help in Test Mode and by the code generator
3153 ** to decide whether to generate help support code.
3154 */
3155 BOOL            
3156 obj_has_help_data(ABObj obj)
3157 {
3158     STRING help_text = istr_string(obj->help_text);
3159
3160     if( (help_text != 0) && (*help_text != 0) ) {
3161                 return TRUE;
3162     }
3163     return FALSE;
3164 }
3165
3166 int
3167 obj_set_help_data(ABObj obj,
3168                   STRING help_volume,
3169                   STRING help_location,
3170                   STRING help_text
3171 )
3172 {
3173     verify_for_write(obj);
3174     istr_destroy(obj->help_volume);
3175     istr_destroy(obj->help_location);
3176     istr_destroy(obj->help_text);
3177
3178     obj->help_volume = istr_create(help_volume);
3179     obj->help_location = istr_create(help_location);
3180     obj->help_text = istr_create(help_text);
3181
3182     return 0;
3183 }
3184
3185 int
3186 obj_set_help_volume(ABObj obj,
3187                     STRING help_volume
3188 )
3189 {
3190     verify_for_write(obj);
3191     istr_destroy(obj->help_volume);
3192     obj->help_volume = istr_create(help_volume);
3193
3194     return 0;
3195 }
3196
3197 int
3198 obj_set_help_location(ABObj obj,
3199                       STRING help_location
3200 )
3201 {
3202     verify_for_write(obj);
3203     istr_destroy(obj->help_location);
3204     obj->help_location = istr_create(help_location);
3205
3206     return 0;
3207 }
3208
3209 int
3210 obj_set_help_text(ABObj obj,
3211                   STRING help_text
3212 )
3213 {
3214     verify_for_write(obj);
3215     istr_destroy(obj->help_text);
3216     obj->help_text = istr_create(help_text);
3217
3218     return 0;
3219 }
3220
3221 int
3222 obj_get_help_data(ABObj obj,
3223                   STRING * help_volume,
3224                   STRING * help_location,
3225                   STRING * help_text
3226 )
3227 {
3228     verify_for_read(obj);
3229     *help_volume = istr_string(obj->help_volume);
3230     *help_location = istr_string(obj->help_location);
3231     *help_text = istr_string(obj->help_text);
3232     return 0;
3233 }
3234
3235 STRING
3236 obj_get_help_volume(
3237                     ABObj obj
3238 )
3239 {
3240     STRING              help_volume = NULL;
3241     verify_for_read(obj);
3242
3243     help_volume = istr_string(obj->help_volume);
3244     return (help_volume);
3245 }
3246
3247 STRING
3248 obj_get_help_location(
3249                       ABObj obj
3250 )
3251 {
3252     STRING              help_location = NULL;
3253     verify_for_read(obj);
3254
3255     help_location = istr_string(obj->help_location);
3256     return (help_location);
3257 }
3258
3259 STRING
3260 obj_get_help_text(
3261                   ABObj obj
3262 )
3263 {
3264     STRING              help_text = NULL;
3265     verify_for_read(obj);
3266
3267     help_text = istr_string(obj->help_text);
3268     return (help_text);
3269 }
3270
3271 int
3272 obj_set_word_wrap(ABObj obj, BOOL word_wrap)
3273 {
3274     verify_for_write(obj);
3275     if (obj_is_text_pane(obj))
3276     {
3277         obj->info.text.word_wrap = word_wrap;
3278         return 0;
3279     }
3280     member_error(obj, "word_wrap");
3281     return -1;
3282 }
3283
3284
3285 BOOL
3286 obj_get_word_wrap(ABObj obj)
3287 {
3288     verify_for_read(obj);
3289     return (obj->info.text.word_wrap);
3290 }
3291
3292 int
3293 obj_set_line_style(ABObj obj, AB_LINE_TYPE line_style)
3294 {
3295     verify_for_write(obj);
3296     switch (obj->type)
3297     {
3298     case AB_TYPE_SEPARATOR:
3299         obj->info.separator.line_style = line_style;
3300         return 0;
3301     case AB_TYPE_ITEM:
3302         obj->info.item.line_style = line_style;
3303         return 0;
3304     }
3305     member_error(obj, "line_style");
3306     return -1;
3307 }
3308
3309
3310 AB_LINE_TYPE
3311 obj_get_line_style(
3312                    ABObj obj
3313 )
3314 {
3315     verify_for_read(obj);
3316
3317     switch(obj->type)
3318     {
3319         case AB_TYPE_SEPARATOR:
3320             return (obj->info.separator.line_style);
3321         case AB_TYPE_ITEM:
3322             return (obj->info.item.line_style);
3323         default:
3324             return (AB_LINE_UNDEF);
3325     }
3326 }
3327
3328 int
3329 obj_set_arrow_style(ABObj obj, AB_ARROW_STYLE arrow_style)
3330 {
3331     verify_for_write(obj);
3332     switch (obj->type)
3333     {
3334     case AB_TYPE_SPIN_BOX:
3335         obj->info.spin_box.arrow_style = arrow_style;
3336         return 0;
3337     }
3338     member_error(obj, "arrow_style");
3339     return -1;
3340 }
3341
3342
3343 AB_ARROW_STYLE
3344 obj_get_arrow_style(
3345                     ABObj obj
3346 )
3347 {
3348     verify_for_read(obj);
3349     if (!obj || !obj_is_spin_box(obj))
3350         return (AB_ARROW_UNDEF);
3351
3352     return (obj->info.spin_box.arrow_style);
3353 }
3354
3355 int
3356 obj_set_show_value(
3357                    ABObj obj,
3358                    BOOL val
3359 )
3360 {
3361     verify_for_write(obj);
3362     if (!obj_is_scale(obj))
3363     {
3364         member_error(obj, "scale_show_value");
3365         return -1;
3366     }
3367
3368     obj->info.scale.show_value = val;
3369     return 0;
3370 }
3371
3372 BOOL
3373 obj_get_show_value(
3374                    ABObj obj
3375 )
3376 {
3377     verify_for_read(obj);
3378     if (!obj_is_scale(obj))
3379     {
3380         member_error(obj, "show_value");
3381         return FALSE;
3382     }
3383
3384     return (obj->info.scale.show_value);
3385 }
3386
3387 int
3388 obj_set_user_data(ABObj obj, STRING user_data)
3389 {
3390     verify_for_write(obj);
3391     istr_destroy(obj->user_data);
3392     obj->user_data = istr_create(user_data);
3393     return 0;
3394 }
3395
3396 STRING
3397 obj_get_user_data(ABObj obj)
3398 {
3399     verify_for_read(obj);
3400     return istr_string(obj->user_data);
3401 }
3402
3403
3404 #ifdef DEBUG
3405
3406 static int
3407 verify(ABObj obj, int min_debug, STRING file, int line)
3408 {
3409     int         rc = 0;
3410
3411     if (debug_level() < min_debug)
3412     {
3413         return 0;
3414     }
3415
3416     rc = objP_update_verify(obj);
3417     if (rc < 0)
3418     {
3419         util_dprintf(0, "Corrupted object detected (%s:%d).\n",
3420                      file, line);
3421         if (debug_level() >= 5)
3422         {
3423             abort();
3424         }
3425         return -1;
3426     }
3427     return 0;
3428 }
3429
3430 /* don't normally check obj integrity on every read (debug level 3) */
3431 static int
3432 verify_for_read_impl(ABObj obj, STRING file, int line)
3433 {
3434     return verify(obj, 1, file, line);
3435 }
3436
3437 static int
3438 verify_for_write_impl(ABObj obj, STRING file, int line)
3439 {
3440     return verify(obj, 1, file, line);
3441 }
3442
3443 #endif /* DEBUG */
3444
3445 #ifdef DEBUG
3446
3447 /*
3448  * Report an attempt to set an unsupported attribute on an object.
3449  */
3450 static int
3451 member_error_impl(ABObj obj, STRING member_name, STRING file, int line)
3452 {
3453     char                obj_name[256];
3454
3455     /*
3456      * We "use" fields that are illegal for objects regularly, and just
3457      * ignore the objects that return errors.
3458      */
3459     return 0;
3460
3461     /*
3462     if (!debugging())
3463     {
3464         return 0;
3465     }
3466     *obj_name = 0;
3467     obj_get_safe_name(obj, obj_name, 256);
3468     util_dprintf(0,
3469                  "ERROR(%s:%d): Bad attribute access '%s' in object '%s'.\n",
3470                  file, line, member_name, obj_name);
3471     return 0;
3472     */
3473 }
3474
3475 #endif                          /* DEBUG */
3476
3477 BOOL
3478 obj_has_hscrollbar(ABObj obj)
3479 {
3480     AB_OBJECT_TYPE      type = AB_TYPE_UNDEF;
3481     AB_SCROLLBAR_POLICY sb_policy = AB_SCROLLBAR_UNDEF;
3482     BOOL                has_hscrollbar = FALSE;
3483
3484     type = obj_get_type(obj);
3485     if (type == AB_TYPE_DRAWING_AREA || type == AB_TYPE_LIST ||
3486         type == AB_TYPE_TERM_PANE || type == AB_TYPE_TEXT_PANE )
3487     {
3488         sb_policy = obj_get_hscrollbar_policy(obj);
3489         if (sb_policy == AB_SCROLLBAR_ALWAYS || 
3490             sb_policy == AB_SCROLLBAR_WHEN_NEEDED)
3491         {
3492             has_hscrollbar = TRUE;
3493         }
3494     }
3495
3496     return (has_hscrollbar);
3497 }
3498
3499 BOOL 
3500 obj_has_vscrollbar(ABObj obj) 
3501
3502     AB_OBJECT_TYPE      type = AB_TYPE_UNDEF; 
3503     AB_SCROLLBAR_POLICY sb_policy = AB_SCROLLBAR_UNDEF;
3504     BOOL                has_vscrollbar = FALSE; 
3505  
3506     type = obj_get_type(obj); 
3507     if (type == AB_TYPE_DRAWING_AREA || type == AB_TYPE_LIST ||
3508         type == AB_TYPE_TERM_PANE || type == AB_TYPE_TEXT_PANE ) 
3509     { 
3510         sb_policy = obj_get_vscrollbar_policy(obj); 
3511         if (sb_policy == AB_SCROLLBAR_ALWAYS || 
3512             sb_policy == AB_SCROLLBAR_WHEN_NEEDED)
3513         { 
3514             has_vscrollbar = TRUE; 
3515         } 
3516     }    
3517
3518     return (has_vscrollbar); 
3519
3520
3521 int
3522 obj_set_ok_label(ABObj obj, STRING label)
3523 {
3524     verify_for_write(obj);
3525     if (!obj_is_file_chooser(obj))
3526     {
3527         member_error(obj, "ok_label");
3528         return -1;
3529     }
3530     istr_destroy(obj->info.file_chooser.ok_label);
3531     obj->info.file_chooser.ok_label = istr_create(label);
3532     return 0;
3533 }    
3534
3535 STRING
3536 obj_get_ok_label( ABObj obj)
3537 {
3538     STRING              label = NULL;
3539  
3540     verify_for_read(obj);
3541     if (!obj_is_file_chooser(obj))
3542     {
3543         member_error(obj, "ok_label");
3544         return NULL;
3545     }
3546     label = istr_string(obj->info.file_chooser.ok_label);
3547     return (label);
3548 }
3549
3550 int
3551 obj_set_action1_label(ABObj obj, STRING label)
3552 {
3553     verify_for_write(obj);
3554     if (!obj_is_message(obj))
3555     {
3556         member_error(obj, "action1_label");
3557         return -1;
3558     }
3559     istr_destroy(obj->info.message.action1_label);
3560     obj->info.message.action1_label = istr_create(label);
3561     return 0;
3562 }
3563
3564 STRING
3565 obj_get_action1_label( ABObj obj)
3566 {
3567     STRING              label = NULL;
3568
3569     verify_for_read(obj);
3570     if (!obj_is_message(obj))
3571     {
3572         member_error(obj, "action1_label");
3573         return NULL;
3574     }
3575     label = istr_string(obj->info.message.action1_label);
3576     return (label);
3577 }
3578
3579 int
3580 obj_set_action2_label(ABObj obj, STRING label)
3581 {
3582     verify_for_write(obj);
3583     if (!obj_is_message(obj))
3584     {
3585         member_error(obj, "action2_label");
3586         return -1;
3587     }
3588     istr_destroy(obj->info.message.action2_label);
3589     obj->info.message.action2_label = istr_create(label);
3590     return 0;
3591 }
3592  
3593 STRING
3594 obj_get_action2_label( ABObj obj)
3595 {
3596     STRING              label = NULL;
3597
3598     verify_for_read(obj);
3599     if (!obj_is_message(obj))
3600     {
3601         member_error(obj, "action2_label");
3602         return NULL;
3603     }
3604     label = istr_string(obj->info.message.action2_label);
3605     return (label);
3606 }
3607
3608 int
3609 obj_set_action3_label(ABObj obj, STRING label)
3610 {
3611     verify_for_write(obj);
3612     if (!obj_is_message(obj))
3613     {
3614         member_error(obj, "action3_label");
3615         return -1;
3616     }
3617     istr_destroy(obj->info.message.action3_label);
3618     obj->info.message.action3_label = istr_create(label);
3619     return 0;
3620 }
3621  
3622 STRING
3623 obj_get_action3_label( ABObj obj)
3624 {
3625     STRING              label = NULL;
3626
3627     verify_for_read(obj);
3628     if (!obj_is_message(obj))
3629     {
3630         member_error(obj, "action3_label");
3631         return NULL;
3632     }
3633     label = istr_string(obj->info.message.action3_label);
3634     return (label);
3635 }
3636
3637 int 
3638 obj_set_directory(ABObj obj, STRING dir)
3639 {
3640     verify_for_write(obj);
3641     if (!obj_is_file_chooser(obj))
3642     {
3643         member_error(obj, "directory");
3644         return -1;
3645     }
3646     istr_destroy(obj->info.file_chooser.directory);
3647     obj->info.file_chooser.directory = istr_create(dir);
3648     return 0;
3649 }
3650
3651 STRING 
3652 obj_get_directory( ABObj obj)
3653
3654     STRING              dir = NULL; 
3655  
3656     verify_for_read(obj);   
3657     if (!obj_is_file_chooser(obj))
3658     {
3659         member_error(obj, "directory");
3660         return NULL;
3661     }
3662     dir = istr_string(obj->info.file_chooser.directory);
3663     return (dir);
3664
3665
3666
3667 int 
3668 obj_set_auto_dismiss(ABObj obj, BOOL dismiss)
3669 {
3670     verify_for_write(obj);
3671     if (!obj_is_file_chooser(obj))
3672     {
3673         member_error(obj, "auto_dismiss");
3674         return -1;
3675     }
3676     obj->info.file_chooser.auto_dismiss = dismiss;
3677     return 0;
3678 }
3679
3680 BOOL
3681 obj_get_auto_dismiss( ABObj obj)
3682 {
3683     verify_for_read(obj);
3684     if (!obj_is_file_chooser(obj))
3685     {
3686         member_error(obj, "auto_dismiss");
3687         return FALSE;
3688     }
3689     return (obj->info.file_chooser.auto_dismiss);
3690 }
3691
3692
3693 int
3694 obj_set_file_type_mask(ABObj obj, AB_FILE_TYPE_MASK ftm)
3695 {
3696     verify_for_write(obj);
3697     if (!obj_is_file_chooser(obj))
3698     {
3699         member_error(obj, "file_type_mask");
3700         return -1;
3701     }
3702     obj->info.file_chooser.file_type_mask = ftm;
3703     return 0;
3704 }
3705
3706 AB_FILE_TYPE_MASK
3707 obj_get_file_type_mask( ABObj obj)
3708 {
3709     verify_for_read(obj);
3710     if (!obj_is_file_chooser(obj))
3711     {
3712         member_error(obj, "file_type_mask");
3713         return (AB_FILE_TYPE_MASK)0;
3714     }
3715
3716     return (obj->info.file_chooser.file_type_mask);
3717 }
3718
3719 int
3720 obj_set_msg_string(ABObj obj, STRING msg)
3721 {
3722     verify_for_write(obj);
3723     if (!obj_is_message(obj))
3724     {
3725         member_error(obj, "message");
3726         return -1;
3727     }
3728     istr_destroy(obj->info.message.msg_string);
3729     obj->info.message.msg_string = istr_create(msg);
3730     return 0;
3731 }
3732
3733 STRING
3734 obj_get_msg_string( ABObj obj)
3735 {
3736     STRING              msg = NULL;
3737
3738     verify_for_read(obj);
3739     if (!obj_is_message(obj))
3740     {
3741         member_error(obj, "message");
3742         return NULL;
3743     }
3744     msg = istr_string(obj->info.message.msg_string);
3745     return (msg);
3746 }
3747
3748 int
3749 obj_set_msg_type(ABObj obj, AB_MESSAGE_TYPE msg_type)
3750 {
3751     verify_for_write(obj);
3752     if (obj_is_message(obj))
3753     {
3754         return (obj->info.message.type = msg_type);
3755     }
3756     return ERR_BAD_PARAM1; 
3757 }
3758  
3759 AB_MESSAGE_TYPE
3760 obj_get_msg_type( ABObj obj)
3761
3762     verify_for_read(obj); 
3763     if (obj_is_message(obj)) 
3764     { 
3765         return (obj->info.message.type); 
3766     } 
3767     return AB_MSG_UNDEF;
3768
3769
3770 int
3771 obj_set_default_btn(ABObj obj, AB_DEFAULT_BUTTON button)
3772 {
3773     verify_for_write(obj);
3774     if (obj_is_message(obj))
3775     {
3776         return (obj->info.message.default_btn = button);
3777     }
3778     return ERR_BAD_PARAM1;
3779 }
3780
3781 AB_DEFAULT_BUTTON
3782 obj_get_default_btn( ABObj obj)
3783 {
3784     verify_for_read(obj);
3785     if (obj_is_message(obj))
3786     {
3787         return (obj->info.message.default_btn);
3788     }
3789     return AB_DEFAULT_BTN_UNDEF;
3790 }
3791
3792 BOOL
3793 obj_has_action1_button(ABObj obj)
3794 {
3795     verify_for_read(obj);
3796     if (obj_is_message(obj))
3797         return (!util_strempty(obj_get_action1_label(obj)));
3798     else
3799         return FALSE;
3800 }
3801
3802 BOOL
3803 obj_has_action2_button(ABObj obj)
3804 {
3805     verify_for_read(obj);
3806     if (obj_is_message(obj))
3807         return (!util_strempty(obj_get_action2_label(obj)));
3808     else
3809         return FALSE;
3810 }
3811
3812 BOOL
3813 obj_has_action3_button(ABObj obj)
3814 {
3815     verify_for_read(obj);
3816     if (obj_is_message(obj))
3817         return (!util_strempty(obj_get_action3_label(obj)));
3818     else
3819         return FALSE;
3820 }
3821
3822 BOOL
3823 obj_has_cancel_button(ABObj obj)
3824 {
3825     verify_for_read(obj);
3826     if (obj_is_message(obj))
3827         return (obj->info.message.cancel_button != 0);
3828     else
3829         return FALSE;
3830 }
3831
3832 BOOL
3833 obj_has_help_button(ABObj obj)
3834 {
3835     verify_for_read(obj);
3836     if (obj_is_message(obj))
3837         return (obj->info.message.help_button != 0);
3838     else
3839         return FALSE;
3840 }
3841
3842 int
3843 obj_set_sessioning_method(ABObj obj, AB_SESSIONING_METHOD sessioning_method)
3844 {
3845     verify_for_write(obj);
3846     if (obj_is_project(obj))
3847     {
3848         return (obj->info.project.session_mgmt.sessioning_method = sessioning_method);
3849     }
3850     return ERR_BAD_PARAM1; 
3851 }
3852  
3853 AB_SESSIONING_METHOD
3854 obj_get_sessioning_method( ABObj obj)
3855
3856     verify_for_read(obj); 
3857     if (obj_is_project(obj)) 
3858     { 
3859         return (obj->info.project.session_mgmt.sessioning_method); 
3860     } 
3861     return AB_SESSIONING_UNDEF;
3862
3863 int
3864 obj_set_cancel_button(ABObj obj, BOOL has_button)
3865 {
3866     verify_for_write(obj);
3867     if (!obj_is_message(obj))
3868         return -1;
3869     obj->info.message.cancel_button = has_button;
3870     return 0;
3871 }
3872
3873 int
3874 obj_set_help_button(ABObj obj, BOOL has_button)
3875 {
3876     verify_for_write(obj);
3877     if (!obj_is_message(obj))
3878         return -1;
3879     obj->info.message.help_button = has_button;
3880     return 0;
3881 }
3882 obj_set_tooltalk_level(ABObj obj, AB_TOOLTALK_LEVEL tt_level)
3883 {
3884     verify_for_write(obj);
3885     if (obj_is_project(obj))
3886     {
3887         return (obj->info.project.tooltalk.level = tt_level);
3888     }   
3889     return ERR_BAD_PARAM1;
3890 }
3891
3892 AB_TOOLTALK_LEVEL
3893 obj_get_tooltalk_level( ABObj obj)
3894 {
3895     verify_for_read(obj);
3896     if (obj_is_project(obj))
3897     {
3898         return (obj->info.project.tooltalk.level);
3899     }
3900     return AB_TOOLTALK_UNDEF;
3901 }
3902
3903 int
3904 obj_set_pane_min( ABObj obj, int val)
3905 {
3906     verify_for_write(obj);
3907     if (!obj_is_pane(obj) && !obj_is_layers(obj))
3908         return -1;
3909
3910     if (obj_is_text_pane(obj))
3911         obj->info.text.pane_min = val;
3912     if (obj_is_term_pane(obj))
3913         obj->info.term.pane_min = val;
3914     if (obj_is_drawing_area(obj))
3915         obj->info.drawing_area.pane_min = val;
3916     if (obj_is_container(obj))
3917         obj->info.container.pane_min = val;
3918     if (obj_is_layers(obj))
3919         obj->info.layer.pane_min = val;
3920     return 0;
3921 }
3922
3923 int 
3924 obj_get_pane_min( ABObj obj)
3925 {
3926     verify_for_read(obj); 
3927     if (!obj_is_pane(obj) && !obj_is_layers(obj))
3928         return -1; 
3929
3930     if (obj_is_text_pane(obj)) 
3931         return (obj->info.text.pane_min); 
3932     if (obj_is_term_pane(obj)) 
3933         return (obj->info.term.pane_min);
3934     if (obj_is_drawing_area(obj))   
3935         return (obj->info.drawing_area.pane_min); 
3936     if (obj_is_container(obj)) 
3937         return (obj->info.container.pane_min);
3938     if (obj_is_layers(obj))
3939         return (obj->info.layer.pane_min);
3940 }
3941
3942 int
3943 obj_set_pane_max( ABObj obj, int val)
3944 {
3945     verify_for_write(obj);
3946     if (!obj_is_pane(obj) && !obj_is_layers(obj))
3947         return -1; 
3948
3949     if (obj_is_text_pane(obj)) 
3950         obj->info.text.pane_max = val; 
3951     if (obj_is_term_pane(obj)) 
3952         obj->info.term.pane_max = val;
3953     if (obj_is_drawing_area(obj))   
3954         obj->info.drawing_area.pane_max = val; 
3955     if (obj_is_container(obj)) 
3956         obj->info.container.pane_max = val; 
3957     if (obj_is_layers(obj))
3958         obj->info.layer.pane_max = val;
3959     return 0; 
3960 }
3961
3962 int 
3963 obj_get_pane_max( ABObj obj)
3964 {
3965     verify_for_read(obj);  
3966     if (!obj_is_pane(obj) && !obj_is_layers(obj))  
3967         return -1;  
3968
3969     if (obj_is_text_pane(obj))  
3970         return (obj->info.text.pane_max); 
3971     if (obj_is_term_pane(obj))  
3972         return (obj->info.term.pane_max); 
3973     if (obj_is_drawing_area(obj))      
3974         return (obj->info.drawing_area.pane_max); 
3975     if (obj_is_container(obj)) 
3976         return (obj->info.container.pane_max);
3977     if (obj_is_layers(obj))
3978         return (obj->info.layer.pane_max);
3979 }
3980
3981 int
3982 obj_set_i18n_enabled(ABObj obj, BOOL i18n_enabled)
3983 {
3984     verify_for_write(obj);
3985     if (obj_is_project(obj))
3986     {
3987         obj->info.project.i18n.enabled = i18n_enabled;
3988         return 0;
3989     }
3990     return ERR_BAD_PARAM1; 
3991 }
3992  
3993 BOOL
3994 obj_get_i18n_enabled( ABObj obj)
3995
3996     verify_for_read(obj); 
3997     if (obj_is_project(obj)) 
3998     { 
3999         return(obj->info.project.i18n.enabled); 
4000     } 
4001     return FALSE;
4002
4003
4004 int
4005 obj_get_num_win_children( ABObj obj)
4006 {
4007     ABObj               refObj = NULL;
4008     AB_OBJ_REF_TYPE     refType = AB_REF_UNDEF;
4009     ABObjList           refs = NULL;
4010     void                *voidRefType = NULL;
4011     int                 numRefs = 0, i = 0;
4012     int                 numWinChildren = 0;
4013
4014     verify_for_read(obj);
4015     if (!obj_is_base_win(obj))
4016         return ERR;
4017
4018     if ((refs = obj_get_refs_to(obj)) != NULL)
4019     {
4020         numRefs = objlist_get_num_objs(refs);
4021         for (i = 0; i < numRefs; i++)
4022         {
4023             refObj = objlist_get_obj(refs, i, &voidRefType);
4024             refType = (AB_OBJ_REF_TYPE)voidRefType;
4025
4026             if (refType == AB_REF_WIN_PARENT)
4027             {
4028                 numWinChildren++;
4029             }
4030         }
4031         objlist_destroy(refs);
4032     }
4033  
4034     return (numWinChildren);
4035 }
4036
4037 int
4038 obj_set_read_only(ABObj obj, BOOL is_read_only)
4039 {
4040     verify_for_write(obj);
4041     if (is_read_only)
4042     {
4043         obj_set_impl_flags(obj, ObjFlagIsReadOnly);
4044     }
4045     else
4046     {   
4047         obj_clear_impl_flags(obj, ObjFlagIsReadOnly);
4048     }
4049     return 0;
4050 }
4051  
4052 BOOL
4053 obj_get_read_only(ABObj obj)
4054 {
4055     verify_for_read(obj);
4056     return obj_has_impl_flags(obj, ObjFlagIsReadOnly);
4057 }
4058
4059 STRING
4060 obj_get_func_help_location(ABObj obj)
4061 {
4062     verify_for_read(obj);
4063     if (obj_is_action(obj))
4064     {
4065         return (istr_string(obj->info.action.location));
4066     }
4067     member_error(obj, "func_help_location");
4068     return NULL;
4069 }
4070
4071 int
4072 obj_set_func_help_location(ABObj obj, STRING location)
4073 {
4074     verify_for_write(obj);
4075     if (!(obj_is_action(obj) && 
4076         (obj->info.action.func_type == AB_FUNC_HELP_VOLUME)))
4077     {
4078         member_error(obj, "func_help_location");
4079         return -1;
4080     }
4081     istr_destroy(obj->info.action.location);
4082     obj->info.action.location = istr_create(location);
4083     return 0;
4084 }
4085
4086 STRING
4087 obj_get_func_help_volume(ABObj obj)
4088 {
4089     verify_for_read(obj);
4090     if (obj_is_action(obj))
4091     {
4092         return (istr_string(obj->info.action.volume_id));
4093     }
4094     member_error(obj, "func_help_volume");
4095     return NULL;
4096 }
4097
4098 int
4099 obj_set_func_help_volume(ABObj obj, STRING volume)
4100 {
4101     verify_for_write(obj); 
4102     if (!(obj_is_action(obj) &&  
4103         (obj->info.action.func_type == AB_FUNC_HELP_VOLUME)))
4104     {  
4105         member_error(obj, "func_help_volume"); 
4106         return -1; 
4107     } 
4108     istr_destroy(obj->info.action.volume_id);
4109     obj->info.action.volume_id = istr_create(volume); 
4110     return 0; 
4111 }
4112
4113
4114
4115 /**************************************************************************
4116  **************************************************************************
4117  ***                                                                    ***
4118  ***                                                                    ***
4119  ***                    Drag and Drop                                   ***
4120  ***                                                                    ***
4121  *** dnd flags:                                                         ***
4122  ***    bit  0     -> drag enabled                                      ***
4123  ***    bit  1     -> drag to root allowed                              ***
4124  ***    bits 2-4   -> drag ops                                          ***
4125  ***    bits 5-8   -> drag types                                        ***
4126  ***    bit  9     -> drop enabled                                      ***
4127  ***    bits 10-12 -> drop ops                                          ***
4128  ***    bits 13-16 -> drop types                                        ***
4129  ***                                                                    ***
4130  **************************************************************************
4131  **************************************************************************/
4132
4133 #define ObjDndFlagDragEnabled           (((unsigned)0x0001))
4134 #define ObjDndFlagDragToRootOK          (((unsigned)0x0001)<<1)
4135 #define ObjDndFlagDragOpsFBIT           (2)             /* first bit */
4136 #define ObjDndFlagDragOpsNBITS          (3)             /* num bits */
4137 #define ObjDndFlagDragTypesFBIT         (5)             /* first bit */
4138 #define ObjDndFlagDragTypesNBITS        (4)             /* num bits */
4139 #define ObjDndFlagDropEnabled           (((unsigned)0x0001)<<9)
4140 #define ObjDndFlagDropOpsFBIT           (10)            /* first bit */
4141 #define ObjDndFlagDropOpsNBITS          (3)             /* num bits */
4142 #define ObjDndFlagDropTypesFBIT         (13)            /* first bit */
4143 #define ObjDndFlagDropTypesNBITS        (4)             /* num bits */
4144 #define ObjDndFlagDropOnChildOK         (((unsigned)0x0001)<<17)
4145
4146
4147 int
4148 obj_set_drag_cursor(ABObj obj, STRING filename)
4149 {
4150     verify_for_write(obj);
4151     istr_destroy(obj->drag_cursor);
4152     obj->drag_cursor = istr_create(filename);
4153     return 0;
4154 }
4155
4156 STRING
4157 obj_get_drag_cursor(ABObj obj)
4158 {
4159     verify_for_read(obj);
4160     return istr_string(obj->drag_cursor);
4161 }
4162
4163 int
4164 obj_set_drag_cursor_mask(ABObj obj, STRING filename)
4165 {
4166     verify_for_write(obj);
4167     istr_destroy(obj->drag_cursor_mask);
4168     obj->drag_cursor_mask = istr_create(filename);
4169     return 0;
4170 }
4171
4172 STRING
4173 obj_get_drag_cursor_mask(ABObj obj)
4174 {
4175     verify_for_read(obj);
4176     return istr_string(obj->drag_cursor_mask);
4177 }
4178
4179 int
4180 obj_set_drag_initially_enabled(ABObj obj, BOOL enabled)
4181 {
4182     obj->impl_dnd_flags &= ~ObjDndFlagDragEnabled;
4183     if (enabled)
4184     {
4185         obj->impl_dnd_flags |= ObjDndFlagDragEnabled;
4186     }
4187     return 0;
4188 }
4189
4190 BOOL
4191 obj_get_drag_initially_enabled(ABObj obj)
4192 {
4193     return ((obj->impl_dnd_flags & ObjDndFlagDragEnabled) != 0);
4194 }
4195
4196 int
4197 obj_set_drag_to_root_allowed(ABObj obj, BOOL allowed)
4198 {
4199     obj->impl_dnd_flags &= ~ObjDndFlagDragToRootOK;
4200     if (allowed)
4201     {
4202         obj->impl_dnd_flags |= ObjDndFlagDragToRootOK;
4203     }
4204     return 0;
4205 }
4206
4207 BOOL
4208 obj_get_drag_to_root_allowed(ABObj obj)
4209 {
4210     return ((obj->impl_dnd_flags & ObjDndFlagDragToRootOK) != 0);
4211 }
4212
4213
4214 int
4215 obj_set_drag_ops(ABObj obj, BYTE dragOps)
4216 {
4217     obj->impl_dnd_flags &= ~(0x07U<<ObjDndFlagDragOpsFBIT);
4218     obj->impl_dnd_flags |= ((dragOps & 0x07)<<ObjDndFlagDragOpsFBIT);
4219     return 0;
4220 }
4221
4222
4223 BYTE
4224 obj_get_drag_ops(ABObj obj)
4225 {
4226     return (BYTE)((obj->impl_dnd_flags >> ObjDndFlagDragOpsFBIT) & 0x07);
4227 }
4228
4229
4230 int
4231 obj_set_drag_types(ABObj obj, BYTE dragTypes)
4232 {
4233     obj->impl_dnd_flags &= ~(0x0fU<<ObjDndFlagDragTypesFBIT);
4234     obj->impl_dnd_flags |= ((dragTypes & 0x0f) << ObjDndFlagDragTypesFBIT);
4235     return 0;
4236 }
4237
4238
4239 BYTE
4240 obj_get_drag_types(ABObj obj)
4241 {
4242     return (BYTE)((obj->impl_dnd_flags >> ObjDndFlagDragTypesFBIT) & 0x0f);
4243 }
4244
4245 int
4246 obj_set_drop_initially_enabled(ABObj obj, BOOL enabled)
4247 {
4248     obj->impl_dnd_flags &= ~ObjDndFlagDropEnabled;
4249     if (enabled)
4250     {
4251         obj->impl_dnd_flags |= ObjDndFlagDropEnabled;
4252     }
4253     return 0;
4254 }
4255
4256 BOOL
4257 obj_get_drop_initially_enabled(ABObj obj)
4258 {
4259     return ((obj->impl_dnd_flags & ObjDndFlagDropEnabled) != 0);
4260 }
4261
4262 int
4263 obj_set_drop_ops(ABObj obj, BYTE dropOps)
4264 {
4265     obj->impl_dnd_flags &= ~(0x07U<<ObjDndFlagDropOpsFBIT);
4266     obj->impl_dnd_flags |= ((dropOps & 0x07)<<ObjDndFlagDropOpsFBIT);
4267     return 0;
4268 }
4269
4270
4271 BYTE
4272 obj_get_drop_ops(ABObj obj)
4273 {
4274     return (BYTE)((obj->impl_dnd_flags >> ObjDndFlagDropOpsFBIT) & 0x07);
4275 }
4276
4277
4278 int
4279 obj_set_drop_types(ABObj obj, BYTE dropTypes)
4280 {
4281     obj->impl_dnd_flags &= ~(0x0fU<<ObjDndFlagDropTypesFBIT);
4282     obj->impl_dnd_flags |= ((dropTypes & 0x0f) << ObjDndFlagDropTypesFBIT);
4283     return 0;
4284 }
4285
4286
4287 BYTE
4288 obj_get_drop_types(ABObj obj)
4289 {
4290     return (BYTE)((obj->impl_dnd_flags >> ObjDndFlagDropTypesFBIT) & 0x0f);
4291 }
4292
4293
4294 int
4295 obj_set_drop_on_children_is_allowed(ABObj obj, BOOL allowed)
4296 {
4297     obj->impl_dnd_flags &= ~ObjDndFlagDropOnChildOK;
4298     if (allowed)
4299     {
4300         obj->impl_dnd_flags |= ObjDndFlagDropOnChildOK;
4301     }
4302     return 0;
4303 }
4304
4305 BOOL
4306 obj_drop_on_children_is_allowed(ABObj obj)
4307 {
4308     return ((obj->impl_dnd_flags & ObjDndFlagDropOnChildOK) != 0);
4309 }
4310