Example #1
0
/*
** Set the label glyph (ie graphic) on an object
*/
void
ui_obj_set_label_glyph(
    ABObj       obj,
    STRING	fileName
)
{
    ABObj  labelObj = NULL;
    
    if (obj == NULL)
	return;

    if (util_strempty(fileName))
	return;
    
    labelObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ);
    if (labelObj == NULL || objxm_get_widget(labelObj) == NULL)
	return;

    switch (obj_get_type(obj))
    {
	case AB_TYPE_BUTTON:
	case AB_TYPE_CHOICE:
	case AB_TYPE_COMBO_BOX:
	case AB_TYPE_LABEL:
	case AB_TYPE_LIST:
	case AB_TYPE_SPIN_BOX:
	case AB_TYPE_SCALE:
	case AB_TYPE_TEXT_FIELD:
	    ui_set_label_glyph(objxm_get_widget(labelObj), fileName);
	    break;

	case AB_TYPE_ITEM:
	    switch(obj_get_item_type(obj))
	    {
		case AB_ITEM_FOR_MENU:
		case AB_ITEM_FOR_MENUBAR:
		case AB_ITEM_FOR_CHOICE:
		    ui_set_label_glyph(objxm_get_widget(labelObj), fileName);
		    break;

		default:
		    break;
	    }
	    break;
	    
	default:
	    break;
    }
}
Example #2
0
File: proj.c Project: juddy/edcde
int
proj_set_cur_module(
    ABObj	module
)
{
    if ( (module != NULL) && (obj_get_type(module) != AB_TYPE_MODULE) )
	return -1;

    AB_cur_module = module;
    if (module != NULL)
	ab_update_stat_region(AB_STATUS_CUR_MODULE, obj_get_name(module));
    else
	ab_update_stat_region(AB_STATUS_CUR_MODULE, NULL);
	
    return OK;
}
Example #3
0
/* 
 * Can the object's width be changed (from Prop sheet)?
 */ 
BOOL
abobj_width_resizable(
    ABObj       obj
)
{
    BOOL        resizable = True;
 
    switch(obj_get_type(obj))
    {
        case AB_TYPE_CHOICE:
            resizable = False;
            break; 
	case AB_TYPE_SPIN_BOX:
	case AB_TYPE_COMBO_BOX:
	case AB_TYPE_BUTTON:
	case AB_TYPE_LABEL:
	case AB_TYPE_LIST:
        case AB_TYPE_BASE_WINDOW: 
        case AB_TYPE_DIALOG:
	    if (obj_get_width(obj) == -1)
		resizable = False;
	    break;
        case AB_TYPE_SCALE: 
            if (obj_get_orientation(obj) == AB_ORIENT_VERTICAL) 
                resizable = False; 
            break; 
        case AB_TYPE_CONTAINER: 
        { 
            AB_CONTAINER_TYPE cont_type; 
            cont_type = obj_get_container_type(obj); 
            if (cont_type == AB_CONT_MENU_BAR ||
                cont_type == AB_CONT_TOOL_BAR ||
                cont_type == AB_CONT_FOOTER ||
                cont_type == AB_CONT_BUTTON_PANEL ||
                cont_type == AB_CONT_GROUP ||
		(obj_is_control_panel(obj) && obj_get_width(obj) == -1))
                resizable = False;
            break; 
        }
        default:
            break;
    }
    return resizable;
}
Example #4
0
BOOL
abobj_is_movable(
    ABObj       obj
)
{
    BOOL        	movable = True;
    ABObj		pobj;
    AB_CONTAINER_TYPE	cont_type;

    /* If object is a child of a Group and the group has a
     * defined layout type, then it is not movable
     */
    pobj = obj_get_root(obj_get_parent(obj));
    if (obj_is_group(pobj) &&
        obj_get_group_type(pobj) != AB_GROUP_IGNORE)
        movable = False;

    switch(obj_get_type(obj))
    {
	case AB_TYPE_TEXT_PANE:
	case AB_TYPE_TERM_PANE:
	case AB_TYPE_DRAWING_AREA:
        case AB_TYPE_CONTAINER:
        {
	    /* If object is child of PanedWindow, it cannot be moved */
	    if (obj_is_paned_win(pobj))
		movable = False;
	    else if (obj_is_container(obj))
	    {
            	cont_type = obj_get_container_type(obj);
            	if (cont_type == AB_CONT_MENU_BAR ||
                    cont_type == AB_CONT_TOOL_BAR ||
                    cont_type == AB_CONT_FOOTER ||
                    cont_type == AB_CONT_BUTTON_PANEL)
                    movable = False;
	    }
            break;
        }
        default:
            break;
    }
    return movable;
}
Example #5
0
/*
 * Can the object's height be changed (from Prop sheet)?
 */
