Merge "Reduce ImageActor & RenderableActor APIs" into tizen
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / navigation-frame / page-impl.cpp
index 0b15d12..82fb886 100644 (file)
@@ -1,26 +1,26 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // CLASS HEADER
-
 #include "page-impl.h"
 
 // EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/type-registry-helper.h>
 
 namespace Dali
 {
@@ -39,12 +39,15 @@ BaseHandle Create()
   return Toolkit::Page::New();
 }
 
-TypeRegistration mType( typeid(Toolkit::Page), typeid(CustomActor), Create );
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::Page, Toolkit::Control, Create )
+DALI_PROPERTY_REGISTRATION( Toolkit, Page, "title",     STRING, TITLE     )
+DALI_PROPERTY_REGISTRATION( Toolkit, Page, "sub-title", STRING, SUB_TITLE )
+DALI_TYPE_REGISTRATION_END()
 
 } // unnamed namespace
 
 Page::Page()
-: ControlImpl(false),
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
   mTitle(""),
   mSubTitle("")
 {
@@ -158,26 +161,54 @@ Toolkit::Popup Page::GetPopupMenu() const
   return mPopupMenu;
 }
 
-void Page::OnInitialize()
+void Page::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
 {
-  Actor self = Self();
+  Toolkit::Page page = Toolkit::Page::DownCast( Dali::BaseHandle( object ) );
 
-  mPropertyTitle = self.RegisterProperty( Dali::Toolkit::Page::PROPERTY_TITLE, "", Property::READ_WRITE );
-  mPropertySubTitle = self.RegisterProperty( Dali::Toolkit::Page::PROPERTY_SUB_TITLE, "", Property::READ_WRITE );
+  if ( page )
+  {
+    switch ( index )
+    {
+      case Toolkit::Page::Property::TITLE:
+      {
+        GetImpl( page ).SetTitle( value.Get< std::string >() );
+        break;
+      }
+
+      case Toolkit::Page::Property::SUB_TITLE:
+      {
+        GetImpl( page ).SetSubTitle( value.Get< std::string >() );
+        break;
+      }
+    }
+  }
 }
 
-void Page::OnPropertySet( Property::Index index, Property::Value propertyValue )
+Property::Value Page::GetProperty( BaseObject* object, Property::Index propertyIndex )
 {
-  if( index == mPropertyTitle )
-  {
-    std::string title( propertyValue.Get<std::string>() );
-    SetTitle(title);
-  }
-  else if( index == mPropertySubTitle )
+  Property::Value value;
+
+  Toolkit::Page page = Toolkit::Page::DownCast( Dali::BaseHandle( object ) );
+
+  if ( page )
   {
-    std::string subTitle( propertyValue.Get<std::string>() );
-    SetSubTitle(subTitle);
+    switch ( propertyIndex )
+    {
+      case Toolkit::Page::Property::TITLE:
+      {
+        value = GetImpl( page ).mTitle;
+        break;
+      }
+
+      case Toolkit::Page::Property::SUB_TITLE:
+      {
+        value = GetImpl( page ).mSubTitle;
+        break;
+      }
+    }
   }
+
+  return value;
 }
 
 } // namespace Internal