summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-02-18 11:29:11 +0000
committerTom Hacohen <tom@stosb.com>2013-02-18 11:29:11 +0000
commit57c18ab8d76e8bee92c05c7b5dc3e4b701115a9a (patch)
treeda6aa93cb957178236d78492fe4178ffba98d93f
Initial commit.
-rw-r--r--.gitignore5
-rw-r--r--AUTHORS1
-rw-r--r--CMakeLists.txt50
-rw-r--r--README7
-rw-r--r--cmake/Modules/MakeDistcheck.cmake122
-rw-r--r--cmakeconfig.h.in8
-rw-r--r--src/bin/CMakeLists.txt21
-rw-r--r--src/bin/solve_calc.c95
-rw-r--r--src/bin/solve_calc.h9
-rw-r--r--src/bin/solve_main.c305
10 files changed, 623 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9074f44
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
1*.swp
2tags
3*~
4Session.vim
5/build
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..ee22837
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
Tom Hacohen <tom@stosb.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..c060b36
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,50 @@
1cmake_minimum_required(VERSION 2.6)
2project(solve)
3set(VMAJ 0)
4set(VMIN 1)
5set(VMIC 0)
6set(PACKAGE_VERSION ${VMAJ}.${VMIN}.${VMIC})
7
8set(PACKAGE ${CMAKE_PROJECT_NAME})
9set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
10
11include_directories ("${PROJECT_BINARY_DIR}")
12
13find_package(Eina REQUIRED)
14find_package(Ecore REQUIRED)
15find_package(Evas REQUIRED)
16find_package(Elementary REQUIRED)
17
18ADD_DEFINITIONS(-DPACKAGE_BIN_DIR="${CMAKE_INSTALL_PREFIX}/bin"
19 -DPACKAGE_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/${CMAKE_PROJECT_NAME}"
20 -DPACKAGE_LIB_DIR="${CMAKE_INSTALL_PREFIX}/lib")
21
22set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/locale")
23
24ADD_DEFINITIONS(
25 -DLOCALE_DIR="${LOCALEDIR}"
26 )
27
28ADD_DEFINITIONS(-DHAVE_CONFIG_H)
29
30configure_file (
31 "${PROJECT_SOURCE_DIR}/cmakeconfig.h.in"
32 "${PROJECT_BINARY_DIR}/config.h"
33 )
34
35add_subdirectory(src/bin)
36
37# Make dist
38set(CPACK_PACKAGE_VERSION_MAJOR ${VMAJ})
39set(CPACK_PACKAGE_VERSION_MINOR ${VMIN})
40set(CPACK_PACKAGE_VERSION_PATCH ${VMIC})
41set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2")
42set(CPACK_SOURCE_PACKAGE_FILE_NAME
43 "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
44set(CPACK_SOURCE_IGNORE_FILES
45 "${CMAKE_BINARY_DIR};/.git/;.svn/;.swp$;~$;${CPACK_SOURCE_IGNORE_FILES}")
46include(CPack)
47add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
48
49include(MakeDistcheck)
50add_distcheck()
diff --git a/README b/README
new file mode 100644
index 0000000..0bbd802
--- /dev/null
+++ b/README
@@ -0,0 +1,7 @@
1This is a quickly hacked together PoC of Bret Victor's Scrubbing Calculator (http://worrydream.com/ScrubbingCalculator/).
2
3I wrote it so people will have an example no how to interact with anchors. It's incomplete and mostly hackish, that will either improve or not in the future.
4
5Use CMAKE_PREFIX_PATH=/EFL-PREFIX/share/cmake/Modules if you installed the EFL in a non-standard path.<F2>
6
7Written by Tom Hacohen <tom@stosb.com>.
diff --git a/cmake/Modules/MakeDistcheck.cmake b/cmake/Modules/MakeDistcheck.cmake
new file mode 100644
index 0000000..1f383a5
--- /dev/null
+++ b/cmake/Modules/MakeDistcheck.cmake
@@ -0,0 +1,122 @@
1# - adds support for the 'make distcheck' command -*- cmake -*-
2# Dependencies:
3# 1. CPack generating ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz.
4# 2. Having a "dist" target, e.g:
5# add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
6# Usage:
7# add_distcheck() ... called exactly once per project in the top-level
8# CMakeLists.txt; it adds the 'dist' and 'distcheck'
9# targets
10#
11# This module implements the 'make dist' and 'make distcheck'
12# commands.
13# It supports the following variables:
14#
15# DISTCHECK_TMPDIR ... directory for temporary files
16# DISTCHECK_FILENAME ... basename of existing tar.gz.; defaults to
17# ${CPACK_SOURCE_PACKAGE_FILE_NAME}
18# DISTCHECK_CMAKEFLAGS
19# ... flags which are given to 'cmake' by 'make distcheck'
20# DISTCHECK_BUILDTARGETS
21# ... the build-targets tried by 'make distcheck';
22# defaults to nothing (--> all)
23# DISTCHECK_INSTALLTARGETS
24# ... the install-targets tried by 'make distcheck';
25# defaults to 'install'
26#
27# Example:
28# --- top-level CMakeLists.txt ---
29# add_subdirectory(foo)
30# ...
31# ...
32# set(CPACK_PACKAGE_VERSION_MAJOR ${ECRIRE_VERSION_MAJOR})
33# set(CPACK_PACKAGE_VERSION_MINOR ${ECRIRE_VERSION_MINOR})
34# set(CPACK_PACKAGE_VERSION_PATCH ${ECRIRE_VERSION_MICRO})
35# set(CPACK_SOURCE_GENERATOR "TGZ")
36# set(CPACK_SOURCE_IGNORE_FILES
37# "${CMAKE_BINARY_DIR};/.git/;~$;${CPACK_SOURCE_IGNORE_FILES}")
38# include(CPack)
39# add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
40#
41# find_package(Distcheck)
42# add_distcheck()
43#
44#
45# Copyright (C) 2012 Tom Hacohen <tom@stosb.com>
46# Based on the work done by:
47# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
48#
49# Redistribution and use, with or without modification, are permitted
50# provided that the following conditions are met:
51#
52# 1. Redistributions must retain the above copyright notice, this
53# list of conditions and the following disclaimer.
54# 2. The name of the author may not be used to endorse or promote
55# products derived from this software without specific prior
56# written permission.
57#
58# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
59# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
60# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
62# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
64# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
65# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
66# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
67# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
68# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69
70macro(add_distcheck)
71 set(MakeDist_FOUND 1)
72
73 set(DISTCHECK_TMPDIR "${CMAKE_BINARY_DIR}/.make-dist" CACHE PATH "directory for temporary files created by'make dist*'")
74 set(DISTCHECK_FILENAME ${CPACK_SOURCE_PACKAGE_FILE_NAME} CACHE PATH "basename of the tarball created by 'make dist'")
75 set(DISTCHECK_CMAKEFLAGS CACHE STRING "flags which are given to 'cmake' by 'make distcheck'")
76 set(DISTCHECK_BUILDTARGETS "" CACHE STRING "build-target(s) tried by 'make distcheck'")
77 set(DISTCHECK_INSTALLTARGETS install CACHE STRING "install-target(s) tried by 'make distcheck'")
78
79 mark_as_advanced(DISTCHECK_TMPDIR DISTCHECK_FILENAME DISTCHECK_CMAKEFLAGS DISTCHECK_BUILDTARGETS DISTCHECK_INSTALLTARGETS)
80
81 set(DISTCHECK_BASESOURCEDIR "${DISTCHECK_TMPDIR}/source")
82 set(DISTCHECK_SOURCEDIR "${DISTCHECK_BASESOURCEDIR}/${DISTCHECK_FILENAME}")
83 set(DISTCHECK_BUILDDIR "${DISTCHECK_TMPDIR}/build")
84 set(DISTCHECK_INSTALLTARGETS "install")
85 add_custom_target(distcheck
86 # Create the tarball
87 COMMAND ${CMAKE_MAKE_PROGRAM} dist
88
89 # Create the temp dir.
90 COMMAND chmod -Rf a+w "${DISTCHECK_TMPDIR}" 2>/dev/null || :
91 COMMAND rm -rf "${DISTCHECK_TMPDIR}"
92 COMMAND mkdir -p "${DISTCHECK_SOURCEDIR}" "${DISTCHECK_BUILDDIR}"
93
94 # extract tarball
95 COMMAND tar xzf ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz -C "${DISTCHECK_BASESOURCEDIR}"
96 # write-protect sources to detect modifies-sourcetree bugs
97 COMMAND chmod -R a-w "${DISTCHECK_SOURCEDIR}"
98
99 COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH="${DISTCHECK_TMPDIR}/install" ${DISTCHECK_CMAKEFLAGS} "${DISTCHECK_SOURCEDIR}"
100
101 COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_BUILDTARGETS}
102
103 # execute 'make install' without DESTDIR
104 COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_INSTALLTARGETS} DESTDIR=
105 # write protect installation path to detect writing outside of DESTDIR
106 COMMAND chmod -R a-w "${DISTCHECK_TMPDIR}/install"
107 # execute 'make install' with DESTDIR and move the files to a better location
108 COMMAND cd "${DISTCHECK_BUILDDIR}" && ${CMAKE_MAKE_PROGRAM} ${DISTCHECK_INSTALLTARGETS} DESTDIR="${DISTCHECK_TMPDIR}/install-tmp"
109 COMMAND mv "${DISTCHECK_TMPDIR}/install-tmp/${DISTCHECK_TMPDIR}/install" "${DISTCHECK_TMPDIR}/install-destdir"
110
111 # generate list of files which were installed by the both 'make
112 # install' commands above and compare them
113 COMMAND cd "${DISTCHECK_TMPDIR}/install" && find -type f | sort > ../files.install
114 COMMAND cd "${DISTCHECK_TMPDIR}/install-destdir" && find -type f | sort > ../files.destdir
115 COMMAND cd "${DISTCHECK_TMPDIR}" && diff files.install files.destdir
116
117 # cleanup tmpdir
118 COMMAND chmod -R u+Xw "${DISTCHECK_TMPDIR}" 2>/dev/null || :
119 COMMAND rm -rf "${DISTCHECK_TMPDIR}"
120 )
121endmacro(add_distcheck)
122
diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in
new file mode 100644
index 0000000..dac95d5
--- /dev/null
+++ b/cmakeconfig.h.in
@@ -0,0 +1,8 @@
1#define PACKAGE "@PACKAGE@"
2#define PACKAGE_NAME PACKAGE
3#define VERSION "@PACKAGE_VERSION@"
4#define VMAJ @VMAJ@
5#define VMIN @VMIN@
6#define VMIC @VMIC@
7
8#cmakedefine ENABLE_NLS
diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt
new file mode 100644
index 0000000..2d318a3
--- /dev/null
+++ b/src/bin/CMakeLists.txt
@@ -0,0 +1,21 @@
1LIST(APPEND SOLVE_CC_SOURCES
2 solve_main.c
3 solve_calc.c
4 )
5
6include_directories(
7 ${EINA_INCLUDE_DIRS}
8 ${ELEMENTARY_INCLUDE_DIRS}
9 ${EVAS_INCLUDE_DIRS}
10 ${ECORE_INCLUDE_DIRS}
11 )
12
13add_executable(solve ${SOLVE_CC_SOURCES})
14target_link_libraries(solve
15 ${EINA_LIBRARIES}
16 ${ELEMENTARY_LIBRARIES}
17 ${EVAS_LIBRARIES}
18 ${ECORE_LIBRARIES}
19 )
20
21install(TARGETS solve DESTINATION bin)
diff --git a/src/bin/solve_calc.c b/src/bin/solve_calc.c
new file mode 100644
index 0000000..be76986
--- /dev/null
+++ b/src/bin/solve_calc.c
@@ -0,0 +1,95 @@
1#include <Elementary.h>
2
3#include "solve_calc.h"
4
5/* Start of BC */
6static void (*_bc_res_cb)(void *data, const char *result);
7static Ecore_Exe *bc_exe;
8static Ecore_Event_Handler *ee_data_handle;
9static Ecore_Event_Handler *ee_error_handle;
10
11static const char _bc_allowed_chars[] = "0123456789.()+-*/ \t";
12
13/* FIXME: Instead of blindly stripping, we should strip if doesn't look
14 * like a number. */
15static char *
16_bc_prepare_expression(const char *expression)
17{
18 char *ret = calloc(1, strlen(expression) + 2); /* \n + \0 */
19 char *tmp = ret;
20
21 for ( ; *expression ; expression++)
22 {
23 if (strchr(_bc_allowed_chars, *expression))
24 {
25 *(tmp++) = *expression;
26 }
27 }
28
29 *tmp = '\n';
30
31 return ret;
32}
33
34/* Got the result. */
35static Eina_Bool
36_bc_msg_from_child_handler(void *data, int type EINA_UNUSED, void *event)
37{
38 Ecore_Exe_Event_Data *dataFromProcess = (Ecore_Exe_Event_Data *)event;
39 char msg[1024];
40
41 if (dataFromProcess->size >= (int) (sizeof(msg) - 1))
42 {
43 fprintf(stdout, "Data too big for buffer. error\n");
44 return ECORE_CALLBACK_DONE;
45 }
46
47 strncpy(msg, dataFromProcess->data, dataFromProcess->size);
48 msg[dataFromProcess->size] = 0;
49
50 if (_bc_res_cb)
51 _bc_res_cb(data, msg);
52
53 return ECORE_CALLBACK_DONE;
54}
55
56void
57solve_calc_callback_set(void (*cb)(void *data, const char *result), const void *data)
58{
59 ee_data_handle = ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _bc_msg_from_child_handler, data);
60 ee_error_handle = ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _bc_msg_from_child_handler, data);
61
62 _bc_res_cb = cb;
63}
64
65void
66solve_calc_calc(const char *_expression)
67{
68 char *expression = _bc_prepare_expression(_expression);
69 if (EINA_TRUE != ecore_exe_send(bc_exe, expression, strlen(expression)))
70 {
71 printf("Can't send expression to bc.\n");
72 }
73 free(expression);
74}
75
76/* We assume we init once. */
77void
78solve_calc_init(void)
79{
80 bc_exe = ecore_exe_pipe_run("bc -l",
81 ECORE_EXE_PIPE_ERROR |
82 ECORE_EXE_PIPE_READ |
83 ECORE_EXE_PIPE_WRITE, NULL);
84}
85
86void
87solve_calc_shutdown(void)
88{
89 if (ee_data_handle)
90 ecore_event_handler_del(ee_data_handle);
91 if (ee_error_handle)
92 ecore_event_handler_del(ee_error_handle);
93 ecore_exe_free(bc_exe);
94}
95/* End of BC */
diff --git a/src/bin/solve_calc.h b/src/bin/solve_calc.h
new file mode 100644
index 0000000..ad6a85d
--- /dev/null
+++ b/src/bin/solve_calc.h
@@ -0,0 +1,9 @@
1#ifndef _SOLVE_CALC_H
2#define _SOLVE_CALC_H
3
4void solve_calc_callback_set(void (*cb)(void *data, const char *result), const void *data);
5void solve_calc_calc(const char *expression);
6void solve_calc_init(void);
7void solve_calc_shutdown(void);
8
9#endif
diff --git a/src/bin/solve_main.c b/src/bin/solve_main.c
new file mode 100644
index 0000000..eeb308f
--- /dev/null
+++ b/src/bin/solve_main.c
@@ -0,0 +1,305 @@
1// http://worrydream.com/ScrubbingCalculator/
2#include <Elementary.h>
3#include <Elementary_Cursor.h>
4#include "solve_calc.h"
5
6/* Amount of pixels that translate to a change unit. */
7#define SLIDER_SENSITIVITY 2
8
9static void
10my_win_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
11{
12 /* called when my_win_main is requested to be deleted */
13 elm_exit(); /* exit the program's main loop that runs in elm_run() */
14}
15
16/* VERY BASIC anchor adding code, assumes text has no anchors. */
17static char *
18_decorate(const char *str)
19{
20 char *ret;
21 Eina_Bool last_is_num = EINA_FALSE;
22 int i;
23 int count = 0;
24 Eina_Strbuf *strbuf = eina_strbuf_new();
25 eina_strbuf_append(strbuf, str);
26 i = eina_strbuf_length_get(strbuf) - 1;
27
28 for ( ; i >= 0 ; i--)
29 {
30 if (isdigit(str[i]) || (str[i] == '-'))
31 {
32 if (!last_is_num)
33 {
34 eina_strbuf_insert(strbuf, "</a>", i + 1);
35 last_is_num = EINA_TRUE;
36 }
37 }
38 else
39 {
40 if (last_is_num)
41 {
42 eina_strbuf_insert_printf(strbuf, "<a href=%d>", i + 1, count++);
43 last_is_num = EINA_FALSE;
44 }
45 }
46 }
47
48 if (last_is_num)
49 {
50 eina_strbuf_insert_printf(strbuf, "<a href=%d>", i + 1, count++);
51 }
52
53 ret = eina_strbuf_string_steal(strbuf);
54 eina_strbuf_free(strbuf);
55
56 return ret;
57}
58
59static void
60_update_ent(Evas_Object *obj, const char *str)
61{
62 char *tmp;
63 tmp = _decorate(str);
64 solve_calc_calc(str);
65
66 int pos = elm_entry_cursor_pos_get(obj);
67
68 elm_object_text_set(obj, tmp);
69
70 elm_entry_cursor_pos_set(obj, pos);
71
72 free(tmp);
73}
74
75static void
76_en_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
77{
78 char *tmp = elm_entry_markup_to_utf8(elm_object_text_get(obj));
79 _update_ent(obj, tmp);
80 free(tmp);
81}
82
83/* Change number.
84 * FIXME hackish. */
85
86static void
87_number_range_from_tag_get(const char *str, const char *number_tag, size_t *range_start, size_t *range_end)
88{
89 const char *start;
90
91 {
92 char search[1024];
93 snprintf(search, sizeof(search), "href=%s", number_tag);
94 start = strstr(str, search);
95 }
96
97 {
98 if (!start)
99 {
100 printf("ERROR!\n");
101 goto cleanup;
102 }
103
104 start = strchr(start, '>');
105
106 if (!start)
107 {
108 printf("ERROR!\n");
109 goto cleanup;
110 }
111 else
112 {
113 start++;
114
115 *range_start = start - str;
116 start = strchr(start, '<');
117 if (!start)
118 {
119 printf("ERROR!\n");
120 goto cleanup;
121 }
122
123 *range_end = start - str;
124 }
125 }
126
127 return;
128
129cleanup:
130 *range_start = *range_end = 0;
131}
132
133static int
134_number_from_tag_get(Evas_Object *obj, const char *number_tag)
135{
136 const char *str = elm_object_text_get(obj);
137 size_t range_start, range_end;
138 _number_range_from_tag_get(str, number_tag, &range_start, &range_end);
139 if (range_start < range_end)
140 {
141 int number;
142
143 number = atoi(str + range_start);
144
145 return number;
146 }
147
148 printf("ERROR!\n");
149 return 0;
150}
151
152static void
153_change_number(Evas_Object *obj, const char *number_tag, int new_num)
154{
155 const char *str = elm_object_text_get(obj);
156 Eina_Strbuf *strbuf = eina_strbuf_new();
157 eina_strbuf_append(strbuf, str);
158
159 {
160 size_t range_start, range_end;
161 _number_range_from_tag_get(str, number_tag, &range_start, &range_end);
162 if (range_start < range_end)
163 {
164 eina_strbuf_remove(strbuf, range_start, range_end);
165 eina_strbuf_insert_printf(strbuf, "%d", range_start, new_num);
166 }
167 }
168
169 /* Update the entry. */
170 {
171 char *tmp = elm_entry_markup_to_utf8(eina_strbuf_string_get(strbuf));
172 _update_ent(obj, tmp);
173 eina_strbuf_free(strbuf);
174 free(tmp);
175 }
176}
177
178typedef struct
179{
180 Eina_Stringshare *name;
181 Evas_Coord x;
182 Evas_Object *en;
183 int base_number;
184} Slider_Data;
185
186static void
187_slider_out(void *_data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
188{
189 Slider_Data *data = _data;
190 evas_object_del(obj);
191 eina_stringshare_del(data->name);
192 free(data);
193}
194
195static void
196_slider_move(void *_data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
197{
198 Evas_Event_Mouse_Move *einfo = event_info;
199 Slider_Data *data = _data;
200 Evas_Coord x;
201 int delta;
202
203 if (!(einfo->buttons & 0x1))
204 return;
205
206 x = einfo->cur.canvas.x;
207
208 delta = (x - data->x) / SLIDER_SENSITIVITY;
209 _change_number(data->en, data->name, data->base_number + delta);
210}
211
212static void
213_anchor_in(void *_data EINA_UNUSED, Evas_Object *en, void *event_info)
214{
215 Slider_Data *data = calloc(1, sizeof(*data));
216 Evas_Object *slider;
217 Elm_Entry_Anchor_Info *info = event_info;
218
219 slider = elm_button_add(en);
220 evas_object_move(slider, info->x, info->y);
221 evas_object_resize(slider, info->w, info->h);
222 evas_object_color_set(slider, 0, 0, 0, 0);
223 elm_object_cursor_set(slider, ELM_CURSOR_SB_H_DOUBLE_ARROW);
224
225 evas_object_show(slider);
226
227 evas_object_event_callback_add(slider, EVAS_CALLBACK_MOUSE_OUT, _slider_out, data);
228 evas_object_event_callback_add(slider, EVAS_CALLBACK_MOUSE_MOVE, _slider_move, data);
229
230 data->en = en;
231 data->name = eina_stringshare_add(info->name);
232 data->base_number = _number_from_tag_get(en, info->name);
233 evas_pointer_canvas_xy_get(evas_object_evas_get(en), &data->x, NULL);
234}
235
236static void
237_solve_calc_res_cb(void *data, const char *result)
238{
239 Evas_Object *enres = data;
240 elm_object_text_set(enres, " = ");
241 elm_entry_entry_append(enres, result);
242}
243
244int
245main(int argc, char *argv[])
246{
247 Evas_Object *win, *bg, *bx, *en, *enres;
248 Evas_Coord w, h;
249 {
250 w = 510;
251 h = 100;
252 }
253
254 elm_init(argc, argv);
255 solve_calc_init();
256
257 win = elm_win_add(NULL, "scrubber", ELM_WIN_BASIC);
258 elm_win_title_set(win, "Scrubber");
259 elm_win_autodel_set(win, EINA_TRUE);
260 evas_object_smart_callback_add(win, "delete,request", my_win_del, NULL);
261
262 bg = elm_bg_add(win);
263 elm_win_resize_object_add(win, bg);
264 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
265 evas_object_show(bg);
266
267 bx = elm_box_add(win);
268 elm_win_resize_object_add(win, bx);
269 elm_box_horizontal_set(bx, EINA_TRUE);
270 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
271 evas_object_show(bx);
272
273 en = elm_entry_add(bx);
274 elm_entry_scrollable_set(en, EINA_TRUE);
275 elm_entry_single_line_set(en, EINA_TRUE);
276 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
277 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
278 elm_box_pack_end(bx, en);
279 evas_object_smart_callback_add(en, "anchor,in", _anchor_in, NULL);
280 evas_object_smart_callback_add(en, "changed,user", _en_changed, NULL);
281 evas_object_show(en);
282
283 enres = elm_entry_add(bx);
284 elm_entry_editable_set(enres, EINA_FALSE);
285 elm_entry_single_line_set(enres, EINA_TRUE);
286 evas_object_size_hint_weight_set(enres, 0.0, EVAS_HINT_EXPAND);
287 evas_object_size_hint_align_set(enres, 0.0, EVAS_HINT_FILL);
288 elm_box_pack_end(bx, enres);
289 evas_object_show(enres);
290
291 evas_object_resize(win, w, h);
292
293 solve_calc_callback_set(_solve_calc_res_cb, enres);
294
295 evas_object_show(win);
296
297 elm_run();
298
299 solve_calc_shutdown();
300
301 elm_shutdown();
302
303 return 0;
304}
305