Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtappbuilder / src / ab / panedwin_ed_stubs.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 /*** DTB_USER_CODE_START vvv Add file header below vvv ***/
24 /*
25  *      $XConsortium: panedwin_ed_stubs.c /main/3 1995/11/06 17:44:56 rswiston $
26  *
27  * @(#)panedwin_ed_stubs.c      1.15 18 Jan 1995 cde_app_builder/src/ab
28  *
29  *      RESTRICTED CONFIDENTIAL INFORMATION:
30  *
31  *      The information in this document is subject to special
32  *      restrictions in a confidential disclosure agreement between
33  *      HP, IBM, Sun, USL, SCO and Univel.  Do not distribute this
34  *      document outside HP, IBM, Sun, USL, SCO, or Univel without
35  *      Sun's specific written approval.  This document and all copies
36  *      and derivative works thereof must be returned or destroyed at
37  *      Sun's request.
38  *
39  *      Copyright 1993 Sun Microsystems, Inc.  All rights reserved.
40  *
41  */
42
43 /*** DTB_USER_CODE_END   ^^^ Add file header above ^^^ ***/
44
45 /*
46  * File: panedwin_ed_stubs.c
47  * Contains: Module callbacks and connection functions
48  *
49  * This file was generated by dtcodegen, from module panedwin_ed
50  *
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.
54  *
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!                                 **
58  */
59
60 #include <stdio.h>
61 #include <Xm/Xm.h>
62 #include "dtb_utils.h"
63 #include "dtbuilder.h"
64 #include "panedwin_ed_ui.h"
65
66
67 /**************************************************************************
68  *** DTB_USER_CODE_START
69  ***
70  *** All necessary header files have been included.
71  ***
72  *** Add include files, types, macros, externs, and user functions here.
73  ***/
74
75 #include <Xm/List.h>
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"
88
89 typedef struct  PANEDWIN_EDITOR_SETTINGS
90 {
91     Widget                      prop_sheet;
92     PropFieldSettingRec         name;
93     PropGeometrySettingRec      geometry;
94     PropGeometrySettingRec      min_max_geo;
95     ABObj                       current_pw_obj;
96     ABObj                       current_pane_obj;
97 } PanedWinEditorSettingsRec, *PanedWinEditorSettings;
98
99 /*
100  * Declarations of global widgets used by callbacks.
101  */
102 ABObj           current_pw_child = NULL;
103 /*
104  * End declarations of global widgets
105  */
106
107 /*************************************************************************
108 **                                                                      **
109 **       Private Function Declarations                                  **
110 **                                                                      **
111 **************************************************************************/
112
113 static Widget   panedwin_editor_init(
114                     DtbPanedwinEdDialogInfo     pw_cgen,
115                     Widget                      parent
116                 );
117 static int      panedwin_editor_load(
118                     ABObj       project
119                 );
120 static int      panedwin_editor_clear();
121 static int      panedwin_editor_clear_geom();
122
123 static int      panedwin_editor_activate(
124                     BOOL         active
125                 );
126 static int      panedwin_editor_apply();
127 static BOOL     panedwin_editor_pending();
128 static void     panedwinEdP_init();
129 static void     pw_objlist_load(
130                    Widget      list
131                 );
132 static BOOL     pw_objlist_test_func(
133                     ABObj test_obj
134                 );
135 static BOOL     pw_child_test_func(
136                     ABObj test_obj
137                 );
138 static BOOL     verify_editor();
139 static void     turnoff_changebars();
140
141 /*
142  * Callbacks
143  */
144 static int      pw_obj_reparentedOCB(
145                     ObjEvReparentInfo   info
146                 );
147 static int      pw_obj_updateOCB(
148                     ObjEvUpdateInfo     info
149                 );
150 static int      pw_obj_destroyedOCB(
151                     ObjEvDestroyInfo    info
152                 );
153 static int      pw_obj_renamedOCB(
154                     ObjEvAttChangeInfo  info
155                 );
156 static void     pw_objlist_selectCB(
157                     Widget              widget,
158                     XtPointer           client_data,
159                     XmListCallbackStruct *listdata
160                 );
161 static void     pw_panelist_selectCB(
162                     Widget              widget,
163                     XtPointer           client_data,
164                     XmListCallbackStruct *listdata
165                 );
166
167 /*************************************************************************
168 **                                                                      **
169 **       Data                                                           **
170 **                                                                      **
171 **************************************************************************/
172
173 PanedWinEditorSettingsRec    pw_editor_settings_rec;
174
175 /*************************************************************************
176 **                                                                      **
177 **       Function Definitions                                           **
178 **                                                                      **
179 **************************************************************************/
180  
181 void
182 panedwin_ed_show_dialog(
183 )
184 {
185     /* If there is no Message Editor, create it */
186     if (AB_panedWinEd_dialog == (Widget)NULL)
187     {
188         /* Create and manage the Paned Window Editor */
189         AB_panedWinEd_dialog = 
190                 panedwin_editor_init(&dtb_panedwin_ed_dialog, AB_toplevel);
191
192         /* Hack to make panes list have nice layout */
193         XtVaSetValues(XtParent(dtb_panedwin_ed_dialog.panelist_scrolledwin), 
194                 XmNrightAttachment,     XmATTACH_FORM,
195                 XmNrightOffset,         100,
196                 NULL);
197
198         /* Add Update, Rename, and Destroy object callbacks */
199         panedwinEdP_init();
200
201         /* Load in the panedWindow object list */
202         pw_objlist_load(dtb_panedwin_ed_dialog.objlist);
203
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);
208
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);
214
215         /*
216          * Setup dialog to participate in dtbuilder window protocol
217          */
218         ab_register_window(AB_panedWinEd_dialog, AB_WIN_DIALOG, 
219                 WindowHidden, AB_toplevel, AB_WPOS_TILE_HORIZONTAL,
220                 NULL, NULL);
221     }
222
223     if (AB_panedWinEd_dialog != NULL)
224         XtManageChild(AB_panedWinEd_dialog);
225 }
226
227 static Widget
228 panedwin_editor_init(
229     DtbPanedwinEdDialogInfo     pw_cgen,
230     Widget                      parent
231 )
232 {
233     PanedWinEditorSettingsRec   *pws = &pw_editor_settings_rec;
234
235     /*                                
236      * Create Dialog widgets...
237      */
238     dtbPanedwinEdDialogInfo_clear(pw_cgen);
239
240     if (dtb_panedwin_ed_dialog_initialize(pw_cgen, parent) == 0)
241     {
242         pws->prop_sheet = pw_cgen->attrs_ctrlpanel;
243         pws->current_pw_obj = NULL;
244         pws->current_pane_obj = NULL;
245
246         /* Name Field */
247         prop_field_init(&(pws->name), pw_cgen->name_field_label,
248                             pw_cgen->name_field, pw_cgen->name_cb);
249
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,
255                             pw_cgen->geo_cb);
256
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);
261
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);
265
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,
271                 pw_cgen->height_cb); 
272
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);
277
278         prop_changebars_cleared(pws->prop_sheet);
279
280         return (pw_cgen->dialog_shellform);
281     }
282     else
283         return NULL;
284
285 }  
286
287 static int
288 panedwin_editor_activate(
289     BOOL         active
290 )
291 {
292     ui_set_active(pw_editor_settings_rec.prop_sheet, active);
293     return OK;
294 }
295
296
297 static int
298 panedwin_editor_clear(
299 )
300 {
301     PanedWinEditorSettingsRec   *pws = &pw_editor_settings_rec;
302
303     /* Clear Name Field */
304     prop_field_set_value(&(pws->name), "", False);
305
306     /* Clear pane information */
307     panedwin_editor_clear_geom();
308  
309     pws->current_pw_obj = NULL;
310     pws->current_pane_obj = NULL;
311
312     turnoff_changebars();
313
314     return OK;
315 }
316
317 static int
318 panedwin_editor_clear_geom(
319 )
320 {
321     PanedWinEditorSettingsRec   *pws = &pw_editor_settings_rec;
322
323     /* Clear Pane Geometry Setting */
324     prop_geomfield_clear(&(pws->geometry), GEOM_WIDTH);
325     prop_geomfield_clear(&(pws->geometry), GEOM_HEIGHT);
326
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);
330
331     return OK;
332 }
333
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
337  * height values.
338  */
339 static int
340 panedwin_editor_load(
341     ABObj    obj
342 )
343 {
344     PanedWinEditorSettingsRec   *pws = &pw_editor_settings_rec;
345     int                         width = 0, height = 0;
346  
347     if (obj == NULL)
348     {
349         if (pws->current_pane_obj != NULL)
350             obj = pws->current_pane_obj;
351         else
352             return ERROR;
353     }
354     else if (!obj_is_pane(obj) && !obj_is_layers(obj))
355         return ERROR;
356     else
357         pws->current_pane_obj = obj;
358
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);
364
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);
370
371     turnoff_changebars();
372
373     return OK;
374 }
375
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.
379  */
380 int
381 panedwin_editor_apply(
382 )
383 {
384     PanedWinEditorSettingsRec   *pws = &pw_editor_settings_rec;
385     STRING                      value;
386     int                         geom;
387
388     if (!verify_editor())
389         return ERROR;
390
391     if (prop_changed(pws->name.changebar))
392     {
393         value = prop_field_get_value(&(pws->name));   
394         abobj_set_name(pws->current_pw_obj, value);
395         util_free(value);
396     }
397     if (prop_changed(pws->geometry.changebar))
398     {
399     }
400     if (prop_changed(pws->min_max_geo.changebar))
401     {
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);
406     }
407
408     if (pws->current_pw_obj != NULL)
409         abobj_instantiate_changes(pws->current_pw_obj);
410
411     if (pws->current_pane_obj != NULL)
412         abobj_instantiate_changes(pws->current_pane_obj);
413
414     turnoff_changebars();
415
416     return OK;
417 }
418
419 static BOOL
420 panedwin_editor_pending(
421 )
422 {
423     return(prop_changebars_pending(pw_editor_settings_rec.prop_sheet));
424 }
425
426 static BOOL
427 verify_editor(
428 )
429 {
430     PanedWinEditorSettingsRec   *pws = &pw_editor_settings_rec;
431
432     if (prop_changed(pws->name.changebar) && 
433         !prop_name_ok(pws->current_pw_obj, pws->name.field))
434         return False;
435     else 
436         return True;
437 }
438
439 static void
440 turnoff_changebars(
441 )
442 {
443     PanedWinEditorSettingsRec   *pws = &pw_editor_settings_rec;
444
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);
448
449     prop_changebars_cleared(pws->prop_sheet);
450 }
451
452 /* This routine is called when an item is selected from the
453  * Paned Window Objects list in the Paned Window Editor.
454  */
455 static void
456 pw_objlist_selectCB(
457     Widget      widget,
458     XtPointer   client_data,
459     XmListCallbackStruct *listdata
460 )
461 {
462     ABObj               module = NULL;
463     ABObj               selected_obj = NULL;
464     STRING              name = NULL;
465     Widget              panelist = dtb_panedwin_ed_dialog.panelist;
466     PanedWinEditorSettingsRec   *pws = &pw_editor_settings_rec;
467
468     name = objxm_xmstr_to_str(listdata->item);
469     if (name)
470     {
471         abobj_moduled_name_extract(name, &module, &selected_obj);
472         util_free(name);
473
474         if (selected_obj)
475         {
476             /* An Object is loaded with pending changes...*/
477             /* REMIND: Need to add code to deal with pending changes.*/
478         
479             /* Clear out the panes list first */
480             XmListDeleteAllItems(panelist);
481         
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);
485
486             /* Load  Name of paned window object */
487             prop_field_set_value(&(pws->name), 
488                         obj_get_name(selected_obj), False);
489
490             /* Set the current paned window object */
491             pws->current_pw_obj = selected_obj;
492         }
493     }
494 }
495
496 static void
497 pw_panelist_selectCB(
498     Widget      widget,
499     XtPointer   client_data,
500     XmListCallbackStruct *listdata
501 )
502 {
503     ABObj               module = NULL;
504     ABObj               selected_obj = NULL;
505     STRING              name = NULL;
506
507     name = objxm_xmstr_to_str(listdata->item);
508     if (name)
509     {
510         XtVaGetValues(widget, XmNuserData, &module, NULL);
511         if (module != NULL)
512         {
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);
521
522             selected_obj = obj_scoped_find_by_name(module, name);
523             panedwin_editor_load(selected_obj);
524             current_pw_child = selected_obj;
525         }
526         util_free(name);
527     }
528 }
529
530 /*
531  * Traverse the project and load all panedWindow objects.
532  */
533 static void
534 pw_objlist_load(
535    Widget      list
536 )
537 {
538     ABObj           proj = proj_get_project();
539     int             num_items = 0;
540  
541     if (proj == NULL || list == NULL)
542         return;
543  
544     num_items = abobj_list_load(list, proj, pw_objlist_test_func);
545 }
546
547 /*
548  * Test whether an object should be loaded into the
549  * Paned Window Editor object list.
550  */
551 static BOOL
552 pw_objlist_test_func(
553     ABObj test_obj
554 )
555 {
556     ABObj       module = NULL;
557  
558     if ((module = obj_get_module(test_obj)) == NULL)
559         return(False);
560  
561     if (obj_is_paned_win(test_obj) &&
562         obj_has_flag(module, MappedFlag))
563     {
564         return(True);
565     }
566     else
567         return(False);
568 }
569
570 /* Test whether the object is a module and if so test
571  * if it is mapped (showing).
572  */
573 static BOOL
574 module_test_func(
575     ABObj test_obj
576 )
577 {
578     if (!obj_is_module(test_obj))
579         return(False);
580
581     if (obj_has_flag(test_obj, MappedFlag))
582     {
583         return(True);
584     }
585     else
586         return(False);
587 }
588
589 /*
590  * Test whether an object should be loaded into the
591  * list of panes in the Paned Window Editor.
592  */
593 static BOOL
594 pw_child_test_func(
595     ABObj test_obj
596 )
597 {
598     ABObj       module = NULL;
599     ABObj       parent = NULL;
600
601     if ((module = obj_get_module(test_obj)) == NULL)
602         return(False);
603
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))
607     {
608         return(True);
609     }
610     else
611         return(False);
612 }
613
614 /*
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.
618  */
619 static int
620 pw_obj_updateOCB(
621     ObjEvUpdateInfo     info
622 )
623 {
624     Widget      list = dtb_panedwin_ed_dialog.objlist;
625     int         ret = 0;
626
627     if (AB_panedWinEd_dialog != NULL)
628     {
629         if (!obj_is_project(info->obj) && !obj_is_module(info->obj)
630             && !obj_is_paned_win(info->obj))
631             return 0;
632
633         /* Populate the Paned Window Editor list */
634         ret = abobj_list_obj_updated(list, info, pw_objlist_test_func);
635     }
636     return (ret);
637 }
638
639 /*
640  * obj-callback: object is being destroyed - remove from Paned
641  *               Window Editor object list.
642  */
643 static int
644 pw_obj_destroyedOCB(
645     ObjEvDestroyInfo    info
646 )
647 {
648     Widget      list = dtb_panedwin_ed_dialog.objlist;
649     Widget      panelist = dtb_panedwin_ed_dialog.panelist;
650     ABObj       parent = NULL;
651     STRING      name = NULL;
652     XmStringTable sel_item = NULL;
653     int         ret = 0;
654                      
655     if (AB_panedWinEd_dialog != NULL)
656     {
657         if (!obj_is_project(info->obj) && !obj_is_paned_win(info->obj)
658             && !obj_is_pane(info->obj) && !obj_is_layers(info->obj))
659             return 0;
660  
661         if (obj_is_project(info->obj))
662         {
663             /* Clear the Paned Window Editor and make it inactive */
664             panedwin_editor_clear();
665
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);
670
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);
675         }
676         else if (obj_is_paned_win(info->obj))
677         {
678             /* Clear out the paned window editor if the paned window
679              * being destroyed is the one which is currently loaded.
680              */
681             XtVaGetValues(list, XmNselectedItems, &sel_item, NULL);
682             if (sel_item != NULL)
683             {
684                 name = abobj_get_moduled_name(info->obj);
685                 if (strcmp(name, objxm_xmstr_to_str(sel_item[0])) == 0)
686                     panedwin_editor_clear();
687             }
688             ret = abobj_list_obj_destroyed(list, info->obj, 
689                                 pw_objlist_test_func);
690         }
691         else /* Object is a pane OR a layer */
692         {
693             parent = obj_get_parent(info->obj);
694             if ( ((parent = obj_get_parent(info->obj)) != NULL) &&
695                 obj_is_paned_win(parent))
696             {
697                 XtVaGetValues(panelist, XmNselectedItems, &sel_item, NULL);
698                 if (sel_item != NULL)
699                 {
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();
703                 }
704                 ret = abobj_list_obj_destroyed(panelist, info->obj, 
705                                 pw_child_test_func);
706             }
707         }
708     }
709     return (ret);
710 }
711
712 static int
713 pw_obj_renamedOCB(
714     ObjEvAttChangeInfo    info
715 )
716 {
717     Widget      list = dtb_panedwin_ed_dialog.objlist;
718     Widget      panelist = dtb_panedwin_ed_dialog.panelist;
719     ABObj       parent = NULL,
720                 sel_module = NULL,
721                 selected_obj = NULL;
722     XmStringTable sel_item = NULL;
723     STRING      mod_name = NULL;
724     int         ret = 0;
725
726     if (!obj_is_module(info->obj) && !obj_is_paned_win(info->obj)
727         && !obj_is_pane(info->obj) && !obj_is_layers(info->obj))
728         return 0;
729
730     if (AB_panedWinEd_dialog != NULL)
731     {
732         if (obj_is_module(info->obj))
733         {
734             mod_name = obj_get_name(info->obj);
735             if (mod_name == NULL)
736                 return -1;
737      
738             if (info->old_name != NULL)
739             {
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);
743
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);
747             }
748         }
749         else if (obj_is_paned_win(info->obj))
750         {
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.
755              */
756             if (info->old_name != NULL)
757             {  
758                 ret = abobj_list_obj_renamed(list, info->obj,
759                         istr_string(info->old_name), pw_objlist_test_func);
760             }
761         }
762         else    /* obj is a pane OR a layer */
763         {
764             if (info->old_name == NULL)
765             {
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 
769                  * obj's parent.
770                  */  
771                 parent = obj_get_parent(info->obj);
772                 if ( (parent != NULL) && obj_is_paned_win(parent) )
773                 {
774                     XtVaGetValues(list, XmNselectedItems, &sel_item, NULL);
775                     if (sel_item != NULL)
776                     {
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,
782                                         pw_child_test_func);
783                     }
784                 }
785             }
786             /* The pane's name has changed */
787             else
788                 ret = abobj_list_obj_renamed(panelist, info->obj,
789                         istr_string(info->old_name), pw_child_test_func);
790         }
791     }
792     return (ret);
793 }
794
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 
798  * menu.
799  */
800 static int
801 pw_obj_reparentedOCB(
802     ObjEvReparentInfo     info
803 )
804 {
805     Widget      list = dtb_panedwin_ed_dialog.objlist;
806     Widget      panelist = dtb_panedwin_ed_dialog.panelist;
807     ABObj       parent = NULL,
808                 sel_module = NULL,
809                 selected_obj = NULL;
810     XmStringTable sel_item = NULL;
811     STRING      name = NULL;
812     int         ret = 0;
813
814     if (AB_panedWinEd_dialog != NULL)
815     {
816         if (!obj_is_pane(info->obj) && !obj_is_layers(info->obj))
817             return 0;
818
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).
824          */
825         parent = obj_get_parent(info->obj);
826         if (obj_get_name(info->obj) != NULL)
827         {
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. 
836              */
837             if ((info->old_parent != NULL) && 
838                 obj_is_paned_win(info->old_parent))
839             {
840                 if (current_pw_child == info->obj)
841                     panedwin_editor_clear_geom();
842                 ret = abobj_list_obj_reparented(panelist, info, 
843                                 pw_child_test_func);
844             }
845         }
846     }
847     return (ret);
848 }
849
850 static void
851 panedwinEdP_init()
852 {
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");
857 }
858
859 /*** DTB_USER_CODE_END
860  ***
861  *** End of user code section
862  ***
863  **************************************************************************/
864
865
866
867
868 /**************************************************************************
869  *** DTB_USER_CODE_START
870  ***
871  *** All automatically-generated data and functions have been defined.
872  ***
873  *** Add new functions here, or at the top of the file.
874  ***/
875 /*** DTB_USER_CODE_END
876  ***
877  *** End of user code section
878  ***
879  **************************************************************************/
880
881