Example #1
0
static int
write_instance_ptr_var(
    GenCodeInfo	genCodeInfo,
    ABObj		ipObj,
    STRING		instanceVarName,
    STRING		paramName,
    BOOL		castValue,
    STRING		comment
)
{
    FILE	*codeFile = genCodeInfo->code_file;

    if (ipObj == NULL)
    {
        return 0;
    }
    abio_printf(genCodeInfo->code_file, "%s\t%s = ",
                abmfP_get_c_struct_ptr_type_name(ipObj),
                instanceVarName);
    if (castValue)
    {
        abio_printf(codeFile, "(%s)", abmfP_get_c_struct_ptr_type_name(ipObj));
    }

    abio_printf(codeFile, "%s;", paramName);

    if (comment != NULL)
    {
        abio_printf(genCodeInfo->code_file, "\t%s", comment);
    }
    abio_puts(genCodeInfo->code_file, nlstr);
    return 0;
}
Example #2
0
/*
 * Generate XtVaSetvalues calls in callbacks.
 * obj is the object that will have it's resources set.
 *
 * Resource list must be name,value pairs, NULL-terminated
 * All resource values must be of type (void *)
 */
static int
printf_setval(GenCodeInfo genCodeInfo, ABObj obj, ...)
{
    int			return_value = 0;
    File		codeFile = genCodeInfo->code_file;
#if defined(__osf__) || defined(linux) || defined(CSRG_BASED)
    /* OSF/1 define va_list in <va_list.h> as structure of char ** and int
     * Sun define va_list as void * */
    va_list             paramList = { 0, 0 };
#else
    va_list             paramList = NULL;
#endif /* __osf__ */
    STRING              resName = NULL;
    void		*resValue = NULL;
    STRING		objCName = NULL;
    ISTRING		istrValue = NULL;

    va_start(paramList, obj);

    objCName = abmfP_get_c_name(genCodeInfo, obj);
    abio_printf(codeFile, "\tXtVaSetValues(%s,", objCName);
    abio_printf(codeFile, "\n\t\t");

    while ((resName = va_arg(paramList, STRING)) != NULL)
    {
        resValue = va_arg(paramList, VoidPtr);
        switch (abmfP_get_res_type(resName, obj))
        {
        case AB_ARG_LITERAL:
        case AB_ARG_PIXEL:
        case AB_ARG_PIXMAP:
        case AB_ARG_XMSTRING:
            istrValue = istr_create((STRING)resValue);
            resValue = (VoidPtr)istrValue;
            break;

        case AB_ARG_WIDGET:
            util_dprintf(1,
                         "Ignoring unsupported connection resource type: WIDGET\n");
            break;
        }
        abmfP_write_arg_val(genCodeInfo, FALSE, resName, resValue, obj);
        abio_printf(codeFile, ",\n\t\t");

        istr_destroy(istrValue);
        resValue = NULL;
    }
    abio_printf(codeFile, "NULL);");

    va_end(paramList);
    return return_value;
}
Example #3
0
/*
 * writes #include <blah.h>
 */
