7c6a2a4b5397e8be36fcaa6e0c8a21ff27d77d05
[apps/osp/Gallery.git] / src / GlSlideShowPopUp.cpp
1 //
2 // Tizen Native SDK
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.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
18 /**
19  * @file        SlideShowPopUp.cpp
20  * @brief       This file contains the definitions of the SlideShowPopUp class.
21  */
22
23 #include <FUiScenes.h>
24
25 #include "GlResourceManager.h"
26 #include "GlSlideSettingListener.h"
27 #include "GlSlideShowPopUp.h"
28
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
36
37 static const int ID_FORMAT_START = 501;
38 static const int ID_FORMAT_SETTING = 502;
39 static const int ID_CANCEL_BUTTON = 503;
40
41 SlideShowPopUp::SlideShowPopUp(void)
42         : __pList(null)
43         , __pListener(null)
44 {
45 }
46
47 SlideShowPopUp::~SlideShowPopUp(void)
48 {
49 }
50
51 bool
52 SlideShowPopUp::Initialize(void)
53 {
54         Button* pCancelButton = null;
55         Popup::Construct(L"IDL_SLIDESHOW_SETTING_POPUP");
56
57         __pList = static_cast<ListView*>(GetControl(L"IDC_POPUP_LIST"));
58
59         if (__pList == null)
60         {
61                 return false;
62         }
63
64         __pList->SetItemProvider(*this);
65         __pList->AddListViewItemEventListener(*this);
66
67         pCancelButton = static_cast<Button*>(GetControl(L"IDC_BUTTON", true));
68
69         if (pCancelButton != null)
70         {
71                 pCancelButton->AddActionEventListener(*this);
72                 pCancelButton->SetActionId(ID_CANCEL_BUTTON);
73         }
74
75         return true;
76 }
77
78 result
79 SlideShowPopUp::OnTerminating(void)
80 {
81         return E_SUCCESS;
82 }
83
84 void
85 SlideShowPopUp::OnActionPerformed(const Control& source, int actionId)
86 {
87         switch (actionId)
88         {
89         case ID_CANCEL_BUTTON:
90         {
91                 Popup::SetShowState(false);
92                 Popup::Show();
93         }
94         break;
95
96         default:
97                 break;
98         }
99         return;
100 }
101
102 void
103 SlideShowPopUp::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
104 {
105         if (__pListener != null)
106         {
107                 __pListener->OnSlideSettingPopUpItemSelected(index);
108         }
109 }
110
111 ListItemBase*
112 SlideShowPopUp::CreateItem(int index, int itemWidth)
113 {
114         ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
115         int listItemHeight = 112;
116
117         CustomItem* pItem = new (std::nothrow) CustomItem();
118         result r = pItem->Construct(Dimension(GetClientAreaBounds().width, listItemHeight), style);
119         pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
120
121         if (IsFailed(r))
122         {
123                 AppLogDebug("Create Item Failed with error %s", GetErrorMessage(r));
124                 return null;
125         }
126
127         switch (index)
128         {
129         case 0:
130         {
131                 pItem->AddElement(Rectangle(25, 0, GetClientAreaBounds().width, listItemHeight), ID_FORMAT_START,
132                                 ResourceManager::GetString(L"IDS_MEDIABR_OPT_START_SLIDESHOW"), true);
133         }
134         break;
135
136         case 1:
137         {
138                 pItem->AddElement(Rectangle(25, 0, GetClientAreaBounds().width, listItemHeight), ID_FORMAT_SETTING,
139                                 ResourceManager::GetString(L"IDS_MEDIABR_BODY_SLIDESHOW_SETTINGS"), true);
140         }
141         break;
142
143         break;
144         default:
145                 break;
146         }
147
148         return pItem;
149 }
150
151 bool
152 SlideShowPopUp::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
153 {
154         return true;
155 }
156
157 int
158 SlideShowPopUp::GetItemCount(void)
159 {
160         return 2;
161 }
162
163 void
164 SlideShowPopUp::SetEventListner(ISlideSettingListener* listner)
165 {
166         __pListener = listner;
167 }