diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-02-27 12:35:14 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-02-27 12:35:14 +0100 |
commit | 63df15daae7a3b86478d635128e814149918bb09 (patch) | |
tree | e76fbea0f1b0432ec17c105310d9928e420dfa06 /lib/efl | |
parent | 7603f4c0902bf5845c7e7654c3745f5519347c8b (diff) | |
download | ffi-efl-63df15daae7a3b86478d635128e814149918bb09.zip ffi-efl-63df15daae7a3b86478d635128e814149918bb09.tar.gz |
add elementary,elementary_all,elm/elm_bg,elm/elm_label,elm/elm_object,elm/elm_win
Diffstat (limited to 'lib/efl')
-rw-r--r-- | lib/efl/elementary.rb | 30 | ||||
-rw-r--r-- | lib/efl/elementary_all.rb | 12 | ||||
-rw-r--r-- | lib/efl/elm/elm_bg.rb | 37 | ||||
-rw-r--r-- | lib/efl/elm/elm_label.rb | 22 | ||||
-rw-r--r-- | lib/efl/elm/elm_object.rb | 68 | ||||
-rw-r--r-- | lib/efl/elm/elm_win.rb | 33 |
6 files changed, 202 insertions, 0 deletions
diff --git a/lib/efl/elementary.rb b/lib/efl/elementary.rb new file mode 100644 index 0000000..f1c1ec5 --- /dev/null +++ b/lib/efl/elementary.rb @@ -0,0 +1,30 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/evas' +require 'efl/native/elementary' +# +module Efl + # + module Elm + # + def self.version + Native::VersionStruct.new(Native.elm_version) + end + # + class << self + def init *args + a = args.select { |e| e.is_a? String } + a << __FILE__ if a.length==0 + ptr = FFI::MemoryPointer.new :pointer, a.length + a.each_with_index do |s,i| + ptr[i].write_pointer FFI::MemoryPointer.from_string(s) + end + Native.elm_init a.length, ptr + end + end + # + end +end +# +# EOF diff --git a/lib/efl/elementary_all.rb b/lib/efl/elementary_all.rb new file mode 100644 index 0000000..537e46d --- /dev/null +++ b/lib/efl/elementary_all.rb @@ -0,0 +1,12 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/elementary' +# +require 'efl/elm/elm_object' +# +require 'efl/elm/elm_bg' +require 'efl/elm/elm_label' +require 'efl/elm/elm_win' +# +# EOF diff --git a/lib/efl/elm/elm_bg.rb b/lib/efl/elm/elm_bg.rb new file mode 100644 index 0000000..1eea4ce --- /dev/null +++ b/lib/efl/elm/elm_bg.rb @@ -0,0 +1,37 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/elm/elm_object' +require 'efl/native/elm/elm_bg' +# +module Efl + # + module Elm + # + class ElmBg < ElmObject + # + include Helper + constructor :elm_bg_add + search_prefixes 'elm_bg_' + # + def file_get + f = FFI::MemoryPointer.new :pointer + g = FFI::MemoryPointer.new :pointer + Native.elm_bg_file_get @ptr, f, g + [ f.read_pointer.read_string, g.read_pointer.read_string ] + end + alias :file :file_get + def color_get + r = FFI::MemoryPointer.new :int + g = FFI::MemoryPointer.new :int + b = FFI::MemoryPointer.new :int + Native.elm_bg_color_get @ptr, r, g, b + [ r.read_int, g.read_int, b.read_int ] + end + alias :color :color_get + end + # + end +end +# +# EOF diff --git a/lib/efl/elm/elm_label.rb b/lib/efl/elm/elm_label.rb new file mode 100644 index 0000000..57460c4 --- /dev/null +++ b/lib/efl/elm/elm_label.rb @@ -0,0 +1,22 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/elm/elm_object' +require 'efl/native/elm/elm_label' +# +module Efl + # + module Elm + # + class ElmLabel < ElmObject + # + include Helper + constructor :elm_label_add + search_prefixes 'elm_label_' + # + end + # + end +end +# +# EOF diff --git a/lib/efl/elm/elm_object.rb b/lib/efl/elm/elm_object.rb new file mode 100644 index 0000000..f640da5 --- /dev/null +++ b/lib/efl/elm/elm_object.rb @@ -0,0 +1,68 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/elementary' +require 'efl/native/elm/elm_object' +# +module Efl + # + module Elm + # + module Helper + def self.included kls + def kls.constructor meth + self.class_eval <<-EOF + def initialize ptr, &block + if ptr.is_a? FFI::Pointer + super ptr, &block + else + super Native.method(:#{meth}), ptr, &block + end + end + EOF + end + end + end + # + class ElmObject < Efl::Evas::REvasObject + # + search_prefixes 'elm_object_' + # + def smart_callback_add event_str, cb, data=FFI::MemoryPointer::NULL + Native.evas_object_smart_callback_add @ptr, event_str, cb, data + end + # + def text_set label + Native.elm_object_part_text_set @ptr, nil, label + end + alias :text= :text_set + # + def text_get + Native.elm_object_part_text_get @ptr, nil + end + alias :text :text_get + # + def content_set content + Native.elm_object_part_content_set @ptr, nil, content + end + alias :content= :content_set + # + def content_get + Native.elm_object_part_content_get @ptr, nil + end + alias :content :content_get + # + def content_unset + Native.elm_object_part_content_unset @ptr, nil + end + # + def parent_widget_get + ElmObject.new Native.elm_object_parent_widget_get @ptr + end + alias :parent_widget :parent_widget_get + end + # + end +end +# +# EOF diff --git a/lib/efl/elm/elm_win.rb b/lib/efl/elm/elm_win.rb new file mode 100644 index 0000000..daac677 --- /dev/null +++ b/lib/efl/elm/elm_win.rb @@ -0,0 +1,33 @@ +#! /usr/bin/env ruby +# -*- coding: UTF-8 -*- +# +require 'efl/elm/elm_object' +require 'efl/native/elm/elm_win' +# +module Efl + # + module Elm + # + class ElmWin < ElmObject + # + search_prefixes 'elm_win_' + # + def initialize parent, title, type=:elm_win_basic, &block + super Native.method(:elm_win_add), parent, title, type, &block + end +# def inwin_add +# ElmInWin.new @ptr +# end + def screen_position_get + x = FFI::MemoryPointer.new :int + y = FFI::MemoryPointer.new :int + Native.elm_win_screen_position_get @ptr, x, y + [ x.read_int, y.read_int ] + end + alias :screen_position :screen_position_get + end + # + end +end +# +# EOF |