int
abmfP_write_c_system_include(GenCodeInfo genCodeInfo, STRING fileName)
{
    File	codeFile = genCodeInfo->code_file;
    abio_printf(codeFile, "#include <%s>\n", fileName);
    return 0;
}
Example #4
0
static int
write_main_session_restore(
    GenCodeInfo	genCodeInfo, 
    ABObj	project
)
{
    File	codeFile;

    if (!genCodeInfo || !project)
	return (0);

    codeFile = genCodeInfo->code_file;

    if (abmfP_proj_needs_session_restore(project))
    {
        AB_TRAVERSAL	trav;
	ABObj		action;
	char		*ss_restore_CB_name = NULL;

        abio_puts(codeFile,"\n");
        abio_puts(codeFile,"if (dtb_app_resource_rec.session_file)\n");
        abio_puts(codeFile,"{\n");

	if (!obj_is_project(project))
	    project = obj_get_project(project);

	/*
	 * Search for session restore callback in project
	 * action list
	 */
    	for (trav_open(&trav, project, AB_TRAV_ACTIONS);
             (action = trav_next(&trav)) != NULL;)
    	{
	    switch(obj_get_when(action))
	    {
		case AB_WHEN_SESSION_RESTORE:
		    /*
		     * Remember session restore callback if found
		     */
		    ss_restore_CB_name = obj_get_func_name(action);
		    break;
		default:
		    break;
	    }
	}
	trav_close(&trav);

	abio_printf(codeFile, 
	"    dtb_set_client_session_restoreCB((DtbClientSessionRestoreCB)%s);\n",
		ss_restore_CB_name ? ss_restore_CB_name : "NULL");

        abio_puts(codeFile,
	"    (void)dtb_session_restore(toplevel, dtb_app_resource_rec.session_file);\n");
        abio_puts(codeFile,"}\n");

        abio_puts(codeFile,"\n");
    }

    return (0);
}
Example #5
0
static void
set_up_user_type_variables(GenCodeInfo genCodeInfo, ABObj toObj)
{
    File                codeFile = genCodeInfo->code_file;
    ABObj               structObj = abmfP_obj_get_struct_obj(toObj);
    ABObj		winParent = NULL;
    char		winParentName[1024];
    *winParentName = 0;

    /*
     * Determine window parent of this popup
     */
    winParent = obj_get_win_parent(structObj);
    if (winParent == NULL)
    {
        sprintf(winParentName, "%s()", abmfP_lib_get_toplevel_widget->name);
    }
    else
    {
        strcpy(winParentName, abmfP_get_c_name(genCodeInfo, winParent));
    }

    /*
     * REMIND: This is obsolete and should be removed!
     */
    if (cwd_is_dtbuilder_src_dir())
    {
        write_instance_ptr_var(genCodeInfo, toObj,
                               instanceVarName, abmfP_client_data_var_name, TRUE, NULL);
        abio_puts(genCodeInfo->code_file, nlstr);
    }
    else
    {
        write_instance_ptr_var(genCodeInfo, toObj,
                               toVarName, abmfP_client_data_var_name, TRUE, NULL);
        write_instance_ptr_var(genCodeInfo, toObj,
                               instanceVarName, toVarName, FALSE, "/* obsolete */");
        abio_puts(genCodeInfo->code_file, nlstr);
    }
    abio_printf(codeFile, "if (!(%s->initialized))\n", get_to_var_name());
    abmfP_write_c_block_begin(genCodeInfo);
    abio_printf(codeFile, "%s(%s, %s);\n",
                abmfP_get_init_proc_name(structObj),
                get_to_var_name(),
                winParentName);
    abmfP_write_c_block_end(genCodeInfo);
}
Example #6
0
static int
write_centering_static_func_decls(GenCodeInfo genCodeInfo, ABObj project)
{
    File	codeFile;

    if (!genCodeInfo || !project)
	return (0);
    
    codeFile = genCodeInfo->code_file;

    abio_puts(codeFile, "/*\n");
    abio_puts(codeFile, " * Private functions used for dynamic centering of objects\n");
    abio_puts(codeFile, " */\n");
    abio_printf(codeFile, "%s\n", abmfP_lib_center_widget->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_uncenter_widget->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_centering_handler->proto);

    return (0);
}
Example #7
0
static int
write_msg_static_func_decls(
    GenCodeInfo genCodeInfo,
    ABObj project
)
{
    File        codeFile;

    if (!genCodeInfo || !project)
        return (0);

    codeFile = genCodeInfo->code_file;
 
    abio_puts(codeFile, "/*\n");
    abio_puts(codeFile, " * Static functions used for messages.\n");
    abio_puts(codeFile, " */\n");
    abio_printf(codeFile, "%s\n", abmfP_lib_destroyCB->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_modal_dlgCB->proto);
 
    return (0);
}
Example #8
0
int
abmfP_write_file_footer(
			GenCodeInfo	genCodeInfo,
			STRING		fileName,
			BOOL		closeIfdef
)
{
    if (closeIfdef)
    {
	abio_printf(genCodeInfo->code_file, "#endif /* %s */\n",
		abmfP_get_define_from_file_name(fileName));
    }
    return 0;
}
Example #9
0
static int
write_i18n_declarations(
    GenCodeInfo	genCodeInfo,
    ABObj	project
    )
{
    File	codeFile;
    STRING      *p = NULL;
    int		ret_val = 0;

    if (genCodeInfo == NULL)
        goto cret;

    codeFile = genCodeInfo->code_file;

    /*
     * Write out the include directives
     */
    for (p = I18n_Includes; *p; p++)
    {
	abio_printf(codeFile, "#include %s\n", *p);
    }

    /*
     * Write out the macro for the name of the catalog
     */
    abio_printf(codeFile, "#define DTB_PROJECT_CATALOG\t\"%s\"\n",
                obj_get_name(project));

    abio_puts(codeFile,
              "/* Handle for standard message catalog for the project */\n");
    
    abio_puts(codeFile, "extern nl_catd\tDtb_project_catd;\n");
    
cret:
    return(ret_val);
}
Example #10
0
static int
write_func_var_decl(FILE *file, FileFuncInfo funcInfo)
{
    char	ptrVarName[256];
    STRING	funcNamePtr = NULL;

    funcNamePtr = funcInfo->funcName;
    if (strncmp(funcNamePtr, "dtb_", 4) == 0)
    {
	funcNamePtr += 4;
    }
    sprintf(ptrVarName, "abmfP_lib_%s", funcNamePtr);
    abio_printf(file, "extern LibFunc %s;\n", ptrVarName);
    return 0;
}
Example #11
0
/*
 * If return_value is null, no return is written
 */
