X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Frb_text.c;h=4c90a347966f7e76b40c6cd611999fd6a92d9ea5;hb=HEAD;hp=7488367b5271724b6be2877524ccea7cae3e2376;hpb=d36ce8122174a98523857df52cf7308b09bab38d;p=ruby-evas.git diff --git a/src/rb_text.c b/src/rb_text.c index 7488367..4c90a34 100644 --- a/src/rb_text.c +++ b/src/rb_text.c @@ -1,6 +1,4 @@ /* - * $Id: rb_text.c 368 2006-02-15 18:07:49Z tilman $ - * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * * This library is free software; you can redistribute it and/or @@ -26,9 +24,6 @@ #include "rb_evas.h" #include "rb_evas_object.h" -#define DEF_CONST(mod, prefix, name) \ - rb_define_const ((mod), #name, INT2FIX (prefix##name)); - #define GET_COLOR_METHOD(name) \ int r = 0, g = 0, b = 0, a = 0; \ \ @@ -101,8 +96,6 @@ static VALUE c_font_source_set (VALUE self, VALUE val) { GET_OBJ (self, RbEvasObject, e); - Check_Type (val, T_STRING); - evas_object_text_font_source_set (e->real, StringValuePtr (val)); return Qnil; @@ -119,7 +112,7 @@ static VALUE c_font_source_set (VALUE self, VALUE val) */ static VALUE c_get_font (VALUE self) { - char *font = NULL; + const char *font = NULL; Evas_Font_Size size = 0; GET_OBJ (self, RbEvasObject, e); @@ -142,7 +135,6 @@ static VALUE c_set_font (VALUE self, VALUE font, VALUE size) { GET_OBJ (self, RbEvasObject, e); - Check_Type (font, T_STRING); Check_Type (size, T_FIXNUM); evas_object_text_font_set (e->real, StringValuePtr (font), @@ -179,8 +171,6 @@ static VALUE c_text_set (VALUE self, VALUE val) { GET_OBJ (self, RbEvasObject, e); - Check_Type (val, T_STRING); - evas_object_text_text_set (e->real, StringValuePtr (val)); return Qnil; @@ -341,6 +331,53 @@ static VALUE c_set_outline_color (VALUE self, SET_COLOR_METHOD (outline); } +static VALUE c_ascent_get (VALUE self) +{ + GET_OBJ (self, RbEvasObject, e); + + return INT2FIX ((int) evas_object_text_ascent_get (e->real)); +} + +static VALUE c_descent_get (VALUE self) +{ + GET_OBJ (self, RbEvasObject, e); + + return INT2FIX ((int) evas_object_text_descent_get (e->real)); +} + +static VALUE c_max_ascent_get (VALUE self) +{ + GET_OBJ (self, RbEvasObject, e); + + return INT2FIX ((int) evas_object_text_max_ascent_get (e->real)); +} + +static VALUE c_max_descent_get (VALUE self) +{ + GET_OBJ (self, RbEvasObject, e); + + return INT2FIX ((int) evas_object_text_max_descent_get (e->real)); +} + +static VALUE c_advance_get (VALUE self) +{ + int h = 0, v = 0; + + GET_OBJ (self, RbEvasObject, e); + + h = (int) evas_object_text_horiz_advance_get (e->real); + v = (int) evas_object_text_vert_advance_get (e->real); + + return rb_ary_new3 (2, INT2FIX (h), INT2FIX (v)); +} + +static VALUE c_inset_get (VALUE self) +{ + GET_OBJ (self, RbEvasObject, e); + + return INT2FIX ((int) evas_object_text_inset_get (e->real)); +} + void Init_Text (void) { VALUE c, c2; @@ -366,6 +403,13 @@ void Init_Text (void) rb_define_method (c, "get_outline_color", c_get_outline_color, 0); rb_define_method (c, "set_outline_color", c_set_outline_color, 4); + rb_define_method (c, "ascent", c_ascent_get, 0); + rb_define_method (c, "descent", c_descent_get, 0); + rb_define_method (c, "max_ascent", c_max_ascent_get, 0); + rb_define_method (c, "max_descent", c_max_descent_get, 0); + rb_define_method (c, "advance", c_advance_get, 0); + rb_define_method (c, "inset", c_inset_get, 0); + c2 = rb_define_class_under (mEvas, "Style", c); DEF_CONST (c2, EVAS_TEXT_STYLE_, PLAIN);