Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / cpp / Sample / Tizen C++ / UiControls / UiControls / project / src / FormMgr.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.tizenopensource.org/license
10 //
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.
16 //
17 #include "FormMgr.h"\r
18 #include "AnimationForm.h"\r
19 #include "ButtonForm.h"\r
20 #include "CheckButtonForm.h"\r
21 #include "ColorPickerForm.h"\r
22 #include "EditDateForm.h"\r
23 #include "EditForm.h"\r
24 #include "MenuForm.h"\r
25 #include "MsgBoxPopupForm.h"\r
26 #include "OverlayKeypadForm.h"\r
27 #include "PanelForm.h"\r
28 #include "ProgressForm.h"\r
29 #include "RadioGroupForm.h"\r
30 #include "SliderForm.h"\r
31 #include "EditTimeForm.h"\r
32 #include "NavigationForm.h"\r
33 #include "DateTimeForm.h"\r
34 #include "ListViewForm.h"\r
35 #include "GroupedListViewForm.h"\r
36 #include "IconListViewForm.h"\r
37 #include "SearchBarForm.h"\r
38 #include "EnrichedTextForm.h"\r
39 #include "ExpandableEditAreaForm.h"\r
40 #include "GalleryForm.h"\r
41 #include "TextBoxForm.h"\r
42 #include "CustomButtonForm.h"\r
43 #include "DataBindingForm.h"\r
44 \r
45 using namespace Osp::App;\r
46 using namespace Osp::Base;\r
47 using namespace Osp::Ui;\r
48 using namespace Osp::Ui::Controls;\r
49 \r
50 FormMgr::FormMgr(void):\r
51 __pPreviousForm(null),\r
52 __pMainForm(null)\r
53 {\r
54 }\r
55 \r
56 FormMgr::~FormMgr(void)\r
57 {\r
58 }\r
59 \r
60 bool\r
61 FormMgr::Initialize(void)\r
62 {\r
63         result r = E_SUCCESS;\r
64         r = Construct(FORM_STYLE_NORMAL);\r
65         SetName(L"FormMgr");\r
66 \r
67         return true;\r
68 }\r
69 \r
70 bool FormMgr::SetStarterForm(RequestId requestId, Osp::Base::Collection::IList* pArgs)\r
71 {\r
72         Form* pCurrentForm = Application::GetInstance()->GetAppFrame()->GetFrame()->GetCurrentForm();\r
73 \r
74         if (pCurrentForm == this)\r
75                 SwitchToForm(requestId, pArgs);\r
76         else\r
77                 return false;\r
78 \r
79         return true;\r
80 }\r
81 \r
82 void FormMgr::OnUserEventReceivedN(RequestId requestId, Osp::Base::Collection::IList* pArgs)\r
83 {\r
84         SwitchToForm(requestId, pArgs);\r
85 }\r
86 \r
87 void\r
88 FormMgr::SwitchToForm(RequestId requestId, Osp::Base::Collection::IList* pArgs)\r
89 {\r
90         Frame* pFrame = Application::GetInstance()->GetAppFrame()->GetFrame();\r
91         BaseForm* pExeForm = null;\r
92 \r
93         switch (requestId)\r
94         {\r
95         case REQUEST_MAINFORM:\r
96                 {\r
97                         if (__pMainForm == null)\r
98                         {\r
99                                 __pMainForm = new MainForm();\r
100                                 __pMainForm->Initialize();\r
101                                 pFrame->AddControl(*__pMainForm);\r
102                         }\r
103                         pFrame->SetCurrentForm(*__pMainForm);\r
104       __pMainForm->Draw();\r
105       if (__pPreviousForm != null)\r
106       {\r
107         if (__pPreviousForm != __pMainForm)\r
108           pFrame->RemoveControl(*__pPreviousForm);\r
109       }\r
110       __pPreviousForm = __pMainForm;\r
111                         \r
112                         return;\r
113                 }\r
114                 break;\r
115         case REQUEST_ANIMATIONFORM:\r
116                         pExeForm = new AnimationForm();\r
117                 break;\r
118         case REQUEST_BUTTONFORM:\r
119                         pExeForm = new ButtonForm();\r
120                         break;\r
121         case REQUEST_CHECKBUTTONFORM:\r
122                         pExeForm = new CheckButtonForm();\r
123                         break;\r
124         case REQUEST_COLORPICKERFORM:\r
125                         pExeForm = new ColorPickerForm();\r
126                         break;\r
127         case REQUEST_EDITDATEFORM:\r
128                         pExeForm = new EditDateForm();\r
129                         break;\r
130         case REQUEST_EDITFORM:\r
131                         pExeForm = new EditForm();\r
132                         break;\r
133         case REQUEST_MENUFORM:\r
134                         pExeForm = new MenuForm();\r
135                         break;\r
136         case REQUEST_MSGBOXPOPUPFORM:\r
137                         pExeForm = new MsgBoxPopupForm();\r
138                         break;\r
139         case REQUEST_OVERLAYKEYPADFORM:\r
140                         pExeForm = new OverlayKeypadForm();\r
141                         break;\r
142         case REQUEST_PANELFORM:\r
143                         pExeForm = new PanelForm();\r
144                         break;\r
145         case REQUEST_PROGRESSFORM:\r
146                         pExeForm = new ProgressForm();\r
147                         break;\r
148         case REQUEST_RADIOGROUPFORM:\r
149                         pExeForm = new RadioGroupForm();\r
150                         break;\r
151         case REQUEST_SLIDABLRFORM:\r
152                         pExeForm = new SliderForm();\r
153                         break;\r
154         case REQUEST_EDITTIMEFORM:\r
155                         pExeForm = new EditTimeForm();\r
156                         break;\r
157         case REQUEST_NAVIGATIONFORM:\r
158                         pExeForm = new NavigationForm();\r
159                         break;\r
160         case REQUEST_DATETIMEFORM:\r
161                         pExeForm = new DateTimeForm();\r
162                         break;\r
163         case REQUEST_LISTVIEWFORM:\r
164                         pExeForm = new ListViewForm();\r
165                         break;\r
166         case REQUEST_GROUPEDLISTVIEWFORM:\r
167                         pExeForm = new GroupedListViewForm();\r
168                         break;\r
169         case REQUEST_ICONLISTVIEWFORM:\r
170                         pExeForm = new IconListViewForm();\r
171                         break;\r
172         case REQUEST_SEARCHBARFORM:\r
173                         pExeForm = new SearchBarForm();\r
174                         break;\r
175         case REQUEST_ENRICHEDTEXTFORM:\r
176                         pExeForm = new EnrichedTextForm();\r
177                         break;\r
178         case REQUEST_EXPANDABLEEDITAREAFORM:\r
179                         pExeForm = new ExpandableEditAreaForm();\r
180                         break;\r
181         case REQUEST_GALLERYFORM:\r
182                         pExeForm = new GalleryForm();\r
183                         break;\r
184         case REQUEST_TEXTBOXFORM:\r
185                         pExeForm = new TextBoxForm();\r
186                         break;\r
187         case REQUEST_CUSTOMBUTTONFORM:\r
188                         pExeForm = new CustomButtonForm();\r
189                         break;\r
190 \r
191         case REQUEST_DATABINDINGFORM:\r
192                         pExeForm = new DataBindingForm();
193                         break;
194         default:\r
195                 return;\r
196                 break;\r
197         }\r
198 \r
199         pExeForm->Initialize();\r
200         pFrame->AddControl(*pExeForm);\r
201         pFrame->SetCurrentForm(*pExeForm);\r
202         pExeForm->Draw();\r
203 \r
204   if (__pPreviousForm != null)\r
205   {\r
206     if (__pPreviousForm != __pMainForm)\r
207       pFrame->RemoveControl(*__pPreviousForm);\r
208   }\r
209         __pPreviousForm = pExeForm;\r
210 \r
211         return;\r
212 }\r