e0cf61695efdeb3c6a292015aba0d504a1515ce0
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / navigation-frame / page.h
1 #ifndef __DALI_TOOLKIT_PAGE_H__
2 #define __DALI_TOOLKIT_PAGE_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-vector.h>
23
24 // INTERNAL INCLUDES
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>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Internal DALI_INTERNAL
36 {
37 // Forward declarations
38 class Page;
39 }
40
41 /**
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.
45  */
46 class DALI_IMPORT_API Page : public Control
47 {
48
49 public:
50
51   /**
52    * @brief The start and end property ranges for this control.
53    */
54   enum PropertyRange
55   {
56     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
57     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices
58   };
59
60   /**
61    * @brief An enumeration of properties belonging to the Page class.
62    */
63   struct Property
64   {
65     enum
66     {
67       TITLE = PROPERTY_START_INDEX, ///< name "title",          @see SetTitle(),         type string
68       SUB_TITLE,                    ///< name "sub-title",      @see SetSubTitle(),      type string
69     };
70   };
71
72   /**
73    * Structure to indicate a control on the navigation tool bar and its group (HorizontalLeft, HorizontalRight or HorizontalCenter)
74    */
75   struct ControlOnBar
76   {
77     /**
78      * Constructor
79      */
80     ControlOnBar(Actor actor, Toolkit::Alignment::Type alignment)
81     : control( actor ),
82       alignment( alignment )
83     {
84     }
85
86     Actor control;                            ///< The control actor
87     Toolkit::Alignment::Type alignment;       ///< The alignment of the control actor
88   };
89
90   typedef std::vector< const ControlOnBar* > ControlOnBarContainer;
91
92 public:
93
94   /**
95    * Create a Page handle; this can be initialized with Page::New().
96    * Calling member function with an uninitialized handle is not allowed.
97    */
98   Page();
99
100   /**
101    * Copy Constructor.
102    */
103   Page( const Page& handle );
104
105   /**
106    * Assignment operator.
107    * Change this handle to point to another real object.
108    */
109   Page& operator=( const Page& handle );
110
111   /**
112    * Create an initialized Page.
113    * @return A handle to a newly allocated Dali resource.
114    */
115   static Page New();
116
117   /**
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.
123    */
124   static Page DownCast( BaseHandle handle );
125
126   /**
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.
130    */
131   void SetTitle(const std::string& title);
132
133   /**
134    * Retrieve the title of the page.
135    * @return The Page's title or "" when the item does not have a title.
136    */
137   const std::string& GetTitle() const;
138
139   /**
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.
143    */
144   void SetSubTitle(const std::string& subtitle);
145
146   /**
147    * Retrieve the subtitle of the page.
148    * @return The Page's subtitle or "" when the subtitle does not have a subtitle.
149    */
150   const std::string& GetSubTitle() const;
151
152   /**
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
156    */
157   void SetTitleIcon( Actor titleIcon);
158
159   /**
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.
162    */
163   Actor GetTitleIcon() const;
164
165   /**
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
173    */
174   bool AddControlToToolBar(Actor control, Alignment::Type alignment);
175
176   /**
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.
179    */
180   const ControlOnBarContainer GetControlsOnToolBar() const;
181
182   /**
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
187    */
188   bool AddControlToTitleBar(Actor control);
189
190   /**
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.
193    */
194   const ActorContainer GetControlsOnTitleBar() const;
195
196   /**
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
199    */
200   void SetPopupMenu( Toolkit::Popup popupMenu );
201
202   /**
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
205    */
206   Toolkit::Popup GetPopupMenu() const;
207
208 public: // Not intended for application developers
209
210   /**
211    * Creates a handle using the Toolkit::Internal implementation.
212    * @param[in] impl The Page implementation.
213    */
214   DALI_INTERNAL Page(Internal::Page& impl);
215
216   /**
217    * Allows the creation of this Control from an Internal::CustomActor pointer.
218    * @param[in]  internal  A pointer to the internal CustomActor.
219    */
220   explicit DALI_INTERNAL Page( Dali::Internal::CustomActor* internal );
221 };
222
223 } // namespace Toolkit
224
225 } // namespace Dali
226
227 #endif /* __DALI_TOOLKIT_PAGE_H__ */