2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FUiCtrlMessageBox.h
20 * @brief This is the header file for the %MessageBox class.
22 * This header file contains the declarations of the %MessageBox class.
25 #ifndef _FUI_CTRL_MESSAGE_BOX_H_
26 #define _FUI_CTRL_MESSAGE_BOX_H_
28 #include <FUiWindow.h>
30 namespace Tizen { namespace Ui { namespace Controls
34 * @enum MessageBoxStyle
36 * Defines the %MessageBox style.
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 */
55 * @enum MessageBoxModalResult
57 * Defines the %MessageBox notifications.
61 enum MessageBoxModalResult
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 */
79 * @brief This class implements a message box.
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.
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>.
89 * The following example demonstrates how to use the %MessageBox class.
92 // Sample code for MessageBoxSample.h
95 class MessageBoxSample
96 : public Tizen::Ui::Controls::Form
97 , public Tizen::Ui::IActionEventListener
100 bool Initialize(void);
101 void OpenMessageBox(void);
102 virtual result OnInitializing(void);
103 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
106 static const int ID_BTN_DO_SOMETHING = 101;
111 // Sample code for MessageBoxSample.cpp
112 #include <FGraphics.h>
114 #include "MessageBoxSample.h"
116 using namespace Tizen::Graphics;
117 using namespace Tizen::Ui::Controls;
120 MessageBoxSample::Initialize(void)
122 Construct(FORM_STYLE_NORMAL);
127 MessageBoxSample::OnInitializing(void)
129 result r = E_SUCCESS;
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);
137 // Adds the button to the form
138 AddControl(*pButton);
144 MessageBoxSample::OpenMessageBox(void)
146 // Creates an instance of MessageBox
147 MessageBox messageBox;
148 messageBox.Construct(L"MessageBox Title", L"MessageBox Sample Code.", MSGBOX_STYLE_OK, 3000);
152 // Calls ShowAndWait() : Draws and Shows itself and processes events
153 messageBox.ShowAndWait(modalResult);
157 case MSGBOX_RESULT_OK:
168 MessageBoxSample::OnActionPerformed(const Control& source, int actionId)
172 case ID_BTN_DO_SOMETHING:
184 class _OSP_EXPORT_ MessageBox
185 : public Tizen::Ui::Window
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.
196 * This destructor overrides Tizen::Base::Object::~Object().
200 virtual ~MessageBox(void);
203 * Initializes this instance of %MessageBox with the specified parameters.
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'.
220 result Construct(const Tizen::Base::String& title, const Tizen::Base::String& text, MessageBoxStyle style, unsigned long timeout = 0);
224 * Runs the modal window. @n
225 * This method should be called only after calling the Construct() method.
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.
234 virtual result ShowAndWait(int& modalResult);
237 * Gets the text of the %MessageBox control.
241 * @return The text of this %MessageBox instance, @n
242 * else an empty string if the instance is invalid
244 Tizen::Base::String GetText(void) const;
247 * Gets the title of the %MessageBox control.
251 * @return The title of this %MessageBox instance, @n
252 * else an empty string if the instance is invalid
254 Tizen::Base::String GetTitleText(void) const;
257 * Gets the style of the current %MessageBox.
261 * @return The style of the current %MessageBox, @n
262 * else @c MSGBOX_STYLE_NONE if the instance is invalid
264 MessageBoxStyle GetMessageBoxStyle(void) const;
267 * Gets the timeout value of %MessageBox.
271 * @return The timeout value in milliseconds, @n
272 * else @c 0 if the instance is invalid
274 virtual unsigned long GetTimeout(void) const;
277 * Sets the color of the %MessageBox control.
281 * @param[in] color The color to set
283 void SetColor(const Tizen::Graphics::Color& color);
286 * Gets the color of the %MessageBox control.
290 * @return The color to set
292 Tizen::Graphics::Color GetColor(void) const;
295 * Sets the title text color of the %MessageBox control.
299 * @param[in] color The title text color to set
301 void SetTitleTextColor(const Tizen::Graphics::Color& color);
304 * Gets the title text color of the %MessageBox control.
308 * @return The title text color
310 Tizen::Graphics::Color GetTitleTextColor(void) const;
313 * Sets the text color of the %MessageBox control.
317 * @param[in] color The text color to set
319 void SetTextColor(const Tizen::Graphics::Color& color);
322 * Gets the text color of the %MessageBox control.
326 * @return The text color
328 Tizen::Graphics::Color GetTextColor(void) const;
331 friend class _MessageBoxImpl;
335 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
337 MessageBox(const MessageBox& rhs);
340 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
342 MessageBox& operator =(const MessageBox& rhs);
347 }}} // Tizen::Ui::Controls
349 #endif // _FUI_CTRL_MESSAGE_BOX_H_