[Calculator] Apply constant for resource ID
authorSeokpil Park <seokpil.park@samsung.com>
Sat, 13 Apr 2013 07:51:42 +0000 (16:51 +0900)
committerSeokpil Park <seokpil.park@samsung.com>
Sat, 13 Apr 2013 07:51:51 +0000 (16:51 +0900)
Change-Id: I686e7674f04aefa475f116b29ae5110a0b59f9cf
Signed-off-by: Seokpil Park <seokpil.park@samsung.com>
project/inc/AppResourceId.h [new file with mode: 0644]
project/src/AppResourceId.cpp [new file with mode: 0644]
project/src/CalculatorForm.cpp

diff --git a/project/inc/AppResourceId.h b/project/inc/AppResourceId.h
new file mode 100644 (file)
index 0000000..b835196
--- /dev/null
@@ -0,0 +1,43 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 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 _APP_RESOURCE_ID_H_
+#define _APP_RESOURCE_ID_H_
+
+extern const wchar_t* IDC_PANEL_CALC;
+extern const wchar_t* IDF_FORM;
+extern const wchar_t* IDC_LBL_DISPLAY;
+extern const wchar_t* IDC_BTN_BACK;
+extern const wchar_t* IDC_BTN_CLEAR;
+extern const wchar_t* IDC_BTN_0;
+extern const wchar_t* IDC_BTN_1;
+extern const wchar_t* IDC_BTN_2;
+extern const wchar_t* IDC_BTN_3;
+extern const wchar_t* IDC_BTN_4;
+extern const wchar_t* IDC_BTN_5;
+extern const wchar_t* IDC_BTN_6;
+extern const wchar_t* IDC_BTN_7;
+extern const wchar_t* IDC_BTN_8;
+extern const wchar_t* IDC_BTN_9;
+extern const wchar_t* IDC_BTN_DOT;
+extern const wchar_t* IDC_BTN_PLUS;
+extern const wchar_t* IDC_BTN_MINUS;
+extern const wchar_t* IDC_BTN_DIVIDE;
+extern const wchar_t* IDC_BTN_MULTIPLY;
+extern const wchar_t* IDC_BTN_EQUAL;
+
+#endif /* _APP_RESOURCE_ID_H_ */
diff --git a/project/src/AppResourceId.cpp b/project/src/AppResourceId.cpp
new file mode 100644 (file)
index 0000000..30360f4
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// Tizen C++ SDK
+// Copyright (c) 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 "AppResourceId.h"
+
+const wchar_t* IDC_PANEL_CALC = L"IDC_PANEL_CALC";
+const wchar_t* IDF_FORM = L"IDF_FORM";
+const wchar_t* IDC_LBL_DISPLAY = L"IDC_LBL_DISPLAY";
+const wchar_t* IDC_BTN_BACK = L"IDC_BTN_BACK";
+const wchar_t* IDC_BTN_CLEAR = L"IDC_BTN_CLEAR";
+const wchar_t* IDC_BTN_0 = L"IDC_BTN_0";
+const wchar_t* IDC_BTN_1 = L"IDC_BTN_1";
+const wchar_t* IDC_BTN_2 = L"IDC_BTN_2";
+const wchar_t* IDC_BTN_3 = L"IDC_BTN_3";
+const wchar_t* IDC_BTN_4 = L"IDC_BTN_4";
+const wchar_t* IDC_BTN_5 = L"IDC_BTN_5";
+const wchar_t* IDC_BTN_6 = L"IDC_BTN_6";
+const wchar_t* IDC_BTN_7 = L"IDC_BTN_7";
+const wchar_t* IDC_BTN_8 = L"IDC_BTN_8";
+const wchar_t* IDC_BTN_9 = L"IDC_BTN_9";
+const wchar_t* IDC_BTN_DOT = L"IDC_BTN_DOT";
+const wchar_t* IDC_BTN_PLUS = L"IDC_BTN_PLUS";
+const wchar_t* IDC_BTN_MINUS = L"IDC_BTN_MINUS";
+const wchar_t* IDC_BTN_DIVIDE = L"IDC_BTN_DIVIDE";
+const wchar_t* IDC_BTN_MULTIPLY = L"IDC_BTN_MULTIPLY";
+const wchar_t* IDC_BTN_EQUAL = L"IDC_BTN_EQUAL";
index 3835286..77567d4 100644 (file)
@@ -18,6 +18,7 @@
 #include <new>
 #include <FUiLayout.h>
 
+#include "AppResourceId.h"
 #include "CalculatorForm.h"
 
 using namespace Tizen::Base;
@@ -57,7 +58,7 @@ CalculatorForm::~CalculatorForm(void)
 result
 CalculatorForm::Construct(void)
 {
-       result r = Form::Construct(L"IDF_FORM");
+       result r = Form::Construct(IDF_FORM);
        TryReturn(!IsFailed(r), r, "Form::Construct() failed with [%s]", GetErrorMessage(r));
 
        Header* pHeader = GetHeader();
@@ -80,22 +81,22 @@ CalculatorForm::AddCalculatorPanel(void)
 
        const String BUTTON_NAME[] =
        {
-               L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9", L"DOT",
-               L"PLUS", L"MINUS", L"MULTIPLY", L"DIVIDE", L"BACK", L"CLEAR", L"EQUAL"
+               IDC_BTN_0, IDC_BTN_1, IDC_BTN_2, IDC_BTN_3, IDC_BTN_4, IDC_BTN_5, IDC_BTN_6, IDC_BTN_7, IDC_BTN_8, IDC_BTN_9, IDC_BTN_DOT,
+               IDC_BTN_PLUS, IDC_BTN_MINUS, IDC_BTN_MULTIPLY, IDC_BTN_DIVIDE, IDC_BTN_BACK, IDC_BTN_CLEAR, IDC_BTN_EQUAL
        };
 
        Button* pButton = null;
 
        for (int i = 0; i < BTN_ID_COUNT; i++)
        {
-               pButton = static_cast< Button* >(GetControl(String("IDC_BTN_") + BUTTON_NAME[i]));
+               pButton = static_cast< Button* >(GetControl(BUTTON_NAME[i]));
                TryReturn(pButton != null, r = E_SYSTEM, "Panel::GetControl() failed");
 
                pButton->SetActionId(i);
                pButton->AddActionEventListener(*this);
        }
 
-       __pLabelPrint = static_cast< Label* >(GetControl("IDC_LBL_DISPLAY"));
+       __pLabelPrint = static_cast< Label* >(GetControl(IDC_LBL_DISPLAY));
        TryReturn(__pLabelPrint != null, r = E_SYSTEM, "Panel::GetControl(IDC_LBL_DISPLAY) failed");
 
        __pLabelPrint->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);