BOOL
abobj_height_resizable(
    ABObj	obj
)
{
    BOOL 	resizable = True;

    switch(obj_get_type(obj))
    {
        case AB_TYPE_COMBO_BOX:
	case AB_TYPE_TEXT_FIELD:
	case AB_TYPE_SPIN_BOX:
        case AB_TYPE_CHOICE:
            resizable = False;
	    break;
	case AB_TYPE_BUTTON:
	case AB_TYPE_LABEL:
	case AB_TYPE_BASE_WINDOW:
	case AB_TYPE_DIALOG:
	    if (obj_get_height(obj) == -1)
		resizable = False;
	    break;
	case AB_TYPE_SCALE:
	    if (obj_get_orientation(obj) == AB_ORIENT_HORIZONTAL)
		resizable = False;
	    break;
        case AB_TYPE_CONTAINER:
        {
            AB_CONTAINER_TYPE cont_type;
            cont_type = obj_get_container_type(obj);
            if (cont_type == AB_CONT_MENU_BAR ||
		(obj_is_control_panel(obj) && obj_get_height(obj) == -1))
		resizable = False;
	    break;
        }
        default:
            break;
    }
    return resizable;
}
Example #6
0
/*
 * Can the object be resized using direct-manipulation?
 */
BOOL
abobj_is_directly_resizable(
    ABObj       obj
)
{
    BOOL        resizable = True;

    switch(obj_get_type(obj))
    {
        case AB_TYPE_BUTTON:
        case AB_TYPE_LABEL:
        case AB_TYPE_COMBO_BOX:
	case AB_TYPE_LIST:
            if (obj_get_width(obj) == -1)
                resizable = False;
            break;
	case AB_TYPE_CHOICE:
	    resizable = False;
	    break;
        case AB_TYPE_CONTAINER:
	{
            AB_CONTAINER_TYPE cont_type;
            cont_type = obj_get_container_type(obj);
            if ((cont_type == AB_CONT_MENU_BAR ||
                 cont_type == AB_CONT_TOOL_BAR ||
                 cont_type == AB_CONT_FOOTER ||
		 cont_type == AB_CONT_BUTTON_PANEL ||
		 cont_type == AB_CONT_GROUP) ||
		obj_get_width(obj) == -1)
                resizable = False;
            break;
        }
        default:
            break;
    }
    return resizable;
}
Example #7
0
/*
 * ui_get_obj_pixmap
 * based on an object's type and subtype, return a pixmap, and
 * it's width/height. This pixmap typically can be used to represent
 * the object in viewers/browsers.
 */
