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 FUiCtrlPopup.h
20 * @brief This is the header file for the %Popup class.
22 * This header file contains the declarations of the %Popup class.
25 #ifndef _FUI_CTRL_POPUP_H_
26 #define _FUI_CTRL_POPUP_H_
28 #include <FUiWindow.h>
30 namespace Tizen { namespace Ui
32 class DataBindingContext;
36 namespace Tizen { namespace Ui { namespace Controls
41 * @brief This class displays a popup on the top of the screen.
45 * The %Popup class displays messages to alert the user of important changes, to request confirmation for a significant task, or to
46 * serve as a warning. It is an implementation of the Window class.
48 * 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>.
50 * @see Tizen::Ui::Window
52 * The following example demonstrates how to use the %Popup class.
55 // Sample code for PopupSample.h
59 : public Tizen::Ui::Controls::Form
60 , public Tizen::Ui::IActionEventListener
66 bool Initialize(void);
69 virtual result OnInitializing(void);
70 virtual result OnTerminating(void);
71 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
74 static const int ID_BUTTON_OPEN_POPUP = 501;
75 static const int ID_BUTTON_CLOSE_POPUP = 502;
77 Tizen::Ui::Controls::Popup* __pPopup;
82 // Sample code for PopupSample.cpp
83 #include <FGraphics.h>
85 #include "PopupSample.h"
87 using namespace Tizen::Graphics;
88 using namespace Tizen::Ui::Controls;
91 PopupSample::Initialize(void)
93 Construct(FORM_STYLE_NORMAL);
98 PopupSample::OnInitializing(void)
100 result r = E_SUCCESS;
102 // Creates an instance of Popup
103 __pPopup = new Popup();
104 __pPopup->Construct(true, Dimension(600,800));
105 __pPopup->SetTitleText(L"Popup Sample");
107 // Creates an instance of Button to close the popup.
108 Button* pCloseButton = new Button();
109 pCloseButton->Construct(Rectangle(10, 10, 250, 80), L"Close Popup");
110 pCloseButton->SetActionId(ID_BUTTON_CLOSE_POPUP);
111 pCloseButton->AddActionEventListener(*this);
113 // Adds the button to the popup
114 __pPopup->AddControl(*pCloseButton);
116 // Creates an instance of Button to open the popup.
117 Button* pOpenButton = new Button();
118 pOpenButton->Construct(Rectangle(10, 10, 250, 60), L"Open Popup");
119 pOpenButton->SetActionId(ID_BUTTON_OPEN_POPUP);
120 pOpenButton->AddActionEventListener(*this);
122 // Adds the button to the form
123 AddControl(*pOpenButton);
129 PopupSample::ShowPopup(void)
131 __pPopup->SetShowState(true);
136 PopupSample::HidePopup(void)
138 __pPopup->SetShowState(false);
143 PopupSample::OnTerminating(void)
145 result r = E_SUCCESS;
147 // Deallocates the __pPopup
154 PopupSample::OnActionPerformed(const Control& source, int actionId)
158 case ID_BUTTON_OPEN_POPUP:
163 case ID_BUTTON_CLOSE_POPUP:
175 class _OSP_EXPORT_ Popup
176 : public Tizen::Ui::Window
180 * 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.
187 * This destructor overrides Tizen::Base::Object::~Object().
191 virtual ~Popup(void);
194 * Initializes this instance of %Popup with the specified dimensions.
198 * @return An error code
199 * @param[in] hasTitle Set to @c true if the %Popup control has a title, @n
201 * @param[in] dim The size of the %Popup control
202 * @exception E_SUCCESS The method is successful.
203 * @exception E_INVALID_ARG A specified input parameter is invalid.
204 * @exception E_SYSTEM A system error has occurred.
206 result Construct(bool hasTitle, const Tizen::Graphics::Dimension& dim);
209 * Initializes this instance of %Popup and child controls with the specified resource ID @n
211 * This method first attempts to find the resource file in the folder that corresponds to the current screen resolution. @n
212 * If it fails to find the resource file, it searches in other folders in the following order when CoordinateSystem is Logical in the application manifest file @n
213 * the density folder that corresponds to the current screen size category "res/screen-size-normal/" folder.
217 * @return An error code
218 * @param[in] resourceId The resource ID describing the %Popup control
219 * @exception E_SUCCESS The method is successful.
220 * @exception E_FILE_NOT_FOUND The specified file cannot be found.
221 * @exception E_INVALID_FORMAT The specified XML format is invalid.
222 * @exception E_OPERATION_FAILED The operation has failed.
224 result Construct(const Tizen::Base::String& resourceId);
227 * Initializes this instance of %Popup with the specified layout and dimensions.
231 * @return An error code
232 * @param[in] layout The layout for both the portrait and landscape mode
233 * @param[in] hasTitle Set to @c true if the %Popup control should have a title, @n
235 * @param[in] dim The size of the %Popup control
236 * @exception E_SUCCESS The method is successful.
237 * @exception E_INVALID_ARG A specified input parameter is invalid, or
238 * the specified layout is already bound to another container.
239 * @exception E_SYSTEM A system error has occurred.
241 result Construct(const Tizen::Ui::Layout& layout, bool hasTitle, const Tizen::Graphics::Dimension& dim);
244 * Initializes this instance of %Popup with the specified layouts and dimensions.
248 * @return An error code
249 * @param[in] portraitLayout The layout for the portrait mode
250 * @param[in] landscapeLayout The layout for the landscape mode
251 * @param[in] hasTitle Set to @c true if this %Popup control should have a title, @n
253 * @param[in] dim The size of the %Popup control
254 * @exception E_SUCCESS The method is successful.
255 * @exception E_INVALID_ARG A specified input parameter is invalid, or
256 * the specified layout is already bound to another container.
257 * @exception E_SYSTEM A system error has occurred.
259 result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, bool hasTitle, const Tizen::Graphics::Dimension& dim);
262 * Shows the modal window. @n
265 * @return An error code
266 * @param[out] modalResult The %Popup's notification. @n
267 * This value is the 'modalResult' parameter of the EndModal() method
268 * @exception E_SUCCESS The method is successful.
269 * @exception E_INVALID_STATE The %Popup is not visible. The visible state of the %Popup should be set @c true.
270 * @remarks Do not call this method from Tizen::App::App::OnAppInitializing(). @n
271 * To show a %Popup properly from Tizen::Ui::Controls::Form::OnInitializing(), theForm must
272 * have been successfully drawn before the DoModal() method.
274 result DoModal(int& modalResult);
277 * Closes the modal window. @n
280 * @return An error code
281 * @param[in] modalResult The result value of the modal window. @n
282 * The value which needs to be returned as the output parameter of DoModal() method should be passed as the input argument
283 * @exception E_SUCCESS The method is successful.
284 * @exception E_INVALID_STATE The method is not supported because this popup isn't running as a modal window.
286 result EndModal(int modalResult);
289 * Sets the title of the %Popup control.
293 * @return An error code
294 * @param[in] title The title to be set
295 * @exception E_SUCCESS The method is successful.
296 * @exception E_SYSTEM A system error has occurred.
298 virtual result SetTitleText(const Tizen::Base::String& title);
301 * Gets the title of the %Popup control.
305 * @return The title of the %Popup control
307 Tizen::Base::String GetTitleText(void) const;
310 * Gets the bounds of the client area.
314 * @return The bounds of the client area in a Rectangle instance
316 Tizen::Graphics::Rectangle GetClientAreaBounds(void) const;
319 * Creates and returns a graphics canvas whose bounds (position and size) are equal to the bounds of the client area of the %Popup control.
323 * @return The graphic canvas of the %Popup control, @n
324 * else @c null if an error occurs
325 * @exception E_SUCCESS The method is successful.
326 * @exception E_RESOURCE_UNAVAILABLE The required resource is currently unavailable.
327 * @remarks The method allocates a Tizen::Graphics::Canvas whose bounds are equal to that of the client area of the %Popup control. @n
328 * It is the responsibility of the developers to deallocate the canvas after use.
329 * @remarks The canvas is valid only if the properties of the parent control of the canvas remain unchanged. @n
330 * Therefore, delete the previously allocated canvas and create a new canvas using the GetCanvasN() method if the size or position of the
331 * control is changed.
332 * @remarks The specific error code can be accessed using the GetLastResult() method.
334 Tizen::Graphics::Canvas* GetClientAreaCanvasN(void) const;
337 * Translates the specified position to the client coordinates.
341 * @return The position in relative to the top-left corner of the client-area, @n
342 * else @c (-1,-1) if the instance is invalid
343 * @param[in] position The position relative to the top-left corner of the %Popup control
344 * @see TranslateFromClientAreaPosition()
346 Tizen::Graphics::Point TranslateToClientAreaPosition(const Tizen::Graphics::Point& position) const;
349 * Translates the specified client position to the control coordinate.
353 * @return The position in relative to the top-left corner of the %Popup control, @n
354 * else @c (-1,-1) if the instance is invalid
355 * @param[in] clientPosition The position relative to the top-left corner of the client area
356 * @see TranslateToClientAreaPosition()
358 Tizen::Graphics::Point TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition) const;
361 * Gets the color of the %Popup control.
365 * @return The color, @n
366 * else RGBA(0, 0, 0, 0) if an error occurs
367 * @exception E_SUCCESS The method is successful.
368 * @remarks The specific error code can be accessed using the GetLastResult() method.
370 Tizen::Graphics::Color GetColor(void) const;
373 * Sets the color of the %Popup control.
377 * @return An error code
378 * @param[in] color The color to be set
379 * @exception E_SUCCESS The method is successful.
380 * @exception E_SYSTEM A system error has occurred.
382 result SetColor(const Tizen::Graphics::Color& color);
385 * Gets the title text color of the %Popup control.
389 * @return The color, @n
390 * else RGBA(0, 0, 0, 0) if an error occurs
391 * @exception E_SUCCESS The method is successful.
392 * @remarks The specific error code can be accessed using the GetLastResult() method.
394 Tizen::Graphics::Color GetTitleTextColor(void) const;
397 * Sets the title text color of the %Popup control.
401 * @return An error code
402 * @param[in] color The title text color
403 * @exception E_SUCCESS The method is successful.
404 * @exception E_SYSTEM A system error has occurred.
406 result SetTitleTextColor(const Tizen::Graphics::Color& color);
409 * Gets the data binding context.
413 * @return The data binding context
414 * @exception E_SUCCESS The method is successful.
415 * @exception E_SYSTEM A system error has occurred.
416 * @remarks The specific error code can be accessed using the GetLastResult() method.
418 DataBindingContext* GetDataBindingContextN(void) const;
421 friend class _PopupImpl;
424 // The following methods are reserved and may change its name at any time without
427 virtual void Popup_Reserved1(void) { }
428 virtual void Popup_Reserved2(void) { }
429 virtual void Popup_Reserved3(void) { }
433 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
435 Popup(const Popup& rhs);
438 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
440 Popup& operator =(const Popup& rhs);
445 }}} // Tizen::Ui::Controls
447 #endif //_FUI_CTRL_POPUP_H_