1 #ifndef __DALI_TOOLKIT_PAGE_H__
2 #define __DALI_TOOLKIT_PAGE_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/dali-vector.h>
25 #include <dali-toolkit/public-api/controls/control.h>
26 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
27 #include <dali-toolkit/public-api/controls/popup/popup.h>
35 namespace Internal DALI_INTERNAL
37 // Forward declarations
42 * A Page is a custom control which can be pushed into the stack of navigation control.
43 * It serves as the root of a navigation view.
44 * It also carries the title/subtitle/buttons/icons information which would be shown on the navigation bars when the item is on the top of the stack.
46 class DALI_IMPORT_API Page : public Control
52 * @brief The start and end property ranges for this control.
56 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
57 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
61 * @brief An enumeration of properties belonging to the Page class.
67 TITLE = PROPERTY_START_INDEX, ///< name "title", @see SetTitle(), type string
68 SUB_TITLE, ///< name "sub-title", @see SetSubTitle(), type string
73 * Structure to indicate a control on the navigation tool bar and its group (HorizontalLeft, HorizontalRight or HorizontalCenter)
80 ControlOnBar(Actor actor, Toolkit::Alignment::Type alignment)
82 alignment( alignment )
86 Actor control; ///< The control actor
87 Toolkit::Alignment::Type alignment; ///< The alignment of the control actor
90 typedef std::vector< const ControlOnBar* > ControlOnBarContainer;
95 * Create a Page handle; this can be initialized with Page::New().
96 * Calling member function with an uninitialized handle is not allowed.
103 Page( const Page& handle );
106 * Assignment operator.
107 * Change this handle to point to another real object.
109 Page& operator=( const Page& handle );
112 * Create an initialized Page.
113 * @return A handle to a newly allocated Dali resource.
118 * Downcast an object handle to Page.
119 * If handle points to a Page, the downcast produces valid handle.
120 * If not, the returned handle is left uninitialized.
121 * @param[in] handle Handle to an object.
122 * @return handle to a Page of an uninitialized handle.
124 static Page DownCast( BaseHandle handle );
127 * Sets the Page's title.
128 * The title will be displayed on the navigation title bar when the item is on the top of the stack.
129 * @param[in] title The Page's title.
131 void SetTitle(const std::string& title);
134 * Retrieve the title of the page.
135 * @return The Page's title or "" when the item does not have a title.
137 const std::string& GetTitle() const;
140 * Sets the Page's subtitle.
141 * The subtitle will be displayed on the navigation title bar when the item is on the top of the stack.
142 * @param[in] subtitle The Page's subtitle.
144 void SetSubTitle(const std::string& subtitle);
147 * Retrieve the subtitle of the page.
148 * @return The Page's subtitle or "" when the subtitle does not have a subtitle.
150 const std::string& GetSubTitle() const;
153 * Sets the Page's title icon.
154 * The icon will be displayed in front of the title on the navigation item bar when the item is on the top.
155 * @param[in] titleIcon The Page's icon
157 void SetTitleIcon( Actor titleIcon);
160 * Retrieve the title icon of the page.
161 * @return The Page's icon or an empty handle when the item does not have title icon.
163 Actor GetTitleIcon() const;
166 * Set a control onto the navigation tool bar when the item is on the top.
167 * Only one control (the last set one) is valid for HorizontalLeft and HorizontalRight each.
168 * Can have multiple controls for HorizontalCenter.
169 * If the control is uninitialized or if the alignment has a value other from HorizontalLeft/HorizontalRight/HorizontalCenter, the control is not added.
170 * @param[in] control The control on the navigation tool bar.
171 * @param[in] alignment The position of the control, can be HorizontalLeft/HorizontalRight/HorizontalCenter.
172 * @return true if add control successfully, false if fail to add the control
174 bool AddControlToToolBar(Actor control, Alignment::Type alignment);
177 * Retrieve the controls that would be displayed on the navigation tool bar when the item is on the top.
178 * @return the vector of tool bar controls associated with the current item.
180 const ControlOnBarContainer GetControlsOnToolBar() const;
183 * Set a control onto the right part of the navigation title bar when the item is on the top.
184 * If the control is uninitialized or if the alignment has a value other from HorizontalLeft/HorizontalRight/HorizontalCenter, the control is not added.
185 * @param[in] control The control on the navigation title bar.
186 * @return true if add control successfully, false if fail to add the control
188 bool AddControlToTitleBar(Actor control);
191 * Retrieve the controls that would be displayed on the navigation title bar when the item is on the top.
192 * @return the vector of title bar controls associate with the current item.
194 const ActorContainer GetControlsOnTitleBar() const;
197 * Set the menu which would pop up when the KEY_MENU is pressed.
198 * @param[in] popupMenu the popup menu connected to the KEY_MENU event
200 void SetPopupMenu( Toolkit::Popup popupMenu );
203 * Get the menu which would pop up when the KEY_MENU is pressed.
204 * @return The popup menu connected to the KEY_MENU event
206 Toolkit::Popup GetPopupMenu() const;
208 public: // Not intended for application developers
211 * Creates a handle using the Toolkit::Internal implementation.
212 * @param[in] impl The Page implementation.
214 DALI_INTERNAL Page(Internal::Page& impl);
217 * Allows the creation of this Control from an Internal::CustomActor pointer.
218 * @param[in] internal A pointer to the internal CustomActor.
220 explicit DALI_INTERNAL Page( Dali::Internal::CustomActor* internal );
223 } // namespace Toolkit
227 #endif /* __DALI_TOOLKIT_PAGE_H__ */