int
abmfP_write_c_func_end(
		GenCodeInfo	genCodeInfo,
		STRING		return_value
)
{
    File	file= genCodeInfo->code_file;
    if (return_value != NULL)
    {
	abio_printf(file, "return %s;\n", return_value);
    }
    abio_set_indent(file, 0); /* { vi hack */
    abio_puts(file, "}\n\n");
    return 0;
}
Example #12
0
static int	
write_func_as_strings(FILE *file, FileFuncInfo funcInfo)
{
    char	recVarName[256];
    char	ptrVarName[256];
    char	*funcNamePtr = NULL;

    funcNamePtr = funcInfo->funcName;
    if (strncmp(funcNamePtr, "dtb_", 4) == 0)
    {
	funcNamePtr += 4;
    }
    sprintf(recVarName, "%%abmfP_lrc_%s", funcNamePtr);
    sprintf(ptrVarName, "%%abmfP_lib_%s", funcNamePtr);

    abio_puts(file, "\n");
    abio_puts(file,   "/*\n");
    abio_printf(file, " * %s\n", ptrVarName);
    abio_puts(file,   " */\n");

    abio_printf(file, "static LibFuncRec %s = \n", recVarName);
    abio_printf(file, "{\n");
    abio_indent(file);

    abio_puts(file, "/* name */\n");
    write_c_string(file, funcInfo->funcName);
    abio_puts(file, ",\n");
    abio_puts(file, "\n");

    abio_printf(file, "/* proto */\n");
    write_c_string(file, funcInfo->funcProto);
    abio_puts(file, ",\n");
    abio_puts(file, "\n");

    abio_printf(file, "/* def */\n");
    write_c_string(file, funcInfo->funcCode);

    abio_puts(file, "\n");
    abio_outdent(file);
    abio_printf(file, "}; /* %s */\n", recVarName);

    abio_printf(file, "LibFunc %s = &(%s);\n", 
	ptrVarName, recVarName);
    return 0;
}
Example #13
0
static int
write_map_window(
			GenCodeInfo	genCodeInfo, 
			ABObj 		window,
			BOOL		show
)
{
    File	codeFile = genCodeInfo->code_file;
    ABObj	project = obj_get_project(window);
    ABObj	proj_root_window = abmfP_get_root_window(project);
    ABObjRec	showActionRec;
    ABObj	showAction = &showActionRec;
    ABObj	winParent = NULL;
    char	winParentName[1024];
    obj_construct(showAction, AB_TYPE_ACTION, NULL);
    *winParentName = 0;

    obj_set_from(showAction, NULL);
    obj_set_to(showAction, window);
    obj_set_func_type(showAction, AB_FUNC_BUILTIN);
    obj_set_func_builtin(showAction, AB_STDACT_SHOW);

    winParent = obj_get_win_parent(window);
    if (winParent == NULL)
    {
	sprintf(winParentName, "%s()", abmfP_lib_get_toplevel_widget->name);
    }
    else
    {
        strcpy(winParentName, abmfP_get_c_name(genCodeInfo, winParent));
    }
    abio_printf(codeFile, "%s(%s, %s);\n",
	abmfP_get_init_proc_name(window),
	abmfP_get_c_struct_ptr_name(genCodeInfo, window),
	winParentName);

    if (show)
    	abmfP_write_builtin_action(genCodeInfo, showAction, FALSE);

    obj_destruct(showAction);
    return 0;
}
Example #14
0
/*
 * printf_getval - can only get one resource.  This can be changed at a later
 * date if need be. NOTE: We need to declare local variables in one pass,
 * Then write out an XtVaGetValues on a second pass, if we ever want to get
 * more that one value back.
 */
