Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-toolkit.git] / optional / 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) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali-toolkit/public-api/controls/control.h>
22 #include <dali-toolkit/public-api/controls/alignment/alignment.h>
23 #include <dali-toolkit/public-api/controls/popup/popup.h>
24
25 namespace Dali DALI_IMPORT_API
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33 // Forward declarations
34 class Page;
35 }
36
37 /**
38  * A Page is a custom control which can be pushed into the stack of navigation control.
39  * It serves as the root of a navigation view.
40  * 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.
41  */
42 class Page : public Control
43 {
44
45 public:
46
47   /**
48    * The names of custom properties installed by this control.
49    */
50   // Property Names
51   static const char* const PROPERTY_TITLE;       ///< name "title", type std::string
52   static const char* const PROPERTY_SUB_TITLE;   ///< name "sub-title", type std::string
53
54   /**
55    * Structure to indicate a control on the navigation tool bar and its group (HorizontalLeft, HorizontalRight or HorizontalCenter)
56    */
57   struct ControlOnBar
58   {
59     /**
60      * Constructor
61      */
62     ControlOnBar(Actor actor, Toolkit::Alignment::Type alignment)
63     : control( actor ),
64       alignment( alignment )
65     {
66     }
67
68     Actor control;                            ///< The control actor
69     Toolkit::Alignment::Type alignment;       ///< The alignment of the control actor
70   };
71
72   typedef std::vector< const ControlOnBar* > ControlOnBarContainer;
73
74 public:
75
76   /**
77    * Create a Page handle; this can be initialized with Page::New().
78    * Calling member function with an uninitialized handle is not allowed.
79    */
80   Page();
81
82   /**
83    * Copy Constructor.
84    */
85   Page( const Page& handle );
86
87   /**
88    * Assignment operator.
89    * Change this handle to point to another real object.
90    */
91   Page& operator=( const Page& handle );
92
93   /**
94    * Create an initialized Page.
95    * @return A handle to a newly allocated Dali resource.
96    */
97   static Page New();
98
99   /**
100    * Downcast an object handle to Page.
101    * If handle points to a Page, the downcast produces valid handle.
102    * If not, the returned handle is left uninitialized.
103    * @param[in] handle Handle to an object.
104    * @return handle to a Page of an uninitialized handle.
105    */
106   static Page DownCast( BaseHandle handle );
107
108   /**
109    * Sets the Page's title.
110    * The title will be displayed on the navigation title bar when the item is on the top of the stack.
111    * @param[in] title The Page's title.
112    */
113   void SetTitle(const std::string& title);
114
115   /**
116    * Retrieve the title of the page.
117    * @return The Page's title or "" when the item does not have a title.
118    */
119   const std::string& GetTitle() const;
120
121   /**
122    * Sets the Page's subtitle.
123    * The subtitle will be displayed on the navigation title bar when the item is on the top of the stack.
124    * @param[in] subtitle The Page's subtitle.
125    */
126   void SetSubTitle(const std::string& subtitle);
127
128   /**
129    * Retrieve the subtitle of the page.
130    * @return The Page's subtitle or "" when the subtitle does not have a subtitle.
131    */
132   const std::string& GetSubTitle() const;
133
134   /**
135    * Sets the Page's title icon.
136    * The icon will be displayed in front of the title on the navigation item bar when the item is on the top.
137    * @param[in] titleIcon The Page's icon
138    */
139   void SetTitleIcon( Actor titleIcon);
140
141   /**
142    * Retrieve the title icon of the page.
143    * @return The Page's icon or an empty handle when the item does not have title icon.
144    */
145   Actor GetTitleIcon() const;
146
147   /**
148    * Set a control onto the navigation tool bar when the item is on the top.
149    * Only one control (the last set one) is valid for HorizontalLeft and HorizontalRight each.
150    * Can have multiple controls for HorizontalCenter.
151    * If the control is uninitialized or if the alignment has a value other from HorizontalLeft/HorizontalRight/HorizontalCenter, the control is not added.
152    * @param[in] control The control on the navigation tool bar.
153    * @param[in] alignment The position of the control, can be HorizontalLeft/HorizontalRight/HorizontalCenter.
154    * @return true if add control successfully, false if fail to add the control
155    */
156   bool AddControlToToolBar(Actor control, Alignment::Type alignment);
157
158   /**
159    * Retrieve the controls that would be displayed on the navigation tool bar when the item is on the top.
160    * @return the vector of tool bar controls associated with the current item.
161    */
162   const ControlOnBarContainer GetControlsOnToolBar() const;
163
164   /**
165    * Set a control onto the right part of the navigation title bar when the item is on the top.
166    * If the control is uninitialized or if the alignment has a value other from HorizontalLeft/HorizontalRight/HorizontalCenter, the control is not added.
167    * @param[in] control The control on the navigation title bar.
168    * @return true if add control successfully, false if fail to add the control
169    */
170   bool AddControlToTitleBar(Actor control);
171
172   /**
173    * Retrieve the controls that would be displayed on the navigation title bar when the item is on the top.
174    * @return the vector of title bar controls associate with the current item.
175    */
176   const ActorContainer GetControlsOnTitleBar() const;
177
178   /**
179    * Set the menu which would pop up when the KEY_MENU is pressed.
180    * @param[in] popupMenu the popup menu connected to the KEY_MENU event
181    */
182   void SetPopupMenu( Toolkit::Popup popupMenu );
183
184   /**
185    * Get the menu which would pop up when the KEY_MENU is pressed.
186    * @return The popup menu connected to the KEY_MENU event
187    */
188   Toolkit::Popup GetPopupMenu() const;
189
190 public: // Not intended for application developers
191
192   /**
193    * Creates a handle using the Toolkit::Internal implementation.
194    * @param[in] impl The Page implementation.
195    */
196   Page(Internal::Page& impl);
197
198   /**
199    * Allows the creation of this Control from an Internal::CustomActor pointer.
200    * @param[in]  internal  A pointer to the internal CustomActor.
201    */
202   Page( Dali::Internal::CustomActor* internal );
203 };
204
205 } // namespace Toolkit
206
207 } // namespace Dali
208
209 #endif /* __DALI_TOOLKIT_PAGE_H__ */