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 FUiContainer.h
20 * @brief This is the header file for the %Container class.
22 * This header file contains the declarations of the %Container class.
25 #ifndef _FUI_CONTAINER_H_
26 #define _FUI_CONTAINER_H_
28 #include <FBaseTypes.h>
29 #include <FBaseColLinkedList.h>
30 #include <FUiControl.h>
32 namespace Tizen { namespace Ui {
39 * @brief This class is an abstract base class of all the generic containers of Controls.
43 * @remarks As the %Container is an abstract class, use the Tizen::Ui::Controls::Panel class or another class derived from
44 * %Container to apply the container functionality.
46 * The %Container class is the abstract base class of all generic Control containers. A container is a UI element which can contain
49 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/containers.htm">Containers</a>.
54 class _OSP_EXPORT_ Container
60 * This destructor overrides Tizen::Base::Object::~Object().
64 virtual ~Container(void) = 0;
68 * Adds the control at the end of the list maintained by the container.
72 * @return An error code
73 * @param[in] control The control to be added to the container
74 * @exception E_SUCCESS The method is successful.
75 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
76 * The specified @c control is an instance of Window, or this control's parent container.
77 * @exception E_MAX_EXCEEDED The number of child controls has exceeded the maximum limit.
78 * @exception E_SYSTEM A system error has occurred.
79 * @remarks When the control is added, it is placed at the top of the drawing stack maintained by the container.@n
80 * This means the last control added is drawn last
81 * @remarks A control becomes displayable only after it has been added to a displayable container. Some methods may not work normally if the methods
82 * of the control are called before adding the control to a container. After the control is added to a %Container, the OnInitializing()
83 * method of the control are called before adding the control to a container. After the control is added to a %Container, the
84 * OnInitializing() method of the control is invoked for the initialization of the control such as creating and adding child controls.
85 * @see Tizen::Ui::Control::OnInitializing()
86 * @see Tizen::Ui::Control::OnTerminating()
89 * // Uses Panel instead of Container, because Container is an abstract class.
90 * Panel* pPanel = new Panel();
91 * pPanel->Construct(Rectangle(100, 250, 300, 300));
93 * Form* pForm = new Form();
94 * pForm->Construct(FORM_STYLE_NORMAL|FORM_STYLE_TITLE|FORM_STYLE_INDICATOR);
95 * pForm->AddControl(*pPanel);
98 * pForm->Invalidate(true);
103 result AddControl(const Control& control);
106 * Before the system calls OnDraw() method to allow the user to do custom drawing, this method is called to clear the canvas. The user can override this method to change this default behavior.
112 virtual void OnClearBackground(void);
115 * Called when the container needs to draw itself. @n
116 * Users can override this method to display user-specific drawings. @n
117 * This method is called after the container has drawn itself, but just before the container draws its child controls.
120 * @brief <i> [Compatibility] </i>
125 * @compatibility This method has compatibility issues with OSP compatible applications. @n
126 * For more information, see @ref CompOnDrawPage "here".
129 * @return An error code
130 * @exception E_SUCCESS The method is successful.
131 * @exception E_SYSTEM A system error has occurred.
133 virtual result OnDraw(void);
137 * @page CompOnDrawPage Compatibility for OnDraw()
138 * @section CompOnDrawPage IssueSection Issues
139 * Implementing this method in OSP compatible applications has the following issues: @n
140 * -# The platform draws the control by calling the parent's OnDraw() callback before invoking the control's OnDraw() callback. So, the users can't control the control's drawing behavior by overriding the OnDraw() callback.
142 * @section CompOnDrawPage SolutionSection Resolutions
143 * This issue has been resolved in Tizen. @n
144 * -# The platform does not call the parent's OnDraw() callback before invoking the control's OnDraw() callback. Therefore, you needs to call the parent container's OnDraw() callback in the OnDraw() callback if you override this method.
149 * Called to notify that the control's show state is changing.
153 * @param[in] showState The new show state of the control
154 * @see Osp::Ui::Control::SetShowState()
156 virtual void OnShowStateChanging(bool showState);
159 * Called to notify that the control's show state is changed.
163 * @param[in] showState The new show state of the control
164 * @see Tizen::Ui::Control::SetShowState()
166 virtual void OnShowStateChanged(bool showState);
169 * Called to notify that the bounds of the control is changing.
173 * @return An error code
174 * @param[in] oldRect The old position and size values of the control
175 * @param[in] newRect The new position and size values of the control
176 * @remarks If the method returns an exception, the resulting exception
177 * is propagated and the control's size is unchanged.@n
178 * Provide control specific exceptions.
179 * @see Tizen::Ui::Control::SetBounds()
180 * @see Tizen::Ui::Control::SetSize()
182 virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect);
185 * Called to notify that the bounds of the control is changed.
189 * @return An error code
190 * @param[in] oldRect The old position and size values of the control
191 * @param[in] newRect The new position and size values of the control
192 * @see Tizen::Ui::Control::SetBounds()
193 * @see Tizen::Ui::Control::SetSize()
195 virtual void OnBoundsChanged(const Tizen::Graphics::Rectangle& oldRect, const Tizen::Graphics::Rectangle& newRect);
198 * Overrides this method to indicate that the specified @c width and @c height
199 * can be supported or a new @c width and @c height should be applied instead
200 * of the specified values.
204 * @return A Boolean flag that indicates whether the specified @c width
205 * and @ height are supported.
206 * @param[in, out] evaluatedSize The width and the height that need to be evaluated.
208 virtual void OnEvaluateSize(Tizen::Graphics::Dimension& evaluatedSize);
211 * Removes the specified control from the container.
215 * @return An error code
216 * @param[in] control The child control to be removed
217 * @exception E_SUCCESS The method is successful.
218 * @exception E_OBJ_NOT_FOUND The specified instance is not found within the indicated range (that is, the @c control is not found).
219 * @exception E_SYSTEM A system error has occurred.
220 * @remarks The removed child control is deleted from the memory. Before deletion, OnTerminating() of the child control is called.
221 * @see Tizen::Ui::Control::OnTerminating()
223 result RemoveControl(const Control& control);
226 * Removes the specified control from the container.
230 * @return An error code
231 * @param[in] index The index of the control to be removed
232 * @exception E_SUCCESS The method is successful.
233 * @exception E_OUT_OF_RANGE The specified @c index is out of range.
234 * @exception E_SYSTEM A system error has occurred.
235 * @remarks The removed child control is deleted from the memory. Before deletion, OnTerminating() of the child control is called.
236 * @see Tizen::Ui::Control::OnTerminating()
238 result RemoveControl(int index);
241 * Removes all the controls from the container.
245 * @remarks The removed child controls are deleted from the memory. Before deletion, OnTerminating() of the child control is called.
246 * @see Tizen::Ui::Control::OnTerminating()
248 void RemoveAllControls(void);
251 * Gets the control at the specified index of the list that is kept by the container.
255 * @return The control at the specified index of the list, @n
256 * else @c null if the index is not valid
257 * @param[in] index The index of the control
259 Control* GetControl(int index) const;
262 * Gets the control with the specified name. @n
263 * If there are multiple matches of the name, the first match is returned.
266 * @brief <i> [Compatibility] </i>
271 * @compatibility This method has compatibility issues with OSP compatible applications. @n
272 * For more information, see @ref CompGetControlPage "here".
275 * @return The control having the specified name, @n
276 * else @c null if the name is not valid
277 * @param[in] name The name of the control
278 * @param[in] recursive Set to @c true to find a match recursively, @n
281 Control* GetControl(const Tizen::Base::String& name, bool recursive = false) const;
285 * @page CompGetControlPage Compatibility for GetControl()
286 * @section CompGetControlPage IssueSection Issues
287 * Implementing this method in OSP compatible applications has the following issues: @n
288 * -# GetControl() method searches for itself first and then child controls in OSP, whereas only @n
289 * child controls are searched for from Tizen.
291 * @section CompGetControlPage SolutionSection Resolutions
292 * This issue has been resolved in Tizen. @n
297 * Gets the number of the controls in the container.
301 * @return The number of controls in the container
303 int GetControlCount(void) const;
306 * Gets a list of the controls of the container.
310 * @return The list of the controls of the container
312 Tizen::Base::Collection::IList* GetControls(void) const;
315 * Gets the portrait layout of the container.
319 * @return The portrait layout of the container, @n
320 * else @c null if the layout does not exist
321 * @exception E_SUCCESS The method is successful.
322 * @exception E_OUT_OF_MEMORY The memory is insufficient.
323 * @remarks The returned layout can be @c null, if it is not set.
325 Layout* GetPortraitLayoutN(void) const;
328 * Gets the landscape layout of the container.
332 * @return The landscape layout of the container, @n
333 * else @c null if the layout does not exist
334 * @exception E_SUCCESS The method is successful.
335 * @exception E_OUT_OF_MEMORY The memory is insufficient.
336 * @remarks The returned layout can be @c null, if it is not set.
338 Layout* GetLandscapeLayoutN(void) const;
341 * Gets the layout of the current orientation.
345 * @return The layout of the current orientation, @n
346 * else @c null if the layout does not exist
347 * @exception E_SUCCESS The method is successful.
348 * @exception E_OUT_OF_MEMORY The memory is insufficient.
349 * @remarks The returned layout can be @c null, if it is not set.
351 Layout* GetLayoutN(void) const;
354 * Checks whether the specified control is a child or descendant of the container.
358 * @return @c true if the specified control is within the containment hierarchy of the container, @n
360 * @param[in] control The control
362 bool IsAncestorOf(const Control& control) const;
365 * Sets whether the specified child control must always be above other children.
369 * @return An error code
370 * @param[in] control The child control
371 * @param[in] alwaysOnTop The Boolean value indicating that @c control
372 * must always be on the top
373 * @exception E_SUCCESS The method is successful.
374 * @exception E_INVALID_ARG A specified input parameter is invalid.@n
375 * The specified control is not a child of this
377 * @remarks If multiple child control are set as "always on top", then
378 * their relative order is not specified. If the specified child
379 * control is a container, then all its children inherit this
380 * property and they are "always on top" of other controls.@n
381 * If the method is called on a child control with a @c false
382 * value, then it's state becomes normal. The relative order
383 * of child controls in normal state is not specified.
384 * @see IsControlAlwaysOnTop()
386 result SetControlAlwaysOnTop(Tizen::Ui::Control& control, bool alwaysOnTop);
389 * Sets whether the specified child control must always be below other children.
393 * @return An error code
394 * @param[in] control The child control
395 * @param[in] alwaysAtBottom The Boolean value indicating that @c control
396 * must always be at the bottom.
397 * @exception E_SUCCESS The method is successful.
398 * @exception E_INVALID_ARG A specified input parameter is invalid.@n
399 * The specified control is not a child of this
401 * @remarks If multiple child control are set as "always at bottom", then
402 * their relative order is not specified. If the specified child
403 * control is a container, then all its children inherit this
404 * property and they become "always at bottom" as well.@n
405 * If the method is called on a child control with a @c false
406 * value, then it's state becomes normal. The relative order
407 * of child controls in normal state is not specified.
408 * @see IsControlAlwaysAtBottom()
410 result SetControlAlwaysAtBottom(Tizen::Ui::Control& control, bool alwaysAtBottom);
413 * Checks whether the specified child control is always at the bottom of
418 * @return @c true if the specified child control is set as always at the bottom, @n
420 * @param[in] control The child control
421 * @exception E_SUCCESS The method is successful.
422 * @exception E_INVALID_ARG A specified input parameter is invalid.@n
423 * The specified control is not a child of this
425 * @remarks The specific error code can be accessed using the GetLastResult()
427 * @see SetControlAlwaysAtBottom()
429 bool IsControlAlwaysAtBottom(const Tizen::Ui::Control& control) const;
432 * Checks whether the specified child control is always on the top of
437 * @return @c true if the specified child control is set as always on the top, @n
439 * @param[in] control The child control
440 * @exception E_SUCCESS The method is successful.
441 * @exception E_INVALID_ARG A specified input parameter is invalid. @n
442 * The specified control is not a child of this
444 * @remarks The specific error code can be accessed using the GetLastResult()
446 * @see SetControlAlwaysOnTop()
448 bool IsControlAlwaysOnTop(const Tizen::Ui::Control& control) const;
452 * 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.
459 * Initializes this instance of %Container.
463 * @return An error code
464 * @exception E_SUCCESS The method is successful.
465 * @exception E_SYSTEM A system error has occurred.
467 result Construct(void);
470 * Initializes this instance of %Container.
474 * @return An error code
475 * @param[in] rect The rectangle bounds to be set
476 * @param[in] resizable Set to @c true to make the container resizable, @n
478 * @param[in] movable Set to @c true to make the container movable, @n
480 * @exception E_SUCCESS The method is successful.
481 * @exception E_INVALID_ARG A specified input parameter is invalid.
482 * @remarks This method must be called from the derived classes's construct methods.
483 * @remarks If the @c resizable is @c false, IsResizable() returns @c false.
486 result Construct(const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true);
489 * Initializes this instance of %Container with the specified layout and rectangular region.
493 * @return An error code
494 * @param[in] layout The layout for both the portrait and landscape mode
495 * @param[in] rect The location and size of the %Container
496 * @param[in] resizable Set to @c true to make the container resizable, @n
498 * @param[in] movable Set to @c true to make the container movable, @n
500 * @exception E_SUCCESS The method is successful.
501 * @exception E_INVALID_ARG A specified input parameter is invalid.
502 * @remarks This method must be called from the derived classes's construct methods.
503 * @remarks If the @c resizable is @c false, IsResizable() returns @c false.
505 * @see Tizen::Ui::Layout
506 * @see Tizen::Ui::Container::GetLayoutN()
508 result Construct(const Tizen::Ui::Layout& layout, const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true);
511 * Initializes this instance of %Container with the specified layouts and rectangular region.
515 * @return An error code
516 * @param[in] portraitLayout The layout for the portrait mode
517 * @param[in] landscapeLayout The layout for the landscape mode
518 * @param[in] rect The location and size of the %Container
519 * @param[in] resizable Set to @c true to make the container resizable, @n
521 * @param[in] movable Set to @c true to make the container movable, @n
523 * @exception E_SUCCESS The method is successful.
524 * @exception E_INVALID_ARG A specified input parameter is invalid.
525 * @remarks If the @c resizable is @c false, IsResizable() returns @c false.
527 * @see Tizen::Ui::Layout
528 * @see Tizen::Ui::Layout
529 * @see Tizen::Ui::Container::GetLayoutN()
530 * @see Tizen::Ui::Container::GetPortraitLayoutN()
531 * @see Tizen::Ui::Container::GetLandscapeLayoutN()
533 result Construct(const Tizen::Ui::Layout& portraitLayout, const Tizen::Ui::Layout& landscapeLayout, const Tizen::Graphics::Rectangle& rect, bool resizable = true, bool movable = true);
536 * Gets the index of the specified control.
539 * @return An error code
540 * @param[in] control The control
541 * @param[out] index The index of the control
542 * @exception E_SUCCESS The method is successful.
543 * @exception E_OBJ_NOT_FOUND The specified instance of Control is not found.
544 * @see SetControlAt()
547 result GetControlAt(const Control& control, int& index) const;
550 * Sets the control at the specified index.
554 * @return An error code
555 * @param[in] control The control
556 * @param[in] index The index
557 * @exception E_SUCCESS The method is successful.
558 * @exception E_OUT_OF_RANGE The specified @c index is out of range.
559 * @exception E_SYSTEM A system error has occurred.
560 * @remarks The @c control must be first added to this container. @n
561 * Call the Invalidate() method after this, to apply the change to be shown.
562 * @see Invalidate(), GetControlAt()
565 result SetControlAt(const Control& control, int index);
569 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
571 Container(const Container& rhs);
574 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
576 Container& operator =(const Container& rhs);
579 friend class _ContainerImpl;
582 // This method is for internal use only.
583 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
585 // This method is reserved and may change its name at any time without prior notice.
587 virtual void Container_Reserved1(void) {}
590 // This method is for internal use only.
591 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
593 // This method is reserved and may change its name at any time without prior notice.
595 virtual void Container_Reserved2(void) {}
598 // This method is for internal use only.
599 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
601 // This method is reserved and may change its name at any time without prior notice.
603 virtual void Container_Reserved3(void) {}
606 // This method is for internal use only.
607 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
609 // This method is reserved and may change its name at any time without prior notice.
611 virtual void Container_Reserved4(void) {}
614 // This method is for internal use only.
615 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
617 // This method is reserved and may change its name at any time without prior notice.
619 virtual void Container_Reserved5(void) {}
625 #endif //_FUI_CONTAINER_H_