Beispiel #1
0
/*
** Set the label on an object
**     string and glyphs are supported
*/
void
ui_obj_set_label(
    ABObj       obj,
    STRING	label
)
{
    if (obj == NULL)
	return;

    switch (obj_get_label_type(obj))
    {
	case AB_LABEL_STRING:
	    ui_obj_set_label_string(obj, label);
	    break;

	case AB_LABEL_GLYPH:
	    ui_obj_set_label_glyph(obj, label);
	    break;

	default:
	    return;
    }
}
Beispiel #2
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
}