static int write_main_xt_i18n( GenCodeInfo genCodeInfo, ABObj project ) { File codeFile; int ret_val = 0; if (!genCodeInfo || !project) goto cret; codeFile = genCodeInfo->code_file; abio_puts(codeFile, nlstr); abmfP_write_c_comment(genCodeInfo, TRUE, "NULL language_proc installs the default Xt language procedure"); abio_puts(codeFile, "XtSetLanguageProc((XtAppContext)NULL,\n"); abio_indent(codeFile); abio_puts(codeFile, "language_proc, language_proc_client_data);\n"); abio_outdent(codeFile); abio_puts(codeFile, "\n"); cret: return(ret_val); }
static int write_app_resource_struct( GenCodeInfo genCodeInfo, ABObj project ) { File codeFile; if (!genCodeInfo || !project) return (0); codeFile = genCodeInfo->code_file; abio_puts(codeFile,"\n"); abmfP_write_c_comment(genCodeInfo, FALSE, "Structure to store values for Application Resources"); abio_puts(codeFile,"typedef struct {\n"); abio_indent(codeFile); abio_puts(codeFile,"char *session_file;\n"); abio_puts(codeFile,"\n"); abmfP_write_user_struct_fields_seg(genCodeInfo); abio_outdent(codeFile); abio_puts(codeFile, "} DtbAppResourceRec;\n"); abio_puts(codeFile,"\n"); return (0); }
static int write_popup_menu_vars(GenCodeInfo genCodeInfo, ABObj project) { abio_puts(genCodeInfo->code_file, nlstr); abmfP_write_c_comment(genCodeInfo, FALSE, "Variables that keep track of which menus go with which widgets"); abio_puts(genCodeInfo->code_file, "static DtbMenuRef\tpopupMenus = NULL;\n" "static int\tnumPopupMenus = 0;\n"); return 0; }
static int write_save_command_var(GenCodeInfo genCodeInfo, ABObj project) { File codeFile; if (!genCodeInfo || !project) return (0); codeFile = genCodeInfo->code_file; abio_puts(codeFile, nlstr); abmfP_write_c_comment(genCodeInfo, FALSE, "Variable for storing command used to invoke application"); abio_puts(codeFile, "static char\t\t\t\t*dtb_save_command_str = (char *)NULL;\n"); return (0); }
static int write_all_static_func_decls(GenCodeInfo genCodeInfo, ABObj project) { File codeFile= genCodeInfo->code_file; write_centering_static_func_decls(genCodeInfo, project); if (abmfP_proj_has_message(project)) write_msg_static_func_decls(genCodeInfo, project); /* * Write out static functions for aligning objects in groups */ write_align_static_func_decls(genCodeInfo, project); /* * private path-determing functions */ abio_puts(genCodeInfo->code_file, nlstr); abmfP_write_c_comment(genCodeInfo, FALSE, "Private functions used for finding paths"); abio_printf(codeFile, "%s\n\n", abmfP_lib_determine_exe_dir->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_determine_exe_dir_from_argv->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_determine_exe_dir_from_path->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_path_is_executable->proto); /* private popup menu functions */ abio_printf(codeFile, "%s\n\n", abmfP_lib_popup_menu->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_popup_menu_destroyCB->proto); /* * static drag functions */ abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_terminate->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_button1_motion_handler->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_start->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_convertCB->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_to_rootCB->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_drag_finishCB->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_drop_animateCB->proto); abio_printf(codeFile, "%s\n\n", abmfP_lib_drop_transferCB->proto); return 0; }
static int write_all_vars(GenCodeInfo genCodeInfo, ABObj project) { File codeFile = genCodeInfo->code_file; write_session_CB_vars(genCodeInfo, project); write_tooltalk_CB_vars(genCodeInfo, project); write_save_toplevel_widget_var(genCodeInfo, project); write_save_command_var(genCodeInfo, project); write_popup_menu_vars(genCodeInfo, project); write_dnd_vars(genCodeInfo, project); /* * write path-to-executable var */ abio_puts(codeFile, nlstr); abmfP_write_c_comment(genCodeInfo, FALSE, "Directory where the binary for this process whate loaded from"); abio_puts(codeFile, "static char\t\t\t\t*dtb_exe_dir = (char *)NULL;\n"); return 0; }
static int write_all_lib_funcs(GenCodeInfo genCodeInfo, ABObj project) { File codeFile= genCodeInfo->code_file; abio_puts(codeFile, "\n"); abmfP_write_c_comment(genCodeInfo, FALSE, "Application Builder utility funcs"); write_lib_func(genCodeInfo, abmfP_lib_cvt_file_to_pixmap); write_lib_func(genCodeInfo, abmfP_lib_set_label_from_bitmap_data); write_lib_func(genCodeInfo, abmfP_lib_set_label_pixmaps); write_lib_func(genCodeInfo, abmfP_lib_file_has_extension); write_lib_func(genCodeInfo, abmfP_lib_cvt_filebase_to_pixmap); write_lib_func(genCodeInfo, abmfP_lib_cvt_image_file_to_pixmap); write_lib_func(genCodeInfo, abmfP_lib_set_label_from_image_file); write_lib_func(genCodeInfo, abmfP_lib_cvt_resource_from_string); write_lib_func(genCodeInfo, abmfP_lib_create_greyed_pixmap); write_lib_func(genCodeInfo, abmfP_lib_save_toplevel_widget); write_lib_func(genCodeInfo, abmfP_lib_get_toplevel_widget); write_lib_func(genCodeInfo, abmfP_lib_remove_sash_focus); write_lib_func(genCodeInfo, abmfP_lib_save_command); write_lib_func(genCodeInfo, abmfP_lib_get_command); write_lib_func(genCodeInfo, abmfP_lib_help_dispatch); write_lib_func(genCodeInfo, abmfP_lib_more_help_dispatch); write_lib_func(genCodeInfo, abmfP_lib_help_back_hdlr); write_lib_func(genCodeInfo, abmfP_lib_do_onitem_help); write_lib_func(genCodeInfo, abmfP_lib_show_help_volume_info); write_lib_func(genCodeInfo, abmfP_lib_call_help_callback); /* * The session save callback is written out always */ write_lib_func(genCodeInfo, abmfP_lib_session_save); write_lib_func(genCodeInfo, abmfP_lib_get_client_session_saveCB); if (abmfP_proj_needs_session_save(project)) { write_lib_func(genCodeInfo, abmfP_lib_set_client_session_saveCB); } if (abmfP_proj_needs_session_restore(project)) { write_lib_func(genCodeInfo, abmfP_lib_session_restore); write_lib_func(genCodeInfo, abmfP_lib_set_client_session_restoreCB); write_lib_func(genCodeInfo, abmfP_lib_get_client_session_restoreCB); } /* * Write out ToolTalk functions if needed */ switch(obj_get_tooltalk_level(project)) { case AB_TOOLTALK_DESKTOP_ADVANCED: write_lib_func(genCodeInfo, abmfP_lib_set_tt_msg_quitCB); write_lib_func(genCodeInfo, abmfP_lib_get_tt_msg_quitCB); write_lib_func(genCodeInfo, abmfP_lib_tt_msg_quit); write_lib_func(genCodeInfo, abmfP_lib_set_tt_msg_do_commandCB); write_lib_func(genCodeInfo, abmfP_lib_get_tt_msg_do_commandCB); write_lib_func(genCodeInfo, abmfP_lib_tt_msg_do_command); write_lib_func(genCodeInfo, abmfP_lib_set_tt_msg_get_statusCB); write_lib_func(genCodeInfo, abmfP_lib_get_tt_msg_get_statusCB); write_lib_func(genCodeInfo, abmfP_lib_tt_msg_get_status); write_lib_func(genCodeInfo, abmfP_lib_set_tt_msg_pause_resumeCB); write_lib_func(genCodeInfo, abmfP_lib_get_tt_msg_pause_resumeCB); write_lib_func(genCodeInfo, abmfP_lib_tt_msg_pause_resume); write_lib_func(genCodeInfo, abmfP_lib_tt_contractCB); /* fall through */ case AB_TOOLTALK_DESKTOP_BASIC: write_lib_func(genCodeInfo, abmfP_lib_tt_close); break; default: break; } /* Write out Message posting utilities */ if (abmfP_proj_has_message(project)) { write_lib_func(genCodeInfo, abmfP_lib_create_message_dlg); write_lib_func(genCodeInfo, abmfP_lib_destroyCB); write_lib_func(genCodeInfo, abmfP_lib_MessageBoxGetActionButton); write_lib_func(genCodeInfo, abmfP_lib_show_message); write_lib_func(genCodeInfo, abmfP_lib_show_modal_message); write_lib_func(genCodeInfo, abmfP_lib_modal_dlgCB); } /* Write out centering routines */ write_lib_func(genCodeInfo, abmfP_lib_children_center); write_lib_func(genCodeInfo, abmfP_lib_children_uncenter); write_lib_func(genCodeInfo, abmfP_lib_center); write_lib_func(genCodeInfo, abmfP_lib_uncenter); write_lib_func(genCodeInfo, abmfP_lib_center_widget); write_lib_func(genCodeInfo, abmfP_lib_uncenter_widget); write_lib_func(genCodeInfo, abmfP_lib_centering_handler); /* Write out align routines */ write_lib_func(genCodeInfo, abmfP_lib_get_label_widget); write_lib_func(genCodeInfo, abmfP_lib_get_offset_from_ancestor); write_lib_func(genCodeInfo, abmfP_lib_get_label_width); write_lib_func(genCodeInfo, abmfP_lib_get_widest_label); write_lib_func(genCodeInfo, abmfP_lib_get_widest_value); write_lib_func(genCodeInfo, abmfP_lib_get_widget_rect); write_lib_func(genCodeInfo, abmfP_lib_get_greatest_size); write_lib_func(genCodeInfo, abmfP_lib_get_group_cell_size); write_lib_func(genCodeInfo, abmfP_lib_get_group_row_col); write_lib_func(genCodeInfo, abmfP_lib_get_group_child); write_lib_func(genCodeInfo, abmfP_lib_children_align); write_lib_func(genCodeInfo, abmfP_lib_align_children); write_lib_func(genCodeInfo, abmfP_lib_align_handler); write_lib_func(genCodeInfo, abmfP_lib_expose_handler); write_lib_func(genCodeInfo, abmfP_lib_free_group_info); write_lib_func(genCodeInfo, abmfP_lib_align_rows); write_lib_func(genCodeInfo, abmfP_lib_align_cols); write_lib_func(genCodeInfo, abmfP_lib_align_left); write_lib_func(genCodeInfo, abmfP_lib_align_right); write_lib_func(genCodeInfo, abmfP_lib_align_labels); write_lib_func(genCodeInfo, abmfP_lib_align_vcenter); write_lib_func(genCodeInfo, abmfP_lib_align_top); write_lib_func(genCodeInfo, abmfP_lib_align_bottom); write_lib_func(genCodeInfo, abmfP_lib_align_hcenter); /* Write out path-finding routines */ write_lib_func(genCodeInfo, abmfP_lib_get_exe_dir); write_lib_func(genCodeInfo, abmfP_lib_determine_exe_dir); write_lib_func(genCodeInfo, abmfP_lib_determine_exe_dir_from_argv); write_lib_func(genCodeInfo, abmfP_lib_determine_exe_dir_from_path); write_lib_func(genCodeInfo, abmfP_lib_path_is_executable); /* write out popup menu routines */ write_lib_func(genCodeInfo, abmfP_lib_popup_menu_register); write_lib_func(genCodeInfo, abmfP_lib_popup_menu); write_lib_func(genCodeInfo, abmfP_lib_popup_menu_destroyCB); /* Write out drag and drop routines */ write_lib_func(genCodeInfo, abmfP_lib_drag_site_register); write_lib_func(genCodeInfo, abmfP_lib_drop_site_register); write_lib_func(genCodeInfo, abmfP_lib_drag_terminate); write_lib_func(genCodeInfo, abmfP_lib_drag_button1_motion_handler); write_lib_func(genCodeInfo, abmfP_lib_drag_start); write_lib_func(genCodeInfo, abmfP_lib_drag_convertCB); write_lib_func(genCodeInfo, abmfP_lib_drag_to_rootCB); write_lib_func(genCodeInfo, abmfP_lib_drag_finishCB); write_lib_func(genCodeInfo, abmfP_lib_drop_animateCB); write_lib_func(genCodeInfo, abmfP_lib_drop_transferCB); return 0; }
/* * Write main() for the given project. */ static int write_main(GenCodeInfo genCodeInfo, ABObj project) { int returnValue = 0; File codeFile = genCodeInfo->code_file; ABObj window = NULL; int initialized = FALSE; ABObj main_window= NULL; AB_TRAVERSAL trav; BOOL mainWindowHasIcon = FALSE; abmfP_gencode_enter_func(genCodeInfo); main_window = abmfP_get_root_window(project); if (main_window != NULL) { mfobj_set_flags(main_window, CGenFlagTreatAsAppShell); } mainWindowHasIcon = ( (main_window != NULL) && ( (obj_get_icon(main_window) != NULL) || (obj_get_icon_mask(main_window) != NULL)) ); abio_puts(codeFile, "\n\n"); abio_puts(codeFile, abmfP_comment_begin); abio_puts(codeFile, abmfP_comment_continue); abio_printf(codeFile, "main for application %s\n", obj_get_name(project)); abio_puts(codeFile, abmfP_comment_end); /* * Write func declaration. */ abio_puts(codeFile, "int\n"); if (genCodeInfo->prototype_funcs) { abio_puts(codeFile, "main(int argc, char **argv)\n"); } else { abio_puts(codeFile, "main(argc, argv)\n"); abio_indent(codeFile); abio_puts(codeFile, "int\t\targc;\n"); abio_puts(codeFile, "char\t\t**argv;\n"); abio_outdent(codeFile); } abio_puts(codeFile, "{\n"); abio_set_indent(codeFile, 1); /* * Local variables */ abio_puts(codeFile, "Widget\t\ttoplevel = (Widget)NULL;\n"); abio_puts(codeFile, "Display\t\t*display = (Display*)NULL;\n"); abio_puts(codeFile, "XtAppContext\tapp = (XtAppContext)NULL;\n"); abio_puts(codeFile, "String\t\t*fallback_resources = (String*)NULL;\n"); abio_puts(codeFile, "ArgList\t\tinit_args = (ArgList)NULL;\n"); abio_puts(codeFile, "Cardinal\t\tnum_init_args = (Cardinal)0;\n"); abio_puts(codeFile, "ArgList\t\tget_resources_args = (ArgList)NULL;\n"); abio_puts(codeFile, "Cardinal\t\tnum_get_resources_args = (Cardinal)0;\n"); abio_puts(codeFile, "Atom\t\tsave_yourself_atom = (Atom)NULL;\n"); write_main_i18n_local_vars(genCodeInfo, project); write_main_tooltalk_local_vars(genCodeInfo, project); abio_puts(codeFile, nlstr); if (mainWindowHasIcon) { abmfP_icon_pixmap_var(genCodeInfo) = istr_const("icon_pixmap"); abmfP_icon_mask_pixmap_var(genCodeInfo) = istr_const("icon_mask_pixmap"); abio_puts(codeFile, "Pixmap\ticon_pixmap = NULL;\n"); abio_puts(codeFile, "Pixmap\ticon_mask_pixmap = NULL;\n"); } abmfP_write_user_long_seg(genCodeInfo, " No initialization has been done.\n" " ***\n" " *** Add local variables and code." ); if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API) write_main_xt_i18n(genCodeInfo, project); /* * Create a parent shell for every other shell and don't realize it. This * way, we can be consistent with our hierarchy. */ abio_printf(codeFile,"toplevel = XtAppInitialize(&app, \"%s\",\n", abmfP_capitalize_first_char(obj_get_name(project))); abio_indent(codeFile); abio_puts(codeFile, "optionDescList, XtNumber(optionDescList),\n"); abio_puts(codeFile, "&argc, argv, fallback_resources,\n"); abio_puts(codeFile, "init_args, num_init_args);\n\n"); abio_outdent(codeFile); abmfP_write_c_comment(genCodeInfo, FALSE, "Get display and verify initialization was successful."); abio_puts(codeFile, "if (toplevel != NULL)\n"); abmfP_write_c_block_begin(genCodeInfo); abio_puts(codeFile, "display = XtDisplayOfObject(toplevel);\n"); abmfP_write_c_block_end(genCodeInfo); if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API) write_main_msg_i18n(genCodeInfo, project); abio_puts(codeFile, "if (display == NULL)\n"); abmfP_write_c_block_begin(genCodeInfo); abio_puts(codeFile, "fprintf(stderr, \"Could not open display.\");\n"); abio_puts(codeFile, "exit(1);\n"); abmfP_write_c_block_end(genCodeInfo); /* Save the toplevel widget so it can be fetched later as needed */ abio_puts(codeFile,"\n"); abmfP_write_c_comment(genCodeInfo, FALSE, "Save the toplevel widget so it can be fetched later as needed."); abio_puts(codeFile, "dtb_save_toplevel_widget(toplevel);\n"); /* Save the command used to invoke the application */ abio_puts(codeFile,"\n"); abmfP_write_c_comment(genCodeInfo, FALSE, "Save the command used to invoke the application."); abio_puts(codeFile, "dtb_save_command(argv[0]);\n"); /* * Get application resources */ abio_puts(codeFile,"\n"); abio_puts(codeFile, "XtGetApplicationResources(toplevel, (XtPointer)&dtb_app_resource_rec,\n"); abio_indent(codeFile); abio_puts(codeFile, "resources, XtNumber(resources),\n"); abio_puts(codeFile, "get_resources_args, num_get_resources_args);\n"); abio_outdent(codeFile); abio_puts(codeFile, nlstr); /* * User segment after initialization */ abmfP_write_user_long_seg(genCodeInfo, " A connection to the X server has been established, and all\n" " *** initialization has been done.\n" " ***\n" " *** Add extra initialization code after this comment." ); /* * Call session restore callback (if needed) */ write_main_session_restore(genCodeInfo, project); /* * Initialize all global variables */ abio_puts(codeFile, nlstr); abmfP_write_c_comment(genCodeInfo, FALSE, "Initialize all global variables."); for (trav_open(&trav, project, AB_TRAV_SALIENT_UI); (window= trav_next(&trav)) != NULL; ) { if (!obj_is_defined(window)) { continue; } if (obj_is_message(window)) { abio_printf(codeFile, "%s(&%s);\n", abmfP_get_msg_clear_proc_name(window), abmfP_get_c_struct_global_name(window)); } else if (obj_is_window(window)) { abio_printf(codeFile, "%s(&%s);\n", abmfP_get_clear_proc_name(window), abmfP_get_c_struct_global_name(window)); } } trav_close(&trav); abio_puts(codeFile, "\n"); if (main_window != NULL) { abmfP_write_c_comment(genCodeInfo, FALSE, "Set up the application's root window."); abio_printf(codeFile, "%s = toplevel;\n", abmfP_get_c_name_global(main_window)); if (obj_get_icon(main_window) != NULL) { abio_printf(codeFile, "%s(%s,\n", abmfP_lib_cvt_image_file_to_pixmap->name, abmfP_get_c_name_global(main_window)); abio_indent(codeFile); abio_put_string(codeFile, obj_get_icon(main_window)); abio_printf(codeFile, ", &%s);\n", istr_string(abmfP_icon_pixmap_var(genCodeInfo))); abio_outdent(codeFile); abmfP_icon_pixmap_var_has_value(genCodeInfo) = TRUE; } if (obj_get_icon_mask(main_window) != NULL) { abio_printf(codeFile, "%s(%s,\n", abmfP_lib_cvt_image_file_to_pixmap->name, abmfP_get_c_name_global(main_window)); abio_indent(codeFile); abio_put_string(codeFile, obj_get_icon_mask(main_window)); abio_printf(codeFile, ", &%s);\n", istr_string(abmfP_icon_mask_pixmap_var(genCodeInfo))); abio_outdent(codeFile); abmfP_icon_mask_pixmap_var_has_value(genCodeInfo) = TRUE; } if (abmfP_get_num_args_of_classes(main_window, ABMF_ARGCLASS_ALL) > 0) { abmfP_xt_va_list_open_setvalues(genCodeInfo, main_window); abmfP_obj_spew_args(genCodeInfo, main_window, ABMF_ARGCLASS_ALL, ABMF_ARGFMT_VA_LIST); if (!obj_get_resizable(main_window)) { abio_printf(codeFile, "XmNmwmDecorations, MWM_DECOR_ALL | MWM_DECOR_RESIZEH,\n"); abio_printf(codeFile, "XmNmwmFunctions, MWM_FUNC_ALL | MWM_FUNC_RESIZE,\n"); } abmfP_xt_va_list_close(genCodeInfo); } } abio_puts(codeFile, nlstr); if ((main_window != NULL) && (obj_is_initially_visible(main_window))) { /* ApplicationShell doesn't require "show" action for mapping */ write_map_window(genCodeInfo, main_window, False); } /* * Display any initially mapped windows */ abio_puts(codeFile, nlstr); abmfP_write_c_comment(genCodeInfo, FALSE, "Map any initially-visible windows"); for (trav_open(&trav, project, AB_TRAV_WINDOWS); (window = trav_next(&trav)) != NULL;) { if ( (window != main_window) && (obj_is_initially_visible(window)) && obj_is_defined(window) ) { write_map_window(genCodeInfo, window, True); } } trav_close(&trav); /* * Get WM_SAVE_YOURSELF atom */ abio_puts(codeFile, "\n"); abio_puts(codeFile, "save_yourself_atom = XmInternAtom(XtDisplay(toplevel),\n"); abio_puts(codeFile, "\t\"WM_SAVE_YOURSELF\", False);\n"); /* * Register callback for WM_SAVE_YOURSELF */ write_main_register_save_yourself(genCodeInfo, project, "save_yourself_atom"); /* * User seg before realize */ abmfP_write_user_long_seg(genCodeInfo, " All initially-mapped widgets have been created, but not\n" " *** realized. Set resources on widgets, or perform other operations\n" " *** that must be completed before the toplevel widget is\n" " *** realized." ); /* * Realize the widget hierarchy */ abio_puts(codeFile, "XtRealizeWidget(toplevel);\n\n"); /* * Write ToolTalk Initialization if needed */ write_main_tooltalk_init(genCodeInfo, project); /* * User seg before event loop */ abmfP_write_user_long_seg(genCodeInfo, " The initially-mapped widgets have all been realized, and\n" " *** the Xt main loop is about to be entered." ); abio_puts(codeFile, nlstr); abmfP_write_c_comment(genCodeInfo, FALSE, "Enter event loop"); abio_puts(codeFile, "XtAppMainLoop(app);\n"); /* * Write func footer. */ abio_printf(codeFile, "return 0;\n"); abio_set_indent(codeFile, 0); abio_puts(codeFile, "}\n\n"); abmfP_gencode_exit_func(genCodeInfo); return returnValue; }
/* * Write the callback proc stub file. */ int abmfP_write_stubs_c_file( GenCodeInfo genCodeInfo, STRING codeFileName, ABObj module ) { File codeFile = genCodeInfo->code_file; STRING errmsg = NULL; ABObj win_obj = NULL; ABObj project = obj_get_project(module); char moduleHeaderFileName[MAX_PATH_SIZE]; char moduleName[MAX_PATH_SIZE]; /* * Write file header. */ abmfP_write_user_header_seg(genCodeInfo); abio_puts(codeFile, nlstr); sprintf(moduleName, "module %s", obj_get_name(module)); abmfP_write_file_header( genCodeInfo, codeFileName, FALSE, moduleName, util_get_program_name(), ABMF_MODIFY_USER_SEGS, " * Contains: Module callbacks and connection functions" ); /* * Write includes. */ strcpy(moduleHeaderFileName, abmfP_get_ui_header_file_name(module)); abmfP_write_c_system_include(genCodeInfo, "stdio.h"); abmfP_write_c_system_include(genCodeInfo, "Xm/Xm.h"); abmfP_write_c_local_include(genCodeInfo, abmfP_get_utils_header_file_name(module)); /* * Include project file if i18n is enabled. This file * is needed for the message catalog stuff */ if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API) abmfP_write_c_local_include(genCodeInfo, abmfP_get_project_header_file_name(project)); abmfP_write_c_local_include(genCodeInfo, moduleHeaderFileName); /* * Write out includes for modules with connection targets */ { StringListRec connIncludes; int i = 0; int num_strings = 0; strlist_construct(&connIncludes); strlist_add_str(&connIncludes, moduleHeaderFileName, NULL); abmfP_get_connect_includes(&connIncludes, module); num_strings = strlist_get_num_strs(&connIncludes); if (num_strings > 1) /* start at 1 - skip this_ui.h */ { abio_puts(codeFile, nlstr); abmfP_write_c_comment(genCodeInfo, FALSE, "Header files for cross-module connections"); } for (i = 1; i < num_strings; ++i) { abio_printf(codeFile, "#include %s\n", strlist_get_str(&connIncludes, i, NULL)); } strlist_destruct(&connIncludes); } abio_puts(codeFile, nlstr); abmfP_write_user_file_top_seg(genCodeInfo); abio_puts(codeFile, nlstr); if (write_action_functions(genCodeInfo, module) != OK) return ERROR; abmfP_write_user_file_bottom_seg(genCodeInfo); return OK; }
static int write_tooltalk_cb_body2( GenCodeInfo genCodeInfo, ABObj action ) { File codeFile; if (!genCodeInfo || !action) return 0; codeFile = genCodeInfo->code_file; abio_puts(codeFile, "\n"); switch(obj_get_when(action)) { case AB_WHEN_TOOLTALK_QUIT: abio_puts(codeFile, "if (cancel == True)\n"); abio_indent(codeFile); abio_puts(codeFile, "tttk_message_fail(msg, TT_DESKTOP_ECANCELED, 0, 1);\n"); abio_outdent(codeFile); abio_puts(codeFile, "else\n"); abio_puts(codeFile, "{\n"); abio_indent(codeFile); write_tooltalk_msg_reply(codeFile); abio_puts(codeFile, "\n"); abmfP_write_c_comment(genCodeInfo, FALSE, "Now that the Message has been replied, process Quit operation"); abmfP_write_user_code_seg(genCodeInfo, NULL); abio_puts(codeFile, nlstr); abio_outdent(codeFile); abio_puts(codeFile, "}\n"); break; case AB_WHEN_TOOLTALK_GET_STATUS: abio_puts(codeFile, "tt_message_arg_val_set(msg, 0, status_string);\n"); write_tooltalk_msg_reply(codeFile); break; case AB_WHEN_TOOLTALK_PAUSE_RESUME: abio_puts(codeFile, "if (already_set == True)\n"); abio_indent(codeFile); abio_puts(codeFile, "tt_message_status_set(msg, TT_DESKTOP_EALREADY);\n"); abio_outdent(codeFile); write_tooltalk_msg_reply(codeFile); break; case AB_WHEN_TOOLTALK_DO_COMMAND: abio_puts(codeFile, "tt_free(command);\n"); abio_puts(codeFile, "tt_message_status_set(msg, status);\n"); abio_puts(codeFile, "if (tt_is_err(status))\n"); abio_indent(codeFile); abio_puts(codeFile, "tttk_message_fail(msg, status, 0, 1);\n"); abio_outdent(codeFile); abio_puts(codeFile, "else\n"); abio_puts(codeFile, "{\n"); abio_indent(codeFile); abio_puts(codeFile, "if (result != NULL)\n"); abio_indent(codeFile); abio_puts(codeFile, "tt_message_arg_val_set(msg, 1, result);\n"); abio_outdent(codeFile); write_tooltalk_msg_reply(codeFile); abio_outdent(codeFile); abio_puts(codeFile, "}\n"); break; default: break; } abio_puts(codeFile, nlstr); abmfP_write_user_code_seg(genCodeInfo, NULL); abio_puts(codeFile, nlstr); abio_puts(codeFile, "return True;\n"); return 0; }
int abmfP_write_builtin_action( GenCodeInfo genCodeInfo, ABObj action, BOOL setUpVars ) { int return_value = 0; File codeFile = genCodeInfo->code_file; ABObj toObj = NULL; STRING actionTKResource = NULL; /* in toolkit */ STRING actionResource = NULL; /* in source code */ ISTRING istr_resource = NULL; AB_BUILTIN_ACTION builtin_action = AB_STDACT_UNDEF; toObj = obj_get_to(action); builtin_action = obj_get_func_builtin(action); if (toObj != NULL) { toObj = objxm_comp_get_target_for_builtin_action(toObj, builtin_action); } if (toObj == NULL) { abmfP_write_c_comment(genCodeInfo, FALSE, "Invalid action ignored."); abio_puts(codeFile, nlstr); return 0; } /* * We need to convert the resource into a string that can be put * in the .c file. */ actionTKResource = objxm_get_resource_for_builtin_action( toObj, builtin_action); istr_resource = objxm_get_res_strname(actionTKResource); actionResource = istr_string(istr_resource); if (abmfP_get_c_name(genCodeInfo, toObj) == NULL) { return_value = write_builtin_action_for_ref(genCodeInfo, action, toObj, setUpVars, builtin_action, actionTKResource, actionResource); } else { if (setUpVars) { set_up_user_type_variables(genCodeInfo, toObj); } return_value = write_builtin_action(genCodeInfo, action, toObj, builtin_action, actionTKResource, actionResource); } if (return_value == 0) abio_printf(codeFile, nlstr); epiloge: abio_printf(codeFile, nlstr); return return_value; }