summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2014-07-16 17:34:22 -0300
committerSavio Sena <savio@expertisesolutions.com.br>2014-07-21 20:53:12 -0300
commitcfd259d3bb86eb2aadb19455fac240289d96c27a (patch)
treecb6087e8abee6aee9fc7ca02d147c2ed69755997
parenta1f0348e68a683408e8d36067bc717006bb21eb7 (diff)
Added simple, initial, C++ example
-rw-r--r--src/examples/Makefile.am14
-rw-r--r--src/examples/box_cxx_example_02.cc204
2 files changed, 218 insertions, 0 deletions
diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am
index 52046657c..508834137 100644
--- a/src/examples/Makefile.am
+++ b/src/examples/Makefile.am
@@ -38,6 +38,7 @@ bg_example_01.c \
38bg_example_02.c \ 38bg_example_02.c \
39bg_example_03.c \ 39bg_example_03.c \
40box_example_02.c \ 40box_example_02.c \
41box_cxx_example_02.cc \
41bubble_example_01.c \ 42bubble_example_01.c \
42button_example_00.c \ 43button_example_00.c \
43button_example_01.c \ 44button_example_01.c \
@@ -188,6 +189,7 @@ bg_example_01 \
188bg_example_02 \ 189bg_example_02 \
189bg_example_03 \ 190bg_example_03 \
190box_example_02 \ 191box_example_02 \
192box_cxx_example_02 \
191bubble_example_01 \ 193bubble_example_01 \
192button_example_00 \ 194button_example_00 \
193button_example_01 \ 195button_example_01 \
@@ -300,6 +302,17 @@ efl_thread_3_SOURCES = efl_thread_3.c
300efl_thread_4_SOURCES = efl_thread_4.c 302efl_thread_4_SOURCES = efl_thread_4.c
301endif 303endif
302 304
305box_cxx_example_02_SOURCES = box_cxx_example_02.cc
306box_cxx_example_02_CXXFLAGS = -fPIC \
307@ELEMENTARY_ELOCATION_CFLAGS@ \
308@ELEMENTARY_EWEATHER_CFLAGS@ \
309@ELEMENTARY_EMAP_CFLAGS@ \
310@ELEMENTARY_X_CFLAGS@ \
311@ELEMENTARY_CFLAGS@ \
312@ELEMENTARY_CXX_CFLAGS@
313
314box_cxx_example_02_LDFLAGS = -fPIC
315
303# This variable will hold the list of screenshots that will be made 316# This variable will hold the list of screenshots that will be made
304# by "make screenshots". Each item in the list is of the form: 317# by "make screenshots". Each item in the list is of the form:
305# <example executable>:<screenshot filename>:<delay in seconds> 318# <example executable>:<screenshot filename>:<delay in seconds>
@@ -307,6 +320,7 @@ SCREENSHOTS = \
307actionslider_example_01:actionslider_01.png:0.0 \ 320actionslider_example_01:actionslider_01.png:0.0 \
308bg_example_02:bg_01.png:0.0 \ 321bg_example_02:bg_01.png:0.0 \
309box_example_02:box_example_02.png:1.3 \ 322box_example_02:box_example_02.png:1.3 \
323box_cxx_example_02:box_cxx_example_02.png:1.3 \
310bubble_example_01:bubble_example_01.png:0.0 \ 324bubble_example_01:bubble_example_01.png:0.0 \
311button_example_00:button_00.png:0.0 \ 325button_example_00:button_00.png:0.0 \
312button_example_01:button_01.png:0.0 \ 326button_example_01:button_01.png:0.0 \
diff --git a/src/examples/box_cxx_example_02.cc b/src/examples/box_cxx_example_02.cc
new file mode 100644
index 000000000..3842ceb80
--- /dev/null
+++ b/src/examples/box_cxx_example_02.cc
@@ -0,0 +1,204 @@
1//Compile with:
2//gcc -g box_example_02.c -o box_example_02 `pkg-config --cflags --libs elementary`
3
4#ifdef HAVE_CONFIG_H
5# include <elementary_config.h>
6#endif
7
8#define ELM_INTERNAL_API_ARGESFSDFEFC
9#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
10#define ELM_INTERFACE_ATSPI_COMPONENT_PROTECTED
11#define ELM_INTERFACE_ATSPI_ACTION_PROTECTED
12#define ELM_INTERFACE_ATSPI_VALUE_PROTECTED
13#define ELM_INTERFACE_ATSPI_EDITABLE_TEXT_PROTECTED
14#define ELM_INTERFACE_ATSPI_TEXT_PROTECTED
15#define ELM_INTERFACE_ATSPI_SELECTION_PROTECTED
16#define ELM_INTERFACE_ATSPI_IMAGE_PROTECTED
17#define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
18
19#include <Elementary.h>
20
21#include <Eo.h>
22#include <Evas.h>
23#include <Elementary.h>
24#include <elm_widget.h>
25#include <elm_interface_atspi_accessible.h>
26
27#include <elm_win.eo.hh>
28#include <elm_box.eo.hh>
29#include <elm_button.eo.hh>
30
31typedef struct
32{
33 Eina_List *transitions;
34 Evas_Object *box;
35 Evas_Object_Box_Layout last_layout;
36} Transitions_Data;
37
38static void
39_add_cb(void *data, Evas_Object *obj, void *ev)
40{
41 Evas_Object *btn;
42 Eina_List *children;
43 Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
44
45 btn = elm_button_add(tdata->box);
46 elm_object_text_set(btn, "I do nothing");
47 children = (Eina_List *)elm_box_children_get(tdata->box);
48 if (children)
49 {
50 elm_box_pack_after(tdata->box, btn, (Evas_Object *)children->data);
51 eina_list_free(children);
52 }
53 else
54 elm_box_pack_end(tdata->box, btn);
55 evas_object_show(btn);
56}
57
58static void
59_clear_cb(void *data, Evas_Object *obj, void *ev)
60{
61 Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
62 elm_box_clear(tdata->box);
63}
64
65static void
66_unpack_cb(void *data, Evas_Object *obj, void *ev)
67{
68 Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
69 elm_box_unpack(tdata->box, obj);
70 evas_object_move(obj, 0, 50);
71 evas_object_color_set(obj, 128, 64, 0, 128);
72}
73
74static void
75_test_box_transition_change(void *data)
76{
77 Transitions_Data *tdata = static_cast<Transitions_Data*>(data);
78 Elm_Box_Transition *layout_data;
79 Evas_Object_Box_Layout next_layout;
80
81 if (!data) return;
82 next_layout = reinterpret_cast<Evas_Object_Box_Layout>(eina_list_data_get(tdata->transitions));
83 layout_data = elm_box_transition_new(2.0, tdata->last_layout,
84 NULL, NULL, next_layout, NULL, NULL,
85 _test_box_transition_change, tdata);
86 elm_box_layout_set(tdata->box, elm_box_layout_transition, layout_data,
87 elm_box_transition_free);
88 tdata->last_layout = next_layout;
89
90 tdata->transitions = eina_list_demote_list(tdata->transitions,
91 tdata->transitions);
92}
93
94EAPI_MAIN int
95elm_main(int argc, char *argv[])
96{
97 static Transitions_Data tdata = {
98 .transitions = NULL,
99 .box = NULL,
100 .last_layout = NULL
101 };
102
103 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
104
105 {
106 ::elm_win win ( ::eo_ref( elm_win_util_standard_add("box-transition", "Box Transition") ));
107 elm_win_autodel_set(win._eo_ptr(), EINA_TRUE);
108
109 elm_box bigbox ( ::eo_ref( elm_box_add(win._eo_ptr()) ));
110 bigbox.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
111 win.resize_object_add(bigbox._eo_ptr());
112 bigbox.visibility_set(true);
113
114 {
115 elm_box bx ( ::eo_ref( elm_box_add(win._eo_ptr()) ));
116 bx.horizontal_set(EINA_TRUE);
117 bigbox.pack_end(bx._eo_ptr());
118 bx.visibility_set(true);
119
120 {
121 elm_button bt ( ::eo_ref(elm_button_add(win._eo_ptr()) ));
122 bt.text_set("Add");
123 bx.pack_end(bt._eo_ptr());
124 bt.visibility_set(true);
125 evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _add_cb, &tdata);
126 }
127
128 {
129 elm_button bt ( ::eo_ref(elm_button_add(win._eo_ptr())));
130 bt.text_set("Clear");
131 bx.pack_end(bt._eo_ptr());
132 bt.visibility_set(true);
133 evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _clear_cb, &tdata);
134 }
135 }
136
137 {
138 elm_box bx ( ::eo_ref( elm_box_add(win._eo_ptr())));
139 bx.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
140 bx.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
141 bigbox.pack_end(bx._eo_ptr());
142 bx.visibility_set(true);
143
144 {
145 elm_button bt ( ::eo_ref( elm_button_add(win._eo_ptr()) ));
146 bt.text_set("Button 1");
147 evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _unpack_cb, &tdata);
148 bt.size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
149 bt.size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL);
150 bx.pack_end(bt._eo_ptr());
151 bt.visibility_set(true);
152 }
153
154 {
155 elm_button bt ( ::eo_ref( elm_button_add(win._eo_ptr()) ));
156 bt.text_set("Button 2");
157 bt.size_hint_weight_set(EVAS_HINT_EXPAND, 0.0);
158 bt.size_hint_align_set(1.0, 0.5);
159 evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _unpack_cb, &tdata);
160 bx.pack_end(bt._eo_ptr());
161 bt.visibility_set(true);
162 }
163
164 {
165 elm_button bt ( ::eo_ref(elm_button_add(win._eo_ptr())));
166 bt.text_set("Button 3");
167 evas_object_smart_callback_add(bt._eo_ptr(), "clicked", _unpack_cb, &tdata);
168 bx.pack_end(bt._eo_ptr());
169 bt.visibility_set(true);
170 }
171
172 tdata.box = bx._eo_ptr();
173 tdata.last_layout = evas_object_box_layout_horizontal;
174 tdata.transitions =
175 (eina_list_append(tdata.transitions, (void*)evas_object_box_layout_vertical));
176 tdata.transitions =
177 (eina_list_append(tdata.transitions, (void*)evas_object_box_layout_horizontal));
178 tdata.transitions =
179 (eina_list_append(tdata.transitions, (void*)evas_object_box_layout_stack));
180 tdata.transitions =
181 (eina_list_append(tdata.transitions, (void*)evas_object_box_layout_homogeneous_vertical));
182 tdata.transitions =
183 (eina_list_append(tdata.transitions, (void*)evas_object_box_layout_homogeneous_horizontal));
184 tdata.transitions =
185 (eina_list_append(tdata.transitions, (void*)evas_object_box_layout_flow_vertical));
186 tdata.transitions =
187 (eina_list_append(tdata.transitions, (void*)evas_object_box_layout_flow_horizontal));
188 tdata.transitions =
189 (eina_list_append(tdata.transitions, (void*)evas_object_box_layout_stack));
190
191 bx.layout_set(evas_object_box_layout_horizontal, NULL, NULL);
192 _test_box_transition_change(&tdata);
193 }
194
195 win.size_set(300, 320);
196 win.visibility_set(true);
197 }
198
199 elm_run();
200 elm_shutdown();
201
202 return 0;
203}
204ELM_MAIN()