add code to double check object type before doing anything to objects

SVN revision: 3523
This commit is contained in:
Carsten Haitzler 2000-09-18 02:22:04 +00:00
parent e7c086bd57
commit 8923422a2e
10 changed files with 84 additions and 20 deletions

View File

@ -49,6 +49,8 @@ typedef struct _Evas_Object_Gradient_Box * Evas_Object_Gradient_Box;
#define OBJECT_LINE 1233
#define OBJECT_GRADIENT_BOX 1234
#define IF_OBJ(_o, _t) if (((Evas_Object)_o)->type != _t)
struct _Evas_Render_Data
{
int *method[RENDER_METHOD_COUNT];

View File

@ -13,6 +13,7 @@ _evas_free_gradient_box(Evas_Object o)
{
Evas_Object_Gradient_Box oo;
IF_OBJ(o, OBJECT_GRADIENT_BOX) return;
oo = o;
if (oo->current.gradient) evas_gradient_free(oo->current.gradient);
free(o);
@ -93,6 +94,7 @@ evas_set_gradient(Evas e, Evas_Object o, Evas_Gradient grad)
{
Evas_Object_Gradient_Box oo;
IF_OBJ(o, OBJECT_GRADIENT_BOX) return;
oo = o;
if (oo->current.gradient)
evas_gradient_free(oo->current.gradient);

View File

@ -9,6 +9,7 @@ _evas_free_image(Evas_Object o)
{
Evas_Object_Image oo;
IF_OBJ(o, OBJECT_IMAGE) return;
oo = o;
if (oo->current.file) free(oo->current.file);
free(o);
@ -157,6 +158,7 @@ evas_set_image_fill(Evas e, Evas_Object o, double x, double y, double w, double
{
Evas_Object_Image oo;
IF_OBJ(o, OBJECT_IMAGE) return;
oo = o;
oo->current.fill.x = x;
oo->current.fill.y = y;
@ -172,6 +174,7 @@ evas_get_image_size(Evas e, Evas_Object o, int *w, int *h)
{
Evas_Object_Image oo;
IF_OBJ(o, OBJECT_IMAGE) return;
oo = o;
if (w) *w = oo->current.image.w;
if (h) *h = oo->current.image.h;
@ -182,6 +185,7 @@ evas_set_image_border(Evas e, Evas_Object o, int l, int r, int t, int b)
{
Evas_Object_Image oo;
IF_OBJ(o, OBJECT_IMAGE) return;
oo = o;
oo->current.border.l = l;
oo->current.border.r = r;
@ -196,6 +200,7 @@ evas_get_image_border(Evas e, Evas_Object o, int *l, int *r, int *t, int *b)
{
Evas_Object_Image oo;
IF_OBJ(o, OBJECT_IMAGE) return;
oo = o;
if (l) *l = oo->current.border.l;
if (r) *r = oo->current.border.r;

View File

@ -794,6 +794,8 @@ __evas_image_get_colormap(Display *disp, int screen)
if (__evas_cmap) return __evas_cmap;
v = __evas_imlib_get_visual(disp, screen);
__evas_cmap = DefaultColormap(disp, screen);
return __evas_cmap;
__evas_cmap = XCreateColormap(disp, RootWindow(disp, screen), v, AllocNone);
return __evas_cmap;
}
@ -805,6 +807,7 @@ __evas_image_init(Display *disp, int screen, int colors)
if (!initted)
{
imlib_set_color_usage(216);
imlib_set_font_cache_size(1024 * 1024);
imlib_set_cache_size(8 * 1024 * 1024);
initted = 1;

View File

@ -717,6 +717,8 @@ __evas_imlib_get_colormap(Display *disp, int screen)
if (__evas_cmap) return __evas_cmap;
v = __evas_imlib_get_visual(disp, screen);
__evas_cmap = DefaultColormap(disp, screen);
return __evas_cmap;
__evas_cmap = XCreateColormap(disp, RootWindow(disp, screen), v, AllocNone);
return __evas_cmap;
}
@ -728,6 +730,7 @@ __evas_imlib_init(Display *disp, int screen, int colors)
if (!initted)
{
imlib_set_color_usage(216);
imlib_set_font_cache_size(1024 * 1024);
imlib_set_cache_size(8 * 1024 * 1024);
initted = 1;

View File

@ -9,6 +9,7 @@ _evas_free_line(Evas_Object o)
{
Evas_Object_Line oo;
IF_OBJ(o, OBJECT_LINE) return;
oo = o;
free(o);
}
@ -81,6 +82,7 @@ evas_set_line_xy(Evas e, Evas_Object o, double x1, double y1, double x2, double
Evas_Object_Line oo;
int event_update = 0;
IF_OBJ(o, OBJECT_LINE) return;
oo = (Evas_Object_Line)o;
if ((o->current.visible) &&
(_evas_point_in_object(e, o, e->mouse.x, e->mouse.y)))

View File

@ -9,6 +9,7 @@ _evas_free_rectangle(Evas_Object o)
{
Evas_Object_Rectangle oo;
IF_OBJ(o, OBJECT_RECTANGLE) return;
oo = o;
free(o);
}

View File

@ -13,6 +13,7 @@ _evas_free_text(Evas_Object o)
{
Evas_Object_Text oo;
IF_OBJ(o, OBJECT_TEXT) return;
oo = o;
if (oo->current.text) free(oo->current.text);
free(o);
@ -158,6 +159,7 @@ evas_get_text_string(Evas e, Evas_Object o)
{
Evas_Object_Text oo;
IF_OBJ(o, OBJECT_TEXT) return "";
oo = o;
return oo->current.text;
}
@ -167,6 +169,7 @@ evas_get_text_font(Evas e, Evas_Object o)
{
Evas_Object_Text oo;
IF_OBJ(o, OBJECT_TEXT) return "";
oo = o;
return oo->current.font;
}
@ -176,6 +179,7 @@ evas_get_text_size(Evas e, Evas_Object o)
{
Evas_Object_Text oo;
IF_OBJ(o, OBJECT_TEXT) return 0;
oo = o;
return oo->current.size;
}
@ -186,6 +190,7 @@ evas_text_at_position(Evas e, Evas_Object o, double x, double y,
{
Evas_Object_Text oo;
IF_OBJ(o, OBJECT_TEXT) return -1;
oo = o;
switch (e->current.render_method)
{
@ -275,6 +280,7 @@ evas_text_at(Evas e, Evas_Object o, int index,
{
Evas_Object_Text oo;
IF_OBJ(o, OBJECT_TEXT) return;
oo = o;
switch (e->current.render_method)
{
@ -352,6 +358,7 @@ evas_text_get_ascent_descent(Evas e, Evas_Object o,
int a, d;
Evas_Object_Text oo;
IF_OBJ(o, OBJECT_TEXT) return;
oo = o;
a = 0; d = 0;
switch (e->current.render_method)
@ -424,6 +431,7 @@ evas_text_get_max_ascent_descent(Evas e, Evas_Object o,
int a, d;
Evas_Object_Text oo;
IF_OBJ(o, OBJECT_TEXT) return;
oo = o;
a = 0; d = 0;
switch (e->current.render_method)
@ -496,6 +504,7 @@ evas_text_get_advance(Evas e, Evas_Object o,
int a, d;
Evas_Object_Text oo;
IF_OBJ(o, OBJECT_TEXT) return;
oo = o;
a = 0; d = 0;
switch (e->current.render_method)
@ -563,6 +572,7 @@ evas_text_get_inset(Evas e, Evas_Object o)
Evas_Object_Text oo;
int inset;
IF_OBJ(o, OBJECT_TEXT) return 0.0;
oo = o;
switch (e->current.render_method)
{

View File

@ -904,6 +904,8 @@ __evas_x11_get_colormap(Display *disp, int screen)
if (__evas_cmap) return __evas_cmap;
v = __evas_x11_get_visual(disp, screen);
__evas_cmap = DefaultColormap(disp, screen);
return __evas_cmap;
__evas_cmap = XCreateColormap(disp, RootWindow(disp, screen), v, AllocNone);
return __evas_cmap;
}
@ -915,6 +917,7 @@ __evas_x11_init(Display *disp, int screen, int colors)
if (!initted)
{
imlib_set_color_usage(216);
imlib_set_font_cache_size(1024 * 1024);
imlib_set_cache_size(8 * 1024 * 1024);
initted = 1;

View File

@ -93,28 +93,61 @@ main(int argc, char **argv)
};
win_w = 640; win_h = 480;
if (argc >= 3)
{
win_w = atoi(argv[1]);
win_h = atoi(argv[2]);
}
e = evas_new();
if ((argc >= 4) && (!strcmp(argv[3], "software")))
evas_set_output_method(e, RENDER_METHOD_ALPHA_SOFTWARE);
else if ((argc >= 4) && (!strcmp(argv[3], "x11")))
evas_set_output_method(e, RENDER_METHOD_BASIC_HARDWARE);
else if ((argc >= 4) && (!strcmp(argv[3], "image")))
for (i = 1; i < argc; i++)
{
DATA32 *data;
buffer = imlib_create_image(win_w, win_h);
imlib_context_set_image(buffer);
evas_set_output_method(e, RENDER_METHOD_IMAGE);
evas_set_output_image(e, buffer);
if ((!strcmp(argv[i], "-x")) && (i < (argc - 1)))
{
i++;
win_w = atoi(argv[i]);
}
else if ((!strcmp(argv[i], "-y")) && (i < (argc - 1)))
{
i++;
win_h = atoi(argv[i]);
}
else if ((!strcmp(argv[i], "-m")) && (i < (argc - 1)))
{
i++;
if (!strcmp(argv[i], "x11"))
evas_set_output_method(e, RENDER_METHOD_BASIC_HARDWARE);
else if (!strcmp(argv[i], "soft"))
evas_set_output_method(e, RENDER_METHOD_ALPHA_SOFTWARE);
else if (!strcmp(argv[i], "hard"))
evas_set_output_method(e, RENDER_METHOD_3D_HARDWARE);
else if (!strcmp(argv[i], "buf"))
{
DATA32 *data;
buffer = imlib_create_image(win_w, win_h);
imlib_context_set_image(buffer);
evas_set_output_method(e, RENDER_METHOD_IMAGE);
evas_set_output_image(e, buffer);
}
}
else if ((!strcmp(argv[i], "-c")) && (i < (argc - 1)))
{
i++;
evas_set_output_colors(e, atoi(argv[i]));
}
else if ((!strcmp(argv[i], "-s")) && (i < (argc - 1)))
{
i++;
evas_set_scale_smoothness(e, atoi(argv[i]));
}
else
{
printf("Usage:\n");
printf(" %s [options]\n", argv[0]);
printf("Where options is one or more of:\n");
printf(" -x width - width of window in pixels\n");
printf(" -y height - height of window in pixels\n");
printf(" -m [x11 | soft | hard | buf] - rendering mode\n");
printf(" -c colors - maximum colors allocated\n");
printf(" -s [1 | 0] - smooth scaling / rendering\n");
exit(0);
}
}
else
evas_set_output_method(e, RENDER_METHOD_3D_HARDWARE);
d = XOpenDisplay(NULL);
vis = evas_get_optimal_visual(e, d);
@ -324,7 +357,7 @@ main(int argc, char **argv)
hh = ww;
evas_resize(e, o[i], ww, hh);
evas_set_image_fill(e, o[i], 0, 0, ww, hh);
/*
/*
evas_set_color(e, o[i], 255, 255, 255,
(((1.0 + cos((double)(a + j) * 2 * 3 * 3.141592654 / 1000)) / 2) * 255));
*/