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
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 extern char *sys_errlist[];
232 char Buf[MAXPATHLEN]; /* Work buffer */
234 /*************************************************************************
236 ** Function Definitions
238 **************************************************************************/
239 static int select_fn(
244 * Project Window Xt callbacks
248 * Popup the project window by managing the container child of the
254 ABObj proj = proj_get_project();
256 ChooserInfo info = NULL;
258 if (AB_proj_window == NULL)
261 Proj_viewer = create_proj_struct();
263 create_proj_ui_handles(Proj_viewer);
264 proj_add_objects(proj);
266 /* Check if the shared file chooser is already
267 * up when the Project Organizer is displayed.
268 * If it is, then find out which one is up and
269 * set the appropriate menu items inactive.
271 if ((AB_generic_chooser != NULL) &&
272 XtIsManaged(AB_generic_chooser))
274 XtVaGetValues(AB_generic_chooser,
277 proj_set_menus(info->chooser_type, FALSE);
279 /* When the Project Organizer is first brought
280 * up, no modules are selected so certain menu
281 * items (like Module ->Save/Save As) should be
284 update_menu_items(0, 0);
286 ab_show_window(AB_proj_window);
287 abobj_update_proj_name( proj );
292 * Create callback for project window widgets
297 XtPointer client_data,
301 char *tmp_str = (char *)client_data;
304 widget_str = strtok(tmp_str, "+");
308 * If project viewer structure has not been initialized,
313 Proj_viewer = create_proj_struct();
316 XtVaSetValues(widget, XmNuserData, (XtPointer)Proj_viewer, NULL);
321 * Create viewer data structure for project window
327 extern VMethods projP_methods;
329 v = vwr_create(projP_methods);
337 XtPointer client_data,
341 ui_win_show(widget, False, NULL);
345 create_proj_ui_handles(
349 Widget draw_area = NULL;
353 dtbProjProjMainInfo_clear(&dtb_proj_proj_main);
356 * Create ui handle struct for project window
358 ui = aob_create_ui_obj();
360 (void)dtb_proj_proj_main_initialize(&dtb_proj_proj_main, AB_toplevel);
361 ui->shell = dtb_proj_proj_main.proj_main;
362 AB_proj_window = dtb_proj_proj_main.proj_main_mainwin;
364 ab_register_window(AB_proj_window, AB_WIN_WINDOW,
365 WindowHidden, AB_toplevel, AB_WPOS_TILE_VERTICAL,
366 popdown_proj_window, NULL);
370 * Until the generated code sets XmNmenuHelpWidget properly,
371 * this is a workaround.
373 XtVaSetValues(dtb_proj_proj_main.menubar,
374 XmNmenuHelpWidget, dtb_proj_proj_main.menubar_items.Help_item,
377 XtRealizeWidget(ui->shell);
379 ui->ip = (void *)&dtb_proj_proj_main;
381 v->ui_handle = (void *)ui;
383 if (!(draw_area = brws_draw_area(v)))
385 fprintf(stderr, "Can't find draw area widget for project\n");
390 * Set event handler on draw area for dragging/rubber banding
392 XtAddEventHandler(draw_area,
393 Button1MotionMask | Button2MotionMask, False,
394 projP_drawarea_button_drag, (XtPointer)NULL);
396 brwsP_make_drawarea_snap(v, draw_area);
398 setup_vwr_graphics(v);
400 enable_proj_actions(draw_area);
416 Proj_viewer = create_proj_struct();
422 project = obj_get_project(obj);
424 viewer = Proj_viewer;
427 (*m->insert_tree)(viewer, obj);
430 * Erase/redraw viewer
432 if (viewer->ui_handle)
435 * Don't need to erase viewer as a new node is
436 * added to end of the array of nodes in project window
437 erase_viewer(viewer);
459 project = obj_get_project(obj);
461 viewer = Proj_viewer;
464 (*m->remove_tree)(viewer, obj);
467 * Erase/redraw viewer
469 if (viewer->ui_handle)
471 erase_viewer(viewer);
477 * Register project actions with Xt
480 proj_register_actions(
484 XtAppAddActions(app, projwin_actions, XtNumber(projwin_actions));
488 * Enable project window actions
495 if (proj_transtbl == NULL)
500 len = strlen(base_translations) + 1;
502 if (AB_btn1_transfer == True) /* Button2 can be used for ADJUST */
503 len += strlen(btn2_adjust_translations);
505 translations = (String)util_malloc(len*sizeof(char));
506 if (translations == NULL)
509 strcpy(translations, base_translations);
510 if (AB_btn1_transfer == True) /* Button2 can be used for ADJUST */
511 strcat(translations, btn2_adjust_translations);
513 proj_transtbl = XtParseTranslationTable(translations);
515 util_free(translations);
518 /* enable build mode behavior */
519 XtVaSetValues(widget,
520 XtNtranslations, proj_transtbl,
525 * Disable project window actions
528 disable_proj_actions(
535 * Action: Select module in project window
550 XtVaGetValues(widget, XmNuserData, &v, NULL);
555 selected_node = vwr_locate_node(v,
556 event->xbutton.x, event->xbutton.y);
560 VNode *selected_nodes = NULL;
561 int num_selected = 0;
563 if (!(m = v->methods))
567 obj = (AB_OBJ *)selected_node->obj_data;
573 * Deselect all selected module nodes
574 * Select the module node
576 aob_deselect_all_nodes(v, TRUE);
579 vwr_get_cond(v->current_tree, &selected_nodes,
580 &num_selected, select_fn);
583 free((char *)selected_nodes);
585 update_menu_items(0, num_selected);
590 * Action: Toggle select module in project window
593 toggle_select_module(
605 XtVaGetValues(widget, XmNuserData, &v, NULL);
610 selected_node = vwr_locate_node(v,
611 event->xbutton.x, event->xbutton.y);
615 VNode *selected_nodes = NULL;
616 int num_selected = 0;
618 if (!(m = v->methods))
622 obj = (AB_OBJ *)selected_node->obj_data;
628 * Toggle select the module node
630 if (BRWS_NODE_STATE_IS_SET(selected_node, BRWS_NODE_SELECTED))
635 vwr_get_cond(v->current_tree, &selected_nodes,
636 &num_selected, select_fn);
639 free((char *)selected_nodes);
641 update_menu_items(0, num_selected);
646 * Action: Show the module when double-clicked on.
663 XtVaGetValues(widget, XmNuserData, &v, NULL);
668 selected_node = vwr_locate_node(v,
669 event->xbutton.x, event->xbutton.y);
673 VNode *selected_nodes = NULL;
674 int num_selected = 0;
676 if (!(m = v->methods))
680 obj = (ABObj) selected_node->obj_data;
686 * Set busy cursor before this potentially
689 ab_set_busy_cursor(TRUE);
691 /* If the module is already showing, then
692 * make all of its windows come to the fore-
695 if (obj_has_flag(obj, MappedFlag))
697 for (trav_open(&trav, obj, AB_TRAV_WINDOWS);
698 (winobj = trav_next(&trav)) != NULL; )
700 if (obj_has_flag(winobj, MappedFlag))
701 ui_win_front(objxm_get_widget(winobj));
704 proj_set_cur_module(obj);
706 else if( abobj_show_tree(obj, TRUE) == -1 )
708 if (util_get_verbosity() > 0)
709 fprintf(stderr,"show_module: error in abobj_show_tree\n");
713 proj_set_cur_module(obj);
716 vwr_get_cond(v->current_tree, &selected_nodes,
717 &num_selected, select_fn);
720 free((char *)selected_nodes);
722 update_menu_items(0, num_selected);
727 ab_set_busy_cursor(FALSE);
737 if (BRWS_NODE_STATE_IS_SET(module, BRWS_NODE_SELECTED))
744 project_select_rband(
749 if (!vnode || !rband_rect)
752 if (((int)rband_rect->x <= vnode->x) &&
753 ((int)(rband_rect->x + (short)rband_rect->width) >= (vnode->x + vnode->width)) &&
754 ((int)rband_rect->y <= vnode->y) &&
755 ((int)(rband_rect->y + (short)rband_rect->height) >= vnode->y + vnode->height))
762 * Update the sensitivity of menu items depending on
763 * the old/new count of modules selected.
765 * NOTE: Currently, this proc does not use the old_count
766 * param. It will, in future use it for optimization.
776 no_module_selected(&dtb_proj_proj_main);
782 one_module_selected(&dtb_proj_proj_main);
786 mult_module_selected(&dtb_proj_proj_main);
790 * no_module_selected()
791 * No module is currently selected, so desensitize all
792 * relevant menu items
796 DtbProjProjMainInfo proj_w
799 ProjModMenubuttonMenuItems menu_rec;
804 menu_rec = &(proj_w->menubar_Module_item_mod_menubutton_menu_items);
806 ui_set_active(menu_rec->Save_item, FALSE);
807 ui_set_active(menu_rec->Save_As_item, FALSE);
808 ui_set_active(menu_rec->Show_item, FALSE);
809 ui_set_active(menu_rec->Hide_item, FALSE);
810 ui_set_active(menu_rec->Browse_item, FALSE);
811 ui_set_active(menu_rec->Export_item, FALSE);
812 ui_set_active(menu_rec->Remove_item, FALSE);
816 * one_module_selected()
817 * One module is currently selected, so make all
818 * menu items sensitive
822 DtbProjProjMainInfo proj_w
825 ProjModMenubuttonMenuItems menu_rec;
826 ChooserInfo info = NULL;
830 menu_rec = &(proj_w->menubar_Module_item_mod_menubutton_menu_items);
832 ui_set_active(menu_rec->Show_item, TRUE);
833 ui_set_active(menu_rec->Hide_item, TRUE);
834 ui_set_active(menu_rec->Browse_item, TRUE);
835 ui_set_active(menu_rec->Remove_item, TRUE);
837 /* If the FSB has not been created yet or if it has
838 * been created but it is not displayed, then make
839 * the menu items active.
841 if ((AB_generic_chooser == NULL) ||
842 !XtIsManaged(AB_generic_chooser))
844 ui_set_active(menu_rec->Save_item, TRUE);
845 ui_set_active(menu_rec->Save_As_item, TRUE);
846 ui_set_active(menu_rec->Import_item, TRUE);
847 ui_set_active(menu_rec->Export_item, TRUE);
849 else if (XtIsManaged(AB_generic_chooser))
851 XtVaGetValues(AB_generic_chooser, XmNuserData, &info, NULL);
852 if (info->chooser_type == AB_EXPORT_CHOOSER)
854 ui_set_active(menu_rec->Export_item, TRUE);
856 else if (info->chooser_type == AB_SAVE_PROJ_AS_CHOOSER)
858 ui_set_active(menu_rec->Save_item, TRUE);
859 ui_set_active(menu_rec->Save_As_item, TRUE);
861 else if (info->chooser_type == AB_IMPORT_CHOOSER)
863 ui_set_active(menu_rec->Import_item, TRUE);
869 * mult_module_selected()
870 * Multiple modules are currently selected.
871 * We desensitize the Save/Save As/Export buttons
872 * because the choossers cannot handle multiple
873 * saves at the moment...
876 mult_module_selected(
877 DtbProjProjMainInfo proj_w
880 ProjModMenubuttonMenuItems menu_rec;
885 menu_rec = &(proj_w->menubar_Module_item_mod_menubutton_menu_items);
887 ui_set_active(menu_rec->Save_item, FALSE);
888 ui_set_active(menu_rec->Save_As_item, FALSE);
889 ui_set_active(menu_rec->Export_item, FALSE);
890 ui_set_active(menu_rec->Show_item, TRUE);
891 ui_set_active(menu_rec->Hide_item, TRUE);
892 ui_set_active(menu_rec->Browse_item, TRUE);
893 ui_set_active(menu_rec->Remove_item, TRUE);
900 obj_add_rename_callback(projP_obj_renameOCB, "PROJ");
901 obj_add_destroy_callback(projP_obj_destroyOCB, "PROJ");
902 obj_add_update_callback(projP_obj_updateOCB, "PROJ");
904 AB_project = obj_create(AB_TYPE_PROJECT, NULL);
905 obj_set_name(AB_project, "project");
906 abobj_show_tree(AB_project, TRUE);
911 /* This destroys the current project and creates
912 * a new default project named "project" since
913 * dtbuilder can never have a NULL project.
916 proj_destroy_project(
920 obj_set_flag(proj, BeingDestroyedFlag);
922 proj_create_new_proj(NULL);
934 * Update project window and browsers
938 /* Initialize the current module to NULL,
939 * since no modules are showing yet.
941 proj_set_cur_module(NULL);
943 cgen_notify_new_project(AB_project);
944 appfw_notify_new_project(AB_project);
963 if ( (module != NULL) && (obj_get_type(module) != AB_TYPE_MODULE) )
966 AB_cur_module = module;
968 ab_update_stat_region(AB_STATUS_CUR_MODULE, obj_get_name(module));
970 ab_update_stat_region(AB_STATUS_CUR_MODULE, NULL);
979 return AB_cur_module;
988 if ( !obj_is_module(module) )
991 abobj_set_name(module, name);
993 if (abobj_update_module_name(module) == -1)
996 /* Update the browser */
997 brws_update_node(module);
999 /* Update the project window */
1000 proj_update_node(module);
1002 if (module == proj_get_cur_module())
1004 if (ab_update_stat_region(AB_STATUS_CUR_MODULE, name) == -1)
1011 * Action: Update "Module Path:" in the project window
1012 * whenever the user moves the pointer over a
1016 pointer_motion_proc(
1024 VNode node_under_pointer = NULL;
1026 XMotionEvent *mevent = (XMotionEvent*)event;
1027 char mod_path[MAXPATHLEN] = "";
1029 util_dprintf(2, "pointer_motion_proc:\n");
1030 XtVaGetValues(widget, XmNuserData, &v, NULL);
1035 node_under_pointer = vwr_locate_node(v,
1036 mevent->x, mevent->y);
1037 if (node_under_pointer != NULL)
1039 /* USE METHODS !! */
1040 obj = (AB_OBJ *)node_under_pointer->obj_data;
1045 util_dprintf(2, "\tmodule name is %s\n", obj_get_name(obj));
1047 /* If the module has not been saved, file will be NULL */
1048 if (obj_get_file(obj) != NULL)
1050 util_get_dir_name_from_path(obj_get_file(obj), mod_path,
1055 strcpy(mod_path, ".");
1058 util_dprintf(2, "\tmodule path is %s\n", mod_path);
1060 if (!util_strempty(mod_path))
1062 util_dprintf(2, "\tupdating the project window status region\n");
1063 proj_update_stat_region(PROJ_STATUS_MOD_PATH, mod_path);
1068 /* If we're not over a node, clear out the module
1069 * path status label in the project window.
1071 util_dprintf(2, "\tpointer is not positioned over a node\n");
1072 proj_update_stat_region(PROJ_STATUS_MOD_PATH, NULL);
1079 STRING uil_file_name
1082 ABObj project = proj_get_project();
1083 ABObjPtr uil_interface;
1085 if ((uil_interface = abuil_get_uil_file(uil_file_name, project))
1088 fprintf(stderr, "Failed to import %s.\n", uil_file_name);
1092 fprintf(stderr, "Succesfully imported %s.\n", uil_file_name);
1094 obj_set_flag(project, SaveNeededFlag);
1099 abobj_show_tree(uil_interface, TRUE);
1100 abobj_set_save_needed(project, TRUE);
1104 proj_open_proj_okCB(
1106 XtPointer client_data,
1107 XmSelectionBoxCallbackStruct *call_data
1110 STRING proj_filename = (STRING) NULL;
1111 XmString xm_buf = (XmString) NULL;
1112 DtbObjectHelpData help_data = NULL;
1114 proj_filename = (STRING)objxm_xmstr_to_str(call_data->value);
1116 /* If the file chooser selection text field is empty, return */
1117 if ( util_strempty(proj_filename) )
1119 dtb_proj_no_name_msg_initialize(&dtb_proj_no_name_msg);
1120 (void)dtb_show_modal_message(widget,
1121 &dtb_proj_no_name_msg, NULL, NULL, NULL);
1123 else if (!util_file_exists(proj_filename))
1125 sprintf(Buf, catgets(Dtb_project_catd, 100, 8,
1126 "The file %s does not exist."), proj_filename);
1127 util_printf_err(Buf);
1129 else if (!util_file_is_regular_file(proj_filename))
1131 sprintf(Buf, catgets(Dtb_project_catd, 100, 69,
1132 "Cannot open %s.\n%s is not a regular file."),
1133 proj_filename, proj_filename);
1134 xm_buf = XmStringCreateLocalized(Buf);
1135 dtb_proj_error_msg_initialize(&dtb_proj_error_msg);
1137 help_data = (DtbObjectHelpData) util_malloc(sizeof(DtbObjectHelpDataRec));
1138 help_data->help_text = catgets(Dtb_project_catd, 100, 89,
1139 "The file you specified is a directory or\nanother special file.");
1140 help_data->help_volume = "";
1141 help_data->help_locationID = "";
1143 (void)dtb_show_modal_message(widget,
1144 &dtb_proj_error_msg, xm_buf, help_data, NULL);
1146 util_free(help_data);
1147 XmStringFree(xm_buf);
1151 XtUnmanageChild(widget); /* pop down the chooser */
1152 ab_check_and_open_bip(proj_filename);
1159 XtPointer client_data,
1160 XmSelectionBoxCallbackStruct *call_data
1163 /* Pop down the file chooser. This must be done
1164 * explicitly because the file chooser autoUnmanage
1165 * resource was set to FALSE.
1167 XtUnmanageChild(widget);
1174 XtPointer client_data,
1175 XmSelectionBoxCallbackStruct *call_data
1178 STRING file_name = (STRING) NULL;
1179 XmString xm_buf = (XmString) NULL;
1180 BOOL read_OK, write_OK;
1181 DtbObjectHelpData help_data = NULL;
1183 if (call_data->reason != XmCR_OK)
1188 file_name = (STRING)objxm_xmstr_to_str(call_data->value);
1190 /* If the file chooser selection text field is empty,
1191 * return, leaving the chooser up to give the user
1194 if (util_strempty(file_name))
1196 dtb_proj_no_name_msg_initialize(&dtb_proj_no_name_msg);
1197 (void)dtb_show_modal_message(widget,
1198 &dtb_proj_no_name_msg, NULL, NULL, NULL);
1200 else if (!util_file_exists(file_name))
1202 /* If the file specified does not exist, keep up the file
1203 * chooser so that the user can specify another file.
1205 sprintf(Buf, catgets(Dtb_project_catd, 100, 8,
1206 "The file %s does not exist."), file_name);
1207 util_printf_err(Buf);
1209 else if (!util_file_is_regular_file(file_name))
1211 sprintf(Buf, catgets(Dtb_project_catd, 100, 70,
1212 "Cannot import %s.\n%s is not a regular file."),
1213 file_name, file_name);
1214 xm_buf = XmStringCreateLocalized(Buf);
1215 dtb_proj_error_msg_initialize(&dtb_proj_error_msg);
1217 help_data = (DtbObjectHelpData) util_malloc(sizeof(DtbObjectHelpDataRec));
1218 help_data->help_text = catgets(Dtb_project_catd, 100, 89,
1219 "The file you specified is a directory or\nanother special file.");
1220 help_data->help_volume = "";
1221 help_data->help_locationID = "";
1223 (void)dtb_show_modal_message(widget,
1224 &dtb_proj_error_msg, xm_buf, help_data, NULL);
1226 util_free(help_data);
1227 XmStringFree(xm_buf);
1231 ChooserInfo info = NULL;
1233 XtVaGetValues(AB_generic_chooser,
1237 if (info->ImportAsBil)
1239 /* Pop down the file chooser */
1240 XtUnmanageChild(widget);
1241 ab_check_and_import_bil(file_name, info->ImportByCopy);
1243 else /* Import as UIL */
1245 abio_access_file(file_name, &read_OK, &write_OK);
1248 /* Pop down the file chooser */
1249 XtUnmanageChild(widget);
1250 import_uil(file_name);
1254 sprintf(Buf, catgets(Dtb_project_catd, 100, 9,
1255 "%s does not have read permission."),
1257 util_printf_err(Buf);
1264 * Object rename callback
1265 * Update project organizer when module is renamed.
1268 projP_obj_renameOCB(
1269 ObjEvAttChangeInfo info
1272 ABObj obj = info->obj;
1276 * We only care about modules and projects here
1278 if (!obj || (!obj_is_module(obj) && !obj_is_project(obj)))
1282 * Update the module name only if the old name is not NULL.
1284 * If the old name is NULL that means this is a new object.
1285 * and we let the update callback handle that.
1287 if (info->old_name != NULL)
1288 proj_update_node(obj);
1295 * Object destroy callback
1296 * Remove viewer nodes from project organizer when module is destroyed.
1299 projP_obj_destroyOCB(
1300 ObjEvDestroyInfo info
1303 ABObj obj = info->obj;
1305 if (!obj || (!obj_is_module(obj) && !obj_is_project(obj)))
1308 if (obj->projwin_data)
1310 ABObj proj = obj_get_project(obj);
1316 * If the project is being destroyed, skip if the object passed in is
1317 * not the project itself. We do this so that proj_delete_objects() is
1318 * not called for every module in the project. Instead, it is called
1319 * just once for the project.
1321 if (obj_has_flag(proj, BeingDestroyedFlag) && !obj_is_project(obj))
1324 proj_delete_objects(obj);
1331 * projP_obj_updateOCB
1332 * Update project organizer when new modules are added
1335 projP_obj_updateOCB(
1336 ObjEvUpdateInfo info
1339 ABObj obj = info->obj;
1343 * We should only care about modules and projects
1346 if (!obj || (!obj_is_module(obj) && !obj_is_project(obj)))
1349 proj_add_objects(obj);
1355 * Action: mouse button down on browser
1365 XButtonEvent *bevent;
1367 if (event->type == ButtonPress)
1369 bevent = (XButtonEvent*)event;
1371 if (bevent->state == 0 && bevent->button == 1)/* RUBBERBAND SELECT */
1373 if (ui_initiate_rubberband(widget, True,
1374 project_rband, (XtPointer)NULL) == ERROR)
1376 if (util_get_verbosity() > 0)
1377 fprintf(stderr,"project organizer: couldn't begin rubberbanding\n");
1380 mselect_adjust = False;
1382 else if (bevent->button == 2 || /* RUBBERBAND ADJUST SELECT */
1383 (bevent->button == 1 && (bevent->state & ShiftMask)))
1385 if (ui_initiate_rubberband(widget, True,
1386 project_rband, (XtPointer)NULL) == ERROR)
1388 if (util_get_verbosity() > 0)
1389 fprintf(stderr,"project organizer: couldn't begin rubberbanding\n");
1392 mselect_adjust = True;
1398 * EventHandler: project organizer draw area drag action ...
1401 projP_drawarea_button_drag(
1403 XtPointer client_data,
1405 Boolean *cont_dispatch
1408 if (event->type == MotionNotify)
1410 if (((XMotionEvent*)event)->state & Button1Mask) /* RUBBERBAND SELECT */
1412 ui_button_drag(widget, event, client_data);
1414 else if (((XMotionEvent*)event)->state & Button2Mask) /* RUBBERBAND ADJUST */
1416 ui_button_drag(widget, event, client_data);
1426 XRectangle *rb_rect,
1427 XtPointer client_data
1431 VNode *selected_nodes = NULL;
1433 ABSelectedRec old_sel,
1435 XRectangle tmp_rect;
1436 int num_selected = 0,
1437 num_cur_selected = 0,
1440 XtVaGetValues(widget, XmNuserData, &v, NULL);
1445 if (!(m = v->methods))
1448 /* If rubberband was drawn from lower-right to upper-left,
1449 * translate rect so that x,y is upper-left point in rectangle.
1451 if (rect_right(rb_rect) < rb_rect->x ||
1452 rect_bottom(rb_rect) < rb_rect->y)
1454 tmp_rect.x = rect_right(rb_rect);
1455 tmp_rect.y = rect_bottom(rb_rect);
1456 tmp_rect.width = rb_rect->x - tmp_rect.x;
1457 tmp_rect.height = rb_rect->y - tmp_rect.y;
1458 rb_rect = &tmp_rect;
1462 * Important: set rband_rect so that
1463 * the function 'project_select_rband' can see it.
1465 rband_rect = rb_rect;
1468 * Get list of currently selected modules in project
1471 vwr_get_cond(v->current_tree, &selected_nodes,
1472 &num_selected, select_fn);
1476 * If select adjust, remember how many modules are currently
1479 num_cur_selected = num_selected;
1483 * If not select adjust, the current select count is reset
1485 num_cur_selected = 0;
1488 * Deselect all currently selected nodes
1490 for (i=0; i < num_selected; ++i)
1497 obj = (ABObj)selected_nodes[i]->obj_data;
1507 * Free up node list if it contained anything
1510 util_free(selected_nodes);
1513 * Get nodes in browser that are within the
1514 * rubber band rectangle.
1516 vwr_get_cond(v->current_tree, &selected_nodes,
1517 &num_selected, project_select_rband);
1520 * Update (activate/deactivate) project organizer menu items
1522 update_menu_items(0, num_cur_selected + num_selected);
1525 * Return if no selected nodes
1527 if (num_selected == 0)
1531 * For each object enclosed in rubber band rectangle
1533 for (i=0; i < num_selected; ++i)
1541 obj = (ABObj)selected_nodes[i]->obj_data;
1555 * Free up node list if it contained anything
1558 util_free(selected_nodes);
1562 proj_unmap_chooserCB(
1564 XtPointer clientData,
1568 ChooserInfo info = NULL;
1570 XtVaGetValues(AB_generic_chooser, XmNuserData, &info, NULL);
1572 /* Destroy the "extra" file chooser child if one
1573 * exists (i.e. Save Project As, Import Module, etc.)
1575 if (info->child != NULL)
1577 XtDestroyWidget(info->child);
1580 /* Set the appropriate File menu items and Project
1581 * Organizer Project and Module menu items active.
1583 pal_set_File_menu(info->chooser_type, TRUE);
1584 proj_set_menus(info->chooser_type, TRUE);