summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Hanne <marius.hanne@sourceagency.org>2013-02-18 15:43:24 +0100
committerMarius Hanne <marius.hanne@sourceagency.org>2013-02-18 15:47:14 +0100
commit14030eb7e06e6b4acd8ada00291dbf196b31234c (patch)
treec047cdd3c42d39dec594c31c2f40f596838bc842
parentf72de68ba9365398cf17c07594ce0ef666ab5992 (diff)
downloadffi-efl-14030eb7e06e6b4acd8ada00291dbf196b31234c.zip
ffi-efl-14030eb7e06e6b4acd8ada00291dbf196b31234c.tar.gz
examples for ElmButton
-rw-r--r--test/test_button-native.rb39
-rw-r--r--test/test_button.rb40
2 files changed, 79 insertions, 0 deletions
diff --git a/test/test_button-native.rb b/test/test_button-native.rb
new file mode 100644
index 0000000..5a805b2
--- /dev/null
+++ b/test/test_button-native.rb
@@ -0,0 +1,39 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/native/elm/elm_win'
+require 'efl/native/elm/elm_bg'
+require 'efl/native/elm/elm_button'
+require 'efl/native/elm/elm_object'
+#
+include Efl::Native
+#
+elm_init 0, FFI::MemoryPointer::NULL
+#
+def on_click data, object, event
+ elm_exit
+end
+#
+win = elm_win_add(nil, "Greetings", 0)
+elm_win_title_set(win, "Hello, World!")
+elm_win_autodel_set(win, true)
+elm_policy_set(0, 1)
+evas_object_resize(win, 240, 60)
+evas_object_show(win)
+#
+bg = elm_bg_add(win)
+evas_object_size_hint_weight_set(bg, 1.0, 1.0)
+elm_win_resize_object_add(win, bg)
+evas_object_show(bg)
+#
+btn = elm_button_add(win)
+elm_object_part_text_set(btn, nil, "Good-Bye, World!")
+evas_object_smart_callback_add(btn, "clicked", method(:on_click), nil)
+evas_object_resize(btn, 120, 30)
+evas_object_move(btn, 60, 15)
+evas_object_show(btn)
+#
+elm_run
+elm_shutdown
+#
+# EOF
diff --git a/test/test_button.rb b/test/test_button.rb
new file mode 100644
index 0000000..93168d3
--- /dev/null
+++ b/test/test_button.rb
@@ -0,0 +1,40 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+require 'efl/elm/elm_win'
+require 'efl/elm/elm_bg'
+require 'efl/elm/elm_button'
+#
+include Efl
+#
+class MyWin < Elm::ElmWin
+ #
+ def initialize
+ super(nil, "Greetings") do
+ title_set "Hello, World!"
+ resize 240, 60
+ show
+ end
+ @bg = Elm::ElmBg.new(self) do
+ size_hint_weight_expand
+ show
+ end
+ resize_object_add @bg
+ @btn = Elm::ElmButton.new(self) do
+ part_text_set(nil, "Good-Bye, World!")
+ smart_callback_add("clicked", ->(*_) { Elm.exit }, nil)
+ resize 120, 30
+ move 60, 15
+ show
+ end
+ end
+end
+#
+Elm.init
+#
+MyWin.new
+#
+Elm.run
+Elm.shutdown
+#
+# EOF