Calculator UI / src /

main.c

  1. /*
  2. * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
  3. *
  4. * Licensed under the Apache License, Version 2.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
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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.
  15. */
  16.  
  17. #include "$(appName).h"
  18.  
  19. typedef struct appdata {
  20. const char *name;
  21. Evas_Object *win;
  22. Evas_Object *bg;
  23. Evas_Object *conform;
  24. Evas_Object *entry;
  25. Evas_Object *basic_content;
  26. Evas_Object *advanced_content;
  27. } appdata_s;
  28.  
  29. /*
  30. * @brief Function will be operated when window deletion is requested
  31. * @param[in] data The data to be passed to the callback function
  32. * @param[in] obj The Evas object handle to be passed to the callback function
  33. * @param[in] event_info The system event information
  34. */
  35. static void
  36. win_delete_request_cb(void *data , Evas_Object *obj , void *event_info)
  37. {
  38. ui_app_exit();
  39. }
  40.  
  41. /*
  42. * @brief Function will be operated when back key event is triggered on window
  43. * @param[in] data The data to be passed to the callback function
  44. * @param[in] obj The Evas object handle to be passed to the callback function
  45. * @param[in] event_info The system event information
  46. */
  47. static void
  48. win_back_cb(void *data , Evas_Object *obj , void *event)
  49. {
  50. appdata_s *ad = data;
  51. /* Let window go to hide state. */
  52. elm_win_lower(ad->win);
  53. }
  54.  
  55. /*
  56. * @brief Function to create background object
  57. * @param[in] parent The Evas object which background object is created on
  58. * @param[out] Evas_Object The background object which is created
  59. */
  60. static Evas_Object *
  61. create_bg(Evas_Object *parent)
  62. {
  63. Evas_Object *bg;
  64.  
  65. if (parent == NULL) return NULL;
  66.  
  67. bg = elm_bg_add(parent);
  68. evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  69. elm_win_resize_object_add(parent, bg);
  70. evas_object_show(bg);
  71.  
  72. return bg;
  73. }
  74.  
  75. /*
  76. * @brief Function to create conformant object
  77. * @param[in] parent The Evas object which conformant object is created on
  78. * @param[out] Evas_Object The conformant object which is created
  79. */
  80. static Evas_Object *
  81. create_conform(Evas_Object *parent)
  82. {
  83. Evas_Object *conform, *bg;
  84.  
  85. if (parent == NULL) return NULL;
  86.  
  87. conform = elm_conformant_add(parent);
  88. evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  89. elm_win_resize_object_add(parent, conform);
  90.  
  91. bg = elm_bg_add(conform);
  92. elm_object_style_set(bg, "indicator/headerbg");
  93. elm_object_part_content_set(conform, "elm.swallow.indicator_bg", bg);
  94. evas_object_show(bg);
  95.  
  96. evas_object_show(conform);
  97. return conform;
  98. }
  99.  
  100. /*
  101. * @brief Function will be operated when window rotation is changed
  102. * @param[in] data The data to be passed to the callback function
  103. * @param[in] obj The Evas object handle to be passed to the callback function
  104. * @param[in] event_info The system event information
  105. */
  106. static void
  107. rotation_cb(void *data, Evas_Object *obj, void *event_info)
  108. {
  109. appdata_s *ad = data;
  110. int current_degree = elm_win_rotation_get(obj);
  111.  
  112. if (current_degree != 0 && current_degree != 180) {
  113. elm_grid_pack_set(ad->basic_content, 45, 3, 52, 94);
  114. elm_grid_pack_set(ad->advanced_content, 3, 3, 36, 94);
  115. } else {
  116. elm_grid_pack_set(ad->basic_content, 3, 3, 94, 94);
  117. elm_grid_pack_set(ad->advanced_content, -100, -100, 94, 94);
  118. }
  119. }
  120.  
  121. /*
  122. * @brief Function will be operated when '0' button is clicked
  123. * @param[in] data The data to be passed to the callback function
  124. * @param[in] obj The Evas object handle to be passed to the callback function
  125. * @param[in] event_info The system event information
  126. */
  127. static void
  128. clicked_0_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  129. {
  130. Evas_Object *entry = data;
  131. elm_entry_entry_append(entry, "<font_size=50>0</font_size>");
  132. }
  133.  
  134. /*
  135. * @brief Function will be operated when '' button is clicked
  136. * @param[in] data The data to be passed to the callback function
  137. * @param[in] obj The Evas object handle to be passed to the callback function
  138. * @param[in] event_info The system event information
  139. */
  140. static void
  141. clicked_1_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  142. {
  143. Evas_Object *entry = data;
  144. elm_entry_entry_append(entry, "<font_size=50>1</font_size>");
  145. }
  146.  
  147. /*
  148. * @brief Function will be operated when '2' button is clicked
  149. * @param[in] data The data to be passed to the callback function
  150. * @param[in] obj The Evas object handle to be passed to the callback function
  151. * @param[in] event_info The system event information
  152. */
  153. static void
  154. clicked_2_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  155. {
  156. Evas_Object *entry = data;
  157. elm_entry_entry_append(entry, "<font_size=50>2</font_size>");
  158. }
  159.  
  160. /*
  161. * @brief Function will be operated when '3' button is clicked
  162. * @param[in] data The data to be passed to the callback function
  163. * @param[in] obj The Evas object handle to be passed to the callback function
  164. * @param[in] event_info The system event information
  165. */
  166. static void
  167. clicked_3_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  168. {
  169. Evas_Object *entry = data;
  170. elm_entry_entry_append(entry, "<font_size=50>3</font_size>");
  171. }
  172.  
  173. /*
  174. * @brief Function will be operated when '4' button is clicked
  175. * @param[in] data The data to be passed to the callback function
  176. * @param[in] obj The Evas object handle to be passed to the callback function
  177. * @param[in] event_info The system event information
  178. */
  179. static void
  180. clicked_4_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  181. {
  182. Evas_Object *entry = data;
  183. elm_entry_entry_append(entry, "<font_size=50>4</font_size>");
  184. }
  185.  
  186. /*
  187. * @brief Function will be operated when '5' button is clicked
  188. * @param[in] data The data to be passed to the callback function
  189. * @param[in] obj The Evas object handle to be passed to the callback function
  190. * @param[in] event_info The system event information
  191. */
  192. static void
  193. clicked_5_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  194. {
  195. Evas_Object *entry = data;
  196. elm_entry_entry_append(entry, "<font_size=50>5</font_size>");
  197. }
  198.  
  199. /*
  200. * @brief Function will be operated when '6' button is clicked
  201. * @param[in] data The data to be passed to the callback function
  202. * @param[in] obj The Evas object handle to be passed to the callback function
  203. * @param[in] event_info The system event information
  204. */
  205. static void
  206. clicked_6_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  207. {
  208. Evas_Object *entry = data;
  209. elm_entry_entry_append(entry, "<font_size=50>6</font_size>");
  210. }
  211.  
  212. /*
  213. * @brief Function will be operated when '7' button is clicked
  214. * @param[in] data The data to be passed to the callback function
  215. * @param[in] obj The Evas object handle to be passed to the callback function
  216. * @param[in] event_info The system event information
  217. */
  218. static void
  219. clicked_7_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  220. {
  221. Evas_Object *entry = data;
  222. elm_entry_entry_append(entry, "<font_size=50>7</font_size>");
  223. }
  224.  
  225. /*
  226. * @brief Function will be operated when '8' button is clicked
  227. * @param[in] data The data to be passed to the callback function
  228. * @param[in] obj The Evas object handle to be passed to the callback function
  229. * @param[in] event_info The system event information
  230. */
  231. static void
  232. clicked_8_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  233. {
  234. Evas_Object *entry = data;
  235. elm_entry_entry_append(entry, "<font_size=50>8</font_size>");
  236. }
  237.  
  238. /*
  239. * @brief Function will be operated when '9' button is clicked
  240. * @param[in] data The data to be passed to the callback function
  241. * @param[in] obj The Evas object handle to be passed to the callback function
  242. * @param[in] event_info The system event information
  243. */
  244. static void
  245. clicked_9_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  246. {
  247. Evas_Object *entry = data;
  248. elm_entry_entry_append(entry, "<font_size=50>9</font_size>");
  249. }
  250.  
  251. /*
  252. * @brief Function will be operated when 'C' button is clicked
  253. * @param[in] data The data to be passed to the callback function
  254. * @param[in] obj The Evas object handle to be passed to the callback function
  255. * @param[in] event_info The system event information
  256. */
  257. static void
  258. clicked_c_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  259. {
  260. Evas_Object *entry = data;
  261. elm_entry_entry_set(entry, "<align=right>");
  262. }
  263.  
  264. /*
  265. * @brief Function will be operated when '/' button is clicked
  266. * @param[in] data The data to be passed to the callback function
  267. * @param[in] obj The Evas object handle to be passed to the callback function
  268. * @param[in] event_info The system event information
  269. */
  270. static void
  271. clicked_divide_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  272. {
  273. Evas_Object *entry = data;
  274. elm_entry_entry_append(entry, "<font_size=50>/</font_size>");
  275. }
  276.  
  277. /*
  278. * @brief Function will be operated when 'X' button is clicked
  279. * @param[in] data The data to be passed to the callback function
  280. * @param[in] obj The Evas object handle to be passed to the callback function
  281. * @param[in] event_info The system event information
  282. */
  283. static void
  284. clicked_multi_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  285. {
  286. Evas_Object *entry = data;
  287. elm_entry_entry_append(entry, "<font_size=50>X</font_size>");
  288. }
  289.  
  290. /*
  291. * @brief Function will be operated when '+' button is clicked
  292. * @param[in] data The data to be passed to the callback function
  293. * @param[in] obj The Evas object handle to be passed to the callback function
  294. * @param[in] event_info The system event information
  295. */
  296. static void
  297. clicked_plus_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  298. {
  299. Evas_Object *entry = data;
  300. elm_entry_entry_append(entry, "<font_size=50>+</font_size>");
  301. }
  302.  
  303. /*
  304. * @brief Function will be operated when '-' button is clicked
  305. * @param[in] data The data to be passed to the callback function
  306. * @param[in] obj The Evas object handle to be passed to the callback function
  307. * @param[in] event_info The system event information
  308. */
  309. static void
  310. clicked_minus_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  311. {
  312. Evas_Object *entry = data;
  313. elm_entry_entry_append(entry, "<font_size=50>-</font_size>");
  314. }
  315.  
  316. /*
  317. * @brief Function will be operated when '.' button is clicked
  318. * @param[in] data The data to be passed to the callback function
  319. * @param[in] obj The Evas object handle to be passed to the callback function
  320. * @param[in] event_info The system event information
  321. */
  322. static void
  323. clicked_dot_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
  324. {
  325. Evas_Object *entry = data;
  326. elm_entry_entry_append(entry, "<font_size=50>.</font_size>");
  327. }
  328.  
  329. /*
  330. * @brief Function to create button layout
  331. * @param[in] parent The Evas object which layout object is created on
  332. * @param[in] ad The data structure to manage gui object
  333. * @param[out] Evas_Object The layout object which is created
  334. */
  335. static Evas_Object *
  336. create_panel_basic_content(Evas_Object *parent, appdata_s *ad)
  337. {
  338. Evas_Object *table, *button;
  339.  
  340. /* Table */
  341. table = elm_table_add(parent);
  342. elm_table_padding_set(table, 10, 10);
  343.  
  344. /* Button */
  345. button = elm_button_add(table);
  346. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  347. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  348. elm_object_text_set(button, "<font_size = 50>C</font_size>");
  349. evas_object_smart_callback_add(button, "clicked", clicked_c_cb, ad->entry);
  350. evas_object_show(button);
  351. elm_table_pack(table, button, 0, 0, 1, 1);
  352.  
  353. /* Button */
  354. button = elm_button_add(table);
  355. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  356. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  357. elm_object_text_set(button, "<font_size = 50>/</font_size>");
  358. evas_object_smart_callback_add(button, "clicked", clicked_divide_cb, ad->entry);
  359. evas_object_show(button);
  360. elm_table_pack(table, button, 1, 0, 1, 1);
  361.  
  362. /* Button */
  363. button = elm_button_add(table);
  364. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  365. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  366. elm_object_text_set(button, "<font_size = 50>X</font_size>");
  367. evas_object_smart_callback_add(button, "clicked", clicked_multi_cb, ad->entry);
  368. evas_object_show(button);
  369. elm_table_pack(table, button, 2, 0, 1, 1);
  370.  
  371. /* Button */
  372. button = elm_button_add(table);
  373. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  374. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  375. elm_object_text_set(button, "<font_size = 50>Back</font_size>");
  376. evas_object_show(button);
  377. elm_table_pack(table, button, 3, 0, 1, 1);
  378.  
  379. /* Button */
  380. button = elm_button_add(table);
  381. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  382. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  383. elm_object_text_set(button, "<font_size = 50>7</font_size>");
  384. evas_object_smart_callback_add(button, "clicked", clicked_7_cb, ad->entry);
  385. evas_object_show(button);
  386. elm_table_pack(table, button, 0, 1, 1, 1);
  387.  
  388. /* Button */
  389. button = elm_button_add(table);
  390. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  391. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  392. elm_object_text_set(button, "<font_size = 50>8</font_size>");
  393. evas_object_smart_callback_add(button, "clicked", clicked_8_cb, ad->entry);
  394. evas_object_show(button);
  395. elm_table_pack(table, button, 1, 1, 1, 1);
  396.  
  397. /* Button */
  398. button = elm_button_add(table);
  399. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  400. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  401. elm_object_text_set(button, "<font_size = 50>9</font_size>");
  402. evas_object_smart_callback_add(button, "clicked", clicked_9_cb, ad->entry);
  403. evas_object_show(button);
  404. elm_table_pack(table, button, 2, 1, 1, 1);
  405.  
  406. /* Button */
  407. button = elm_button_add(table);
  408. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  409. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  410. elm_object_text_set(button, "<font_size = 50>-</font_size>");
  411. evas_object_smart_callback_add(button, "clicked", clicked_minus_cb, ad->entry);
  412. evas_object_show(button);
  413. elm_table_pack(table, button, 3, 1, 1, 1);
  414.  
  415. /* Button */
  416. button = elm_button_add(table);
  417. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  418. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  419. elm_object_text_set(button, "<font_size = 50>4</font_size>");
  420. evas_object_smart_callback_add(button, "clicked", clicked_4_cb, ad->entry);
  421. evas_object_show(button);
  422. elm_table_pack(table, button, 0, 2, 1, 1);
  423.  
  424. /* Button */
  425. button = elm_button_add(table);
  426. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  427. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  428. elm_object_text_set(button, "<font_size = 50>5</font_size>");
  429. evas_object_smart_callback_add(button, "clicked", clicked_5_cb, ad->entry);
  430. evas_object_show(button);
  431. elm_table_pack(table, button, 1, 2, 1, 1);
  432.  
  433. /* Button */
  434. button = elm_button_add(table);
  435. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  436. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  437. elm_object_text_set(button, "<font_size = 50>6</font_size>");
  438. evas_object_smart_callback_add(button, "clicked", clicked_6_cb, ad->entry);
  439. evas_object_show(button);
  440. elm_table_pack(table, button, 2, 2, 1, 1);
  441.  
  442. /* Button */
  443. button = elm_button_add(table);
  444. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  445. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  446. elm_object_text_set(button, "<font_size = 50>+</font_size>");
  447. evas_object_smart_callback_add(button, "clicked", clicked_plus_cb, ad->entry);
  448. evas_object_show(button);
  449. elm_table_pack(table, button, 3, 2, 1, 1);
  450.  
  451. /* Button */
  452. button = elm_button_add(table);
  453. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  454. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  455. elm_object_text_set(button, "<font_size = 50>1</font_size>");
  456. evas_object_smart_callback_add(button, "clicked", clicked_1_cb, ad->entry);
  457. evas_object_show(button);
  458. elm_table_pack(table, button, 0, 3, 1, 1);
  459.  
  460. /* Button */
  461. button = elm_button_add(table);
  462. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  463. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  464. elm_object_text_set(button, "<font_size = 50>2</font_size>");
  465. evas_object_smart_callback_add(button, "clicked", clicked_2_cb, ad->entry);
  466. evas_object_show(button);
  467. elm_table_pack(table, button, 1, 3, 1, 1);
  468.  
  469. /* Button */
  470. button = elm_button_add(table);
  471. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  472. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  473. elm_object_text_set(button, "<font_size = 50>3</font_size>");
  474. evas_object_smart_callback_add(button, "clicked", clicked_3_cb, ad->entry);
  475. evas_object_show(button);
  476. elm_table_pack(table, button, 2, 3, 1, 1);
  477.  
  478. /* Button */
  479. button = elm_button_add(table);
  480. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  481. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  482. elm_object_text_set(button, "<font_size = 50>( )</font_size>");
  483. evas_object_show(button);
  484. elm_table_pack(table, button, 3, 3, 1, 1);
  485.  
  486. /* Button */
  487. button = elm_button_add(table);
  488. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  489. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  490. elm_object_text_set(button, "<font_size = 50>0</font_size>");
  491. evas_object_smart_callback_add(button, "clicked", clicked_0_cb, ad->entry);
  492. evas_object_show(button);
  493. elm_table_pack(table, button, 0, 4, 1, 1);
  494.  
  495. /* Button */
  496. button = elm_button_add(table);
  497. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  498. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  499. elm_object_text_set(button, "<font_size = 50>.</font_size>");
  500. evas_object_smart_callback_add(button, "clicked", clicked_dot_cb, ad->entry);
  501. evas_object_show(button);
  502. elm_table_pack(table, button, 1, 4, 1, 1);
  503.  
  504. /* Button */
  505. button = elm_button_add(table);
  506. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  507. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  508. elm_object_text_set(button, "<font_size = 50>+/-</font_size>");
  509. evas_object_show(button);
  510. elm_table_pack(table, button, 2, 4, 1, 1);
  511.  
  512. /* Button */
  513. button = elm_button_add(table);
  514. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  515. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  516. elm_object_text_set(button, "<font_size = 50>=</font_size>");
  517. evas_object_show(button);
  518. elm_table_pack(table, button, 3, 4, 1, 1);
  519.  
  520. evas_object_show(table);
  521.  
  522. return table;
  523. }
  524.  
  525. /*
  526. * @brief Function to create advanced button layout
  527. * @param[in] parent The Evas object which layout object is created on
  528. * @param[in] ad The data structure to manage gui object
  529. * @param[out] Evas_Object The layout object which is created
  530. */
  531. static Evas_Object *
  532. create_panel_advanced_content(Evas_Object *parent, appdata_s *ad)
  533. {
  534. Evas_Object *table, *button;
  535.  
  536. /* Table */
  537. table = elm_table_add(parent);
  538. elm_table_padding_set(table, 10, 10);
  539.  
  540. /* Button */
  541. button = elm_button_add(table);
  542. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  543. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  544. elm_object_text_set(button, "<font_size = 50>x!</font_size>");
  545. evas_object_show(button);
  546. elm_table_pack(table, button, 0, 0, 1, 1);
  547.  
  548. /* Button */
  549. button = elm_button_add(table);
  550. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  551. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  552. elm_object_text_set(button, "<font_size = 50>sqrt</font_size>");
  553. evas_object_show(button);
  554. elm_table_pack(table, button, 1, 0, 1, 1);
  555.  
  556. /* Button */
  557. button = elm_button_add(table);
  558. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  559. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  560. elm_object_text_set(button, "<font_size = 50>%</font_size>");
  561. evas_object_show(button);
  562. elm_table_pack(table, button, 2, 0, 1, 1);
  563.  
  564. /* Button */
  565. button = elm_button_add(table);
  566. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  567. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  568. elm_object_text_set(button, "<font_size = 50>sin</font_size>");
  569. evas_object_show(button);
  570. elm_table_pack(table, button, 0, 1, 1, 1);
  571.  
  572. /* Button */
  573. button = elm_button_add(table);
  574. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  575. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  576. elm_object_text_set(button, "<font_size = 50>cos</font_size>");
  577. evas_object_show(button);
  578. elm_table_pack(table, button, 1, 1, 1, 1);
  579.  
  580. /* Button */
  581. button = elm_button_add(table);
  582. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  583. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  584. elm_object_text_set(button, "<font_size = 50>tan</font_size>");
  585. evas_object_show(button);
  586. elm_table_pack(table, button, 2, 1, 1, 1);
  587.  
  588. /* Button */
  589. button = elm_button_add(table);
  590. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  591. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  592. elm_object_text_set(button, "<font_size = 50>ln</font_size>");
  593. evas_object_show(button);
  594. elm_table_pack(table, button, 0, 2, 1, 1);
  595.  
  596. /* Button */
  597. button = elm_button_add(table);
  598. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  599. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  600. elm_object_text_set(button, "<font_size = 50>log</font_size>");
  601. evas_object_show(button);
  602. elm_table_pack(table, button, 1, 2, 1, 1);
  603.  
  604. /* Button */
  605. button = elm_button_add(table);
  606. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  607. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  608. elm_object_text_set(button, "<font_size = 50>1/x</font_size>");
  609. evas_object_show(button);
  610. elm_table_pack(table, button, 2, 2, 1, 1);
  611.  
  612. /* Button */
  613. button = elm_button_add(table);
  614. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  615. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  616. elm_object_text_set(button, "<font_size = 50>e^x</font_size>");
  617. evas_object_show(button);
  618. elm_table_pack(table, button, 0, 3, 1, 1);
  619.  
  620. /* Button */
  621. button = elm_button_add(table);
  622. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  623. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  624. elm_object_text_set(button, "<font_size = 50>X^2</font_size>");
  625. evas_object_show(button);
  626. elm_table_pack(table, button, 1, 3, 1, 1);
  627.  
  628. /* Button */
  629. button = elm_button_add(table);
  630. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  631. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  632. elm_object_text_set(button, "<font_size = 50>Y^x</font_size>");
  633. evas_object_show(button);
  634. elm_table_pack(table, button, 2, 3, 1, 1);
  635.  
  636. /* Button */
  637. button = elm_button_add(table);
  638. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  639. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  640. elm_object_text_set(button, "<font_size = 50>| X |</font_size>");
  641. evas_object_show(button);
  642. elm_table_pack(table, button, 0, 4, 1, 1);
  643.  
  644. /* Button */
  645. button = elm_button_add(table);
  646. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  647. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  648. elm_object_text_set(button, "<font_size = 50>PI</font_size>");
  649. evas_object_show(button);
  650. elm_table_pack(table, button, 1, 4, 1, 1);
  651.  
  652. /* Button */
  653. button = elm_button_add(table);
  654. evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  655. evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
  656. elm_object_text_set(button, "<font_size = 50>e</font_size>");
  657. evas_object_show(button);
  658. elm_table_pack(table, button, 2, 4, 1, 1);
  659.  
  660. evas_object_show(table);
  661.  
  662. return table;
  663. }
  664.  
  665. /*
  666. * @brief Function to create panel object
  667. * @param[in] parent The Evas object which panel object is created on
  668. * @param[in] ad The data structure to manage gui object
  669. * @param[out] Evas_Object The panel object which is created
  670. */
  671. static Evas_Object *
  672. create_panel(Evas_Object *parent, appdata_s *ad)
  673. {
  674. Evas_Object *panel, *grid;
  675.  
  676. /* Panel */
  677. panel = elm_panel_add(parent);
  678. elm_panel_orient_set(panel, ELM_PANEL_ORIENT_BOTTOM);
  679. evas_object_show(panel);
  680.  
  681. /* Grid */
  682. grid = elm_grid_add(panel);
  683. evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  684. evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
  685. elm_object_content_set(panel, grid);
  686.  
  687. /* Panel basic content */
  688. ad->basic_content = create_panel_basic_content(grid, ad);
  689. evas_object_size_hint_weight_set(ad->basic_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  690. evas_object_size_hint_align_set(ad->basic_content, EVAS_HINT_FILL, EVAS_HINT_FILL);
  691. elm_grid_pack(grid, ad->basic_content, 3, 3, 94, 94);
  692.  
  693. /* Panel advanced content */
  694. ad->advanced_content = create_panel_advanced_content(grid, ad);
  695. evas_object_size_hint_weight_set(ad->advanced_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  696. evas_object_size_hint_align_set(ad->advanced_content, EVAS_HINT_FILL, EVAS_HINT_FILL);
  697. elm_grid_pack(grid, ad->advanced_content, -100, -100, 94, 94);
  698.  
  699. return panel;
  700. }
  701.  
  702. /*
  703. * @brief Function to create entry
  704. * @param[in] parent The Evas object which entry object is created on
  705. * @param[out] Evas_Object The entry object which is created
  706. */
  707. static Evas_Object *
  708. create_entry(Evas_Object *parent)
  709. {
  710. Evas_Object *entry;
  711.  
  712. entry = elm_entry_add(parent);
  713. elm_entry_editable_set(entry, EINA_FALSE);
  714. elm_entry_entry_set(entry, "<font_size=50><align=right></font_size>");
  715. evas_object_show(entry);
  716.  
  717. return entry;
  718. }
  719.  
  720. /*
  721. * @brief Function to create base gui layout
  722. * @param[in] ad The data structure to manage gui object
  723. */
  724. static void
  725. create_base_gui(appdata_s *ad)
  726. {
  727. Evas_Object *grid, *panel;
  728.  
  729. ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
  730. elm_win_autodel_set(ad->win, EINA_TRUE);
  731.  
  732. if (elm_win_wm_rotation_supported_get(ad->win)) {
  733. int rots[4] = { 0, 90, 180, 270 };
  734. elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
  735. }
  736.  
  737. evas_object_smart_callback_add(ad->win, "wm,rotation,changed", rotation_cb, ad);
  738. evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
  739. eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
  740.  
  741. ad->bg = create_bg(ad->win);
  742. ad->conform = create_conform(ad->win);
  743. elm_win_conformant_set(ad->win, EINA_TRUE);
  744. elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
  745. elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE);
  746.  
  747. /* Grid */
  748. grid = elm_grid_add(ad->conform);
  749. evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
  750. evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
  751. elm_object_content_set(ad->conform, grid);
  752.  
  753. /* Entry */
  754. ad->entry = create_entry(grid);
  755. elm_grid_pack(grid, ad->entry, 5, 5, 90, 25);
  756.  
  757. /* Panel */
  758. panel = create_panel(grid, ad);
  759. elm_grid_pack(grid, panel, 0, 35, 100, 65);
  760.  
  761. /* Show window after base gui is set up */
  762. evas_object_show(ad->win);
  763. }
  764.  
  765. /*
  766. * @brief Hook to take necessary actions before main event loop starts
  767. * Initialize UI resources and application's data
  768. * If this function return true, the main loop of application starts
  769. * If this function return false, the application is terminated
  770. * @param[in] user_data The data to be passed to the callback function
  771. */
  772. static bool app_create(void *user_data)
  773. {
  774. /* Hook to take necessary actions before main event loop starts
  775. Initialize UI resources and application's data
  776. If this function returns true, the main loop of application starts
  777. If this function returns false, the application is terminated */
  778. appdata_s *ad = user_data;
  779.  
  780. create_base_gui(ad);
  781.  
  782. return true;
  783. }
  784.  
  785. /*
  786. * @brief This callback function is called when another application
  787. * sends the launch request to the application
  788. * @param[in] app_control The handle to the app_control
  789. * @param[in] user_data The data to be passed to the callback function
  790. */
  791. static void app_control(app_control_h app_control, void *user_data)
  792. {
  793. /* Handle the launch request. */
  794. }
  795.  
  796. /*
  797. * @brief This callback function is called each time
  798. * the application is completely obscured by another application
  799. * and becomes invisible to the user
  800. * @param[in] user_data The data to be passed to the callback function
  801. */
  802. static void app_pause(void *user_data)
  803. {
  804. /* Take necessary actions when application becomes invisible. */
  805. }
  806.  
  807. /*
  808. * @brief This callback function is called each time
  809. * the application becomes visible to the user
  810. * @param[in] user_data The data to be passed to the callback function
  811. */
  812. static void app_resume(void *user_data)
  813. {
  814. /* Take necessary actions when application becomes visible. */
  815. }
  816.  
  817. /*
  818. * @brief This callback function is called once after the main loop of the application exits
  819. * @param[in] user_data The data to be passed to the callback function
  820. */
  821. static void app_terminate(void *user_data)
  822. {
  823. /* Release all resources (*/
  824. appdata_s *ad;
  825.  
  826. if (!user_data)
  827. return;
  828.  
  829. ad = user_data;
  830.  
  831. if (ad->win)
  832. evas_object_del(ad->win);
  833. }
  834.  
  835. /*
  836. * @brief This function will be called when the language is changed
  837. * @param[in] event_info The system event information
  838. * @param[in] user_data The user data to be passed to the callback function
  839. */
  840. static void ui_app_lang_changed(app_event_info_h event_info, void *user_data)
  841. {
  842. /*APP_EVENT_LANGUAGE_CHANGED*/
  843. char *locale = NULL;
  844. system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
  845. elm_language_set(locale);
  846. free(locale);
  847. return;
  848. }
  849.  
  850. /*
  851. * @brief This function will be called when the orientation is changed
  852. * @param[in] event_info The system event information
  853. * @param[in] user_data The user data to be passed to the callback function
  854. */
  855. static void ui_app_orient_changed(app_event_info_h event_info, void *user_data)
  856. {
  857. /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
  858. return;
  859. }
  860.  
  861. /*
  862. * @brief This function will be called when the region is changed
  863. * @param[in] event_info The system event information
  864. * @param[in] user_data The user data to be passed to the callback function
  865. */
  866. static void ui_app_region_changed(app_event_info_h event_info, void *user_data)
  867. {
  868. /*APP_EVENT_REGION_FORMAT_CHANGED*/
  869. }
  870.  
  871. /*
  872. * @brief This function will be called when the battery is low
  873. * @param[in] event_info The system event information
  874. * @param[in] user_data The user data to be passed to the callback function
  875. */
  876. static void ui_app_low_battery(app_event_info_h event_info, void *user_data)
  877. {
  878. /*APP_EVENT_LOW_BATTERY*/
  879. }
  880.  
  881. /*
  882. * @brief This function will be called when the memory is low
  883. * @param[in] event_info The system event information
  884. * @param[in] user_data The user data to be passed to the callback function
  885. */
  886. static void ui_app_low_memory(app_event_info_h event_info, void *user_data)
  887. {
  888. /*APP_EVENT_LOW_MEMORY*/
  889. }
  890.  
  891. /*
  892. * @brief Main function of the application
  893. * @param[in] argc The argument count
  894. * @param[in] argv The argument vector
  895. */
  896. int main(int argc, char *argv[])
  897. {
  898. appdata_s ad = {0, };
  899. int ret;
  900.  
  901. ui_app_lifecycle_callback_s event_callback = {0, };
  902. app_event_handler_h handlers[5] = {NULL, };
  903.  
  904. event_callback.create = app_create;
  905. event_callback.terminate = app_terminate;
  906. event_callback.pause = app_pause;
  907. event_callback.resume = app_resume;
  908. event_callback.app_control = app_control;
  909.  
  910. ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad);
  911. ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
  912. ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
  913. ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
  914. ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
  915. ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
  916.  
  917. ret = ui_app_main(argc, argv, &event_callback, &ad);
  918. if (ret != APP_ERROR_NONE)
  919. dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_main() is failed. err = %d", ret);
  920.  
  921. return ret;
  922. }