Merge "Remove obsolete and non functional SizeChanged signal from actor" into tizen
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / navigation-frame / page-impl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19
20 #include "page-impl.h"
21
22 // EXTERNAL INCLUDES
23 #include <dali/public-api/object/type-registry.h>
24
25 // INTERNAL INCLUDES
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 namespace
37 {
38
39 BaseHandle Create()
40 {
41   return Toolkit::Page::New();
42 }
43
44 TypeRegistration mType( typeid(Toolkit::Page), typeid(CustomActor), Create );
45
46 } // unnamed namespace
47
48 Page::Page()
49 : Control( CONTROL_BEHAVIOUR_NONE ),
50   mTitle(""),
51   mSubTitle(""),
52   mPropertyTitle(Property::INVALID_INDEX),
53   mPropertySubTitle(Property::INVALID_INDEX)
54 {
55 }
56
57 Page::~Page()
58 {
59   Toolkit::Page::ControlOnBarContainer::const_iterator iter;
60
61   if( !mToolBarControls.empty() )
62   {
63     for( iter = mToolBarControls.begin(); iter != mToolBarControls.end(); iter++ )
64     {
65       delete( *iter );
66     }
67   }
68
69 }
70
71 Toolkit::Page Page::New()
72 {
73   // Create the implementation, temporarily owned by this handle on stack
74   IntrusivePtr< Page > internalpage = new Page();
75
76   // Pass ownership to CustomActor handle
77   Toolkit::Page page( *internalpage );
78
79   // Second-phase init of the implementation
80   // This can only be done after the CustomActor connection has been made...
81   internalpage->Initialize();
82
83   return page;
84
85 }
86
87 void Page::SetTitle(const std::string& title)
88 {
89   mTitle = title;
90 }
91
92 const std::string& Page::GetTitle() const
93 {
94   return mTitle;
95 }
96
97 void Page::SetSubTitle(const std::string& subtitle)
98 {
99   mSubTitle = subtitle;
100 }
101
102 const std::string& Page::GetSubTitle() const
103 {
104   return mSubTitle;
105 }
106
107 void Page::SetTitleIcon( Actor titleIcon)
108 {
109   mTitleIcon = titleIcon;
110 }
111
112 Actor Page::GetTitleIcon() const
113 {
114   return mTitleIcon;
115 }
116
117 bool Page::AddControlToToolBar(Actor control, Toolkit::Alignment::Type alignment)
118 {
119   if( !control || ( alignment!=Toolkit::Alignment::HorizontalLeft
120                  && alignment!=Toolkit::Alignment::HorizontalCenter
121                  && alignment!=Toolkit::Alignment::HorizontalRight ) )
122   {
123     return false;
124   }
125   else
126   {
127     mToolBarControls.push_back(new Toolkit::Page::ControlOnBar(control, alignment));
128     return true;
129   }
130 }
131
132 const Toolkit::Page::ControlOnBarContainer& Page::GetControlsOnToolBar() const
133 {
134   return mToolBarControls;
135 }
136
137 bool Page::AddControlToTitleBar(Actor control)
138 {
139   if( !control )
140   {
141     return false;
142   }
143   else
144   {
145     mTitleBarControls.push_back(control);
146     return true;
147   }
148 }
149
150 const ActorContainer& Page::GetControlsOnTitleBar() const
151 {
152   return mTitleBarControls;
153 }
154
155 void Page::SetPopupMenu( Toolkit::Popup popupMenu )
156 {
157   mPopupMenu = popupMenu;
158 }
159
160 Toolkit::Popup Page::GetPopupMenu() const
161 {
162   return mPopupMenu;
163 }
164
165 void Page::OnInitialize()
166 {
167   Actor self = Self();
168
169   mPropertyTitle = self.RegisterProperty( Dali::Toolkit::Page::PROPERTY_TITLE, "", Property::READ_WRITE );
170   mPropertySubTitle = self.RegisterProperty( Dali::Toolkit::Page::PROPERTY_SUB_TITLE, "", Property::READ_WRITE );
171 }
172
173 void Page::OnPropertySet( Property::Index index, Property::Value propertyValue )
174 {
175   if( index == mPropertyTitle )
176   {
177     std::string title( propertyValue.Get<std::string>() );
178     SetTitle(title);
179   }
180   else if( index == mPropertySubTitle )
181   {
182     std::string subTitle( propertyValue.Get<std::string>() );
183     SetSubTitle(subTitle);
184   }
185 }
186
187 } // namespace Internal
188
189 } // namespace Toolkit
190
191 } // namespace Dali