void
ui_get_obj_pixmap
(
    AB_OBJ		*obj,
    Pixmap		*pixmap,	/* RETURN */
    unsigned int	*width,		/* RETURN */
    unsigned int	*height		/* RETURN */
)
{
    int			i;
    AB_OBJECT_TYPE	type;
    int			subtype;
    Pixmap		p = NULL;
    BOOL		found = FALSE;

    if (!obj || !pixmap || !width || !height)
	return;

    /*
     * Initialize pixmaps
     */
    init_obj_pixmaps();

    /*
     * Get object type/subtype
     */
    type = obj_get_type(obj);
    subtype = obj_get_subtype(obj);

    /*
     * Special case for scale/gauge
     * The subtype field is not used. Instead it's read-only
     * state is used to determine if it is a scale/gauge.
     */
    if (type == AB_TYPE_SCALE)
    {
        if (obj_get_read_only(obj) == False)
	    subtype = AB_SCALE_SCALE;
        else /* Gauge */
	    subtype = AB_SCALE_GAUGE;
    }

    /*
     * Search for object type/subtype match
     */
    for (i=0; (object_pixmaps[i].type != AB_TYPE_UNKNOWN); ++i)
    {
	if ((type == object_pixmaps[i].type) &&
	    (subtype == object_pixmaps[i].subtype))
	{
	    *pixmap = object_pixmaps[i].pixmap;
	    *width = object_pixmaps[i].width;
	    *height = object_pixmaps[i].height;

	    if (*pixmap)
	        found = TRUE;

	    break;
	}
    }

    /*
     * If no match, return the default pixmap
     */
    if (!found)
    {
        *pixmap = default_pixmap;
        *width = default_pixmap_width;
        *height = default_pixmap_height;
    }
}
Example #8
0
/*
** Set the label string on an object
** (converts it to XmString internally, if needed)
*/
void
ui_obj_set_label_string(
    ABObj       obj,
    STRING	label
)
{
    ABObj labelObj   = NULL;
    
    if (obj == NULL)
	return;
	
    switch (obj_get_type(obj))
    {
	case AB_TYPE_BUTTON:
	case AB_TYPE_CHOICE:
	case AB_TYPE_COMBO_BOX:
	case AB_TYPE_LABEL:
	case AB_TYPE_LIST:
	case AB_TYPE_SPIN_BOX:
	case AB_TYPE_SCALE:
	case AB_TYPE_TEXT_FIELD:
	    labelObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ);
	    if (labelObj == NULL || objxm_get_widget(labelObj) == NULL)
		return;

	    ui_set_label_string(objxm_get_widget(labelObj), label);
	    break;

	case AB_TYPE_ITEM:
	    switch(obj_get_item_type(obj))
	    {
		case AB_ITEM_FOR_MENU:
		case AB_ITEM_FOR_MENUBAR:
		case AB_ITEM_FOR_CHOICE:
		    labelObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ);
		    if (labelObj == NULL || objxm_get_widget(labelObj) == NULL)
			return;

		    ui_set_label_string(objxm_get_widget(labelObj), label);
		    break;

		case AB_ITEM_FOR_COMBO_BOX:
		case AB_ITEM_FOR_LIST:
		case AB_ITEM_FOR_SPIN_BOX:
		    {
			ABObj        p_obj = obj_get_parent(obj);
			Widget       parent = objxm_get_widget(p_obj);
			AB_ITEM_TYPE itype = (AB_ITEM_TYPE)obj_get_subtype(obj);
			int          pos;
			int          num_items;
			XmString     xmitem;
	    
			if (parent != NULL)
			{
			    xmitem = XmStringCreateLocalized(label);
			    pos = obj_get_child_num(obj);
			    pos++; /* XmList starts at 1 */
		
			    if (obj_is_combo_box_item(obj))
				parent = ui_combobox_get_list_widget(parent);
		
			    if (obj_is_list_item(obj) ||
				obj_is_combo_box_item(obj))
				XtVaGetValues(parent,
				    XmNitemCount, &num_items,
				    NULL);
			    else if (obj_is_spin_box_item(obj))
				XtVaGetValues(parent,
				    DtNnumValues, &num_items,
				    NULL);

			    if (pos <= num_items)
			    {
				if (obj_is_list_item(obj) ||
				    obj_is_combo_box_item(obj))
				{
				    XmListReplacePositions(parent, &pos,
					&xmitem, 1);
				}
				else
				{
				    DtSpinBoxDeletePos(parent, pos);
				    DtSpinBoxAddItem(parent, xmitem, pos);
				}
			    }
			    XmStringFree(xmitem);
			}
		    }
		    break;

		default:
		    break;
	    }
	    break;
	    
	case AB_TYPE_BASE_WINDOW:
	case AB_TYPE_DIALOG:
	case AB_TYPE_FILE_CHOOSER:
	    labelObj = objxm_comp_get_subobj(obj, AB_CFG_LABEL_OBJ);
	    if (labelObj == NULL || objxm_get_widget(labelObj) == NULL)
		return;

	    XtVaSetValues(objxm_get_widget(labelObj), XmNtitle, label, NULL);
	    break;

	default:
	    break;
    }
}
/*
 * test == 1: get next pid
 * test == 2: get next oid
 * test == 3: check existing obj
 * test == 4: check non existing obj
 * test == 5: check if pid empty
 * test == 6: get type
 */
