--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(calculator C)
+
+SET(SRCS
+ src/calc-main.c
+ src/calculator_edje.c
+ src/calculator_parser.c
+ src/calc-expression.c
+ src/calc-string.c
+ src/calc-view.c)
+
+SET(ORG "org")
+SET(VENDOR "tizen")
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "${ORG}.${VENDOR}.${PACKAGE}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+#SET(INSTALL_DIR_APPS "/opt/apps/${PKGNAME}")
+SET(INSTALL_DIR_PRE "/opt")
+
+SET(BINDIR "${PREFIX}/bin")
+SET(RESDIR "${PREFIX}/res")
+SET(DATADIR "${PREFIX}/data")
+SET(LOCALEDIR "${RESDIR}/locale")
+SET(ICONDIR "${RESDIR}/icons")
+SET(DESKTOPICONDIR "${ICONDIR}/default/small")
+SET(EDJDIR "${RESDIR}/edje")
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED elementary utilX
+ dlog svi evas edje
+ ecore-x ecore ecore-input capi-appfw-application
+)
+
+FIND_LIBRARY(LIB_M m)
+
+# Apply Public emulator image
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+ INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.calculator.png DESTINATION ${ICONDIR})
+ MESSAGE("install confidential icon ...")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS(${pkgs_CFLAGS})
+ADD_DEFINITIONS("-fpie")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-DSLP_PROF")
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+
+ADD_DEFINITIONS("-DINSTALL_DIR_APPS=\"${INSTALL_DIR_APPS}\"")
+ADD_DEFINITIONS("-DBINDIR=\"${BINDIR}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DICONDIR=\"${ICONDIR}\"")
+ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"")
+
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-pie" ${LIB_M})
+
+ADD_CUSTOM_TARGET(calculator.edj
+ COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/images
+ ${CMAKE_SOURCE_DIR}/calculator.edc ${CMAKE_BINARY_DIR}/calculator.edj
+ DEPENDS ${CMAKE_SOURCE_DIR}/calculator.edc
+)
+ADD_DEPENDENCIES(${PROJECT_NAME} calculator.edj)
+
+ADD_CUSTOM_TARGET(calculator_theme.edj
+ COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/theme
+ ${CMAKE_SOURCE_DIR}/theme/calculator_theme.edc ${CMAKE_BINARY_DIR}/theme/calculator_theme.edj
+ DEPENDS ${CMAKE_SOURCE_DIR}/theme/calculator_theme.edc
+)
+ADD_DEPENDENCIES(${PROJECT_NAME} calculator_theme.edj)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION
+${BINDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/calculator.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/theme/calculator_theme.edj DESTINATION
+${EDJDIR})
+
+# install application HOME directory
+INSTALL(DIRECTORY DESTINATION ${DATADIR})
+
+# process setting
+install(FILES ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.ini DESTINATION /opt/share/process-info )
+
+ADD_SUBDIRECTORY(po)
+
+# desktop icon
+set(PREFIX ${CMAKE_INSTALL_PREFIX})
+configure_file(org.tizen.calculator.desktop.in org.tizen.calculator.desktop)
+install(FILES ${CMAKE_SOURCE_DIR}/org.tizen.calculator.desktop DESTINATION
+/opt/share/applications)
+install(FILES ${CMAKE_SOURCE_DIR}/org.tizen.calculator.png DESTINATION ${DESKTOPICONDIR})
--- /dev/null
+Flora License
+
+Version 1.0, May, 2012
+
+http://www.tizenopensource.org/license
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies with the standards set forth in the Compatibility Definition Document and passes the Compatibility Test Suite as defined from time to time by the Tizen Technical Steering Group and certified by the Tizen Association or its designated agent.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work solely as incorporated into a Tizen Certified Platform, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work solely as incorporated into a Tizen Certified Platform to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof pursuant to the copyright license above, in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+ 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+ 2. You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+ 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+
+ 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Flora License, Version 1.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.tizenopensource.org/license
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include "edc/edc-macro.edc"
+
+#define WIDTH 720
+#define HEIGHT 1280
+#define WIDTH_LAN 1280
+#define HEIGHT_LAN 720
+#define WIDTH_POR 720
+#define HEIGHT_POR 1280
+images {
+ /*portrait*/
+
+ image: "images/P04_calculator_bg.png" COMP;
+ image: "images/P04_calculator_keypad_bg.png" COMP;
+ image: "images/P04_calculator_btn_01.png" COMP;
+ image: "images/P04_calculator_btn_01_press.png" COMP;
+ image: "images/P04_calculator_btn_02.png" COMP;
+ image: "images/P04_calculator_btn_02_press.png" COMP;
+ image: "images/P04_calculator_btn_03.png" COMP;
+ image: "images/P04_calculator_btn_03_press.png" COMP;
+ image: "images/P04_calculator_btn_04.png" COMP;
+ image: "images/P04_calculator_btn_04_press.png" COMP;
+ image: "images/P04_calculator_btn_05.png" COMP;
+ image: "images/P04_calculator_btn_05_press.png" COMP;
+ image: "images/P04_calculator_btn_06.png" COMP;
+ image: "images/P04_calculator_btn_06_press.png" COMP;
+ image: "images/P04_calculator_btn_07.png" COMP;
+ image: "images/P04_calculator_btn_07_press.png" COMP;
+ image: "images/P04_calculator_btn_08.png" COMP;
+ image: "images/P04_calculator_btn_08_press.png" COMP;
+ image: "images/P04_calculator_btn_09.png" COMP;
+ image: "images/P04_calculator_btn_09_press.png" COMP;
+ image: "images/P04_calculator_btn_10.png" COMP;
+ image: "images/P04_calculator_btn_10_press.png" COMP;
+ image: "images/P04_calculator_btn_n00.png" COMP;
+ image: "images/P04_calculator_btn_n00_press.png" COMP;
+ image: "images/P04_calculator_btn_n01.png" COMP;
+ image: "images/P04_calculator_btn_n01_press.png" COMP;
+ image: "images/P04_calculator_btn_n02.png" COMP;
+ image: "images/P04_calculator_btn_n02_press.png" COMP;
+ image: "images/P04_calculator_btn_n03.png" COMP;
+ image: "images/P04_calculator_btn_n03_press.png" COMP;
+ image: "images/P04_calculator_btn_n04.png" COMP;
+ image: "images/P04_calculator_btn_n04_press.png" COMP;
+ image: "images/P04_calculator_btn_n05.png" COMP;
+ image: "images/P04_calculator_btn_n05_press.png" COMP;
+ image: "images/P04_calculator_btn_n06.png" COMP;
+ image: "images/P04_calculator_btn_n06_press.png" COMP;
+ image: "images/P04_calculator_btn_n07.png" COMP;
+ image: "images/P04_calculator_btn_n07_press.png" COMP;
+ image: "images/P04_calculator_btn_n08.png" COMP;
+ image: "images/P04_calculator_btn_n08_press.png" COMP;
+ image: "images/P04_calculator_btn_n09.png" COMP;
+ image: "images/P04_calculator_btn_n09_press.png" COMP;
+
+ image: "images/P04_calculator_down_arrow.png" COMP;
+ image: "images/P04_calculator_up_arrow.png" COMP;
+ // image: "P04_calculator_up_arrow.png" COMP;
+
+ image: "images/P04_calculator_input_bg.png" COMP;
+ image: "images/P04_calculator_input_bg_02.png" COMP;
+
+ image: "images/P04_calculator_button_clear.png" COMP;
+ image: "images/P04_calculator_button_clear_dim.png" COMP;
+ image: "images/P04_calculator_button_clear_focus.png" COMP;
+ image: "images/P04_calculator_button_clear_press.png" COMP;
+
+ }
+collections {
+ #include "edc/Inc.calculator.main.edc"
+ #include "edc/Inc.calculator.pannel.por.edc"
+}
--- /dev/null
+[ProcessSetting]
+BG_SCHEDULE=true
+
--- /dev/null
+calculator (0.1.3-59) unstable; urgency=low
+
+ * Fix the bug that calculate wrong ,such as (2+2)9
+ * Git: apps/c/calculator
+ * Tag: calculator_0.1.3-59
+
+ -- Goo Lee <goo81.lee@samsung.com> Mon, 1 Apr 2012 17:24:22 +0900
--- /dev/null
+Source: calculator
+Section: devel
+Priority: extra
+Maintainer: Zhao Danni <danni.zhao@samsung.com>, Yang Qing <qing_.yang@samsung.com>, Zhou Zhibin <zhibin.zhou@samsung.com>
+Uploaders:
+Build-Depends: debhelper (>= 5), libelm-dev, libslp-utilx-dev, dlog-dev, libsvi-dev, libevas-dev, libedje-dev, capi-appfw-application-dev
+Standards-Version: 0.1.0
+
+Package: org.tizen.calculator
+Section: utils
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Calculator application
+
+Package: org.tizen.calculator-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Calculator application
+
--- /dev/null
+usr/bin
+usr/sbin
--- /dev/null
+CMakeLists.txt
--- /dev/null
+@PREFIX@/bin/*
+@PREFIX@/res/edje/*
+@PREFIX@/res/icons/*
+@PREFIX@/res/locale/*
+@PREFIX@/data
+/opt/share/applications/*
+/opt/share/process-info/*
+
--- /dev/null
+#!/bin/sh
+if [ ${USER} == "root" ]
+then
+ # 5000 is inhouse user id
+ # do not use relative path
+ chown -R 5000:5000 /opt/apps/org.tizen.calculator/data
+fi
+
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS += -Wall -g
+CXXFLAGS ?= -Wall -g
+LDFLAGS ?=
+PREFIX ?= /opt/apps/org.tizen.calculator
+DATADIR ?= /opt/apps/org.tizen.calculator/res
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+ CXXFLAGS += -O0
+else
+ CFLAGS += -O2
+ CXXFLAGS += -O2
+endif
+
+CFLAGS += -fPIC
+CXXFLAGS += -fPIC
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--hash-style=both
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+ touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE)
+ #docbook-to-man debian/wavplayer.sgml > wavplayer.1
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) clean
+ rm -rf CMakeCache.txt
+ rm -rf CMakeFiles
+ rm -rf cmake_install.cmake
+ rm -rf Makefile
+ rm -rf install_manifest.txt
+ rm -rf org.tizen.calculator.desktop
+
+ rm -rf po/CMakeCache.txt
+ rm -rf po/CMakeFiles
+ rm -rf po/cmake_install.cmake
+ rm -rf po/Makefile
+ rm -rf po/install_manifest.txt
+
+ rm -rf *.so
+ rm -rf *.edj
+ rm -rf theme/*.edj
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/wavplayer.
+ $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+# dh_strip --dbg-package=org.tizen.calculator-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define PADDING_TOP_POR 60
+#define PADDING_BOTTOM_POR 50
+#define PADDING_LEFT_POR 24
+#define PADDING_RIGHT_POR 24
+
+
+group {
+ name: "main";
+
+ script {
+ public result_show;
+ }
+
+ parts {
+ /* background */
+ //EDC_PART_BG("bg")
+ part {
+ name: "head";
+ type: RECT;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0;}
+ rel2 { relative: 1.0 50/1280;}
+ color: 0 0 0 255;
+ }
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 0.0;}
+ rel2 { relative: 0.0 0.0;}
+ color: 0 0 0 255;
+ }
+ }
+ part {
+ name: "bg";
+ type: RECT;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: 0.0 50/1280;}
+ rel2 { relative: 1.0 (1.0+1.0/1280);}
+ color: 0 0 0 0;
+ }
+ }
+ //EDC_PART_IMAGE("bg_img", "bg", EDC_IMAGE("images/59_calculator_bg.png")) /* DON'T REMOVE */
+ EDC_PART_IMAGE("bg_img", "bg", EDC_IMAGE("images/P04_calculator_bg.png"))
+
+ EDC_PART_PADDING_BR("entry_img_pad_br_por", EDC_SIZE(PADDING_RIGHT_POR, 0), "bg")
+
+ /* Input Entry */
+ part {
+ name: "entry/rect";
+ type: IMAGE;
+ mouse_events: 1;
+ scale: 1;
+
+ description {
+ state: "default" 0.0;
+ visible: 1;
+ min: 0 252;
+ fixed: 0 1;
+ align: 0.5 0;
+ rel1 {relative: 24/720 110/1280;}
+ rel2 {relative: (720-24)/720 (50+60+252)/1280;}
+ image {
+ normal: "images/P04_calculator_input_bg.png";
+ border: 24 24 79 24;
+ border_scale: 1;
+ }
+ }
+ }
+
+ EDC_PART_PADDING_TL("entry_swl_pad_tl_por", EDC_SIZE(32, 38), "entry/rect")
+ EDC_PART_PADDING_BR("entry_swl_pad_br_por", EDC_SIZE(32, 46), "entry/rect")
+
+ part {
+ name: "input/entry";
+ type: SWALLOW;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ visible: 1;
+ rel1 {relative: 1.0 1.0; to: "entry_swl_pad_tl_por";}
+ rel2 {relative: 0.0 0.0; to: "entry_swl_pad_br_por";}
+ }
+ }
+
+ /* History Entry */
+ part {
+ name: "history_rect_padding_br";
+ type: RECT;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 {relative: 24/720 (1280-61)/1280;}
+ rel2 {relative: (720-24)/720 1.0;}
+ color: 0 0 0 0;
+ }
+ }
+ part {
+ name: "history/rect";
+ type: IMAGE;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ rel1 { relative: 0.0 0.0; to: "entry/rect";}
+ rel2 {
+ relative: 1.0 0.0;
+ to_x: "entry/rect";
+ to_y: "history_rect_padding_br";
+ }
+ image {
+ normal: "images/P04_calculator_input_bg.png";
+ border: 24 24 79 24;
+ border_scale: 1;
+ }
+ }
+ description {
+ state: "show" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ image {
+ normal: "images/P04_calculator_input_bg_02.png";
+ border: 24 24 79 24;
+ border_scale: 1;
+ }
+ }
+ }
+
+ EDC_PART_RECT_PADDING("history/rect2", "history/rect",
+ EDC_COOR(32, 32), EDC_COOR(32, 42))
+ EDC_PART_SWALLOW_HIDE_SHOW("history/scroll", "history/rect2")
+
+ /* Keypad */
+ EDC_PART_SWALLOW_SHOW_HIDE("por_pannel/rect", "bg")
+ EDC_PART_SWALLOW_SHOW_HIDE("lan_pannel/rect", "bg")
+
+ part {
+ name: "history/clear/image";
+ type: IMAGE;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+
+ rel1 { relative: 0.0 0.0; to: "history/rect"; offset: 32 38;}
+ rel2 { relative: 0.0 0.0; to: "history/rect"; offset: 96 102;}
+ image {
+ normal: "images/P04_calculator_button_clear_dim.png";
+ // border: 24 24 79 24;
+ // border_scale: 1;
+ }
+ }
+ description {
+ state: "up" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ image {
+ normal: "images/P04_calculator_button_clear_dim.png";
+
+ }
+ }
+
+ description {
+ state: "press" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ image {
+ normal: "images/P04_calculator_button_clear_press.png";
+
+ }
+ }
+ }
+
+ }
+
+ programs {
+ program {
+ name: "group_load";
+ signal: "load";
+ script {
+ set_int(result_show, 0);
+ }
+ }
+
+ program {
+ name: "show_history";
+ signal: "show,hist";
+ source: "";
+ script {
+ set_state(PART:"history/scroll", "show", 0.0);
+ set_state(PART:"history/rect", "show", 0.0);
+ set_state(PART:"history/clear/image", "up", 0.0);
+
+ }
+ }
+ program {
+ name: "hide_history";
+ signal: "hide,hist";
+ source: "";
+ script {
+ set_state(PART:"history/scroll", "default", 0.0);
+ set_state(PART:"history/rect", "default", 0.0);
+ set_state(PART:"history/clear/image", "default", 0.0);
+
+ }
+ }
+ program {
+ name: "to_portrait";
+ signal: "portrait";
+ source: "";
+ script {
+ set_state(PART:"entry/rect", "default", 0.0);
+ set_state(PART:"input/entry", "default", 0.0);
+ set_state(PART:"lan_pannel/rect", "hide", 0.0);
+ set_state(PART:"por_pannel/rect", "default", 0.0);
+ set_state(PART:"bg_img", "default", 0.0);
+ set_state(PART:"bg", "default", 0.0);
+ set_state(PART:"head", "default", 0.0);
+ }
+ }
+
+ program {
+ name: "clear_click";
+ signal: "mouse,clicked,1";
+ source: "history/clear/image";
+ action: SIGNAL_EMIT "clicked" "";
+ }
+ program {
+ name: "clear_click1";
+ signal: "mouse,down,1";
+ source: "history/clear/image";
+ action: STATE_SET "press" 0.0;
+ target: "history/clear/image";
+ }
+ program {
+ name: "clear_click2";
+ signal: "mouse,up,1";
+ source: "history/clear/image";
+ action: STATE_SET "up" 0.0;
+ target: "history/clear/image";
+ }
+
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define PANNEL_W_POR 720
+#define PANNEL_H_POR (807+61) //558
+#define PANNEL_FULL_W_POR 720
+//#define PANNEL_FULL_H_POR 584
+#define PANNEL_FULL_H_POR 857
+
+#define PANNEL_X_LOFF_POR 24
+#define PANNEL_Y_LOFF_POR 50//???
+
+#define PANNEL_KEY_W_PAD_POR 16
+#define PANNEL_KEY_H_PAD_POR 18
+#define PANNEL_KEY_W_POR 156
+#define PANNEL_KEY_H_POR 147
+#define PANNEL_KEY_FULL_W_POR (PANNEL_KEY_W_POR+PANNEL_KEY_W_PAD_POR)
+#define PANNEL_KEY_FULL_H_POR (PANNEL_KEY_H_POR+PANNEL_KEY_H_PAD_POR)
+
+#define PANNEL_COR_POR_REF1_X(X,Y) ((PANNEL_X_LOFF_POR+PANNEL_KEY_FULL_W_POR*(Y))/PANNEL_W_POR)
+#define PANNEL_COR_POR_REF1_Y(X,Y) ((PANNEL_Y_LOFF_POR+PANNEL_KEY_FULL_H_POR*(X))/PANNEL_FULL_H_POR)
+#define PANNEL_COR_POR_REF2_X(X,Y) ((PANNEL_X_LOFF_POR+PANNEL_KEY_FULL_W_POR*(Y)+PANNEL_KEY_W_POR)/PANNEL_W_POR)
+#define PANNEL_COR_POR_REF2_Y(X,Y) ((PANNEL_Y_LOFF_POR+PANNEL_KEY_FULL_H_POR*(X)+PANNEL_KEY_H_POR)/PANNEL_FULL_H_POR)
+
+#define KEYPAD_KEY_IMG(key_name, relx1, rely1, relx2, rely2, bg_img, bg_img_press, text_img, text_img_press, to_part) \
+ EDC_PART_RECT_RELATIVE(key_name, to_part, relx1, rely1, relx2, rely2)\
+ EDC_PART_BUTTON_IMG(key_name"_bg", key_name, EDC_IMAGE(bg_img), EDC_IMAGE(bg_img))\
+ EDC_PART_BUTTON_IMG(key_name"_txt", key_name, EDC_IMAGE(text_img), EDC_IMAGE(text_img_press))
+
+#define KEYPAD_KEY_TXT(key_name, relx1, rely1, relx2, rely2, bg_img, bg_img_press, text_txt, text_txt_press, to_part) \
+ EDC_PART_RECT_RELATIVE(key_name, to_part, relx1, rely1, relx2, rely2)\
+ EDC_PART_BUTTON_IMG(key_name"_bg", key_name, EDC_IMAGE(bg_img), EDC_IMAGE(bg_img)))\
+ EDC_PART_TEXT(key_name"_txt", key_name, SHADOW, \
+ EDC_TEXT_SHADOW(text_txt, 67, "SLP:style=Medium", EDC_COLOR(255,255,255,255), EDC_COLOR(0,0,0,255)))\
+
+
+#define KEYPAD_KEY_PROG(key_name) \
+ program { \
+ name: "mouse_down_"key_name; \
+ signal: "mouse,down,1"; \
+ source: key_name; \
+ action: STATE_SET "pressed" 0.0; \
+ target: key_name"_bg"; \
+ target: key_name"_txt"; \
+ } \
+ program { \
+ name: "mouse_up_"key_name; \
+ signal: "mouse,up,1"; \
+ source: key_name; \
+ action: STATE_SET "default" 0.0; \
+ target: key_name"_bg"; \
+ target: key_name"_txt"; \
+ }
+
+///////////////////// prtrait pannel ////////////////////////////////////////
+ group {
+ name: "por_pannel";
+ script {
+ public pannel_state;
+ }
+
+ parts {
+ part {
+ name: "por_pannel/in";
+ type: RECT;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ visible: 0;
+ rel1 { relative: 0.0 (60+252)/(1280-50));}
+ rel2 { relative: 1.0 (1280-61)/1280; }
+ }
+ description {
+ state: "down" 0.0;
+ inherit: "default" 0.0;
+ rel1 { relative: 0.0 1.0; offset: 0 0;}
+ rel2 { relative: 1.0 1.0; offset: 0 PANNEL_H_POR;}
+ }
+ }
+ part {
+ name: "por_pannel/BG";
+ type: IMAGE;
+ mouse_events: 1;
+ description {
+ state: "default" 0.0;
+ visible: 1;
+ rel1 { relative: 0.0 (60+50+252)/(1280-50);}
+ rel2 { relative: 1.0 1.0; }
+ image { normal: "images/P04_calculator_keypad_bg.png"; }
+ }
+ description {
+ state: "down" 0.0;
+ inherit: "default" 0.0;
+ rel1 { relative: 0.0 1.0; offset: 0 0;}
+ rel2 { relative: 1.0 1.0; offset: 0 PANNEL_H_POR;}
+ image { normal: "images/P04_calculator_keypad_bg.png"; }
+ }
+ }
+
+ /* close&open icon */
+ part {
+ name: "pannel/icon";
+ type: IMAGE;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: (24+32+291)/720 (60+50+252-16-6-20)/1280;}
+ rel2 { relative: (24+32+291+26)/720 (60+50+252-6-20)/1280;}
+ image { normal: "images/P04_calculator_down_arrow.png"; }
+ }
+ description {
+ state: "open" 0.0;
+ inherit: "default" 0.0;
+ rel1 { relative: (24+32+291)/720 (1280-61-16-6-8)/1280;}
+ rel2 { relative: (24+32+291+26)/720 (1280-61-6-8)/1280;}
+ image { normal: "images/P04_calculator_up_arrow.png"; }
+ }
+ }
+ part {
+ name: "pannel/icon/rect";
+ type: RECT;
+ mouse_events: 0;
+ description {
+ state: "default" 0.0;
+ rel1 { relative: (24+32+291-50)/720 (60+50+252-16-6-75)/1280;}
+ rel2 { relative: (24+32+291+26+50)/720 (60+50+252-6+75)/1280;}
+ color: 0 0 0 0;
+ }
+ description {
+ state: "open" 0.0;
+ inherit: "default" 0.0;
+ rel1 { relative: (24+32+291-50)/720 (1280-61-6-16-75)/1280;}
+ rel2 { relative: (24+32+291+26+50)/720 (1280-61-6+75)/1280;}
+ }
+ }
+
+
+ /* create pannel keys */
+ // c, /, *, <-
+ KEYPAD_KEY_IMG("item_c",
+ PANNEL_COR_POR_REF1_X(0,0), PANNEL_COR_POR_REF1_Y(0,0),
+ PANNEL_COR_POR_REF2_X(0,0), PANNEL_COR_POR_REF2_Y(0,0),
+ "images/P04_calculator_btn_01.png", "images/P04_calculator_btn_01_press.png",
+ "images/P04_calculator_btn_01.png", "images/P04_calculator_btn_01_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_div",
+ PANNEL_COR_POR_REF1_X(0,1), PANNEL_COR_POR_REF1_Y(0,1),
+ PANNEL_COR_POR_REF2_X(0,1), PANNEL_COR_POR_REF2_Y(0,1),
+ "images/P04_calculator_btn_02.png", "images/P04_calculator_btn_02_press.png",
+ "images/P04_calculator_btn_02.png", "images/P04_calculator_btn_02_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_mul",
+ PANNEL_COR_POR_REF1_X(0,2), PANNEL_COR_POR_REF1_Y(0,2),
+ PANNEL_COR_POR_REF2_X(0,2), PANNEL_COR_POR_REF2_Y(0,2),
+ "images/P04_calculator_btn_03.png", "images/P04_calculator_btn_03_press.png",
+ "images/P04_calculator_btn_03.png", "images/P04_calculator_btn_03_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_del",
+ PANNEL_COR_POR_REF1_X(0,3), PANNEL_COR_POR_REF1_Y(0,3),
+ PANNEL_COR_POR_REF2_X(0,3), PANNEL_COR_POR_REF2_Y(0,3),
+ "images/P04_calculator_btn_04.png", "images/P04_calculator_btn_04_press.png",
+ "images/P04_calculator_btn_04.png", "images/P04_calculator_btn_04_press.png",
+ "por_pannel/in");
+
+
+ // 1, 2, 3, -
+ KEYPAD_KEY_IMG("item_num1",
+ PANNEL_COR_POR_REF1_X(1,0), PANNEL_COR_POR_REF1_Y(1,0),
+ PANNEL_COR_POR_REF2_X(1,0), PANNEL_COR_POR_REF2_Y(1,0),
+ "images/P04_calculator_btn_n01.png", "images/P04_calculator_btn_n01_press.png",
+ "images/P04_calculator_btn_n01.png", "images/P04_calculator_btn_n01_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_num2",
+ PANNEL_COR_POR_REF1_X(1,1), PANNEL_COR_POR_REF1_Y(1,1),
+ PANNEL_COR_POR_REF2_X(1,1), PANNEL_COR_POR_REF2_Y(1,1),
+ "images/P04_calculator_btn_n02.png", "images/P04_calculator_btn_n02_press.png",
+ "images/P04_calculator_btn_n02.png", "images/P04_calculator_btn_n02_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_num3",
+ PANNEL_COR_POR_REF1_X(1,2), PANNEL_COR_POR_REF1_Y(1,2),
+ PANNEL_COR_POR_REF2_X(1,2), PANNEL_COR_POR_REF2_Y(1,2),
+ "images/P04_calculator_btn_n03.png", "images/P04_calculator_btn_n03_press.png",
+ "images/P04_calculator_btn_n03.png", "images/P04_calculator_btn_n03_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_sub",
+ PANNEL_COR_POR_REF1_X(1,3), PANNEL_COR_POR_REF1_Y(1,3),
+ PANNEL_COR_POR_REF2_X(1,3), PANNEL_COR_POR_REF2_Y(1,3),
+ "images/P04_calculator_btn_05.png", "images/P04_calculator_btn_05_press.png",
+ "images/P04_calculator_btn_05.png", "images/P04_calculator_btn_05_press.png",
+ "por_pannel/in");
+
+
+ // 4, 5 ,6, +
+ KEYPAD_KEY_IMG("item_num4",
+ PANNEL_COR_POR_REF1_X(2,0), PANNEL_COR_POR_REF1_Y(2,0),
+ PANNEL_COR_POR_REF2_X(2,0), PANNEL_COR_POR_REF2_Y(2,0),
+ "images/P04_calculator_btn_n04.png", "images/P04_calculator_btn_n04_press.png",
+ "images/P04_calculator_btn_n04.png", "images/P04_calculator_btn_n04_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_num5",
+ PANNEL_COR_POR_REF1_X(2,1), PANNEL_COR_POR_REF1_Y(2,1),
+ PANNEL_COR_POR_REF2_X(2,1), PANNEL_COR_POR_REF2_Y(2,1),
+ "images/P04_calculator_btn_n05.png", "images/P04_calculator_btn_n05_press.png",
+ "images/P04_calculator_btn_n05.png", "images/P04_calculator_btn_n05_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_num6",
+ PANNEL_COR_POR_REF1_X(2,2), PANNEL_COR_POR_REF1_Y(2,3),
+ PANNEL_COR_POR_REF2_X(2,2), PANNEL_COR_POR_REF2_Y(2,3),
+ "images/P04_calculator_btn_n06.png", "images/P04_calculator_btn_n06_press.png",
+ "images/P04_calculator_btn_n06.png", "images/P04_calculator_btn_n06_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_plus",
+ PANNEL_COR_POR_REF1_X(2,3), PANNEL_COR_POR_REF1_Y(2,3),
+ PANNEL_COR_POR_REF2_X(2,3), PANNEL_COR_POR_REF2_Y(2,3),
+ "images/P04_calculator_btn_06.png", "images/P04_calculator_btn_06_press.png",
+ "images/P04_calculator_btn_06.png", "images/P04_calculator_btn_06_press.png",
+ "por_pannel/in");
+
+
+
+ // 7, 8, 9, ()
+ KEYPAD_KEY_IMG("item_num7",
+ PANNEL_COR_POR_REF1_X(3,0), PANNEL_COR_POR_REF1_Y(3,0),
+ PANNEL_COR_POR_REF2_X(3,0), PANNEL_COR_POR_REF2_Y(3,0),
+ "images/P04_calculator_btn_n07.png", "images/P04_calculator_btn_n07_press.png",
+ "images/P04_calculator_btn_n07.png", "images/P04_calculator_btn_n07_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_num8",
+ PANNEL_COR_POR_REF1_X(3,1), PANNEL_COR_POR_REF1_Y(3,1),
+ PANNEL_COR_POR_REF2_X(3,1), PANNEL_COR_POR_REF2_Y(3,1),
+ "images/P04_calculator_btn_n08.png", "images/P04_calculator_btn_n08_press.png",
+ "images/P04_calculator_btn_n08.png", "images/P04_calculator_btn_n08_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_num9",
+ PANNEL_COR_POR_REF1_X(3,2), PANNEL_COR_POR_REF1_Y(3,2),
+ PANNEL_COR_POR_REF2_X(3,2), PANNEL_COR_POR_REF2_Y(3,2),
+ "images/P04_calculator_btn_n09.png", "images/P04_calculator_btn_n09_press.png",
+ "images/P04_calculator_btn_n09.png", "images/P04_calculator_btn_n09_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_brack",
+ PANNEL_COR_POR_REF1_X(3,3), PANNEL_COR_POR_REF1_Y(3,3),
+ PANNEL_COR_POR_REF2_X(3,3), PANNEL_COR_POR_REF2_Y(3,3),
+ "images/P04_calculator_btn_07.png", "images/P04_calculator_btn_07_press.png",
+ "images/P04_calculator_btn_07.png", "images/P04_calculator_btn_07_press.png",
+ "por_pannel/in");
+
+
+ //0, ., +/-, =
+ KEYPAD_KEY_IMG("item_num0",
+ PANNEL_COR_POR_REF1_X(4,0), PANNEL_COR_POR_REF1_Y(4,0),
+ PANNEL_COR_POR_REF2_X(4,0), PANNEL_COR_POR_REF2_Y(4,0),
+ "images/P04_calculator_btn_n00.png", "images/P04_calculator_btn_n00_press.png",
+ "images/P04_calculator_btn_n00.png", "images/P04_calculator_btn_n00_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_dot",
+ PANNEL_COR_POR_REF1_X(4,1), PANNEL_COR_POR_REF1_Y(4,1),
+ PANNEL_COR_POR_REF2_X(4,1), PANNEL_COR_POR_REF2_Y(4,1),
+ "images/P04_calculator_btn_10.png", "images/P04_calculator_btn_10_press.png",
+ "images/P04_calculator_btn_10.png", "images/P04_calculator_btn_10_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_neg",
+ PANNEL_COR_POR_REF1_X(4,2), PANNEL_COR_POR_REF1_Y(4,2),
+ PANNEL_COR_POR_REF2_X(4,2), PANNEL_COR_POR_REF2_Y(4,2),
+ "images/P04_calculator_btn_09.png", "images/P04_calculator_btn_09_press.png",
+ "images/P04_calculator_btn_09.png", "images/P04_calculator_btn_09_press.png",
+ "por_pannel/in");
+ KEYPAD_KEY_IMG("item_eq",
+ PANNEL_COR_POR_REF1_X(4,3), PANNEL_COR_POR_REF1_Y(4,4),
+ PANNEL_COR_POR_REF2_X(4,3), PANNEL_COR_POR_REF2_Y(4,4),
+ "images/P04_calculator_btn_08.png", "images/P04_calculator_btn_08_press.png",
+ "images/P04_calculator_btn_08.png", "images/P04_calculator_btn_08_press.png",
+ "por_pannel/in");
+ }
+
+ programs {
+ program {
+ name: "group_load";
+ signal: "load";
+ script {
+ set_int(pannel_state, 1);
+ }
+ }
+ /* pannel open/close program */
+ //press up/down
+ program {
+ name: "icon_click2";
+ //signal: "mouse,down,1";
+ //source: "pannel/icon";
+ source: "pannel/icon/rect";
+
+ script {
+ if(get_int(pannel_state) == 1)
+ {
+ emit("pannel,down", "por");
+ set_state(PART:"pannel/icon", "open", 0.0);
+ set_state(PART:"pannel/icon/rect", "open", 0.0);
+ set_int(pannel_state, 0);
+ }
+ else
+ {
+ emit("pannel,up", "por");
+ set_state(PART:"pannel/icon", "default", 0.0);
+ set_state(PART:"pannel/icon/rect", "default", 0.0);
+ set_int(pannel_state, 1);
+ }
+ }
+ }
+
+ //flick up/down
+ program {
+ name: "icon_click";
+ //signal: "pannel,flick";
+ source: "";
+ script {
+ if(get_int(pannel_state) == 1)
+ {
+ emit("pannel,down", "por");
+ set_state(PART:"pannel/icon", "open", 0.0);
+ set_state(PART:"pannel/icon/rect", "open", 0.0);
+ set_int(pannel_state, 0);
+ }
+ else
+ {
+ emit("pannel,up", "por");
+ set_state(PART:"pannel/icon", "default", 0.0);
+ set_state(PART:"pannel/icon/rect", "default", 0.0);
+ set_int(pannel_state, 1);
+ }
+ }
+ }
+
+ program {
+ name: "pannel/down";
+ signal: "pannel,down";
+ source: "*";
+ action: STATE_SET "down" 0.0;
+ target: "por_pannel/in";
+ target: "por_pannel/BG";
+ transition: ACCELERATE 0.4;
+ after: "check_icon_open";
+ }
+ program {
+ name: "pannel/up";
+ signal: "pannel,up";
+ source: "*";
+ action: STATE_SET "default" 0.0;
+ target: "por_pannel/in";
+ target: "por_pannel/BG";
+ transition: ACCELERATE 0.3;
+ after: "check_icon_default";
+ }
+
+ program {
+ name: "check_icon_open";
+ script {
+ if(get_int(pannel_state) == 1)
+ {
+ set_state(PART:"pannel/icon", "open", 0.0);
+ set_state(PART:"pannel/icon/rect", "open", 0.0);
+ set_int(pannel_state, 0);
+ }
+ }
+ }
+
+ program {
+ name: "check_icon_default";
+ script {
+ if(get_int(pannel_state) == 0)
+ {
+ set_state(PART:"pannel/icon", "default", 0.0);
+ set_state(PART:"pannel/icon/rect", "default", 0.0);
+ set_int(pannel_state, 1);
+ }
+ }
+ }
+
+ /* programs for pennel items */
+ KEYPAD_KEY_PROG("item_c");
+ KEYPAD_KEY_PROG("item_div");
+ KEYPAD_KEY_PROG("item_mul");
+ KEYPAD_KEY_PROG("item_del");
+
+ KEYPAD_KEY_PROG("item_num7");
+ KEYPAD_KEY_PROG("item_num8");
+ KEYPAD_KEY_PROG("item_num9");
+ KEYPAD_KEY_PROG("item_sub");
+
+ KEYPAD_KEY_PROG("item_num4");
+ KEYPAD_KEY_PROG("item_num5");
+ KEYPAD_KEY_PROG("item_num6");
+ KEYPAD_KEY_PROG("item_plus");
+
+ KEYPAD_KEY_PROG("item_num1");
+ KEYPAD_KEY_PROG("item_num2");
+ KEYPAD_KEY_PROG("item_num3");
+ KEYPAD_KEY_PROG("item_brack");
+
+ KEYPAD_KEY_PROG("item_dot");
+ KEYPAD_KEY_PROG("item_num0");
+ KEYPAD_KEY_PROG("item_neg");
+ KEYPAD_KEY_PROG("item_eq");
+ }
+ }
+///////////////////// prtrait pannel finish ////////////////////////////////////////
+
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __EDC_MACRO_H__
+#define __EDC_MACRO_H__
+
+/* Basic */
+#define EDC_COLOR(nR, nG, nB, nA) nR nG nB nA
+#define EDC_SIZE(nW, nH) nW nH
+#define EDC_COOR(nX, nY) nX nY /* coordinate */
+#define EDC_IMAGE_BORDER(nL, nR, nT, nB) nL nR nT nB
+
+/* Image */
+#define EDC_IMAGE(sImage)\
+ image.normal: sImage;
+#define EDC_IMAGE_WITH_BORDER(sImage, imgBorder)\
+ image {normal: sImage; border: imgBorder; border_scale: 1;}
+
+/* Text */
+#define EDC_TEXT(sText, nSize, sFont, crFill) \
+ color: crFill;\
+ text { \
+ text: sText; \
+ size: nSize; \
+ align: 0.5 0.5; \
+ font: sFont; \
+ }
+
+#define EDC_TEXT_SHADOW(sText, nSize, sFont, crFill, crShadow) \
+ color2: crShadow;\
+ EDC_TEXT(sText, nSize, sFont, crFill)
+
+
+/* Relative */
+#define EDC_REL_TO_XY(fpRelX, fpRelY, coorOffset, sToPartX, sToPartY)\
+ relative: fpRelX fpRelY; offset: coorOffset; to_x: sToPartX; to_y: sToPartY
+
+#define EDC_REL_TO(fpRelX, fpRelY, coorOffset, sToPart)\
+ relative: fpRelX fpRelY; offset: coorOffset; to: sToPart
+
+#define EDC_REL_ABSOLUTE(coorOffset, sToPart)\
+ EDC_REL_TO(0.0, 0.0, coorOffset, sToPart)
+
+#define EDC_REL_RELATIVE(fpRelX, fpRelY, sToPart)\
+ relative: fpRelX fpRelY; to: sToPart
+
+/* state */
+#define EDC_STATE_BASE(sName, sizeMin, bFixW, bFixH, fpAlignX, fpAlignY,\
+ relTopLeft, relBottomRight, other)\
+ description {\
+ state: sName 0.0;\
+ min: sizeMin;\
+ fixed: bFixW bFixH;\
+ align: fpAlignX fpAlignY;\
+ rel1 { relTopLeft; }\
+ rel2 { relBottomRight; } \
+ other \
+ }
+
+/* state - padding top-left */
+#define EDC_STATE_PADDING_TL(sName, sizeMin, sToPart) \
+ EDC_STATE_BASE(sName, sizeMin, 1, 1, 0.0, 0.0, \
+ EDC_REL_RELATIVE(0.0, 0.0, sToPart), \
+ EDC_REL_RELATIVE(0.0, 0.0, sToPart), visible: 0;)
+
+/* state - padding bottom-right */
+#define EDC_STATE_PADDING_BR(sName, sizeMin, sToPart) \
+ EDC_STATE_BASE(sName, sizeMin, 1, 1, 1.0, 1.0, \
+ EDC_REL_RELATIVE(1.0, 1.0, sToPart), \
+ EDC_REL_RELATIVE(1.0, 1.0, sToPart), visible: 0;)
+
+
+#define EDC_STATE_COMMON(sName, relTopLeft, relBottomRight, other) \
+ EDC_STATE_BASE(sName, EDC_SIZE(0, 0), 0, 0, 0.5, 0.5, relTopLeft, relBottomRight, other)
+
+#define EDC_STATE_COMMON_RECT(sName, relTopLeft, relBottomRight, crFill) \
+ EDC_STATE_COMMON(sName, relTopLeft, relBottomRight, color: crFill;)
+
+#define EDC_STATE_COMMON_IMAGE(sName, relTopLeft, relBottomRight, img) \
+ EDC_STATE_COMMON(sName, relTopLeft, relBottomRight, img)
+
+#define EDC_STATE_COMMON_TEXT(sName, relTopLeft, relBottomRight, txt) \
+ EDC_STATE_COMMON(sName, relTopLeft, relBottomRight, txt)
+
+/* Background */
+#define EDC_PART_BG(sName)\
+ part {\
+ name: sName;\
+ type: RECT;\
+ mouse_events: 0;\
+ description {\
+ state: "default" 0.0;\
+ rel1 { relative: 0.0 0.0;}\
+ rel2 { relative: 1.0 1.0;}\
+ color: 0 0 0 0;\
+ }\
+ }
+
+/* Part */
+#define EDC_PART_BASE(sName, enumType, bMouse, bRepeat, stateDefault, stateOther...) \
+ part {\
+ name: sName;\
+ type: enumType;\
+ mouse_events: bMouse;\
+ repeat_events: bRepeat;\
+ scale: 1;\
+ stateDefault\
+ ##stateOther\
+ }
+
+#define EDC_PART_PADDING_TL(sName, sizeMin, sToPart) \
+ EDC_PART_BASE(sName, RECT, 1, 0, \
+ EDC_STATE_PADDING_TL("default", sizeMin, sToPart))
+
+#define EDC_PART_PADDING_BR(sName, sizeMin, sToPart) \
+ EDC_PART_BASE(sName, RECT, 1, 0, \
+ EDC_STATE_PADDING_BR("default", sizeMin, sToPart))
+
+/* Part - Rectagnle */
+#define EDC_PART_RECT_COMMON(sName, relTopLeft, relBottomRight) \
+ EDC_PART_BASE(sName, RECT, 1, 1, \
+ EDC_STATE_COMMON_RECT("default", relTopLeft, relBottomRight, EDC_COLOR(0, 0, 0, 0)))
+
+#define EDC_PART_RECT_ABSOLUTE(sName, sToPart, coorTopLeft, coorBottomRight) \
+ EDC_PART_RECT_COMMON(sName, \
+ EDC_REL_ABSOLUTE(coorTopLeft, sToPart),\
+ EDC_REL_ABSOLUTE(coorBottomRight, sToPart))
+
+#define EDC_PART_RECT_RELATIVE(sName, sToPart, fpRel1X, fpRel1Y, fpRel2X, fpRel2Y) \
+ EDC_PART_RECT_COMMON(sName, \
+ EDC_REL_RELATIVE(fpRel1X, fpRel1Y, sToPart), \
+ EDC_REL_RELATIVE(fpRel2X, fpRel2Y, sToPart))
+
+#define EDC_PART_RECT_PADDING(sName, sToPart, coorTopLeft, coorBottomRight) \
+ EDC_PART_PADDING_TL(sName"_padding_tl", coorTopLeft, sToPart)\
+ EDC_PART_PADDING_BR(sName"_padding_br", coorBottomRight, sToPart)\
+ EDC_PART_RECT_COMMON(sName, \
+ EDC_REL_RELATIVE(1.0, 1.0, sName"_padding_tl"), \
+ EDC_REL_RELATIVE(0.0, 0.0, sName"_padding_br"))
+
+#define EDC_PART_RECT_COLOR(sName, sToPart, crFill) \
+ EDC_PART_BASE(sName, RECT, 1, 0, \
+ EDC_STATE_COMMON_RECT("default", \
+ EDC_REL_RELATIVE(0.0, 0.0, sToPart), \
+ EDC_REL_RELATIVE(1.0, 1.0, sToPart), crFill))
+
+/* Part - Image */
+#define EDC_PART_IMAGE(sName, sToPart, img)\
+ EDC_PART_BASE(sName, IMAGE, 1, 0, \
+ EDC_STATE_COMMON_IMAGE("default", \
+ EDC_REL_RELATIVE(0.0, 0.0, sToPart), \
+ EDC_REL_RELATIVE(1.0, 1.0, sToPart), img))
+
+/* Part - Text */
+#define EDC_PART_TEXT(sName, sToPart, enumEffect, txt)\
+ EDC_PART_BASE(sName, TEXT, 1, 1, \
+ effect: enumEffect;\
+ EDC_STATE_COMMON_TEXT("default", \
+ EDC_REL_RELATIVE(0.0, 0.0, sToPart), \
+ EDC_REL_RELATIVE(1.0, 1.0, sToPart), txt))
+
+/* Two state part */
+#define EDC_PART_TWO_STATE(sName, enumType, sToPart, sStateName2, state1Do, state2Do)\
+ EDC_PART_BASE(sName, enumType, 1, 1, \
+ EDC_STATE_COMMON("default", \
+ EDC_REL_RELATIVE(0.0, 0.0, sToPart), \
+ EDC_REL_RELATIVE(1.0, 1.0, sToPart), state1Do;)\
+ EDC_STATE_COMMON(sStateName2, \
+ EDC_REL_RELATIVE(0.0, 0.0, sToPart), \
+ EDC_REL_RELATIVE(1.0, 1.0, sToPart), state2Do;))
+
+#define EDC_PART_BUTTON_IMG(sName, sToPart, imgNormal, imgPressed) \
+ EDC_PART_TWO_STATE(sName, IMAGE, sToPart, "pressed", imgNormal, imgPressed)
+
+#define EDC_PART_TWO_IMG(sName, sToPart, sState, imgNormal, imgPressed) \
+ EDC_PART_TWO_STATE(sName, IMAGE, sToPart, sState, imgNormal, imgPressed)
+
+#define EDC_PART_SWALLOW_SHOW_HIDE(sName, sToPart) \
+ EDC_PART_TWO_STATE(sName, SWALLOW, sToPart, "hide", visible: 1;, visible: 0;)
+
+#define EDC_PART_SWALLOW_HIDE_SHOW(sName, sToPart) \
+ EDC_PART_TWO_STATE(sName, SWALLOW, sToPart, "show", visible: 0;, visible: 1;)
+
+
+#endif /* __EDC_MACRO_H__ */
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#ifndef __DEF_CALC_EXPRESSION_H_
+#define __DEF_CALC_EXPRESSION_H_
+
+#ifdef __cplusplus
+extern "C" {
+
+#endif /* __cplusplus */
+
+#include "calculator_parser.h"
+
+#define IS_SIGN(ch) ((ch) == '+' || (ch) == '-')
+#define IS_SCIENCE_E(ch) ((ch) == 'E' || (ch) == 'e')
+#define IS_OPERATOER(ch) ((ch) == '+' || (ch) == '-' || (ch) == 'x' || (ch) == '/' || (ch) == '^')
+#define IS_DIGITAL(ch) (isdigit((ch)) || (ch) == 'p' || (ch) == 'e')
+
+/* */
+#define FLOAT_EQUAL(a, b) (fabs((a) - (b)) < 0.000000000001)
+ struct calc_func_t {
+ op_id_t id;
+ char *symbol;
+ };
+
+/**
+* @describe
+*
+*
+* @param expr_in
+* @param expr_out
+* @return void
+* @exception
+*/
+ void calc_expr_format_expression(const char *expr_in, char *expr_out);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @return int
+* @exception
+*/
+ int calc_expr_get_operator_num(const char *expr);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @return int
+* @exception
+*/
+ int calc_expr_get_left_parentheses_num(const char *expr);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @return void
+* @exception
+*/
+ void calc_expr_replace_with_special_char(char *expr);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @return void
+* @exception
+*/
+ void calc_expr_replace_from_special_char(char *expr);
+
+/**
+* @describe
+*
+*
+* @param result
+* @param text
+* @return void
+* @exception
+*/
+ void calc_expr_num_format_result(double result, char *text);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @param cursor
+* @return void
+* @exception
+*/
+ char *calc_expr_get_current_func_at_cursor(char *expr, int cursor);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @param cursor
+* @param begin
+* @param length
+* @return int
+* @exception
+*/
+ int calc_expr_get_current_num_at_cursor(char *expr, int cursor,
+ int *begin, int *length);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @return void
+* @exception
+*/
+ void calc_expr_close_parentheses(char *exp);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @return void
+* @exception
+*/
+ void calc_expr_preprocess(char *exp);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @param cursor
+* @return void
+* @exception
+*/
+ void calc_expr_input_backspace(char *exp, int *cursor);
+
+/**
+* @describe
+*
+*
+* @param expr
+* @param cursor
+* @param cursor
+* @return str
+* @exception
+*/
+ void calc_expr_input_insert(char *exp, int *cursor, char *str);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __DEF_CALC_EXPRESSION_H_ */
+
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __DEF_CALCULATOR_H_
+#define __DEF_CALCULATOR_H_
+
+#include <Elementary.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+/* Path & Name */
+#define PACKAGE "calculator"
+#define LAYOUT_EDJ_NAME EDJDIR"/calculator.edj"
+#define CALCULATOR_THEME EDJDIR"/calculator_theme.edj"
+
+#define GRP_MAIN "main"
+#define GRP_POR_PANNEL "por_pannel"
+#define GRP_LAN_PANNEL "lan_pannel"
+
+
+#define SAVE_HISTORY
+
+/* Max */
+#define MAX_FONT_SIZE 44
+#define NUMBER_LENGTH 1024
+#define MAX_EXPRESSION_LENGTH 1024
+#define MAX_RESULT_LENGTH 1024
+#define MAX_ERROR_MESSAGE_LENGTH 256
+
+//#define MAX_TAG_EXPRESSION_LENGTH 4096
+#define MAX_TAG_EXPRESSION_LENGTH 420*48
+
+//#define MAX_RESULT_LENGTH 128
+
+#define MAX_HISTORY_NUM 10
+#define MAX_DECIMAL_NUM 5
+#define MAX_NUM_LENGTH 15
+#define MAX_OPERATOR_NUM 20
+#define MAX_PARENTHESES_NUM 64
+
+/* Math */
+#define PI 3.1415926535897932384626433832795
+#define EXPONENT 2.718281828459045235360287471352662497757
+#define RADIAN_FACTOR (PI/180)
+#define DEGREEN_FACTOR (180/PI)
+
+/* Function */
+#ifndef _EDJ
+#define _EDJ(x) (Evas_Object *)elm_layout_edje_get(x)
+#endif /* _EDJ */
+
+#ifndef _
+#define _(str) gettext(str)
+#endif /* _ */
+
+#ifndef gettext_noop
+#define gettext_noop(str) (str)
+#endif /* gettext_noop */
+
+#ifndef N_
+#define N_(str) gettext_noop(str)
+#endif /* N_ */
+
+#define SFREE(var)\
+ if(var != NULL){\
+ free((void *)var);\
+ var = NULL;\
+ }\
+
+#define CALCULATOR_CONTENT_LEN 32
+
+#define CALCULATOR_MAX_RESULT_SUM2 (10e+100) /**<maximum num of result sum*/
+#define CALCULATOR_MIN_RESULT_SUM2 (-10e+100) /**<minimum num of result sum*/
+
+/* BEGIN DEBUG LOG MACRO */
+//#define _DEBUG
+#ifdef _DEBUG
+/* use prefix 'P' means print */
+#define PTAG fprintf(stdout, "[%s : %d]\n", __FILE__, __LINE__)
+#define PLOG(fmt, arg...) fprintf(stderr, " ## "fmt, ##arg)
+#else
+#define PTAG(fmt, arg...)
+#define PLOG(fmt, arg...)
+#endif
+#define CONV_FUNC_IN() PLOG("FUNC: %s .......... in\n", __func__)
+#define CONV_FUNC_OUT() PLOG("FUNC: %s .......... out\n", __func__)
+
+#define ALARM_INFO_RED(fmt, arg...) PLOG(FONT_COLOR_RED fmt FONT_COLOR_RESET, ##arg)
+//#define ALARM_INFO(fmt, arg...) fprintf("[%s:%d] "fmt,__FILE__, __LINE__,##arg);
+
+/* END DEBUG LOG MACRO */
+
+/* Help String of UI Guideline */
+#define CALC_MSG_MAX_DIGIT _("IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE")
+#define CALC_MSG_MAX_DEC_DIGIT _("IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE")
+#define CALC_MSG_MAX_OP _("IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE")
+#define CALC_MSG_DIVIDE_BY_ZERO _("IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO")
+#define CALC_MSG_NUM_FIRST _("IDS_CCL_POP_NO_NUMBER_ERROR")
+#define CALC_MSG_OUT_OF_RANGE _("IDS_CCL_POP_ERROR")
+#define CALC_MSG_NUM_AFTER_OP _("IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR")
+#define CALC_MSG_INVALID_SQUARE _("IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION")
+#define CALC_MSG_INVALID_LOG _("IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION")
+#define CALC_MSG_INVALID_FAC _("IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION")
+#define CALC_MSG_NUM_FIRST_FAC _("IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION")
+#define CALC_MSG_NUM_FIRST_RECIP _("IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION")
+#define CALC_MSG_NUM_FIRST_X2 _("IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION")
+#define CALC_MSG_NUM_FIRST_XY _("IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION")
+
+/* Custtom Error Message */
+#define CALC_MSG_OP_FIRST _("IDS_CCL_POP_NO_OPERATOR_ERROR")
+#define CALC_MSG_INVALID_LN _("Invalid input for ln function")
+#define CALC_MSG_INVALID_XY _("Invalid param for x^y")
+#define CALC_MSG_INVALID_TAN _("Invalid param for tan")
+#define CALC_MSG_ENTRY_LIMIT _("Already had decimal in digit")
+
+#define CALC_MSG_SYNTAX_ERROR _("IDS_CCL_POP_SYNTAX_ERROR")
+
+/* System String */
+#define SYS_STR_WARNING dgettext("sys_string", "IDS_COM_POP_WARNING") /* "Warning" */
+#define SYS_STR_OK dgettext("sys_string", "IDS_COM_SK_OK") /* "OK" */
+#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
+
+struct appdata {
+ Evas_Object *win; //main window
+ Evas_Object *bg;
+ Evas_Object *layout;
+ Evas_Object *edje;
+ Evas_Object *eo;
+
+ Evas_Object *input_scroller;
+ Evas_Object *input_entry;
+ Evas_Object *por_pannel;
+ Evas_Object *lan_pannel;
+ Evas_Object *popup;
+ Evas_Object *btn;
+
+ Ecore_Timer *calc_timer;
+ Ecore_Timer *wrong_timer;
+ int svi_handle;
+#ifdef SAVE_HISTORY
+ Evas_Object *hist_scroll;
+ Evas_Object *hist_area;
+#endif
+};
+
+/**
+* @describe
+* Load edj file from group to elm_layout.
+*
+* @param parent
+* @param file
+* @param group
+* @return
+* @exception
+*/
+Evas_Object *load_edj(Evas_Object * parent, const char *file,
+ const char *group);
+void _calc_entry_clear(Evas_Object * entry);
+
+#endif /* __DEF_CALCULATOR_H__ */
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#ifndef __DEF_CALC_STRING_H_
+#define __DEF_CALC_STRING_H_
+
+#ifdef __cplusplus
+extern "C" {
+
+#endif /* __cplusplus */
+
+/**
+* @describe
+*
+*
+* @param str
+* @param index
+* @param str2
+* @return void
+* @exception
+*/
+ void string_insert(char *str, int index, char *str2);
+
+/**
+* @describe
+*
+*
+* @param str
+* @param a
+* @param b
+* @return void
+* @exception
+*/
+ void string_replace(char *str, char *a, char *b);
+
+/**
+* @describe
+*
+*
+* @param str
+* @param at
+* @param length
+* @return void
+* @exception
+*/
+ void string_remove_at(char *str, int at, int length);
+
+#ifdef _DEBUG
+/**
+* @describe
+*
+*
+* @param i
+* @param at
+* @return char*
+* @exception
+*/
+
+/* DON'T REMOVE
+char* itoa(int i);
+*/
+#endif /* _DEBUG */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __DEF_CALC_STRING_H_ */
+
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#ifndef __DEF_CALC_VIEW_H_
+#define __DEF_CALC_VIEW_H_
+
+#include "calc-main.h"
+struct history_item {
+ char expression[MAX_EXPRESSION_LENGTH];
+ char result[MAX_RESULT_LENGTH];
+};
+
+/**
+* @describe
+*
+*
+* @param ad
+* @return void
+* @exception
+*/
+void calc_view_load(struct appdata *ad);
+
+/**
+* @describe
+*
+*
+* @param ad
+* @return void
+* @exception
+*/
+void calc_view_load_in_idle(struct appdata *ad);
+
+/**
+* @describe
+*
+*
+* @param msg
+* @param ad
+* @return void
+* @exception
+*/
+void calc_view_show_popup(char *msg, struct appdata *ad);
+
+/**
+* @describe
+*
+*
+* @param ad
+* @return void
+* @exception
+*/
+void calc_view_revise_input_scroller(struct appdata *ad);
+
+/**
+* @describe
+*
+*
+* @param result
+* @param ad
+* @return void
+* @exception
+*/
+void calc_view_show_result(const char *result, struct appdata *ad);
+
+/**
+* @describe
+*
+*
+* @param entry
+* @return int
+* @exception
+*/
+int calc_view_cursor_get_position(Evas_Object * entry);
+
+/**
+* @describe
+*
+*
+* @param entry
+* @param pos
+* @return void
+* @exception
+*/
+void calc_view_cursor_set_position(Evas_Object * entry, int pos);
+
+/**
+* @describe
+*
+*
+* @param entry
+* @param pos
+* @return void
+* @exception
+*/
+void calc_view_save_history(struct history_item item);
+
+#endif /* __DEF_CALC_VIEW_H_ */
+
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#ifndef __CALCULATOR_PARSER_H
+#define __CALCULATOR_PARSER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <glib.h>
+
+ typedef enum {
+ CHAR_IS_NULL = 0, //
+ CHAR_IS_DIGIT, //0,1,2...
+ CHAR_IS_LEFT_PARENTHESE, //(
+ CHAR_IS_RIGHT_PARENTHESE,
+ CHAR_IS_PLUS_MINUS, //+/-
+ CHAR_IS_PI, //Pi
+ CHAR_IS_E, //e
+ CHAR_IS_MULTIPLY_DIVIDE, // */
+ CHAR_IS_CHARACTER, //a,P,C,^
+ CHAR_IS_POINT, //point
+ } last_char_t;
+
+/**
+
+*@enum calculator_state_t, define calculator current state
+
+* This enum is used to judge or record which state is current.
+
+*/
+ typedef enum {
+ CALCULATOR_WAITING_INPUT = 0, /**<waiting input state*/
+ CALCULATOR_OPERAND_INPUT, /**<operand input state*/
+ CALCULATOR_OPERAND_FRACTION_INPUT, /**<fraction operand input state*/
+ CALCULATOR_OPERATOR_INPUT, /**<[basic] operator input state*/
+ CALCULATOR_OPERATOR_OPERAND_INPUT, /**<operand after [basic] operator input state*/
+ CALCULATOR_SPECIAL_SYMBOL_INPUT, /**<special symbol inputting state*/
+ CALCULATOR_SPECIAL_SYMBOL_INPUT_OVER,
+ /**<special symbol inputed state*/
+ CALCULATOR_SPECIAL_FUNCTION_INPUT, /**<function[excluding basic operator] input state*/
+ CALCULATOR_NAVIGATION, /**<browser in entry state, depreated*/
+ CALCULATOR_CALCULATED, /**<calculation completed state*/
+ CALCULATOR_ERROR_OCCURED, /**<error occured state*/
+ } calculator_state_t;
+
+/**
+
+*@enum calculator_calculate_priority_t, define calculation priorities
+
+* This enum is used to mark operator &functions's priority.
+
+*/
+ typedef enum {
+ CALCULATOR_CALCULATE_PRIORITY_INVALID = 0,
+ /**<invalid priority*/
+ CALCULATOR_CALCULATE_PRIORITY_LOW, /**<lowest priority*/
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE, /**<middle priority*/
+ CALCULATOR_CALCULATE_PRIORITY_HIGH, /**<high priority*/
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, /**<higher priority*/
+ CALCULATOR_CALCULATE_PRIORITY_HIGHEST, /**<highest priority*/
+ } calculator_calculate_priority_t;
+
+/**
+
+*@enum operator_type_t, define calculator operator type
+
+*/
+ typedef enum {
+ OPERATOR_TYPE_INVALID = 0,
+ /**<operator type invalid*/
+ OPERATOR_TYPE_UNARY, /**<operator unary*/
+ OPERATOR_TYPE_BINARY, /**<operator binary*/
+ OPERATOR_TYPE_CNT, /**<max count*/
+ } operator_type_t;
+
+/**
+
+*@enum function_category_t, define calculator function category
+
+*/
+ typedef enum {
+ FUNCTION_INVALID = 0,
+ /**<category invalid*/
+ FUNCTION_PREFIX, /**<prefix category, operand follows functions*/
+ FUNCTION_POSTFIX, /**<postfix category, function follows operand*/
+ FUNCTION_CONSTANT,
+ /**<constant category, only for PI*/
+ FUNCTION_CNT, /**<max count*/
+ } function_category_t;
+
+ typedef enum {
+ OP_INVALID = 0,
+
+ /* basic pannel */
+ OP_PARENTHESIS, // 1
+ OP_DELETE,
+ OP_CLEAR,
+ OP_DIVIDE,
+
+ OP_NUM_7, // 5
+ OP_NUM_8,
+ OP_NUM_9,
+ OP_MULTIPLY,
+
+ OP_NUM_4, // 9
+ OP_NUM_5,
+ OP_NUM_6,
+ OP_MINUS,
+
+ OP_NUM_1, // 13
+ OP_NUM_2,
+ OP_NUM_3,
+ OP_PLUS,
+
+ OP_DOT, // 17
+ OP_NUM_0,
+ OP_PLUS_MINUS,
+ OP_EQUAL,
+
+ /* function pannel */
+ OP_PERCENT, //21
+ OP_ROOT,
+ OP_FACT,
+
+ OP_SIN, // 24
+ OP_COS,
+ OP_TAN,
+
+ OP_LN, // 27
+ OP_LOG,
+ OP_1X,
+
+ OP_EX, // 30
+ OP_X2,
+ OP_XY,
+
+ OP_ABS, // 33
+ OP_PI,
+ OP_E,
+ } op_id_t;
+
+ typedef struct {
+ op_id_t op_id;
+ char *op_sym;
+ char *op_name;
+ } op_item_t;
+
+/**
+
+* @struct calculator_node_data_t, calculator node data structure
+
+* This structure is used as node data of n-ary tree
+
+*/
+ typedef struct {
+ double tmp_result; /**<store result by temoprary*/
+ calculator_calculate_priority_t node_calcu_priority;
+ /**<node calculation priority*/
+ operator_type_t operator_type; /**<node operator type*/
+ int children_num; /**<node children number*/
+ char cur_operator; /**<node operator char*/
+ int negative_flag; /**<node negative flag*/
+ } calculator_node_data_t;
+
+/**
+
+* @struct calculator_parentheses_data_t, calculator parentheses data structure
+
+*/
+ typedef struct {
+// GNode* tree; /**<parentheses tree node*/
+ char *start_pos;/**<parentheses start position in original string*/
+ char *end_pos; /**<parentheses end position in original string*/
+ bool matched;
+ /**<parentheses if is matched*/
+ } calculator_parentheses_data_t;
+
+/**
+
+* @struct function_t, calculator function data structure
+
+*/
+ typedef struct {
+ char *func_name; /**<function name, use only prompt*/
+ char *func_string; /**<function string, use in text view*/
+ gint str_len; /**<function string length*/
+ char function_char; /**<function char*/
+ function_category_t category; /**<fuction category, input after operand*/
+ operator_type_t op_type; /**<operator type*/
+ calculator_calculate_priority_t priority;
+ /**<calculation priority*/
+ bool has_parentheses; /**<if function has parentheses*/
+ } function_t;
+
+/**
+* @describe
+*
+*
+* @param tmp_result
+* @return bool
+* @exception
+*/
+//bool calculator_calculate_truncate_result(double* tmp_result);
+
+/**
+* @describe
+*
+*
+* @param szInputString
+* @return bool
+* @exception
+*/
+ int calculator_get_open_braket(const char *szInputString);
+
+/**
+* @describe
+*
+*
+* @param szInput
+* @param pDigitCnt
+* @param pPointCnt
+* @return bool
+* @exception
+*/
+ bool calculator_get_digits_number(char *szInput, int *pDigitCnt,
+ int *pPointCnt);
+
+/**
+* @describe
+*
+*
+* @param szInput
+* @param pDigitCnt
+* @param pPointCnt
+* @return bool
+* @exception
+*/
+ bool calculator_calculate(char *string, double *result,
+ char *error_msg);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif
--- /dev/null
+Name=calculator
+Type=Application
+Exec=@BINDIR@/@PROJECT_NAME@
+Icon=@PKGNAME@.png
+nodisplay=False
+Version=0.1.0
+X-TIZEN-TaskManage=True
+X-TIZEN-Multiple=False
+X-TIZEN-Removable=False
+
+Name[en_US]=Calculator
+Name[nl_NL]=Calculator
+Name[de_DE]=Rechner
+Name[zh_HK]=計算機
+Name[zh_CN]=计算器
+Name[ru_RU]=Калькулятор
+Name[ko_KR]=계산기
+Name[zh_TW]=計算器
+Name[ja_JP]=電卓
+Name[es_ES]=Calculadora
+Name[el_GR]=Αριθμομηχανή
+Name[it_IT]=Calcolatrice
+Name[tr_TR]=Hesap makinesi
+Name[pt_PT]=Calculadora
+Name[fr_FR]=Calculatrice
+
+
+
+
--- /dev/null
+%define _app_prefix /opt/apps/org.tizen.calculator
+Name: org.tizen.calculator
+Version: 0.1.4
+Release: 3
+Summary: Calculator application
+Source: %{name}-%{version}.tar.gz
+License: Flora Software License
+Group: Applications
+BuildRequires: cmake
+BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(embryo)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(utilX)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(appcore-common)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(svi)
+BuildRequires: gettext-tools
+BuildRequires: edje-bin, embryo-bin
+
+%description
+SLP Calculator application
+
+%prep
+%setup -q
+
+%build
+
+LDFLAGS+="-Wl,--rpath=%{_app_prefix}/lib -Wl,--as-needed -Wl,--hash-style=both"; export LDFLAGS
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{_app_prefix}
+
+make %{?jobs:-j%jobs}
+
+%post
+chown -R 5000:5000 %{_app_prefix}/data
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+mkdir -p %{buildroot}%{_app_prefix}/data
+
+%find_lang calculator
+
+%files -f calculator.lang
+%{_app_prefix}/data
+/opt/apps/org.tizen.calculator/bin/calculator
+/opt/apps/org.tizen.calculator/res/edje/calculator.edj
+/opt/apps/org.tizen.calculator/res/edje/calculator_theme.edj
+/opt/apps/org.tizen.calculator/res/icons/default/small/org.tizen.calculator.png
+/opt/share/applications/org.tizen.calculator.desktop
+/opt/share/process-info/calculator.ini
+
--- /dev/null
+# for i18n
+
+SET(POFILES de_DE.po el_GR.po en.po es_ES.po fr_FR.po it_IT.po ja_JP.po ko_KR.po nl_NL.po pt_PT.po ru_RU.po tr_TR.po zh_CN.po zh_HK.po zh_TW.po)
+
+SET(MSGFMT "/usr/bin/msgfmt")
+
+FOREACH(pofile ${POFILES})
+ SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile})
+ MESSAGE("PO: ${pofile}")
+ GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE)
+ GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE)
+ SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${moFile}
+ COMMAND ${MSGFMT} -o ${moFile} ${absPofile}
+ DEPENDS ${absPofile}
+ )
+ INSTALL(FILES ${moFile}
+ DESTINATION /opt/apps/org.tizen.calculator/res/locale/${lang}/LC_MESSAGES RENAME ${PROJECT_NAME}.mo)
+ SET(moFiles ${moFiles} ${moFile})
+ENDFOREACH(pofile)
+
+MESSAGE(".mo files: ${moFiles}")
+ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles})
--- /dev/null
+# List of source files containing translatable strings.
+calculator.h
+calculator.c
+calculator_edje.c
+calculator_parser.h
+calculator_parser.c
+calculator_def.h
+strtbl.h
--- /dev/null
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-08-17 15:35+0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: calculator_edje.c:3467
+msgid "Invalid expression"
+msgstr ""
+
+#: calculator_edje.c:3505 calculator_edje.c:3510
+msgid "Invalid digit!"
+msgstr ""
+
+#: calculator_edje.c:3545 calculator_edje.c:3563 calculator_edje.c:3573
+#: calculator_edje.c:3591 calculator_edje.c:3974 calculator_edje.c:3979
+#: calculator_edje.c:3997 calculator_edje.c:4007 calculator_edje.c:4012
+#: calculator_edje.c:4051 calculator_edje.c:4064 calculator_edje.c:4083
+#: calculator_edje.c:4094 calculator_edje.c:4100 calculator_edje.c:4124
+#: calculator_edje.c:4139 calculator_edje.c:4158
+msgid "Invalid expression!"
+msgstr ""
+
+#: calculator_edje.c:3602 calculator_edje.c:3607 calculator_edje.c:3612
+#: calculator_edje.c:3630 calculator_edje.c:3640 calculator_edje.c:3645
+#: calculator_edje.c:3650 calculator_edje.c:3663 calculator_edje.c:3673
+#: calculator_edje.c:3678 calculator_edje.c:3691 calculator_edje.c:3701
+#: calculator_edje.c:3706 calculator_edje.c:3712 calculator_edje.c:3725
+#: calculator_edje.c:3735 calculator_edje.c:3748 calculator_edje.c:3758
+#: calculator_edje.c:3763 calculator_edje.c:3781 calculator_edje.c:3791
+#: calculator_edje.c:3796 calculator_edje.c:3809 calculator_edje.c:3819
+#: calculator_edje.c:3832 calculator_edje.c:3842 calculator_edje.c:3847
+#: calculator_edje.c:3852 calculator_edje.c:3865 calculator_edje.c:3875
+#: calculator_edje.c:3880 calculator_edje.c:3885 calculator_edje.c:3898
+#: calculator_edje.c:3908 calculator_edje.c:3913 calculator_edje.c:3918
+#: calculator_edje.c:3931 calculator_edje.c:3941 calculator_edje.c:3946
+#: calculator_edje.c:3951 calculator_edje.c:3964 calculator_edje.c:4134
+msgid "Invalid operator!"
+msgstr ""
+
+#: calculator_edje.c:4106
+msgid "Parenthesis error!"
+msgstr ""
+
+#: calculator_parser.c:633 calculator_parser.c:664
+msgid "Syntax error"
+msgstr ""
+
+#. 5
+#. error msgs
+#: calculator_def.h:77
+msgid "IDS_CCL_POP_UP_TO_15_CHARACTERS_AVAILABLE"
+msgstr ""
+
+#: calculator_def.h:78
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr ""
+
+#: calculator_def.h:79
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr ""
+
+#: calculator_def.h:80
+msgid "IDS_CCL_POP_UP_TO_40_CHARACTERS_AVAILABLE"
+msgstr ""
+
+#: calculator_def.h:81
+msgid "IDS_CCL_POP_ENTER_OPERATOR_FIRST_ORANGE"
+msgstr ""
+
+#: calculator_def.h:82
+msgid "IDS_CCL_POP_ENTER_NUMBER_FIRST_ORANGE"
+msgstr ""
+
+#: calculator_def.h:83
+msgid "IDS_CCL_POP_ERROR"
+msgstr ""
+
+#: calculator_def.h:84
+msgid "IDS_CCL_POP_DIVIDE_ZERO"
+msgstr ""
+
+#: calculator_def.h:85
+msgid "IDS_CCL_POP_PARENTHESES_ERRORs"
+msgstr ""
+
+#: calculator_def.h:86
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr ""
+
+#: calculator_def.h:87
+msgid "IDS_CCL_POP_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr ""
+
+#: calculator_def.h:88
+msgid "IDS_CCL_POP_INVALID_INPUT_FOR LOG_FUNCTION"
+msgstr ""
+
+#: calculator_def.h:89
+msgid "IDS_CCL_POP_INVALID_INPUT_FOR LN_FUNCTION"
+msgstr ""
+
+#: calculator_def.h:90
+msgid "IDS_CCL_POP_NATURAL_NUMBER_ONLY_FOR_FACTORIAL"
+msgstr ""
+
+#: calculator_def.h:91
+msgid "IDS_CCL_POP_INVALID_PARAMETER_FOR_XY"
+msgstr ""
+
+#: calculator_def.h:92
+msgid "IDS_CCL_POP_INVALID_PARAMETER_FOR_TAN"
+msgstr ""
+
+#: calculator_def.h:93
+msgid "IDS_CCL_POP_ENTER_NUMBER_FIRST_BEFORE_TAPPING_FACTORIAL"
+msgstr ""
+
+#: calculator_def.h:94
+msgid "IDS_CCL_POP_ENTER_NUMBER_FIRST_BEFORE_TAPPING_1X"
+msgstr ""
+
+#: calculator_def.h:95
+msgid "IDS_CCL_POP_ENTER_NUMBER_FIRST_BEFORE_TAPPING_X2"
+msgstr ""
+
+#: calculator_def.h:96
+msgid "IDS_CCL_POP_ENTER_NUMBER_FIRST_BEFORE_TAPPING_XY"
+msgstr ""
+
+#: calculator_def.h:97
+msgid "IDS_CCL_POP_NO_INPUT"
+msgstr ""
+
+#: calculator_def.h:98
+msgid "IDS_CCL_POP_OVERFLOW"
+msgstr ""
+
+#: calculator_def.h:99
+msgid "IDS_CCL_POP_THE_RESULT_IS_TOO_LONG_TO_BE_DISPLAYED"
+msgstr ""
+
+#: calculator_def.h:100
+msgid "IDS_CCL_POP_ALREADY_HAD_DECIMAL_IN_DIGIT"
+msgstr ""
+
+#: calculator_def.h:101
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr ""
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Umrechnen in"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Syntaxfehler"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "Bis zu 5 Dezimalstellen verfügbar"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "Bis zu 20 Operatoren verfügbar"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "Division durch Null nicht möglich"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Zuerst Nr. Eingeben"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Überlauf"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Zahl hinter Operator eingeben"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Ungültige Eingabe für Quadratwurzelfunktion"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Ungültige Eingabe für Protokollfunktion"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Natürliche Zahl nur für x!-Funktion"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "Zahl vor Eingabe der 1/x-Funktion eingeben"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "Zahl vor Eingabe der x^2-Funktion eingeben"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "Zahl vor Eingabe der x^y-Funktion eingeben"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "Zahl vor x!-Funktion eingeben"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Zuerst Op. eing."
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "Bis zu 15 Stellen verfügbar"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Μετατροπή σε"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Σφάλμα σύνταξης"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "Διαθέσιμα μέχρι 5 δεκαδικά ψηφία"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "Μέχρι 20 διαθέσιμοι παροχείς"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "Δεν είναι δυνατή η διαίρεση με μηδέν"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Εισάγετε πρώτα αριθμό"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Εκτός εμβέλειας"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Εισάγετε αριθμό μετά τον παροχέα"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Μη έγκυρη εισαγωγή για συνάρτηση τετραγωνικής ρίζας"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Μη έγκυρη εισαγωγή για συνάρτηση αρχείου καταγραφής"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Φυσικός αριθμός μόνο για συνάρτηση x!"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "Εισαγωγή αριθμού πριν από την εισαγωγή συνάρτησης 1/x"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "Εισαγωγή αριθμού πριν από την εισαγωγή συνάρτησης x^2"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "Εισαγωγή αριθμού πριν από την εισαγωγή συνάρτησης x^y"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "Εισαγωγή αριθμού πριν από την εισαγωγή συνάρτησης x!"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Εισαγ.συμβόλου πρώτα"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "Διαθέσιμα μέχρι 15 ψηφία"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Convert to"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Syntax error"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "Up to 5 decimals available"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "Up to 20 operators available"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "Unable to divide by zero"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Enter number first"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Out of range"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Enter number after operator"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Invalid input for square root function"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Invalid input for log function"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Natural number only for x! function"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "Enter number before inputting 1/x function"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "Enter number before inputting x^2 function"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "Enter number before inputting x^y function"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "Enter number before inputting x! function"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Enter operator first"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "Up to 15 digits available"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Convertir a"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Error de sintaxis"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "Hasta 5 decimales disponibles"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "Hasta 20 operadores disponibles"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "No se puede dividir por cero"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Introduc. número 1º"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Fuera de intervalo"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Introduzca número después del operador"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Entrada incorrecta de función de raíz cuadrada"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Entrada incorrecta de función de registro"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Número natural sólo para función x!"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "Introducir número antes de escribir función 1/x"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "Introducir número antes de escribir función x^2"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "Introducir número antes de escribir función x^y"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "Introducir número antes de escribir función x!"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Introduz operador 1º"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "Hasta 15 dígitos disponibles"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Convertir en"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Erreur de syntaxe"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "Jusqu'à 5 décimales"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "Jusqu'à 20 opérateurs"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "Impossible de diviser par zéro"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Entrez chiffre"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Maximum atteint"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Entrez le nombre après l'opérateur"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Saisie non valide pour la fonction racine carrée"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Saisie non valide pour la fonction logarithme"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Entier naturel uniquement pour la fonction x!"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "Entrez un nombre avant la saisie de la fonction 1/x"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "Entrez un nombre avant la saisie de la fonction x^2"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "Entrez un nombre avant la saisie de la fonction x^y"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "Entrez un nombre avant la saisie de la fonction x!"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Entrez opérateur"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "Jusqu'à 15 chiffres"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Converti in"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Errore di sintassi"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "Fino a 5 decimali disponibili"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "Fino a 20 operazioni disponibili"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "Impossibile dividere per zero"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Inserire numero"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Fuori intervallo"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Immetti numero dopo operatore"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Immissione non valida per funzione radice quadrata"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Immissione non valida per funzione logaritmo"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Numero naturale solo per funzione x!"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "Inserisci numero prima di digitare la funzione 1/x"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "Inserisci numero prima di digitare la funzione x^2"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "Inserisci numero prima di digitare la funzione x^y"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "Inserisci numero prima di digitare la funzione x!"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Inser. prima operat."
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "Fino a 15 cifre disponibili"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "に換算"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "シンタックスエラー"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "最大小数点以下5桁まで使用できます"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "最大20の演算子が使用できます"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "0で割ることはできません"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "まず数字を入力してください"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "圏外"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "演算子の後に数字を入力します"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "平方根関数の入力が正しくありません"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "ログ関数の入力を正しくありません"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "x! 関数の場合だけ自然数"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "入力 1/x 機能の前に数を入力してください"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "x^2関数を入力する前に数字を入力してください"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "入力x^y機能の前に数を入力してください"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "入力x!機能の前に数を入力してください"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "まず計算式を入力してください"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "最大15桁まで使用できます"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "단위환산으로 이동"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "시스템 오류가 발생하였습니다"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "소수점 5자리까지 입력할 수 있습니다"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "연산자는 20개까지 입력할 수 있습니다"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "0으로 나눌 수 없습니다"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "먼저 숫자를 입력하세요"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "계산 범위를 벗어났습니다"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "연산기호 입력 후 숫자를 입력하세요"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "제곱근 함수의 입력 내용이 바르지 않습니다"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "로그 함수의 입력 내용이 바르지 않습니다"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "x! 함수에는 자연수만 입력할 수 있습니다"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "1/x 함수를 입력하기 전 숫자를 입력하세요"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "제곱근 함수를 입력하기 전 숫자를 입력하세요"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "x^y 함수를 입력하기 전 숫자를 입력하세요"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "x! 함수를 입력하기 전 숫자를 입력하세요"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "먼저 연산기호를 입력하세요"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "숫자는 15자리까지 입력할 수 있습니다"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Converteren naar"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Syntaxfout"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "Maximaal 5 decimalen beschikbaar"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "Max. 20 reken-tekens beschikbaar"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "Kan niet delen door nul"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Geef eerst het getal in"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Buiten bereik"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Geef getal in na operator"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Ongeldige invoer voor vierkantswortelfunctie"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Ongeldige invoer voor logfunctie"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Alleen natuurlijk getal voor x!-functie"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "Geef eerst getal in en dan de functie 1/x"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "Geef eerst getal in en dan de functie x^2"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "Geef eerst getal in en dan de functie x^y"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "Geef eerst getal in en dan de functie x!"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Geef eerst het reken-teken in"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "Maximaal 15 cijfers beschikbaar"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Converter em"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Erro de sintaxe"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "Até 5 decimais disponíveis"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "Até 20 operadores disponíveis"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "Impossível dividir por zero"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Intr. n.º primeiro"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Fora de alcance"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Introduzir número depois do operador"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Introdução inválida para a função de raiz quadrada"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Introdução inválida para função de registo"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Número natural apenas para função x!"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "Introduzir número antes da introdução da função 1/x"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "Introduzir número antes da introdução da função x^2"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "Introduzir número antes da introdução da função x^y"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "Introduzir número antes da introdução da função x!"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Intr. oper. primeiro"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "Até 15 dígitos disponíveis"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Преобразовать в"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Синтаксическая ошибка"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "Доступно до 5 десятичных знаков"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "Доступно до 20 операторов"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "Деление на ноль невозможно"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Введите число"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Вне диапазона"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Введите число за оператором"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Введены недопустимые данные для функции квадратного корня"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Введены недопустимые данные для функции логарифма"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Функция x! поддерживает только натуральные числа"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "Введите число перед вводом функции 1/x"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "Введите число перед вводом функции x^2"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "Введите число перед вводом функции x^y"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "Введите число перед вводом функции x!"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Введите оператор"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "Доступно до 15 цифр"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "Hedef birim"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "Sözdizimi hatası"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "En fazla 5 hane kullanılabilir"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "En fazla 20 operatör kullanılabilir"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "Sıfıra bölünemez"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "Önce sayı girin"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "Aralık dışında"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "Operatörün ardından numara girin"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "Kare kök fonksiyonu için geçersiz giriş"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "Günlük fonksiyonu için geçersiz giriş"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "Yalnızca x! fonksiyonu için doğal sayı"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "1/x fonksiyonu girmeden önce numara girin"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "x^2 fonksiyonu girmeden önce numara girin"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "x^y fonksiyonu girmeden önce numara girin"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "x! fonksiyonu girmeden önce numara girin"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "Önce operatörü girin"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "En fazla 15 hane kullanılabilir"
+
--- /dev/null
+#!/bin/sh
+
+PACKAGE=calculator
+SRCROOT=..
+POTFILES=POTFILES.in
+
+#ALL_LINGUAS= am az be ca cs da de el en_CA en_GB es et fi fr hr hu it ja ko lv mk ml ms nb ne nl pa pl pt pt_BR ru rw sk sl sr sr@Latn sv ta tr uk vi zh_CN zh_TW
+ALL_LINGUAS="en_US en_GB ja ko zh_CN"
+
+XGETTEXT=/usr/bin/xgettext
+MSGMERGE=/usr/bin/msgmerge
+
+echo -n "Make ${PACKAGE}.pot "
+if [ ! -e $POTFILES ] ; then
+ echo "$POTFILES not found"
+ exit 1
+fi
+
+$XGETTEXT --default-domain=${PACKAGE} --directory=${SRCROOT} \
+ --add-comments --keyword=_ --keyword=N_ --files-from=$POTFILES \
+&& test ! -f ${PACKAGE}.po \
+ || (rm -f ${PACKAGE}.pot && mv ${PACKAGE}.po ${PACKAGE}.pot)
+
+if [ $? -ne 0 ]; then
+ echo "error"
+ exit 1
+else
+ echo "done"
+fi
+
+for LANG in $ALL_LINGUAS; do
+ echo "$LANG : "
+
+ if [ ! -e $LANG.po ] ; then
+ cp ${PACKAGE}.pot ${LANG}.po
+ echo "${LANG}.po created"
+ else
+ if $MSGMERGE ${LANG}.po ${PACKAGE}.pot -o ${LANG}.new.po ; then
+ if cmp ${LANG}.po ${LANG}.new.po > /dev/null 2>&1; then
+ rm -f ${LANG}.new.po
+ else
+ if mv -f ${LANG}.new.po ${LANG}.po; then
+ echo ""
+ else
+ echo "msgmerge for $LANG.po failed: cannot move $LANG.new.po to $LANG.po" 1>&2
+ rm -f ${LANG}.new.po
+ exit 1
+ fi
+ fi
+ else
+ echo "msgmerge for $LANG failed!"
+ rm -f ${LANG}.new.po
+ fi
+ fi
+ echo ""
+done
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "换算成"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "语法错误"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "小数点后最多可达 5 位"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "最多可达20个运算符"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "不能除以零"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "请先输入数字"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "超出范围"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "在运算符后输入数字"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "输入无效平方根函数"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "输入无效对数函数"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "x!函数只可输入自然数"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "在输入1/x函数之前输入数字"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "在输入x^2函数之前输入数字"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "在输入x^y函数之前输入数字"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "在输入x!函数之前输入数字"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "请先输入运算符"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "最多可达15 位"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "換算為"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "語法錯誤"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "最多5 位小數點可用"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "20 個營運商可用"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "無法除以零"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "先輸入數字"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "超出範圍"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "在運算後輸入數字"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "無效的平方根函數輸入"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "無效的記錄函數輸入"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "自然數只適用於 x! 函數"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "輸入 1/x 函數前,請先輸入數字"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "輸入 x^2 函數前,請先輸入數字"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "輸入 x^y 函數前,請先輸入數字"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "輸入 x! 函數前,請先輸入數字"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "先輸入運算符"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "最多 15 位數字可用"
+
--- /dev/null
+msgid "IDS_CCL_OPT_CONVERT_TO"
+msgstr "轉換到"
+
+msgid "IDS_CCL_POP_SYNTAX_ERROR"
+msgstr "語法錯誤"
+
+msgid "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE"
+msgstr "最多可使用 5 個小數位數"
+
+msgid "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE"
+msgstr "最多可使用 20 個運算子"
+
+msgid "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO"
+msgstr "無法除以0"
+
+msgid "IDS_CCL_POP_NO_NUMBER_ERROR"
+msgstr "請先輸入數字"
+
+msgid "IDS_CCL_POP_ERROR"
+msgstr "超出範圍"
+
+msgid "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR"
+msgstr "運算元後輸入數字"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION"
+msgstr "輸入無效平方根函數"
+
+msgid "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION"
+msgstr "無效的輸入日誌功能"
+
+msgid "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION"
+msgstr "自然數只對 x!函數"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION"
+msgstr "輸入數字,然後輸入 1 / x的函數"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION"
+msgstr "輸入號碼前輸入χ^ 2功能"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION"
+msgstr "輸入號碼前輸入χ^ y功能"
+
+msgid "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION"
+msgstr "輸入數字,然後輸入到X!函數"
+
+msgid "IDS_CCL_POP_NO_OPERATOR_ERROR"
+msgstr "先輸入運算子"
+
+msgid "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE"
+msgstr "最多可使用 15 位數"
+
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <string.h>
+#include <stdbool.h>
+#include <stdio.h> //snprintf
+#include <ctype.h> //isdigit
+#include <math.h>
+#include "calc-main.h"
+#include "calc-string.h"
+#include "calc-expression.h"
+
+/* special characters */
+#define PI_S "\xcf\x80"
+#define DIVIDE "\xc3\xb7"
+#define MULTIPLY "\xc3\x97"
+#define SQRT "\xe2\x88\x9a"
+extern char decimal_ch;
+extern char separator_ch;
+struct calc_func_t calc_func[] = {
+ {OP_PERCENT, "%"},
+ {OP_ROOT, "sqrt("},
+ {OP_FACT, "!"},
+ {OP_SIN, "sin("},
+ {OP_COS, "cos("},
+ {OP_TAN, "tan("},
+ {OP_LN, "ln("},
+ {OP_LOG, "log("},
+ {OP_1X, "1/x"},
+ {OP_EX, "e^("}, {OP_X2, "^2"}, {OP_XY, "^("}, {OP_ABS, "abs("},
+};
+
+
+/*
+ * format number with comma
+ */
+static void _calc_expr_format_number(const char *in, char *out)
+{
+ char number[NUMBER_LENGTH] = { 0 };
+ char *dot = strchr(in, decimal_ch);
+ int length = (dot == NULL ? strlen(in) : dot - in);
+ bool negative = (in[0] == '-' ? true : false);
+ length -= (negative ? 1 : 0); /* the number length between '-' and '.' */
+ strncpy(number, negative ? in + 1 : in, length);
+ int comma_count = length / 3; /* the count of comma that will be add */
+ comma_count -= (length % 3 == 0 ? 1 : 0);
+ int p = length - 3; /* insert ',' at number[p] */
+ while (comma_count--)
+ {
+ int l = length;
+ while (l > p)
+ {
+ number[l] = number[l - 1];
+ l--;
+ }
+ number[p] = separator_ch;
+ length++;
+ p -= 3;
+ }
+ char *s = out;
+ if (negative)
+ {
+ out[0] = '-';
+ s += 1;
+ }
+ strncpy(s, number, length);
+ s[length] = '\0';
+ if (dot != NULL)
+ {
+ strcpy(s + length, dot);
+ }
+}
+
+
+/**
+ * @description
+ * Get the fisrt number's postion in the expression string.
+ *
+ * @param expr Expression string
+ * @param begin The index of fisrt digit(maybe '-')
+ * @param end The index of last digit
+ * @return bool
+ * @exception none
+ */
+static bool _calc_expr_get_number_position(const char *expr, int *begin,
+ int *end)
+{
+ if (expr == NULL) {
+ return false;
+ }
+ bool negative = false;
+ char *digit = "0123456789";
+ char digit_with_dot[32] = { 0 };
+ snprintf(digit_with_dot, sizeof(digit_with_dot), "%s%c", digit,
+ decimal_ch);
+ int b = strcspn(expr, digit);
+ if (b == strlen(expr)) {
+ return false;
+ }
+ if (b > 0 && expr[b - 1] == '-')
+ {
+
+ /* if before '-' is ')' or digit, I cosider it as minus. */
+ if (b > 1 && (expr[b - 2] == ')' || isdigit(expr[b - 2])))
+ {
+ negative = false;
+ }
+
+ else
+ {
+ negative = true;
+ }
+ }
+ int length = strspn(expr + b, digit_with_dot);
+ *begin = (negative ? b - 1 : b);
+ *end = b + length - 1;
+ return true;
+}
+
+/*
+ * replace common char with special locally.
+ */
+void calc_expr_replace_with_special_char(char *expr)
+{
+ CONV_FUNC_IN();
+ string_replace(expr, "p", PI_S);
+ string_replace(expr, "x", MULTIPLY);
+ string_replace(expr, "/", DIVIDE);
+ string_replace(expr, "sqrt", SQRT);
+ CONV_FUNC_OUT();
+}
+
+void calc_expr_replace_from_special_char(char *expr)
+{
+ CONV_FUNC_IN();
+ string_replace(expr, PI_S, "p");
+ string_replace(expr, MULTIPLY, "x");
+ string_replace(expr, DIVIDE, "/");
+ string_replace(expr, SQRT, "sqrt");
+ CONV_FUNC_OUT();
+}
+
+/*
+ * convert string for calculate to string for display
+ */
+void calc_expr_format_expression(const char *expr_in, char *expr_out)
+{
+ CONV_FUNC_IN();
+ char number1[NUMBER_LENGTH] = { 0 };
+ char number2[NUMBER_LENGTH] = { 0 };
+ const char *in = expr_in;
+ char *out = expr_out;
+ int begin, end;
+ while (_calc_expr_get_number_position(in, &begin, &end)) {
+ int l = end - begin + 1;
+ strncpy(number1, in + begin, l);
+ number1[l] = '\0';
+ _calc_expr_format_number(number1, number2);
+ strncpy(out, in, begin);
+ out += begin;
+ strcpy(out, number2);
+ in = in + end + 1;
+ out = out + strlen(out);
+ }
+ strcpy(out, in);
+ calc_expr_replace_with_special_char(expr_out);
+ CONV_FUNC_OUT();
+}
+
+int calc_expr_get_operator_num(const char *expr)
+{
+ if (expr == NULL) {
+ return 0;
+ }
+ char *operator = "+-x/^";
+ int count = 0;
+ int i = 0;
+ while (expr[i]) {
+ int j = 0;
+ while (operator[j]) {
+ if (operator[j] == expr[i]) {
+ count++;
+ break;
+ }
+ ++j;
+ }
+ ++i;
+ }
+ return count;
+}
+
+int calc_expr_get_left_parentheses_num(const char *expr)
+{
+ if (expr == NULL) {
+ return 0;
+ }
+ int i = 0;
+ int count = 0;
+ while (expr[i] != '\0') {
+ if (expr[i] == '(') {
+ count++;
+ }
+ i++;
+ }
+ return count;
+}
+
+void calc_expr_num_remove_end_zero(char *number)
+{
+ int len = strlen(number);
+ if (strchr(number, 'e') != NULL || strchr(number, 'E') != NULL) {
+ return;
+ }
+ if (strchr(number, decimal_ch) != NULL) {
+ while (len > 0 && number[len - 1] == '0') {
+ number[len - 1] = '\0';
+ len--;
+ }
+ if (len > 0 && number[len - 1] == decimal_ch) {
+ number[len - 1] = '\0';
+ len--;
+ }
+ }
+}
+
+void calc_expr_num_format_result(double result, char *text)
+{
+ char buf[MAX_EXPRESSION_LENGTH] = { 0 };
+ if (FLOAT_EQUAL(result, 0)) {/* Solve the bug of "-0". This judge can't remove. */
+ strcpy(text, "0");
+ return;
+ }
+ snprintf(buf, sizeof(buf), "%.*lf", MAX_DECIMAL_NUM, result);
+ calc_expr_num_remove_end_zero(buf);
+ printf("%s\n", buf);
+ if (strlen(buf) > MAX_NUM_LENGTH) {
+ double revise_result = result;
+ /* 12345678650*100,000 The result should be 1.23456787+E15, not 1.23456786+E15. */
+ if (buf[9] == '5') {
+ buf[9] = '6';
+ sscanf(buf, "%lf", &revise_result);
+ }
+ snprintf(buf, sizeof(buf), "%.8E", revise_result);
+ }
+ strcpy(text, buf);
+}
+
+
+/**
+ * Get fucntion at current cursor position.
+ * If get successfully return the function symbol.
+ * If at the cursor position is not a function, return NULL.
+ */
+char *calc_expr_get_current_func_at_cursor(char *expr, int cursor)
+{
+ if (cursor == 0) {
+ return NULL;
+ }
+ int pos = cursor - 1; //previous cursor position
+ int func_num = sizeof(calc_func) / sizeof(calc_func[0]); //the number of fucntions
+ int i = 0;
+ char *ch = NULL;
+ for (i = 0; i < func_num; ++i) {
+ if ((ch = strchr(calc_func[i].symbol, expr[pos])) == NULL){
+ continue;
+ }
+ int t = pos - (ch - calc_func[i].symbol);
+ if (t < 0) {
+ continue;
+ }
+ if (!strncmp(calc_func[i].symbol, expr + t, strlen(calc_func[i].symbol))) //equal
+ {
+ PLOG("current function : %s\n", calc_func[i].symbol);
+ return calc_func[i].symbol;
+ }
+ }
+ return NULL;
+}
+
+
+/**
+ * Parse the first number and give the number length in the expression.
+ * @param exp the expression string
+ * @param number the first number in the expression
+ * @param length the number's length in the expression string
+ * @return int 0 if parse succefully, else return -1
+ */
+int calc_expr_parse_number(const char *exp, double *number, int *length)
+{
+ const char *ptr = IS_SIGN(exp[0]) ? exp + 1 : exp;
+ char *digit = "0123456789";
+ int t = strspn(ptr, digit);
+ if (t == 0) {
+ return -1;
+ } /* has no digit */
+ ptr += t;
+ if (ptr[0] == decimal_ch) {
+ ptr += 1;
+ t = strspn(ptr, digit);
+ ptr += t;
+ }
+ if (IS_SCIENCE_E(ptr[0])) /* science number */ {
+ ptr += 1;
+ ptr += IS_SIGN(ptr[0]) ? 1 : 0;
+ t = strspn(ptr, digit);
+ ptr += (t == 0 && IS_SIGN(ptr[-1]) ? -1 : t); /* "1.0E-" are not allowed */
+ }
+ int len = ptr - exp;
+ double num = 0.0;
+ char *buf = (char *)malloc(len + 1);
+ if (buf == NULL) {
+ return -1;
+ }
+ strncpy(buf, exp, len);
+ buf[len] = '\0';
+ sscanf(buf, "%lf", &num);
+ free(buf);
+ if (number != NULL) {
+ *number = num;
+ }
+ if (length != NULL) {
+ *length = len;
+ }
+ return 0; /* successfully */
+}
+
+
+/*
+ * Return the current number position at the cursor in expr
+ * @expr, the expression string
+ * @cursor, the cursor postion
+ * @[out]begin, the current number begin position
+ * @[out]length, the current number's length
+ * @return, return 0 if get succefully, else return -1
+ */
+int calc_expr_get_current_num_at_cursor(char *expr, int cursor, int *begin,
+ int *length)
+{
+ int index = cursor;
+ int _begin = 0;
+ int _length = 0;
+ int counter = 0;
+ if (expr[index] == 'p' || expr[index] == 'e') {
+ if (index > 0 && expr[index - 1] == '-') { //-e OR -p
+ _begin = index - 1;
+ _length = 2;
+ }
+ else {
+ _begin = index;
+ _length = 1;
+ }
+ }
+ else {
+ if (expr[index] == 'E' || expr[index] == decimal_ch) {
+ index--;
+ }
+ while (calc_expr_parse_number(expr + index, NULL, &_length) ==
+ 0){
+ counter++; /* flag */
+ if (index + _length <= cursor) {
+ index += 1;
+ break;
+ }
+ if (index == 0)
+ break;
+ index--;
+ if (expr[index] == 'E' || expr[index] == decimal_ch)
+ index--;
+ }
+ if (counter == 0) {
+ return -1;
+ } /* not a number */
+ if (0 != calc_expr_parse_number(expr + index, NULL, NULL)) {
+ index += 1;
+ }
+ calc_expr_parse_number(expr + index, NULL, &_length);
+ if (IS_SIGN(expr[index])) {
+ if (index > 0
+ && (isdigit(expr[index - 1])
+ || expr[index - 1] == ')')) {
+ index += 1;
+ _length -= 1;
+ }
+ }
+ _begin = index;
+ }
+ if (begin != NULL) {
+ *begin = _begin;
+ }
+ if (length != NULL) {
+ *length = _length;
+ }
+ return 0; /* successfully */
+}
+
+
+/*
+ * Auto close parentheses at the end of exp.
+ */
+void calc_expr_close_parentheses(char *exp)
+{
+ int cnt_l = 0, cnt_r = 0;
+ int i = 0;
+ for (i = 0; exp[i]; ++i) {
+ if ('(' == exp[i]) {
+ cnt_l++;
+ }
+ if (')' == exp[i]) {
+ cnt_r++;
+ }
+ }
+ int n = cnt_l - cnt_r;
+ while (n > 0) {
+ strcat(exp, ")");
+ n--;
+ }
+}
+
+
+/**
+ * According "[Fraser] UI_Calculator_v0.5_20101125.pdf",
+ * *123+2=125
+ * /123+2=125
+ * Enter operator at first are allowed.
+ * So it should remove 'x' or '/' at the first position.
+ */
+void calc_expr_remove_first_operator(char *exp)
+{
+ if (exp != NULL && strlen(exp) > 0) {
+ if (exp[0] == 'x' || exp[0] == '/' || exp[0] == '+') {
+ string_remove_at(exp, 0, 1);
+ }
+ }
+}
+
+
+/**
+ * @description
+ * According "[Fraser] UI_Calculator_v0.5_20101125.pdf",
+ * 123+= : 123+123=246
+ * 123-= : 123-123=0
+ * 123*= : 123*123=15129
+ * 123/= : 123/123=1
+ * The operator at last are allowed.
+ * The function process these conditions.
+ *
+ * @param exp
+ * @return void
+ * @exception none
+ */
+void calc_expr_process_last_operator(char *exp)
+{
+ int len = strlen(exp);
+ if (len > 1 && IS_OPERATOER(exp[len - 1])) {
+ int b, l;
+ if (0 ==
+ calc_expr_get_current_num_at_cursor(exp, len - 2, &b, &l)) {
+ strncat(exp, exp + b, l);
+ exp[len + l] = '\0';
+ }
+ }
+}
+
+
+/*
+ * Preprocess befeore calculating.
+ */
+void calc_expr_preprocess(char *exp)
+{
+ calc_expr_close_parentheses(exp);
+ calc_expr_remove_first_operator(exp);
+ calc_expr_process_last_operator(exp);
+}
+
+/*
+ * process expression input backspace
+ * @[in/out]expr, the expression string
+ * @[in/out]cursor, the cursor postion
+ * When the fuction return, the exp and cursor will be updated.
+ */
+void calc_expr_input_backspace(char *exp, int *cursor)
+{
+ int _cursor = *cursor;
+ int count = 0;
+ if (_cursor <= 0) {
+ return;
+ }
+ if (_cursor > strlen(exp)) {
+ _cursor = strlen(exp);
+ } /* set to the end */
+ char *func = calc_expr_get_current_func_at_cursor(exp, _cursor);
+ if (NULL == func) {
+ count = 1;
+ _cursor -= 1;
+ } else {
+ int p = _cursor;
+ while (p >= 0 && (strncmp(func, exp + p, strlen(func)) != 0)) {
+ p--;
+ }
+ count = strlen(func);
+ _cursor = p;
+ }
+ string_remove_at(exp, _cursor, count);
+ *cursor = _cursor;
+}
+
+
+/*
+ * insert str in exp at sursor position
+ * @[in/out]expr, the expression string
+ * @[in/out]cursor, the cursor postion
+ * @[in]str, the string insert into
+ * When the fuction return, the exp and cursor will be updated.
+ */
+void calc_expr_input_insert(char *exp, int *cursor, char *str)
+{
+ int _cursor = *cursor;
+ if (_cursor < 0) {
+ return;
+ }
+ if (_cursor > strlen(exp)) {
+ _cursor = strlen(exp) + 1;
+ } /* set to the end */
+ string_insert(exp, _cursor, str);
+ *cursor = _cursor + strlen(str);
+}
+
+
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <app.h>
+#include <dlog.h>
+#include <Ecore_X.h> /* ecore_x_window_size_get */
+#include <utilX.h> /* KEY_END */
+#include <svi.h>
+#include "calc-main.h"
+#include "calc-view.h"
+
+extern char calculator_input_str[];
+extern int calculator_cursor_pos;
+
+static int max_fontsize = 67;
+extern void calc_xxx(struct appdata *ap); /* will be removed */
+
+Evas_Object *load_edj(Evas_Object * parent, const char *file, const char *group)
+{
+ Evas_Object *eo;
+ int r;
+ eo = elm_layout_add(parent);
+ if (eo) {
+ r = elm_layout_file_set(eo, file, group);
+ if (!r) {
+ evas_object_del(eo);
+ return NULL;
+ }
+ evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ }
+ return eo;
+}
+
+/**
+* @describe
+*
+*
+* @param ad
+* @param angle
+* @return void
+* @exception
+*/
+static void _to_portrait(struct appdata *ad, int angle)
+{
+ elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+ edje_object_signal_emit(_EDJ(ad->edje), "portrait", "");
+ elm_win_rotation_with_resize_set(ad->win, angle);
+ elm_win_rotation_with_resize_set(ad->eo, angle);/*when rotating, resize the window eo*/
+ max_fontsize = 67;
+}
+
+int get_max_fontsize()
+{
+ return max_fontsize;
+}
+
+/**
+* @describe
+*
+*
+* @param data
+* @param obj
+* @param event_info
+* @return void
+* @exception
+*/
+static void _win_del(void *data, Evas_Object * obj, void *event_info)
+{
+ elm_exit();
+}
+
+#if 0
+/**
+* @describe
+*
+*
+* @param data
+* @return int
+* @exception
+*/
+static int _capture_idle_image(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+
+ char name[128];
+ //snprintf(name, sizeof(name), COM_SAMSUNG_S, PACKAGE);
+ snprintf(name, sizeof(name), "com.%s.%s", VENDOR, PACKAGE);
+ Evas *evas = evas_object_evas_get(ad->win);
+
+ if (ui_idlecapture_exists(name) == EINA_FALSE) {
+ ui_idlecapture_set(evas, name);
+ }
+
+ return ECORE_CALLBACK_CANCEL; //0
+}
+#endif
+/**
+* @describe
+*
+*
+* @param data
+* @return int
+* @exception
+*/
+static int _set_input_entry_focus(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ elm_object_focus_set(ad->input_entry, EINA_TRUE); //set focus
+ _calc_entry_clear(ad->input_entry);
+
+ return ECORE_CALLBACK_CANCEL; //0
+}
+
+/**
+* @describe
+*
+*
+* @param data
+* @return int
+* @exception
+*/
+static int _load_idle_view(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ calc_view_load_in_idle(ad);
+
+ return ECORE_CALLBACK_CANCEL; //0
+}
+
+/**
+* @describe
+*
+*
+* @param name
+* @return Evas_Object*
+* @exception
+*/
+static Evas_Object *_create_win(const char *name)
+{
+ Evas_Object *eo;
+ int w, h;
+ eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
+ if (eo) {
+ elm_win_title_set(eo, name);
+ elm_win_borderless_set(eo, EINA_TRUE);
+ evas_object_smart_callback_add(eo, "delete,request", _win_del,
+ NULL);
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w,
+ &h);
+ evas_object_resize(eo, w, h);
+ }
+ return eo;
+}
+
+/**
+* @describe
+*
+*
+* @param ad
+* @return void
+* @exception
+*/
+static void _on_exit(struct appdata *ad)
+{
+ //ui_bgimg_fini_noti();
+
+ if (ad->popup) {
+ evas_object_del(ad->popup);
+ ad->popup = NULL;
+ }
+
+ if (ad->por_pannel) {
+ evas_object_del(ad->por_pannel);
+ ad->por_pannel = NULL;
+ }
+
+ if (ad->lan_pannel) {
+ evas_object_del(ad->lan_pannel);
+ ad->lan_pannel = NULL;
+ }
+
+ if (ad->input_entry) {
+ evas_object_del(ad->input_entry);
+ ad->input_entry = NULL;
+ }
+#ifdef SAVE_HISTORY
+ if (ad->hist_area) {
+ evas_object_del(ad->hist_area);
+ ad->hist_area = NULL;
+ }
+
+ if (ad->hist_scroll) {
+ evas_object_del(ad->hist_scroll);
+ ad->hist_scroll = NULL;
+ }
+#endif
+
+ if (ad->edje) {
+ evas_object_del(ad->edje);
+ ad->edje = NULL;
+ }
+
+ if (ad->layout) {
+ evas_object_del(ad->layout);
+ ad->layout = NULL;
+ }
+
+ if (ad->win) {
+ evas_object_del(ad->win);
+ ad->win = NULL;
+ }
+
+ /* delete timer */
+ if (ad->calc_timer) {
+ ecore_timer_del(ad->calc_timer);
+ ad->calc_timer = NULL;
+ }
+ if (ad->svi_handle) {
+ svi_fini(ad->svi_handle);
+ }
+}
+
+static bool app_launch(void *data)
+{
+ CONV_FUNC_IN();
+ struct appdata *ad = (struct appdata *)data;
+
+ /* Use elm_theme_extension_add() API before creating any widgets */
+ //elm_theme_overlay_add(NULL, CALCULATOR_THEME);
+ elm_theme_extension_add(NULL, CALCULATOR_THEME);
+
+ /* main widnow */
+ ad->win = _create_win(PACKAGE);
+ if (ad->win == NULL) {
+ return FALSE;
+ }
+ evas_object_show(ad->win);
+
+ elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+
+ /* will be removed */
+ calc_xxx(ad);
+
+ /* load main view */
+ calc_view_load(ad);
+ _to_portrait(ad, 0);
+
+ /* register callback */
+ //ecore_idler_add((Ecore_Task_Cb)_capture_idle_image, ad);
+ ecore_idler_add((Ecore_Task_Cb) _set_input_entry_focus, ad);
+ ecore_idler_add((Ecore_Task_Cb) _load_idle_view, ad);
+
+ CONV_FUNC_OUT();
+ return TRUE; //EXIT_SUCCESS
+}
+
+/**
+* @describe
+*
+*
+* @param data
+* @return int
+* @exception
+*/
+static bool app_create(void *data)
+{
+ return TRUE; //EXIT_SUCCESS
+}
+
+/**
+* @describe
+*
+*
+* @param data
+* @return int
+* @exception
+*/
+static void app_terminate(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ _on_exit(ad);
+}
+
+/**
+* @describe
+*
+*
+* @param data
+* @return int
+* @exception
+*/
+static void app_pause(void *data)
+{
+ // Take necessary actions when application becomes invisible
+}
+
+/**
+* @describe
+*
+*
+* @param data
+* @return int
+* @exception
+*/
+static void app_resume(void *data)
+{
+ // Take necessary actions when application becomes visible.
+}
+
+static void app_service(service_h service, void *data)
+{
+ CONV_FUNC_IN();
+ struct appdata *ad = (struct appdata *)data;
+
+ if (ad->win != NULL) { /* calculator has already launced. */
+ elm_win_activate(ad->win);
+ return;
+ }
+ app_launch(ad);
+ evas_object_show(ad->win);
+ CONV_FUNC_OUT();
+}
+
+
+/**
+* @describe
+* The entry of the program
+*
+* @param argc
+* @param argv
+* @param int
+* @exception
+*/
+int main(int argc, char *argv[])
+{
+ struct appdata ad;
+
+ app_event_callback_s event_callback;
+
+ event_callback.create = app_create;
+ event_callback.terminate = app_terminate;
+ event_callback.pause = app_pause;
+ event_callback.resume = app_resume;
+ event_callback.service = app_service;
+ event_callback.low_memory = NULL;
+ event_callback.low_battery = NULL;
+ event_callback.device_orientation = NULL;
+ event_callback.language_changed = NULL;
+ event_callback.region_format_changed = NULL;
+
+ memset(&ad, 0x0, sizeof(struct appdata));
+
+ return app_efl_main(&argc, &argv, &event_callback, &ad);
+}
+
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <stdio.h>
+#include <string.h>
+#include "calc-main.h"
+#include "calc-string.h"
+#include <glib.h>
+
+#undef BUFLEN
+#define BUFLEN 1024
+
+/*
+ * Insert str2 to str at index.
+ */
+void string_insert(char *str, int index, char *str2)
+{
+ int buf_size = strlen(str) + strlen(str2) + 1;
+ char *buf = (char *)malloc(buf_size);
+ if (buf == NULL) {
+ return;
+ }
+ memset(buf, 0, buf_size);
+ strncpy(buf, str, index);
+ buf[index] = '\0';
+ strncat(buf, str2, buf_size - 1 - strlen(buf)); //don't use g_strlcat, because has bug.
+ strncat(buf, str + index, buf_size - 1 - strlen(buf));
+ strcpy(str, buf);
+ free(buf);
+}
+
+
+/*
+ * Replace a with b in str locally.
+ */
+void string_replace(char *str, char *a, char *b)
+{
+ char *pch = NULL;
+ char buf[BUFLEN] = { 0 };
+ while ((pch = strstr(str, a)) != NULL) {
+ strncpy(buf, str, pch - str);
+ buf[pch - str] = '\0';
+ g_strlcat(buf, b, sizeof(buf));
+ g_strlcat(buf, pch + strlen(a), sizeof(buf));
+ strcpy(str, buf);
+ }
+}
+
+void string_remove_at(char *str, int at, int length)
+{
+ int i = at;
+ while ((str[i] = str[i + length]) != '\0') {
+ i++;
+ }
+}
+
+
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+#ifdef _DEBUG
+/* @attention DON'T REMOVE
+char* itoa(int i)
+{
+ char *a = (char *)malloc(42);
+ if (a) { sprintf(a, "%d", i); }
+ return a;
+}
+*/
+#endif /* _DEBUG */
+
+/* Remove later.
+if (i != 0)//last digit number
+{
+ //if ((new_node) && (CALCULATOR_GET_NODE_DATA(new_node)->tmp_result == PI || CALCULATOR_GET_NODE_DATA(new_node)->tmp_result == EXPONENT))
+ if ((new_node) && (FLOAT_EQUAL(CALCULATOR_GET_NODE_DATA(new_node)->tmp_result,PI)
+ || FLOAT_EQUAL(CALCULATOR_GET_NODE_DATA(new_node)->tmp_result, EXPONENT)))
+ {
+ node_data = g_malloc0(sizeof(calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type = OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority = CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tree = g_node_new(node_data);
+
+ if (last_node)
+ {
+ __calculator_calculate_insert_node(&last_node, tree, new_node);
+ }
+ else
+ {
+ g_node_insert(tree, -1, new_node);
+ CALCULATOR_GET_NODE_DATA(tree)->children_num++;
+ }
+ last_node = tree;
+ new_node = NULL;
+ }
+
+ factor = atof(tmp);
+ memset(tmp, 0x00, sizeof(tmp));
+ i = 0;
+
+ node_data = g_malloc0(sizeof(calculator_node_data_t));
+ node_data->tmp_result = factor;
+ node_data->negative_flag = 1;
+ node_data->negative_flag *= negative_sign;
+ negative_sign = 1;
+ new_node = g_node_new(node_data);
+
+ if (last_node != NULL)
+ {
+ if (CALCULATOR_GET_NODE_DATA(last_node)->children_num > CALCULATOR_GET_NODE_DATA(last_node)->operator_type)
+ {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+ else
+ {
+ g_node_insert(last_node, -1, new_node);
+ CALCULATOR_GET_NODE_DATA(last_node)->children_num++;
+ }
+ new_node = NULL;
+ }
+}
+*/
+
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <Elementary.h>
+#include <stdbool.h>
+#include "calc-main.h"
+#include "calc-expression.h"
+#include "calc-view.h"
+#include <Ecore_X.h>
+
+extern char decimal_ch;
+extern char separator_ch;
+extern char calculator_input_str[];
+extern void _calc_add_tag(char *string, char *format_string);
+extern int get_max_fontsize();
+extern calculator_state_t calculator_get_state();
+
+/*
+ * BEGIN INPUT SCROLLER REVISE
+ *
+ * Accturally it needn't these fuction.
+ * But scroller lack fuction and has many bugs.
+ * So we need to revise it.
+ */
+
+/**
+* @describe
+* The entry of the program
+*
+* @param data
+* @return Eina_Bool
+*/
+static Eina_Bool _calc_view_revise_input_scroller_timer_cb(void *data)
+{
+ struct appdata *ad = (struct appdata *)data;
+ int child_w, child_h;
+ elm_scroller_child_size_get(ad->input_scroller, &child_w, &child_h);
+ printf("|| Child size : w=%d h=%d\n", child_w, child_h);
+ int scroller_w, scroller_h;
+ elm_scroller_region_get(ad->input_scroller, NULL, NULL, &scroller_w,
+ &scroller_h);
+ printf("|| Region size : w=%d h=%d\n", scroller_w, scroller_h);
+ int region_y = child_h - scroller_h;
+ elm_scroller_region_bring_in(ad->input_scroller, 0, region_y,
+ scroller_w, scroller_h);
+ return ECORE_CALLBACK_CANCEL; //0
+}
+
+
+/**
+* @describe
+* The entry of the program
+*
+* @param ad the appdata
+* @return void
+*/
+void calc_view_revise_input_scroller(struct appdata *ad)
+{
+
+ /* Because return ECORE_CALLBACK_CANCEL, the timer will be deleted automatically */
+ ecore_timer_add(0.05, _calc_view_revise_input_scroller_timer_cb,
+ ad);
+}
+
+/* END INPUT SCROLLER REVISE */
+void calc_view_show_result(const char *result, struct appdata *ad)
+{
+ char buf[MAX_RESULT_LENGTH] = { 0 };
+ char temp[MAX_RESULT_LENGTH] = { 0 };
+ snprintf(buf, MAX_RESULT_LENGTH,
+ "<br><+ font_size=%d><color=#855B11FF><yellow>=</yellow>",
+ get_max_fontsize());
+ snprintf(temp, MAX_RESULT_LENGTH,
+ "<+ font_size=%d><color=#000000ff><yellow>%s</yellow>",
+ get_max_fontsize(), result);
+ strncat(buf, temp, strlen(temp));
+
+#if 0
+ elm_entry_entry_set(entry, buf);
+
+#else /* */
+ elm_entry_cursor_end_set(ad->input_entry);
+ elm_entry_entry_insert(ad->input_entry, buf);
+ calc_view_revise_input_scroller(ad);
+
+#endif /* */
+ evas_object_show(ad->input_entry);
+}
+
+/* BEGIN ABOUT CURSOR */
+
+/**
+* @description
+* Because display expression and calculate expression are not the same.
+* The display expression has comma or some special character.
+* So we should correct the cursor position for input expression
+*
+* @param entry input entry
+* @param cur_pos the cursor position in display expression
+* @return int the cursor position in input expression
+*/
+static int
+_calc_view_cursor_correct_position(Evas_Object * entry, int cur_pos)
+{
+ char buf[MAX_EXPRESSION_LENGTH] = { 0 };
+ char *ss = elm_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ strncpy(buf, ss, MAX_EXPRESSION_LENGTH - 1);
+ int i = 0, len = cur_pos;
+ int count_sqrt = 0; /* the number of sqrt before cursor */
+ int count_comma = 0; /* the number of comma before cursor */
+ for (i = 0; i < len; ++i) {
+ if (buf[i] == separator_ch){
+ count_comma++;
+ } else if (buf[i] == '\xcf' || buf[i] == '\xc3') {
+ len += 1;
+ } else if (buf[i] == '\xe2') {
+ len += 2;
+ count_sqrt++;
+ }
+ }
+ SFREE(ss);
+ return cur_pos + count_sqrt * 3 - count_comma;
+}
+
+int calc_view_cursor_get_position(Evas_Object * entry)
+{
+ int pos = elm_entry_cursor_pos_get(entry);
+ return _calc_view_cursor_correct_position(entry, pos);
+}
+
+void calc_view_cursor_set_position(Evas_Object * entry, int pos)
+{
+ const char *expr =
+ elm_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ const char *input = calculator_input_str;
+ int i = 0, j = 0;
+ int cur_pos = 0;
+ while (j < pos){
+ if (expr[i] == input[j]){
+ cur_pos++;
+ i++;
+ j++;
+ }
+
+ else if (expr[i] == separator_ch)
+ {
+ cur_pos++;
+ i++;
+ }
+
+ else if (expr[i] == '\xc3' || expr[i] == '\xcf') /* mutiply/devide or PI */
+ {
+ cur_pos++;
+ i += 2;
+ j++;
+ }
+
+ else if (expr[i] == '\xe2' && input[j] == 's') /* sqrt */
+ {
+ cur_pos++;
+ i += 3;
+ j += 4;
+ }
+
+ else if (expr[i] == '*' && input[j] == 'x')
+ {
+ cur_pos++;
+ i++;
+ j++;
+ }
+
+ else
+ {
+ PLOG("ERROR %s [%c %c]\n", __func__, expr[i],
+ input[j]);
+ break;
+ }
+ }
+ elm_entry_cursor_pos_set(entry, cur_pos);
+ elm_object_focus_set(entry, EINA_TRUE);
+ SFREE(expr);
+}
+
+/* END ABOUT CURSOR */
+
+#ifdef SAVE_HISTORY
+
+/* BEGIN ABOUT HISTORY */
+static struct history_item history[MAX_HISTORY_NUM];
+static int history_index = 0;
+void calc_view_save_history(struct history_item item)
+{
+ CONV_FUNC_IN();
+ history[history_index] = item;
+ history_index = (1 + history_index) % MAX_HISTORY_NUM;
+ CONV_FUNC_OUT();
+}
+void _calc_view_show_newest_histroy(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+ char content[MAX_TAG_EXPRESSION_LENGTH + MAX_RESULT_LENGTH] = { 0 };
+ char tag_text[MAX_TAG_EXPRESSION_LENGTH] = { 0 };
+ char buf[MAX_RESULT_LENGTH] = { 0 };
+ int new_index = (history_index - 1) % MAX_HISTORY_NUM;
+ _calc_add_tag(history[new_index].expression, tag_text);
+ strncat(content, tag_text, strlen(tag_text));
+ snprintf(buf, MAX_RESULT_LENGTH,
+ "<br><align=right><+ font_size=%d><color=#855B11FF><yellow>=</yellow>",
+ get_max_fontsize());
+ strncat(content, buf, strlen(buf));
+ snprintf(buf, MAX_RESULT_LENGTH,
+ "<align=right><color=#000000ff><+ font_size=%d><yellow>%s</yellow><br>",
+ get_max_fontsize(), history[new_index].result);
+ strncat(content, buf, strlen(buf));
+ elm_entry_entry_set(entry, content);
+ CONV_FUNC_OUT();
+}
+static void _calc_view_show_histroy(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+ char content[(MAX_TAG_EXPRESSION_LENGTH + MAX_TAG_EXPRESSION_LENGTH) *
+ MAX_HISTORY_NUM] = { 0 };
+ char tag_text[MAX_TAG_EXPRESSION_LENGTH] = { 0 };
+ char buf[MAX_RESULT_LENGTH] = { 0 };
+ char input_str[MAX_TAG_EXPRESSION_LENGTH] = { 0 };
+ char input_str_tag[MAX_TAG_EXPRESSION_LENGTH] = { 0 };
+ int i = 0;
+ int j = 0;
+ for (i = history_index; i <= history_index + MAX_HISTORY_NUM - 1; i++) {
+ j = i % MAX_HISTORY_NUM;
+ if (strlen(history[j].expression) > 0) {
+ _calc_add_tag(history[j].expression, tag_text);
+ strncat(content, tag_text, strlen(tag_text));
+ memset(tag_text, 0, sizeof(tag_text));
+ snprintf(buf, MAX_RESULT_LENGTH,
+ "<br><align=right><+ font_size=%d><color=#855B11FF><yellow>=</yellow>",
+ get_max_fontsize());
+ strncat(content, buf, strlen(buf));
+ snprintf(buf, MAX_RESULT_LENGTH,
+ "<align=right><color=#000000ff><+ font_size=%d><yellow>%s</yellow><br><+ font_size=20> <br>",
+ get_max_fontsize(), history[j].result);
+ strncat(content, buf, strlen(buf));
+ }
+ }
+ calculator_state_t tmp_state = calculator_get_state();
+ if (tmp_state != CALCULATOR_CALCULATED){
+ calc_expr_format_expression(calculator_input_str, input_str);
+ _calc_add_tag(input_str, input_str_tag);
+ strncat(content, input_str_tag, strlen(input_str_tag));
+ }
+ elm_entry_entry_set(entry, content);
+ CONV_FUNC_OUT();
+}
+
+void _calc_view_clear_histroy(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+ int i = 0;
+ for (i = history_index + MAX_HISTORY_NUM - 1; i >= history_index; --i) {
+ int j = i % MAX_HISTORY_NUM;
+ if (strlen(history[j].expression) > 0)
+ {
+ memset(history[j].expression, 0,
+ sizeof(history[j].expression));
+ memset(history[j].result, 0,
+ sizeof(history[j].result));
+ }
+ }
+ _calc_entry_clear(entry);
+ CONV_FUNC_OUT();
+}
+
+static void _calc_view_show_history_cb
+ (void *data, Evas_Object * o, const char *emission, const char *source)
+ {
+ CONV_FUNC_IN();
+ struct appdata *ad = (struct appdata *)data;
+ evas_object_hide(ad->input_entry);/*hide the input entry,before showing history area*/
+ _calc_view_show_histroy(ad->hist_area);
+ edje_object_signal_emit(_EDJ(ad->edje), "show,hist", "");
+
+ /* sync lan & por pannel state */
+ Evas_Object * pannel =
+ !strcmp(source, "por") ? ad->lan_pannel : ad->por_pannel;
+ edje_object_signal_emit(_EDJ(pannel), "pannel,down", source);
+ CONV_FUNC_OUT();
+}
+
+static void
+_calc_view_hide_history_cb(void *data, Evas_Object * o, const char *emission,
+ const char *source)
+{
+ CONV_FUNC_IN();
+ struct appdata *ad = (struct appdata *)data;
+ edje_object_signal_emit(_EDJ(ad->edje), "hide,hist", "");
+
+ /* sync lan & por pannel state */
+ Evas_Object * pannel =
+ !strcmp(source, "por") ? ad->lan_pannel : ad->por_pannel;
+ edje_object_signal_emit(_EDJ(pannel), "pannel,up", source);
+ evas_object_show(ad->input_entry); /*show the input entry,after hide history area */
+ elm_object_focus_set(ad->input_entry, EINA_TRUE); //can't remove show cursor
+ CONV_FUNC_OUT();
+}
+
+static Evas_Object *
+_calc_view_create_history_entry(Evas_Object * parent)
+{
+ Evas_Object * entry = elm_entry_add(parent);
+ elm_entry_single_line_set(entry, EINA_FALSE);
+ elm_entry_line_wrap_set(entry, ELM_WRAP_WORD);
+ elm_entry_editable_set(entry, EINA_FALSE);
+ elm_entry_entry_set(entry, "<align=right>");
+ elm_entry_magnifier_disabled_set(entry, EINA_TRUE);
+ evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0.0);
+ evas_object_show(entry);
+ return entry;
+}
+
+static Evas_Object *
+_calc_view_create_history_scroller(Evas_Object * parent)
+{
+ Evas_Object * scroller = elm_scroller_add(parent);
+ elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
+ evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_show(scroller);
+ return scroller;
+}
+
+
+/* END ABOUT HISTORY */
+
+#endif /* */
+void calc_view_load_in_idle(struct appdata *ad)
+{
+ CONV_FUNC_IN();
+ PLOG("%s run.\n", __func__);
+
+#ifdef SAVE_HISTORY
+ /* history area */
+ ad->hist_area = _calc_view_create_history_entry(ad->edje);
+ ad->hist_scroll = _calc_view_create_history_scroller(ad->edje);
+ elm_object_content_set(ad->hist_scroll, ad->hist_area);
+ edje_object_part_swallow(_EDJ(ad->edje), "history/scroll",
+ ad->hist_scroll);
+
+ /* callbacks */
+ edje_object_signal_callback_add(_EDJ(ad->por_pannel), "pannel,down",
+ "por", _calc_view_show_history_cb,
+ ad);
+ edje_object_signal_callback_add(_EDJ(ad->por_pannel), "pannel,up",
+ "por", _calc_view_hide_history_cb,
+ ad);
+#endif /* */
+ CONV_FUNC_OUT();
+}
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <stdbool.h> /* true/false */
+#include <Elementary.h>
+#include <dlog.h>
+
+#include "calc-main.h"
+#include "calculator_parser.h"
+#include "calc-string.h"
+#include "calc-expression.h"
+#include "calc-view.h"
+#include <svi.h>
+
+#define CALCULATOR_CHAR_IS_OPERATOR(C) ((C == '+')||(C == '-')||(C == 'x')||(C == '/')) /**<judge if a char is a basic operator*/
+#define CALCULATOR_CHAR_IS_MULTI_DIVIDE_OPERATOR(C) ((C == 'x')||(C == '/')) /**<judge if an operator is "*" or "/"*/
+#define CALCULATOR_CHAR_IS_PLUS_DEDUCT(C) ((C == '+')||(C == '-'))
+#define CALCULATOR_CHAR_IS_DIGITAL(C)(C >= '0' && C <= '9')
+#define CALCULATOR_IS_DIGIT_DOT(ch, decimal) (isdigit(ch) || decimal == (ch))
+
+static Elm_Entry_Filter_Limit_Size limit_filter_data;
+
+extern int get_max_fontsize();
+extern void _calc_view_show_newest_histroy(Evas_Object * entry);
+extern void _calc_view_clear_histroy(Evas_Object * entry);
+extern gboolean __calculator_search_function(char *op, int* len);
+static void __calculator_wrong_format_create(char * wrong_string);
+extern gboolean __calculator_search_function(char *op, int* len);
+
+static struct appdata *ad; /* will be removed */
+static calculator_state_t calculator_state = CALCULATOR_WAITING_INPUT;
+static double last_result = 0.0;
+
+int calculator_cursor_pos = 0;
+char calculator_input_str[MAX_EXPRESSION_LENGTH] = { 0 };
+char calculator_before_paste_str[MAX_EXPRESSION_LENGTH] = { 0 };
+
+bool paste_flag = FALSE;
+
+struct lconv *locale = NULL;
+char *decimal = NULL;
+char *separator = NULL;
+char decimal_ch = 0;
+char separator_ch = 0;
+
+static op_item_t calc_op_item[] = {
+ {OP_INVALID, "", NULL},
+
+ /* basic */
+ {OP_PARENTHESIS, "()", NULL},
+ {OP_DELETE, "<-", NULL},
+ {OP_CLEAR, "C", NULL},
+ {OP_DIVIDE, "/", NULL},
+
+ {OP_NUM_7, "7", NULL},
+ {OP_NUM_8, "8", NULL},
+ {OP_NUM_9, "9", NULL},
+ {OP_MULTIPLY, "x", NULL},
+
+ {OP_NUM_4, "4", NULL},
+ {OP_NUM_5, "5", NULL},
+ {OP_NUM_6, "6", NULL},
+ {OP_MINUS, "-", NULL},
+
+ {OP_NUM_1, "1", NULL},
+ {OP_NUM_2, "2", NULL},
+ {OP_NUM_3, "3", NULL},
+ {OP_PLUS, "+", NULL},
+
+ {OP_DOT, ".", NULL},
+ {OP_NUM_0, "0", NULL},
+ {OP_PLUS_MINUS, "+/-", NULL},
+ {OP_EQUAL, "=", NULL},
+
+ /* functional */
+ {OP_PERCENT, "%", NULL},
+ {OP_ROOT, "sqrt", "sqrt("},
+ {OP_FACT, "x!", "!"},
+
+ {OP_SIN, "sin", "sin("},
+ {OP_COS, "cos", "cos("},
+ {OP_TAN, "tan", "tan("},
+
+ {OP_LN, "ln", "ln("},
+ {OP_LOG, "log", "log("},
+ {OP_1X, "1/x", "1/x"},
+
+ {OP_EX, "e^x", "e^("},
+ {OP_X2, "x^2", "^2"},
+ {OP_XY, "x^y", "^("},
+
+ {OP_ABS, "abs", "abs("},
+ {OP_PI, "Pi", "p"},
+ {OP_E, "e", "e"},
+};
+char *error_string[] = {
+ "IDS_CCL_POP_UP_TO_15_DIGITS_AVAILABLE",
+ "IDS_CCL_POP_UP_TO_5_DECIMALS_AVAILABLE",
+ "IDS_CCL_POP_UP_TO_20_OPERATORS_AVAILABLE",
+ "IDS_CCL_POP_UNABLE_TO_DIVIDE_BY_ZERO",
+ "IDS_CCL_POP_NO_NUMBER_ERROR",
+ "IDS_CCL_POP_ERROR",
+ "IDS_CCL_POP_ENTER_NUMBER_AFTER_OPERATOR",
+ "IDS_CCL_BODY_INVALID_INPUT_FOR_SQUARE_ROOT_FUNCTION",
+ "IDS_CCL_BODY_INVALID_INPUT_FOR_LOG_FUNCTION",
+ "IDS_CCL_BODY_NATURAL_NUMBER_ONLY_FOR_X_E_FUNCTION",
+ "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X_E_FUNCTION",
+ "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_1_X_FUNCTION",
+ "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_X2_FUNCTION",
+ "IDS_CCL_BODY_ENTER_NUMBER_BEFORE_INPUTTING_XY_FUNCTION",
+ "IDS_CCL_POP_NO_OPERATOR_ERROR",
+ "IDS_CCL_POP_SYNTAX_ERROR",
+};
+
+
+calculator_state_t calculator_get_state()
+{
+ return calculator_state;
+}
+
+void _calc_add_tag(char *string, char *format_string)
+{
+ CONV_FUNC_IN();
+ int i = 0;
+ int begin = 0;
+ int end = 0;
+ char buf[MAX_EXPRESSION_LENGTH] = { 0 };
+ char tmp[MAX_EXPRESSION_LENGTH] = { 0 };
+ char *p = NULL;
+ while (string[i] != '\0') {
+ if (CALCULATOR_CHAR_IS_DIGITAL(string[i])
+ || string[i] == separator_ch || string[i] == decimal_ch) {
+ begin = i;
+ p = &string[begin];
+ while (CALCULATOR_CHAR_IS_DIGITAL(string[i])
+ || string[i] == separator_ch
+ || string[i] == decimal_ch) {
+ i++;
+ }
+ end = i - 1;
+ strncpy(tmp, p, MAX_EXPRESSION_LENGTH - 1);
+ tmp[end - begin + 1] = '\0';
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf),
+ "<align=right><+ font_size=%d><color=#000000ff>%s",
+ get_max_fontsize(), tmp);
+ strcat(format_string, buf);
+ } else {
+ begin = i;
+ p = &string[begin];
+ while (!CALCULATOR_CHAR_IS_DIGITAL(string[i])
+ && string[i] != separator_ch
+ && string[i] != decimal_ch
+ && string[i] != '\0') {
+ i++;
+ }
+ end = i - 1;
+ strncpy(tmp, p, MAX_EXPRESSION_LENGTH - 1);
+ tmp[end - begin + 1] = '\0';
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf),
+ "<align=right><+ font_size=%d><color=#855B11FF>%s",
+ get_max_fontsize(), tmp);
+ strcat(format_string, buf);
+ }
+
+ }
+ PLOG("Expression with tag : %s\n", format_string);
+ CONV_FUNC_OUT();
+}
+
+/* BEGIN INPUT ENTRY RELATED */
+
+/**
+* @describe
+*
+*
+* @param entry
+* @param str
+* @return void
+* @exception
+*/
+static void _calc_entry_text_set(Evas_Object * entry, const char *str)
+{
+ CONV_FUNC_IN();
+ char tmp[MAX_EXPRESSION_LENGTH] = { 0 };
+ char tag_text[MAX_TAG_EXPRESSION_LENGTH] = { 0 };
+
+ if (str == NULL) {
+ return;
+ }
+
+ if (strlen(str) == 0) {
+ elm_entry_entry_set(entry, "");
+ calc_view_cursor_set_position(entry, calculator_cursor_pos);
+ return;
+ }
+ calc_expr_format_expression(str, tmp);
+ _calc_add_tag(tmp, tag_text);
+ elm_entry_entry_set(entry, tag_text);
+
+ calc_view_cursor_set_position(entry, calculator_cursor_pos);
+ calc_view_revise_input_scroller(ad);
+ CONV_FUNC_OUT();
+
+}
+
+void _calc_entry_text_set_rotate(struct appdata *ad)
+{
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ _calc_view_show_newest_histroy(ad->input_entry);
+ elm_entry_cursor_end_set(ad->input_entry);
+ } else {
+ _calc_entry_text_set(ad->input_entry, calculator_input_str);
+ }
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @param str
+* @return void
+* @exception
+*/
+static void _calc_entry_text_insert(Evas_Object * entry, char *str)
+{
+ CONV_FUNC_IN();
+ calc_expr_input_insert(calculator_input_str, &calculator_cursor_pos,
+ str);
+ printf("calculator_input_str=%s, str=%s, calculator_cursor_pos=%d\n", calculator_input_str, str, calculator_cursor_pos);
+ _calc_entry_text_set(entry, calculator_input_str);
+ CONV_FUNC_OUT();
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @param from_pos
+* @param end_pos
+* @return void
+* @exception
+*/
+static void _calc_entry_text_remove(Evas_Object * entry, const int from_pos,
+ const int end_pos)
+{
+ CONV_FUNC_IN();
+ string_remove_at(calculator_input_str, from_pos,
+ end_pos - from_pos + 1);
+ calculator_cursor_pos = from_pos;
+ _calc_entry_text_set(entry, calculator_input_str);
+ CONV_FUNC_OUT();
+}
+
+/**
+* @describe
+* Set correct cursor position in entry.
+*
+* @param entry
+* @return void
+* @exception
+*/
+static void _calc_entry_cursor_set(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+ calc_view_cursor_set_position(entry, calculator_cursor_pos);
+ CONV_FUNC_OUT();
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @return void
+* @exception
+*/
+static void _calc_entry_backspace(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+ calc_expr_input_backspace(calculator_input_str, &calculator_cursor_pos);
+ _calc_entry_text_set(entry, calculator_input_str);
+ CONV_FUNC_OUT();
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @return void
+* @exception
+*/
+void _calc_entry_clear(Evas_Object * entry)
+{
+ memset(calculator_input_str, 0, sizeof(calculator_input_str));
+ calculator_cursor_pos = 0;
+ _calc_entry_text_set(entry, "");
+ calc_view_cursor_set_position(entry, calculator_cursor_pos);
+}
+
+/* END INPUT ENTRY RELATED */
+
+/**
+* @describe
+*
+*
+* @param text
+* @param begin
+* @param end
+* @return void
+* @exception
+*/
+static bool
+__calculator_get_float_num_in_cursor_position(char *text, int cur_pos,
+ int *begin, int *end)
+{
+ CONV_FUNC_IN();
+
+ int pos = cur_pos - 1;
+ if (pos < 0) {
+ pos++;
+ pos = 0;
+ }
+ int _begin = 0;
+ int _end = 0;
+
+ if ('p' == text[pos] || 'e' == text[pos]) {
+ *begin = pos;
+ *end = pos;
+ return true;
+ } else if (CALCULATOR_IS_DIGIT_DOT(text[pos], decimal_ch)) {
+ for (_begin = pos - 1;
+ CALCULATOR_IS_DIGIT_DOT(text[_begin], decimal_ch)
+ && _begin >= 0; --_begin) {
+ ; /* NULL */
+ }
+ _begin++;
+ if (_begin > 1 && '-' == text[_begin - 1]
+ && '(' == text[_begin - 2]) {
+ _begin--;
+ }
+ for (_end = pos + 1;
+ CALCULATOR_IS_DIGIT_DOT(text[_end], decimal_ch)
+ && _end < strlen(text); ++_end) {
+ ; /* NULL */
+ }
+ _end--;
+
+ *begin = _begin;
+ *end = _end;
+ return true;
+ } else {
+ return false;
+ }
+ CONV_FUNC_OUT();
+}
+
+/**
+* @describe
+*
+*
+* @param entry_text
+* @param str
+* @param from
+* @param end
+* @return void
+* @exception
+*/
+static bool
+__calculator_get_cursor_position_float_string(char *entry_text, char *str,
+ int cur_pos, int *from, int *end)
+{
+ CONV_FUNC_IN();
+
+ int from_pos = cur_pos;
+ int end_pos = cur_pos;
+
+ if (false ==
+ __calculator_get_float_num_in_cursor_position(entry_text, cur_pos,
+ &from_pos,
+ &end_pos)) {
+ return false;
+ }
+
+ /* set from&end position */
+ if (from != NULL) {
+ *from = from_pos;
+ }
+ if (end != NULL) {
+ *end = end_pos;
+ }
+
+ strncpy(str, entry_text + from_pos, end_pos - from_pos + 1);
+ str[end_pos - from_pos + 1] = '\0';
+ CONV_FUNC_OUT();
+ return true;
+}
+
+/**
+* @describe
+* Get the float number in current cursor
+*
+* @param entry_text
+* @param str
+* @return void
+* @exception
+*/
+static bool
+__calculator_get_before_cursor_float_string(char *entry_text, char *str)
+{
+ CONV_FUNC_IN();
+
+ int from_pos = calculator_cursor_pos;
+ int end_pos = calculator_cursor_pos;
+
+ if (false ==
+ __calculator_get_float_num_in_cursor_position(entry_text,
+ calculator_cursor_pos,
+ &from_pos,
+ &end_pos)) {
+ return false;
+ }
+ snprintf(str, calculator_cursor_pos - from_pos + 1, "%s",
+ entry_text + from_pos);
+ CONV_FUNC_OUT();
+ return true;
+}
+
+/**
+* @describe
+* Get string before cursor in the Entry.
+*
+* @param entry_text
+* @param str
+* @return void
+* @exception
+*/
+static void
+__calculator_get_input_from_begin_to_cursor(char *entry_text, char *str)
+{
+ CONV_FUNC_IN();
+
+ if (calculator_cursor_pos > 0) {
+ strncpy(str, entry_text, calculator_cursor_pos);
+ str[calculator_cursor_pos] = '\0';
+ } else {
+ strcpy(str, "");
+ }
+ CONV_FUNC_OUT();
+}
+
+/**
+* @describe
+*
+* judge the type of current input
+*
+* @param input
+* @return void
+* @exception
+*/
+static last_char_t __calculator_string_get_char_type( char ch_in)
+{
+ CONV_FUNC_IN();
+ if (ch_in == '\0') {
+ return CHAR_IS_NULL;
+ }
+ if (ch_in == 'p') {
+ return CHAR_IS_PI;
+ }
+ if (ch_in == 'e') {
+ return CHAR_IS_E;
+ }
+ if (CALCULATOR_CHAR_IS_MULTI_DIVIDE_OPERATOR(ch_in)) {
+ return CHAR_IS_MULTIPLY_DIVIDE;
+ }
+ if (ch_in == '(') {
+ return CHAR_IS_LEFT_PARENTHESE;
+ }
+ if (ch_in == ')') {
+ return CHAR_IS_RIGHT_PARENTHESE;
+ }
+ if (CALCULATOR_CHAR_IS_DIGITAL(ch_in)) {
+ return CHAR_IS_DIGIT;
+ }
+ if (CALCULATOR_CHAR_IS_PLUS_DEDUCT(ch_in) ){
+ return CHAR_IS_PLUS_MINUS;
+ }
+ if (ch_in == decimal_ch) {
+ return CHAR_IS_POINT;
+ }
+ return CHAR_IS_CHARACTER;
+ CONV_FUNC_OUT();
+}
+
+static bool __calculator_string_digit_in(const char *input)
+{
+ int i =0;
+ while(input[i]!='\0'){
+ if(CALCULATOR_CHAR_IS_DIGITAL(input[i])){
+ return TRUE;
+ }else{
+ i++;
+ }
+ }
+ return FALSE;
+}
+
+/*
+* search charactor in input string, if have charactor, return True and index of first charactor;
+* else return False;
+*/
+static bool __calculator_string_char_search(const char *input, int *index)
+{
+ CONV_FUNC_IN();
+ int len_cp = strlen(input);
+ if(len_cp <= 0){
+ return FALSE;
+ }
+ int i = 0;
+ for(; i < len_cp ; i++){
+ last_char_t cur_char_type = __calculator_string_get_char_type(input[i]);
+ if (CHAR_IS_CHARACTER == cur_char_type) {
+ *index = i;
+ return TRUE;
+ }
+ }
+ return FALSE;
+ CONV_FUNC_OUT();
+}
+
+/*
+* search invalid charactor in input string, if have invalid charactor, return True and index of first invalid charactor;
+* else return False;
+*/
+static bool __calculator_string_invalid_char_search(char *input, int *index)
+{
+ int sub_index = 0;
+ char *p = input;
+ bool char_in = FALSE;
+ int len = 0;
+ char_in = __calculator_string_char_search(p, &sub_index);
+ if(!char_in){/*no charactor*/
+ return FALSE;
+ }
+ while(p){
+ /* charactor present*/
+ *index += sub_index;
+ p += sub_index;
+ if(!__calculator_search_function(p, &len)){/*charactor not a function*/
+ return TRUE;
+ }else{/*the first sevaral charactors are function, continue search*/
+ *index += len;
+ p += len;
+ }
+ }
+ return FALSE;
+}
+/**
+* @describe
+*
+*
+* @param entry
+* @param op_item
+* @return void
+* @exception
+*/
+static void
+__calculator_control_panel_number_button_clicked(Evas_Object * entry,
+ op_item_t * op_item)
+{
+ CONV_FUNC_IN();
+
+ /* replace special characters */
+ char entry_text[MAX_EXPRESSION_LENGTH] = { 0 };
+ snprintf(entry_text, sizeof(entry_text), "%s", calculator_input_str);
+
+ //Current state is calculated, clear all
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input", "");
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ return;
+ }
+
+ char str_buf[MAX_EXPRESSION_LENGTH] = { 0 };
+ char before_cursor[MAX_EXPRESSION_LENGTH] = { 0 };
+ int before_len = 0;
+ int nDigitCnt = 0;
+ int nPointCnt = 0;
+ __calculator_get_cursor_position_float_string(entry_text, str_buf,
+ calculator_cursor_pos,
+ NULL, NULL);
+ __calculator_get_input_from_begin_to_cursor(entry_text, before_cursor);
+ before_len = strlen(before_cursor);
+ calculator_get_digits_number(str_buf, &nDigitCnt, &nPointCnt);
+
+ char str_bufa[MAX_EXPRESSION_LENGTH] = { 0 };
+ __calculator_get_before_cursor_float_string(entry_text, str_bufa);
+ if (strcmp(str_bufa, "0") == 0) {
+ _calc_entry_backspace(entry);
+ }
+
+ if (strlen(str_buf) >= MAX_NUM_LENGTH) {
+ __calculator_wrong_format_create(CALC_MSG_MAX_DIGIT);
+ return;
+ } else if (nPointCnt >= MAX_DECIMAL_NUM
+ && calculator_cursor_pos > nDigitCnt) {
+ __calculator_wrong_format_create(CALC_MSG_MAX_DEC_DIGIT);
+ return;
+ } else if (before_len > 0
+ && (__calculator_string_get_char_type(before_cursor[before_len - 1]) ==
+ CHAR_IS_PI
+ || __calculator_string_get_char_type(before_cursor[before_len - 1]) ==
+ CHAR_IS_E)) {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ return;
+ } else if (before_len > 0
+ && ((before_cursor[before_len - 1] == '(')
+ ||
+ CALCULATOR_CHAR_IS_DIGITAL(before_cursor[before_len - 1])
+ || CALCULATOR_CHAR_IS_OPERATOR(before_cursor[before_len - 1]) || (int)before_cursor[before_len - 1] > 120)) //* or/
+ {
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ return;
+ } else if (before_len > 0 && (before_cursor[before_len - 1] == ')')) {
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ return;
+ } else {
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ return;
+ }
+ CONV_FUNC_OUT();
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @return void
+* @exception
+*/
+static void _calc_btn_dot_clicked(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+ char temp[MAX_RESULT_LENGTH] = { 0 };
+ char str_num[CALCULATOR_CONTENT_LEN] = { 0 };
+ int str_num_len = 0;
+
+ char decimal_str[32] = { 0 };
+
+ /* replace special characters */
+ char entry_text[MAX_EXPRESSION_LENGTH] = { 0 };
+ strncpy(entry_text, calculator_input_str, MAX_EXPRESSION_LENGTH - 1);
+
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ calc_expr_num_format_result(last_result, temp);
+ if (strchr(temp, 'E') != NULL) {
+ return;
+ }
+ /* science number */
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, temp);
+ }
+
+ int from_pos = 0;
+ int end_pos = 0;
+ if (!__calculator_get_cursor_position_float_string
+ (entry_text, str_num, calculator_cursor_pos, &from_pos, &end_pos)) {
+ if (calculator_cursor_pos == 0
+ || IS_OPERATOER(calculator_input_str[from_pos - 1])) {
+ snprintf(decimal_str, sizeof(decimal_str), "0%c",
+ decimal_ch);
+ _calc_entry_text_insert(entry, decimal_str);
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ return;
+ } else {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ }
+ return;
+ } else {
+ if (strcmp(str_num, "p") == 0 || strcmp(str_num, "e") == 0) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ return;
+ }
+ }
+
+ str_num_len = strlen(str_num);
+ if (str_num_len > 0 && str_num[str_num_len - 1] == decimal_ch) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ return;
+ }
+
+ int nDigitCnt = 0;
+ int nPointCnt = 0;
+ calculator_get_digits_number(str_num, &nDigitCnt, &nPointCnt);
+
+ if (nDigitCnt >= 15) {
+ __calculator_wrong_format_create(CALC_MSG_MAX_DIGIT);
+ return;
+ }
+
+ if (nPointCnt > 0) {
+ __calculator_wrong_format_create(CALC_MSG_ENTRY_LIMIT);
+ return;
+ }
+ snprintf(decimal_str, sizeof(decimal_str), "%c", decimal_ch);
+ _calc_entry_text_insert(entry, decimal_str);
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ CONV_FUNC_OUT();
+ return;
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @return void
+* @exception
+*/
+static void _calc_btn_backspace_clicked(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ if (calculator_cursor_pos > strlen(calculator_input_str)) {
+ calculator_cursor_pos = strlen(calculator_input_str); /* set last position */
+ }
+ }
+ _calc_entry_backspace(entry);
+ CONV_FUNC_OUT();
+}
+
+static int __calculator_delete_long_press(void *data)
+{
+ CONV_FUNC_IN();
+ Evas_Object *entry = (Evas_Object *) data;
+ _calc_btn_backspace_clicked(entry);
+ CONV_FUNC_OUT();
+ return 1;
+}
+
+/**
+* @describe
+* Process +.-.*.\ these four buttons clicked.
+*
+* @param entry
+* @param op_item
+* @return void
+* @exception
+*/
+static void
+__calculator_control_normal_func_clicked(Evas_Object * entry,
+ op_item_t * op_item)
+{
+ CONV_FUNC_IN();
+ char all_input[MAX_EXPRESSION_LENGTH] = { 0 };
+ strncpy(all_input, calculator_input_str, MAX_EXPRESSION_LENGTH - 1);
+
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input", "");
+ char temp[20] = { 0 };
+
+ calc_expr_num_format_result(last_result, temp);
+ _calc_entry_clear(entry);
+
+ if (temp[0] == '-' || strchr(temp, 'E')) //result < 0 or sicience number
+ {
+ _calc_entry_text_insert(entry, "(");
+ _calc_entry_text_insert(entry, temp);
+ _calc_entry_text_insert(entry, ")");
+ } else {
+ _calc_entry_text_insert(entry, temp);
+ }
+
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ return;
+
+ }
+ if(!strcmp(op_item->op_sym, "x") || !strcmp(op_item->op_sym, "/") || !strcmp(op_item->op_sym, "+")){
+ if(!__calculator_string_digit_in(calculator_input_str)){ return; }
+ }
+ int nCntOp = calc_expr_get_operator_num(all_input);
+ if (nCntOp >= MAX_OPERATOR_NUM) { /* Can't exceed 20 operators */
+ __calculator_wrong_format_create(CALC_MSG_MAX_OP);
+ return;
+ }
+
+ char before_cursor[MAX_EXPRESSION_LENGTH] = { 0 };
+ int input_len = 0;
+
+ __calculator_get_input_from_begin_to_cursor(all_input, before_cursor);
+ input_len = strlen(before_cursor);
+
+ if (input_len > 0) {
+ if (before_cursor[input_len - 1] == '('
+ && !strcmp(op_item->op_sym, "-")) {
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ } else if (((input_len > 1) && (before_cursor[input_len - 1] == '-') && (before_cursor[input_len - 2] == '(')) //(-
+ || before_cursor[input_len - 1] == decimal_ch || before_cursor[input_len - 1] == '(') // . or (
+ {
+
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ return;
+ } else if (IS_OPERATOER(before_cursor[input_len - 1])) {
+ if ((input_len > 1 || !strcmp(op_item->op_sym, "-"))
+ || input_len == 1) {
+ _calc_entry_backspace(entry);
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ } else {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ }
+ return;
+ } else if (before_cursor[input_len - 1] == ')') //
+ {
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ return;
+ } else {
+ if (!IS_DIGITAL(before_cursor[input_len - 1])) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ return;
+ } else {
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ return;
+ }
+ }
+ } else { /* before_cursor si empty */
+
+ _calc_entry_text_insert(entry, op_item->op_sym);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ }
+ CONV_FUNC_OUT();
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @return void
+* @exception
+*/
+static void __calculator_symbol_negative_clicked(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+
+ char result[MAX_RESULT_LENGTH] = { 0 };
+
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input", "");
+
+ calc_expr_num_format_result(last_result, result);
+ if (last_result < 0) {
+ string_remove_at(result, 0, 1); //remove '-'
+ } else {
+ string_insert(result, 0, "(-"); // add (-xxx)
+ string_insert(result, strlen(result), ")");
+ }
+
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, result);
+
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ //use_last_result = 1;
+
+ return;
+ }
+
+ int cursor = calculator_cursor_pos;
+ int begin = 0, length = 0;
+ char expr[MAX_EXPRESSION_LENGTH] = { 0 };
+ strncpy(expr, calculator_input_str, MAX_EXPRESSION_LENGTH - 1);
+ int flag = 0;
+
+ cursor -= 1;
+ if (expr[cursor] == ')') {
+ cursor -= 1;
+ flag = 1; /* before current cursor is ')' */
+ }
+
+ if (0 ==
+ calc_expr_get_current_num_at_cursor(expr, cursor, &begin,
+ &length)) {
+ if (expr[begin] == '-') {
+ if (begin > 0 && expr[begin - 1] == '('
+ && expr[begin + length] == ')') {
+ string_remove_at(expr, begin + length, 1); //remove ')'
+ string_remove_at(expr, begin - 1, 2); // remove '(-'
+ calculator_cursor_pos -= flag ? 3 : 2;
+ } else {
+ string_remove_at(expr, begin, 1);
+ calculator_cursor_pos -= 1;
+ }
+
+ } else {
+ if (flag == 1) //not '(-xxx)' but has ')'
+ {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ return;
+ } else {
+ string_insert(expr, begin + length, ")");
+ string_insert(expr, begin, "(-");
+ calculator_cursor_pos +=
+ (((begin + length) ==
+ calculator_cursor_pos) ? 3 : 2);
+ }
+ }
+ strncpy(calculator_input_str, expr, MAX_EXPRESSION_LENGTH - 1);
+
+ _calc_entry_text_set(entry, calculator_input_str);
+ _calc_entry_cursor_set(entry);
+
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+
+ } else {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ }
+ CONV_FUNC_OUT();
+}
+
+/* search the previous operator and value */
+static char * __calculator_search_prev_input(char *input_str)
+{
+ int i = strlen(input_str) - 1;
+ int rightbracket = 0;
+ char *prev_input = NULL;
+ for ( ; i > 0; i--){
+ if (input_str[i] == ')') {
+ rightbracket++;
+ } else if (input_str[i] == '(') {
+ rightbracket--;
+ }
+ if ((CALCULATOR_CHAR_IS_PLUS_DEDUCT(input_str[i])
+ ||CALCULATOR_CHAR_IS_MULTI_DIVIDE_OPERATOR(input_str[i])) && (rightbracket == 0)){
+ prev_input = &input_str[i];
+ return prev_input;
+ }
+ }
+ return prev_input;
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @return void
+* @exception
+*/
+static void __calculator_op_equal(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ /*duplicate previous input operator and value*/
+ char *p = __calculator_search_prev_input(calculator_input_str);
+ if (p == NULL) {
+ return;
+ }
+ char prev_input[32] = { 0 };
+ int len = g_strlcpy(prev_input, p, sizeof(prev_input));
+ if(len >= sizeof(prev_input)){
+ return;
+ }
+ char temp[32] = { 0 };
+ calc_expr_num_format_result(last_result, temp);
+ _calc_entry_clear(entry);
+
+ if (temp[0] == '-' || strchr(temp, 'E')) {
+ _calc_entry_text_insert(entry, "(");
+ _calc_entry_text_insert(entry, temp);
+ _calc_entry_text_insert(entry, ")");
+ } else {
+ _calc_entry_text_insert(entry, temp);
+ }
+ _calc_entry_text_insert(entry, prev_input);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ }
+
+ double result = 0;
+ char str_buf[MAX_EXPRESSION_LENGTH] = { 0 };
+ char result_buf[MAX_RESULT_LENGTH] = { 0 };
+ int str_len = 0;
+ char error_msg[MAX_ERROR_MESSAGE_LENGTH] = { 0 };
+ calc_expr_close_parentheses(calculator_input_str);
+ _calc_entry_text_set(entry, calculator_input_str);
+ snprintf(str_buf, sizeof(str_buf), "%s", calculator_input_str);
+ str_len = strlen(str_buf);
+ if (str_len == 0) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ return;
+ }
+
+ PLOG("calculate :%s\n", str_buf);
+ if (!calculator_calculate(str_buf, &result, error_msg)) {
+ PLOG("error : %s\n", error_msg);
+ __calculator_wrong_format_create(error_msg);
+ calculator_state = CALCULATOR_ERROR_OCCURED;
+ return;
+ } else {
+ last_result = result;
+ memset(result_buf, 0, CALCULATOR_CONTENT_LEN + 1);
+ calc_expr_num_format_result(result, result_buf);
+ /* save result */
+
+ struct history_item item;
+ memset(item.expression, 0, sizeof(item.expression));
+ memset(item.result, 0, sizeof(item.result));
+ calc_expr_format_expression(calculator_input_str,
+ item.expression);
+ calc_expr_format_expression(result_buf, item.result);
+#ifdef SAVE_HISTORY
+ calc_view_save_history(item);
+#endif
+
+ /* show result */
+ calculator_state = CALCULATOR_CALCULATED;
+ calc_view_show_result(item.result, ad);
+
+ }
+ CONV_FUNC_OUT();
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @return void
+* @exception none
+*/
+static void __calculator_parenthesis_clicked(Evas_Object * entry)
+{
+ CONV_FUNC_IN();
+ char all_input[MAX_EXPRESSION_LENGTH] = { 0 };
+ snprintf(all_input, sizeof(all_input), "%s", calculator_input_str);
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input", "");
+
+ char temp[MAX_RESULT_LENGTH] = { 0 };
+
+ calc_expr_num_format_result(last_result, temp);
+ _calc_entry_clear(entry);
+
+ if (temp[0] == '-' || strchr(temp, 'E') != NULL) //result < 0 or science number
+ {
+ _calc_entry_text_insert(entry, "((");
+ _calc_entry_text_insert(entry, temp);
+ _calc_entry_text_insert(entry, ")");
+ } else {
+ _calc_entry_text_insert(entry, "(");
+ _calc_entry_text_insert(entry, temp);
+ }
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ return;
+ }
+ char before_cursor[MAX_EXPRESSION_LENGTH] = { 0 };
+ int input_len = 0;
+ __calculator_get_input_from_begin_to_cursor(all_input, before_cursor);
+ input_len = strlen(before_cursor);
+
+ if (input_len == 0) {
+ _calc_entry_text_insert(entry, "(");
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ return;
+ }
+ int bracket_num = calculator_get_open_braket(all_input);
+ if (input_len > 0) {
+ if (before_cursor[input_len - 1] == decimal_ch) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ return;
+ } else if (bracket_num > 0 //'(' is more than ')'
+ && before_cursor[input_len - 1] != '('
+ && (before_cursor[input_len - 1] == ')'
+ || isdigit(before_cursor[input_len - 1])
+ ||
+ (__calculator_string_get_char_type
+ (before_cursor[input_len - 1]) == CHAR_IS_PI
+ ||
+ __calculator_string_get_char_type
+ (before_cursor[input_len - 1]) == CHAR_IS_E))) {
+ _calc_entry_text_insert(entry, ")");
+ return;
+ } else if (bracket_num == 0) {
+ if (calc_expr_get_left_parentheses_num
+ (calculator_input_str) < MAX_PARENTHESES_NUM) {
+ _calc_entry_text_insert(entry, "(");
+ }
+ return;
+ } else if (before_cursor[input_len - 1] != ')') //'(' is less than ')'!isdigit(before_cursor[input_len-1])&&(
+ {
+ if (calc_expr_get_left_parentheses_num
+ (calculator_input_str) < MAX_PARENTHESES_NUM) {
+ _calc_entry_text_insert(entry, "(");
+ }
+ return;
+ }
+ }
+ CONV_FUNC_OUT();
+ return;
+}
+
+/**
+* @describe
+*
+*
+* @param entry
+* @param op_item
+* @return void
+* @exception
+*/
+static void
+__calculator_control_functions_button_clicked(Evas_Object * entry,
+ op_item_t * op_item)
+{
+ CONV_FUNC_IN();
+
+ char *str = NULL;
+ function_t function = { 0 };
+
+ memset(&function, 0x0, sizeof(function_t));
+ str = op_item->op_name;
+
+ char all_input[MAX_EXPRESSION_LENGTH] = { 0 };
+ int input_len = 0;
+ char before_cursor[MAX_EXPRESSION_LENGTH] = { 0 };
+ int before_len = 0;
+ last_char_t last_char_type = 0;
+
+ snprintf(all_input, sizeof(all_input), "%s", calculator_input_str);
+ __calculator_get_input_from_begin_to_cursor(all_input, before_cursor);
+ input_len = strlen(all_input);
+ before_len = strlen(before_cursor);
+ if(before_len > 0){
+ last_char_type = __calculator_string_get_char_type(before_cursor[before_len - 1]);
+ }
+
+ switch (op_item->op_id) {
+ case OP_PERCENT:
+ /* if it is calculated state */
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+
+ char temp[CALCULATOR_CONTENT_LEN] = { 0 };
+ double per_result = last_result / 100.0;
+
+ calc_expr_num_format_result(per_result, temp);
+ _calc_entry_clear(entry);
+
+ if (strcmp(temp, "0") == 0) {
+ _calc_entry_text_insert(entry, "0");
+ } else if (temp[0] == '-') //result < 0
+ {
+ _calc_entry_text_insert(entry, "(");
+ _calc_entry_text_insert(entry, temp);
+ _calc_entry_text_insert(entry, ")");
+ } else {
+ _calc_entry_text_insert(entry, temp);
+ }
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ return;
+ }
+
+ {
+ int from_pos, end_pos;
+ char str_num[CALCULATOR_CONTENT_LEN] = { 0 };
+ char temp[CALCULATOR_CONTENT_LEN] = { 0 };
+ double per_result = 0.0;
+
+ if (false ==
+ __calculator_get_cursor_position_float_string
+ (all_input, str_num, calculator_cursor_pos,
+ &from_pos, &end_pos)) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ return;
+ }
+
+ {
+ if (strlen(str_num) == 0) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ return;
+ }
+
+ if (strcmp(str_num, "0") == 0) {
+ return;
+ }
+
+ per_result = atof(str_num);
+ per_result /= 100.0;
+
+ calc_expr_num_format_result(per_result, temp);
+
+ _calc_entry_text_remove(entry, from_pos,
+ end_pos);
+ _calc_entry_text_insert(entry, temp);
+
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ return;
+ }
+ }
+ break;
+ case OP_PI:
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, "p");
+ break;
+ }
+ if ((before_len != 0) && (before_cursor[before_len - 1] != '+')
+ && (before_cursor[before_len - 1] != '-')
+ && (last_char_type != CHAR_IS_MULTIPLY_DIVIDE)
+ && (before_cursor[before_len - 1] != '^')
+ && (before_cursor[before_len - 1] != '(')
+ && (before_cursor[before_len - 1] != 'P')
+ && before_cursor[before_len - 1] != 'C') {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ break;
+ }
+ _calc_entry_text_insert(entry, "p");
+ break;
+
+ case OP_E:
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+ }
+ if ((before_len != 0) && (before_cursor[before_len - 1] != '+')
+ && (before_cursor[before_len - 1] != '-')
+ && (last_char_type != CHAR_IS_MULTIPLY_DIVIDE)
+ && (before_cursor[before_len - 1] != '^')
+ && (before_cursor[before_len - 1] != '(')
+ && (before_cursor[before_len - 1] != 'P')
+ && before_cursor[before_len - 1] != 'C') {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ break;
+ }
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+
+ case OP_SIN: //sin()
+ case OP_COS: //cos()
+ case OP_TAN: //tan()
+ case OP_LOG: //log()
+ case OP_ABS: //abs()
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+ }
+ if (last_char_type == CHAR_IS_PI || last_char_type == CHAR_IS_E) {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ break;
+ }
+
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+
+ case OP_LN: //ln()
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+ }
+ if (last_char_type == CHAR_IS_PI) {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ break;
+ }
+ if ((before_len != 0) && (before_cursor[before_len - 1] != '+')
+ && (before_cursor[before_len - 1] != '-')
+ && (last_char_type != CHAR_IS_MULTIPLY_DIVIDE)
+ && (before_cursor[before_len - 1] != '^')
+ && (before_cursor[before_len - 1] != '(')
+ && (before_cursor[before_len - 1] != 'C')
+ && (before_cursor[before_len - 1] != 'P')) {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ break;
+ }
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+
+ case OP_ROOT: //sqrt()
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+ }
+ if (last_char_type == CHAR_IS_PI) {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ break;
+ }
+ if ((before_len != 0) && (before_cursor[before_len - 1] != '+')
+ && (before_cursor[before_len - 1] != '-')
+ && (last_char_type != CHAR_IS_MULTIPLY_DIVIDE)
+ && (before_cursor[before_len - 1] != '^')
+ && (before_cursor[before_len - 1] != '(')
+ && (before_cursor[before_len - 1] != 'C')
+ && (before_cursor[before_len - 1] != 'P')) {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ break;
+ }
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+
+ case OP_EX: //e^
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+ }
+ if (last_char_type == CHAR_IS_PI) {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ break;
+ }
+ if ((before_len != 0) && (before_cursor[before_len - 1] != '+')
+ && (before_cursor[before_len - 1] != '-')
+ && (last_char_type != CHAR_IS_MULTIPLY_DIVIDE)
+ && (before_cursor[before_len - 1] != '^')
+ && (before_cursor[before_len - 1] != '(')
+ && (before_cursor[before_len - 1] != 'C')
+ && (before_cursor[before_len - 1] != 'P')) {
+ __calculator_wrong_format_create(CALC_MSG_OP_FIRST);
+ break;
+ }
+ _calc_entry_text_insert(entry, op_item->op_name);
+ break;
+
+ case OP_X2: //x^2
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+
+ char temp[CALCULATOR_CONTENT_LEN] = { 0 };
+ calc_expr_num_format_result(last_result, temp);
+ _calc_entry_clear(entry);
+
+ if (temp[0] == '-' || strchr(temp, 'E')) //result < 0 or science number
+ {
+ _calc_entry_text_insert(entry, "(");
+ _calc_entry_text_insert(entry, temp);
+ _calc_entry_text_insert(entry, ")");
+ } else {
+ _calc_entry_text_insert(entry, temp);
+ }
+ _calc_entry_text_insert(entry, op_item->op_name);
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ //use_last_result = 1;
+ return;
+ }
+
+ if (input_len == 0) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST_X2);
+ break;
+ }
+ if (last_char_type == CHAR_IS_PI) {
+ _calc_entry_text_insert(entry, op_item->op_name);
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ break;
+ } else if ((before_len > 0)
+ && (!isdigit(before_cursor[before_len - 1]))
+ && (before_cursor[before_len - 1] != ')')) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST_X2);
+ break;
+ }
+ _calc_entry_text_insert(entry, op_item->op_name);
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ break;
+ case OP_XY: //x^y
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+
+ char temp[CALCULATOR_CONTENT_LEN] = { 0 };
+
+ calc_expr_num_format_result(last_result, temp);
+ _calc_entry_clear(entry);
+
+ if (temp[0] == '-' || strchr(temp, 'E')) //result < 0 or science number
+ {
+ _calc_entry_text_insert(entry, "(");
+ _calc_entry_text_insert(entry, temp);
+ _calc_entry_text_insert(entry, ")");
+ } else {
+ _calc_entry_text_insert(entry, temp);
+ }
+ _calc_entry_text_insert(entry, op_item->op_name);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ return;
+ }
+
+ if (input_len == 0) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST_XY);
+ break;
+ }
+ if ((last_char_type == CHAR_IS_PI)
+ || (last_char_type == CHAR_IS_E)) {
+ _calc_entry_text_insert(entry, op_item->op_name);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ break;
+ } else if ((before_len > 0)
+ && !isdigit(before_cursor[before_len - 1])
+ && (before_cursor[before_len - 1] != ')')) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST_XY);
+ break;
+ }
+ _calc_entry_text_insert(entry, op_item->op_name);
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ break;
+
+ case OP_FACT: //x!
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+
+ char temp[MAX_RESULT_LENGTH] = { 0 };
+
+ calc_expr_num_format_result(last_result, temp);
+
+ if (strchr(temp, decimal_ch) != NULL || strchr(temp, '-') != NULL) //revise by bfl
+ {
+ __calculator_wrong_format_create(CALC_MSG_INVALID_FAC);
+ calculator_state = CALCULATOR_WAITING_INPUT; //revise by bfl
+ return;
+ }
+
+ _calc_entry_clear(entry);
+ _calc_entry_text_insert(entry, "(");
+ _calc_entry_text_insert(entry, temp);
+ _calc_entry_text_insert(entry, "!)");
+
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ return;
+ }
+
+ if (input_len == 0) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST_FAC);
+ break;
+ }
+ if ((last_char_type == CHAR_IS_PI)
+ || (last_char_type == CHAR_IS_E)) {
+ __calculator_wrong_format_create(CALC_MSG_INVALID_FAC);
+ break;
+ }
+
+ /* check if it is natural */
+ {
+ char str_buf[MAX_EXPRESSION_LENGTH] = { 0 };
+ int from_pos = 0, end_pos = 0;
+
+ if (false ==
+ __calculator_get_cursor_position_float_string
+ (all_input, str_buf, calculator_cursor_pos,
+ &from_pos, &end_pos)) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST);
+ break;
+ }
+
+ if (strchr(str_buf, decimal_ch) != NULL
+ || str_buf[0] == '-') {
+ __calculator_wrong_format_create(CALC_MSG_INVALID_FAC);
+ break;
+ }
+
+ _calc_entry_text_remove(entry, from_pos, end_pos);
+ _calc_entry_text_insert(entry, "(");
+ _calc_entry_text_insert(entry, str_buf);
+ _calc_entry_text_insert(entry, "!)");
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ }
+ break;
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+ case OP_1X:
+ if (calculator_state == CALCULATOR_CALCULATED) {
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+
+ char temp[MAX_RESULT_LENGTH] = { 0 };
+ int i = 0;
+
+ calc_expr_num_format_result(last_result, temp);
+ if (strchr(temp, 'E') != NULL) //science number
+ {
+ temp[strlen(temp)] = ')';
+ for (i = strlen(temp); i > 0; --i) {
+ temp[i] = temp[i - 1];
+ }
+ temp[0] = '(';
+ }
+
+ _calc_entry_clear(entry);
+ if (temp[0] == '-') {
+ _calc_entry_text_insert(entry, "(-1");
+ _calc_entry_text_insert(entry, "/");
+
+ _calc_entry_text_insert(entry, &temp[1]);
+ _calc_entry_text_insert(entry, ")");
+ } else {
+ _calc_entry_text_insert(entry, "(1");
+ _calc_entry_text_insert(entry, "/");
+
+ _calc_entry_text_insert(entry, temp);
+ _calc_entry_text_insert(entry, ")");
+ }
+
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ //use_last_result = 1;
+ return;
+ }
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+ if (input_len == 0) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST_RECIP);
+ break;
+ }
+
+ /* check if it is digit */
+ {
+ char str_buf[MAX_EXPRESSION_LENGTH] = { 0 };
+ int from_pos = 0, end_pos = 0;
+
+ if (false ==
+ __calculator_get_cursor_position_float_string
+ (all_input, str_buf, calculator_cursor_pos,
+ &from_pos, &end_pos)) {
+ __calculator_wrong_format_create(CALC_MSG_NUM_FIRST_RECIP);
+ break;
+ }
+
+ if (strcmp(str_buf, "p") && strcmp(str_buf, "e")
+ && atof(str_buf) == 0) {
+ __calculator_wrong_format_create(CALC_MSG_DIVIDE_BY_ZERO);
+ break;
+ }
+
+ _calc_entry_text_remove(entry, from_pos, end_pos);
+ if (str_buf[0] == '-') {
+ _calc_entry_text_insert(entry, "(-1");
+ _calc_entry_text_insert(entry, "/");
+
+ _calc_entry_text_insert(entry, &str_buf[1]);
+ _calc_entry_text_insert(entry, ")");
+ } else {
+ _calc_entry_text_insert(entry, "(1");
+ _calc_entry_text_insert(entry, "/");
+
+ _calc_entry_text_insert(entry, str_buf);
+ _calc_entry_text_insert(entry, ")");
+ }
+
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ }
+ break;
+
+ default:
+ break;
+ }
+ calculator_state = CALCULATOR_SPECIAL_FUNCTION_INPUT;
+ CONV_FUNC_OUT();
+ return;
+}
+
+/////////////////////////// input text finish ////////////////////////////
+
+/**
+* @describe
+*
+*
+* @param evas_obj
+* @param obj
+* @return void
+* @exception
+*/
+static int _calculator_get_input_item(Evas_Object * evas_obj, Evas_Object * obj)
+{
+ CONV_FUNC_IN();
+
+ int val = 0;
+ if (evas_obj == edje_object_part_object_get(obj, "item_brack")) {
+ val = OP_PARENTHESIS;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_del")) {
+ val = OP_DELETE;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_c")) {
+ val = OP_CLEAR;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_div")) {
+ val = OP_DIVIDE;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num7")) {
+ val = OP_NUM_7;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num8")) {
+ val = OP_NUM_8;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num9")) {
+ val = OP_NUM_9;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_mul")) {
+ val = OP_MULTIPLY;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num4")) {
+ val = OP_NUM_4;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num5")) {
+ val = OP_NUM_5;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num6")) {
+ val = OP_NUM_6;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_sub")) {
+ val = OP_MINUS;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num1")) {
+ val = OP_NUM_1;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num2")) {
+ val = OP_NUM_2;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num3")) {
+ val = OP_NUM_3;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_plus")) {
+ val = OP_PLUS;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_dot")) {
+ val = OP_DOT;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_num0")) {
+ val = OP_NUM_0;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_neg")) {
+ val = OP_PLUS_MINUS;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_eq")) {
+ val = OP_EQUAL;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_per")) {
+ val = OP_PERCENT;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_sqr")) {
+ val = OP_ROOT;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_fac")) {
+ val = OP_FACT;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_sin")) {
+ val = OP_SIN;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_cos")) {
+ val = OP_COS;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_tan")) {
+ val = OP_TAN;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_ln")) {
+ val = OP_LN;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_log")) {
+ val = OP_LOG;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_1x")) {
+ val = OP_1X;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_ex")) {
+ val = OP_EX;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_x2")) {
+ val = OP_X2;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_xy")) {
+ val = OP_XY;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_abs")) {
+ val = OP_ABS;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_pi")) {
+ val = OP_PI;
+ } else if (evas_obj == edje_object_part_object_get(obj, "item_e")) {
+ val = OP_E;
+ }
+ CONV_FUNC_OUT();
+ return val;
+}
+
+/**
+* @description
+* Interpret all of our different signals, and do things !
+*
+* @param data
+* @param e
+* @param evas_obj
+* @param event_info
+* @return void
+* @exception none
+*/
+static void
+_calculator_interp(void *data, Evas * e, Evas_Object * evas_obj,
+ void *event_info)
+{
+ CONV_FUNC_IN();
+
+ int val = 0;
+ if (data && ad->popup == NULL) {
+ Evas_Object *obj = (Evas_Object *) data;
+ val = _calculator_get_input_item(evas_obj, obj);
+ if (ad->wrong_timer) {
+ ecore_timer_del(ad->wrong_timer);
+ ad->wrong_timer = NULL;
+ }
+ _calc_entry_text_set(ad->input_entry, calculator_input_str);
+ switch (val) {
+ case OP_DELETE:
+ _calc_btn_backspace_clicked(ad->input_entry);
+ if (ad->calc_timer) {
+ ecore_timer_del(ad->calc_timer);
+ ad->calc_timer = NULL;
+ }
+ ad->calc_timer =
+ ecore_timer_add(0.1,
+ (Ecore_Task_Cb)
+ __calculator_delete_long_press,
+ ad->input_entry);
+ break;
+ case OP_CLEAR:
+ edje_object_signal_emit(_EDJ(ad->edje), "show,input",
+ "");
+ _calc_entry_clear(ad->input_entry);
+ calculator_state = CALCULATOR_WAITING_INPUT;
+ break;
+ case OP_PLUS:
+ case OP_MINUS:
+ case OP_MULTIPLY:
+ case OP_DIVIDE:
+ __calculator_control_normal_func_clicked(ad->
+ input_entry,
+ &calc_op_item
+ [val]);
+ break;
+ case OP_EQUAL:
+ __calculator_op_equal(ad->input_entry);
+ break;
+ case OP_DOT:
+ _calc_btn_dot_clicked(ad->input_entry);
+ break;
+ case OP_PARENTHESIS:
+ __calculator_parenthesis_clicked(ad->input_entry);
+ break;
+ case OP_NUM_0:
+ case OP_NUM_1:
+ case OP_NUM_2:
+ case OP_NUM_3:
+ case OP_NUM_4:
+ case OP_NUM_5:
+ case OP_NUM_6:
+ case OP_NUM_7:
+ case OP_NUM_8:
+ case OP_NUM_9:
+ __calculator_control_panel_number_button_clicked(ad->
+ input_entry,
+ &calc_op_item
+ [val]);
+ break;
+ case OP_PLUS_MINUS:
+ __calculator_symbol_negative_clicked(ad->input_entry);
+ break;
+ case OP_PERCENT...OP_E:
+ __calculator_control_functions_button_clicked(ad->
+ input_entry,
+ &calc_op_item
+ [val]);
+ break;
+ default:
+ break;
+ }
+ if (ad->svi_handle) {
+ svi_play_sound(ad->svi_handle, SVI_SND_TOUCH_SIP);
+ svi_play_vib(ad->svi_handle, SVI_VIB_TOUCH_SIP);
+ }
+ }
+
+ CONV_FUNC_OUT();
+}
+
+static void __calculator_wrong_format_delete(Evas_Object *in_entry)
+{
+ _calc_entry_text_set(in_entry, calculator_input_str);
+ if (ad->wrong_timer) {
+ ecore_timer_del(ad->wrong_timer);
+ ad->wrong_timer = NULL;
+ }
+}
+
+static void __calculator_wrong_text_set(char * wrong_string)
+{
+ char buf[MAX_EXPRESSION_LENGTH] = { 0 };
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf),
+ "<align=right><+ font_size=%d><color=#855B11FF>%s",
+ get_max_fontsize(), wrong_string);
+ elm_entry_entry_set(ad->input_entry, buf);
+ elm_entry_cursor_end_set(ad->input_entry);
+ calc_view_revise_input_scroller(ad);
+}
+
+/**
+* @describe
+*
+*
+* @param msg
+* @return void
+* @exception none
+*/
+static void __calculator_wrong_format_create(char * wrong_string)
+{
+ __calculator_wrong_text_set(wrong_string);
+ if (ad->wrong_timer) {
+ ecore_timer_del(ad->wrong_timer);
+ ad->wrong_timer = NULL;
+ }
+ ad->wrong_timer =
+ ecore_timer_add(2,
+ (Ecore_Task_Cb)
+ __calculator_wrong_format_delete,
+ ad->input_entry);
+}
+
+/* mouse up for delete button. */
+static void
+__calculator_delelte_up(void *data, Evas * e, Evas_Object * evas_obj,
+ void *event_info)
+{
+ if (ad->calc_timer) {
+ ecore_timer_del(ad->calc_timer);
+ ad->calc_timer = NULL;
+ }
+}
+
+/**
+* @describe
+* Register clicked callback of the keys on the keypad.
+*
+* @param keypad the keypad
+* @return void
+*/
+static void _calc_view_keypad_cb_register(Evas_Object * keypad)
+{
+ char *key_name[] = {
+ "item_per", "item_sqr", "item_fac", "item_c", "item_div",
+ "item_mul", "item_del",
+ "item_sin", "item_cos", "item_tan", "item_num7", "item_num8",
+ "item_num9", "item_sub",
+ "item_ln", "item_log", "item_1x", "item_num4", "item_num5",
+ "item_num6", "item_plus",
+ "item_ex", "item_x2", "item_xy", "item_num1", "item_num2",
+ "item_num3", "item_brack",
+ "item_abs", "item_pi", "item_e", "item_num0", "item_dot",
+ "item_neg", "item_eq",
+ };
+
+ Evas_Object *item = NULL;
+ int key_num = sizeof(key_name) / sizeof(key_name[0]);
+ int i = 0;
+
+ for (i = 0; i < key_num; ++i) {
+ item =
+ (Evas_Object *) edje_object_part_object_get(keypad,
+ key_name[i]);
+ if (item != NULL) {
+ evas_object_event_callback_add(item,
+ EVAS_CALLBACK_MOUSE_DOWN,
+ _calculator_interp,
+ (void *)keypad);
+ if (0 == strcmp(key_name[i], "item_del")) {
+ evas_object_event_callback_add(item,
+ EVAS_CALLBACK_MOUSE_UP,
+ __calculator_delelte_up,
+ (void *)keypad);
+ }
+
+ }
+ }
+}
+
+/**
+* @description
+* The callback of input entry when mouse up.
+*
+* @param data unused
+* @param e unused
+* @param entry the input entry
+* @param event_info unused
+* @return void
+*/
+static void
+_calc_view_input_entry_mouseup_cb(void *data, Evas * e, Evas_Object * entry,
+ void *event_info)
+{
+ calculator_cursor_pos = calc_view_cursor_get_position(entry); //for softkey input and mouse move
+}
+
+static void
+_calc_view_input_entry_to_str(char *entry_str, char *internal_str, int buf_size)
+{
+ strncpy(internal_str, entry_str, buf_size - 1);
+ /* remove result that behind '='(include '=') */
+ char *enter = strchr(internal_str, '=');
+ if (enter != NULL) {
+ enter--;
+ *enter = '\0';
+ }
+ calc_expr_replace_from_special_char(internal_str);
+ /* remove all ',' and '\n'*/
+ int i = 0;
+ int j = 0;
+ while (internal_str[j] != '\0'){
+
+ if (internal_str[j] == separator_ch || internal_str[j] == '\n'){
+ j++;
+ } else {
+ internal_str[i++] = internal_str[j++];
+ }
+ }
+ internal_str[i] = '\0';
+
+}
+
+#ifdef __i386__
+static void
+_calc_view_input_entry_keyup_cb(void *data, Evas * e, Evas_Object * entry,
+ void *event_info)
+{
+ calculator_cursor_pos = calc_view_cursor_get_position(entry); //for hardkey input
+ if (data) {
+ Evas_Event_Key_Up *evt = (Evas_Event_Key_Up *) event_info;
+ printf("keyname: %s\n", (char *)evt->keyname);
+ if ((0 == strcmp(evt->keyname, "XF86Phone"))||
+ (0 == strcmp(evt->keyname, "XF86PowerOff"))||
+ (0 == strcmp(evt->keyname, "XF86AudioRaiseVolume"))||
+ (0 == strcmp(evt->keyname, "XF86AudioLowerVolume"))){
+ return;
+ }
+ _calc_entry_backspace(ad->input_entry);
+ }
+}
+#endif
+static bool
+_calc_view_input_entry_error_include(char *string)
+{
+ int i = 0;
+ for(; i < ARRAY_SIZE(error_string); i++)
+ {
+ if(!strcmp(string, _(error_string[i]))){
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/**
+* @description
+* The callback of input entry when text changed.
+*
+* @param data the appdata
+* @param [in]obj the input entry
+* @param event_info unused
+* @return void
+*/
+static void
+_calc_view_input_entry_changed_cb(void *data, Evas_Object * obj,
+ void *event_info)
+{
+ struct appdata *ad = (struct appdata *)data;
+ PLOG("Input entry test changed\n"); /* Don't remove the log. It can guard against recursion. */
+ const char *str = (char *)elm_entry_entry_get(obj);
+
+ if (paste_flag) {
+ char *entry_tmp = elm_entry_markup_to_utf8(str);
+ char *entry_expr= elm_entry_markup_to_utf8(entry_tmp);/*because the string format from clipboard is not correct*/
+ char internal_expr[MAX_EXPRESSION_LENGTH] = { 0 };
+ char f_number_buf[NUMBER_LENGTH] = { 0 };
+ char s_number_buf[NUMBER_LENGTH] = { 0 };
+ paste_flag = FALSE;
+ _calc_view_input_entry_to_str(entry_expr, internal_expr,
+ MAX_EXPRESSION_LENGTH);
+ int index = 0;
+ bool char_in =__calculator_string_invalid_char_search(internal_expr, &index);
+ __calculator_get_cursor_position_float_string(internal_expr,
+ f_number_buf,
+ calculator_cursor_pos,
+ NULL, NULL);
+ int cur_pos = calc_view_cursor_get_position(ad->input_entry);
+ __calculator_get_cursor_position_float_string(internal_expr,
+ s_number_buf,
+ cur_pos, NULL,
+ NULL);
+ int nCntOp = calc_expr_get_operator_num(internal_expr);
+
+ if ((strlen(f_number_buf) > MAX_NUM_LENGTH)
+ || (strlen(s_number_buf) > MAX_NUM_LENGTH)) {
+ __calculator_wrong_format_create(CALC_MSG_MAX_DIGIT);
+ } else if (nCntOp >= MAX_OPERATOR_NUM) {
+ __calculator_wrong_format_create(CALC_MSG_MAX_OP);
+ } else {
+ if(char_in){
+ strncpy(calculator_input_str, internal_expr,
+ index);
+ calculator_cursor_pos = index;
+ }else{
+ strncpy(calculator_input_str, internal_expr,
+ sizeof(calculator_input_str) - 1);
+ calculator_cursor_pos = cur_pos;
+ }
+ _calc_entry_text_set(ad->input_entry, calculator_input_str);
+ }
+
+ if (entry_expr) {
+ free(entry_expr);
+ }
+ }else{
+ char *entry_expr_s = elm_entry_markup_to_utf8(str);
+ char internal_expr_s[MAX_EXPRESSION_LENGTH] = { 0 };
+ _calc_view_input_entry_to_str(entry_expr_s, internal_expr_s,
+ MAX_EXPRESSION_LENGTH);
+ if(!_calc_view_input_entry_error_include(internal_expr_s)){
+ /*change calculator_input_str, after cut operation*/
+ strncpy(calculator_input_str, internal_expr_s,
+ MAX_EXPRESSION_LENGTH - 1);
+ }
+ }
+ /*
+ * Prevent pasting images into entry.
+ * If a image pasted, "<item absize=... href=...>" will be appended into entry.
+ */
+ if (strstr(str, "item") != NULL) {
+ int pos = 0;
+ char buf[MAX_EXPRESSION_LENGTH] = { 0 };
+
+ while (elm_entry_cursor_prev(obj)) {
+ pos++;
+ } /* save cursor position */
+ pos -= 1; /* correct */
+
+ strncpy(buf, str, sizeof(buf));
+ char *begin = strstr(buf, "<item");
+ char *end = strchr(begin, '>');
+ string_remove_at(buf, begin - buf, end - begin + 1); /* remove "<item...>" */
+ elm_entry_entry_set(obj, buf);
+
+ while (pos--) {
+ elm_entry_cursor_next(obj);
+ } /* retrieve cursor position */
+
+ calc_view_revise_input_scroller(ad);
+ }
+
+}
+
+static void
+_calc_view_input_entry_paste_cb(void *data, Evas_Object * obj, void *event_info)
+{
+ CONV_FUNC_IN();
+ paste_flag = TRUE;
+ strncpy(calculator_before_paste_str, calculator_input_str,
+ MAX_EXPRESSION_LENGTH - 1);
+ printf("line = %d\n", __LINE__);
+ CONV_FUNC_OUT();
+}
+
+static void
+__conv_view_clear_clicked_cb(void *data, Evas_Object * obj, const char *emission, const char *source)
+{
+
+ CONV_FUNC_IN();
+
+ struct appdata *ad = (struct appdata *)data;
+ elm_entry_entry_set(ad->hist_area, "");
+ elm_entry_entry_set(ad->input_entry, "");
+ _calc_view_clear_histroy(ad->hist_area);
+
+ CONV_FUNC_OUT();
+}
+
+/**
+* @description
+* Create an entry for inputing expression.
+*
+* @param parent the entry's parent
+* @param ad the appdata
+* @return Evas_Object* the input entry
+*/
+static Evas_Object *_calc_view_create_input_entry(Evas_Object * parent,
+ struct appdata *ad)
+{
+ CONV_FUNC_IN();
+ Evas_Object *entry = elm_entry_add(ad->edje);
+ elm_entry_single_line_set(entry, EINA_FALSE);
+ elm_entry_line_wrap_set(entry, ELM_WRAP_WORD);
+ elm_entry_editable_set(entry, EINA_TRUE);
+ elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
+ elm_entry_entry_set(entry, "");
+ elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_NO_IMAGE);
+ elm_entry_magnifier_disabled_set(entry, EINA_TRUE);
+ elm_entry_cursor_end_set(entry);
+ elm_object_style_set(entry, "black");
+ evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ evas_object_event_callback_add(entry, EVAS_CALLBACK_MOUSE_UP,
+ _calc_view_input_entry_mouseup_cb, ad);
+ evas_object_smart_callback_add(entry, "changed",
+ _calc_view_input_entry_changed_cb, ad);
+ evas_object_smart_callback_add(entry, "selection,paste",
+ _calc_view_input_entry_paste_cb, ad);
+#ifdef __i386__
+ evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_UP,
+ _calc_view_input_entry_keyup_cb, ad);
+#endif
+ evas_object_show(entry);
+ limit_filter_data.max_char_count = 0;
+ limit_filter_data.max_byte_count = 419 + 20; //19*21+20//result:20
+ elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size,
+ &limit_filter_data);
+ CONV_FUNC_OUT();
+ return entry;
+}
+
+/**
+* @description
+* Create a input scrooler which around the input entry.
+* It can give a input entry a scroller.
+*
+* @param parent the parent of input scroller
+* @return Evas_Object* the input scroller
+* @exception
+*/
+static Evas_Object *_calc_view_create_input_scroller(Evas_Object * parent)
+{
+ CONV_FUNC_IN();
+ Evas_Object *scroller = elm_scroller_add(parent);
+ elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
+ evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+
+ evas_object_show(scroller);
+
+ CONV_FUNC_OUT();
+
+ return scroller;
+}
+
+/**
+* @description
+* Create the main layout.
+*
+* @param parent main layout's parent
+* @return Evas_Object* when success return a layout, return NULL oppositely.
+*/
+static Evas_Object *_calc_view_create_layout_main(Evas_Object * parent)
+{
+ CONV_FUNC_IN();
+
+ if (parent == NULL) {
+ return NULL;
+ }
+
+ Evas_Object *layout = elm_layout_add(parent);
+ if (layout == NULL) {
+ return NULL;
+ }
+
+ elm_layout_theme_set(layout, "standard", "window", "integration");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(parent, layout);
+
+ edje_object_signal_emit(_EDJ(layout), "elm,state,show,content", "elm");
+ edje_object_signal_emit(_EDJ(layout), "elm,state,show,indicator",
+ "elm");
+ evas_object_show(layout);
+
+ CONV_FUNC_OUT();
+
+ return layout;
+}
+
+/**
+* @description
+* Load the main view of calculator.
+* Create the input entry and keypad.
+*
+* @param ad the appdata
+* @return void
+*/
+void calc_view_load(struct appdata *ad)
+{
+ CONV_FUNC_IN();
+
+ ad->layout = _calc_view_create_layout_main(ad->win);
+ ad->edje = load_edj(ad->win, LAYOUT_EDJ_NAME, GRP_MAIN);
+ evas_object_show(ad->edje);
+ evas_object_name_set(ad->edje, "edje");
+ elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->edje);
+
+ /* inititialize environment variable */
+ locale = localeconv();
+ decimal = locale->decimal_point;
+ separator = locale->thousands_sep;
+ int len_seq = strlen(separator);
+ decimal_ch = decimal[0];
+ separator_ch = separator[0];
+ if (len_seq == 2 || len_seq == 0) {
+ separator_ch = 32;
+ }
+ /*init svi */
+ svi_init(&ad->svi_handle);
+
+ /* input area */
+ ad->input_entry = _calc_view_create_input_entry(ad->edje, ad);
+ ad->input_scroller = _calc_view_create_input_scroller(ad->edje);
+ elm_object_content_set(ad->input_scroller, ad->input_entry);
+ edje_object_part_swallow(_EDJ(ad->edje), "input/entry",
+ ad->input_scroller);
+ edje_object_signal_callback_add(_EDJ(ad->edje), "clicked", "",
+ __conv_view_clear_clicked_cb, ad);
+
+ /* pannels */
+ ad->por_pannel = load_edj(ad->edje, LAYOUT_EDJ_NAME, GRP_POR_PANNEL);
+ edje_object_part_swallow(_EDJ(ad->edje), "por_pannel/rect",
+ ad->por_pannel);
+ edje_object_signal_emit(_EDJ(ad->edje), "portrait", "");
+ _calc_view_keypad_cb_register(_EDJ(ad->por_pannel));
+
+ CONV_FUNC_OUT();
+
+}
+
+/**
+* @description
+* assign global variable , this will be removed
+*
+* @param ad
+* @return void
+* @exception
+*/
+void calc_xxx(struct appdata *ap)
+{
+ ad = ap;
+}
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#include <math.h> /* For math functions, cos(), sin(), etc. */
+#include <dlog.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include "calc-main.h"
+#include "calc-string.h"
+#include "calc-expression.h"
+#include "calculator_parser.h"
+
+#define CALCULATOR_MAX_FUNC_NUMBER 16 /**<maximum num of function*/
+
+extern char decimal_ch;
+static char g_stack[MAX_EXPRESSION_LENGTH];
+
+static calculator_parentheses_data_t g_parentheses_data[MAX_PARENTHESES_NUM];
+
+static int oper_num = 0;
+
+static const function_t g_functions[CALCULATOR_MAX_FUNC_NUMBER] = {
+ {"x^y", "^", 1, '^', FUNCTION_POSTFIX, OPERATOR_TYPE_BINARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGH, FALSE},
+ {"ln", "ln", 2, 'L', FUNCTION_PREFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, TRUE},
+ {"sqrt", "sqrt", 4, 'q', FUNCTION_PREFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, TRUE},
+ {"e^x", "e^", 2, 'E', FUNCTION_PREFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, FALSE},
+ {"x!", "!", 1, '!', FUNCTION_POSTFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHEST, FALSE},
+ {"1/x", "/", 1, 'x', FUNCTION_POSTFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHEST, FALSE},
+ {"sin", "sin", 3, 's', FUNCTION_PREFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, TRUE},
+ {"cos", "cos", 3, 'c', FUNCTION_PREFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, TRUE},
+ {"tan", "tan", 3, 't', FUNCTION_PREFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, TRUE},
+ {"Pi", "p", 1, 'p', FUNCTION_CONSTANT, OPERATOR_TYPE_INVALID,
+ CALCULATOR_CALCULATE_PRIORITY_INVALID, FALSE},
+ {"e", "e", 1, 'e', FUNCTION_CONSTANT, OPERATOR_TYPE_INVALID,
+ CALCULATOR_CALCULATE_PRIORITY_INVALID, FALSE},
+ {"log", "log", 3, 'l', FUNCTION_PREFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, TRUE},
+ {"abs", "abs", 3, 'b', FUNCTION_PREFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, TRUE},
+ {"2^x", "2^", 2, '2', FUNCTION_PREFIX, OPERATOR_TYPE_UNARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGHER, FALSE},
+ {"xCy", "C", 1, 'C', FUNCTION_POSTFIX, OPERATOR_TYPE_BINARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGH, FALSE},
+ {"xPy", "P", 1, 'P', FUNCTION_POSTFIX, OPERATOR_TYPE_BINARY,
+ CALCULATOR_CALCULATE_PRIORITY_HIGH, FALSE},
+};
+
+#define CALCULATOR_GET_NODE_DATA(t) ((calculator_node_data_t*)(((GNode*)(t))->data))/**<to get data from GNode structure*/
+
+/**
+* @describe
+*
+*
+* @param out_tree
+* @param to_insert
+* @param const_node
+* @return gboolean
+* @exception
+*/
+static gboolean
+__calculator_calculate_insert_node(GNode ** out_tree, GNode * to_insert,
+ GNode * const_node)
+{
+ GNode *upper_node = NULL;
+ GNode *node = NULL;
+ calculator_node_data_t *node_data = NULL;
+
+ if ((!out_tree) || (!*out_tree) || (!to_insert)) {
+ return FALSE;
+ }
+
+ upper_node = *out_tree;
+ node = upper_node;
+
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ while (CALCULATOR_GET_NODE_DATA(upper_node)->node_calcu_priority >
+ CALCULATOR_GET_NODE_DATA(to_insert)->node_calcu_priority) {
+ if (G_NODE_IS_ROOT(upper_node)) {
+ g_node_insert(to_insert, -1, upper_node);
+ CALCULATOR_GET_NODE_DATA(to_insert)->children_num++;
+
+ if (const_node) {
+ g_node_insert(*out_tree, -1, const_node); //value of last node's priority>= upper_node's > to_insert's
+ CALCULATOR_GET_NODE_DATA(*out_tree)->
+ children_num++;
+ }
+ break;
+ }
+ node = upper_node;
+ upper_node = upper_node->parent;
+ }
+
+ if (CALCULATOR_GET_NODE_DATA(upper_node)->node_calcu_priority ==
+ CALCULATOR_GET_NODE_DATA(to_insert)->node_calcu_priority) {
+ if (CALCULATOR_GET_NODE_DATA(to_insert)->operator_type ==
+ OPERATOR_TYPE_BINARY) {
+ GNode *parent_node = NULL;
+
+ if (!G_NODE_IS_ROOT(upper_node)) {
+ parent_node = upper_node->parent;
+ g_node_unlink(upper_node);
+ g_node_insert(parent_node, -1, to_insert);
+ }
+
+ g_node_insert(to_insert, -1, upper_node);
+ CALCULATOR_GET_NODE_DATA(to_insert)->children_num++;
+
+ if (const_node) {
+ g_node_insert(*out_tree, -1, const_node);
+ CALCULATOR_GET_NODE_DATA(*out_tree)->
+ children_num++;
+ }
+ } else if (CALCULATOR_GET_NODE_DATA(to_insert)->operator_type ==
+ OPERATOR_TYPE_UNARY) {
+ GNode *tmp_node = NULL;
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ if (const_node) {
+ node_data =
+ g_malloc0(sizeof(calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type = OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tmp_node = g_node_new(node_data);
+
+ if (CALCULATOR_GET_NODE_DATA(to_insert)->
+ cur_operator != '!') {
+ __calculator_calculate_insert_node
+ (out_tree, tmp_node, const_node);
+ } else //(CALCULATOR_GET_NODE_DATA(to_insert)->cur_operator == '!')
+ {
+ g_node_insert(to_insert, -1,
+ const_node);
+ CALCULATOR_GET_NODE_DATA(to_insert)->
+ children_num++;
+ }
+
+ g_node_insert(*out_tree, -1, to_insert);
+ CALCULATOR_GET_NODE_DATA(*out_tree)->
+ children_num++;
+ } else {
+ g_node_insert(upper_node, -1, to_insert); //combine from right
+ CALCULATOR_GET_NODE_DATA(upper_node)->
+ children_num++;
+ }
+ }
+ } else if (CALCULATOR_GET_NODE_DATA(upper_node)->node_calcu_priority <
+ CALCULATOR_GET_NODE_DATA(to_insert)->node_calcu_priority) {
+ if (CALCULATOR_GET_NODE_DATA(to_insert)->operator_type ==
+ OPERATOR_TYPE_BINARY) {
+ if (node != upper_node) {
+ g_node_unlink(node);
+ CALCULATOR_GET_NODE_DATA(upper_node)->
+ children_num--;
+
+ g_node_insert(to_insert, -1, node);
+ CALCULATOR_GET_NODE_DATA(to_insert)->
+ children_num++;
+ }
+
+ if (const_node) {
+ if (CALCULATOR_GET_NODE_DATA(*out_tree)->
+ node_calcu_priority >
+ CALCULATOR_GET_NODE_DATA(to_insert)->
+ node_calcu_priority) {
+ g_node_insert(*out_tree, -1,
+ const_node);
+ CALCULATOR_GET_NODE_DATA(*out_tree)->
+ children_num++;
+ } else {
+ g_node_insert(to_insert, -1,
+ const_node);
+ CALCULATOR_GET_NODE_DATA(to_insert)->
+ children_num++;
+ }
+ }
+
+ g_node_insert(upper_node, -1, to_insert);
+ CALCULATOR_GET_NODE_DATA(upper_node)->children_num++;
+ }
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ else if (CALCULATOR_GET_NODE_DATA(to_insert)->operator_type == OPERATOR_TYPE_UNARY) //upper_node must be equal to node equalized to *out_tree, for no functions' prority higher than unary operator
+ {
+ if (const_node) {
+
+ if (CALCULATOR_GET_NODE_DATA(to_insert)->
+ cur_operator != '!') {
+ GNode *tmp_node = NULL;
+
+ node_data =
+ g_malloc0(sizeof
+ (calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type =
+ OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tmp_node = g_node_new(node_data);
+
+ __calculator_calculate_insert_node
+ (out_tree, tmp_node, const_node);
+ } else //(CALCULATOR_GET_NODE_DATA(to_insert)->cur_operator == '!')
+ {
+ g_node_insert(to_insert, -1,
+ const_node);
+ CALCULATOR_GET_NODE_DATA(to_insert)->
+ children_num++;
+ }
+ }
+
+ g_node_insert(*out_tree, -1, to_insert);
+ CALCULATOR_GET_NODE_DATA(*out_tree)->children_num++;
+ }
+
+ }
+
+ *out_tree = to_insert;
+ return TRUE;
+}
+
+/**
+* @describe
+*
+*
+* @param node
+* @param data
+* @return gboolean
+* @exception
+*/
+static gboolean
+__calculator_tree_destroy_traverse_func(GNode * node, gpointer data)
+{
+ if (CALCULATOR_GET_NODE_DATA(node)) {
+ g_free(CALCULATOR_GET_NODE_DATA(node));
+ }
+ g_node_destroy(node);
+ return FALSE;
+}
+
+/**
+* @describe
+*
+*
+* @param tree
+* @return gboolean
+* @exception
+*/
+static gboolean __calculator_tree_destroy_all(GNode ** tree)
+{
+ guint depth = 0;
+ GNode *root = NULL;
+
+ if (*tree) {
+ root = g_node_get_root(*tree);
+ depth = g_node_max_height(root);
+ g_node_traverse(root, G_POST_ORDER, G_TRAVERSE_ALL, depth,
+ __calculator_tree_destroy_traverse_func, NULL);
+
+ *tree = NULL;
+ }
+ return TRUE;
+}
+
+/**
+* @describe
+*
+*
+* @param result
+* @param error_msg
+* @return gboolean
+* @exception
+*/
+static gboolean __calculator_check_overflow(double result, char *error_msg)
+{
+ if ((result > CALCULATOR_MAX_RESULT_SUM2)
+ || (result < CALCULATOR_MIN_RESULT_SUM2)) {
+ strcat(error_msg, CALC_MSG_OUT_OF_RANGE);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+* @describe
+* add parenthesis between function and paremeter.
+*
+* @param exp
+* @param func
+* @return void
+* @exception
+*/
+static void __calculator_expression_add_parenthesis(char *exp, const char *func)
+{
+ char *p = exp;
+ char *digit = "0123456789.";
+
+ while ((p = strstr(p, func)) != NULL) {
+ p = p + strlen(func);
+ if (*p != '(') {
+ int l = strspn(p, digit);
+ string_insert(exp, p - exp, "(");
+ string_insert(exp, p - exp + l + 1, ")");
+ p += l + 2;
+ }
+ }
+}
+
+/**
+* @describe
+* If sin/cos/tan function omitted parenthesis, add it
+*
+* @param exp
+* @return void
+* @exception
+*/
+static void __calculator_expression_tri_func_parenthesis(char *exp)
+{
+ __calculator_expression_add_parenthesis(exp, "sin");
+ __calculator_expression_add_parenthesis(exp, "cos");
+ __calculator_expression_add_parenthesis(exp, "tan");
+}
+
+/**
+* @describe
+* record every matching parentheses position
+*
+* @param string
+* @param end_pos
+* @param error_msg
+* @return bool
+* @exception
+*/
+static bool
+__calculator_calculate_formula_scan(char *string, int *end_idx, char *error_msg)
+{
+ CONV_FUNC_IN();
+ gint i = 0;
+ gchar *p = NULL;
+
+ p = string;
+ memset(g_parentheses_data, 0x0, sizeof(g_parentheses_data));
+
+ __calculator_expression_tri_func_parenthesis(string);
+
+ while (*p != '\0') {
+ if (*p == '(') {
+ while (g_parentheses_data[i].start_pos) {
+ i++;
+ }
+ g_parentheses_data[i].start_pos = p;
+ }
+ if (*p == ')') {
+ while (g_parentheses_data[i].end_pos) {
+ i--;
+ }
+ if (g_parentheses_data[i].start_pos) {
+ g_parentheses_data[i].end_pos = p;
+ }
+ }
+ p++;
+ }
+ *end_idx = p - 1 - string;
+ CONV_FUNC_OUT();
+ return TRUE;
+}
+
+/**
+* @describe
+*
+*
+* @param n
+* @param err_msg
+* @return double
+* @exception
+*/
+static double __calculator_calculate_factorial(double n, char *err_msg)
+{
+ if (n < 0) {
+ strcat(err_msg, CALC_MSG_INVALID_FAC);
+ return -1;
+ } else if (n >= 30) {
+ strcat(err_msg, CALC_MSG_OUT_OF_RANGE);
+ return -1;
+ }
+
+ double i = 0;
+ double result = 1;
+ for (i = 2; i <= n; ++i) {
+ result *= i;
+ }
+ return result;
+}
+
+/**
+* @describe
+* Judge the op is a operator, if yes, give fucntion type
+*
+* @param op
+* @param function
+* @return gboolean
+* @exception
+*/
+static gboolean __calculator_util_get_operator(char *op, function_t * function)
+{
+ gint i = 0;
+ gboolean ret = FALSE;
+ if ((*op == decimal_ch) || (*op == '(') || (*op == ')')) {
+ ret = FALSE;
+ } else if (isdigit(*op)) {
+ ret = FALSE;
+ } else if ((*op == '+') || (*op == '-') || (*op == 'x') || (*op == '/')) {
+ function->category = FUNCTION_POSTFIX;
+ function->function_char = *op;
+ function->func_name = NULL;
+ function->func_string = NULL;
+ function->has_parentheses = FALSE;
+ function->op_type = OPERATOR_TYPE_BINARY;
+ if ((*op == '+') || (*op == '-')) {
+ function->priority = CALCULATOR_CALCULATE_PRIORITY_LOW;
+ } else {
+ function->priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ }
+ function->str_len = 1;
+ ret = TRUE;
+ } else {
+ for (i = 0; i < CALCULATOR_MAX_FUNC_NUMBER; i++) {
+ if (!strncmp
+ (op, g_functions[i].func_string,
+ strlen(g_functions[i].func_string))) {
+ memcpy(function, &g_functions[i],
+ sizeof(function_t));
+ ret = TRUE;
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
+/* search function, if have, return TRUE and get the length of current function;else return FALSE */
+gboolean __calculator_search_function(char *op, int* len)
+{
+ gint i = 0;
+ gboolean ret = FALSE;
+ for (i = 0; i < CALCULATOR_MAX_FUNC_NUMBER; i++) {
+ if (!strncmp
+ (op, g_functions[i].func_string,
+ strlen(g_functions[i].func_string))) {
+ ret = TRUE;
+ if(len){
+ *len = strlen(g_functions[i].func_string);
+ }
+ break;
+ }
+ }
+ return ret;
+}
+
+/**
+* @describe
+*
+*
+* @param pos
+* @return calculator_parentheses_data_t*
+* @exception
+*/
+static calculator_parentheses_data_t
+ *__calculator_calculate_get_parentheses_info(gchar * pos)
+{
+ calculator_parentheses_data_t *found = NULL;
+ gint i = 0;
+
+ while ((g_parentheses_data[i].start_pos) ||
+ (g_parentheses_data[i].end_pos)) {
+ if (g_parentheses_data[i].start_pos == pos) {
+ found = &g_parentheses_data[i];
+ break;
+ } else if (g_parentheses_data[i].end_pos == pos) {
+ found = &g_parentheses_data[i];
+ break;
+ }
+ i++;
+ }
+
+ return found;
+}
+
+/**
+* @describe
+*
+*
+* @param tmp_result
+* @param out_tree
+* @param start_pos
+* @param end_pos
+* @param error_msg
+* @return gboolean
+* @exception
+*/
+static gboolean
+__calculator_calculate_formula_parse(double *tmp_result, GNode ** out_tree,
+ char *start_pos, int end_idx,
+ char *error_msg)
+{
+ CONV_FUNC_IN();
+ char *end_pos = start_pos + end_idx;
+ gchar *p = NULL;
+ gchar *q = NULL;
+ gchar tmp[MAX_RESULT_LENGTH];
+ gint i = 0;
+ gdouble factor = 0;
+ calculator_state_t calculator_state = CALCULATOR_OPERAND_INPUT;
+ calculator_node_data_t *node_data = NULL;
+ GNode *tree = NULL;
+ GNode *new_node = NULL;
+ GNode *last_node = NULL; //to proc parentheses
+ calculator_parentheses_data_t *p_data = NULL;
+ gint negative_sign = 1;
+ function_t function = { 0 };
+
+ memset(tmp, 0x00, sizeof(tmp));
+
+ if (start_pos > end_pos) {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ /* Scan from start to end of string */
+ for (p = start_pos; p <= end_pos;) {
+ q = p; /* Point to start of string */
+ if (q != NULL && __calculator_util_get_operator(q, &function)) //('.'::'('::')') and digits are four exceptions
+ {
+ oper_num++;
+ if (oper_num > MAX_OPERATOR_NUM) {
+ strcat(error_msg, CALC_MSG_MAX_OP);
+ return false;
+ }
+
+ p = q + function.str_len; /* Shift */
+ if ((NULL == p)
+ && (function.category != FUNCTION_CONSTANT)) {
+ return false;
+ }
+ if ((NULL != p) && (*p == decimal_ch)) {
+ printf("p:%s\n", p);
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return false;
+ }
+ calculator_state = CALCULATOR_OPERATOR_INPUT;
+ if (i != 0) //save the before operator,create a node.such as 345sin(),save 345
+ {
+ factor = atof(tmp);
+ memset(tmp, 0x00, sizeof(tmp));
+ i = 0;
+
+ node_data =
+ g_malloc0(sizeof(calculator_node_data_t));
+ node_data->tmp_result = factor;
+
+ node_data->negative_flag = 1;
+ node_data->negative_flag *= negative_sign;
+ new_node = g_node_new(node_data);
+ negative_sign = 1;
+ } else {
+ if (!new_node) //no leaf node before, first factor's "+/-" sign allowed.
+ {
+ if (((function.op_type ==
+ OPERATOR_TYPE_BINARY)
+ && (function.function_char != '+')
+ && (function.function_char != '-'))
+ ||
+ ((function.op_type ==
+ OPERATOR_TYPE_UNARY)
+ && (function.category ==
+ FUNCTION_POSTFIX))) {
+ PLOG("Line:%d", __LINE__);
+ strcat(error_msg,
+ _("Syntax error"));
+ return FALSE;
+ } else if (function.function_char ==
+ '-') {
+ negative_sign = -1;
+ continue;
+ }
+ }
+ }
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ if (function.category == FUNCTION_CONSTANT) //Pi, e
+ {
+ if (new_node) //have the operator like 345,now it will 345*Pi
+ {
+ node_data =
+ g_malloc0(sizeof
+ (calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type =
+ OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tree = g_node_new(node_data);
+
+ if (last_node == NULL) //first node
+ {
+ g_node_insert(tree, -1,
+ new_node);
+ CALCULATOR_GET_NODE_DATA(tree)->
+ children_num++;
+ } else {
+ if (CALCULATOR_GET_NODE_DATA
+ (last_node)->children_num >
+ CALCULATOR_GET_NODE_DATA
+ (last_node)->
+ operator_type) {
+ PLOG("Line:%d",
+ __LINE__);
+ strcat(error_msg,
+ _
+ ("Syntax error"));
+ return FALSE;
+ }
+ __calculator_calculate_insert_node
+ (&last_node, tree,
+ new_node);
+ }
+ new_node = NULL;
+ last_node = tree;
+
+ } //Pi will like a leaf
+ node_data =
+ g_malloc0(sizeof(calculator_node_data_t));
+ if (function.function_char == 'p') {
+ node_data->tmp_result = PI;
+ } else if (function.function_char == 'e') {
+ node_data->tmp_result = EXPONENT;
+ }
+ node_data->cur_operator =
+ function.function_char;
+ node_data->node_calcu_priority =
+ function.priority;
+ node_data->negative_flag = 1;
+ node_data->negative_flag *= negative_sign;
+ new_node = g_node_new(node_data);
+ negative_sign = 1;
+ continue;
+ } else if (function.category == FUNCTION_PREFIX) //sin()
+ {
+ if (!last_node) //first node
+ {
+ if (new_node) {
+ node_data =
+ g_malloc0(sizeof
+ (calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type =
+ OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tree = g_node_new(node_data);
+
+ g_node_insert(tree, -1,
+ new_node);
+ CALCULATOR_GET_NODE_DATA(tree)->
+ children_num++;
+
+ last_node = tree;
+ new_node = NULL;
+ }
+ }
+
+ }
+
+ node_data = g_malloc0(sizeof(calculator_node_data_t));
+ node_data->cur_operator = function.function_char;
+ node_data->node_calcu_priority = function.priority;
+ node_data->operator_type = function.op_type;
+ node_data->negative_flag = 1;
+ tree = g_node_new(node_data);
+
+ if (last_node == NULL) //first node
+ {
+ if (new_node) {
+ g_node_insert(tree, -1, new_node);
+ CALCULATOR_GET_NODE_DATA(tree)->
+ children_num++;
+ }
+ } else {
+ if (CALCULATOR_GET_NODE_DATA(last_node)->
+ children_num >
+ CALCULATOR_GET_NODE_DATA(last_node)->
+ operator_type) {
+ strcat(error_msg,
+ CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+ __calculator_calculate_insert_node(&last_node,
+ tree,
+ new_node);
+ }
+ last_node = tree;
+ new_node = NULL;
+ } else {
+ p++; /* Shift */
+ }
+
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+ if (NULL == q) {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR); //add for "6((" ,then "="
+ return FALSE;
+ } //added by zhaodanni for prevent
+ else if (*q == decimal_ch) {
+ if (!isdigit(*p)
+ || (calculator_state ==
+ CALCULATOR_OPERAND_FRACTION_INPUT)) {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ } else {
+ calculator_state =
+ CALCULATOR_OPERAND_FRACTION_INPUT;
+ }
+ tmp[i++] = *q;
+ } else if (*q == '(') {
+ if (__calculator_util_get_operator(p, &function)) {
+ if ((function.category == FUNCTION_POSTFIX) && ((*p != '+') && (*p != '-'))) //"(*","(/", not allowed.
+ {
+ strcat(error_msg,
+ CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+ }
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ //if ((new_node) && (CALCULATOR_GET_NODE_DATA(new_node)->tmp_result == PI || CALCULATOR_GET_NODE_DATA(new_node)->tmp_result == EXPONENT))
+ if ((new_node)
+ &&
+ (FLOAT_EQUAL
+ (CALCULATOR_GET_NODE_DATA(new_node)->tmp_result,
+ PI)
+ || FLOAT_EQUAL(CALCULATOR_GET_NODE_DATA(new_node)->
+ tmp_result, EXPONENT))) {
+ node_data =
+ g_malloc0(sizeof(calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type = OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tree = g_node_new(node_data);
+
+ if (last_node) {
+ __calculator_calculate_insert_node
+ (&last_node, tree, new_node);
+ } else {
+ g_node_insert(tree, -1, new_node);
+ CALCULATOR_GET_NODE_DATA(tree)->
+ children_num++;
+ }
+ last_node = tree;
+ new_node = NULL;
+ }
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ if (i != 0) {
+ factor = atof(tmp);
+ memset(tmp, 0x00, sizeof(tmp));
+ i = 0;
+
+ node_data =
+ g_malloc0(sizeof(calculator_node_data_t));
+ node_data->tmp_result = factor;
+ node_data->negative_flag = 1;
+ node_data->negative_flag *= negative_sign;
+ negative_sign = 1;
+ new_node = g_node_new(node_data);
+
+ node_data =
+ g_malloc0(sizeof(calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type = OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tree = g_node_new(node_data);
+
+ if (last_node == NULL) //first node
+ {
+ g_node_insert(tree, -1, new_node);
+ CALCULATOR_GET_NODE_DATA(tree)->
+ children_num++;
+ } else {
+ if (CALCULATOR_GET_NODE_DATA
+ (last_node)->children_num >
+ CALCULATOR_GET_NODE_DATA
+ (last_node)->operator_type) {
+ strcat(error_msg,
+ CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+
+ __calculator_calculate_insert_node
+ (&last_node, tree, new_node);
+ }
+ last_node = tree;
+ new_node = NULL;
+ }
+
+ p_data = __calculator_calculate_get_parentheses_info(q);
+ if (!p_data) {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+ p = p_data->end_pos;
+ } else if (*q == ')') {
+ if (*p == decimal_ch) //").", not allowed.
+ {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+
+ p_data = __calculator_calculate_get_parentheses_info(q);
+ if (!p_data) {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+ if (!__calculator_calculate_formula_parse
+ (NULL, &new_node, (p_data->start_pos + 1),
+ (p_data->end_pos - 1) - (p_data->start_pos + 1),
+ error_msg)) {
+ if (new_node != NULL) {
+ __calculator_tree_destroy_all
+ (&new_node);
+ } else {
+ LOGD("current node is null\n");
+ }
+ return FALSE;
+ }
+ if (new_node) {
+ CALCULATOR_GET_NODE_DATA(new_node)->
+ negative_flag *= negative_sign;
+ }
+ negative_sign = 1;
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ if ((*p == '(') || (isdigit(*p))) {
+ node_data =
+ g_malloc0(sizeof(calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type = OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tree = g_node_new(node_data);
+
+ if (last_node == NULL) //first node
+ {
+ if (new_node) {
+ g_node_insert(tree, -1,
+ new_node);
+ CALCULATOR_GET_NODE_DATA(tree)->
+ children_num++;
+ }
+ } else {
+ if (CALCULATOR_GET_NODE_DATA
+ (last_node)->children_num >
+ CALCULATOR_GET_NODE_DATA
+ (last_node)->operator_type) {
+ strcat(error_msg,
+ CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+
+ __calculator_calculate_insert_node
+ (&last_node, tree, new_node);
+ }
+ last_node = tree;
+ new_node = NULL;
+ }
+ } else if (isdigit(*q)) {
+ if (new_node) {
+ node_data =
+ g_malloc0(sizeof(calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type = OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tree = g_node_new(node_data);
+
+ if (last_node) {
+ __calculator_calculate_insert_node
+ (&last_node, tree, new_node);
+ } else {
+ g_node_insert(tree, -1, new_node);
+ CALCULATOR_GET_NODE_DATA(tree)->
+ children_num++;
+ }
+ last_node = tree;
+ new_node = NULL;
+ }
+ calculator_state = CALCULATOR_OPERAND_INPUT;
+ tmp[i++] = *q;
+ }/*for unvalid input ,such as "clipborad"*/
+ else if ((*q != '+') && (*q != '-') && (*q != 'x')
+ && (*q != '/')) {
+ if (!__calculator_search_function(q, NULL)) {
+ printf("q=%s,line=%d\n", q, __LINE__);
+ strcat(error_msg, "invalid input");
+ return FALSE;
+ }
+ }
+ }
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ if (i != 0) //last digit number
+ {
+ //if ((new_node) && (CALCULATOR_GET_NODE_DATA(new_node)->tmp_result == PI || CALCULATOR_GET_NODE_DATA(new_node)->tmp_result == EXPONENT))
+ if ((new_node)
+ &&
+ (FLOAT_EQUAL
+ (CALCULATOR_GET_NODE_DATA(new_node)->tmp_result, PI)
+ || FLOAT_EQUAL(CALCULATOR_GET_NODE_DATA(new_node)->
+ tmp_result, EXPONENT))) {
+ node_data = g_malloc0(sizeof(calculator_node_data_t));
+ node_data->cur_operator = 'x';
+ node_data->negative_flag = 1;
+ node_data->operator_type = OPERATOR_TYPE_BINARY;
+ node_data->node_calcu_priority =
+ CALCULATOR_CALCULATE_PRIORITY_MIDDLE;
+ tree = g_node_new(node_data);
+
+ if (last_node) {
+ __calculator_calculate_insert_node(&last_node,
+ tree,
+ new_node);
+ } else {
+ g_node_insert(tree, -1, new_node);
+ CALCULATOR_GET_NODE_DATA(tree)->children_num++;
+ }
+ last_node = tree;
+ new_node = NULL;
+ }
+
+ factor = atof(tmp);
+ memset(tmp, 0x00, sizeof(tmp));
+ i = 0;
+
+ node_data = g_malloc0(sizeof(calculator_node_data_t));
+ node_data->tmp_result = factor;
+ node_data->negative_flag = 1;
+ node_data->negative_flag *= negative_sign;
+ negative_sign = 1;
+ new_node = g_node_new(node_data);
+
+ if (last_node != NULL) {
+ if (CALCULATOR_GET_NODE_DATA(last_node)->children_num >
+ CALCULATOR_GET_NODE_DATA(last_node)->
+ operator_type) {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ } else {
+ g_node_insert(last_node, -1, new_node);
+ CALCULATOR_GET_NODE_DATA(last_node)->
+ children_num++;
+ }
+ new_node = NULL;
+ }
+ }
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ if (new_node != NULL) {
+ CALCULATOR_GET_NODE_DATA(new_node)->negative_flag *=
+ negative_sign;
+ negative_sign = 1;
+
+ if (last_node != NULL) {
+ if (CALCULATOR_GET_NODE_DATA(last_node)->children_num >
+ CALCULATOR_GET_NODE_DATA(last_node)->
+ operator_type) {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ } else {
+ g_node_insert(last_node, -1, new_node);
+ CALCULATOR_GET_NODE_DATA(last_node)->
+ children_num++;
+ }
+ } else {
+ last_node = new_node;
+ }
+ new_node = NULL;
+ }
+ *out_tree = g_node_get_root(last_node);
+ CONV_FUNC_OUT();
+ return TRUE;
+}
+
+/**
+* @describe
+*
+*
+* @param node
+* @param data
+* @return gboolean
+* @exception
+*/
+static gboolean
+__calculator_calculate_exec_traverse_func(GNode * node, gpointer data)
+{
+ gdouble operand0, operand1 = 0.0;
+ char *error_msg = (char *)data;
+
+/*
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ if (CALCULATOR_GET_NODE_DATA(node)->children_num !=
+ CALCULATOR_GET_NODE_DATA(node)->operator_type) {
+ strcat(error_msg, CALC_MSG_NUM_AFTER_OP);
+ return TRUE; //break the recursion
+ }
+
+ operand0 =
+ CALCULATOR_GET_NODE_DATA(node->children)->tmp_result *
+ CALCULATOR_GET_NODE_DATA(node->children)->negative_flag;
+ CALCULATOR_GET_NODE_DATA(node->children)->negative_flag = 1;
+
+ if (CALCULATOR_GET_NODE_DATA(node)->operator_type ==
+ OPERATOR_TYPE_BINARY) {
+ operand1 =
+ CALCULATOR_GET_NODE_DATA(node->children->next)->tmp_result *
+ CALCULATOR_GET_NODE_DATA(node->children->next)->
+ negative_flag;
+ CALCULATOR_GET_NODE_DATA(node->children->next)->negative_flag =
+ 1;
+ }
+
+/* @ describe
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+ switch (CALCULATOR_GET_NODE_DATA(node)->cur_operator) {
+ case '+':
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result =
+ operand0 + operand1;
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+ case '-':
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result =
+ operand0 - operand1;
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+ case 'x':
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result =
+ operand0 * operand1;
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+ case '/':
+ if (FLOAT_EQUAL(operand1, 0)) {
+ strcat(error_msg, CALC_MSG_DIVIDE_BY_ZERO);
+ return TRUE; //break the recursion
+ } else {
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result =
+ operand0 / operand1;
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ }
+ break;
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ case '^':
+ if (operand0 < 0) {
+ gdouble power = 0.0;
+ power = floor(operand1);
+ if (!FLOAT_EQUAL(power, operand1)) //operand1 is not an integer
+ {
+ strcat(error_msg, CALC_MSG_INVALID_XY);
+ return TRUE;
+ }
+ }
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result =
+ pow(operand0, operand1);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+ case '!':
+ if (operand0 < 0) {
+ gdouble power = 0.0;
+ power = floor(operand1);
+ if (!FLOAT_EQUAL(power, operand1)) //operand1 is not an integer
+ {
+ strcat(error_msg, CALC_MSG_INVALID_FAC);
+ return TRUE;
+ }
+ }
+ if (strlen(error_msg) != 0) {
+ return TRUE;
+ }
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result =
+ __calculator_calculate_factorial(operand0, error_msg);
+ if (strlen(error_msg) != 0) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+
+ case 'L':
+ if (operand0 < 0) {
+ strcat(error_msg, CALC_MSG_INVALID_LN);
+ return TRUE;
+ } else if (FLOAT_EQUAL(operand0, 0)) {
+ strcat(error_msg, CALC_MSG_INVALID_LN);
+ return TRUE;
+ }
+
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result = log(operand0);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+ case 'q':
+ if (operand0 < 0) {
+ strcat(error_msg, CALC_MSG_INVALID_SQUARE);
+ return TRUE;
+ }
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result = sqrt(operand0);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+ case 'E':
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result = exp(operand0);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+
+ case 's':
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result =
+ sin(operand0 * RADIAN_FACTOR);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+ case 'c':
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result =
+ cos(operand0 * RADIAN_FACTOR);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+ case 't':
+ if (FLOAT_EQUAL(fmod(operand0, 180), 90) || FLOAT_EQUAL(fmod(operand0, 180), -90)) //revise by bfl
+ {
+ strcat(error_msg, CALC_MSG_INVALID_TAN);
+ return TRUE;
+ }
+
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result =
+ tan(operand0 * RADIAN_FACTOR);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ case 'l':
+ if (operand0 < 0) {
+ strcat(error_msg, CALC_MSG_INVALID_LOG);
+ return TRUE;
+ } else if (FLOAT_EQUAL(operand0, 0)) {
+ strcat(error_msg, CALC_MSG_INVALID_LOG);
+ return TRUE;
+ }
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result = log10(operand0);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+ case 'b':
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result = fabs(operand0);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+
+ case '2':
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result = pow(2, operand0);
+ if (!__calculator_check_overflow
+ (CALCULATOR_GET_NODE_DATA(node)->tmp_result, error_msg)) {
+ return TRUE;
+ }
+ //calculator_calculate_truncate_result(&(CALCULATOR_GET_NODE_DATA(node)->tmp_result));
+ break;
+
+ default:
+ break;
+ }
+
+/* @ describe
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+ CALCULATOR_GET_NODE_DATA(node)->tmp_result *=
+ CALCULATOR_GET_NODE_DATA(node)->negative_flag;
+ CALCULATOR_GET_NODE_DATA(node)->negative_flag = 1;
+
+ return FALSE;
+}
+
+/**
+* @describe
+*
+*
+* @param tree
+* @param result
+* @param error_msg
+* @return gboolean
+* @exception
+*/
+static gboolean
+__calculator_calculate_exec(GNode * tree, double **result, char *error_msg)
+{
+ guint depth = 0;
+ depth = g_node_max_height(tree);
+
+ if (depth < 1) {
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE; //break the recursion
+ } else if (depth == 1) {
+ **result = CALCULATOR_GET_NODE_DATA(tree)->tmp_result;
+ **result *= CALCULATOR_GET_NODE_DATA(tree)->negative_flag;
+ return TRUE;
+ }
+
+/* @ describe
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+ g_node_traverse(tree,
+ G_POST_ORDER,
+ G_TRAVERSE_NON_LEAFS,
+ depth,
+ __calculator_calculate_exec_traverse_func,
+ (gpointer) error_msg);
+
+ if (strlen(error_msg) > 0) {
+ return FALSE;
+ } else {
+ **result = CALCULATOR_GET_NODE_DATA(tree)->tmp_result;
+ }
+ return TRUE;
+}
+
+/**
+* @describe
+*
+*
+* @param tmp_result
+* @return gboolean
+* @exception
+*/
+
+#if 0
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+/*
+bool calculator_calculate_truncate_result(double* tmp_result)
+{
+
+ return TRUE;
+}
+*/
+#endif
+
+/**
+* @describe
+*
+*
+* @param szInputString
+* @return int
+* @exception
+*/
+int calculator_get_open_braket(const char *szInputString)
+{
+ int nReversIndex = strlen(szInputString) - 1;
+ int nOpenCnt = 0;
+ int nCloseCnt = 0;
+
+ while (nReversIndex >= 0) {
+ if (szInputString[nReversIndex] == '(') {
+ nOpenCnt++;
+ } else if (szInputString[nReversIndex] == ')') {
+ nCloseCnt++;
+ }
+ nReversIndex--;
+ }
+ return (nOpenCnt - nCloseCnt);
+}
+
+/**
+* @describe
+*
+*
+* @param szInput
+* @param [out]pDigitCnt : count of digit before point(.)
+* @param [out]pPointCnt: count of digit after point(.)
+* @return int
+* @exception
+*/
+bool calculator_get_digits_number(char *szInput, int *pDigitCnt, int *pPointCnt)
+{
+ int nLen = strlen(szInput);
+ int nIndex;
+
+ int nTempCnt = 0;
+ int nTempCntb = 0;
+
+ *pDigitCnt = 0;
+ *pPointCnt = 0;
+
+/* @ describe
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+ if (nLen > 0) {
+ for (nIndex = nLen - 1; nIndex >= 0; nIndex--) {
+ if (isdigit(szInput[nIndex])) {
+ nTempCnt++;
+ } else if (szInput[nIndex] == decimal_ch) {
+ *pPointCnt = nTempCnt;
+ nTempCnt = 0;
+ break;
+ }
+ }
+ for (nIndex = 0; nIndex < nLen; nIndex++) {
+ if (isdigit(szInput[nIndex])) {
+ nTempCntb++;
+ } else if (szInput[nIndex] == decimal_ch) {
+ *pDigitCnt = nTempCntb;
+ break;
+ }
+ }
+ //*pDigitCnt = nTempCntb;
+ }
+ return true;
+}
+
+/* @ describe
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+
+/**
+* @describe
+*
+*
+* @param str
+* @param error_msg
+* @return bool
+* @exception
+*/
+bool calculator_expression_length_check(char *str, char *error_msg)
+{
+ int is_digit = 0, has_dot = 0;
+ int idx = 0, nCount = 0, nDigitCnt = 0, nPointCnt = 0;
+ char *p = NULL;
+ char c;
+
+#if 0
+/*
+
+ if(strlen(str) > CALCULATOR_MAX_INPUT_DIGIT_NUMBER_POR)
+ {
+ strcat(error_msg, CALC_MSG_MAX_INPUT);
+ return FALSE;
+ }
+*/
+#endif
+
+ p = str;
+ while (idx < strlen(str)) {
+ c = p[idx];
+
+ if (isdigit(c)) {
+ if (is_digit == 0) {
+ is_digit = 1;
+
+ nDigitCnt = 1;
+ nCount = 1;
+ } else {
+ nCount++;
+ if (nCount > MAX_NUM_LENGTH) {
+ strcat(error_msg, CALC_MSG_MAX_DIGIT);
+ return FALSE;
+ }
+
+ if (has_dot == 0) {
+ nDigitCnt++;
+ } else {
+ nPointCnt++;
+/* @ attention
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+#if 0 //YangQ
+ /*
+ if(nPointCnt > CALCULATORUI_MAX_INPUT_DECIMALS)
+ {
+ strcat(error_msg, CALC_MSG_MAX_DEC_DIGIT);
+ PTAG;
+ return FALSE;
+ }
+ */
+#endif
+ }
+ }
+ }
+/* @ describe
+ This is redundant comment.
+ Its only use is for Klocwork testing.
+ The comment rete should passed 25%.
+ But we have only one day to do this work.
+ So, sorry, I will delete this comment and add useful comment later.
+*/
+ else if (c == decimal_ch) {
+ if (has_dot == 1) {
+ strcat(error_msg, CALC_MSG_ENTRY_LIMIT);
+ return FALSE;
+ } else {
+ has_dot = 1;
+ }
+ } else {
+ if (is_digit == 1) {
+ is_digit = 0;
+ has_dot = 0;
+ nCount = 0;
+ nDigitCnt = 0;
+ nPointCnt = 0;
+ }
+ }
+
+ idx++;
+ }
+
+ return TRUE;
+
+}
+
+/**
+* @describe
+*
+*
+* @param string
+* @param result
+* @param error_msg
+* @return bool
+* @exception
+*/
+bool calculator_calculate(gchar * string, gdouble * result, char *error_msg)
+{
+#if 1 //YangQ add.
+ string_replace(string, "E+", "x10^");
+ string_replace(string, "E-", "x0.1^");
+#endif
+ GNode *tree = NULL;
+ int end_idx = 0;
+
+ memset(error_msg, 0, sizeof(error_msg));
+ memset(g_stack, 0, sizeof(g_stack));
+ oper_num = 0;
+
+ strncpy(g_stack, string, MAX_EXPRESSION_LENGTH - 1);
+ g_stack[MAX_EXPRESSION_LENGTH - 1] = '\0';
+
+ char *digit = "0123456789pe";
+ if (strcspn(g_stack, digit) == strlen(g_stack)) { /* no digit in expression */
+ strcat(error_msg, CALC_MSG_SYNTAX_ERROR);
+ return FALSE;
+ }
+
+ if (!calculator_expression_length_check(g_stack, error_msg)) {
+ return FALSE;
+ }
+ if (!__calculator_calculate_formula_scan(g_stack, &end_idx, error_msg)) {
+ return FALSE;
+ }
+
+ if (!__calculator_calculate_formula_parse
+ (result, &tree, g_stack, end_idx, error_msg)) {
+ if (tree != NULL) {
+ __calculator_tree_destroy_all(&tree);
+ } else {
+ LOGD("current tree is null\n");
+ }
+ PLOG("error_msg:%s,line:%d\n", error_msg, __LINE__);
+ return FALSE;
+ }
+ if (!__calculator_calculate_exec(tree, &result, error_msg)) {
+ if (tree != NULL) {
+ __calculator_tree_destroy_all(&tree);
+ }
+ return FALSE;
+ }
+ if (!__calculator_check_overflow(*result, error_msg)) {
+ if (tree != NULL) {
+ __calculator_tree_destroy_all(&tree);
+ }
+ return FALSE;
+ }
+
+ if (tree != NULL)
+ __calculator_tree_destroy_all(&tree);
+ oper_num = 0;
+ return TRUE;
+}
--- /dev/null
+/*
+ * Copyright 2012 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+#define ENTRY_BLOCK_HANDLE_SOURCE2 "elm/entry/selection/block_handle_right"
+#define ENTRY_BLOCK_HANDLE_SOURCE3 "elm/entry/selection/block_handle_left"
+#define ENTRY_BLOCK_HANDLE_SOURCE2_B "elm/entry/Bselection/block_handle_right"
+#define ENTRY_BLOCK_HANDLE_SOURCE3_B "elm/entry/Bselection/block_handle_left"
+#define ENTRY_TEXT_COLOR_INC "#000000"
+#define ENTRY_TEXT_COLOR_INC_B "#000000"
+#define ENTRY_PREEDIT_BACKGROUND_COLOR_INC "#000000"
+#define ENTRY_PREEDIT_BACKGROUND_COLOR_INC_B "#FFFFFF"
+#define ENTRY_PREEDIT_TEXT_COLOR_INC "#FFFFFF"
+#define ENTRY_PREEDIT_TEXT_COLOR_INC_B "#000000"
+#define ENTRY_CURSOR_COLOR_INC 217 147 26 255
+#define ENTRY_CURSOR_COLOR_INC_B 42 109 140 255
+#define ENTRY_SELECTION_BG_COLOR 204 230 224 127
+#define ENTRY_SELECTION_BG_COLOR_B 90 123 138 127
+
+collections {
+ images {
+ image: "black/copy&paste_Icon_left.png" COMP;
+ image: "black/copy&paste_Icon_left_press.png" COMP;
+ image: "black/copy&paste_Icon_right.png" COMP;
+ image: "black/copy&paste_Icon_right_press.png" COMP;
+ }
+
+ group {
+ name: "elm/entry/base/black";
+ alias: "elm/entry/base/char_wrap";
+ data.item: "default_font_size" "24";
+ data.item: "min_font_size" "8";
+ data.item: "max_font_size" "60";
+ styles
+ {
+ style { name: "entry_textblock_char_wrap_style_B";
+ base: "font=SLP:style=Roman font_size=67 align=right color="ENTRY_TEXT_COLOR_INC_B" wrap=char left_margin=2 right_margin=2";
+ tag: "br" "\n";
+ tag: "ps" "ps";
+ tag: "tab" "\t";
+ tag: "em" "+ font=SLP:style=Oblique";
+ tag: "b" "+ font=SLP:style=Bold";
+ tag: "link" "+ color=#800 underline=on underline_color=#8008";
+ tag: "hilight" "+ font=SLP:style=Bold";
+ tag: "preedit" "+ underline=on underline_color="ENTRY_PREEDIT_BACKGROUND_COLOR_INC"";
+ tag: "preedit_sel" "+ backing=on backing_color="ENTRY_PREEDIT_BACKGROUND_COLOR_INC" color="ENTRY_PREEDIT_TEXT_COLOR_INC"";
+ }
+ style { name: "entry_textblock_char_wrap_disabled_style_B";
+ base: "font=SLP:style=Roman font_size="ENTRY_TEXT_SIZE_INC" color=#00000080 wrap=char";
+ tag: "br" "\n";
+ tag: "ps" "ps";
+ tag: "tab" "\t";
+ tag: "em" "+ font=SLP:style=Oblique";
+ tag: "b" "+ font=SLP:style=Bold";
+ tag: "link" "+ color=#00000080 underline=on underline_color=#00000080";
+ tag: "hilight" "+ font=SLP:style=Bold";
+ tag: "preedit" "+ underline=on underline_color="ENTRY_PREEDIT_BACKGROUND_COLOR_INC"";
+ tag: "preedit_sel" "+ backing=on backing_color="ENTRY_PREEDIT_BACKGROUND_COLOR_INC" color="ENTRY_PREEDIT_TEXT_COLOR_INC"";
+ }
+ }
+ data {
+ item: context_menu_orientation "horizontal";
+ }
+ parts {
+ part { name: "entry.swallow.background";
+ type: SWALLOW;
+ description { state: "default" 0.0;
+ visible: 1;
+ rel1 { relative: 0 0; to: "elm.text"; }
+ rel2 { relative: 1 1; to: "elm.text"; }
+ }
+ }
+ }
+ parts {
+ part { name: "elm.text";
+ type: TEXTBLOCK;
+ mouse_events: 1;
+ scale: 1;
+ entry_mode: EDITABLE;
+ select_mode: BLOCK_HANDLE;
+ //cursor_mode: BEFORE;
+ multiline: 1;
+ source: "elm/entry/Bselection/default"; // selection under
+ source2: ENTRY_BLOCK_HANDLE_SOURCE2_B; // block handle
+ source3: ENTRY_BLOCK_HANDLE_SOURCE3_B; // block handle
+ source4: "elm/entry/Bcursor/default"; // cursorover
+ source5: "elm/entry/Banchor/default"; // anchor under
+// source6: "X"; // anchor over
+ description { state: "default" 0.0;
+ fixed: 1 0;
+ text {
+ style: "entry_textblock_char_wrap_style_B";
+ min: 0 1;
+ }
+ }
+ description { state: "disabled" 0.0;
+ inherit: "default" 0.0;
+ text {
+ style: "entry_textblock_char_wrap_disabled_style_B";
+ min: 0 1;
+ }
+ }
+ }
+ }
+ programs {
+ program { name: "focus";
+ signal: "load";
+ source: "";
+ action: FOCUS_SET;
+ target: "elm.text";
+ }
+ program { name: "disable";
+ signal: "elm,state,disabled";
+ source: "elm";
+ action: STATE_SET "disabled" 0.0;
+ target: "elm.text";
+ }
+ program { name: "enable";
+ signal: "elm,state,enabled";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "elm.text";
+ }
+ }
+ }
+
+ group { name: "elm/entry/Bcursor/default";
+ parts {
+ part { name: "clip2";
+ type: RECT;
+ mouse_events: 0;
+ scale: 1;
+ description { state: "default" 0.0;
+ rel1.to: "clip";
+ rel2.to: "clip";
+ //color: 229 134 22 255;
+ visible: 0;
+ }
+ description { state: "focused" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ }
+ part { name: "clip";
+ type: RECT;
+ mouse_events: 0;
+ scale: 1;
+ clip_to: "clip2";
+ description { state: "default" 0.0;
+ rel1.offset: -10 0;
+ rel2.offset: 9 9;
+ }
+ description { state: "hidden" 0.0;
+ inherit: "default" 0.0;
+ visible: 0;
+ }
+ }
+ part { name: "base";
+ mouse_events: 0;
+ scale: 1;
+ clip_to: "clip";
+ description { state: "default" 0.0;
+ min: 2 2;
+ align: 0.5 1.0;
+ color: 0 0 0 0;
+ }
+ }
+
+ part { name: "glow";
+ type: RECT;
+ mouse_events: 0;
+ scale: 1;
+ clip_to: "clip2";
+ description { state: "default" 0.0;
+ min: 3 0;
+ fixed: 1 0;
+ align: 0.5 0.5;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 0 2;
+ }
+ rel2 {
+ relative: 0.0 1.0;
+ offset: 0 -2;
+ }
+ color: ENTRY_CURSOR_COLOR_INC_B;
+ }
+ description { state: "hidden" 0.0;
+ inherit: "default" 0.0;
+ color: 0 0 0 0;
+ }
+ }
+ }
+ programs {
+ program { name: "show";
+ action: STATE_SET "hidden" 0.0;
+ in: 0.6 0.0;
+ target: "glow";
+ after: "show4";
+ }
+ program { name: "show4";
+ action: STATE_SET "default" 0.0;
+ in: 0.6 0.0;
+ target: "glow";
+ after: "show";
+ }
+ program { name: "focused";
+ signal: "elm,action,focus";
+ source: "elm";
+ action: STATE_SET "focused" 0.0;
+ target: "clip2";
+ after: "show4";
+ }
+ program { name: "unfocused";
+ signal: "elm,action,unfocus";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "clip2";
+ after: "stop_glow";
+ }
+ program { name: "stop_glow";
+ action: ACTION_STOP;
+ target: "show";
+ target: "show4";
+ }
+ }
+ }
+
+
+ group { name: "elm/entry/Bselection/default";
+ parts {
+ part { name: "bg";
+ type: RECT;
+ scale: 1;
+ mouse_events: 0;
+ description { state: "default" 0.0;
+ color: ENTRY_SELECTION_BG_COLOR_B;
+ }
+ }
+ }
+ }
+/////////////////////////////////////////////////////////////////////////
+ group { name: "elm/entry/Bselection/block_handle_left";
+ data.item: "position" "BOTTOM";
+ images {
+ image: "black/copy&paste_Icon_left.png" COMP;
+ image: "black/copy&paste_Icon_left_press.png" COMP;
+ }
+ parts {
+ part { name: "bg";
+ type: RECT;
+ scale: 1;
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ visible: 0;
+ fixed: 1 1;
+ align: 1 0;
+ min: 30 42;
+ color: 0 0 0 0;
+ }
+ description { state: "show" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ }
+ part { name: "handle";
+ mouse_events: 1;
+ scale: 1;
+ description { state: "default" 0.0;
+ visible: 0;
+ fixed: 1 1;
+ align: 1 0;
+ min: 30 42;
+ rel1 {
+ relative: 1.1 0.0;
+ offset: 0 -2;
+ to: "bg";
+ }
+ rel2 {
+ relative: 1.1 0.0;
+ offset: 0 -2;
+ to: "bg";
+ }
+ image {
+ normal: "black/copy&paste_Icon_left.png";
+ border: 0 0 0 0;
+ }
+ image.middle: SOLID;
+ fill.smooth: 0;
+ }
+ description { state: "show" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ description { state: "press" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ image {
+ normal: "black/copy&paste_Icon_left_press.png";
+ border: 0 0 0 0;
+ }
+ }
+ }
+ }
+ programs {
+ program { name: "focused";
+ signal: "elm,action,focus";
+ source: "elm";
+ action: STATE_SET "show" 0.0;
+ target: "handle";
+ target: "bg";
+ }
+ program { name: "unfocused";
+ signal: "elm,action,unfocus";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "handle";
+ target: "bg";
+ }
+ program { name: "pressed";
+ signal: "mouse,down,1";
+ source: "handle";
+ action: STATE_SET "press" 0.0;
+ target: "handle";
+ }
+ program { name: "unpressed";
+ signal: "mouse,up,1";
+ source: "handle";
+ action: STATE_SET "show" 0.0;
+ target: "handle";
+ }
+ }
+ }
+
+ group { name: "elm/entry/Bselection/block_handle_right";
+ data.item: "position" "BOTH";
+ images {
+ image: "black/copy&paste_Icon_right.png" COMP;
+ image: "black/copy&paste_Icon_right_press.png" COMP;
+ }
+ parts {
+/* part { name: "bg";
+ type: RECT;
+ scale: 1;
+ mouse_events: 1;
+ description { state: "default" 0.0;
+ visible: 0;
+ fixed: 1 1;
+ align: 0.5 0.25;
+ min: 50 80;
+ color: 0 0 0 0;
+ }
+ description { state: "show" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ }*/
+ part { name: "handle";
+ mouse_events: 1;
+ scale: 1;
+ description { state: "default" 0.0;
+ visible: 0;
+ fixed: 1 1;
+ align: 0 0;
+ min: 30 42;
+ rel1 {
+ relative: 0.0 0.0;
+ offset: 0 -2;
+ }
+ rel2 {
+ relative: 0.0 0.0;
+ offset: 0 -2;
+ }
+ image {
+ normal: "black/copy&paste_Icon_right.png";
+ border: 0 0 0 0;
+ }
+ image.middle: SOLID;
+ fill.smooth: 0;
+ }
+ description { state: "show" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ }
+ description { state: "press" 0.0;
+ inherit: "default" 0.0;
+ visible: 1;
+ image {
+ normal: "black/copy&paste_Icon_right_press.png";
+ border: 0 0 0 0;
+ }
+ }
+ }
+ }
+ programs {
+ program { name: "focused";
+ signal: "elm,action,focus";
+ source: "elm";
+ action: STATE_SET "show" 0.0;
+ target: "handle";
+// target: "bg";
+ }
+ program { name: "unfocused";
+ signal: "elm,action,unfocus";
+ source: "elm";
+ action: STATE_SET "default" 0.0;
+ target: "handle";
+// target: "bg";
+ }
+ program { name: "pressed";
+ signal: "mouse,down,1";
+ source: "handle";
+ action: STATE_SET "press" 0.0;
+ target: "handle";
+ }
+ program { name: "unpressed";
+ signal: "mouse,up,1";
+ source: "handle";
+ action: STATE_SET "show" 0.0;
+ target: "handle";
+ }
+ }
+ }
+
+
+/////////////////////////////////////////////////////////////////////////
+
+ group { name: "elm/entry/Banchor/default";
+ parts {
+ part { name: "bg";
+ type: RECT;
+ mouse_events: 0;
+ description { state: "default" 0.0;
+ color: 128 0 0 64;
+ }
+ }
+ }
+ }
+
+ group { name: "elm/entry/Bpreedit/default";
+ parts {
+ part { name: "bg";
+ type: RECT;
+ mouse_events: 0;
+ description { state: "default" 0.0;
+ color: 128 128 128 255;
+ }
+ }
+ }
+ }
+
+}
+
+