3 * Copyright 2012 Samsung Electronics Co., Ltd
5 * Licensed under the Flora License, Version 1.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.tizenopensource.org/license
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #ifndef __DEF_CALCULATOR_H_
20 #define __DEF_CALCULATOR_H_
22 #include <Elementary.h>
32 #define PACKAGE "calculator"
33 #define LAYOUT_EDJ_NAME EDJDIR"/calculator.edj"
34 #define CALCULATOR_THEME EDJDIR"/calculator_theme.edj"
36 #define GRP_MAIN "main"
37 #define GRP_POR_PANNEL "por_pannel"
38 #define GRP_LAN_PANNEL "lan_pannel"
39 #define GRP_APPINAPP_MAIN "appinapp.main"
40 #define GRP_MINI_PANNEL "mini_pannel"
41 #define GRP_MINI_TITLE "mini/title"
42 //#define COM_SAMSUNG_S "com.samsung.%s"
47 #define MAX_FONT_SIZE 44
48 #define NUMBER_LENGTH 1024
49 #define MAX_EXPRESSION_LENGTH 1024
50 #define MAX_RESULT_LENGTH 1024
51 #define MAX_ERROR_MESSAGE_LENGTH 256
53 //#define MAX_TAG_EXPRESSION_LENGTH 4096
54 #define MAX_TAG_EXPRESSION_LENGTH 420*48
56 //#define MAX_RESULT_LENGTH 128
58 #define MAX_HISTORY_NUM 10
59 #define MAX_DECIMAL_NUM 5
60 #define MAX_NUM_LENGTH 15
61 #define MAX_OPERATOR_NUM 20
62 #define MAX_PARENTHESES_NUM 64
65 #define PI 3.1415926535897932384626433832795
66 #define EXPONENT 2.718281828459045235360287471352662497757
67 #define RADIAN_FACTOR (PI/180)
68 #define DEGREEN_FACTOR (180/PI)
69 #define PI_STR "3.1415926535897932384626433832795"
70 #define EXPONENT_STR "2.718281828459045235360287471352662497757"
74 #define _EDJ(x) (Evas_Object *)elm_layout_edje_get(x)
78 #define _(str) gettext(str)
82 #define gettext_noop(str) (str)
83 #endif /* gettext_noop */
86 #define N_(str) gettext_noop(str)
95 #define CALCULATOR_CONTENT_LEN 32
97 #define CALCULATOR_MAX_RESULT_SUM2 (10e+100) /**<maximum num of result sum*/
98 #define CALCULATOR_MIN_RESULT_SUM2 (-10e+100) /**<minimum num of result sum*/
100 /* BEGIN DEBUG LOG MACRO */
104 #define LOG_TAG "CALCULATOR"
106 #define CALC_INFO(fmt, arg...) LOGD("[%s:%d] "fmt,__FILE__, __LINE__, ##arg);
107 #define FONT_COLOR_RESET "\033[0m"
108 #define FONT_COLOR_RED "\033[31m"
109 #define FONT_COLOR_GREEN "\033[32m"
110 #define FONT_COLOR_YELLOW "\033[33m"
111 #define FONT_COLOR_BLUE "\033[34m"
112 #define FONT_COLOR_PURPLE "\033[35m"
113 #define FONT_COLOR_CYAN "\033[36m"
114 #define FONT_COLOR_GRAY "\033[37m"
116 #define CALC_INFO_RED(fmt, arg...) CALC_INFO(FONT_COLOR_RED fmt FONT_COLOR_RESET, ##arg)
117 #define CALC_INFO_GREEN(fmt, arg...) CALC_INFO(FONT_COLOR_GREEN fmt FONT_COLOR_RESET, ##arg)
118 #define CALC_INFO_YELLOW(fmt, arg...) CALC_INFO(FONT_COLOR_YELLOW fmt FONT_COLOR_RESET, ##arg)
119 #define CALC_INFO_BLUE(fmt, arg...) CALC_INFO(FONT_COLOR_BLUE fmt FONT_COLOR_RESET, ##arg)
120 #define CALC_INFO_PURPLE(fmt, arg...) CALC_INFO(FONT_COLOR_PURPLE fmt FONT_COLOR_RESET, ##arg)
121 #define CALC_INFO_CYAN(fmt, arg...) CALC_INFO(FONT_COLOR_CYAN fmt FONT_COLOR_RESET, ##arg)
122 #define CALC_INFO_GRAY(fmt, arg...) CALC_INFO(FONT_COLOR_GRAY fmt FONT_COLOR_RESET, ##arg)
125 //#define PERFORMANCE_LOG
126 #ifdef PERFORMANCE_LOG
127 #define DBG(fmt, arg...) SLOGD("%s(%d) " fmt, __FUNCTION__, __LINE__, ##arg)
128 #define CALC_FUN_BEG() DBG("START")
129 #define CALC_FUN_END() DBG("END")
131 #define CALC_FUN_BEG() LOG(LOG_DEBUG,"LAUNCH","[calculator:Application:%s:IN]", __FUNCTION__);
132 #define CALC_FUN_END() LOG(LOG_DEBUG,"LAUNCH","[calculator:Application:%s:OUT]", __FUNCTION__);
135 /* Help String of UI Guideline */
136 #define CALC_MSG_MAX_DIGIT _("IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE")
137 #define CALC_MSG_MAX_DEC_DIGIT _("IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE")
138 #define CALC_MSG_MAX_OP _("IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE")
139 #define CALC_MSG_DIVIDE_BY_ZERO _("IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO")
140 #define CALC_MSG_NUM_FIRST _("IDS_CCL_POP_NO_NUMBER_ERROR")
141 #define CALC_MSG_OUT_OF_RANGE _("IDS_CCL_POP_ERROR")
142 #define CALC_MSG_NUM_AFTER_OP _("IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR")
143 #define CALC_MSG_INVALID_SQUARE _("IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION")
144 #define CALC_MSG_INVALID_LOG _("IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION")
145 #define CALC_MSG_INVALID_FAC _("IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION")
146 #define CALC_MSG_NUM_FIRST_FAC _("IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION")
147 #define CALC_MSG_NUM_FIRST_RECIP _("IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION")
148 #define CALC_MSG_NUM_FIRST_X2 _("IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION")
149 #define CALC_MSG_NUM_FIRST_XY _("IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION")
151 /* Custtom Error Message */
152 #define CALC_MSG_OP_FIRST _("IDS_CCL_POP_NO_OPERATOR_ERROR")
153 #define CALC_MSG_SYNTAX_ERROR _("IDS_CCL_POP_SYNTAX_ERROR")
154 #define CALC_MSG_WRONG_FORMAT _("IDS_CCL_POP_INPUT_ERROR")
156 #define CALC_MSG_CLEAR_HISTTORY _("IDS_CCL_OPT_CLEAR_HISTORY")
157 #define CALC_MSG_MINIMISE _("IDS_CCL_OPT_MINIMISE")
158 #define CALC_MSG_MINIMODE_TITLE _("IDS_CCL_BODY_CALCULATOR")
161 #define CALC_MSG_INVALID_LN _("Invalid input for ln function")
162 #define CALC_MSG_INVALID_XY _("Invalid param for x^y")
163 #define CALC_MSG_INVALID_TAN _("Invalid param for tan")
164 #define CALC_MSG_ENTRY_LIMIT _("Already had decimal in digit")
166 #define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
169 #define DESKTOP_MODE_ICON "/opt/share/icons/default/small/com.samsung.calculator.png"
172 Evas_Object *win; //main window
174 Evas_Object *conform;
179 Evas_Object *input_scroller;
180 Evas_Object *input_entry;
181 Evas_Object *por_pannel;
182 Evas_Object *lan_pannel;
183 Evas_Object *back_btn;
185 Ecore_Timer *calc_timer;
186 Ecore_Timer *wrong_timer;
189 Elm_Object_Item *navi_it;
190 Evas_Object *more_btn;
191 Evas_Object *more_btn_popup;
192 Elm_Object_Item *clear_item;
194 Evas_Object *hist_scroll;
195 Evas_Object *hist_area;
196 Eina_Bool panel_show;
198 Evas_Object *window_icon; //only show it when in desktop mode;
203 * Load edj file from group to elm_layout.
211 Evas_Object *load_edj(Evas_Object * parent, const char *file,
213 void _calc_entry_clear(Evas_Object * entry);
215 #endif /* __DEF_CALCULATOR_H__ */