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 libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: proj.c /main/3 1995/11/06 17:45:35 rswiston $
26 * @(#)proj.c 1.50 17 May 1994
28 * RESTRICTED CONFIDENTIAL INFORMATION:
30 * The information in this document is subject to special
31 * restrictions in a confidential disclosure agreement between
32 * HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
33 * document outside HP, IBM, Sun, USL, SCO, or Univel without
34 * Sun's specific written approval. This document and all copies
35 * and derivative works thereof must be returned or destroyed at
38 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
44 #include <sys/param.h>
47 #include <Xm/BulletinB.h>
48 #include <Xm/SelectioB.h>
49 #include <ab_private/ab.h>
50 #include <ab_private/bil.h>
51 #include <ab_private/abobj.h>
52 #include <ab_private/abobj_set.h>
53 #include <ab_private/appfw.h>
54 #include <ab_private/objxm.h>
55 #include <ab_private/brwsP.h>
56 #include <ab_private/projP.h>
57 #include <ab_private/cgen.h>
58 #include <ab_private/ui_util.h>
59 #include <ab_private/x_util.h>
60 #include <ab_private/trav.h>
61 #include <ab_private/abio.h>
62 #include <ab_private/ab_bil.h>
63 #include <ab_private/proj.h>
64 #include <ab_private/obj.h>
65 #include <ab_private/abuil_load.h>
66 #include <ab_private/pal.h>
68 #include "dtbuilder.h"
70 /*************************************************************************
72 ** Private Function Declarations **
74 **************************************************************************/
75 static Vwr create_proj_struct();
77 static void create_proj_ui_handles(
82 * Action Procs for project window.
84 static void select_module(
91 static void toggle_select_module(
98 static void show_module(
105 static void enable_proj_actions(
109 static void disable_proj_actions(
113 static void no_module_selected(
114 DtbProjProjMainInfo proj_d
117 static void one_module_selected(
118 DtbProjProjMainInfo proj_d
121 static void mult_module_selected(
122 DtbProjProjMainInfo proj_d
125 static void update_menu_items(
130 static void pointer_motion_proc(
137 static void popdown_proj_window(
139 XtPointer client_data,
143 static void import_uil(
148 * Object notification callbacks
150 static int projP_obj_renameOCB(
151 ObjEvAttChangeInfo info
154 static int projP_obj_destroyOCB(
155 ObjEvDestroyInfo info
158 static int projP_obj_updateOCB(
163 * Functions for supporting rubber banding
165 static void project_bpress(
172 static int project_select_rband(
176 static void projP_drawarea_button_drag(
178 XtPointer client_data,
180 Boolean *cont_dispatch
183 static void project_rband(
187 XtPointer client_data
190 /*************************************************************************
194 **************************************************************************/
197 * Project window Actions
199 static XtActionsRec projwin_actions[] = {
200 {"ModButtonPress", (XtActionProc)project_bpress },
201 {"ModSelect", (XtActionProc)select_module },
202 {"ModToggleSelect", (XtActionProc)toggle_select_module },
203 {"ModShowModule", (XtActionProc)show_module },
204 {"ModPointerMotion", (XtActionProc)pointer_motion_proc}
208 * Translations for module subwindow of Project Organizer
210 static String base_translations =
211 "Shift <Btn1Down>: ModButtonPress() \n\
212 <Btn1Down>: ModButtonPress() \n\
213 Shift <Btn1Down>,<Btn1Up>: ModToggleSelect() \n\
214 <Btn1Down>,<Btn1Up>: ModSelect() \n\
215 <Btn1Up>(2): ModShowModule() \n\
216 <Motion>: ModPointerMotion() ";
218 static String btn2_adjust_translations =
219 "\n<Btn2Down>: ModButtonPress() \n\
220 <Btn2Down>,<Btn2Up>: ModToggleSelect() ";
222 static XtTranslations proj_transtbl = NULL;
226 * Static variables used for rubber banding
228 static XRectangle *rband_rect = NULL;
229 static Boolean mselect_adjust = False;
231 char Buf[MAXPATHLEN]; /* Work buffer */
233 /*************************************************************************
235 ** Function Definitions
237 **************************************************************************/
238 static int select_fn(
243 * Project Window Xt callbacks
247 * Popup the project window by managing the container child of the
253 ABObj proj = proj_get_project();
255 ChooserInfo info = NULL;
257 if (AB_proj_window == NULL)
260 Proj_viewer = create_proj_struct();
262 create_proj_ui_handles(Proj_viewer);
263 proj_add_objects(proj);
265 /* Check if the shared file chooser is already
266 * up when the Project Organizer is displayed.
267 * If it is, then find out which one is up and
268 * set the appropriate menu items inactive.
270 if ((AB_generic_chooser != NULL) &&
271 XtIsManaged(AB_generic_chooser))
273 XtVaGetValues(AB_generic_chooser,
276 proj_set_menus(info->chooser_type, FALSE);
278 /* When the Project Organizer is first brought
279 * up, no modules are selected so certain menu
280 * items (like Module ->Save/Save As) should be
283 update_menu_items(0, 0);
285 ab_show_window(AB_proj_window);
286 abobj_update_proj_name( proj );
291 * Create callback for project window widgets
296 XtPointer client_data,
300 char *tmp_str = (char *)client_data;
303 widget_str = strtok(tmp_str, "+");
307 * If project viewer structure has not been initialized,
312 Proj_viewer = create_proj_struct();
315 XtVaSetValues(widget, XmNuserData, (XtPointer)Proj_viewer, NULL);
320 * Create viewer data structure for project window
326 extern VMethods projP_methods;
328 v = vwr_create(projP_methods);
336 XtPointer client_data,
340 ui_win_show(widget, False, XtGrabNone);
344 create_proj_ui_handles(
348 Widget draw_area = NULL;
352 dtbProjProjMainInfo_clear(&dtb_proj_proj_main);
355 * Create ui handle struct for project window
357 ui = aob_create_ui_obj();
359 (void)dtb_proj_proj_main_initialize(&dtb_proj_proj_main, AB_toplevel);
360 ui->shell = dtb_proj_proj_main.proj_main;
361 AB_proj_window = dtb_proj_proj_main.proj_main_mainwin;
363 ab_register_window(AB_proj_window, AB_WIN_WINDOW,
364 WindowHidden, AB_toplevel, AB_WPOS_TILE_VERTICAL,
365 popdown_proj_window, NULL);
369 * Until the generated code sets XmNmenuHelpWidget properly,
370 * this is a workaround.
372 XtVaSetValues(dtb_proj_proj_main.menubar,
373 XmNmenuHelpWidget, dtb_proj_proj_main.menubar_items.Help_item,
376 XtRealizeWidget(ui->shell);
378 ui->ip = (void *)&dtb_proj_proj_main;
380 v->ui_handle = (void *)ui;
382 if (!(draw_area = brws_draw_area(v)))
384 fprintf(stderr, "Can't find draw area widget for project\n");
389 * Set event handler on draw area for dragging/rubber banding
391 XtAddEventHandler(draw_area,
392 Button1MotionMask | Button2MotionMask, False,
393 projP_drawarea_button_drag, (XtPointer)NULL);
395 brwsP_make_drawarea_snap(v, draw_area);
397 setup_vwr_graphics(v);
399 enable_proj_actions(draw_area);
415 Proj_viewer = create_proj_struct();
421 project = obj_get_project(obj);
423 viewer = Proj_viewer;
426 (*m->insert_tree)(viewer, obj);
429 * Erase/redraw viewer
431 if (viewer->ui_handle)
434 * Don't need to erase viewer as a new node is
435 * added to end of the array of nodes in project window
436 erase_viewer(viewer);
458 project = obj_get_project(obj);
460 viewer = Proj_viewer;
463 (*m->remove_tree)(viewer, obj);
466 * Erase/redraw viewer
468 if (viewer->ui_handle)
470 erase_viewer(viewer);
476 * Register project actions with Xt
479 proj_register_actions(
483 XtAppAddActions(app, projwin_actions, XtNumber(projwin_actions));
487 * Enable project window actions
494 if (proj_transtbl == NULL)
499 len = strlen(base_translations) + 1;
501 if (AB_btn1_transfer == True) /* Button2 can be used for ADJUST */
502 len += strlen(btn2_adjust_translations);
504 translations = (String)util_malloc(len*sizeof(char));
505 if (translations == NULL)
508 strcpy(translations, base_translations);
509 if (AB_btn1_transfer == True) /* Button2 can be used for ADJUST */
510 strcat(translations, btn2_adjust_translations);
512 proj_transtbl = XtParseTranslationTable(translations);
514 util_free(translations);
517 /* enable build mode behavior */
518 XtVaSetValues(widget,
519 XtNtranslations, proj_transtbl,
524 * Disable project window actions
527 disable_proj_actions(
534 * Action: Select module in project window
549 XtVaGetValues(widget, XmNuserData, &v, NULL);
554 selected_node = vwr_locate_node(v,
555 event->xbutton.x, event->xbutton.y);
559 VNode *selected_nodes = NULL;
560 int num_selected = 0;
562 if (!(m = v->methods))
566 obj = (AB_OBJ *)selected_node->obj_data;
572 * Deselect all selected module nodes
573 * Select the module node
575 aob_deselect_all_nodes(v, TRUE);
578 vwr_get_cond(v->current_tree, &selected_nodes,
579 &num_selected, select_fn);
582 free((char *)selected_nodes);
584 update_menu_items(0, num_selected);
589 * Action: Toggle select module in project window
592 toggle_select_module(
604 XtVaGetValues(widget, XmNuserData, &v, NULL);
609 selected_node = vwr_locate_node(v,
610 event->xbutton.x, event->xbutton.y);
614 VNode *selected_nodes = NULL;
615 int num_selected = 0;
617 if (!(m = v->methods))
621 obj = (AB_OBJ *)selected_node->obj_data;
627 * Toggle select the module node
629 if (BRWS_NODE_STATE_IS_SET(selected_node, BRWS_NODE_SELECTED))
634 vwr_get_cond(v->current_tree, &selected_nodes,
635 &num_selected, select_fn);
638 free((char *)selected_nodes);
640 update_menu_items(0, num_selected);
645 * Action: Show the module when double-clicked on.
662 XtVaGetValues(widget, XmNuserData, &v, NULL);
667 selected_node = vwr_locate_node(v,
668 event->xbutton.x, event->xbutton.y);
672 VNode *selected_nodes = NULL;
673 int num_selected = 0;
675 if (!(m = v->methods))
679 obj = (ABObj) selected_node->obj_data;
685 * Set busy cursor before this potentially
688 ab_set_busy_cursor(TRUE);
690 /* If the module is already showing, then
691 * make all of its windows come to the fore-
694 if (obj_has_flag(obj, MappedFlag))
696 for (trav_open(&trav, obj, AB_TRAV_WINDOWS);
697 (winobj = trav_next(&trav)) != NULL; )
699 if (obj_has_flag(winobj, MappedFlag))
700 ui_win_front(objxm_get_widget(winobj));
703 proj_set_cur_module(obj);
705 else if( abobj_show_tree(obj, TRUE) == -1 )
707 if (util_get_verbosity() > 0)
708 fprintf(stderr,"show_module: error in abobj_show_tree\n");
712 proj_set_cur_module(obj);
715 vwr_get_cond(v->current_tree, &selected_nodes,
716 &num_selected, select_fn);
719 free((char *)selected_nodes);
721 update_menu_items(0, num_selected);
726 ab_set_busy_cursor(FALSE);
736 if (BRWS_NODE_STATE_IS_SET(module, BRWS_NODE_SELECTED))
743 project_select_rband(
748 if (!vnode || !rband_rect)
751 if (((int)rband_rect->x <= vnode->x) &&
752 ((int)(rband_rect->x + (short)rband_rect->width) >= (vnode->x + vnode->width)) &&
753 ((int)rband_rect->y <= vnode->y) &&
754 ((int)(rband_rect->y + (short)rband_rect->height) >= vnode->y + vnode->height))
761 * Update the sensitivity of menu items depending on
762 * the old/new count of modules selected.
764 * NOTE: Currently, this proc does not use the old_count
765 * param. It will, in future use it for optimization.
775 no_module_selected(&dtb_proj_proj_main);
781 one_module_selected(&dtb_proj_proj_main);
785 mult_module_selected(&dtb_proj_proj_main);
789 * no_module_selected()
790 * No module is currently selected, so desensitize all
791 * relevant menu items
795 DtbProjProjMainInfo proj_w
798 ProjModMenubuttonMenuItems menu_rec;
803 menu_rec = &(proj_w->menubar_Module_item_mod_menubutton_menu_items);
805 ui_set_active(menu_rec->Save_item, FALSE);
806 ui_set_active(menu_rec->Save_As_item, FALSE);
807 ui_set_active(menu_rec->Show_item, FALSE);
808 ui_set_active(menu_rec->Hide_item, FALSE);
809 ui_set_active(menu_rec->Browse_item, FALSE);
810 ui_set_active(menu_rec->Export_item, FALSE);
811 ui_set_active(menu_rec->Remove_item, FALSE);
815 * one_module_selected()
816 * One module is currently selected, so make all
817 * menu items sensitive
821 DtbProjProjMainInfo proj_w
824 ProjModMenubuttonMenuItems menu_rec;
825 ChooserInfo info = NULL;
829 menu_rec = &(proj_w->menubar_Module_item_mod_menubutton_menu_items);
831 ui_set_active(menu_rec->Show_item, TRUE);
832 ui_set_active(menu_rec->Hide_item, TRUE);
833 ui_set_active(menu_rec->Browse_item, TRUE);
834 ui_set_active(menu_rec->Remove_item, TRUE);
836 /* If the FSB has not been created yet or if it has
837 * been created but it is not displayed, then make
838 * the menu items active.
840 if ((AB_generic_chooser == NULL) ||
841 !XtIsManaged(AB_generic_chooser))
843 ui_set_active(menu_rec->Save_item, TRUE);
844 ui_set_active(menu_rec->Save_As_item, TRUE);
845 ui_set_active(menu_rec->Import_item, TRUE);
846 ui_set_active(menu_rec->Export_item, TRUE);
848 else if (XtIsManaged(AB_generic_chooser))
850 XtVaGetValues(AB_generic_chooser, XmNuserData, &info, NULL);
851 if (info->chooser_type == AB_EXPORT_CHOOSER)
853 ui_set_active(menu_rec->Export_item, TRUE);
855 else if (info->chooser_type == AB_SAVE_PROJ_AS_CHOOSER)
857 ui_set_active(menu_rec->Save_item, TRUE);
858 ui_set_active(menu_rec->Save_As_item, TRUE);
860 else if (info->chooser_type == AB_IMPORT_CHOOSER)
862 ui_set_active(menu_rec->Import_item, TRUE);
868 * mult_module_selected()
869 * Multiple modules are currently selected.
870 * We desensitize the Save/Save As/Export buttons
871 * because the choossers cannot handle multiple
872 * saves at the moment...
875 mult_module_selected(
876 DtbProjProjMainInfo proj_w
879 ProjModMenubuttonMenuItems menu_rec;
884 menu_rec = &(proj_w->menubar_Module_item_mod_menubutton_menu_items);
886 ui_set_active(menu_rec->Save_item, FALSE);
887 ui_set_active(menu_rec->Save_As_item, FALSE);
888 ui_set_active(menu_rec->Export_item, FALSE);
889 ui_set_active(menu_rec->Show_item, TRUE);
890 ui_set_active(menu_rec->Hide_item, TRUE);
891 ui_set_active(menu_rec->Browse_item, TRUE);
892 ui_set_active(menu_rec->Remove_item, TRUE);
899 obj_add_rename_callback(projP_obj_renameOCB, "PROJ");
900 obj_add_destroy_callback(projP_obj_destroyOCB, "PROJ");
901 obj_add_update_callback(projP_obj_updateOCB, "PROJ");
903 AB_project = obj_create(AB_TYPE_PROJECT, NULL);
904 obj_set_name(AB_project, "project");
905 abobj_show_tree(AB_project, TRUE);
910 /* This destroys the current project and creates
911 * a new default project named "project" since
912 * dtbuilder can never have a NULL project.
915 proj_destroy_project(
919 obj_set_flag(proj, BeingDestroyedFlag);
921 proj_create_new_proj(NULL);
933 * Update project window and browsers
937 /* Initialize the current module to NULL,
938 * since no modules are showing yet.
940 proj_set_cur_module(NULL);
942 cgen_notify_new_project(AB_project);
943 appfw_notify_new_project(AB_project);
962 if ( (module != NULL) && (obj_get_type(module) != AB_TYPE_MODULE) )
965 AB_cur_module = module;
967 ab_update_stat_region(AB_STATUS_CUR_MODULE, obj_get_name(module));
969 ab_update_stat_region(AB_STATUS_CUR_MODULE, NULL);
978 return AB_cur_module;
987 if ( !obj_is_module(module) )
990 abobj_set_name(module, name);
992 if (abobj_update_module_name(module) == -1)
995 /* Update the browser */
996 brws_update_node(module);
998 /* Update the project window */
999 proj_update_node(module);
1001 if (module == proj_get_cur_module())
1003 if (ab_update_stat_region(AB_STATUS_CUR_MODULE, name) == -1)
1010 * Action: Update "Module Path:" in the project window
1011 * whenever the user moves the pointer over a
1015 pointer_motion_proc(
1023 VNode node_under_pointer = NULL;
1025 XMotionEvent *mevent = (XMotionEvent*)event;
1026 char mod_path[MAXPATHLEN] = "";
1028 util_dprintf(2, "pointer_motion_proc:\n");
1029 XtVaGetValues(widget, XmNuserData, &v, NULL);
1034 node_under_pointer = vwr_locate_node(v,
1035 mevent->x, mevent->y);
1036 if (node_under_pointer != NULL)
1038 /* USE METHODS !! */
1039 obj = (AB_OBJ *)node_under_pointer->obj_data;
1044 util_dprintf(2, "\tmodule name is %s\n", obj_get_name(obj));
1046 /* If the module has not been saved, file will be NULL */
1047 if (obj_get_file(obj) != NULL)
1049 util_get_dir_name_from_path(obj_get_file(obj), mod_path,
1054 strcpy(mod_path, ".");
1057 util_dprintf(2, "\tmodule path is %s\n", mod_path);
1059 if (!util_strempty(mod_path))
1061 util_dprintf(2, "\tupdating the project window status region\n");
1062 proj_update_stat_region(PROJ_STATUS_MOD_PATH, mod_path);
1067 /* If we're not over a node, clear out the module
1068 * path status label in the project window.
1070 util_dprintf(2, "\tpointer is not positioned over a node\n");
1071 proj_update_stat_region(PROJ_STATUS_MOD_PATH, NULL);
1078 STRING uil_file_name
1081 ABObj project = proj_get_project();
1082 ABObjPtr uil_interface;
1084 if ((uil_interface = abuil_get_uil_file(uil_file_name, project))
1087 fprintf(stderr, "Failed to import %s.\n", uil_file_name);
1091 fprintf(stderr, "Successfully imported %s.\n", uil_file_name);
1093 obj_set_flag(project, SaveNeededFlag);
1098 abobj_show_tree(uil_interface, TRUE);
1099 abobj_set_save_needed(project, TRUE);
1103 proj_open_proj_okCB(
1105 XtPointer client_data,
1106 XmSelectionBoxCallbackStruct *call_data
1109 STRING proj_filename = (STRING) NULL;
1110 XmString xm_buf = (XmString) NULL;
1111 DtbObjectHelpData help_data = NULL;
1113 proj_filename = (STRING)objxm_xmstr_to_str(call_data->value);
1115 /* If the file chooser selection text field is empty, return */
1116 if ( util_strempty(proj_filename) )
1118 dtb_proj_no_name_msg_initialize(&dtb_proj_no_name_msg);
1119 (void)dtb_show_modal_message(widget,
1120 &dtb_proj_no_name_msg, NULL, NULL, NULL);
1122 else if (!util_file_exists(proj_filename))
1124 sprintf(Buf, catgets(Dtb_project_catd, 100, 8,
1125 "The file %s does not exist."), proj_filename);
1126 util_printf_err(Buf);
1128 else if (!util_file_is_regular_file(proj_filename))
1130 sprintf(Buf, catgets(Dtb_project_catd, 100, 69,
1131 "Cannot open %s.\n%s is not a regular file."),
1132 proj_filename, proj_filename);
1133 xm_buf = XmStringCreateLocalized(Buf);
1134 dtb_proj_error_msg_initialize(&dtb_proj_error_msg);
1136 help_data = (DtbObjectHelpData) util_malloc(sizeof(DtbObjectHelpDataRec));
1137 help_data->help_text = catgets(Dtb_project_catd, 100, 89,
1138 "The file you specified is a directory or\nanother special file.");
1139 help_data->help_volume = "";
1140 help_data->help_locationID = "";
1142 (void)dtb_show_modal_message(widget,
1143 &dtb_proj_error_msg, xm_buf, help_data, NULL);
1145 util_free(help_data);
1146 XmStringFree(xm_buf);
1150 XtUnmanageChild(widget); /* pop down the chooser */
1151 ab_check_and_open_bip(proj_filename);
1158 XtPointer client_data,
1159 XmSelectionBoxCallbackStruct *call_data
1162 /* Pop down the file chooser. This must be done
1163 * explicitly because the file chooser autoUnmanage
1164 * resource was set to FALSE.
1166 XtUnmanageChild(widget);
1173 XtPointer client_data,
1174 XmSelectionBoxCallbackStruct *call_data
1177 STRING file_name = (STRING) NULL;
1178 XmString xm_buf = (XmString) NULL;
1179 BOOL read_OK, write_OK;
1180 DtbObjectHelpData help_data = NULL;
1182 if (call_data->reason != XmCR_OK)
1187 file_name = (STRING)objxm_xmstr_to_str(call_data->value);
1189 /* If the file chooser selection text field is empty,
1190 * return, leaving the chooser up to give the user
1193 if (util_strempty(file_name))
1195 dtb_proj_no_name_msg_initialize(&dtb_proj_no_name_msg);
1196 (void)dtb_show_modal_message(widget,
1197 &dtb_proj_no_name_msg, NULL, NULL, NULL);
1199 else if (!util_file_exists(file_name))
1201 /* If the file specified does not exist, keep up the file
1202 * chooser so that the user can specify another file.
1204 sprintf(Buf, catgets(Dtb_project_catd, 100, 8,
1205 "The file %s does not exist."), file_name);
1206 util_printf_err(Buf);
1208 else if (!util_file_is_regular_file(file_name))
1210 sprintf(Buf, catgets(Dtb_project_catd, 100, 70,
1211 "Cannot import %s.\n%s is not a regular file."),
1212 file_name, file_name);
1213 xm_buf = XmStringCreateLocalized(Buf);
1214 dtb_proj_error_msg_initialize(&dtb_proj_error_msg);
1216 help_data = (DtbObjectHelpData) util_malloc(sizeof(DtbObjectHelpDataRec));
1217 help_data->help_text = catgets(Dtb_project_catd, 100, 89,
1218 "The file you specified is a directory or\nanother special file.");
1219 help_data->help_volume = "";
1220 help_data->help_locationID = "";
1222 (void)dtb_show_modal_message(widget,
1223 &dtb_proj_error_msg, xm_buf, help_data, NULL);
1225 util_free(help_data);
1226 XmStringFree(xm_buf);
1230 ChooserInfo info = NULL;
1232 XtVaGetValues(AB_generic_chooser,
1236 if (info->ImportAsBil)
1238 /* Pop down the file chooser */
1239 XtUnmanageChild(widget);
1240 ab_check_and_import_bil(file_name, info->ImportByCopy);
1242 else /* Import as UIL */
1244 abio_access_file(file_name, &read_OK, &write_OK);
1247 /* Pop down the file chooser */
1248 XtUnmanageChild(widget);
1249 import_uil(file_name);
1253 sprintf(Buf, catgets(Dtb_project_catd, 100, 9,
1254 "%s does not have read permission."),
1256 util_printf_err(Buf);
1263 * Object rename callback
1264 * Update project organizer when module is renamed.
1267 projP_obj_renameOCB(
1268 ObjEvAttChangeInfo info
1271 ABObj obj = info->obj;
1275 * We only care about modules and projects here
1277 if (!obj || (!obj_is_module(obj) && !obj_is_project(obj)))
1281 * Update the module name only if the old name is not NULL.
1283 * If the old name is NULL that means this is a new object.
1284 * and we let the update callback handle that.
1286 if (info->old_name != NULL)
1287 proj_update_node(obj);
1294 * Object destroy callback
1295 * Remove viewer nodes from project organizer when module is destroyed.
1298 projP_obj_destroyOCB(
1299 ObjEvDestroyInfo info
1302 ABObj obj = info->obj;
1304 if (!obj || (!obj_is_module(obj) && !obj_is_project(obj)))
1307 if (obj->projwin_data)
1309 ABObj proj = obj_get_project(obj);
1315 * If the project is being destroyed, skip if the object passed in is
1316 * not the project itself. We do this so that proj_delete_objects() is
1317 * not called for every module in the project. Instead, it is called
1318 * just once for the project.
1320 if (obj_has_flag(proj, BeingDestroyedFlag) && !obj_is_project(obj))
1323 proj_delete_objects(obj);
1330 * projP_obj_updateOCB
1331 * Update project organizer when new modules are added
1334 projP_obj_updateOCB(
1335 ObjEvUpdateInfo info
1338 ABObj obj = info->obj;
1342 * We should only care about modules and projects
1345 if (!obj || (!obj_is_module(obj) && !obj_is_project(obj)))
1348 proj_add_objects(obj);
1354 * Action: mouse button down on browser
1364 XButtonEvent *bevent;
1366 if (event->type == ButtonPress)
1368 bevent = (XButtonEvent*)event;
1370 if (bevent->state == 0 && bevent->button == 1)/* RUBBERBAND SELECT */
1372 if (ui_initiate_rubberband(widget, True,
1373 project_rband, (XtPointer)NULL) == ERROR)
1375 if (util_get_verbosity() > 0)
1376 fprintf(stderr,"project organizer: couldn't begin rubberbanding\n");
1379 mselect_adjust = False;
1381 else if (bevent->button == 2 || /* RUBBERBAND ADJUST SELECT */
1382 (bevent->button == 1 && (bevent->state & ShiftMask)))
1384 if (ui_initiate_rubberband(widget, True,
1385 project_rband, (XtPointer)NULL) == ERROR)
1387 if (util_get_verbosity() > 0)
1388 fprintf(stderr,"project organizer: couldn't begin rubberbanding\n");
1391 mselect_adjust = True;
1397 * EventHandler: project organizer draw area drag action ...
1400 projP_drawarea_button_drag(
1402 XtPointer client_data,
1404 Boolean *cont_dispatch
1407 if (event->type == MotionNotify)
1409 if (((XMotionEvent*)event)->state & Button1Mask) /* RUBBERBAND SELECT */
1411 ui_button_drag(widget, event, client_data);
1413 else if (((XMotionEvent*)event)->state & Button2Mask) /* RUBBERBAND ADJUST */
1415 ui_button_drag(widget, event, client_data);
1425 XRectangle *rb_rect,
1426 XtPointer client_data
1430 VNode *selected_nodes = NULL;
1432 ABSelectedRec old_sel,
1434 XRectangle tmp_rect;
1435 int num_selected = 0,
1436 num_cur_selected = 0,
1439 XtVaGetValues(widget, XmNuserData, &v, NULL);
1444 if (!(m = v->methods))
1447 /* If rubberband was drawn from lower-right to upper-left,
1448 * translate rect so that x,y is upper-left point in rectangle.
1450 if (rect_right(rb_rect) < rb_rect->x ||
1451 rect_bottom(rb_rect) < rb_rect->y)
1453 tmp_rect.x = rect_right(rb_rect);
1454 tmp_rect.y = rect_bottom(rb_rect);
1455 tmp_rect.width = rb_rect->x - tmp_rect.x;
1456 tmp_rect.height = rb_rect->y - tmp_rect.y;
1457 rb_rect = &tmp_rect;
1461 * Important: set rband_rect so that
1462 * the function 'project_select_rband' can see it.
1464 rband_rect = rb_rect;
1467 * Get list of currently selected modules in project
1470 vwr_get_cond(v->current_tree, &selected_nodes,
1471 &num_selected, select_fn);
1475 * If select adjust, remember how many modules are currently
1478 num_cur_selected = num_selected;
1482 * If not select adjust, the current select count is reset
1484 num_cur_selected = 0;
1487 * Deselect all currently selected nodes
1489 for (i=0; i < num_selected; ++i)
1496 obj = (ABObj)selected_nodes[i]->obj_data;
1506 * Free up node list if it contained anything
1509 util_free(selected_nodes);
1512 * Get nodes in browser that are within the
1513 * rubber band rectangle.
1515 vwr_get_cond(v->current_tree, &selected_nodes,
1516 &num_selected, project_select_rband);
1519 * Update (activate/deactivate) project organizer menu items
1521 update_menu_items(0, num_cur_selected + num_selected);
1524 * Return if no selected nodes
1526 if (num_selected == 0) {
1527 free(selected_nodes);
1532 * For each object enclosed in rubber band rectangle
1534 for (i=0; i < num_selected; ++i)
1542 obj = (ABObj)selected_nodes[i]->obj_data;
1556 * Free up node list if it contained anything
1559 util_free(selected_nodes);
1563 proj_unmap_chooserCB(
1565 XtPointer clientData,
1569 ChooserInfo info = NULL;
1571 XtVaGetValues(AB_generic_chooser, XmNuserData, &info, NULL);
1573 /* Destroy the "extra" file chooser child if one
1574 * exists (i.e. Save Project As, Import Module, etc.)
1576 if (info->child != NULL)
1578 XtDestroyWidget(info->child);
1581 /* Set the appropriate File menu items and Project
1582 * Organizer Project and Module menu items active.
1584 pal_set_File_menu(info->chooser_type, TRUE);
1585 proj_set_menus(info->chooser_type, TRUE);