2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
25 * $XConsortium: pal_group.c /main/6 1996/08/30 14:01:29 mustafa $
27 * @(#)pal_group.c 1.58 08 May 1995
29 * RESTRICTED CONFIDENTIAL INFORMATION:
31 * The information in this document is subject to special
32 * restrictions in a confidential disclosure agreement between
33 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
34 * document outside HP, IBM, Sun, USL, SCO, or Univel without
35 * Sun's specific written approval. This document and all copies
36 * and derivative works thereof must be returned or destroyed at
39 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
45 * pal_group.c - Implements Group object functionality
52 #include <ab_private/ab.h>
53 #include <ab_private/trav.h>
54 #include <ab_private/pal.h>
55 #include <ab_private/prop.h>
56 #include <ab_private/brws.h>
57 #include <ab_private/abobj.h>
58 #include <ab_private/objxm.h>
59 #include <ab_private/abobj_set.h>
60 #include <ab_private/proj.h>
61 #include <ab_private/ui_util.h>
62 #include <ab_private/x_util.h>
63 #include <ab_private/abobj_edit.h>
64 #include "dtbuilder.h"
72 #include "bitmaps/ggp_as_is.xbm"
73 #include "bitmaps/ggp_col.xbm"
74 #include "bitmaps/ggp_row.xbm"
75 #include "bitmaps/ggp_rowcol.xbm"
76 #include "bitmaps/align_top.xbm"
77 #include "bitmaps/align_hcenter.xbm"
78 #include "bitmaps/align_bottom.xbm"
79 #include "bitmaps/align_left.xbm"
80 #include "bitmaps/align_labels.xbm"
81 #include "bitmaps/align_vcenter.xbm"
82 #include "bitmaps/align_right.xbm"
92 typedef struct PROP_GROUP_SETTINGS
95 PropFieldSettingRec name;
96 PropOptionsSettingRec frame;
97 PropRadioSettingRec layout_type;
98 PropRadioSettingRec grid_rowcol;
99 PropFieldSettingRec grid_rowcol_count;
100 PropOptionsSettingRec valign;
101 PropFieldSettingRec vspacing;
102 PropOptionsSettingRec halign;
103 PropFieldSettingRec hspacing;
104 PropGeometrySettingRec pos;
105 PropCheckboxSettingRec init_state;
106 PropColorSettingRec bg_color;
108 } PropGroupSettingsRec, *PropGroupSettings;
110 /*************************************************************************
112 ** Private Function Declarations **
114 **************************************************************************/
118 static int group_initialize(
121 static Widget group_prop_init(
126 static int group_prop_activate(
130 static int group_prop_load(
133 unsigned long loadkey
135 static int group_prop_clear(
138 static int group_prop_apply(
142 static BOOL group_prop_pending(
146 static BOOL verify_props(
149 static void turnoff_changebars(
152 static void setup_grouptype_settings(
156 static void set_new_group_size(
160 static void group_objects(
166 static void ungroup_objects(
171 static void group_align_tops(
175 static void group_align_hcenters(
180 static void group_align_horiz_same_size(
184 static void group_align_bottoms(
188 static void group_align_left(
192 static void group_align_labels(
196 static void group_align_vcenters(
201 static void group_align_right(
205 static void create_member_list(
211 static void get_cell_size(
217 static void get_row_col(
223 static void group_align_rows(
228 static void group_align_cols(
233 static void get_widest_label_obj(
240 static void get_widest_value_obj(
250 static void grouptypeCB(
252 XtPointer clientdata,
253 XmToggleButtonCallbackStruct *state
256 static void undo_group(
260 static void undo_ungroup(
264 static ABObj get_child(
270 static void group_expose_handler(
272 XtPointer client_data,
274 Boolean *cont_dispatch
277 DtbGroupPropDialogInfoRec rev_group_prop_dialog;
279 /*************************************************************************
283 **************************************************************************/
284 PalItemInfo group_palitem_rec = {
285 /* type */ AB_TYPE_CONTAINER,
287 /* animation pixmaps*/ NULL,
288 /* number of pixmaps*/ 0,
289 /* rev_prop_frame */ NULL,
290 /* fix_prop_dialog */ NULL,
291 /* initialize */ group_initialize,
292 /* is_a_test */ obj_is_group,
293 /* prop_initialize */ group_prop_init,
294 /* prop_active */ group_prop_activate,
295 /* prop_clear */ group_prop_clear,
296 /* prop_load */ group_prop_load,
297 /* prop_apply */ group_prop_apply,
298 /* prop_pending */ group_prop_pending
301 PalItemInfo *ab_group_palitem = &group_palitem_rec;
302 PropGroupSettingsRec prop_group_settings_rec[AB_PROP_TYPE_NUM_VALUES];
304 /*************************************************************************
306 ** Function Definitions **
308 **************************************************************************/
311 * Create a group object out of the selected group of objects.
314 abobj_group_selected_objects(
317 ABObj project = proj_get_project();
322 XRectangle current_rect;
325 /* Creation may take awhile, so set busy cursor */
326 ab_set_busy_cursor(True);
328 abobj_get_selected(project, False, False, &sel);
329 abobj_get_rect_for_objects(sel.list, sel.count, ¤t_rect);
330 obj_parent = obj_get_parent(sel.list[0]);
332 newgroup = obj_create(AB_TYPE_CONTAINER, obj_parent);
333 obj_set_subtype(newgroup, AB_CONT_GROUP);
335 if (group_initialize(newgroup) == ERROR)
336 fprintf(stderr, "create_obj_action: couldn't initialize object\n");
337 else if (abobj_show_tree(newgroup, False) == -1)
338 fprintf(stderr,"create_obj_action: couldn't show object\n");
342 /* Deselect any objects that happen to be selected */
343 abobj_deselect_all(project);
344 aob_deselect_all_objects(project);
346 group_objects(newgroup, sel.list, sel.count);
349 * Can only create one group at a time, therefore
350 * only worry about undoing one group.
352 abobj_set_undo(&newgroup, 1, undo_group, AB_UNDO_GROUP);
356 /* Restore to original cursor */
357 ab_set_busy_cursor(False);
370 XRectangle current_rect;
373 abobj_get_rect_for_objects(list, count, ¤t_rect);
376 * Reparent each selected object and set x,y to group
379 for (i = 0; i < count; i++)
382 ABObj cur_obj = NULL;
385 obj_reparent(obj, newgroup);
386 abobj_set_xy(obj, obj_get_x(obj) - current_rect.x,
387 obj_get_y(obj) - current_rect.y);
389 * Clear instantiated flag in child
391 obj_clear_flag(obj, InstantiatedFlag);
394 * Clear instantiated flag in child subtree as
397 for (trav_open(&trav, obj, AB_TRAV_ALL);
398 (cur_obj = trav_next(&trav)) != NULL; )
400 obj_clear_flag(cur_obj, InstantiatedFlag);
407 * For some reason, width and height need to be set on the
411 obj_set_width(newgroup, current_rect.width);
412 obj_set_height(newgroup, current_rect.height);
415 abobj_tree_instantiate_changes(newgroup);
417 /* Make the new obj selected */
418 abobj_select(newgroup);
424 * Ungroup a group. Get list of selected objects, look for groups
425 * in the list. If found, traverse throught the groups children and
426 * re-parent/re-position the child. Finally, keep a list of new parents
427 * to be updated (so that no parent is updated more than once) and update
428 * them after all groups have been ungrouped.
431 abobj_ungroup_selected_objects(
434 ABObj project = proj_get_project();
437 /* Ungrouping may take awhile, so set busy cursor */
438 ab_set_busy_cursor(True);
440 /* Get list of selected objects */
441 abobj_get_selected(project, False, False, &sel);
444 * Remember all objects that were ungrouped so can undo this later
446 abobj_set_undo(sel.list, sel.count, undo_ungroup, AB_UNDO_UNGROUP);
448 ungroup_objects(sel.list, sel.count);
450 /* Restore to original cursor */
451 ab_set_busy_cursor(False);
455 * Ungroups passed objects. Look for groups in the list. If found,
456 * traverse throught the groups children and re-parent/re-position the
457 * child. Finally, keep a list of new parents to be updated so that
458 * no parent is updated more than once and update them after all groups
459 * have been ungrouped.
469 ABObj parent_list = NULL;
470 XRectangle group_rect,
477 Boolean parent_exists = True;
479 if (!obj_list || (count <= 0))
482 for (i = 0; i < count; i++)
485 if (obj_is_group(group))
492 abobj_deselect(group);
493 group_parent = obj_get_parent(group);
496 * Remember group's position
498 group_rect.x = group_rect.y = 0;
499 x_get_widget_rect(objxm_get_widget(group), &group_rect);
501 oobj = objxm_comp_get_subobj(group, AB_CFG_OBJECT_OBJ);
502 num_children = obj_get_num_children(oobj);
504 member_list = (ABObj *)util_malloc(num_children * sizeof(ABObj*));
507 * Group members are all direct children of the AB_CFG_OBJECT_OBJ
510 for (trav_open(&trav, oobj, AB_TRAV_CHILDREN |
512 (member = trav_next(&trav)) != NULL; )
516 member_w = objxm_get_widget(member);
519 * Get member's current position
522 x_get_widget_rect(member_w, &rect);
524 obj_reparent(member, group_parent);
527 * Set attachments with 0 x and y. abobj_set_xy will
528 * set the correct values.
530 obj_init_attachments(member);
531 obj_set_attachment(member, AB_CP_NORTH, AB_ATTACH_POINT,
533 obj_set_attachment(member, AB_CP_WEST, AB_ATTACH_POINT,
537 * Set new position to be:
538 * group's (x, y) + current (x, y)
540 abobj_set_xy(member, group_rect.x + rect.x,
541 group_rect.y + rect.y);
544 * Keep track of objects to re-instantiate later
545 * We don't do it here because we don't want to screw up
546 * the x_get_widget_rect() calls in the current group.
548 member_list[cur_member++] = member;
554 * Un/re-instantiate former group members
556 for (cur_member = 0; cur_member < num_children; ++cur_member)
558 ABObj cur_obj = NULL;
561 * Clear instantiated flag in former group member
563 obj_clear_flag(member_list[cur_member], InstantiatedFlag);
566 * Clear instantiated flag in former group member's subtree
569 for (trav_open(&trav, member_list[cur_member], AB_TRAV_ALL);
570 (cur_obj = trav_next(&trav)) != NULL; )
572 obj_clear_flag(cur_obj, InstantiatedFlag);
576 * The manage_lat parameter used to be FALSE.
577 * It caused list objects to get the wrong size when
578 * ungroup was done. Changing to TRUE somehow fixes
581 abobj_show_tree(member_list[cur_member], TRUE);
584 util_free(member_list);
589 * Keep a list of parents (control panels) that need
590 * to be updated after all groups are ungrouped.
594 list = (ABObj*)XtMalloc(sizeof(ABObj));
595 list[0] = group_parent;
599 for (j = 0; j < list_items; j++)
601 if (list[j] == group_parent)
603 parent_exists = True;
607 if (parent_exists == False)
609 XtRealloc((char*)list, sizeof(ABObj));
610 list[list_items++] = group_parent;
612 parent_exists = False;
624 AB_GROUP_TYPE group_type;
626 ABObj parent = obj_get_parent(obj);
628 XRectangle current_rect;
631 abobj_get_selected(proj_get_project(), False, False, &sel);
632 abobj_get_rect_for_objects(sel.list, sel.count, ¤t_rect);
634 obj_set_unique_name(obj, "group");
637 abobj_set_initial_state(obj, AB_STATE_ACTIVE);
639 obj_set_is_initially_active(obj, True);
641 obj_set_x(obj, current_rect.x);
642 obj_set_y(obj, current_rect.y);
644 obj_set_width(obj, current_rect.width);
645 obj_set_height(obj, current_rect.height);
648 obj_set_group_type(obj, AB_GROUP_IGNORE);
650 /* Set up Default Layout for group*/
651 obj_set_attachment(obj, AB_CP_NORTH, AB_ATTACH_POINT, NULL, obj->y);
652 obj_set_attachment(obj, AB_CP_WEST, AB_ATTACH_POINT, NULL, obj->x);
665 /* Revolving Props */
667 DtbGroupPropDialogInfoRec rev_group_prop_dialog;
669 DtbGroupPropDialogInfo cgen = &dtb_group_prop_dialog; /* Codegen structure */
670 DtbRevolvPropDialogInfo rpd = &(dtb_revolv_prop_dialog);
671 PropGroupSettingsRec *pgs = &(prop_group_settings_rec[type]);
677 if (type == AB_PROP_REVOLVING)
680 * Only the Attributes ControlPanel needs to be created within
681 * the existing Revolving Prop dialog, so fill out all other
682 * fields with the Revolving Prop dialog equivelents, so the
683 * dtb initialize proc will skip those non-NULL fields...
685 dtbGroupPropDialogInfo_clear(&rev_group_prop_dialog);
687 cgen = &(rev_group_prop_dialog);
688 cgen->prop_dialog = rpd->prop_dialog;
689 cgen->prop_dialog_shellform = rpd->prop_dialog_shellform;
690 cgen->prop_dialog_panedwin = rpd->prop_dialog_panedwin;
691 cgen->prop_dialog_form = rpd->prop_dialog_form;
692 cgen->objlist_panel = rpd->objlist_panel;
693 cgen->objlist_label = rpd->objlist_label2;
694 cgen->objlist_scrolledwin = rpd->objlist_scrolledwin;
695 cgen->objlist = rpd->objlist;
696 cgen->attrs_ctrlpanel_frame = rpd->attrs_ctrlpanel_frame;
697 cgen->activate_panel = rpd->activate_panel;
698 cgen->apply_button = rpd->apply_button;
699 cgen->ok_button = rpd->ok_button;
700 cgen->cancel_button = rpd->cancel_button;
701 cgen->reset_button = rpd->reset_button;
702 cgen->help_button = rpd->help_button;
705 else /* AB_PROP_FIXED */
706 cgen = &dtb_group_prop_dialog;
708 if (dtb_group_prop_dialog_initialize(cgen, parent) == 0)
710 pgs->prop_sheet = cgen->attrs_ctrlpanel;
711 pgs->current_obj = NULL;
713 if (type == AB_PROP_REVOLVING)
714 XtVaSetValues(parent,
715 XmNuserData, pgs->current_obj,
718 /* Dialog/Object List */
719 if (type == AB_PROP_FIXED)
721 prop_fixed_dialog_init(ab_group_palitem,
722 cgen->prop_dialog_shellform, cgen->objlist);
723 prop_activate_panel_init(type, ab_group_palitem,
724 cgen->ok_button, cgen->apply_button,
725 cgen->reset_button, cgen->cancel_button,
729 /* Alternate Editor Buttons */
730 prop_editors_panel_init(type, ab_group_palitem,
731 cgen->attach_button, cgen->conn_button, cgen->helptxt_button);
734 * Prop Sheet Settings....
738 prop_field_init(&(pgs->name), cgen->name_field_label,
739 cgen->name_field, cgen->name_cb);
741 /* Border Frame Setting */
743 item[n] = cgen->bframe_opmenu_items.None_item;
744 item_val[n] = AB_LINE_NONE; n++;
745 item[n] = cgen->bframe_opmenu_items.Shadow_Out_item;
746 item_val[n] = AB_LINE_SHADOW_OUT; n++;
747 item[n] = cgen->bframe_opmenu_items.Shadow_In_item;
748 item_val[n] = AB_LINE_SHADOW_IN; n++;
749 item[n] = cgen->bframe_opmenu_items.Etched_Out_item;
750 item_val[n] = AB_LINE_ETCHED_OUT; n++;
751 item[n] = cgen->bframe_opmenu_items.Etched_In_item;
752 item_val[n] = AB_LINE_ETCHED_IN; n++;
753 prop_options_init(&(pgs->frame), cgen->bframe_opmenu_label,
754 cgen->bframe_opmenu, cgen->bframe_opmenu_menu,
755 n, item, (XtPointer*)item_val,
760 item[n] = cgen->layout_rbox_items.bitmaps_ggp_as_is_xbm_item;
761 item_val[n] = AB_GROUP_IGNORE; n++;
762 item[n] = cgen->layout_rbox_items.bitmaps_ggp_col_xbm_item;
763 item_val[n] = AB_GROUP_COLUMNS; n++;
764 item[n] = cgen->layout_rbox_items.bitmaps_ggp_row_xbm_item;
765 item_val[n] = AB_GROUP_ROWS; n++;
766 item[n] = cgen->layout_rbox_items.bitmaps_ggp_rowcol_xbm_item;
767 item_val[n] = AB_GROUP_ROWSCOLUMNS; n++;
768 prop_radiobox_init(&(pgs->layout_type), cgen->layout_rbox_label,
769 cgen->layout_rbox, n, item, (XtPointer*)item_val,
772 for (i=0; i < n; i++)
773 XtAddCallback(item[i], XmNvalueChangedCallback,
774 (XtCallbackProc)grouptypeCB, (XtPointer)type);
777 ui_set_active(cgen->layout_rbox_items.bitmaps_ggp_rowcol_xbm_item, False);
780 /* Grid Row/Columns */
782 item[n] = cgen->gridrowcol_rbox_items.Rows_item;
783 item_val[n] = AB_ORIENT_HORIZONTAL; n++;
784 item[n] = cgen->gridrowcol_rbox_items.Columns_item;
785 item_val[n] = AB_ORIENT_VERTICAL; n++;
786 prop_radiobox_init(&(pgs->grid_rowcol), NULL,
787 cgen->gridrowcol_rbox, n, item, (XtPointer*)item_val,
788 cgen->gridrowcol_cb);
790 /* Grid Row/Column count */
791 prop_field_init(&(pgs->grid_rowcol_count), NULL,
792 cgen->gridrowcol_field, cgen->gridrowcol_cb);
794 /* Vertical Alignment */
796 item[n] = cgen->valign_opmenu_items.bitmaps_align_left_xbm_item;
797 item_val[n] = AB_ALIGN_LEFT; n++;
798 item[n] = cgen->valign_opmenu_items.bitmaps_align_labels_xbm_item;
799 item_val[n] = AB_ALIGN_LABELS; n++;
800 item[n] = cgen->valign_opmenu_items.bitmaps_align_vcenter_xbm_item;
801 item_val[n] = AB_ALIGN_VCENTER; n++;
802 item[n] = cgen->valign_opmenu_items.bitmaps_align_right_xbm_item;
803 item_val[n] = AB_ALIGN_RIGHT; n++;
804 prop_options_init(&(pgs->valign), cgen->valign_opmenu_label,
805 cgen->valign_opmenu, cgen->valign_opmenu_menu,
806 n, item, (XtPointer*)item_val,
809 /* Vertical spacing value */
810 prop_field_init(&(pgs->vspacing), NULL,
811 cgen->vert_spacing_field, cgen->valign_cb);
813 /* Horizontal Alignment */
815 item[n] = cgen->halign_opmenu_items.bitmaps_align_top_xbm_item;
816 item_val[n] = AB_ALIGN_TOP; n++;
817 item[n] = cgen->halign_opmenu_items.bitmaps_align_hcenter_xbm_item;
818 item_val[n] = AB_ALIGN_HCENTER; n++;
819 item[n] = cgen->halign_opmenu_items.bitmaps_align_bottom_xbm_item;
820 item_val[n] = AB_ALIGN_BOTTOM; n++;
821 prop_options_init(&(pgs->halign), cgen->halign_opmenu_label,
822 cgen->halign_opmenu, cgen->halign_opmenu_menu,
823 n, item, (XtPointer*)item_val,
826 /* Horizontal spacing value */
827 prop_field_init(&(pgs->hspacing), NULL,
828 cgen->horiz_spacing_field, cgen->halign_cb);
831 prop_geomfield_init(&(pgs->pos), cgen->pos_label,
832 cgen->x_field_label, cgen->x_field,
833 cgen->y_field_label, cgen->y_field,
834 NULL, NULL, NULL, NULL,
839 item[n] = cgen->istate_ckbox_items.Visible_item;
840 item_val[n] = AB_STATE_VISIBLE; n++;
841 item[n] = cgen->istate_ckbox_items.Active_item;
842 item_val[n] = AB_STATE_ACTIVE; n++;
843 prop_checkbox_init(&(pgs->init_state), cgen->istate_ckbox_label,
844 cgen->istate_ckbox, n, item, item_val,
848 prop_colorfield_init(&(pgs->bg_color), cgen->bg_mbutton,
849 cgen->bg_mbutton_bg_mbutton_menu_items.None_item,
850 cgen->bg_mbutton_bg_mbutton_menu_items.Color_Chooser_item,
851 cgen->bg_swatch, cgen->bg_field, cgen->bg_cb);
853 prop_changebars_cleared(pgs->prop_sheet);
855 return (cgen->prop_dialog_shellform);
867 PropGroupSettingsRec *pgs = &(prop_group_settings_rec[type]);
869 if (pgs->current_obj == NULL)
873 prop_field_set_value(&(pgs->name), "", False);
875 /* Clear Border Frame */
876 prop_options_set_value(&(pgs->frame), (XtPointer)AB_LINE_NONE, False);
878 /* Clear Layout Type */
879 prop_radiobox_set_value(&(pgs->layout_type),
880 (XtPointer)AB_GROUP_IGNORE, False);
882 /* Clear Grid Rows/Columns */
883 prop_radiobox_set_value(&(pgs->grid_rowcol),
884 (XtPointer)AB_ORIENT_HORIZONTAL, False);
885 prop_field_set_numeric_value(&(pgs->grid_rowcol_count), NUMROWCOL, False);
887 /* Clear Vertical Alignment */
888 prop_options_set_value(&(pgs->valign), (XtPointer)AB_ALIGN_LEFT, False);
889 prop_field_set_numeric_value(&(pgs->vspacing), 0, False);
891 /* Clear Horizontal Alignment */
892 prop_options_set_value(&(pgs->halign), (XtPointer)AB_ALIGN_TOP, False);
893 prop_field_set_numeric_value(&(pgs->hspacing), 0, False);
895 /* Clear Object Size */
897 /* Clear Object Resizing */
900 prop_geomfield_clear(&(pgs->pos), GEOM_X);
901 prop_geomfield_clear(&(pgs->pos), GEOM_Y);
903 /* Clear Initial State */
904 prop_checkbox_set_value(&(pgs->init_state), AB_STATE_VISIBLE, True, False);
905 prop_checkbox_set_value(&(pgs->init_state), AB_STATE_ACTIVE, True, False);
908 prop_colorfield_set_value(&(pgs->bg_color), "", False);
910 pgs->current_obj = NULL;
912 turnoff_changebars(type);
925 ui_set_active(prop_group_settings_rec[type].prop_sheet, active);
935 unsigned long loadkey
938 PropGroupSettingsRec *pgs = &(prop_group_settings_rec[type]);
940 BOOL load_all = (loadkey & LoadAll);
944 if (pgs->current_obj != NULL)
945 obj = pgs->current_obj;
949 else if (!obj_is_group(obj))
952 pgs->current_obj = obj;
955 if (load_all || loadkey & LoadName)
956 prop_field_set_value(&(pgs->name), obj_get_name(obj), False);
960 /* Load Border Frame */
961 prop_options_set_value(&(pgs->frame), (XtPointer)obj_get_border_frame(obj), False);
963 /* Load Layout Type */
964 gtype = obj_get_group_type(obj);
965 prop_radiobox_set_value(&(pgs->layout_type), (XtPointer)gtype, False);
966 setup_grouptype_settings(type, gtype);
968 /* Load Alignment, Grid-Rows/Columns */
972 case AB_GROUP_IGNORE:
973 prop_radiobox_set_value(&(pgs->spacing_type),
974 AB_ATTACH_OBJ, False);
975 prop_field_set_numeric_value(&(pgs->spacing),
981 prop_options_set_value(&(pgs->halign),
982 (XtPointer)obj_get_row_align(obj), False);
984 prop_field_set_numeric_value(&(pgs->hspacing),
985 obj_get_hoffset(obj), False);
988 case AB_GROUP_COLUMNS:
989 prop_options_set_value(&(pgs->valign),
990 (XtPointer)obj_get_col_align(obj), False);
992 prop_field_set_numeric_value(&(pgs->vspacing),
993 obj_get_voffset(obj), False);
995 case AB_GROUP_ROWSCOLUMNS:
996 if (obj_get_num_rows(obj) ||
997 (!obj_get_num_rows(obj) &&
998 !obj_get_num_columns(obj)))
1000 prop_radiobox_set_value(&(pgs->grid_rowcol),
1001 (XtPointer)AB_ORIENT_HORIZONTAL, False);
1002 prop_field_set_numeric_value(&(pgs->grid_rowcol_count),
1003 obj_get_num_rows(obj), False);
1007 prop_radiobox_set_value(&(pgs->grid_rowcol),
1008 (XtPointer)AB_ORIENT_VERTICAL, False);
1009 prop_field_set_numeric_value(&(pgs->grid_rowcol_count),
1010 obj_get_num_columns(obj), False);
1013 prop_options_set_value(&(pgs->halign),
1014 (XtPointer)obj_get_row_align(obj), False);
1016 prop_field_set_numeric_value(&(pgs->hspacing),
1017 obj_get_hoffset(obj), False);
1019 prop_options_set_value(&(pgs->valign),
1020 (XtPointer)obj_get_col_align(obj), False);
1022 prop_field_set_numeric_value(&(pgs->vspacing),
1023 obj_get_voffset(obj), False);
1028 /* Load Object Size */
1030 /* Load Object Resizing */
1032 /* Load Initial State */
1033 prop_checkbox_set_value(&(pgs->init_state), AB_STATE_VISIBLE,
1034 obj_is_initially_visible(obj), False);
1035 prop_checkbox_set_value(&(pgs->init_state), AB_STATE_ACTIVE,
1036 obj_is_initially_active(obj), False);
1039 prop_colorfield_set_value(&(pgs->bg_color), obj_get_bg_color(obj), False);
1041 turnoff_changebars(type);
1045 if (load_all || loadkey & LoadPosition)
1046 prop_load_obj_position(obj, &(pgs->pos));
1057 PropGroupSettingsRec *pgs = &(prop_group_settings_rec[type]);
1059 AB_GROUP_TYPE gtype;
1064 BOOL changed = False;
1065 BOOL reset_bg = False;
1067 obj = pgs->current_obj;
1068 gtype = (AB_GROUP_TYPE)prop_radiobox_get_value(&(pgs->layout_type));
1073 if (!verify_props(type))
1076 if (prop_changed(pgs->name.changebar))
1078 value = prop_field_get_value(&(pgs->name));
1079 abobj_set_name(pgs->current_obj, value);
1083 * Set rows/columns based on new layout type. If we are
1084 * changing from AB_GROUP_IGNORE to something else, we need
1085 * to sort the children so that the group comes out looking
1086 * close to the initial layout, regardless of the order of
1089 if (prop_changed(pgs->layout_type.changebar))
1095 case AB_GROUP_IGNORE:
1096 abobj_set_num_rows(obj, 0);
1097 abobj_set_num_columns(obj, 0);
1102 abobj_set_num_rows(obj, 1);
1103 abobj_set_num_columns(obj, 0);
1104 if (obj_get_group_type(obj) == AB_GROUP_IGNORE)
1105 abobj_sort_children(obj, XSORT);
1107 * If changing types, set defaults for row stuff
1108 * in case the user doesn't change them.
1110 if (obj_get_group_type(obj) != AB_GROUP_ROWS)
1112 abobj_set_row_alignment(obj, AB_ALIGN_TOP);
1113 abobj_set_row_attach_type(obj, AB_ATTACH_OBJ);
1114 abobj_set_row_offset(obj, HOFFSET);
1118 case AB_GROUP_COLUMNS:
1119 abobj_set_num_rows(obj, 0);
1120 abobj_set_num_columns(obj, 1);
1121 if (obj_get_group_type(obj) == AB_GROUP_IGNORE)
1122 abobj_sort_children(obj, YSORT);
1124 * If changing types, set defaults for column stuff
1125 * in case the user doesn't change them.
1127 if (obj_get_group_type(obj) != AB_GROUP_COLUMNS)
1129 abobj_set_col_alignment(obj, AB_ALIGN_LEFT);
1130 abobj_set_col_attach_type(obj, AB_ATTACH_OBJ);
1131 abobj_set_col_offset(obj, VOFFSET);
1137 case AB_GROUP_ROWSCOLUMNS:
1139 num_rc = prop_field_get_numeric_value(&(pgs->grid_rowcol_count));
1141 if (prop_radiobox_get_value(&(pgs->grid_rowcol))
1142 == AB_ORIENT_HORIZONTAL)
1144 abobj_set_num_rows(obj, num_rc < 2 ? 2 : num_rc);
1145 abobj_set_num_columns(obj, 0);
1146 if (obj_get_group_type(obj) == AB_GROUP_IGNORE)
1147 abobj_sort_children(obj, YSORT);
1151 abobj_set_num_columns(obj, num_rc < 2 ? 2 : num_rc);
1152 abobj_set_num_rows(obj, 0);
1153 if (obj_get_group_type(obj) == AB_GROUP_IGNORE)
1154 abobj_sort_children(obj, XSORT);
1157 * If changing types, set defaults for row/column stuff
1158 * in case the user doesn't change them.
1160 if (obj_get_group_type(obj) != AB_GROUP_ROWSCOLUMNS)
1163 abobj_set_row_alignment(obj, AB_ALIGN_TOP);
1164 abobj_set_row_attach_type(obj, AB_ATTACH_OBJ);
1165 abobj_set_row_offset(obj, HOFFSET);
1167 abobj_set_col_alignment(obj, AB_ALIGN_LEFT);
1168 abobj_set_col_attach_type(obj, AB_ATTACH_OBJ);
1169 abobj_set_col_offset(obj, VOFFSET);
1173 abobj_set_row_alignment(obj,
1174 (AB_ALIGNMENT)prop_options_get_value(&(pgs->halign)));
1175 abobj_set_row_attach_type(obj,
1176 (AB_ATTACH_TYPE)prop_options_get_value(&(pgs->hspacing_type)));
1177 abobj_set_row_offset(obj,
1178 prop_field_get_numeric_value(&(pgs->hspacing)));
1180 abobj_set_col_alignment(obj,
1181 (AB_ALIGNMENT)prop_options_get_value(&(pgs->valign)));
1182 abobj_set_col_attach_type(obj,
1183 (AB_ATTACH_TYPE)prop_options_get_value(&(pgs->vspacing_type)));
1184 abobj_set_col_offset(obj,
1185 prop_field_get_numeric_value(&(pgs->vspacing)));
1190 abobj_set_group_type(obj, gtype);
1192 if (prop_changed(pgs->grid_rowcol_count.changebar))
1199 num_rc = prop_field_get_numeric_value(&(pgs->grid_rowcol_count));
1200 if (prop_radiobox_get_value(&(pgs->grid_rowcol))
1201 == AB_ORIENT_HORIZONTAL)
1203 abobj_set_num_rows(obj, num_rc < 2 ? 2 : num_rc);
1204 abobj_set_num_columns(obj, 0);
1205 if (obj_get_group_type(obj) == AB_GROUP_IGNORE)
1206 abobj_sort_children(obj, YSORT);
1210 abobj_set_num_columns(obj, num_rc < 2 ? 2 : num_rc);
1211 abobj_set_num_rows(obj, 0);
1212 if (obj_get_group_type(obj) == AB_GROUP_IGNORE)
1213 abobj_sort_children(obj, XSORT);
1216 if (prop_changed(pgs->halign.changebar))
1220 abobj_set_row_alignment(obj,
1221 (AB_ALIGNMENT)prop_options_get_value(&(pgs->halign)));
1223 space_val = prop_field_get_numeric_value(&(pgs->hspacing));
1225 abobj_set_row_offset(obj, space_val);
1227 if (prop_changed(pgs->valign.changebar))
1230 abobj_set_col_alignment(obj,
1231 (AB_ALIGNMENT)prop_options_get_value(&(pgs->valign)));
1233 space_val = prop_field_get_numeric_value(&(pgs->vspacing));
1235 abobj_set_col_offset(obj, space_val);
1240 ABObj oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1241 Widget w = objxm_get_widget(oobj);
1242 WidgetList children_list = NULL;
1243 int num_children = 0;
1246 XmNnumChildren, &num_children,
1247 XmNchildren, &children_list,
1250 XtUnmanageChildren(children_list, num_children);
1252 abobj_layout_group(obj, FALSE);
1254 XtManageChildren(children_list, num_children);
1257 /* Border Frame and Margin */
1258 if (prop_changed(pgs->frame.changebar))
1260 abobj_set_border_frame(pgs->current_obj,
1261 (AB_LINE_TYPE)prop_options_get_value(&(pgs->frame)));
1263 if (prop_changed(pgs->pos.changebar))
1265 if (abobj_is_movable(pgs->current_obj))
1266 abobj_set_xy(pgs->current_obj,
1267 prop_geomfield_get_value(&(pgs->pos), GEOM_X),
1268 prop_geomfield_get_value(&(pgs->pos), GEOM_Y));
1270 if (prop_changed(pgs->init_state.changebar))
1272 abobj_set_visible(pgs->current_obj,
1273 prop_checkbox_get_value(&(pgs->init_state), AB_STATE_VISIBLE));
1274 abobj_set_active(pgs->current_obj,
1275 prop_checkbox_get_value(&(pgs->init_state), AB_STATE_ACTIVE));
1277 if (prop_changed(pgs->bg_color.changebar))
1279 value = prop_colorfield_get_value(&(pgs->bg_color));
1280 abobj_set_background_color(pgs->current_obj, value);
1281 if (util_strempty(value))
1284 prop_colorfield_set_value(&(pgs->bg_color),
1285 obj_get_bg_color(pgs->current_obj), False);
1288 abobj_tree_instantiate_changes(pgs->current_obj);
1290 if (reset_bg) /* Set back to No Color */
1291 abobj_reset_colors(pgs->current_obj, reset_bg, False);
1293 turnoff_changebars(type);
1303 return(prop_changebars_pending(prop_group_settings_rec[type].prop_sheet));
1311 PropGroupSettingsRec *pgs = &(prop_group_settings_rec[type]);
1313 if (prop_changed(pgs->name.changebar) && !prop_name_ok(pgs->current_obj, pgs->name.field))
1316 if (prop_changed(pgs->bg_color.changebar) && !prop_color_ok(pgs->bg_color.field))
1319 if (prop_changed(pgs->grid_rowcol_count.changebar) &&
1320 !prop_number_ok(pgs->grid_rowcol_count.field, (STRING)RowColFieldStr, 1, SHRT_MAX))
1323 if (prop_changed(pgs->valign.changebar) &&
1324 !prop_number_ok(pgs->vspacing.field, (STRING)VertSpacingFieldStr,
1325 -SHRT_MAX, SHRT_MAX))
1328 if (prop_changed(pgs->halign.changebar) &&
1329 !prop_number_ok(pgs->hspacing.field, (STRING)HorizSpacingFieldStr,
1330 -SHRT_MAX, SHRT_MAX))
1334 if (prop_changed(pgs->pos.changebar) &&
1335 (!prop_number_ok(pgs->pos.x_field, (STRING)XFieldStr, -SHRT_MAX, SHRT_MAX) ||
1336 !prop_number_ok(pgs->pos.y_field, (STRING)YFieldStr, -SHRT_MAX, SHRT_MAX)))
1347 PropGroupSettingsRec *pgs = &(prop_group_settings_rec[type]);
1349 prop_set_changebar(pgs->name.changebar, PROP_CB_OFF);
1350 prop_set_changebar(pgs->frame.changebar, PROP_CB_OFF);
1351 prop_set_changebar(pgs->layout_type.changebar, PROP_CB_OFF);
1352 prop_set_changebar(pgs->grid_rowcol.changebar, PROP_CB_OFF);
1353 prop_set_changebar(pgs->valign.changebar, PROP_CB_OFF);
1354 prop_set_changebar(pgs->halign.changebar, PROP_CB_OFF);
1355 prop_set_changebar(pgs->pos.changebar, PROP_CB_OFF);
1356 prop_set_changebar(pgs->init_state.changebar, PROP_CB_OFF);
1357 prop_set_changebar(pgs->bg_color.changebar, PROP_CB_OFF);
1359 prop_changebars_cleared(pgs->prop_sheet);
1366 XtPointer clientdata,
1367 XmToggleButtonCallbackStruct *state
1370 AB_PROP_TYPE type = (AB_PROP_TYPE)clientdata;
1371 AB_GROUP_TYPE value = AB_GROUP_UNDEF;
1375 XtVaGetValues(item, XmNuserData, &value, NULL);
1376 setup_grouptype_settings(type, value);
1383 setup_grouptype_settings(
1388 PropGroupSettingsRec *pgs = &(prop_group_settings_rec[type]);
1389 DtbGroupPropDialogInfo cgen;
1391 if (type == AB_PROP_REVOLVING)
1392 cgen = &rev_group_prop_dialog;
1394 cgen = &dtb_group_prop_dialog;
1396 if (!cgen || !cgen->initialized)
1401 case AB_GROUP_IGNORE:
1402 ui_set_active(cgen->valign_grp, False);
1403 ui_set_active(cgen->halign_grp, False);
1404 ui_set_active(cgen->grid_rowcol_grp, False);
1407 case AB_GROUP_COLUMNS:
1408 ui_set_active(cgen->valign_grp, True);
1409 ui_set_active(cgen->halign_grp, False);
1410 ui_set_active(cgen->grid_rowcol_grp, False);
1414 ui_set_active(cgen->valign_grp, False);
1415 ui_set_active(cgen->halign_grp, True);
1416 ui_set_active(cgen->grid_rowcol_grp, False);
1419 case AB_GROUP_ROWSCOLUMNS:
1420 ui_set_active(cgen->valign_grp, True);
1421 ui_set_active(cgen->halign_grp, True);
1422 ui_set_active(cgen->grid_rowcol_grp, True);
1436 * Remember all objects that will be ungrouped here can
1437 * undo this later (undo of undo)
1439 abobj_set_undo(undo_rec->list, undo_rec->count,
1440 undo_ungroup, AB_UNDO_UNGROUP);
1445 ungroup_objects(undo_rec->list, undo_rec->count);
1465 new_list = (ABObj *)malloc(undo_rec->count * sizeof(ABObj));
1467 project = proj_get_project();
1469 /* Deselect any objects that happen to be selected */
1470 abobj_deselect_all(project);
1471 aob_deselect_all_objects(project);
1473 for (i = 0; i < undo_rec->count; ++i)
1475 ABUndoInfo undo_info;
1477 undo_info = &(undo_rec->info_list[i]);
1480 * If undo record is not the right type, something is WRONG !!
1482 if (undo_info->type != AB_UNDO_UNGROUP)
1485 newgroup = abobj_dup_tree(undo_info->info.ungroup.dup_old_group);
1487 member_list = undo_info->info.ungroup.member_list;
1488 member_count = undo_info->info.ungroup.member_count;
1490 parent = obj_get_parent(member_list[0]);
1492 obj_append_child(parent, newgroup);
1494 if (abobj_show_tree(newgroup, False) == -1)
1495 fprintf(stderr,"create_obj_action: couldn't show object\n");
1498 group_objects(newgroup, member_list, member_count);
1501 new_list[i] = newgroup;
1504 abobj_set_undo(new_list, undo_rec->count, undo_group, AB_UNDO_GROUP);
1515 ABObj oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1521 create_member_list(oobj, &member_list, &member_count);
1524 * Reset groups width and height. for rows, the new height is that of
1525 * the tallest member, the new width is the width of the
1526 * rect occupied by all of the members. For colums, the new
1527 * width is that of the widest member, the new height is the
1528 * height of the rect occupied by all of the members.
1530 abobj_get_rect_for_objects(member_list, member_count, &rect);
1531 abobj_get_greatest_size(member_list, member_count,
1533 (ABObj *) NULL, (ABObj *) NULL);
1534 if (obj_get_group_type(oobj) == AB_GROUP_ROWS)
1536 abobj_set_pixel_width(obj, rect.width, 0);
1537 abobj_set_pixel_height(obj, height, 0);
1539 else if (obj_get_group_type(oobj) == AB_GROUP_ROWS)
1541 abobj_set_pixel_width(obj, width, 0);
1542 abobj_set_pixel_height(obj, rect.height, 0);
1544 util_free(member_list);
1557 int child_old_x, child_old_y;
1558 int group_new_x, group_new_y;
1562 if (!obj_has_flag(obj, XmConfiguredFlag))
1565 pobj = objxm_comp_get_subobj(obj, AB_CFG_PARENT_OBJ);
1567 if (obj_get_num_children(pobj) <= 0)
1570 type = obj_get_group_type(obj);
1573 * Save leftmost objects real x and y to determine group's new
1576 child = obj_get_child(pobj, 0);
1578 child_old_x = obj_get_x(child);
1579 child_old_y = obj_get_y(child);
1581 abobj_clear_layout(pobj, True, (type != AB_GROUP_IGNORE));
1585 * The code to do group layout here should be the code
1586 * used in dtb_utils.c to make sure the behaviour is the
1587 * same. Unfortunately, at this time, this is a big risky
1588 * change. So, some behavioral differences will exist.
1589 * This needs to be fixed in the future.
1593 case AB_GROUP_IGNORE:
1597 obj_set_num_rows(obj, 1);
1598 obj_set_num_columns(obj, 0);
1599 group_align_rows(obj, init);
1600 group_align_left(obj);
1603 case AB_GROUP_COLUMNS:
1604 obj_set_num_rows(obj, 0);
1605 obj_set_num_columns(obj, 1);
1606 group_align_cols(obj, init);
1607 group_align_tops(obj);
1610 case AB_GROUP_ROWSCOLUMNS:
1611 group_align_rows(obj, init);
1612 group_align_cols(obj, init);
1617 group_align_rows(obj);
1618 group_align_cols(obj);
1623 * Re-instantiate all of the children and then the group.
1625 for (i = 0; i < obj_get_num_children(pobj); i++)
1627 abobj_instantiate_changes(obj_get_child(pobj, i));
1632 * Set the childrens x,y's so obj is update with reality.
1634 for (i = 0; i < obj_get_num_children(pobj); i++)
1636 child = obj_get_child(pobj, i);
1637 x_get_widget_rect(objxm_get_widget(child), &rect);
1638 obj_set_x(child, rect.x);
1639 obj_set_y(child, rect.y);
1643 * Place the group so that the topmost/leftmost child remains
1644 * in the same place.
1645 group_new_x = obj_get_x(pobj) +
1646 (child_old_x - obj_get_x(obj_get_child(pobj, 0)));
1648 group_new_y = obj_get_y(pobj) +
1649 (child_old_y - obj_get_y(obj_get_child(pobj, 0)));
1651 abobj_set_xy(pobj, group_new_x, group_new_y);
1654 abobj_instantiate_changes(pobj);
1657 * For some reason, width and height need to be set on the
1659 pobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1660 x_get_widget_rect(objxm_get_widget(pobj), &rect);
1664 obj_set_width(pobj, rect.width);
1665 obj_set_height(pobj, rect.height);
1671 abobj_register_group_expose_handler(
1676 AB_ALIGNMENT row_alignment,
1678 Widget group_widget;
1681 Boolean register_expose = False;
1683 if (!obj || !obj_is_group(obj))
1686 group_widget = objxm_get_widget(obj);
1691 type = obj_get_group_type(obj);
1695 case AB_GROUP_IGNORE:
1699 row_alignment = obj_get_row_align(obj);
1701 if (row_alignment == AB_ALIGN_HCENTER)
1702 register_expose = True;
1705 case AB_GROUP_COLUMNS:
1706 col_alignment = obj_get_col_align(obj);
1708 if ((col_alignment == AB_ALIGN_VCENTER) ||
1709 (col_alignment == AB_ALIGN_LABELS))
1710 register_expose = True;
1713 case AB_GROUP_ROWSCOLUMNS:
1714 row_alignment = obj_get_row_align(obj);
1715 col_alignment = obj_get_col_align(obj);
1717 if ((row_alignment == AB_ALIGN_HCENTER) ||
1718 (col_alignment == AB_ALIGN_LEFT) ||
1719 (col_alignment == AB_ALIGN_LABELS))
1720 register_expose = True;
1724 if (register_expose)
1727 XtAddEventHandler(group_widget,
1728 ExposureMask, False,
1729 group_expose_handler, (XtPointer)obj);
1734 * Group expose handler.
1736 * Some group objects depend on it's members' sizes for their layout.
1737 * Unfortunately, some group members have invalid sizes prior to
1738 * XtRealize(), so the group layout has to be recalculated after the
1739 * group is realized or exposed in this case, since there is no realize
1743 group_expose_handler(
1745 XtPointer client_data,
1747 Boolean *cont_dispatch
1750 ABObj obj = (ABObj)client_data;
1751 WidgetList children_list;
1754 Boolean relayout_all = False,
1755 register_align_handler = False;
1758 if (event->type != Expose)
1761 if (!obj || !obj_is_group(obj))
1767 XtVaGetValues(widget,
1768 XmNnumChildren, &num_children,
1769 XmNchildren, &children_list,
1772 if (num_children <= 0)
1775 XtRemoveEventHandler(widget,
1776 ExposureMask, False,
1777 group_expose_handler, (XtPointer)client_data);
1780 * Turn off 'save needed' temporarily
1782 abobj_disable_save_needed();
1784 abobj_layout_group(obj, FALSE);
1786 abobj_enable_save_needed();
1794 ABAttachment attach;
1797 oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1798 int num_children = obj_get_num_children(oobj),
1806 if (num_children <= 0)
1809 get_cell_size(obj, &cell_width, &cell_height);
1811 get_row_col(obj, &num_rows, &num_columns);
1813 for (j = 0; j < num_rows; j++)
1815 for (i = 0; i < num_columns; i++)
1817 child = get_child(obj, i, j);
1822 if ((i == 0) && (j == 0))
1824 attach.type = AB_ATTACH_POINT;
1825 attach.value = (void *)0;
1828 abobj_set_attachment(child, AB_CP_NORTH, &attach);
1835 previous_child = get_child(obj, 0, j-1);
1839 int offset = obj_get_voffset(obj);
1840 AB_GROUP_TYPE type = obj_get_group_type(obj);
1842 if (type == AB_GROUP_ROWSCOLUMNS)
1844 (cell_height - abobj_get_actual_height(previous_child));
1846 attach.type = AB_ATTACH_OBJ;
1847 attach.value = (void *)previous_child;
1848 attach.offset = offset;
1850 abobj_set_attachment(child, AB_CP_NORTH, &attach);
1855 previous_child = get_child(obj, i-1, j);
1859 attach.type = AB_ATTACH_ALIGN_OBJ_EDGE;
1860 attach.value = (void *)previous_child;
1863 abobj_set_attachment(child, AB_CP_NORTH, &attach);
1870 group_align_hcenters(
1875 ABAttachment attach;
1878 oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1879 AB_GROUP_TYPE type = obj_get_group_type(obj);
1880 int num_children = obj_get_num_children(oobj),
1892 if (num_children <= 0)
1895 get_cell_size(obj, &cell_width, &cell_height);
1897 get_row_col(obj, &num_rows, &num_columns);
1899 offset = obj_get_voffset(obj);
1901 if (type == AB_GROUP_ROWSCOLUMNS)
1903 group_height = (num_rows * cell_height) + ((num_rows-1) * offset);
1904 abobj_set_pixel_width(obj, group_height, 0);
1905 abobj_instantiate_changes(obj);
1908 for (j = 0; j < num_rows; j++)
1910 if (type == AB_GROUP_ROWSCOLUMNS)
1911 gridline = (((j * (cell_height + offset)) + (cell_height/2)) * 100)/group_height;
1915 for (i = 0; i < num_columns; i++)
1917 child = get_child(obj, i, j);
1924 int init_offset = 0;
1925 Widget child_widget = objxm_get_widget(child);
1928 !XtIsSubclass(child_widget, compositeWidgetClass))
1930 int height = abobj_get_actual_height(child);
1932 init_offset = (cell_height - height)/2;
1933 if (type == AB_GROUP_ROWSCOLUMNS)
1934 init_offset += (j * (cell_height + offset));
1937 attach.type = AB_ATTACH_POINT;
1938 attach.value = (void *)0;
1939 attach.offset = init_offset;
1943 int height = abobj_get_actual_height(child);
1945 attach.type = AB_ATTACH_GRIDLINE;
1946 attach.value = (void *)gridline;
1947 attach.offset = -(height/2);
1950 abobj_set_attachment(child, AB_CP_NORTH, &attach);
1954 if (type == AB_GROUP_ROWSCOLUMNS)
1956 abobj_set_pixel_width(obj, -1, 0);
1957 abobj_instantiate_changes(obj);
1962 group_align_horiz_same_size(
1966 ABObj sibling, previous_sibling;
1967 ABObj oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
1968 int num_children = obj_get_num_children(oobj);
1971 sibling = obj_get_child(oobj, num_children - 1);
1973 * Set up childrens attachments from right to left.
1974 * All objects North and South attachments are to
1977 for (i = num_children - 2; i >= 0; i--)
1979 previous_sibling = obj_get_child(oobj, i);
1981 obj_set_attachment(sibling,
1987 obj_set_attachment(sibling,
1990 (void *) previous_sibling,
1991 obj_get_hoffset(oobj));
1993 obj_set_attachment(sibling,
1999 objxm_obj_set_attachment_args(sibling, OBJXM_CONFIG_BUILD);
2000 obj_clear_flag(sibling, BeingDestroyedFlag);
2002 sibling = previous_sibling;
2005 obj_set_attachment(sibling,
2010 obj_set_attachment(sibling,
2016 obj_set_attachment(sibling,
2022 objxm_obj_set_attachment_args(sibling, OBJXM_CONFIG_BUILD);
2023 obj_clear_flag(sibling, BeingDestroyedFlag);
2027 group_align_bottoms(
2031 ABAttachment attach;
2034 oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2035 AB_GROUP_TYPE type = obj_get_group_type(obj);
2036 int num_children = obj_get_num_children(oobj),
2045 if (num_children <= 0)
2048 get_cell_size(obj, &cell_width, &cell_height);
2050 get_row_col(obj, &num_rows, &num_columns);
2052 for (j = 0; j < num_rows; j++)
2054 for (i = 0; i < num_columns; i++)
2056 child = get_child(obj, i, j);
2061 if ((i == 0) && (j == 0))
2063 offset = (cell_height - abobj_get_actual_height(child));
2065 attach.type = AB_ATTACH_POINT;
2066 attach.value = (void *)0;
2067 attach.offset = offset;
2069 abobj_set_attachment(child, AB_CP_NORTH, &attach);
2076 previous_child = get_child(obj, 0, j-1);
2080 offset = obj_get_voffset(obj);
2082 if (type == AB_GROUP_ROWSCOLUMNS)
2084 (cell_height - abobj_get_actual_height(child));
2086 attach.type = AB_ATTACH_OBJ;
2087 attach.value = (void *)previous_child;
2088 attach.offset = offset;
2090 abobj_set_attachment(child, AB_CP_NORTH, &attach);
2095 previous_child = get_child(obj, i-1, j);
2097 if (child && previous_child)
2099 attach.type = AB_ATTACH_ALIGN_OBJ_EDGE;
2100 attach.value = (void *)previous_child;
2103 abobj_set_attachment(child, AB_CP_SOUTH, &attach);
2114 ABAttachment attach;
2117 oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2118 int num_children = obj_get_num_children(oobj),
2126 if (num_children <= 0)
2129 get_cell_size(obj, &cell_width, &cell_height);
2131 get_row_col(obj, &num_rows, &num_columns);
2133 for (j = 0; j < num_rows; j++)
2135 for (i = 0; i < num_columns; i++)
2137 child = get_child(obj, i, j);
2142 if ((i == 0) && (j == 0))
2144 attach.type = AB_ATTACH_POINT;
2145 attach.value = (void *)0;
2148 abobj_set_attachment(child, AB_CP_WEST, &attach);
2154 int offset = obj_get_hoffset(obj);
2155 AB_GROUP_TYPE type = obj_get_group_type(obj);
2157 previous_child = get_child(obj, i-1, j);
2159 if (!previous_child)
2162 if (type == AB_GROUP_ROWSCOLUMNS)
2164 (cell_width - abobj_get_actual_width(previous_child));
2166 attach.type = AB_ATTACH_OBJ;
2167 attach.value = (void *)previous_child;
2168 attach.offset = offset;
2170 abobj_set_attachment(child, AB_CP_WEST, &attach);
2175 previous_child = get_child(obj, i, j-1);
2179 attach.type = AB_ATTACH_ALIGN_OBJ_EDGE;
2180 attach.value = (void *)previous_child;
2183 abobj_set_attachment(child, AB_CP_WEST, &attach);
2194 ABAttachment attach;
2197 oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ),
2200 previous_ref_obj = NULL;
2201 int num_children = 0,
2207 max_label_width = 0,
2208 max_value_width = 0,
2213 num_children = obj_get_num_children(oobj);
2215 if (num_children <= 0)
2218 get_cell_size(obj, &cell_width, &cell_height);
2220 create_member_list(oobj, &child_list, &num_children);
2222 get_widest_label_obj(child_list, num_children, &child, &max_label_width);
2223 get_widest_value_obj(child_list, num_children, &child, &max_value_width);
2225 util_free(child_list);
2227 if (cell_width < max_label_width + max_value_width)
2228 cell_width = max_label_width + max_value_width;
2230 get_row_col(obj, &num_rows, &num_columns);
2233 one_col = (ABObj *)util_malloc(num_rows * sizeof(ABObj));
2235 for (i = 0; i < num_columns; i++)
2240 for (j = 0; j < num_rows; j++)
2241 one_col[j] = get_child(obj, i, j);
2243 get_widest_label_obj(one_col, num_rows, &ref_obj, &ref_width);
2248 if (previous_ref_obj)
2250 offset = (i * (obj_get_hoffset(obj) + cell_width));
2252 attach.offset = offset;
2257 attach.type = AB_ATTACH_POINT;
2258 attach.value = (void *)NULL;
2260 abobj_set_attachment(ref_obj, AB_CP_WEST, &attach);
2262 for (j = 0; j < num_rows; j++)
2264 child = get_child(obj, i, j);
2266 if (!child || (child == ref_obj))
2269 offset = (i * (obj_get_hoffset(obj) + cell_width));
2270 offset += ref_width - abobj_get_label_width(child);
2272 attach.type = AB_ATTACH_POINT;
2273 attach.value = (void *)NULL;
2275 attach.offset = ref_x - abobj_get_label_width(child);
2277 attach.offset = offset;
2279 abobj_set_attachment(child, AB_CP_WEST, &attach);
2282 previous_ref_obj = ref_obj;
2287 group_align_vcenters(
2292 ABAttachment attach;
2295 oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2296 AB_GROUP_TYPE type = obj_get_group_type(obj);
2297 int num_children = obj_get_num_children(oobj),
2309 if (num_children <= 0)
2312 get_cell_size(obj, &cell_width, &cell_height);
2314 get_row_col(obj, &num_rows, &num_columns);
2316 offset = obj_get_hoffset(obj);
2318 if (type == AB_GROUP_ROWSCOLUMNS)
2320 group_width = (num_columns * cell_width) + ((num_columns-1) * offset);
2321 abobj_set_pixel_width(obj, group_width, 0);
2322 abobj_instantiate_changes(obj);
2325 for (i = 0; i < num_columns; i++)
2327 if (type == AB_GROUP_ROWSCOLUMNS)
2328 gridline = (((i * (cell_width + offset)) + (cell_width/2)) * 100)/group_width;
2332 for (j = 0; j < num_rows; j++)
2334 child = get_child(obj, i, j);
2341 int init_offset = 0;
2342 Widget child_widget = objxm_get_widget(child);
2344 if (child_widget && !XtIsSubclass(child_widget, compositeWidgetClass))
2346 int width = abobj_get_actual_width(child);
2348 init_offset = (cell_width - width)/2;
2350 if (type == AB_GROUP_ROWSCOLUMNS)
2351 init_offset += (i * (cell_width + offset));
2354 attach.type = AB_ATTACH_POINT;
2355 attach.value = (void *)0;
2356 attach.offset = init_offset;
2360 int width = abobj_get_actual_width(child);
2362 attach.type = AB_ATTACH_GRIDLINE;
2363 attach.value = (void *)gridline;
2364 attach.offset = -(width/2);
2367 abobj_set_attachment(child, AB_CP_WEST, &attach);
2371 if (type == AB_GROUP_ROWSCOLUMNS)
2373 abobj_set_pixel_width(obj, -1, 0);
2374 abobj_instantiate_changes(obj);
2383 ABAttachment attach;
2386 oobj = objxm_comp_get_subobj(obj, AB_CFG_OBJECT_OBJ);
2387 AB_GROUP_TYPE type = obj_get_group_type(obj);
2388 int num_children = obj_get_num_children(oobj),
2397 if (num_children <= 0)
2400 get_cell_size(obj, &cell_width, &cell_height);
2402 get_row_col(obj, &num_rows, &num_columns);
2404 for (j = 0; j < num_rows; j++)
2406 for (i = 0; i < num_columns; i++)
2408 child = get_child(obj, i, j);
2413 if ((i == 0) && (j == 0))
2415 offset = (cell_width - abobj_get_actual_width(child));
2417 attach.type = AB_ATTACH_POINT;
2418 attach.value = (void *)0;
2419 attach.offset = offset;
2421 abobj_set_attachment(child, AB_CP_WEST, &attach);
2428 previous_child = get_child(obj, i-1, j);
2430 if (!previous_child)
2433 offset = obj_get_hoffset(obj);
2435 if (type == AB_GROUP_ROWSCOLUMNS)
2437 (cell_width - abobj_get_actual_width(child));
2439 attach.type = AB_ATTACH_OBJ;
2440 attach.value = (void *)previous_child;
2441 attach.offset = offset;
2443 abobj_set_attachment(child, AB_CP_WEST, &attach);
2448 previous_child = get_child(obj, i, j-1);
2452 attach.type = AB_ATTACH_ALIGN_OBJ_EDGE;
2453 attach.value = (void *)previous_child;
2456 abobj_set_attachment(child, AB_CP_EAST, &attach);
2465 ABObj **member_list,
2473 *member_count = trav_count(cobj,
2474 AB_TRAV_SALIENT_CHILDREN | AB_TRAV_MOD_SAFE);
2476 *member_list = (ABObj *)malloc(*member_count * sizeof(ABObj));
2479 * Create list of members.
2481 for (trav_open(&trav, cobj, AB_TRAV_SALIENT_CHILDREN |
2482 AB_TRAV_MOD_SAFE), member_index = 0;
2483 (member = trav_next(&trav)) != NULL; ++member_index)
2485 (*member_list)[member_index] = member;
2499 ABObj ret_child = NULL,
2506 if (!group || !obj_is_group(group) ||
2507 (x_pos < 0) || (y_pos < 0))
2510 type = obj_get_group_type(group);
2511 num_rows = obj_get_num_rows(group);
2512 num_columns = obj_get_num_columns(group);
2514 oobj = objxm_comp_get_subobj(group, AB_CFG_OBJECT_OBJ);
2515 num_children = obj_get_num_children(oobj);
2519 case AB_GROUP_IGNORE:
2530 case AB_GROUP_COLUMNS:
2538 case AB_GROUP_ROWSCOLUMNS:
2539 if (!num_rows && !num_columns)
2547 if (y_pos < num_rows)
2548 i = (x_pos * num_rows) + y_pos;
2555 if (x_pos < num_columns)
2556 i = x_pos + (y_pos * num_columns);
2564 if ((i >= 0) && (i < num_children))
2566 ret_child = obj_get_child(oobj, i);
2583 *cell_width = *cell_height = -1;
2588 type = obj_get_group_type(group);
2591 if (type == AB_GROUP_ROWSCOLUMNS)
2596 oobj = objxm_comp_get_subobj(group, AB_CFG_OBJECT_OBJ);
2599 create_member_list(oobj, &member_list, &member_count);
2600 abobj_get_greatest_size(member_list, member_count,
2601 cell_width, cell_height,
2602 (ABObj *) NULL, (ABObj *) NULL);
2604 util_free(member_list);
2607 *cell_width = *cell_height = -1;
2629 oobj = objxm_comp_get_subobj(group, AB_CFG_OBJECT_OBJ);
2631 num_rows = obj_get_num_rows(group);
2632 num_cols = obj_get_num_columns(group);
2633 num_children = obj_get_num_children(oobj);
2635 if ((num_rows <= 0) && (num_cols <= 0))
2643 num_cols = (num_children/num_rows) + ((num_children % num_rows) ? 1 : 0);
2646 num_rows = (num_children/num_cols) + ((num_children % num_cols) ? 1 : 0);
2659 if (!obj || !obj_is_group(obj))
2662 switch (obj_get_row_align(obj))
2665 group_align_tops(obj);
2668 case AB_ALIGN_HCENTER:
2669 group_align_hcenters(obj, init);
2672 case AB_ALIGN_BOTTOM:
2673 group_align_bottoms(obj);
2678 * Default to AB_ALIGN_TOP
2680 group_align_tops(obj);
2693 if (!obj || !obj_is_group(obj))
2696 switch (obj_get_col_align(obj))
2699 group_align_left(obj);
2702 case AB_ALIGN_LABELS:
2703 group_align_labels(obj);
2706 case AB_ALIGN_VCENTER:
2707 group_align_vcenters(obj, init);
2710 case AB_ALIGN_RIGHT:
2711 group_align_right(obj);
2716 * Default to AB_ALIGN_LEFT
2718 group_align_left(obj);
2724 get_widest_label_obj(
2727 ABObj *widest_label,
2734 ABObj widest = NULL;
2736 if (!list || !widest_label)
2739 for (i = 0; i < count; ++i)
2743 tmp_width = abobj_get_label_width(list[i]);
2745 if (tmp_width > cur_width)
2747 cur_width = tmp_width;
2753 *widest_label = widest;
2756 *label_width = cur_width;
2760 get_widest_value_obj(
2763 ABObj *widest_value,
2770 ABObj widest = NULL;
2772 if (!list || !widest_value)
2775 for (i = 0; i < count; ++i)
2782 label_width = abobj_get_label_width(list[i]);
2783 obj_width = abobj_get_actual_width(list[i]);
2785 tmp_width = obj_width - label_width;
2787 if (tmp_width > cur_width)
2789 cur_width = tmp_width;
2795 *widest_value = widest;
2798 *value_width = cur_width;