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 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_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 KeyboardInfoForm::KeyboardInfoForm(void)
46 : __pInputMethodInfo(null)
50 KeyboardInfoForm::~KeyboardInfoForm(void)
55 KeyboardInfoForm::CreateFooter(void)
57 Footer* pFooter = GetFooter();
60 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
61 pFooter->AddActionEventListener(*this);
63 SetFormBackEventListener(this);
67 KeyboardInfoForm::OnInitializing(void)
73 KeyboardInfoForm::OnTerminating(void)
75 if (__pInputMethodInfo != null )
77 __pInputMethodInfo->RemoveAll();
78 delete __pInputMethodInfo;
79 __pInputMethodInfo = null;
83 SetFormBackEventListener(null);
88 KeyboardInfoForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
92 AppLogDebug("pArgs is null");
96 __pInputMethodInfo = pArgs;
97 InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(__pInputMethodInfo->GetAt(0));
98 String headerName = pInputMethodInfo->GetName();
99 const IList* pLangList = pInputMethodInfo->GetLanguageList();
101 CreateHeader(headerName);
103 if (__pTableView != null)
105 int tableViewControlCount = __pTableView->GetControlCount();
106 for (int i = 0; i < tableViewControlCount; i++)
108 __pTableView->RemoveControl(__pTableView->GetControl(0));
110 // __pTableView->RemoveAllControls();
113 int controlCount = GetControlCount();
114 for (int i = 0; i < controlCount; i++)
116 RemoveControl(GetControl(0));
118 // RemoveAllControls();
119 if (pLangList->GetCount() != 0)
125 Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
128 Rectangle clientRect = GetClientAreaBounds();
129 Bitmap* pBitmp = ResourceManager::GetBitmapN(IDB_NO_CONTENTS);
131 int bitmapWidth = pBitmp->GetWidth();
132 int bitmapHeight = pBitmp->GetHeight();
133 String labelText = ResourceManager::GetString(L"IDS_ST_BODY_NO_CONTENT");
134 Color textColor = COLOR_HELP_TEXT_TYPE_03_NORMAL;
135 int noContentTextHeight = GetHeightForStringArea(labelText, bitmapWidth, 32);
137 int xPos = (clientRect.width / LINE_COUNT_2) - (bitmapWidth / DIVIDE_BY_TWO);
138 int yPos = (clientRect.height / LINE_COUNT_2) - ((bitmapHeight + noContentTextHeight) / DIVIDE_BY_TWO);
140 Label* pLabel = new (std::nothrow) Label();
141 pLabel->Construct(Rectangle(xPos, yPos, bitmapWidth, bitmapHeight), L"");
142 pLabel->SetName(NO_CONTENTS);
143 pLabel->SetBackgroundBitmap(*pBitmp);
145 yPos = yPos + bitmapHeight;
147 Label* pLabelNoContents = new (std::nothrow) Label();
148 pLabelNoContents->Construct(Rectangle(0, yPos, clientRect.width, noContentTextHeight), L"");
149 pLabelNoContents->SetName(NO_CONTENTS_TEXT);
150 pLabelNoContents->SetTextColor(textColor);
151 pLabelNoContents->SetText(labelText);
154 AddControl(pLabelNoContents);
160 KeyboardInfoForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
165 KeyboardInfoForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
167 SceneManager* pSceneManager = SceneManager::GetInstance();
168 AppAssert(pSceneManager);
170 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
174 KeyboardInfoForm::GetGroupCount(void)
176 return ID_GROUP_COUNT;
180 KeyboardInfoForm::GetItemCount(int groupIndex)
186 case ID_GROUP_KEYBOARD_SOFTWARE:
188 if (__pInputMethodInfo != null)
190 InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(__pInputMethodInfo->GetAt(0));
191 const IList* pLangList = pInputMethodInfo->GetLanguageList();
192 itemCount = pLangList->GetCount();
205 KeyboardInfoForm::CreateGroupItem(int groupIndex, int itemWidth)
208 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
210 pItem->Construct(Dimension(itemWidth, itemHeight));
211 pItem->SetEnabled(false);
217 KeyboardInfoForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
219 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
221 Rectangle itemMainRectangle;
222 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
224 Label* pLabel = null;
225 int fontSize = GetFontSize();
227 TableViewItem* pItem = new (std::nothrow) TableViewItem();
229 if ((__pInputMethodInfo == null)
236 InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(__pInputMethodInfo->GetAt(0));
237 const IList* pLangList = pInputMethodInfo->GetLanguageList();
238 const Tizen::Locales::Locale* pLocale = static_cast<const Tizen::Locales::Locale*>(pLangList->GetAt(itemIndex));
241 itemMainText = pLocale->GetLocaleCodeString();
244 ItemTypeOneLine(itemMainRectangle);
246 RelativeLayout relativeLayout;
247 relativeLayout.Construct();
249 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
250 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
252 pLabel = new (std::nothrow) Label();
253 pLabel->Construct(itemMainRectangle, itemMainText);
254 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
255 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
256 pLabel->SetTextColor(COLOR_MAIN_TEXT);
258 pItem->AddControl(pLabel);
259 pItem->SetIndividualSelectionEnabled(pLabel, true);
261 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
262 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
263 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
269 KeyboardInfoForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
271 AppLogDebug("ENTER");
280 KeyboardInfoForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
282 AppLogDebug("ENTER");
291 KeyboardInfoForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
293 SceneManager* pSceneManager = SceneManager::GetInstance();
294 AppAssert(pSceneManager);
296 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
300 case ID_GROUP_KEYBOARD_SOFTWARE:
302 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_SELECT_KEYBOARD)
304 // TODO: select software keyboard.
307 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_KEYBOARD_SETTING)
309 // TODO: more setting for software keyboard.
314 case ID_GROUP_KEYBOARD_HARDWARE:
316 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_SELECT_KEYBOARD)
318 // TODO: nothing todo yet.
321 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_KEYBOARD_SETTING)
323 // TODO: nothing todo yet.
334 KeyboardInfoForm::GetDefaultGroupItemHeight(void)
336 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
340 KeyboardInfoForm::GetDefaultItemHeight(void)
342 return H_GROUP_ITEM_DEFAULT;
346 KeyboardInfoForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
351 KeyboardInfoForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
356 KeyboardInfoForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
361 KeyboardInfoForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
366 KeyboardInfoForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
368 Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
371 Rectangle clientRect = GetClientAreaBounds();
372 Rectangle labelBound = pLabel->GetBounds();
374 int xPos = (clientRect.width / LINE_COUNT_2) - (labelBound.width / LINE_COUNT_2);
375 int yPos = (clientRect.height / LINE_COUNT_2) -(labelBound.height / LINE_COUNT_2);
377 pLabel->SetBounds(Rectangle(xPos, yPos, labelBound.width, labelBound.height));
378 yPos = yPos + pLabel->GetBounds().height;
379 Label* pTextLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS_TEXT, false));
380 if (pTextLabel != null)
382 pTextLabel->SetBounds(Rectangle(0, yPos, clientRect.width, pTextLabel->GetBounds().height));