static void time_obj_generic(struct osd_device *osd, int numobj, int numiter,
			     int test)
{
	int ret = 0;
	int i = 0, j = 0;
	uint64_t start, end;
	uint64_t oid = 0, pid = 0;
	int present = 0;
	int isempty = 0;
	uint8_t obj_type = ILLEGAL_OBJ;
	double *t = 0;
	double mu, sd;
	const char *func = NULL;

	if (test < 1 || test > 6)
		return;

	t = Malloc(sizeof(*t) * numiter);
	if (!t)
		return;

	/* run a pilot */
	switch (test) {
	case 1: {
		ret = obj_insert(osd->dbc, 20, 0, 2);
		assert(ret == 0);
		pid = 0;
		ret = obj_get_nextpid(osd->dbc, &pid);
		assert(ret == 0);
		assert(pid == 21);
		ret = obj_delete(osd->dbc, 20, 0);
		assert(ret == 0);
		func = "get_next_pid";
		break;
	}
	case 2: {
		ret = obj_insert(osd->dbc, 1, 2, 128);
		assert(ret == 0);
		oid = 0;
		ret = obj_get_nextoid(osd->dbc, 1, &oid);
		assert(ret == 0);
		assert(oid == 3);
		ret = obj_delete(osd->dbc, 1, 2);
		assert(ret == 0);
		func = "get_next_oid";
		break;
	}
	case 3: 
	case 4: {
		ret = obj_insert(osd->dbc, 1, 2, 128);
		assert(ret == 0);
		ret = obj_ispresent(osd->dbc, 1, 2, &present);
		assert(ret == 0 && present == 1);
		ret = obj_delete(osd->dbc, 1, 2);
		assert(ret == 0);
		ret = obj_ispresent(osd->dbc, 1, 2, &present);
		assert(ret == 0 && present == 0);
		if (test == 3)
			func = "objpresent";
		else
			func = "objnotpresent";
		break;
	}
	case 5: {
		ret = obj_insert(osd->dbc, 1, 2, 128);
		assert(ret == 0);
		ret = obj_isempty_pid(osd->dbc, 1, &isempty);
		assert(ret == 0 && isempty == 0);
		ret = obj_delete(osd->dbc, 1, 2);
		assert(ret == 0);
		ret = obj_isempty_pid(osd->dbc, 1, &isempty);
		assert(ret == 0 && isempty == 1);
		func = "objemptypid";
		break;
	}
	case 6: {
		ret = obj_insert(osd->dbc, 1, 2, USEROBJECT);
		assert(ret == 0);
		ret = obj_get_type(osd->dbc, 1, 2, &obj_type);
		assert(ret == 0 && obj_type == USEROBJECT);
		ret = obj_delete(osd->dbc, 1, 2);
		assert(ret == 0);
		func = "objgettype";
		break;
	}
	default:
		fprintf(stderr, "1 <= test <= 6\n");
		exit(1);
	}

	for (i = 0; i < numiter; i++) {
		for (j = 1; j < numobj+1; j++) {
			if (test == 1) {
				ret = obj_insert(osd->dbc, j, 0, PARTITION);
			} else {
				ret = obj_insert(osd->dbc, 1, j, USEROBJECT);
			}
			assert(ret == 0);
		}

		switch (test) {
		case 1: {
			pid = 0;
			rdtsc(start);
			ret = obj_get_nextpid(osd->dbc, &pid);
			rdtsc(end);
			assert(ret == 0);
			assert(pid == (uint64_t)(numobj+1));
			break;
		}
		case 2: {
			oid = 0;
			rdtsc(start);
			ret = obj_get_nextoid(osd->dbc, 1, &oid);
			rdtsc(end);
			assert(ret == 0);
			assert(oid == (uint64_t)(numobj+1));
			break;
		}
		case 3: {
			oid = numobj;
			rdtsc(start);
			ret = obj_ispresent(osd->dbc, 1, oid, &present);
			rdtsc(end);
			assert(ret == 0 && present == 1);
			break;
		}
		case 4: {
			oid = numobj+2;
			rdtsc(start);
			ret = obj_ispresent(osd->dbc, 1, oid, &present);
			rdtsc(end);
			assert(ret == 0 && present == 0);
			break;
		}
		case 5: {
			rdtsc(start);
			ret = obj_isempty_pid(osd->dbc, 1, &isempty);
			rdtsc(end);
			assert(ret == 0 && isempty == 0);
			break;
		}
		case 6: {
			oid = numobj;
			rdtsc(start);
			ret = obj_get_type(osd->dbc, 1, oid, &obj_type);
			rdtsc(end);
			assert(ret == 0 && obj_type == USEROBJECT);
			break;
		}
		default:
			fprintf(stderr, "1 <= test <= 6\n");
			exit(1);
		}

		t[i] = (double) (end - start) / mhz;
		start = end = 0;

		switch (test) {
		case 1: {
			for (j = 1; j < numobj+1; j++) {
				ret = obj_delete(osd->dbc, j, 0);
				assert(ret == 0);
			}
			break;
		}
		case 2:
		case 3:
		case 4:
		case 5:
		case 6: {
			ret = obj_delete_pid(osd->dbc, 1);
			assert(ret == 0);
			break;
		}
		default:
			fprintf(stderr, "1 <= test <= 6\n");
			exit(1);
		}
	}

	mu = mean(t, numiter);
	sd = stddev(t, mu, numiter);
	printf("%s numiter %d numobj %d test, %d avg %lf +- %lf us\n", func,
	       numiter, numobj, test, mu, sd); 
	free(t);
}
Example #10
0
/*
 * Gets the object that the connection is "actually" from. If write_conn*
 * is called on an object that has references to it, it's actually the
 * references that have the connections, not the object, itself.
 * (e.g., menus never have connections written, it's the menu references
 * that do).
 */
