view src/mbaf/mbobject.c @ 592:de9d210e9c38 openvg

Specify width and height while create an image surface
author Thinker K.F. Li <thinker@branda.to>
date Wed, 30 Jun 2010 19:53:10 +0800
parents f894b30676e9
children 586e50f82c1f
line wrap: on
line source

#include "mb_types.h"
#include "mb_obj.h"


void mb_obj_set_pos(mb_obj_t *obj, co_aix x, co_aix y)
{
    if (MBO_TYPE(obj) == MBO_COORD) {
	    coord_x(((coord_t *) obj)) = x;
	    coord_y(((coord_t *) obj)) = y;
    } else if (MBO_TYPE(obj) == MBO_TEXT) {
	    sh_text_set_pos((shape_t *) obj, x, y);
    } else {
	    return;
    }
    
}

void mb_obj_get_pos(mb_obj_t *obj, co_aix *x, co_aix *y)
{
    if (MBO_TYPE(obj) == MBO_COORD) {
	    *x = coord_x((coord_t *) obj);
	    *y = coord_y((coord_t *) obj);
    } else if (MBO_TYPE(obj) == MBO_TEXT) {
	    sh_text_get_pos((shape_t *) obj, x, y);
    } else {
	    return;
    }
    
}

void mb_obj_set_text(mb_obj_t *obj, const char *text)
{
    if (MBO_TYPE(obj) == MBO_COORD) {
        geo_t *geo;
        shape_t *shape;
	coord_t *g = (coord_t *) obj;

        FOR_COORD_MEMBERS(g, geo) {
            shape = geo_get_shape(geo);
            if(shape->obj.obj_type == MBO_TEXT) {
		sh_text_set_text(shape, text);
		return;
            }
        }
    } else if (MBO_TYPE(obj) == MBO_TEXT) {
	    sh_text_set_text((shape_t *) obj,text);
    } else {
	    return;
    }
    
}


void mb_obj_get_text(mb_obj_t *obj, char *text,int size)
{
    if (MBO_TYPE(obj) == MBO_COORD) {
        geo_t *geo;
        shape_t *shape;
	coord_t *g = (coord_t *) obj;

        FOR_COORD_MEMBERS(g, geo) {
            shape = geo_get_shape(geo);
            if(shape->obj.obj_type == MBO_TEXT) {
		sh_text_get_text(shape, text,size);
		return;
            }
        }
    } else if (MBO_TYPE(obj) == MBO_TEXT) {
	    sh_text_get_text((shape_t *) obj,text,size);
    } else {
	    *text = 0;
	    return;
    }
}

void mb_obj_set_scalex(mb_obj_t *obj,int scale)
{
    if (MBO_TYPE(obj) == MBO_COORD) {
	coord_set_scalex((coord_t *) obj, scale);
    } else {
    }
}

int mb_obj_get_scalex(mb_obj_t *obj)
{
    if (MBO_TYPE(obj) == MBO_COORD) {
	return coord_scalex((coord_t *) obj);
    } else {
	return 100;
    }
}

void mb_obj_set_scaley(mb_obj_t *obj,int scale)
{
    if (MBO_TYPE(obj) == MBO_COORD) {
	coord_set_scaley((coord_t *) obj, scale);
    } else {
    }
}
int mb_obj_get_scaley(mb_obj_t *obj)
{
    if (MBO_TYPE(obj) == MBO_COORD) {
	return coord_scaley((coord_t *) obj);
    } else {
	return 100;
    }
}

void mb_obj_set_rotation(mb_obj_t *obj, int degree)
{
    printf("%s is not implemented yet\n",__FUNCTION__);
}

int mb_obj_get_rotation(mb_obj_t *obj)
{
    printf("%s is not implemented yet\n",__FUNCTION__);
}



void mb_obj_set_color(mb_obj_t *obj, int color)
{
    printf("%s is not implemented yet\n",__FUNCTION__);
}


int mb_obj_get_color(mb_obj_t *obj)
{
    printf("%s is not implemented yet\n",__FUNCTION__);
    return 0;
}