2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <Ecore_X.h> /* ecore_x_window_size_get */
21 #include <utilX.h> /* KEY_END */
23 #include "calc-main.h"
24 #include "calc-view.h"
26 extern char calculator_input_str[];
27 extern int calculator_cursor_pos;
29 static int max_fontsize = 67;
30 extern void calc_xxx(struct appdata *ap); /* will be removed */
32 Evas_Object *load_edj(Evas_Object * parent, const char *file, const char *group)
36 eo = elm_layout_add(parent);
38 r = elm_layout_file_set(eo, file, group);
43 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
58 static void _to_portrait(struct appdata *ad, int angle)
60 elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
61 edje_object_signal_emit(_EDJ(ad->edje), "portrait", "");
62 elm_win_rotation_with_resize_set(ad->win, angle);
63 elm_win_rotation_with_resize_set(ad->eo, angle);/*when rotating, resize the window eo*/
67 int get_max_fontsize()
82 static void _win_del(void *data, Evas_Object * obj, void *event_info)
96 static int _capture_idle_image(void *data)
98 struct appdata *ad = (struct appdata *)data;
101 //snprintf(name, sizeof(name), COM_SAMSUNG_S, PACKAGE);
102 snprintf(name, sizeof(name), "com.%s.%s", VENDOR, PACKAGE);
103 Evas *evas = evas_object_evas_get(ad->win);
105 if (ui_idlecapture_exists(name) == EINA_FALSE) {
106 ui_idlecapture_set(evas, name);
109 return ECORE_CALLBACK_CANCEL; //0
120 static int _set_input_entry_focus(void *data)
122 struct appdata *ad = (struct appdata *)data;
123 elm_object_focus_set(ad->input_entry, EINA_TRUE); //set focus
124 _calc_entry_clear(ad->input_entry);
126 return ECORE_CALLBACK_CANCEL; //0
137 static int _load_idle_view(void *data)
139 struct appdata *ad = (struct appdata *)data;
140 calc_view_load_in_idle(ad);
142 return ECORE_CALLBACK_CANCEL; //0
150 * @return Evas_Object*
153 static Evas_Object *_create_win(const char *name)
157 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
159 elm_win_title_set(eo, name);
160 elm_win_borderless_set(eo, EINA_TRUE);
161 evas_object_smart_callback_add(eo, "delete,request", _win_del,
163 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w,
165 evas_object_resize(eo, w, h);
178 static void _on_exit(struct appdata *ad)
180 //ui_bgimg_fini_noti();
183 evas_object_del(ad->popup);
187 if (ad->por_pannel) {
188 evas_object_del(ad->por_pannel);
189 ad->por_pannel = NULL;
192 if (ad->lan_pannel) {
193 evas_object_del(ad->lan_pannel);
194 ad->lan_pannel = NULL;
197 if (ad->input_entry) {
198 evas_object_del(ad->input_entry);
199 ad->input_entry = NULL;
203 evas_object_del(ad->hist_area);
204 ad->hist_area = NULL;
207 if (ad->hist_scroll) {
208 evas_object_del(ad->hist_scroll);
209 ad->hist_scroll = NULL;
214 evas_object_del(ad->edje);
219 evas_object_del(ad->layout);
224 evas_object_del(ad->win);
229 if (ad->calc_timer) {
230 ecore_timer_del(ad->calc_timer);
231 ad->calc_timer = NULL;
233 if (ad->svi_handle) {
234 svi_fini(ad->svi_handle);
238 static bool app_launch(void *data)
241 struct appdata *ad = (struct appdata *)data;
243 /* Use elm_theme_extension_add() API before creating any widgets */
244 //elm_theme_overlay_add(NULL, CALCULATOR_THEME);
245 elm_theme_extension_add(NULL, CALCULATOR_THEME);
248 ad->win = _create_win(PACKAGE);
249 if (ad->win == NULL) {
252 evas_object_show(ad->win);
254 elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
256 /* will be removed */
263 /* register callback */
264 //ecore_idler_add((Ecore_Task_Cb)_capture_idle_image, ad);
265 ecore_idler_add((Ecore_Task_Cb) _set_input_entry_focus, ad);
266 ecore_idler_add((Ecore_Task_Cb) _load_idle_view, ad);
269 return TRUE; //EXIT_SUCCESS
280 static bool app_create(void *data)
282 return TRUE; //EXIT_SUCCESS
293 static void app_terminate(void *data)
295 struct appdata *ad = (struct appdata *)data;
307 static void app_pause(void *data)
309 // Take necessary actions when application becomes invisible
320 static void app_resume(void *data)
322 // Take necessary actions when application becomes visible.
325 static void app_service(service_h service, void *data)
328 struct appdata *ad = (struct appdata *)data;
330 if (ad->win != NULL) { /* calculator has already launced. */
331 elm_win_activate(ad->win);
335 evas_object_show(ad->win);
342 * The entry of the program
349 int main(int argc, char *argv[])
353 app_event_callback_s event_callback;
355 event_callback.create = app_create;
356 event_callback.terminate = app_terminate;
357 event_callback.pause = app_pause;
358 event_callback.resume = app_resume;
359 event_callback.service = app_service;
360 event_callback.low_memory = NULL;
361 event_callback.low_battery = NULL;
362 event_callback.device_orientation = NULL;
363 event_callback.language_changed = NULL;
364 event_callback.region_format_changed = NULL;
366 memset(&ad, 0x0, sizeof(struct appdata));
368 return app_efl_main(&argc, &argv, &event_callback, &ad);