(StyleManager) Create a style manager
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / internal / controls / navigation-frame / page-impl.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18
19 #include "page-impl.h"
20
21 // EXTERNAL INCLUDES
22
23 // INTERNAL INCLUDES
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace Internal
32 {
33
34 namespace
35 {
36
37 BaseHandle Create()
38 {
39   return Toolkit::Page::New();
40 }
41
42 TypeRegistration mType( typeid(Toolkit::Page), typeid(CustomActor), Create );
43
44 } // unnamed namespace
45
46 Page::Page()
47 : Control( CONTROL_BEHAVIOUR_NONE ),
48   mTitle(""),
49   mSubTitle("")
50 {
51 }
52
53 Page::~Page()
54 {
55   Toolkit::Page::ControlOnBarContainer::const_iterator iter;
56
57   if( !mToolBarControls.empty() )
58   {
59     for( iter = mToolBarControls.begin(); iter != mToolBarControls.end(); iter++ )
60     {
61       delete( *iter );
62     }
63   }
64
65 }
66
67 Toolkit::Page Page::New()
68 {
69   // Create the implementation, temporarily owned by this handle on stack
70   IntrusivePtr< Page > internalpage = new Page();
71
72   // Pass ownership to CustomActor handle
73   Toolkit::Page page( *internalpage );
74
75   // Second-phase init of the implementation
76   // This can only be done after the CustomActor connection has been made...
77   internalpage->Initialize();
78
79   return page;
80
81 }
82
83 void Page::SetTitle(const std::string& title)
84 {
85   mTitle = title;
86 }
87
88 const std::string& Page::GetTitle() const
89 {
90   return mTitle;
91 }
92
93 void Page::SetSubTitle(const std::string& subtitle)
94 {
95   mSubTitle = subtitle;
96 }
97
98 const std::string& Page::GetSubTitle() const
99 {
100   return mSubTitle;
101 }
102
103 void Page::SetTitleIcon( Actor titleIcon)
104 {
105   mTitleIcon = titleIcon;
106 }
107
108 Actor Page::GetTitleIcon() const
109 {
110   return mTitleIcon;
111 }
112
113 bool Page::AddControlToToolBar(Actor control, Toolkit::Alignment::Type alignment)
114 {
115   if( !control || ( alignment!=Toolkit::Alignment::HorizontalLeft
116                  && alignment!=Toolkit::Alignment::HorizontalCenter
117                  && alignment!=Toolkit::Alignment::HorizontalRight ) )
118   {
119     return false;
120   }
121   else
122   {
123     mToolBarControls.push_back(new Toolkit::Page::ControlOnBar(control, alignment));
124     return true;
125   }
126 }
127
128 const Toolkit::Page::ControlOnBarContainer& Page::GetControlsOnToolBar() const
129 {
130   return mToolBarControls;
131 }
132
133 bool Page::AddControlToTitleBar(Actor control)
134 {
135   if( !control )
136   {
137     return false;
138   }
139   else
140   {
141     mTitleBarControls.push_back(control);
142     return true;
143   }
144 }
145
146 const ActorContainer& Page::GetControlsOnTitleBar() const
147 {
148   return mTitleBarControls;
149 }
150
151 void Page::SetPopupMenu( Toolkit::Popup popupMenu )
152 {
153   mPopupMenu = popupMenu;
154 }
155
156 Toolkit::Popup Page::GetPopupMenu() const
157 {
158   return mPopupMenu;
159 }
160
161 void Page::OnInitialize()
162 {
163   Actor self = Self();
164
165   mPropertyTitle = self.RegisterProperty( Dali::Toolkit::Page::PROPERTY_TITLE, "", Property::READ_WRITE );
166   mPropertySubTitle = self.RegisterProperty( Dali::Toolkit::Page::PROPERTY_SUB_TITLE, "", Property::READ_WRITE );
167 }
168
169 void Page::OnPropertySet( Property::Index index, Property::Value propertyValue )
170 {
171   if( index == mPropertyTitle )
172   {
173     std::string title( propertyValue.Get<std::string>() );
174     SetTitle(title);
175   }
176   else if( index == mPropertySubTitle )
177   {
178     std::string subTitle( propertyValue.Get<std::string>() );
179     SetSubTitle(subTitle);
180   }
181 }
182
183 } // namespace Internal
184
185 } // namespace Toolkit
186
187 } // namespace Dali