2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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,
88 * see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_popup_messagebox.htm">Popup and MessageBox</a>.
90 * The following example demonstrates how to use the %MessageBox class.
93 // Sample code for MessageBoxSample.h
96 class MessageBoxSample
97 : public Tizen::Ui::Controls::Form
98 , public Tizen::Ui::IActionEventListener
101 bool Initialize(void);
102 void OpenMessageBox(void);
103 virtual result OnInitializing(void);
104 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
107 static const int ID_BTN_DO_SOMETHING = 101;
112 // Sample code for MessageBoxSample.cpp
113 #include <FGraphics.h>
115 #include "MessageBoxSample.h"
117 using namespace Tizen::Graphics;
118 using namespace Tizen::Ui::Controls;
121 MessageBoxSample::Initialize(void)
123 Construct(FORM_STYLE_NORMAL);
128 MessageBoxSample::OnInitializing(void)
130 result r = E_SUCCESS;
132 // Creates an instance of Button
133 Button* pButton = new Button();
134 pButton->Construct(Rectangle(10, 10, 350, 60), L"MessageBox Test");
135 pButton->SetActionId(ID_BTN_DO_SOMETHING);
136 pButton->AddActionEventListener(*this);
138 // Adds the button to the form
145 MessageBoxSample::OpenMessageBox(void)
147 // Creates an instance of MessageBox
148 MessageBox messageBox;
149 messageBox.Construct(L"MessageBox Title", L"MessageBox Sample Code.", MSGBOX_STYLE_OK, 3000);
153 // Calls ShowAndWait() : Draws and Shows itself and processes events
154 messageBox.ShowAndWait(modalResult);
158 case MSGBOX_RESULT_OK:
169 MessageBoxSample::OnActionPerformed(const Control& source, int actionId)
173 case ID_BTN_DO_SOMETHING:
185 class _OSP_EXPORT_ MessageBox
186 : public Tizen::Ui::Window
190 * The object is not fully constructed after this constructor is called. @n
191 * For full construction, the MessageBox::Construct() method must be called right after calling this constructor.
198 * This destructor overrides Tizen::Base::Object::~Object().
202 virtual ~MessageBox(void);
205 * Initializes this instance of %MessageBox with the specified parameters.
209 * @return An error code
210 * @param[in] title The title string to set
211 * @param[in] text The text string to set
212 * @param[in] style The style of the %MessageBox control
213 * @param[in] timeout The duration of the timeout in milliseconds
214 * @exception E_SUCCESS The method is successful.
215 * @exception E_SYSTEM A system error has occurred.
216 * @exception E_INVALID_ARG The specified @c text is too long.
218 * - To create a %MessageBox control, call ShowAndWait() after the Construct() method is called.
219 * - The message box text cannot contain over @c 399 characters.
220 * - To display the text in multi-lines or to denote the end of line use '\\n'.
221 * - The default owner will be the current Form (or Frame). It is possible that this control may not be visible
222 * due to this ownership relationship. @n In this case, use the SetOwner() method to change the ownership to the top-most window.
225 result Construct(const Tizen::Base::String& title, const Tizen::Base::String& text, MessageBoxStyle style, unsigned long timeout = 0);
229 * Runs the modal window. @n
230 * This method should be called only after calling the Construct() method.
234 * @return An error code
235 * @param[out] modalResult The %MessageBox notification
236 * @exception E_SUCCESS The method is successful.
237 * @exception E_SYSTEM A system error has occurred.
239 virtual result ShowAndWait(int& modalResult);
242 * Gets the text of the %MessageBox control.
246 * @return The text of this %MessageBox instance, @n
247 * else an empty string if the instance is invalid
249 Tizen::Base::String GetText(void) const;
252 * Gets the title of the %MessageBox control.
256 * @return The title of this %MessageBox instance, @n
257 * else an empty string if the instance is invalid
259 Tizen::Base::String GetTitleText(void) const;
262 * Gets the style of the current %MessageBox.
266 * @return The style of the current %MessageBox, @n
267 * else @c MSGBOX_STYLE_NONE if the instance is invalid
269 MessageBoxStyle GetMessageBoxStyle(void) const;
272 * Gets the timeout value of %MessageBox.
276 * @return The timeout value in milliseconds, @n
277 * else @c 0 if the instance is invalid
279 virtual unsigned long GetTimeout(void) const;
282 * Sets the color of the %MessageBox control.
286 * @param[in] color The color to set
288 void SetColor(const Tizen::Graphics::Color& color);
291 * Gets the color of the %MessageBox control.
295 * @return The color to set
297 Tizen::Graphics::Color GetColor(void) const;
300 * Sets the title text color of the %MessageBox control.
304 * @param[in] color The title text color to set
306 void SetTitleTextColor(const Tizen::Graphics::Color& color);
309 * Gets the title text color of the %MessageBox control.
313 * @return The title text color
315 Tizen::Graphics::Color GetTitleTextColor(void) const;
318 * Sets the text color of the %MessageBox control.
322 * @param[in] color The text color to set
324 void SetTextColor(const Tizen::Graphics::Color& color);
327 * Gets the text color of the %MessageBox control.
331 * @return The text color
333 Tizen::Graphics::Color GetTextColor(void) const;
336 friend class _MessageBoxImpl;
340 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
342 MessageBox(const MessageBox& rhs);
345 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
347 MessageBox& operator =(const MessageBox& rhs);
352 }}} // Tizen::Ui::Controls
354 #endif // _FUI_CTRL_MESSAGE_BOX_H_