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