Merge "Fix Ime Rotation" into tizen_2.1
[platform/framework/native/uifw.git] / inc / FUiCtrlMessageBox.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         FUiCtrlMessageBox.h
20 * @brief        This is the header file for the %MessageBox class.
21 *
22 * This header file contains the declarations of the %MessageBox class.
23 */
24
25 #ifndef _FUI_CTRL_MESSAGE_BOX_H_
26 #define _FUI_CTRL_MESSAGE_BOX_H_
27
28 #include <FUiWindow.h>
29
30 namespace Tizen { namespace Ui { namespace Controls
31 {
32
33 /**
34  * @enum        MessageBoxStyle
35  *
36  * Defines the %MessageBox style.
37  *
38  * @since       2.0
39  */
40 enum MessageBoxStyle
41 {
42         MSGBOX_STYLE_NONE,                      /**< The message box does not contain push buttons: NONE */
43         MSGBOX_STYLE_OK,                        /**< The message box contains one push button: OK */
44         MSGBOX_STYLE_CANCEL,                    /**< The message box contains one push button: CANCEL */
45         MSGBOX_STYLE_OKCANCEL,                  /**< The message box contains two push buttons: OK and CANCEL */
46         MSGBOX_STYLE_YESNO,                     /**< The message box contains two push buttons: YES and NO */
47         MSGBOX_STYLE_YESNOCANCEL,               /**< The message box contains three push buttons: YES, NO and CANCEL */
48         MSGBOX_STYLE_ABORTRETRYIGNORE,          /**< The message box contains three push buttons: ABORT, RETRY, and IGNORE */
49         MSGBOX_STYLE_CANCELTRYCONTINUE,         /**< The message box contains three push buttons: CANCEL, TRY, and CONTINUE */
50         MSGBOX_STYLE_RETRYCANCEL                /**< The message box contains two push buttons: RETRY and CANCEL */
51 };
52
53
54 /**
55  * @enum        MessageBoxModalResult
56  *
57  * Defines the %MessageBox notifications.
58  *
59  * @since       2.0
60  */
61 enum MessageBoxModalResult
62 {
63
64         MSGBOX_RESULT_CLOSE,                /**< The message box is closed */
65         MSGBOX_RESULT_OK,                   /**< The OK button is selected */
66         MSGBOX_RESULT_CANCEL,               /**< The cancel button is selected */
67         MSGBOX_RESULT_YES,                  /**< The Yes button is selected */
68         MSGBOX_RESULT_NO,                   /**< The No button is selected */
69         MSGBOX_RESULT_ABORT,                /**< The Abort button is selected */
70         MSGBOX_RESULT_TRY,                  /**< The Try button is selected */
71         MSGBOX_RESULT_RETRY,                /**< The Retry button is selected */
72         MSGBOX_RESULT_IGNORE,               /**< The Ignore button is selected */
73         MSGBOX_RESULT_CONTINUE,             /**< The Continue button is selected */
74 };
75
76
77 /**
78 * @class        MessageBox
79 * @brief        This class implements a message box.
80 *
81 * @since        2.0
82 *
83 * The %MessageBox class displays a confirmation message when the user is asked to confirm an action, or a warning message when the
84 * user wants to continue a potentially dangerous action. It can also display information, question, alarm, and lock messages, or
85 * the user selections.
86 *
87 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_popup_messagebox.htm">Popup and MessageBox</a>.
88 *
89 * The following example demonstrates how to use the %MessageBox class.
90 *
91 * @code
92 // Sample code for MessageBoxSample.h
93 #include <FUi.h>
94
95 class MessageBoxSample
96         : public Tizen::Ui::Controls::Form
97         , public Tizen::Ui::IActionEventListener
98 {
99 public:
100         bool Initialize(void);
101         void OpenMessageBox(void);
102         virtual result OnInitializing(void);
103         virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
104
105 protected:
106         static const int ID_BTN_DO_SOMETHING = 101;
107 };
108  *      @endcode
109  *
110  *      @code
111 // Sample code for MessageBoxSample.cpp
112 #include <FGraphics.h>
113
114 #include "MessageBoxSample.h"
115
116 using namespace Tizen::Graphics;
117 using namespace Tizen::Ui::Controls;
118
119 bool
120 MessageBoxSample::Initialize(void)
121 {
122         Construct(FORM_STYLE_NORMAL);
123         return true;
124 }
125
126 result
127 MessageBoxSample::OnInitializing(void)
128 {
129         result r = E_SUCCESS;
130
131         // Creates an instance of Button
132         Button* pButton = new Button();
133         pButton->Construct(Rectangle(10, 10, 350, 60), L"MessageBox Test");
134         pButton->SetActionId(ID_BTN_DO_SOMETHING);
135         pButton->AddActionEventListener(*this);
136
137         // Adds the button to the form
138         AddControl(*pButton);
139
140         return r;
141 }
142
143 void
144 MessageBoxSample::OpenMessageBox(void)
145 {
146         // Creates an instance of MessageBox
147         MessageBox messageBox;
148         messageBox.Construct(L"MessageBox Title", L"MessageBox Sample Code.", MSGBOX_STYLE_OK, 3000);
149
150         int modalResult = 0;
151
152         // Calls ShowAndWait() : Draws and Shows itself and processes events
153         messageBox.ShowAndWait(modalResult);
154
155         switch (modalResult)
156         {
157         case MSGBOX_RESULT_OK:
158                 {
159                         // ....
160                 }
161                 break;
162         default:
163                 break;
164         }
165 }
166
167 void
168 MessageBoxSample::OnActionPerformed(const Control& source, int actionId)
169 {
170         switch (actionId)
171         {
172         case ID_BTN_DO_SOMETHING:
173                 {
174                         OpenMessageBox();
175                 }
176                 break;
177         default:
178                 break;
179         }
180 }
181 * @endcode
182 */
183
184 class _OSP_EXPORT_ MessageBox
185         : public Tizen::Ui::Window
186 {
187 public:
188         /**
189          * 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.
190          *
191          * @since       2.0
192          */
193         MessageBox(void);
194
195         /**
196          * This destructor overrides Tizen::Base::Object::~Object().
197          *
198          * @since       2.0
199          */
200         virtual ~MessageBox(void);
201
202         /**
203          * Initializes this instance of %MessageBox with the specified parameters.
204          *
205          * @since               2.0
206          *
207          * @return              An error code
208          * @param[in]   title                           The title string to set
209          * @param[in]   text                            The text string to set
210          * @param[in]   style                           The style of the %MessageBox control
211          * @param[in]   timeout                         The duration of the timeout in milliseconds
212          * @exception   E_SUCCESS                       The method is successful.
213          * @exception   E_SYSTEM                        A system error has occurred.
214          * @exception   E_INVALID_ARG           The specified @c text is too long.
215          * @remarks             To create a %MessageBox control, call ShowAndWait() after the Construct() method is called. @n
216          *                              The message box text cannot contain over @c 399 characters. @n
217          *                              To display the text in multi-lines or to denote the end of line use '\\n'.
218          * @see                 ShowAndWait()
219          */
220         result Construct(const Tizen::Base::String& title, const Tizen::Base::String& text, MessageBoxStyle style, unsigned long timeout = 0);
221
222 public:
223         /**
224          * Runs the modal window. @n
225          * This method should be called only after calling the Construct() method.
226          *
227          * @since               2.0
228          *
229          * @return              An error code
230          * @param[out]  modalResult             The %MessageBox notification
231          * @exception   E_SUCCESS           The method is successful.
232          * @exception   E_SYSTEM            A system error has occurred.
233          */
234         virtual result ShowAndWait(int& modalResult);
235
236         /**
237          * Gets the text of the %MessageBox control.
238          *
239          * @since               2.0
240          *
241          * @return              The text of this %MessageBox instance, @n
242          *                              else an empty string if the instance is invalid
243          */
244         Tizen::Base::String GetText(void) const;
245
246         /**
247          * Gets the title of the %MessageBox control.
248          *
249          * @since               2.0
250          *
251          * @return              The title of this %MessageBox instance, @n
252          *                              else an empty string if the instance is invalid
253          */
254         Tizen::Base::String GetTitleText(void) const;
255
256         /**
257          * Gets the style of the current %MessageBox.
258          *
259          * @since               2.0
260          *
261          * @return              The style of the current %MessageBox, @n
262          *                              else @c MSGBOX_STYLE_NONE if the instance is invalid
263          */
264         MessageBoxStyle GetMessageBoxStyle(void) const;
265
266         /**
267          * Gets the timeout value of %MessageBox.
268          *
269          * @since               2.0
270          *
271          * @return              The timeout value in milliseconds, @n
272          *                              else @c 0 if the instance is invalid
273          */
274         virtual unsigned long GetTimeout(void) const;
275
276         /**
277          * Sets the color of the %MessageBox control.
278          *
279          * @since 2.0
280          *
281          * @param[in]   color           The color to set
282          */
283         void SetColor(const Tizen::Graphics::Color& color);
284
285         /**
286          * Gets the color of the %MessageBox control.
287          *
288          * @since 2.0
289          *
290          * @return      The color to set
291          */
292         Tizen::Graphics::Color GetColor(void) const;
293
294         /**
295          * Sets the title text color of the %MessageBox control.
296          *
297          * @since 2.0
298          *
299          * @param[in]   color           The title text color to set
300          */
301         void SetTitleTextColor(const Tizen::Graphics::Color& color);
302
303         /**
304          * Gets the title text color of the %MessageBox control.
305          *
306          * @since 2.0
307          *
308          * @return              The title text color
309          */
310         Tizen::Graphics::Color GetTitleTextColor(void) const;
311
312         /**
313          * Sets the text color of the %MessageBox control.
314          *
315          * @since 2.0
316          *
317          * @param[in]   color           The text color to set
318          */
319         void SetTextColor(const Tizen::Graphics::Color& color);
320
321         /**
322          * Gets the text color of the %MessageBox control.
323          *
324          * @since 2.0
325          *
326          * @return              The text color
327          */
328         Tizen::Graphics::Color GetTextColor(void) const;
329
330 protected:
331         friend class _MessageBoxImpl;
332
333 private:
334         //
335         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
336         //
337         MessageBox(const MessageBox& rhs);
338
339         //
340         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
341         //
342         MessageBox& operator =(const MessageBox& rhs);
343
344 };  // MessageBox
345
346
347 }}} // Tizen::Ui::Controls
348
349 #endif  // _FUI_CTRL_MESSAGE_BOX_H_