Initialize Tizen 2.3
[apps/osp/Contacts.git] / src / CtPanelFactory.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file        CtPanelFactory.cpp
19  * @brief       This is the implementation file for the PanelFactory class.
20  */
21
22 #include "CtContactListEditorPanel.h"
23 #include "CtContactListPanel.h"
24 #include "CtFavoriteListEditorPanel.h"
25 #include "CtFavoriteListPanel.h"
26 #include "CtGroupListPanel.h"
27 #include "CtGroupListEditorPanel.h"
28 #include "CtPanelFactory.h"
29 #include "CtTypes.h"
30
31 using namespace Tizen::Ui::Controls;
32 using namespace Tizen::Ui::Scenes;
33
34 PanelFactory::PanelFactory(void)
35 {
36 }
37
38 PanelFactory::~PanelFactory(void)
39 {
40 }
41
42 Tizen::Ui::Controls::Panel*
43 PanelFactory::CreatePanelN(const Tizen::Base::String& panelId, const Tizen::Ui::Scenes::SceneId& sceneId)
44 {
45         result r = E_SUCCESS;
46
47         Panel* pNewPanel= null;
48         SceneManager* pSceneManager = SceneManager::GetInstance();
49
50         if (panelId == IDC_PANEL_CONTACT_LIST)
51         {
52                 ContactListPanel* pPanel = new (std::nothrow) ContactListPanel();
53                 pPanel->Initialize();
54
55                 r = pSceneManager->AddSceneEventListener(sceneId, *pPanel);
56                 TryCatch(r == E_SUCCESS, delete pPanel, "[%s] Unable to add scene event listener", GetErrorMessage(r));
57
58                 pNewPanel = pPanel;
59         }
60         else if (panelId == IDC_PANEL_CONTACT_LIST_EDITOR)
61         {
62                 ContactListEditorPanel* pPanel = new (std::nothrow) ContactListEditorPanel();
63                 pPanel->Initialize();
64
65                 r = pSceneManager->AddSceneEventListener(sceneId, *pPanel);
66                 TryCatch(r == E_SUCCESS, delete pPanel, "[%s] Unable to add scene event listener", GetErrorMessage(r));
67
68                 pNewPanel = pPanel;
69         }
70         else if (panelId == IDC_PANEL_GROUP_LIST)
71         {
72                 GroupListPanel* pPanel = new (std::nothrow) GroupListPanel();
73                 pPanel->Initialize();
74
75                 r = pSceneManager->AddSceneEventListener(sceneId, *pPanel);
76                 TryCatch(r == E_SUCCESS, delete pPanel, "[%s] Unable to add scene event listener", GetErrorMessage(r));
77
78                 pNewPanel = pPanel;
79         }
80         else if (panelId == IDC_PANEL_GROUP_LIST_EDITOR)
81         {
82                 GroupListEditorPanel* pPanel = new (std::nothrow) GroupListEditorPanel();
83                 pPanel->Initialize();
84
85                 r = pSceneManager->AddSceneEventListener(sceneId, *pPanel);
86                 TryCatch(r == E_SUCCESS, delete pPanel, "[%s] Unable to add scene event listener", GetErrorMessage(r));
87
88                 pNewPanel = pPanel;
89         }
90         else if (panelId == IDC_PANEL_FAVORITE_LIST)
91         {
92                 FavoriteListPanel* pPanel = new (std::nothrow) FavoriteListPanel();
93                 pPanel->Initialize();
94
95                 r = pSceneManager->AddSceneEventListener(sceneId, *pPanel);
96                 TryCatch(r == E_SUCCESS, delete pPanel, "[%s] Unable to add scene event listener", GetErrorMessage(r));
97
98                 pNewPanel = pPanel;
99         }
100         else if (panelId == IDC_PANEL_FAVORITE_LIST_EDITOR)
101         {
102                 FavoriteListEditorPanel* pPanel = new (std::nothrow) FavoriteListEditorPanel();
103                 pPanel->Initialize();
104
105                 r = pSceneManager->AddSceneEventListener(sceneId, *pPanel);
106                 TryCatch(r == E_SUCCESS, delete pPanel, "[%s] Unable to add scene event listener", GetErrorMessage(r));
107
108                 pNewPanel = pPanel;
109         }
110
111         return pNewPanel;
112
113 CATCH:
114         return null;
115 }