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