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->AddActionEventListener(*this);
62 SetFormBackEventListener(this);
66 KeyboardForm::OnInitializing(void)
68 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD"));
77 KeyboardForm::OnTerminating(void)
81 SetFormBackEventListener(null);
86 KeyboardForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
88 __pTableView->UpdateTableView();
92 KeyboardForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
97 KeyboardForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
99 SceneManager* pSceneManager = SceneManager::GetInstance();
100 AppAssert(pSceneManager);
102 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
106 KeyboardForm::GetGroupCount(void)
108 AppLogDebug("ENTER");
109 return ID_GROUP_COUNT;
113 KeyboardForm::GetItemCount(int groupIndex)
119 case ID_GROUP_KEYBOARD_SOFTWARE:
121 itemCount = ID_GROUP_KEYBOARD_SOFTWARE_ITEM_COUNT;
125 case ID_GROUP_KEYBOARD_HARDWARE:
127 itemCount = ID_GROUP_KEYBOARD_HARDWARE_ITEM_COUNT;
135 AppLogDebug("GetItemCount %d", itemCount);
140 KeyboardForm::CreateGroupItem(int groupIndex, int itemWidth)
142 AppLogDebug("ENTER");
144 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
145 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
146 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
147 Rectangle itemMainRectangle;
149 Label* pLabel = null;
151 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
155 case ID_GROUP_KEYBOARD_SOFTWARE:
157 yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
158 itemHeight = H_GROUP_INDEX_DEFAULT;
159 groupText = ResourceManager::GetString(L"IDS_IME_BODY_SOFTWARE_KEYBOARD");
163 case ID_GROUP_KEYBOARD_HARDWARE:
165 yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
166 itemHeight = H_GROUP_INDEX_DEFAULT;
167 groupText = ResourceManager::GetString(L"IDS_IME_BODY_HARDWARE_KEYBOARD");
175 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
176 itemMainRectangle.y = yItemOffset;
177 itemMainRectangle.width = itemWidth;
178 itemMainRectangle.height = itemHeight;
180 RelativeLayout relativeLayout;
181 relativeLayout.Construct();
183 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
184 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
186 pLabel = new (std::nothrow) Label();
187 pLabel->Construct(itemMainRectangle, groupText);
188 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
189 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
190 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
191 pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
193 pItem->AddControl(pLabel);
194 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
195 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
196 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
197 pItem->SetEnabled(false);
203 KeyboardForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
205 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
207 Rectangle itemMainRectangle;
208 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
210 Label* pLabel = null;
211 int fontSize = GetFontSize();
213 TableViewItem* pItem = new (std::nothrow) TableViewItem();
215 if (groupIndex < ID_GROUP_KEYBOARD_SOFTWARE)
217 style = TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING;
222 case ID_GROUP_KEYBOARD_SOFTWARE:
226 case ID_ITEM_KEYBOARD_SOFTWARE_SELECT_KEYBOARD:
228 itemMainText = ResourceManager::GetString(L"IDS_IME_BODY_KEYBOARD_SELECTION");
232 case ID_ITEM_KEYBOARD_SOFTWARE_KEYBOARD_SETTING:
234 itemMainText = ResourceManager::GetString(L"IDS_IME_BODY_WRITING_LANGUAGES");
244 case ID_GROUP_KEYBOARD_HARDWARE:
248 case ID_ITEM_KEYBOARD_HARDWARE_SELECT_KEYBOARD:
250 itemMainText = ResourceManager::GetString(L"IDS_IME_BODY_KEYBOARD_SELECTION");
254 case ID_ITEM_KEYBOARD_HARDWARE_KEYBOARD_SETTING:
256 itemMainText = ResourceManager::GetString(L"IDS_IME_BODY_KEYBOARD_SETTINGS");
270 ItemTypeOneLine(itemMainRectangle);
272 RelativeLayout relativeLayout;
273 relativeLayout.Construct();
275 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
276 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
278 pLabel = new (std::nothrow) Label();
279 pLabel->Construct(itemMainRectangle, itemMainText);
280 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
281 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
282 pLabel->SetTextColor(COLOR_MAIN_TEXT);
284 pItem->AddControl(pLabel);
285 if (style == TABLE_VIEW_ANNEX_STYLE_ONOFF_SLIDING)
287 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN_ONOFF_SLIDING, 0, 0);
291 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
293 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
294 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
300 KeyboardForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
302 AppLogDebug("ENTER");
311 KeyboardForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
313 AppLogDebug("ENTER");
322 KeyboardForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
324 SceneManager* pSceneManager = SceneManager::GetInstance();
325 AppAssert(pSceneManager);
327 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
331 case ID_GROUP_KEYBOARD_SOFTWARE:
333 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_SELECT_KEYBOARD)
335 // TODO: select software keyboard.
336 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_KEYBOARD_SELECTION, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
339 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_KEYBOARD_SETTING)
341 // TODO: more setting for software keyboard.
346 case ID_GROUP_KEYBOARD_HARDWARE:
348 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_SELECT_KEYBOARD)
350 // TODO: nothing todo yet.
353 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_KEYBOARD_SETTING)
355 // TODO: nothing todo yet.
366 KeyboardForm::GetDefaultGroupItemHeight(void)
368 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
372 KeyboardForm::GetDefaultItemHeight(void)
374 return H_GROUP_ITEM_DEFAULT;
378 KeyboardForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
383 KeyboardForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
388 KeyboardForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
393 KeyboardForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)