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
23 /*** DTB_USER_CODE_START vvv Add file header below vvv ***/
25 * $XConsortium: panedwin_ed_stubs.c /main/3 1995/11/06 17:44:56 rswiston $
27 * @(#)panedwin_ed_stubs.c 1.15 18 Jan 1995 cde_app_builder/src/ab
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.
43 /*** DTB_USER_CODE_END ^^^ Add file header above ^^^ ***/
46 * File: panedwin_ed_stubs.c
47 * Contains: Module callbacks and connection functions
49 * This file was generated by dtcodegen, from module panedwin_ed
51 * Any text may be added between the DTB_USER_CODE_START and
52 * DTB_USER_CODE_END comments (even non-C code). Descriptive comments
53 * are provided only as an aid.
55 * ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS. **
56 * ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR **
57 * ** DELETE THE GENERATED COMMENTS! **
62 #include "dtb_utils.h"
63 #include "dtbuilder.h"
64 #include "panedwin_ed_ui.h"
67 /**************************************************************************
68 *** DTB_USER_CODE_START
70 *** All necessary header files have been included.
72 *** Add include files, types, macros, externs, and user functions here.
76 #include <ab_private/ab.h>
77 #include <ab_private/prop.h>
78 #include <ab_private/proj.h>
79 #include <ab_private/abobj.h>
80 #include <ab_private/abobj_set.h>
81 #include <ab_private/abobj_list.h>
82 #include <ab_private/ui_util.h>
83 #include <ab_private/obj_notify.h>
84 #include <ab_private/objxm.h>
85 #include "dtb_utils.h"
86 #include "dtbuilder.h"
87 #include "panedwin_ed_ui.h"
89 typedef struct PANEDWIN_EDITOR_SETTINGS
92 PropFieldSettingRec name;
93 PropGeometrySettingRec geometry;
94 PropGeometrySettingRec min_max_geo;
96 ABObj current_pane_obj;
97 } PanedWinEditorSettingsRec, *PanedWinEditorSettings;
100 * Declarations of global widgets used by callbacks.
102 ABObj current_pw_child = NULL;
104 * End declarations of global widgets
107 /*************************************************************************
109 ** Private Function Declarations **
111 **************************************************************************/
113 static Widget panedwin_editor_init(
114 DtbPanedwinEdDialogInfo pw_cgen,
117 static int panedwin_editor_load(
120 static int panedwin_editor_clear();
121 static int panedwin_editor_clear_geom();
123 static int panedwin_editor_activate(
126 static int panedwin_editor_apply();
127 static BOOL panedwin_editor_pending();
128 static void panedwinEdP_init();
129 static void pw_objlist_load(
132 static BOOL pw_objlist_test_func(
135 static BOOL pw_child_test_func(
138 static BOOL verify_editor();
139 static void turnoff_changebars();
144 static int pw_obj_reparentedOCB(
145 ObjEvReparentInfo info
147 static int pw_obj_updateOCB(
150 static int pw_obj_destroyedOCB(
151 ObjEvDestroyInfo info
153 static int pw_obj_renamedOCB(
154 ObjEvAttChangeInfo info
156 static void pw_objlist_selectCB(
158 XtPointer client_data,
159 XmListCallbackStruct *listdata
161 static void pw_panelist_selectCB(
163 XtPointer client_data,
164 XmListCallbackStruct *listdata
167 /*************************************************************************
171 **************************************************************************/
173 PanedWinEditorSettingsRec pw_editor_settings_rec;
175 /*************************************************************************
177 ** Function Definitions **
179 **************************************************************************/
182 panedwin_ed_show_dialog(
185 /* If there is no Message Editor, create it */
186 if (AB_panedWinEd_dialog == (Widget)NULL)
188 /* Create and manage the Paned Window Editor */
189 AB_panedWinEd_dialog =
190 panedwin_editor_init(&dtb_panedwin_ed_dialog, AB_toplevel);
192 /* Hack to make panes list have nice layout */
193 XtVaSetValues(XtParent(dtb_panedwin_ed_dialog.panelist_scrolledwin),
194 XmNrightAttachment, XmATTACH_FORM,
198 /* Add Update, Rename, and Destroy object callbacks */
201 /* Load in the panedWindow object list */
202 pw_objlist_load(dtb_panedwin_ed_dialog.objlist);
204 /* Add Callback to load panedWin object when selected from list */
205 XtAddCallback(dtb_panedwin_ed_dialog.objlist,
206 XmNbrowseSelectionCallback,
207 (XtCallbackProc)pw_objlist_selectCB, (XtPointer)NULL);
209 /* Add Callback to load panes when a paned window obj is
210 * selected from list. */
211 XtAddCallback(dtb_panedwin_ed_dialog.panelist,
212 XmNbrowseSelectionCallback,
213 (XtCallbackProc)pw_panelist_selectCB, (XtPointer)NULL);
216 * Setup dialog to participate in dtbuilder window protocol
218 ab_register_window(AB_panedWinEd_dialog, AB_WIN_DIALOG,
219 WindowHidden, AB_toplevel, AB_WPOS_TILE_HORIZONTAL,
223 if (AB_panedWinEd_dialog != NULL)
224 XtManageChild(AB_panedWinEd_dialog);
228 panedwin_editor_init(
229 DtbPanedwinEdDialogInfo pw_cgen,
233 PanedWinEditorSettingsRec *pws = &pw_editor_settings_rec;
236 * Create Dialog widgets...
238 dtbPanedwinEdDialogInfo_clear(pw_cgen);
240 if (dtb_panedwin_ed_dialog_initialize(pw_cgen, parent) == 0)
242 pws->prop_sheet = pw_cgen->attrs_ctrlpanel;
243 pws->current_pw_obj = NULL;
244 pws->current_pane_obj = NULL;
247 prop_field_init(&(pws->name), pw_cgen->name_field_label,
248 pw_cgen->name_field, pw_cgen->name_cb);
250 /* Pane Geometry Setting */
251 prop_geomfield_init(&(pws->geometry), pw_cgen->geo_label,
252 NULL, NULL, NULL, NULL,
253 pw_cgen->width_field_label, pw_cgen->width_field,
254 pw_cgen->height_field_label, pw_cgen->height_field,
257 ui_set_active(pw_cgen->width_field_label, False);
258 ui_set_active(pw_cgen->width_field, False);
259 ui_set_active(pw_cgen->height_field_label, False);
260 ui_set_active(pw_cgen->height_field, False);
262 /* REMIND: Make geometry textfields read-only for now */
263 XtVaSetValues(pw_cgen->width_field, XmNeditable, False, NULL);
264 XtVaSetValues(pw_cgen->height_field, XmNeditable, False, NULL);
266 /* Pane Minimum/Maximum Setting */
267 prop_geomfield_init(&(pws->min_max_geo), pw_cgen->pane_height_lbl,
268 NULL, NULL, NULL, NULL,
269 pw_cgen->min_height_field_label, pw_cgen->min_height_field,
270 pw_cgen->max_height_field_label, pw_cgen->max_height_field,
273 ui_set_active(pw_cgen->min_height_field_label, False);
274 ui_set_active(pw_cgen->min_height_field, False);
275 ui_set_active(pw_cgen->max_height_field_label, False);
276 ui_set_active(pw_cgen->max_height_field, False);
278 prop_changebars_cleared(pws->prop_sheet);
280 return (pw_cgen->dialog_shellform);
288 panedwin_editor_activate(
292 ui_set_active(pw_editor_settings_rec.prop_sheet, active);
298 panedwin_editor_clear(
301 PanedWinEditorSettingsRec *pws = &pw_editor_settings_rec;
303 /* Clear Name Field */
304 prop_field_set_value(&(pws->name), "", False);
306 /* Clear pane information */
307 panedwin_editor_clear_geom();
309 pws->current_pw_obj = NULL;
310 pws->current_pane_obj = NULL;
312 turnoff_changebars();
318 panedwin_editor_clear_geom(
321 PanedWinEditorSettingsRec *pws = &pw_editor_settings_rec;
323 /* Clear Pane Geometry Setting */
324 prop_geomfield_clear(&(pws->geometry), GEOM_WIDTH);
325 prop_geomfield_clear(&(pws->geometry), GEOM_HEIGHT);
327 /* Clear Pane Minimum/Maximum Setting */
328 prop_geomfield_clear(&(pws->min_max_geo), GEOM_WIDTH);
329 prop_geomfield_clear(&(pws->min_max_geo), GEOM_HEIGHT);
334 /* This routine is called when a paned window child is
335 * selected in the "Panes" list in the Paned Window
336 * Editor. It loads in the pane geometry and its min/max
340 panedwin_editor_load(
344 PanedWinEditorSettingsRec *pws = &pw_editor_settings_rec;
345 int width = 0, height = 0;
349 if (pws->current_pane_obj != NULL)
350 obj = pws->current_pane_obj;
354 else if (!obj_is_pane(obj) && !obj_is_layers(obj))
357 pws->current_pane_obj = obj;
359 /* Pane Geometry Setting */
360 width = abobj_get_actual_width(obj);
361 height = abobj_get_actual_height(obj);
362 prop_geomfield_set_value(&(pws->geometry), GEOM_WIDTH, width, False);
363 prop_geomfield_set_value(&(pws->geometry), GEOM_HEIGHT, height, False);
365 /* Pane Minimum/Maximum Setting */
366 prop_geomfield_set_value(&(pws->min_max_geo), GEOM_WIDTH,
367 obj_get_pane_min(obj),False);
368 prop_geomfield_set_value(&(pws->min_max_geo), GEOM_HEIGHT,
369 obj_get_pane_max(obj),False);
371 turnoff_changebars();
376 /* This routine is called when the "Apply" button is
377 * pressed. It sets all the values of attributes that
378 * have changed to their new values.
381 panedwin_editor_apply(
384 PanedWinEditorSettingsRec *pws = &pw_editor_settings_rec;
388 if (!verify_editor())
391 if (prop_changed(pws->name.changebar))
393 value = prop_field_get_value(&(pws->name));
394 abobj_set_name(pws->current_pw_obj, value);
397 if (prop_changed(pws->geometry.changebar))
400 if (prop_changed(pws->min_max_geo.changebar))
402 geom = prop_geomfield_get_value(&(pws->min_max_geo), GEOM_WIDTH);
403 abobj_set_pane_min(pws->current_pane_obj, geom);
404 geom = prop_geomfield_get_value(&(pws->min_max_geo), GEOM_HEIGHT);
405 abobj_set_pane_max(pws->current_pane_obj, geom);
408 if (pws->current_pw_obj != NULL)
409 abobj_instantiate_changes(pws->current_pw_obj);
411 if (pws->current_pane_obj != NULL)
412 abobj_instantiate_changes(pws->current_pane_obj);
414 turnoff_changebars();
420 panedwin_editor_pending(
423 return(prop_changebars_pending(pw_editor_settings_rec.prop_sheet));
430 PanedWinEditorSettingsRec *pws = &pw_editor_settings_rec;
432 if (prop_changed(pws->name.changebar) &&
433 !prop_name_ok(pws->current_pw_obj, pws->name.field))
443 PanedWinEditorSettingsRec *pws = &pw_editor_settings_rec;
445 prop_set_changebar(pws->name.changebar, PROP_CB_OFF);
446 prop_set_changebar(pws->geometry.changebar, PROP_CB_OFF);
447 prop_set_changebar(pws->min_max_geo.changebar, PROP_CB_OFF);
449 prop_changebars_cleared(pws->prop_sheet);
452 /* This routine is called when an item is selected from the
453 * Paned Window Objects list in the Paned Window Editor.
458 XtPointer client_data,
459 XmListCallbackStruct *listdata
463 ABObj selected_obj = NULL;
465 Widget panelist = dtb_panedwin_ed_dialog.panelist;
466 PanedWinEditorSettingsRec *pws = &pw_editor_settings_rec;
468 name = objxm_xmstr_to_str(listdata->item);
471 abobj_moduled_name_extract(name, &module, &selected_obj);
476 /* An Object is loaded with pending changes...*/
477 /* REMIND: Need to add code to deal with pending changes.*/
479 /* Clear out the panes list first */
480 XmListDeleteAllItems(panelist);
482 /* Populate the panes list in the editor */
483 abobj_list_update(panelist, selected_obj, pw_child_test_func);
484 XtVaSetValues(panelist, XmNuserData, module, NULL);
486 /* Load Name of paned window object */
487 prop_field_set_value(&(pws->name),
488 obj_get_name(selected_obj), False);
490 /* Set the current paned window object */
491 pws->current_pw_obj = selected_obj;
497 pw_panelist_selectCB(
499 XtPointer client_data,
500 XmListCallbackStruct *listdata
504 ABObj selected_obj = NULL;
507 name = objxm_xmstr_to_str(listdata->item);
510 XtVaGetValues(widget, XmNuserData, &module, NULL);
513 ui_set_active(dtb_panedwin_ed_dialog.width_field_label, True);
514 ui_set_active(dtb_panedwin_ed_dialog.width_field, True);
515 ui_set_active(dtb_panedwin_ed_dialog.height_field_label, True);
516 ui_set_active(dtb_panedwin_ed_dialog.height_field, True);
517 ui_set_active(dtb_panedwin_ed_dialog.min_height_field_label, True);
518 ui_set_active(dtb_panedwin_ed_dialog.min_height_field, True);
519 ui_set_active(dtb_panedwin_ed_dialog.max_height_field_label, True);
520 ui_set_active(dtb_panedwin_ed_dialog.max_height_field, True);
522 selected_obj = obj_scoped_find_by_name(module, name);
523 panedwin_editor_load(selected_obj);
524 current_pw_child = selected_obj;
531 * Traverse the project and load all panedWindow objects.
538 ABObj proj = proj_get_project();
541 if (proj == NULL || list == NULL)
544 num_items = abobj_list_load(list, proj, pw_objlist_test_func);
548 * Test whether an object should be loaded into the
549 * Paned Window Editor object list.
552 pw_objlist_test_func(
558 if ((module = obj_get_module(test_obj)) == NULL)
561 if (obj_is_paned_win(test_obj) &&
562 obj_has_flag(module, MappedFlag))
570 /* Test whether the object is a module and if so test
571 * if it is mapped (showing).
578 if (!obj_is_module(test_obj))
581 if (obj_has_flag(test_obj, MappedFlag))
590 * Test whether an object should be loaded into the
591 * list of panes in the Paned Window Editor.
601 if ((module = obj_get_module(test_obj)) == NULL)
604 parent = obj_get_parent(test_obj);
605 if ( (obj_is_pane(test_obj) || obj_is_layers(test_obj))
606 && obj_is_paned_win(parent) && obj_has_flag(module, MappedFlag))
615 * obj-callback: Called when a new project is opened or
616 * when a new module is created or imported
617 * or when an existing module is shown or hidden.
624 Widget list = dtb_panedwin_ed_dialog.objlist;
627 if (AB_panedWinEd_dialog != NULL)
629 if (!obj_is_project(info->obj) && !obj_is_module(info->obj)
630 && !obj_is_paned_win(info->obj))
633 /* Populate the Paned Window Editor list */
634 ret = abobj_list_obj_updated(list, info, pw_objlist_test_func);
640 * obj-callback: object is being destroyed - remove from Paned
641 * Window Editor object list.
645 ObjEvDestroyInfo info
648 Widget list = dtb_panedwin_ed_dialog.objlist;
649 Widget panelist = dtb_panedwin_ed_dialog.panelist;
652 XmStringTable sel_item = NULL;
655 if (AB_panedWinEd_dialog != NULL)
657 if (!obj_is_project(info->obj) && !obj_is_paned_win(info->obj)
658 && !obj_is_pane(info->obj) && !obj_is_layers(info->obj))
661 if (obj_is_project(info->obj))
663 /* Clear the Paned Window Editor and make it inactive */
664 panedwin_editor_clear();
666 ui_set_active(dtb_panedwin_ed_dialog.width_field_label, False);
667 ui_set_active(dtb_panedwin_ed_dialog.width_field, False);
668 ui_set_active(dtb_panedwin_ed_dialog.height_field_label, False);
669 ui_set_active(dtb_panedwin_ed_dialog.height_field, False);
671 ui_set_active(dtb_panedwin_ed_dialog.min_height_field_label,False);
672 ui_set_active(dtb_panedwin_ed_dialog.min_height_field, False);
673 ui_set_active(dtb_panedwin_ed_dialog.max_height_field_label,False);
674 ui_set_active(dtb_panedwin_ed_dialog.max_height_field, False);
676 else if (obj_is_paned_win(info->obj))
678 /* Clear out the paned window editor if the paned window
679 * being destroyed is the one which is currently loaded.
681 XtVaGetValues(list, XmNselectedItems, &sel_item, NULL);
682 if (sel_item != NULL)
684 name = abobj_get_moduled_name(info->obj);
685 if (strcmp(name, objxm_xmstr_to_str(sel_item[0])) == 0)
686 panedwin_editor_clear();
688 ret = abobj_list_obj_destroyed(list, info->obj,
689 pw_objlist_test_func);
691 else /* Object is a pane OR a layer */
693 parent = obj_get_parent(info->obj);
694 if ( ((parent = obj_get_parent(info->obj)) != NULL) &&
695 obj_is_paned_win(parent))
697 XtVaGetValues(panelist, XmNselectedItems, &sel_item, NULL);
698 if (sel_item != NULL)
700 name = abobj_get_moduled_name(info->obj);
701 if (strcmp(name, objxm_xmstr_to_str(sel_item[0])) == 0)
702 panedwin_editor_clear_geom();
704 ret = abobj_list_obj_destroyed(panelist, info->obj,
714 ObjEvAttChangeInfo info
717 Widget list = dtb_panedwin_ed_dialog.objlist;
718 Widget panelist = dtb_panedwin_ed_dialog.panelist;
722 XmStringTable sel_item = NULL;
723 STRING mod_name = NULL;
726 if (!obj_is_module(info->obj) && !obj_is_paned_win(info->obj)
727 && !obj_is_pane(info->obj) && !obj_is_layers(info->obj))
730 if (AB_panedWinEd_dialog != NULL)
732 if (obj_is_module(info->obj))
734 mod_name = obj_get_name(info->obj);
735 if (mod_name == NULL)
738 if (info->old_name != NULL)
740 /* Change the module prefix in the objlist */
741 abobj_list_obj_renamed(list, info->obj,
742 istr_string(info->old_name), module_test_func);
744 /* Change the module prefix in the panes list */
745 abobj_list_obj_renamed(panelist, info->obj,
746 istr_string(info->old_name), module_test_func);
749 else if (obj_is_paned_win(info->obj))
751 /* Check if the panedWindow obj is being created.
752 * If not, then simply replace the old name with
753 * the new name. Otherwise let the pw_obj_updateOCB
754 * handle adding a newly created panedWindow object.
756 if (info->old_name != NULL)
758 ret = abobj_list_obj_renamed(list, info->obj,
759 istr_string(info->old_name), pw_objlist_test_func);
762 else /* obj is a pane OR a layer */
764 if (info->old_name == NULL)
766 /* This is a new pane dropped on an existing
767 * paned window object OR this is a new layer
768 * being created. To make sure, check the
771 parent = obj_get_parent(info->obj);
772 if ( (parent != NULL) && obj_is_paned_win(parent) )
774 XtVaGetValues(list, XmNselectedItems, &sel_item, NULL);
775 if (sel_item != NULL)
777 abobj_moduled_name_extract(
778 objxm_xmstr_to_str(sel_item[0]),
779 &sel_module, &selected_obj);
780 if (selected_obj == parent)
781 ret = abobj_list_update(panelist, parent,
786 /* The pane's name has changed */
788 ret = abobj_list_obj_renamed(panelist, info->obj,
789 istr_string(info->old_name), pw_child_test_func);
795 /* This callback gets called when a pane child is being
796 * parented to a different object, as when "Unmake Paned
797 * Window" or "Make Paned Window" is chosen from the popup
801 pw_obj_reparentedOCB(
802 ObjEvReparentInfo info
805 Widget list = dtb_panedwin_ed_dialog.objlist;
806 Widget panelist = dtb_panedwin_ed_dialog.panelist;
810 XmStringTable sel_item = NULL;
814 if (AB_panedWinEd_dialog != NULL)
816 if (!obj_is_pane(info->obj) && !obj_is_layers(info->obj))
819 /* If the pane name is NULL, then that means it is a
820 * new pane, one which was dragged from the palette
821 * onto an existing paned window. In that case, let
822 * the pw_obj_renamedOCB callback handle it (i.e. add
823 * it to the pane list).
825 parent = obj_get_parent(info->obj);
826 if (obj_get_name(info->obj) != NULL)
828 /* Either a new paned window obj was created (via
829 * the "Make Paned Window" popup menu OR a paned
830 * window obj is being destroyed (via the "Unmake
831 * Paned Window" popup menu) and therefore its
832 * children are being reparented to the paned window's
833 * parent. If a new paned window was created, we don't
834 * need to update the panes list because that will happen
835 * when the new paned window obj is selected.
837 if ((info->old_parent != NULL) &&
838 obj_is_paned_win(info->old_parent))
840 if (current_pw_child == info->obj)
841 panedwin_editor_clear_geom();
842 ret = abobj_list_obj_reparented(panelist, info,
853 obj_add_reparent_callback(pw_obj_reparentedOCB, "panedwinEdP_init");
854 obj_add_rename_callback(pw_obj_renamedOCB, "panedwinEdP_init");
855 obj_add_update_callback(pw_obj_updateOCB, "panedwinEdP_init");
856 obj_add_destroy_callback(pw_obj_destroyedOCB, "panedwinEdP_init");
859 /*** DTB_USER_CODE_END
861 *** End of user code section
863 **************************************************************************/
868 /**************************************************************************
869 *** DTB_USER_CODE_START
871 *** All automatically-generated data and functions have been defined.
873 *** Add new functions here, or at the top of the file.
875 /*** DTB_USER_CODE_END
877 *** End of user code section
879 **************************************************************************/