3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 /*@file: IntFormFactory.cpp
20 *@brief: FormFactory class helps in creating appropriate forms with a specified form ID.
21 * It Should be derived from Tizen::Ui::Scenes::IFormFactory class
24 #include "IntAddBookmarkForm.h"
25 #include "IntArticleReaderForm.h"
26 #include "IntBookmarkListForm.h"
27 #include "IntBrightnessForm.h"
28 #include "IntCommonLib.h"
29 #include "IntCreateBookmarkFolderForm.h"
30 #include "IntEditBookmarkListForm.h"
31 #include "IntEditHistoryListForm.h"
32 #include "IntEditHomePageForm.h"
33 #include "IntHistoryListForm.h"
34 #include "IntMainForm.h"
35 #include "IntMultipleWindowForm.h"
36 #include "IntReaderFontSizeForm.h"
37 #include "IntFormFactory.h"
38 #include "IntSettingForm.h"
40 using namespace Tizen::App;
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::Ui;
44 using namespace Tizen::Ui::Controls;
45 using namespace Tizen::Ui::Scenes;
47 const wchar_t* IDL_FORM_MAIN_VIEW_SCENE = L"FormMainMenu";
48 const wchar_t* IDL_FORM_BOOKMARK_LIST_SCENE = L"BooKmarkList";
49 const wchar_t* IDL_FORM_HISTORY_LIST_SCENE = L"HistoryList";
50 const wchar_t* IDL_FORM_EDIT_HISTORY_LIST_SCENE = L"EditHistoryList";
51 const wchar_t* IDL_FORM_SETTINGS_CLEAR_PRIVATE_DATA_SCENE = L"SettingsClearPrivateData";
52 const wchar_t* IDL_FORM_MULTIPLE_WINDOW_SCENE = L"MultipleWindow";
53 const wchar_t* IDL_FORM_SETTINGS_SCENE = L"Settings";
54 const wchar_t* IDL_FORM_ADD_BOOKMARK_SCENE = L"AddBookmark";
55 const wchar_t* IDL_FORM_ARTICLE_READER_SCENE = L"ArticleReader";
56 const wchar_t* IDL_FORM_EDIT_BOOKMARK_LIST_SCENE = L"EditBookmarkList";
57 const wchar_t* IDL_FORM_FIND_WORD_SCENE = L"FindWord";
58 const wchar_t* IDL_FORM_CREATE_BOOKMARK_FOLDER_SCENE = L"CreateBookmarkFolder";
59 const wchar_t* IDL_FORM_FONT_SIZE_SCENE = L"FontSize";
60 const wchar_t* IDL_FORM_EDIT_HOME_PAGE_SCENE = L"EditHomePage";
61 const wchar_t* IDL_FORM_BRIGHTNESS_SCENE = L"Brightness";
64 FormFactory::FormFactory(void)
69 FormFactory::~FormFactory(void)
75 FormFactory::CreateFormN(const String& formId, const SceneId& sceneId)
77 AppLog("FormFactory createForm");
79 Tizen::Ui::Controls::Form* pNewForm = null;
80 SceneManager* pSceneManager = SceneManager::GetInstance();
82 if ( pSceneManager == null)
87 if (formId.Contains(IDL_FORM_MAIN_VIEW_SCENE) == true)
89 MainForm* pForm = new(std::nothrow) MainForm();
95 pSceneManager->AddSceneEventListener(sceneId, *pForm);
98 else if (formId == IDL_FORM_BOOKMARK_LIST_SCENE)
100 BookmarkListForm* pForm = new(std::nothrow) BookmarkListForm();
108 else if (formId == IDL_FORM_HISTORY_LIST_SCENE)
110 HistoryListForm* pForm = new(std::nothrow) HistoryListForm();
118 else if (formId == IDL_FORM_EDIT_HISTORY_LIST_SCENE)
120 EditHistoryListForm* pForm = new(std::nothrow) EditHistoryListForm();
129 else if (formId == IDL_FORM_MULTIPLE_WINDOW_SCENE)
131 MultipleWindowForm* pForm = new(std::nothrow) MultipleWindowForm();
139 else if (formId == IDL_FORM_SETTINGS_SCENE)
141 SettingForm* pForm = new(std::nothrow) SettingForm();
149 else if (formId == IDL_FORM_ADD_BOOKMARK_SCENE)
151 AddBookmarkForm* pForm = new(std::nothrow) AddBookmarkForm();
159 else if (formId == IDL_FORM_ARTICLE_READER_SCENE)
161 ArticleReaderForm* pForm = new(std::nothrow) ArticleReaderForm();
169 else if (formId == IDL_FORM_EDIT_BOOKMARK_LIST_SCENE)
171 EditBookmarkListForm* pForm = new(std::nothrow) EditBookmarkListForm();
180 else if (formId == IDL_FORM_CREATE_BOOKMARK_FOLDER_SCENE)
182 CreateBookmarkFolderForm* pForm = new(std::nothrow) CreateBookmarkFolderForm();
191 else if (formId == IDL_FORM_FONT_SIZE_SCENE)
193 ReaderFontSizeForm* pForm = new(std::nothrow) ReaderFontSizeForm();
201 else if (formId == IDL_FORM_EDIT_HOME_PAGE_SCENE)
203 EditHomePageForm* pForm = new(std::nothrow) EditHomePageForm();
211 else if (formId == IDL_FORM_BRIGHTNESS_SCENE)
213 BrightnessForm* pForm = new(std::nothrow) BrightnessForm();
221 AppLogDebug("FormFactory createForm exit");
222 // pSceneManager->AddSceneEventListener(sceneId, *this);
228 FormFactory::SetFontSize(Container& container, int font)
230 IList* pControls = container.GetControls();
231 if(pControls == null)
235 for(int count = 0; count < pControls->GetCount(); count++)
237 //Check if the control is again an container
238 Container *pContainer = dynamic_cast<Container*>(pControls->GetAt(count));
239 if(pContainer != null)
241 SetFontSize(*pContainer, font);
243 else //Check if it is a button
245 Button *pButton = dynamic_cast<Button*>(pControls->GetAt(count));
248 pButton->SetTextSize(font);
250 else //Check if a label
252 Label *pLabel = dynamic_cast<Label*>(pControls->GetAt(count));
255 pLabel->SetTextConfig(font, pLabel->GetTextStyle());
257 else //Check if a EditField
259 EditField *pEditField = dynamic_cast<EditField*>(pControls->GetAt(count));
260 if(pEditField != null)
262 pEditField->SetTextSize(font);
264 else //Check if a EditArea
266 EditArea *pEditArea = dynamic_cast<EditArea*>(pControls->GetAt(count));
267 if(pEditArea != null)
269 pEditArea->SetTextSize(font);
271 else //Check if a ExpandableEditArea
273 ExpandableEditArea *pExpandableEditArea = dynamic_cast<ExpandableEditArea*>(pControls->GetAt(count));
274 if(pExpandableEditArea != null)
276 pExpandableEditArea->SetTextSize(font);
278 else //Check if a TextBox
280 TextBox *pTextBox = dynamic_cast<TextBox*>(pControls->GetAt(count));
283 pTextBox->SetTextSize(font);
285 else //Check if a SearchBar
287 SearchBar *pSearchBar = dynamic_cast<SearchBar*>(pControls->GetAt(count));
288 if(pSearchBar != null)
290 pSearchBar->SetSearchFieldTextSize(font);
292 else //Check if a List
307 FormFactory::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
309 AppLog("FormFactory::OnSceneActivatedN");
310 Form *pForm = UiApp::GetInstance()->GetFrameAt(0)->GetCurrentForm();
314 String fontSizeStr = "";
315 int fontSize = CommonUtil::GetFontSize();
316 AppLog("Font sizeStr: %ls, fontsize:%d", fontSizeStr.GetPointer(), fontSize);
317 SetFontSize(*pForm, fontSize);
318 pForm->Invalidate(true);