2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file CtMainForm.cpp
19 * @brief This is the implementation file for the MainForm class.
23 #include "CtContactsApp.h"
24 #include "CtMainForm.h"
25 #include "CtResourceManager.h"
26 #include "CtSceneRegister.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
36 static const int IDA_HEADER_CONTACTS = 10;
37 static const int IDA_HEADER_GROUPS = 11;
38 static const int IDA_HEADER_FAVORITES = 12;
40 static const wchar_t* IDB_TAB_ICON_CONTACTS = L"C02_tab_icon_contacts.png";
41 static const wchar_t* IDB_TAB_ICON_GROUPS = L"C02_tab_icon_groups.png";
42 static const wchar_t* IDB_TAB_ICON_FAVORITES = L"C02_tab_icon_favourites.png";
43 static const wchar_t* IDB_TAB_ICON_CONTACTS_PRESSED = L"C02_tab_icon_contacts_press.png";
44 static const wchar_t* IDB_TAB_ICON_GROUPS_PRESSED = L"C02_tab_icon_groups_press.png";
45 static const wchar_t* IDB_TAB_ICON_FAVORITES_PRESSED = L"C02_tab_icon_favourites_press.png";
47 MainForm::MainForm(void)
51 MainForm::~MainForm(void)
56 MainForm::Initialize(void)
58 Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER);
62 MainForm::OnInitializing(void)
66 Header* pHeader = GetHeader();
68 r = pHeader->SetStyle(HEADER_STYLE_TAB);
74 r = pHeader->SetTabEditModeEnabled(false);
80 HeaderItem headerContacts;
81 headerContacts.Construct(IDA_HEADER_CONTACTS);
82 r = headerContacts.SetText(ResourceManager::GetString(L"IDS_COM_BODY_CONTACTS"));
88 headerContacts.SetIcon(HEADER_ITEM_STATUS_NORMAL, ResourceManager::GetBitmapN(IDB_TAB_ICON_CONTACTS));
89 headerContacts.SetIcon(HEADER_ITEM_STATUS_PRESSED, ResourceManager::GetBitmapN(IDB_TAB_ICON_CONTACTS_PRESSED));
91 HeaderItem headerGroups;
92 headerGroups.Construct(IDA_HEADER_GROUPS);
93 r = headerGroups.SetText(ResourceManager::GetString(L"IDS_PB_BODY_GROUPS"));
99 headerGroups.SetIcon(HEADER_ITEM_STATUS_NORMAL, ResourceManager::GetBitmapN(IDB_TAB_ICON_GROUPS));
100 headerGroups.SetIcon(HEADER_ITEM_STATUS_PRESSED, ResourceManager::GetBitmapN(IDB_TAB_ICON_GROUPS_PRESSED));
102 HeaderItem headerFavorites;
103 headerFavorites.Construct(IDA_HEADER_FAVORITES);
104 r = headerFavorites.SetText(ResourceManager::GetString(L"IDS_PB_ITAB4_FAVOURITES"));
110 headerFavorites.SetIcon(HEADER_ITEM_STATUS_NORMAL, ResourceManager::GetBitmapN(IDB_TAB_ICON_FAVORITES));
111 headerFavorites.SetIcon(HEADER_ITEM_STATUS_PRESSED, ResourceManager::GetBitmapN(IDB_TAB_ICON_FAVORITES_PRESSED));
113 r = pHeader->AddItem(headerContacts);
118 r = pHeader->AddItem(headerGroups);
123 r = pHeader->AddItem(headerFavorites);
129 SetFormBackEventListener(this);
131 __clientBounds = GetClientAreaBoundsF();
137 MainForm::OnTerminating(void)
139 result r = E_SUCCESS;
145 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
147 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
148 TryReturnVoid(pContactsApp != null, "Unable to cast UiApp to ContactsApp");
150 if (pContactsApp->GetOperationId().Equals(OPERATION_ID_PICK, true))
152 result r = AppControlProviderManager::GetInstance()->SendAppControlResult(pContactsApp->GetRequestId(), APP_CTRL_RESULT_CANCELED, null);
153 AppLogDebug("[%s] The return result from SendAppControlResult().", GetErrorMessage(r));
154 UiApp::GetInstance()->Terminate();
158 SceneManager *pSceneManager = SceneManager::GetInstance();
159 SceneId curSceneId = pSceneManager->GetCurrentSceneId();
161 if (curSceneId == IDSCN_CONTACT_LIST || curSceneId == IDSCN_FAVORITE_LIST || curSceneId == IDSCN_GROUP_LIST)
163 UiApp::GetInstance()->Terminate();
165 else if (SceneManager::GetInstance()->GoBackward(BackwardSceneTransition()) != E_SUCCESS)
167 UiApp::GetInstance()->Terminate();
172 MainForm::GetClientBounds()
175 return __clientBounds;