Merge "fix crash on eglDestroySurface" into tizen_2.1
[platform/framework/native/uifw.git] / inc / FUiCtrlProgressPopup.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 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://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         FUiCtrlProgressPopup.h
20 * @brief                This is the header file for the %ProgressPopup class.
21 *
22 * This header file contains the declarations of the %ProgressPopup class.
23 */
24
25 #ifndef _FUI_CTRL_PROGRESS_POPUP_H_
26 #define _FUI_CTRL_PROGRESS_POPUP_H_
27
28
29 #include <FUiCtrlPopup.h>
30
31
32 namespace Tizen { namespace Ui
33 {
34 class IProgressPopupEventListener;
35 }}      // Tizen::Ui
36
37
38 namespace Tizen { namespace Ui { namespace Controls
39 {
40 /**
41  * @class       ProgressPopup
42  * @brief       This class defines the common behavior of a %ProgressPopup control.
43  *
44  * @since       2.0
45  *
46  * The %ProgressPopup class displays processing animation to show processing status.
47  * It can contain a title, body text and cancel button.
48  *
49  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_progresspopup.htm">ProgressPopup</a>.
50  *
51  * @see Tizen::Ui::Window
52  *
53  * The following example demonstrates how to use the %ProgressPopup class.
54  *
55  * @code
56 // Sample code for ProgressPopupSample.h
57 #include <FUi.h>
58
59 class ProgressPopupSample
60         : public Tizen::Ui::Controls::Form
61         , public Tizen::Ui::IProgressPopupEventListener
62 {
63 public:
64         ProgressPopupSample(void);
65         virtual ~ProgressPopupSample(void);
66
67         virtual bool Initialize(void);
68         void ShowProgressPopup(void);
69         virtual result OnInitializing(void);
70         virtual result OnTerminating(void);
71         virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
72
73         //IProgressPopupEventListener
74         virtual void OnProgressPopupCanceled(void);
75
76 private:
77         static const int ID_BUTTON_PROGRESSPOPUP = 501;
78
79         Tizen::Ui::Controls::ProgressPopup* __pProgressPopup;
80 };
81  * @endcode
82  *
83  * @code
84 // Sample code for ProgressPopupSample.cpp
85 #include "ProgressPopupSample.h"
86
87 using namespace Tizen::Ui;
88 using namespace Tizen::Ui::Controls;
89 using namespace Tizen::Graphics;
90
91 ProgressPopupSample::ProgressPopupSample(void)
92         : __pProgressPopup(null)
93 {
94 }
95
96 ProgressPopupSample::~ProgressPopupSample(void)
97 {
98 }
99
100 bool
101 ProgressPopupSample::Initialize(void)
102 {
103         Construct(FORM_STYLE_NORMAL);
104         return true;
105 }
106
107 result
108 ProgressPopupSample::OnInitializing(void)
109 {
110         result r = E_SUCCESS;
111
112         // Creates an instance of ProgressPopup
113         __pProgressPopup = new (std::nothrow) ProgressPopup();
114         __pProgressPopup->Construct(true,false);
115         __pProgressPopup->SetTitleText(L"ProgressPopup Test");
116         __pProgressPopup->SetText(L"Hello World!!");
117         __pProgressPopup->AddProgressPopupEventListener(*this);
118
119         // Creates an instance of Button to open the ProgressPopup.
120         Button* pButtonProgressPopup = new Button();
121         pButtonProgressPopup->Construct(Rectangle(10, 10, 250, 60), L"Open ProgressPopup");
122         pButtonProgressPopup->SetActionId(ID_BUTTON_PROGRESSPOPUP);
123         pButtonProgressPopup->AddActionEventListener(*this);
124
125         return r;
126 }
127
128 result
129 ProgressPopupSample::OnTerminating(void)
130 {
131         result r = E_SUCCESS;
132
133         // Deallocates the __pProgressPopup
134         delete __pProgressPopup;
135
136         return r;
137 }
138
139 void
140 ProgressPopupSample::ShowProgressPopup(void)
141 {
142         __pProgressPopup->SetShowState(true);
143         __pProgressPopup->Show();
144 }
145
146 void
147 ProgressPopupSample::OnActionPerformed(const Control& source, int actionId)
148 {
149         switch (actionId)
150         {
151         case ID_BUTTON_PROGRESSPOPUP:
152                 ShowProgressPopup();
153                 break;
154         default:
155                 break;
156         }
157 }
158
159 void
160 ProgressPopupSample::OnProgressPopupCanceled(void)
161 {
162         __pProgressPopup->SetShowState(false);
163         Invalidate(true);
164 }
165
166  * @endcode
167  */
168 class _OSP_EXPORT_ ProgressPopup
169         : public Popup
170 {
171 public:
172         /**
173          * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
174          *
175          * @since 2.0
176          */
177         ProgressPopup(void);
178
179         /**
180          * This destructor overrides Tizen::Base::Object::~Object().
181          *
182          * @since 2.0
183          */
184         virtual ~ProgressPopup(void);
185
186         /**
187          * Initializes this instance of %ProgressPopup with the specified parameters.
188          *
189          * @since 2.0
190          * @return        An error code
191          * @param[in]    cancelButton                Set to @c true if the %ProgressPopup window has a cancel button, @n
192          *                                                   else @c false
193          * @param[in]    transparent   Set to @c true if the %ProgressPopup window is translucent, @n
194          *                                                   else @c false
195          * @exception    E_SUCCESS                   The method is successful.
196          * @exception    E_SYSTEM                    A system error has occurred. @n
197                                                              This error occurs when the internal resource is not loaded.
198          * @remarks                                      To show a %ProgressPopup window, call Show() or DoModal() after calling the Construct() method. @n
199          *                                                   By default, the title area and the body text are not shown. @n
200          *                                                   Use SetTitleText() and SetText() to show the title area and the body text.
201          * @remarks                                       If @c transparent is set to true, a progress icon is only shown and a cancel button is not shown. @n
202          *                                                            Also, the texts set by SetTitleText() and SetText() are not shown.
203          * @remarks                                      If the specified @c cancelButton is set to true and ProgressPopup is closed by pressing a Cancel Button,
204          *                                                    out parameter of DoModal(), modalResult, is @c -1.
205          */
206         result Construct(bool cancelButton, bool transparent);
207
208         /**
209          * Sets the text of the %ProgressPopup window.
210          *
211          * @since 2.0
212          * @return                                        An error code
213          * @param[in]    text                           The text to set
214          * @exception    E_SUCCESS                   The method is successful.
215          * @exception    E_OUT_OF_MEMORY       The memory is insufficient.
216          * @remarks         If the %ProgressPopup window is constructed as transparent, the text is not shown.
217          */
218         result SetText(const Tizen::Base::String& text);
219
220         /**
221         * Gets the text of the %ProgressPopup window.
222         *
223         * @since 2.0
224         *
225         * @return                               The text of the %ProgressPopup window, @n
226         *                                       else an empty string if an error occurs
227         */
228         Tizen::Base::String GetText(void) const;
229
230         /**
231          * Adds a listener instance @n
232          * The added listener can listen to events on the given event dispatcher's context when they are fired.
233          *
234          * @since 2.0
235          * @return                                        An error code
236          * @param[in]     listener                      The event listener to add @n Listener should be allocated at heap, not stack.
237          * @exception     E_SUCCESS                  This method was successful.
238          * @exception     E_OBJ_ALREADY_EXIST    The listener was already exist.
239          */
240         result AddProgressPopupEventListener(Tizen::Ui::IProgressPopupEventListener& listener);
241
242         /**
243          * Removes a listener instance. @n
244          * The removed listener cannot listen to events when they are fired.
245          *
246          * @since 2.0
247          * @return                                        An error code
248          * @param[in]     listener                      The event listener to remove @n
249          *                                                   Listener should be referring to previously allocated instance which is passed as an argument to AddProgressPopupEventListener.
250          * @exception     E_SUCCESS                  This method was successful.
251          * @exception     E_OBJ_NOT_FOUND       The listener was not found.
252          */
253         result RemoveProgressPopupEventListener(Tizen::Ui::IProgressPopupEventListener& listener);
254
255         /**
256          * Sets the text color of the %ProgressPopup window.
257          *
258          * @since 2.0
259          * @param[in]                color     The text color
260          */
261         void SetTextColor(const Tizen::Graphics::Color& color);
262
263         /**
264          * Gets the text color of the %ProgressPopup window.
265          *
266          * @since 2.0
267          * @return                  The color, @n
268          *                              else RGBA(0, 0, 0, 0) if an error occurs
269          */
270         Tizen::Graphics::Color GetTextColor(void) const;
271
272 protected:
273         friend class _ProgressPopupImpl;
274
275 private:
276         //
277         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
278         //
279         ProgressPopup(const ProgressPopup& rhs);
280
281         //
282         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
283         //
284         ProgressPopup& operator =(const ProgressPopup& rhs);
285
286 };  // ProgressPopup
287
288
289 }}} // Tizen::Ui::Controls
290
291 #endif  // _FUI_CTRL_PROGRESS_POPUP_H_