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