static ABObj
get_actual_from_obj(ABObj actionOrObj)
{
    static ABObj	lastFromObj = NULL;
    static ABObj	lastActualFromObj = NULL;
    AB_TRAVERSAL	refTrav;
    ABObj		refObj = NULL;
    ABObj		module = NULL;
    ABObj		fromObj = NULL;
    ABObj		actualFromObj = NULL;

    if (actionOrObj == NULL)
    {
        return NULL;
    }

    /*
     * Get the "from" obj
     */
    if (obj_is_action(actionOrObj))
    {
        fromObj = obj_get_from(actionOrObj);
    }
    else if (obj_is_ui(actionOrObj))
    {
        fromObj = actionOrObj;
    }

    /*
     * Shortcut, to avoid a lengthy traversal
     */
    if (fromObj == lastFromObj)
    {
        goto epilogue;
    }

    /*
     * See if we can do anything
     */
    if (fromObj == NULL)
    {
        return NULL;
    }
    module = obj_get_module(fromObj);

    /*
     * Actually find it!
     */
    if (   (!obj_is_ref(fromObj))
            && (   (obj_get_type(fromObj) == AB_TYPE_MENU)
                   || (obj_get_parent_of_type(fromObj, AB_TYPE_MENU) != NULL)) )
    {
        /* find an object that references this one, to
         * get the appropriate type (only menu references are
         * supported, currently).
         */
        for (trav_open(&refTrav, module, AB_TRAV_UI);
                (refObj = trav_next(&refTrav)) != NULL; )
        {
            if (refObj->ref_to == fromObj)
            {
                break;
            }
        }
        trav_close(&refTrav);
    }

    if (actualFromObj == NULL)
    {
        if (refObj != NULL)
        {
            actualFromObj = refObj;
        }
        else
        {
            actualFromObj = fromObj;
        }
    }

    lastFromObj = fromObj;
    lastActualFromObj = actualFromObj;

epilogue:
    return lastActualFromObj;
}