2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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 StKeyboardInfoForm.cpp
19 * @brief This is the implementation file for KeyboardInfoForm class.
23 #include "StResourceManager.h"
24 #include "StKeyboardInfoForm.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Ui;
31 using namespace Tizen::Ui::Controls;
32 using namespace Tizen::Ui::Ime;
33 using namespace Tizen::Ui::Scenes;
35 static const int ID_GROUP_KEYBOARD_SOFTWARE = 0;
36 static const int ID_ITEM_KEYBOARD_SOFTWARE_SELECT_KEYBOARD = 0;
37 static const int ID_ITEM_KEYBOARD_SOFTWARE_KEYBOARD_SETTING = 1;
39 static const int ID_GROUP_KEYBOARD_HARDWARE = 1;
40 static const int ID_GROUP_KEYBOARD_HARDWARE_ITEM_COUNT = 2;
41 static const int ID_ITEM_KEYBOARD_HARDWARE_SELECT_KEYBOARD = 0;
42 static const int ID_ITEM_KEYBOARD_HARDWARE_KEYBOARD_SETTING = 1;
44 static const int ID_GROUP_COUNT = 1;
45 static const int DEVIDE_TWO = 2;
47 KeyboardInfoForm::KeyboardInfoForm(void)
48 : __pInputMethodInfo(null)
52 KeyboardInfoForm::~KeyboardInfoForm(void)
57 KeyboardInfoForm::CreateFooter(void)
59 Footer* pFooter = GetFooter();
62 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
63 pFooter->SetBackButton();
64 pFooter->AddActionEventListener(*this);
66 SetFormBackEventListener(this);
70 KeyboardInfoForm::OnInitializing(void)
76 KeyboardInfoForm::OnTerminating(void)
78 if (__pInputMethodInfo != null )
80 __pInputMethodInfo->RemoveAll();
81 delete __pInputMethodInfo;
82 __pInputMethodInfo = null;
86 SetFormBackEventListener(null);
91 KeyboardInfoForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
95 AppLogDebug("pArgs is null");
99 __pInputMethodInfo = pArgs;
100 InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(__pInputMethodInfo->GetAt(0));
101 String headerName = pInputMethodInfo->GetName();
102 const IList* pLangList = pInputMethodInfo->GetLanguageList();
104 CreateHeader(headerName);
107 if (pLangList->GetCount() != 0)
113 Rectangle clientRect = GetClientAreaBounds();
114 Bitmap* pBitmp = ResourceManager::GetBitmapN(IDB_NO_CONTENTS);
115 int bitmapWidth = pBitmp->GetWidth();
116 int bitmapHeight = pBitmp->GetHeight();
117 int xPos = (clientRect.width / LINE_COUNT_2) - (bitmapWidth / DEVIDE_TWO);
118 int yPos = (clientRect.height / LINE_COUNT_2) - (bitmapHeight / DEVIDE_TWO);
119 String labelText = ResourceManager::GetString(L"IDS_ST_BODY_NO_CONTENT");
120 Color textColor = COLOR_HELP_TEXT_TYPE_03_NORMAL;
122 Label* pLabel = new (std::nothrow) Label();
123 pLabel->Construct(Rectangle(xPos, yPos, bitmapWidth, bitmapHeight), L"");
124 pLabel->SetName(NO_CONTENTS);
125 pLabel->SetBackgroundBitmap(*pBitmp);
127 yPos = yPos + (bitmapHeight / DEVIDE_TWO);
129 Label* pLabelNoContents = new (std::nothrow) Label();
130 pLabelNoContents->Construct(Rectangle(xPos, yPos, bitmapWidth, bitmapHeight), L"");
131 pLabelNoContents->SetName(NO_CONTENTS_TEXT);
132 pLabelNoContents->SetTextColor(textColor);
133 pLabelNoContents->SetText(labelText);
136 AddControl(*pLabelNoContents);
141 KeyboardInfoForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
146 KeyboardInfoForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
148 SceneManager* pSceneManager = SceneManager::GetInstance();
149 AppAssert(pSceneManager);
151 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
155 KeyboardInfoForm::GetGroupCount(void)
157 return ID_GROUP_COUNT;
161 KeyboardInfoForm::GetItemCount(int groupIndex)
167 case ID_GROUP_KEYBOARD_SOFTWARE:
169 if (__pInputMethodInfo != null)
171 InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(__pInputMethodInfo->GetAt(0));
172 const IList* pLangList = pInputMethodInfo->GetLanguageList();
173 itemCount = pLangList->GetCount();
186 KeyboardInfoForm::CreateGroupItem(int groupIndex, int itemWidth)
189 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
191 pItem->Construct(Dimension(itemWidth, itemHeight));
192 pItem->SetEnabled(false);
198 KeyboardInfoForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
200 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
202 Rectangle itemRectangle;
203 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
205 Label* pLabel = null;
206 int fontSize = GetFontSize();
208 TableViewItem* pItem = new (std::nothrow) TableViewItem();
210 if ((__pInputMethodInfo == null)
217 InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(__pInputMethodInfo->GetAt(0));
218 const IList* pLangList = pInputMethodInfo->GetLanguageList();
219 const Tizen::Locales::Locale* pLocale = static_cast<const Tizen::Locales::Locale*>(pLangList->GetAt(itemIndex));
222 itemText = pLocale->GetLocaleCodeString();
225 ItemTypeOneLine(itemRectangle);
227 RelativeLayout relativeLayout;
228 relativeLayout.Construct();
230 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
231 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
233 pLabel = new (std::nothrow) Label();
234 pLabel->Construct(itemRectangle, itemText);
235 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
236 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
237 pLabel->SetTextColor(COLOR_MAIN_TEXT);
239 pItem->AddControl(*pLabel);
240 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
241 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
242 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
248 KeyboardInfoForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
250 AppLogDebug("ENTER");
259 KeyboardInfoForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
261 AppLogDebug("ENTER");
270 KeyboardInfoForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
272 SceneManager* pSceneManager = SceneManager::GetInstance();
273 AppAssert(pSceneManager);
275 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
279 case ID_GROUP_KEYBOARD_SOFTWARE:
281 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_SELECT_KEYBOARD)
283 // TODO: select software keyboard.
286 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_KEYBOARD_SETTING)
288 // TODO: more setting for software keyboard.
293 case ID_GROUP_KEYBOARD_HARDWARE:
295 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_SELECT_KEYBOARD)
297 // TODO: nothing todo yet.
300 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_KEYBOARD_SETTING)
302 // TODO: nothing todo yet.
313 KeyboardInfoForm::GetDefaultGroupItemHeight(void)
315 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
319 KeyboardInfoForm::GetDefaultItemHeight(void)
321 return H_GROUP_ITEM_DEFAULT;
325 KeyboardInfoForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
330 KeyboardInfoForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
335 KeyboardInfoForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
340 KeyboardInfoForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
345 KeyboardInfoForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
347 Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
350 Rectangle clientRect = GetClientAreaBounds();
351 Rectangle labelBound = pLabel->GetBounds();
352 int xPos = (clientRect.width / LINE_COUNT_2) - (labelBound.width / LINE_COUNT_2);
353 int yPos = (clientRect.height / LINE_COUNT_2) - (labelBound.height / LINE_COUNT_2);
354 pLabel->SetBounds(Rectangle(xPos, yPos, labelBound.width, labelBound.height));
355 yPos = yPos + (pLabel->GetBounds().height / DEVIDE_TWO);
356 Label* pTextLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS_TEXT, false));
357 if (pTextLabel != null)
359 pTextLabel->SetBounds(Rectangle(xPos, yPos, labelBound.width, labelBound.height));