static int
printf_getval(GenCodeInfo genCodeInfo, ABObj obj, int nres,...)
{
    int			return_value = 0;
    File		codeFile = genCodeInfo->code_file;
    va_list             ap;
    STRING              resource;
    ARG_TYPES           type;
    STRING		objCName = NULL;
    nres = nres;		/* avoid warning */

    va_start(ap, nres);

    objCName = abmfP_get_c_name(genCodeInfo, obj);
    resource = va_arg(ap, STRING);
    type = va_arg(ap, ARG_TYPES);

    /* Print the declaration */
    switch (type)
    {
    case IMMED_TYPE:
    case INT_TYPE:
        abio_printf(codeFile, "\tint i;\n\n");
        break;
    case STRING_TYPE:
        abio_printf(codeFile, "\tchar *str;\n\n");
        break;
    }

    abio_printf(codeFile, "\tXtVaGetValues(%s,\n\t\t%s, ", objCName, resource);

    /* Print the local variable reference */
    switch (type)
    {
    case IMMED_TYPE:
    case INT_TYPE:
        abio_printf(codeFile, "&i");
        break;
    case STRING_TYPE:
        abio_printf(codeFile, "&str");
        break;
    }
    abio_printf(codeFile, ",\n\t\tNULL);\n");

    va_end(ap);
    return return_value;
}
Example #15
0
int 
abmfP_write_c_comment(
		GenCodeInfo	genCodeInfo,
		BOOL		oneLiner,
		STRING		comment
)
{
    File	file= genCodeInfo->code_file;
    
    if (oneLiner)
    {
	abio_printf(file, "/* %s */\n", comment);
    }
    else
    {
        abio_puts(file, abmfP_comment_begin);
        abio_puts(file, abmfP_comment_continue);
        abio_puts(file, comment);
        abio_puts(file, "\n");
        abio_puts(file, abmfP_comment_end);
    }
    return 0;
}
Example #16
0
static int
write_option_desc_list(GenCodeInfo genCodeInfo, ABObj project)
{
    File	codeFile;

    if (!genCodeInfo || !project)
	return (0);
    
    codeFile = genCodeInfo->code_file;

    abio_puts(codeFile, "\n");
    abio_puts(codeFile, "/*\n");
    abio_puts(codeFile, " * command line options...\n");
    abio_puts(codeFile, " */\n");
    abio_puts(codeFile, "static XrmOptionDescRec optionDescList[] = {\n");
    abio_indent(codeFile);
    abio_puts(codeFile,     "{\"-session\", \"*session\", XrmoptionSepArg, (XPointer)NULL}\n");
    abio_puts(codeFile, "\n");
    abmfP_write_user_struct_fields_seg(genCodeInfo);
    abio_outdent(codeFile);
    abio_printf(codeFile, "};\n");

    return (0);
}
Example #17
0
static int
write_main_tooltalk_init(
    GenCodeInfo genCodeInfo, 
    ABObj project 
) 
{ 
    AB_TOOLTALK_LEVEL	tt_level;
    AB_TRAVERSAL	trav;
    STRING		vendor, version;
    ABObj		action;
    File        	codeFile; 
    int         	ret_val = 0; 
 
    if (!genCodeInfo || !project ||
        (tt_level = obj_get_tooltalk_level(project)) == AB_TOOLTALK_NONE)
        return 0;
 
    codeFile = genCodeInfo->code_file; 

    abio_puts(codeFile, abmfP_comment_begin);
    abio_puts(codeFile, abmfP_comment_continue);
    abio_puts(codeFile, "Initialize ToolTalk to handle Desktop Message Protocol\n");
    abio_puts(codeFile, abmfP_comment_end);

    if (tt_level == AB_TOOLTALK_DESKTOP_ADVANCED)
    {
    	for (trav_open(&trav, project, AB_TRAV_ACTIONS);
             (action = trav_next(&trav)) != NULL;)
    	{
	    switch(obj_get_when(action))
	    {
		case AB_WHEN_TOOLTALK_QUIT:
		    abio_printf(codeFile, "dtb_set_tt_msg_quitCB((DtbTTMsgHandlerCB)%s);\n",
			obj_get_func_name(action));
		    break;
		case AB_WHEN_TOOLTALK_DO_COMMAND:
                    abio_printf(codeFile, "dtb_set_tt_msg_do_commandCB((DtbTTMsgHandlerCB)%s);\n", 
                        obj_get_func_name(action)); 
                    break; 
                case AB_WHEN_TOOLTALK_GET_STATUS: 
                    abio_printf(codeFile, "dtb_set_tt_msg_get_statusCB((DtbTTMsgHandlerCB)%s);\n",  
                        obj_get_func_name(action));  
                    break; 
                case AB_WHEN_TOOLTALK_PAUSE_RESUME:
                    abio_printf(codeFile, "dtb_set_tt_msg_pause_resumeCB((DtbTTMsgHandlerCB)%s);\n",  
                        obj_get_func_name(action));
                    break;
		default:
		    break;
	    }
	}
	trav_close(&trav);
	abio_puts(codeFile, "\n");
    }

    /* Write out tt init code to deal with possible remote display session */
    abio_puts(codeFile, "ttenv = getenv(\"TT_SESSION\");\n");
    abio_puts(codeFile, "if (!ttenv || strlen(ttenv) == 0)\n");
    abio_indent(codeFile);
    abio_puts(codeFile,"ttenv = getenv(\"_SUN_TT_SESSION\");\n");
    abio_outdent(codeFile);
    abio_puts(codeFile, "if (!ttenv || strlen(ttenv) == 0)\n");
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, "session = tt_X_session(XDisplayString(display));\n");
    abio_puts(codeFile, "tt_default_session_set(session);\n");
    abio_puts(codeFile, "tt_free(session);\n");
    abmfP_write_c_block_end(genCodeInfo);
    
    abio_printf(codeFile, "tt_proc_id = ttdt_open(&tt_fd, \"%s\", ",
	obj_get_name(project));
    vendor = obj_get_vendor(project);
    version = obj_get_version(project);
    abio_printf(codeFile, "\"%s\", \"%s\", 1);\n",
	vendor? vendor : "NULL", version? version : "NULL");
    abio_puts(codeFile, "tt_status = tt_ptr_error(tt_proc_id);\n");
    abio_puts(codeFile, "if (tt_status != TT_OK)\n");
/*
    abio_puts(codeFile, "{\n");
    abio_indent(codeFile);
*/
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, 
	"fprintf(stderr,\"ttdt_open(): %s\\n\", tt_status_message(tt_status));\n");
    abio_puts(codeFile, "tt_proc_id = NULL;\n");
/*
    abio_outdent(codeFile);
    abio_puts(codeFile, "}\n");
*/
    abmfP_write_c_block_end(genCodeInfo); 
    abio_puts(codeFile, "else\n");
/*
    abio_puts(codeFile, "{\n");
    abio_indent(codeFile);
*/
    abmfP_write_c_block_begin(genCodeInfo);
    abio_puts(codeFile, "XtAppAddInput(app, tt_fd, (XtPointer)XtInputReadMask,\n");
    abio_indent(codeFile);
    abio_puts(codeFile, "tttk_Xt_input_handler, tt_proc_id);\n\n");
    abio_outdent(codeFile); 
    abio_printf(codeFile, "tt_session_pattern = ttdt_session_join(NULL, %s,\n",
	tt_level == AB_TOOLTALK_DESKTOP_ADVANCED? "dtb_tt_contractCB" : "NULL");
    abio_indent(codeFile);
    abio_puts(codeFile, "toplevel, NULL, True);\n\n");
    abio_outdent(codeFile);
    abio_puts(codeFile, "atexit(dtb_tt_close);\n");
/*
    abio_outdent(codeFile); 
    abio_puts(codeFile, "}\n");
*/
    abmfP_write_c_block_end(genCodeInfo);  

    return 0;

}
Example #18
0
/*
 * Assumes: function name and opening "(" have been written
 */
