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