summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-05-06 11:17:02 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-05-06 11:17:02 +0200
commit86c7bb0aa79ddea6fd26c4525af0fbf212658d1b (patch)
tree340b5e3267e971b85e4c67e09ecf48b951833dee
parente70f8fdfbb74919d38392123b26a764db3561192 (diff)
downloadffi-efl-86c7bb0aa79ddea6fd26c4525af0fbf212658d1b.zip
ffi-efl-86c7bb0aa79ddea6fd26c4525af0fbf212658d1b.tar.gz
Efl::Evas::REvasText and specs
-rw-r--r--lib/efl/evas.rb70
-rw-r--r--spec/evas_spec.rb143
2 files changed, 182 insertions, 31 deletions
diff --git a/lib/efl/evas.rb b/lib/efl/evas.rb
index 942fc4e..3614784 100644
--- a/lib/efl/evas.rb
+++ b/lib/efl/evas.rb
@@ -280,6 +280,76 @@ module Efl
#
search_prefixes 'evas_object_text_'
#
+ def font_get
+ f = FFI::MemoryPointer.new :string
+ s = FFI::MemoryPointer.new :int
+ Native.evas_object_text_font_get @ptr, f, s
+ [ f.read_pointer.read_string, s.read_int ]
+ end
+ alias :font :font_get
+ def char_pos_get pos
+ cx = FFI::MemoryPointer.new :int
+ cy = FFI::MemoryPointer.new :int
+ cw = FFI::MemoryPointer.new :int
+ ch = FFI::MemoryPointer.new :int
+ Native.evas_object_text_char_pos_get @ptr, pos, cx, cy, cw, ch
+ return [ cx.read_int, cy.read_int, cw.read_int, ch.read_int ]
+ end
+ alias :char_pos :char_pos_get
+ def char_coords_get x, y
+ cx = FFI::MemoryPointer.new :int
+ cy = FFI::MemoryPointer.new :int
+ cw = FFI::MemoryPointer.new :int
+ ch = FFI::MemoryPointer.new :int
+ r = Native.evas_object_text_char_coords_get @ptr, x, y, cx, cy, cw, ch
+ return [ r, cx.read_int, cy.read_int, cw.read_int, ch.read_int ]
+ end
+ alias :char_coords :char_coords_get
+ def style_pad_get
+ l = FFI::MemoryPointer.new :int
+ r = FFI::MemoryPointer.new :int
+ t = FFI::MemoryPointer.new :int
+ b = FFI::MemoryPointer.new :int
+ Native.evas_object_text_shadow_color_get @ptr, l, r, t, b
+ return [ l.read_int, r.read_int, t.read_int, b.read_int ]
+ end
+ alias :style_pad :style_pad_get
+ def shadow_color_get
+ r = FFI::MemoryPointer.new :int
+ g = FFI::MemoryPointer.new :int
+ b = FFI::MemoryPointer.new :int
+ a = FFI::MemoryPointer.new :int
+ Native.evas_object_text_shadow_color_get @ptr, r, g, b, a
+ return [ r.read_int, g.read_int, b.read_int, a.read_int ]
+ end
+ alias :shadow_color :shadow_color_get
+ def glow_color_get
+ r = FFI::MemoryPointer.new :int
+ g = FFI::MemoryPointer.new :int
+ b = FFI::MemoryPointer.new :int
+ a = FFI::MemoryPointer.new :int
+ Native.evas_object_text_glow_color_get @ptr, r, g, b, a
+ return [ r.read_int, g.read_int, b.read_int, a.read_int ]
+ end
+ alias :glow_color :glow_color_get
+ def glow2_color_get
+ r = FFI::MemoryPointer.new :int
+ g = FFI::MemoryPointer.new :int
+ b = FFI::MemoryPointer.new :int
+ a = FFI::MemoryPointer.new :int
+ Native.evas_object_text_glow2_color_get @ptr, r, g, b, a
+ return [ r.read_int, g.read_int, b.read_int, a.read_int ]
+ end
+ alias :glow2_color :glow2_color_get
+ def outline_color_get
+ r = FFI::MemoryPointer.new :int
+ g = FFI::MemoryPointer.new :int
+ b = FFI::MemoryPointer.new :int
+ a = FFI::MemoryPointer.new :int
+ Native.evas_object_text_outline_color_get @ptr, r, g, b, a
+ return [ r.read_int, g.read_int, b.read_int, a.read_int ]
+ end
+ alias :outline_color :outline_color_get
end
end
end
diff --git a/spec/evas_spec.rb b/spec/evas_spec.rb
index c8845ba..f490d95 100644
--- a/spec/evas_spec.rb
+++ b/spec/evas_spec.rb
@@ -568,6 +568,7 @@ describe Efl::Evas do
@l = @e.object_line_add
end
after(:all) do
+ @l.free
@e.free
Evas.shutdown
end
@@ -585,6 +586,7 @@ describe Efl::Evas do
@p = @e.object_polygon_add
end
after(:all) do
+ @p.free
@e.free
Evas.shutdown
end
@@ -600,6 +602,116 @@ describe Efl::Evas do
end
end
#
+ describe Efl::Evas::REvasText do
+ #
+ before(:all) do
+ Evas.init
+ realize_evas
+ @t = @e.object_text_add
+ end
+ after(:all) do
+ @t.free
+ @e.free
+ Evas.shutdown
+ end
+ #
+ it "font_source get/set should work" do
+ @t.font_source_set "myFont"
+ @t.font_source_get.should == "myFont"
+ @t.font_source = "myFont2"
+ @t.font_source.should == "myFont2"
+ end
+ #
+ it "font get/set should work" do
+ @t.font_set "Arial", 12
+ @t.font_get.should == ["Arial",12]
+ @t.font = "Ariall", 16
+ @t.font_get.should == ["Ariall",16]
+ end
+ #
+ it "text set/get should work" do
+ @t.text_set "hello"
+ @t.text_get.should == "hello"
+ @t.text="hello world"
+ @t.text.should == "hello world"
+ end
+ #
+ it "test different accessors" do
+ @t.ascent_get.should > 0
+ @t.descent_get.should > 0
+ @t.max_ascent_get.should > 0
+ @t.max_descent_get.should > 0
+ @t.horiz_advance_get.should > 0
+ @t.vert_advance_get.should > 0
+ @t.inset_get.should > 0
+ @t.direction_get.should == :evas_bidi_direction_ltr
+ @t.style_pad_get.length.should == 4
+ @t.ascent.should > 0
+ @t.descent.should > 0
+ @t.max_ascent.should > 0
+ @t.max_descent.should > 0
+ @t.horiz_advance.should > 0
+ @t.vert_advance.should > 0
+ @t.inset.should > 0
+ @t.direction.should == :evas_bidi_direction_ltr
+ @t.style_pad.length.should == 4
+ end
+ #
+ it "bidi_delimiters set/get should work" do
+ @t.bidi_delimiters_set "@"
+ @t.bidi_delimiters_get.should == "@"
+ @t.bidi_delimiters= "#"
+ @t.bidi_delimiters.should == "#"
+ end
+ #
+ it "char_pos_get char_coords_get last_up_to_pos should work" do
+ @t.text="hello world"
+ coords = @t.char_pos_get 6
+ @t.char_coords(coords[0], coords[1])[0].should == 6
+ @t.char_coords_get(coords[0], coords[1])[0].should == 6
+ coords = @t.char_pos_get 3
+ @t.char_coords(coords[0], coords[1])[0].should == 3
+ @t.char_coords_get(coords[0], coords[1])[0].should == 3
+ @t.last_up_to_pos(coords[0], coords[1]).should == 3
+ end
+ #
+ it "style ste/get should work" do
+ @t.style_set :evas_text_style_shadow
+ @t.style_get.should == :evas_text_style_shadow
+ @t.style= :evas_text_style_outline
+ @t.style.should == :evas_text_style_outline
+ end
+ #
+ it "shadow_color set/get should work" do
+ @t.shadow_color_set 100, 150, 200, 50
+ @t.shadow_color_get.should == [100, 150, 200, 50]
+ @t.shadow_color = 100, 150, 200, 50
+ @t.shadow_color.should == [100, 150, 200, 50]
+ end
+ #
+ it "glow_color set/get should work" do
+ @t.glow_color_set 100, 150, 200, 50
+ @t.glow_color_get.should == [100, 150, 200, 50]
+ @t.glow_color = 100, 150, 200, 50
+ @t.glow_color.should == [100, 150, 200, 50]
+ end
+ #
+ it "glow2_color set/get should work" do
+ @t.glow2_color_set 100, 150, 200, 50
+ @t.glow2_color_get.should == [100, 150, 200, 50]
+ @t.glow2_color = 100, 150, 200, 50
+ @t.glow2_color.should == [100, 150, 200, 50]
+ end
+ #
+ it "outline_color set/get should work" do
+ @t.outline_color_set 100, 150, 200, 50
+ @t.outline_color_get.should == [100, 150, 200, 50]
+ @t.outline_color = 100, 150, 200, 50
+ @t.outline_color.should == [100, 150, 200, 50]
+ end
+ #
+ end
+ #
# EAPI Evas_Object *evas_object_image_filled_add (Evas *e);
# EAPI void evas_object_image_memfile_set (Evas_Object *obj, void *data, int size, char *format, char *key);
# EAPI void evas_object_image_file_set (Evas_Object *obj, const char *file, const char *key);
@@ -656,37 +768,6 @@ describe Efl::Evas do
# EAPI Eina_Bool evas_object_image_source_set (Evas_Object *obj, Evas_Object *src);
# EAPI Evas_Object *evas_object_image_source_get (Evas_Object *obj);
# EAPI Eina_Bool evas_object_image_source_unset (Evas_Object *obj);
- # EAPI Evas_Object *evas_object_text_add (Evas *e);
- # EAPI void evas_object_text_font_source_set (Evas_Object *obj, const char *font);
- # EAPI const char *evas_object_text_font_source_get (const Evas_Object *obj);
- # EAPI void evas_object_text_font_set (Evas_Object *obj, const char *font, Evas_Font_Size size);
- # EAPI void evas_object_text_font_get (const Evas_Object *obj, const char **font, Evas_Font_Size *size);
- # EAPI void evas_object_text_text_set (Evas_Object *obj, const char *text);
- # EAPI void evas_object_text_bidi_delimiters_set(Evas_Object *obj, const char *delim);
- # EAPI const char *evas_object_text_bidi_delimiters_get(const Evas_Object *obj);
- # EAPI const char *evas_object_text_text_get (const Evas_Object *obj);
- # EAPI Evas_Coord evas_object_text_ascent_get (const Evas_Object *obj);
- # EAPI Evas_Coord evas_object_text_descent_get (const Evas_Object *obj);
- # EAPI Evas_Coord evas_object_text_max_ascent_get (const Evas_Object *obj);
- # EAPI Evas_Coord evas_object_text_max_descent_get (const Evas_Object *obj);
- # EAPI Evas_Coord evas_object_text_horiz_advance_get(const Evas_Object *obj);
- # EAPI Evas_Coord evas_object_text_vert_advance_get (const Evas_Object *obj);
- # EAPI Evas_Coord evas_object_text_inset_get (const Evas_Object *obj);
- # EAPI Eina_Bool evas_object_text_char_pos_get (const Evas_Object *obj, int pos, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch);
- # EAPI int evas_object_text_char_coords_get (const Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch);
- # EAPI int evas_object_text_last_up_to_pos (const Evas_Object *obj, Evas_Coord x, Evas_Coord y);
- # EAPI Evas_Text_Style_Type evas_object_text_style_get (const Evas_Object *obj);
- # EAPI void evas_object_text_style_set (Evas_Object *obj, Evas_Text_Style_Type type);
- # EAPI void evas_object_text_shadow_color_set (Evas_Object *obj, int r, int g, int b, int a);
- # EAPI void evas_object_text_shadow_color_get (const Evas_Object *obj, int *r, int *g, int *b, int *a);
- # EAPI void evas_object_text_glow_color_set (Evas_Object *obj, int r, int g, int b, int a);
- # EAPI void evas_object_text_glow_color_get (const Evas_Object *obj, int *r, int *g, int *b, int *a);
- # EAPI void evas_object_text_glow2_color_set (Evas_Object *obj, int r, int g, int b, int a);
- # EAPI void evas_object_text_glow2_color_get (const Evas_Object *obj, int *r, int *g, int *b, int *a);
- # EAPI void evas_object_text_outline_color_set(Evas_Object *obj, int r, int g, int b, int a);
- # EAPI void evas_object_text_outline_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a);
- # EAPI void evas_object_text_style_pad_get (const Evas_Object *obj, int *l, int *r, int *t, int *b);
- # EAPI Evas_BiDi_Direction evas_object_text_direction_get (const Evas_Object *obj);
# EAPI Evas_Object *evas_object_textblock_add(Evas *e);
# EAPI const char *evas_textblock_escape_string_get(const char *escape);
# EAPI const char *evas_textblock_string_escape_get(const char *string, int *len_ret);