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