static int
write_func_def_params(
	File	file,
	BOOL	use_prototypes,
	va_list	va_params
)
{
#if defined(__ppc) || defined(linux)
#define va_start_params() __va_copy(params, va_params)
#elif defined(CSRG_BASED)
#define va_start_params() va_copy(params, va_params)
#else
#define va_start_params() (params = va_params)
#endif
#define va_end_params() (0)
    va_list	params;
    int		num_params_written= 0;
    int		num_params= 0;
    BOOL	list_params= FALSE;
    int		i= 0;
    STRING	curParamType = NULL;
    STRING	curParamName = NULL;
    BOOL	paramsDone = FALSE;

    va_start_params();

    /*
     * Count non-NULL string pairs
     */
    num_params = 0;
    va_start_params();
    while (   (va_arg(params, STRING) != NULL) 
	   && (va_arg(params, STRING) != NULL))
    {
	++num_params;
    }

    list_params= (num_params > 1);	/* use "list" format */
    if (num_params > 0)
    {
	if (list_params)
	{
	    abio_puts(file, "\n");
	    abio_indent(file);
	}

	paramsDone = FALSE;
	va_start_params();
	while (!paramsDone)
	{
	    curParamType = va_arg(params, STRING);
	    if (curParamType != NULL)
	    {
		curParamName = va_arg(params, STRING);
	    }
	    if ((curParamType == NULL) || (curParamName == NULL))
	    {
		paramsDone = TRUE;
		continue;
	    }

	    if (use_prototypes)
	    {
	        abio_puts(file, curParamType);
	        abio_puts(file, " ");
	    }
	    abio_puts(file, curParamName);
	    ++num_params_written;
	    if (num_params_written < num_params)
	    {
		abio_puts(file, ",");
	    }
	    if (list_params)
	    {
	        abio_puts(file, "\n");
	    }
	}
	if (list_params)
	{
	    abio_outdent(file);
	}
    }
    abio_puts(file, ")\n");

    /*
     * Write out old-style parameter types
     */
    num_params_written= 0;
    if (!use_prototypes)
    {
	paramsDone = FALSE;
	va_start_params();
	while (!paramsDone)
	{
	    curParamType = va_arg(params, STRING);
	    if (curParamType != NULL)
	    {
		curParamName = va_arg(params, STRING);
	    }
	    if ((curParamType == NULL) || (curParamName == NULL))
	    {
		paramsDone = TRUE;
		continue;
	    }

	    abio_printf(file, "\t%s %s", curParamType, curParamName);
	    ++num_params_written;
	    if (num_params_written < num_params)
	    {
		abio_puts(file, ",");
	    }
	    abio_puts(file, "\n");
	}
    }

    va_end_params();
    return 0;
#undef va_start_params
#undef va_end_params
}
Example #19
0
void exitBook() {
	abio_printf("Спасибо за использование AddressBook.\nПока-пока. ;)\n");
	exit(0);
}
Example #20
0
void printGreetings() {
	abio_printf("Добро пожаловать в интерактивную электронную записную книгу AddressBook.\n");
}
Example #21
0
int
abmfP_write_file_header(
		GenCodeInfo		genCodeInfo,
		STRING			fileName,
		BOOL			openIfdef,
		STRING			gennedFrom,
		STRING			gennedBy,
		ABMF_MODIFY_TYPE	modifyType,
		STRING			description
)
{
    File	codeFile = genCodeInfo->code_file;
    STRING	comment = NULL;

    abio_printf(codeFile, 
        "/*\n"
	" * File: %s\n",
	    fileName);
    
    if (description != NULL)
    {
	abio_printf(codeFile, "%s\n", description);
    }

    abio_puts(codeFile, " *\n");
    abio_printf(codeFile, " * This file was generated by %s, from %s\n",
	gennedBy, gennedFrom);
    abio_puts(codeFile, " *\n");

    comment = NULL;
    switch (modifyType)
    {
	case ABMF_MODIFY_NOT:
	    comment = 
	" *    ** DO NOT MODIFY BY HAND - ALL MODIFICATIONS WILL BE LOST **\n";
	break;

	case ABMF_MODIFY_USER_SEGS:
	    comment =
" * Any text may be added between the DTB_USER_CODE_START and\n"
" * DTB_USER_CODE_END comments (even non-C code). Descriptive comments\n"
" * are provided only as an aid.\n"
" *\n"
" *  ** EDIT ONLY WITHIN SECTIONS MARKED WITH DTB_USER_CODE COMMENTS.  **\n"
" *  ** ALL OTHER MODIFICATIONS WILL BE OVERWRITTEN. DO NOT MODIFY OR  **\n"
" *  ** DELETE THE GENERATED COMMENTS!                                 **\n";
	break;
    }

    if (comment != NULL)
    {
	abio_puts(codeFile, comment);
    }
    abio_puts(codeFile, " */\n");

    if (openIfdef)
    {
	STRING	defineToken = abmfP_get_define_from_file_name(fileName);
	abio_printf(codeFile, "#ifndef %s\n", defineToken);
	abio_printf(codeFile, "#define %s\n", defineToken);
    }

    abio_puts(codeFile, "\n");

    return 0;
}
Example #22
0
static int
write_align_static_func_decls(GenCodeInfo genCodeInfo, ABObj project)
{
    File	codeFile;

    if (!genCodeInfo || !project)
	return (0);
    
    codeFile = genCodeInfo->code_file;

    abio_puts(codeFile, "/*\n");
    abio_puts(codeFile, " * Static functions used for dynamic aligning of group objects\n");
    abio_puts(codeFile, " */\n");
    abio_printf(codeFile, "%s\n", abmfP_lib_get_label_widget->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_get_offset_from_ancestor->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_get_label_width->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_get_widest_label->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_get_widest_value->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_get_widget_rect->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_get_greatest_size->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_get_group_cell_size->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_get_group_row_col->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_get_group_child->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_children->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_handler->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_expose_handler->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_free_group_info->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_rows->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_cols->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_left->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_right->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_labels->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_vcenter->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_top->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_bottom->proto);
    abio_printf(codeFile, "%s\n", abmfP_lib_align_hcenter->proto);

    return (0);
}
Example #23
0
int
abmfP_write_action_function(
    GenCodeInfo	genCodeInfo,
    ABObj		action
)
{
    int			rc = 0;			/* return code */
    BOOL		isTTCB = FALSE;
    BOOL		ss_cb = FALSE;
    File                codeFile = genCodeInfo->code_file;
    BOOL		topUserSegWritten = FALSE;
    BOOL		bottomUserSegWritten = FALSE;
    BOOL		funcBodyWritten = FALSE;
    BOOL		funcEndWritten = FALSE;
    BOOL		actionPrintfWritten = FALSE;
    int                 return_value = 0;
    ABObj               fromObj = obj_get_from(action);
    ABObj		actualFromObj = NULL;
    ABObj		toObj = obj_get_to(action);
    ABObj		module = NULL;
    char		actionName[1024];
    char		actionPrintf[1024];

    abmfP_gencode_enter_func(genCodeInfo);
    abmfP_ip_obj(genCodeInfo) = obj_get_to(action);
    util_strncpy(actionName, abmfP_get_action_name(action), 1024);
    sprintf(actionPrintf, "printf(\"action: %s()\\n\");\n", actionName);

    /***
     *** START OF FUNCTION
     ***/

    switch (obj_get_when(action))
    {
    case AB_WHEN_AFTER_CREATED:
        /*
         * post-create procs have the signature of an Xt Callback,
         * although they are called as conventional functions.
         */
        fromObj = obj_get_from(action);
        actualFromObj = get_actual_from_obj(action);
        abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
        write_instance_ptr_var(genCodeInfo, actualFromObj,
                               get_from_var_name(), "callData", TRUE, NULL);
        abio_puts(genCodeInfo->code_file, nlstr);

        break;

    case AB_WHEN_DRAGGED_FROM:
    {
        abio_printf(genCodeInfo->code_file,
                    abmfP_lib_default_dragCB->def,	/* this is a format string */
                    actionName,actionName,actionName,
                    actionName,actionName, actionName);
        abio_puts(genCodeInfo->code_file, "\n\n");

        /* these are all in the "library" definition */
        topUserSegWritten = TRUE;
        bottomUserSegWritten = TRUE;
        funcBodyWritten = TRUE;
        funcEndWritten = TRUE;
        actionPrintfWritten = TRUE;
    }
    break;

    case AB_WHEN_DROPPED_ON:
    {
        abio_printf(genCodeInfo->code_file,
                    abmfP_lib_default_dropCB->def,	/* this is a format string */
                    actionName,actionName,actionName,actionName);
        abio_puts(genCodeInfo->code_file, "\n\n");

        /* these are all in the "library" definition */
        topUserSegWritten = TRUE;
        bottomUserSegWritten = TRUE;
        funcBodyWritten = TRUE;
        funcEndWritten = TRUE;
        actionPrintfWritten = TRUE;
    }
    break;

    case AB_WHEN_TOOLTALK_QUIT:
    case AB_WHEN_TOOLTALK_DO_COMMAND:
    case AB_WHEN_TOOLTALK_GET_STATUS:
    case AB_WHEN_TOOLTALK_PAUSE_RESUME:
        isTTCB = TRUE;
        abio_printf(codeFile, begin_tt_callback_body, actionName);
        abmfP_write_c_block_begin(genCodeInfo);
        write_tooltalk_cb_vars(genCodeInfo, action);
        break;

    case AB_WHEN_SESSION_RESTORE:
        ss_cb = TRUE;
        abio_printf(codeFile, begin_ss_restore_callback_body,
                    abmfP_get_action_name(action));
        abmfP_write_c_block_begin(genCodeInfo);
        write_ss_cb_vars(genCodeInfo, action);
        break;

    case AB_WHEN_SESSION_SAVE:
        ss_cb = TRUE;
        abio_printf(codeFile, begin_ss_save_callback_body,
                    abmfP_get_action_name(action));
        abmfP_write_c_block_begin(genCodeInfo);
        write_ss_cb_vars(genCodeInfo, action);
        break;

    default:
        abmfP_write_xm_callback_begin(genCodeInfo, FALSE, actionName);
        break;

    } /* switch obj_get_when() */


    /*****
     ***** TOP USER SEGMENT
     *****/

    if (!topUserSegWritten)
    {
        STRING	contents =
            (actionPrintfWritten? NULL:(isTTCB? actionPrintf:NULL));
        abmfP_write_user_var_and_code_seg(genCodeInfo, contents);
        abio_puts(codeFile, nlstr);
        topUserSegWritten = TRUE;
        if (contents != NULL)
        {
            actionPrintfWritten = TRUE;
        }
    }

    /***
     *** FUNCTION BODY
     ***/

    if (isTTCB)
    {
        write_tooltalk_cb_body1(genCodeInfo, action);
        abmfP_write_user_code_seg(genCodeInfo, NULL);
        write_tooltalk_cb_body2(genCodeInfo, action);
        funcBodyWritten = TRUE;
        bottomUserSegWritten = TRUE;
    }
    else if (ss_cb)
    {
        write_ss_cb_body1(genCodeInfo, action);
        abmfP_write_user_code_seg(genCodeInfo, NULL);
        write_ss_cb_body2(genCodeInfo, action);
        funcBodyWritten = TRUE;
        bottomUserSegWritten = TRUE;
    }
    else if (!funcBodyWritten) switch (obj_get_func_type(action))
        {
        case AB_FUNC_BUILTIN:
            rc = abmfP_write_builtin_action(genCodeInfo, action, TRUE);
            return_if_err(rc,rc);
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_USER_DEF:
            abmfP_write_user_start_comment(genCodeInfo, "vvv Add C code below vvv");
            abmfP_write_user_end_comment(genCodeInfo, "^^^ Add C code above ^^^");
            bottomUserSegWritten = TRUE;
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_CODE_FRAG:
            abio_puts(codeFile, obj_get_func_code(action));
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_ON_ITEM_HELP:
            abio_printf(codeFile, "dtb_do_onitem_help();\n");
            funcBodyWritten = TRUE;
            break;

        case AB_FUNC_HELP_VOLUME:
            abio_printf(codeFile,
                        "dtb_show_help_volume_info(\"%s\", \"%s\");\n",
                        istr_string(action->info.action.volume_id),
                        istr_string(action->info.action.location));
            funcBodyWritten = TRUE;
            break;

        default:
        {
            char *obj_name_string = obj_get_name(fromObj);
            util_printf_err(catgets(Dtb_project_catd, 1, 78,
                                    "unknown function type for action from object, %s"),
                            obj_name_string);
            return_code(ERR);
        }
        break;
        }

    /*****
     ***** BOTTOM USER SEGMENT
     *****/

    if (!bottomUserSegWritten)
    {
        STRING	contents = (actionPrintfWritten? NULL:actionPrintf);
        abmfP_write_user_code_seg(genCodeInfo, contents);
        bottomUserSegWritten = TRUE;
        if (contents != NULL)
        {
            actionPrintfWritten = TRUE;
        }
    }

    /*****
     ***** FUNCTION END
     *****/

    if (!funcEndWritten)
    {
        abmfP_write_c_func_end(genCodeInfo, NULL);
        funcEndWritten = TRUE;
    }

epilogue:
    abmfP_gencode_exit_func(genCodeInfo);
    return return_value;
}
Example #24
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;
}
Example #25
0
static int 	
write_main_register_save_yourself(
			GenCodeInfo	genCodeInfo, 
			ABObj		project, 
			char		*atom_name
)
{
    File	codeFile;

    if (!genCodeInfo || !project)
	return (0);

    if (!atom_name)
	atom_name = "save_yourself_atom";

    codeFile = genCodeInfo->code_file;

    abio_puts(codeFile,"\n");

    /*
     * Set client save session callback
     */
    if (abmfP_proj_needs_session_save(project))
    {
        AB_TRAVERSAL	trav;
	ABObj		action;
	char		*ss_save_CB_name = NULL;

	/*
	 * Search for session save callback in project
	 * action list
	 */
    	for (trav_open(&trav, project, AB_TRAV_ACTIONS);
             (action = trav_next(&trav)) != NULL;)
    	{
	    switch(obj_get_when(action))
	    {
		case AB_WHEN_SESSION_SAVE:
		    /*
		     * Remember session save callback if found
		     */
		    ss_save_CB_name = obj_get_func_name(action);
		    break;
		default:
		    break;
	    }
	}
	trav_close(&trav);

	abio_printf(codeFile, 
	    "dtb_set_client_session_saveCB((DtbClientSessionSaveCB)%s);\n",
		ss_save_CB_name ? ss_save_CB_name : "NULL");

	abio_puts(codeFile, "\n");
    }

    abio_printf(codeFile,"XmAddWMProtocolCallback(toplevel, %s,\n", atom_name);
    abio_puts(codeFile,"\tdtb_session_save, (XtPointer)NULL);\n");

    abio_puts(codeFile,"\n");

    return (0);
}
Example #26
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;
}
Example #27
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;
}
Example #28
0
/*
** determine which builtin action and write the appropriate code.
*/
static int
write_builtin_action(
    GenCodeInfo	      genCodeInfo,
    ABObj 	      action,
    ABObj             toObj,
    AB_BUILTIN_ACTION builtin_action,
    STRING            actionTKResource,		       /* in toolkit */
    STRING	      actionResource		       /* in source code */
)
{
#define	 IS(type)	(obj_get_func_type(action) ==(type))
#define	 SVAL(action)	((STRING)obj_get_arg_string(action))
#define	 IVAL(action)	((int)obj_get_arg_int(action))

    File                codeFile     = genCodeInfo->code_file;
    int			return_value = 0;

    if (!codeFile || !action || !toObj || !builtin_action)
        return return_value;

    switch (builtin_action)
    {
    case AB_STDACT_ENABLE:
        abio_print_line(codeFile, NULL);
        abio_print_line(codeFile, "XtSetSensitive(%s, True);",
                        abmfP_get_c_name(genCodeInfo, toObj));
        break;

    case AB_STDACT_DISABLE:
        abio_print_line(codeFile, NULL);
        abio_print_line(codeFile, "XtSetSensitive(%s, False);",
                        abmfP_get_c_name(genCodeInfo, toObj));
        break;

    case AB_STDACT_SHOW:
        switch((obj_get_root(toObj))->type)
        {
        case AB_TYPE_BASE_WINDOW:
            abio_print_line(codeFile, "XtPopup(%s, XtGrabNone);",
                            abmfP_get_c_name(genCodeInfo, toObj));
            break;

        case AB_TYPE_DIALOG:
        case AB_TYPE_FILE_CHOOSER:
        default:
            abio_print_line(codeFile, "XtManageChild(%s);",
                            abmfP_get_c_name(genCodeInfo, toObj));
            break;
        }
        break;

    case AB_STDACT_HIDE:
        switch((obj_get_root(toObj))->type)
        {
        case AB_TYPE_BASE_WINDOW:
            abio_print_line(codeFile, "XtPopdown(%s);",
                            abmfP_get_c_name(genCodeInfo, toObj));
            break;

        case AB_TYPE_DIALOG:
        case AB_TYPE_FILE_CHOOSER:
        default:
            abio_print_line(codeFile, "XtUnmanageChild(%s);",
                            abmfP_get_c_name(genCodeInfo, toObj));
            break;
        }
        break;

    case AB_STDACT_SET_LABEL:
        /* check toObj for root */
        if ( obj_get_label_type(obj_get_root(toObj)) == AB_LABEL_GLYPH)
        {
            abio_printf(codeFile, "%s(%s, ",
                        abmfP_lib_set_label_from_image_file->name,
                        abmfP_get_c_name(genCodeInfo, toObj));
            abio_put_string(codeFile, SVAL(action));
            abio_puts(codeFile, ");\n");
        }
        else
        {
            assert(actionTKResource != NULL);
            printf_setval(genCodeInfo, toObj,
                          actionTKResource, SVAL(action),
                          NULL);
        }
        break;

    case AB_STDACT_SET_VALUE:
        printf_setval(genCodeInfo, toObj,
                      actionTKResource, IVAL(action), NULL);
        break;

    case AB_STDACT_SET_TEXT:
        printf_setval(genCodeInfo, toObj,
                      actionTKResource, SVAL(action),
                      NULL);
        break;

    /* 	case AB_STDACT_SHOW_HELP: */
    /* 	    abio_print_line(codeFile, NULL); */
    /* 	    abio_print_line(codeFile,  */
    /* 		"XtCallCallbacks(%s,XmNhelpCallback,(XtPointer)NULL);", */
    /* 		abmfP_get_c_name(genCodeInfo, toObj)); */
    /* 	    break; */

    default:
    {
        static char         msg[255];

        if (obj_get_name(action) != NULL)
        {
            char *action_name = obj_get_name(action);
            sprintf(msg, catgets(Dtb_project_catd, 1, 76,
                                 "Unknown action name, %s"), action_name);
        }
        else
        {
            int action_type = obj_get_func_builtin(action);
            sprintf(msg, catgets(Dtb_project_catd, 1, 77,
                                 "Unknown action type, %d"), action_type);
        }
        util_error(msg);
        return_value = ERR_INTERNAL;

        /*
         * return msg; Just print message and go on - JT
         */
    }
    break;
    }			/* switch func.value.builtin */

    return return_value;
#undef IS
#undef SVAL
#undef IVAL
}
Example #29
0
static int
write_includes(GenCodeInfo genCodeInfo, ABObj project)
{
    File	 codeFile = genCodeInfo->code_file;
    STRING	 *p       = NULL;
    AB_TRAVERSAL trav;
    ABObj	 module   = NULL;
    StringList   includes = strlist_create();
    char         buf[MAXPATHLEN+1];
    int          i;
    
    strlist_set_is_unique(includes, TRUE);
    *buf = 0;

    /* standard system includes */
    for (p = Includes; *p; p++)
    {
	strlist_add_str(includes, *p, NULL);
    }

    /*
     * Includes for sessioning.
     * These include files are needed only if sessioning
     * is used.
     */
    if (abmfP_proj_needs_session_save(project) || 
	abmfP_proj_needs_session_restore(project))
    {
        for (p = Session_Includes; *p; p++)
        {
	    strlist_add_str(includes, *p, NULL);
        }
    }

    /*
     * Includes for i18n.
     * These include files are needed only if i18n
     * is enabled.
     */
    if (genCodeInfo->i18n_method == ABMF_I18N_XPG4_API)
    {
        for (p = I18n_Includes; *p; p++)
        {
	    strlist_add_str(includes, *p, NULL);
        }
    }

    /* module includes */
    for (trav_open(&trav, project, AB_TRAV_MODULES);
	(module = trav_next(&trav)) != NULL; )
    {
	if (!obj_is_defined(module))
	{
	    continue;
	}
	sprintf(buf, "\"%s\"", abmfP_get_ui_header_file_name(module));
	strlist_add_str(includes, buf, NULL);
    }
    trav_close(&trav);

    /* project include */
    sprintf(buf, "\"%s\"", abmfP_get_project_header_file_name(project));
    strlist_add_str(includes, buf, NULL);

    sprintf(buf, "\"%s\"", abmfP_get_utils_header_file_name(project));
    strlist_add_str(includes, buf, NULL);

    abmfP_get_connect_includes(includes, project);

    /* Write the includes */
    for (i = 0; i < strlist_get_num_strs(includes); ++i)
    {
	abio_printf(codeFile, "#include %s\n",
	    strlist_get_str(includes, i, NULL));
    }
    
    abio_puts(codeFile, nlstr);

    strlist_destroy(includes);
    return 0;
}
Example #30
0
/*
 * 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;
}