3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (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://www.tizenopensource.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.
18 #include "ComplexForm.h"
19 #include "SceneRegister.h"
21 using namespace Osp::Base;
22 using namespace Osp::Ui;
23 using namespace Osp::Ui::Controls;
24 using namespace Osp::Ui::Scenes;
25 using namespace Osp::Base::Collection;
28 static const int ID_BUTTON_NEXT_CHAPTER = 101;
29 static const int ID_BUTTON_HELP = 102;
30 static const int ID_BUTTON_GO_MAIN_MENU = 103;
31 static const int ID_HEADER_BUTTON_LEFT = 110;
32 static const int ID_HEADER_BUTTON_RIGHT = 111;
35 ComplexForm::ComplexForm(void)
39 ComplexForm::~ComplexForm(void)
44 ComplexForm::Initialize(void)
46 Form::Construct(L"IDF_COMPLEX_FORM");
52 ComplexForm::OnInitializing(void)
57 Header* pHeader = GetHeader();
59 ButtonItem buttonItem;
60 buttonItem.Construct(BUTTON_ITEM_STYLE_TEXT, ID_HEADER_BUTTON_LEFT);
61 buttonItem.SetText(L"Info");
62 pHeader->SetButton(BUTTON_POSITION_LEFT, buttonItem);
63 buttonItem.SetActionId(ID_HEADER_BUTTON_RIGHT);
64 buttonItem.SetText(L"Log");
65 pHeader->SetButton(BUTTON_POSITION_RIGHT, buttonItem);
66 pHeader->AddActionEventListener(*this);
69 Footer* pFooter = GetFooter();
71 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
72 pFooter->SetBackButton();
73 pFooter->AddActionEventListener(*this);
75 SetFormBackEventListener(this);
78 Button* pButton = static_cast<Button*>(GetControl("IDC_BUTTON_NEXT_CHAPTER"));
80 pButton->SetActionId(ID_BUTTON_NEXT_CHAPTER);
81 pButton->AddActionEventListener(*this);
83 pButton = static_cast<Button*>(GetControl("IDC_BUTTON_HELP"));
85 pButton->SetActionId(ID_BUTTON_HELP);
86 pButton->AddActionEventListener(*this);
88 pButton = static_cast<Button*>(GetControl("IDC_BUTTON_GO_MAIN_MENU"));
90 pButton->SetActionId(ID_BUTTON_GO_MAIN_MENU);
91 pButton->AddActionEventListener(*this);
97 ComplexForm::OnTerminating(void)
105 ComplexForm::OnSceneActivatedN(const Osp::Ui::Scenes::SceneId& previousSceneId,
106 const Osp::Ui::Scenes::SceneId& currentSceneId, Osp::Base::Collection::IList* pArgs)
108 // Replace title to scene name
109 Header* pHeader = GetHeader();
111 pHeader->SetTitleText(currentSceneId);
113 // Set next button text
114 Button* pButton = static_cast<Button*>(GetControl("IDC_BUTTON_NEXT_CHAPTER"));
116 pButton->SetText((currentSceneId == SCENE_COMPLEX_4) ? L"Back To Chapter 1" : L"Next Chapter >");
118 String chapterDescription;
119 if (currentSceneId == SCENE_COMPLEX_1)
121 chapterDescription = L"Chapter 1.\n\nWelcome to Scene Management.\n\nScene is combination of Form + Panel control.";
123 else if (currentSceneId == SCENE_COMPLEX_2)
125 chapterDescription = L"Chapter 2.\n\nPrepare FormFactory and PanelFactory.\n\nRegister a Scene to SceneManager.";
127 else if (currentSceneId == SCENE_COMPLEX_3)
129 chapterDescription = L"Chapter 3.\n\nScene navigation with GoFoward() and GoBackward()."
130 L"\n\nGet callback with Scene event listener and Scene manager event listener.";
132 else if (currentSceneId == SCENE_COMPLEX_4)
134 chapterDescription = L"Chapter 4.\n\nThe more!\n\nSceneTransitionPolicyProvider and SceneAnimationProvider.";
138 chapterDescription = L"Is error case?";
141 TextBox* pTextBox = static_cast<TextBox*>(GetControl("IDC_TEXTBOX_MESSAGE"));
143 pTextBox->SetText(chapterDescription);
147 ComplexForm::OnSceneDeactivated(const Osp::Ui::Scenes::SceneId& currentSceneId,
148 const Osp::Ui::Scenes::SceneId& nextSceneId)
154 ComplexForm::OnActionPerformed(const Osp::Ui::Control& source, int actionId)
156 SceneManager* pSceneManager = SceneManager::GetInstance();
157 AppAssert(pSceneManager);
158 SceneId currentSceneId = pSceneManager->GetCurrentSceneId();
162 case ID_HEADER_BUTTON_LEFT:
163 pSceneManager->GoForward(ForwardSceneTransition(SCENE_INFORMATION));
166 case ID_HEADER_BUTTON_RIGHT:
167 pSceneManager->GoForward(ForwardSceneTransition(SCENE_LOG));
170 case ID_BUTTON_NEXT_CHAPTER:
171 if (currentSceneId == SCENE_COMPLEX_4)
173 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_COMPLEX_1, SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_OUT));
177 // GoForward via SceneTransitionPolicyProvider's scenario.
178 pSceneManager->GoForward(ForwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
183 pSceneManager->GoForward(ForwardSceneTransition(SCENE_HELP));
186 case ID_BUTTON_GO_MAIN_MENU:
187 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_MAIN_MENU, (currentSceneId == SCENE_COMPLEX_1) ?
188 SCENE_TRANSITION_ANIMATION_TYPE_RIGHT : SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_OUT));
194 ComplexForm::OnFormBackRequested(Osp::Ui::Controls::Form& source)
196 SceneManager* pSceneManager = SceneManager::GetInstance();
197 AppAssert(pSceneManager);
198 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));