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_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;
46 KeyboardInfoForm::KeyboardInfoForm(void)
47 : __pInputMethodInfo(null)
51 KeyboardInfoForm::~KeyboardInfoForm(void)
56 KeyboardInfoForm::CreateFooter(void)
58 Footer* pFooter = GetFooter();
61 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
62 pFooter->SetBackButton();
63 pFooter->AddActionEventListener(*this);
65 SetFormBackEventListener(this);
69 KeyboardInfoForm::OnInitializing(void)
75 KeyboardInfoForm::OnTerminating(void)
77 if (__pInputMethodInfo != null )
79 __pInputMethodInfo->RemoveAll();
80 delete __pInputMethodInfo;
81 __pInputMethodInfo = null;
85 SetFormBackEventListener(null);
90 KeyboardInfoForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
94 AppLogDebug("pArgs is null");
98 __pInputMethodInfo = pArgs;
99 InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(__pInputMethodInfo->GetAt(0));
100 String headerName = pInputMethodInfo->GetName();
101 const IList* pLangList = pInputMethodInfo->GetLanguageList();
103 CreateHeader(headerName);
106 if (__pTableView != null)
108 int tableViewControlCount = __pTableView->GetControlCount();
109 for (int i = 0; i < tableViewControlCount; i++)
111 __pTableView->RemoveControl(__pTableView->GetControl(0));
113 // __pTableView->RemoveAllControls();
116 int controlCount = GetControlCount();
117 for (int i = 0; i < controlCount; i++)
119 RemoveControl(GetControl(0));
121 // RemoveAllControls();
122 if (pLangList->GetCount() != 0)
128 Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
131 Rectangle clientRect = GetClientAreaBounds();
132 Bitmap* pBitmp = ResourceManager::GetBitmapN(IDB_NO_CONTENTS);
134 int bitmapWidth = pBitmp->GetWidth();
135 int bitmapHeight = pBitmp->GetHeight();
136 String labelText = ResourceManager::GetString(L"IDS_ST_BODY_NO_CONTENT");
137 Color textColor = COLOR_HELP_TEXT_TYPE_03_NORMAL;
138 int noContentTextHeight = GetHeightForStringArea(labelText, bitmapWidth, 32);
140 int xPos = (clientRect.width / LINE_COUNT_2) - (bitmapWidth / DIVIDE_BY_TWO);
141 int yPos = (clientRect.height / LINE_COUNT_2) - ((bitmapHeight + noContentTextHeight) / DIVIDE_BY_TWO);
143 Label* pLabel = new (std::nothrow) Label();
144 pLabel->Construct(Rectangle(xPos, yPos, bitmapWidth, bitmapHeight), L"");
145 pLabel->SetName(NO_CONTENTS);
146 pLabel->SetBackgroundBitmap(*pBitmp);
148 yPos = yPos + bitmapHeight;
150 Label* pLabelNoContents = new (std::nothrow) Label();
151 pLabelNoContents->Construct(Rectangle(0, yPos, clientRect.width, noContentTextHeight), L"");
152 pLabelNoContents->SetName(NO_CONTENTS_TEXT);
153 pLabelNoContents->SetTextColor(textColor);
154 pLabelNoContents->SetText(labelText);
157 AddControl(pLabelNoContents);
163 KeyboardInfoForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
168 KeyboardInfoForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
170 SceneManager* pSceneManager = SceneManager::GetInstance();
171 AppAssert(pSceneManager);
173 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
177 KeyboardInfoForm::GetGroupCount(void)
179 return ID_GROUP_COUNT;
183 KeyboardInfoForm::GetItemCount(int groupIndex)
189 case ID_GROUP_KEYBOARD_SOFTWARE:
191 if (__pInputMethodInfo != null)
193 InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(__pInputMethodInfo->GetAt(0));
194 const IList* pLangList = pInputMethodInfo->GetLanguageList();
195 itemCount = pLangList->GetCount();
208 KeyboardInfoForm::CreateGroupItem(int groupIndex, int itemWidth)
211 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
213 pItem->Construct(Dimension(itemWidth, itemHeight));
214 pItem->SetEnabled(false);
220 KeyboardInfoForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
222 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
224 Rectangle itemMainRectangle;
225 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
227 Label* pLabel = null;
228 int fontSize = GetFontSize();
230 TableViewItem* pItem = new (std::nothrow) TableViewItem();
232 if ((__pInputMethodInfo == null)
239 InputMethodInfo* pInputMethodInfo = static_cast<InputMethodInfo*>(__pInputMethodInfo->GetAt(0));
240 const IList* pLangList = pInputMethodInfo->GetLanguageList();
241 const Tizen::Locales::Locale* pLocale = static_cast<const Tizen::Locales::Locale*>(pLangList->GetAt(itemIndex));
244 itemMainText = pLocale->GetLocaleCodeString();
247 ItemTypeOneLine(itemMainRectangle);
249 RelativeLayout relativeLayout;
250 relativeLayout.Construct();
252 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
253 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
255 pLabel = new (std::nothrow) Label();
256 pLabel->Construct(itemMainRectangle, itemMainText);
257 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
258 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
259 pLabel->SetTextColor(COLOR_MAIN_TEXT);
261 pItem->AddControl(pLabel);
262 pItem->SetIndividualSelectionEnabled(pLabel, true);
264 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
265 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
266 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
272 KeyboardInfoForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
274 AppLogDebug("ENTER");
283 KeyboardInfoForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
285 AppLogDebug("ENTER");
294 KeyboardInfoForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
296 SceneManager* pSceneManager = SceneManager::GetInstance();
297 AppAssert(pSceneManager);
299 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
303 case ID_GROUP_KEYBOARD_SOFTWARE:
305 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_SELECT_KEYBOARD)
307 // TODO: select software keyboard.
310 if (itemIndex == ID_ITEM_KEYBOARD_SOFTWARE_KEYBOARD_SETTING)
312 // TODO: more setting for software keyboard.
317 case ID_GROUP_KEYBOARD_HARDWARE:
319 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_SELECT_KEYBOARD)
321 // TODO: nothing todo yet.
324 if (itemIndex == ID_ITEM_KEYBOARD_HARDWARE_KEYBOARD_SETTING)
326 // TODO: nothing todo yet.
337 KeyboardInfoForm::GetDefaultGroupItemHeight(void)
339 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
343 KeyboardInfoForm::GetDefaultItemHeight(void)
345 return H_GROUP_ITEM_DEFAULT;
349 KeyboardInfoForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
354 KeyboardInfoForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
359 KeyboardInfoForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
364 KeyboardInfoForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
369 KeyboardInfoForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
371 Label* pLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS, false));
374 Rectangle clientRect = GetClientAreaBounds();
375 Rectangle labelBound = pLabel->GetBounds();
377 int xPos = (clientRect.width / LINE_COUNT_2) - (labelBound.width / LINE_COUNT_2);
378 int yPos = (clientRect.height / LINE_COUNT_2) -(labelBound.height / LINE_COUNT_2);
380 pLabel->SetBounds(Rectangle(xPos, yPos, labelBound.width, labelBound.height));
381 yPos = yPos + pLabel->GetBounds().height;
382 Label* pTextLabel = static_cast<Label*>(this->GetControl(NO_CONTENTS_TEXT, false));
383 if (pTextLabel != null)
385 pTextLabel->SetBounds(Rectangle(0, yPos, clientRect.width, pTextLabel->GetBounds().height));