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 StKeyboardForm.cpp
19 * @brief This is the implementation file for KeyboardForm class.
22 #include "StKeyboardForm.h"
23 #include "StResourceManager.h"
24 #include "StSettingScenesList.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Ui::Controls;
31 using namespace Tizen::Ui::Scenes;
33 static const int ID_GROUP_KEYBOARD_SOFTWARE = 0;
34 static const int ID_GROUP_KEYBOARD_SOFTWARE_ITEM_COUNT = 1;
35 static const int ID_ITEM_KEYBOARD_SOFTWARE_SELECT_KEYBOARD = 0;
36 static const int ID_ITEM_KEYBOARD_SOFTWARE_KEYBOARD_SETTING = 1;
38 static const int ID_GROUP_KEYBOARD_HARDWARE = 1;
39 static const int ID_GROUP_KEYBOARD_HARDWARE_ITEM_COUNT = 2;
40 static const int ID_ITEM_KEYBOARD_HARDWARE_SELECT_KEYBOARD = 0;
41 static const int ID_ITEM_KEYBOARD_HARDWARE_KEYBOARD_SETTING = 1;
43 static const int ID_GROUP_COUNT = 1;
45 KeyboardForm::KeyboardForm(void)
49 KeyboardForm::~KeyboardForm(void)
54 KeyboardForm::CreateFooter(void)
56 Footer* pFooter = GetFooter();
59 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
60 pFooter->SetBackButton();
61 pFooter->AddActionEventListener(*this);
63 SetFormBackEventListener(this);
67 KeyboardForm::OnInitializing(void)
69 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD"));
79 KeyboardForm::OnTerminating(void)
83 SetFormBackEventListener(null);
88 KeyboardForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
90 __pTableView->UpdateTableView();
94 KeyboardForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
99 KeyboardForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
101 SceneManager* pSceneManager = SceneManager::GetInstance();
102 AppAssert(pSceneManager);
104 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
108 KeyboardForm::GetGroupCount(void)
110 AppLogDebug("ENTER");
111 return ID_GROUP_COUNT;
115 KeyboardForm::GetItemCount(int groupIndex)
121 case ID_GROUP_KEYBOARD_SOFTWARE:
123 itemCount = ID_GROUP_KEYBOARD_SOFTWARE_ITEM_COUNT;
127 case ID_GROUP_KEYBOARD_HARDWARE:
129 itemCount = ID_GROUP_KEYBOARD_HARDWARE_ITEM_COUNT;
137 AppLogDebug("GetItemCount %d", itemCount);
142 KeyboardForm::CreateGroupItem(int groupIndex, int itemWidth)
144 AppLogDebug("ENTER");
146 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
147 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
148 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
149 Rectangle itemMainRectangle;
151 Label* pLabel = null;
153 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
157 case ID_GROUP_KEYBOARD_SOFTWARE:
159 yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
160 itemHeight = H_GROUP_INDEX_DEFAULT;
161 groupText = ResourceManager::GetString(L"IDS_IME_BODY_SOFTWARE_KEYBOARD");
165 case ID_GROUP_KEYBOARD_HARDWARE:
167 yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
168 itemHeight = H_GROUP_INDEX_DEFAULT;
169 groupText = ResourceManager::GetString(L"IDS_IME_BODY_HARDWARE_KEYBOARD");
177 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
178 itemMainRectangle.y = yItemOffset;
179 itemMainRectangle.width = itemWidth;
180 itemMainRectangle.height = itemHeight;
182 RelativeLayout relativeLayout;
183 relativeLayout.Construct();
185 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
186 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
188 pLabel = new (std::nothrow) Label();
189 pLabel->Construct(itemMainRectangle, groupText);
190 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
191 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
192 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
193 pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
195 pItem->AddControl(pLabel);
196 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
197 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
198 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
199 pItem->SetEnabled(false);
205 KeyboardForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
207 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
209 Rectangle itemMainRectangle;
210 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
212 Label* pLabel = null;
213 int fontSize = GetFontSize();
215 TableViewItem* pItem = new (std::nothrow) TableViewItem();
217 if (groupIndex < ID_GROUP_KEYBOARD_SOFTWARE)
219 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
224 case ID_GROUP_KEYBOARD_SOFTWARE:
228 case ID_ITEM_KEYBOARD_SOFTWARE_SELECT_KEYBOARD:
230 itemMainText = ResourceManager::GetString(L"IDS_IME_BODY_KEYBOARD_SELECTION");
234 case ID_ITEM_KEYBOARD_SOFTWARE_KEYBOARD_SETTING:
236 itemMainText = ResourceManager::GetString(L"IDS_IME_BODY_WRITING_LANGUAGES");
246 case ID_GROUP_KEYBOARD_HARDWARE:
250 case ID_ITEM_KEYBOARD_HARDWARE_SELECT_KEYBOARD:
252 itemMainText = ResourceManager::GetString(L"IDS_IME_BODY_KEYBOARD_SELECTION");
256 case ID_ITEM_KEYBOARD_HARDWARE_KEYBOARD_SETTING:
258 itemMainText = ResourceManager::GetString(L"IDS_IME_BODY_KEYBOARD_SETTINGS");
272 ItemTypeOneLine(itemMainRectangle);
274 RelativeLayout relativeLayout;
275 relativeLayout.Construct();
277 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
278 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
280 pLabel = new (std::nothrow) Label();
281 pLabel->Construct(itemMainRectangle, itemMainText);
282 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
283 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
284 pLabel->SetTextColor(COLOR_MAIN_TEXT);
286 pItem->AddControl(pLabel);
287 if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
289 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
293 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
295 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
296 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
302 KeyboardForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
304 AppLogDebug("ENTER");
313 KeyboardForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
315 AppLogDebug("ENTER");
324 KeyboardForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
326 SceneManager* pSceneManager = SceneManager::GetInstance();
327 AppAssert(pSceneManager);
329 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
333 case ID_GROUP_KEYBOARD_SOFTWARE:
335 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_SELECT_KEYBOARD)
337 // TODO: select software keyboard.
338 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_KEYBOARD_SELECTION, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
341 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_KEYBOARD_SETTING)
343 // TODO: more setting for software keyboard.
348 case ID_GROUP_KEYBOARD_HARDWARE:
350 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_SELECT_KEYBOARD)
352 // TODO: nothing todo yet.
355 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_KEYBOARD_SETTING)
357 // TODO: nothing todo yet.
368 KeyboardForm::GetDefaultGroupItemHeight(void)
370 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
374 KeyboardForm::GetDefaultItemHeight(void)
376 return H_GROUP_ITEM_DEFAULT;
380 KeyboardForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
385 KeyboardForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
390 KeyboardForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
395 KeyboardForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)