[4.0] Enhance application device signal
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / adaptor-framework / application.cpp
index d4a9056..1db99e3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
 #include "application.h"
 
 // EXTERNAL INCLUDES
-#include <orientation.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
 #include <application-impl.h>
-#include <orientation-impl.h>
 
 namespace Dali
 {
@@ -36,32 +34,90 @@ Application Application::New()
 
 Application Application::New( int* argc, char **argv[] )
 {
-  Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "Dali Application", DeviceLayout::DEFAULT_BASE_LAYOUT, OPAQUE );
-  return Application(internal.Get());
-}
+  Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
+  if( internal )
+  {
+    if( argc && ( *argc > 0 ) )
+    {
+      internal->GetWindow().SetClass( (*argv)[0], "" );
+    }
 
-Application Application::New( int* argc, char **argv[], const std::string& name )
-{
-  Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT, OPAQUE );
-  return Application(internal.Get());
+    return Application( internal.Get() );
+  }
+  else
+  {
+    internal = Internal::Adaptor::Application::New( argc, argv, "", OPAQUE, PositionSize(),
+      Internal::Adaptor::Framework::NORMAL);
+    return Application(internal.Get());
+  }
 }
 
-Application Application::New( int* argc, char **argv[], const std::string& name, WINDOW_MODE windowMode )
+Application Application::New( int* argc, char **argv[], const std::string& stylesheet )
 {
-  Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, DeviceLayout::DEFAULT_BASE_LAYOUT, windowMode );
-  return Application(internal.Get());
+  Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
+  if( internal )
+  {
+    if( argc && ( *argc > 0 ) )
+    {
+      internal->GetWindow().SetClass( (*argv)[0], "" );
+    }
+    internal->SetStyleSheet( stylesheet );
+
+    return Application( internal.Get() );
+  }
+  else
+  {
+    internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, OPAQUE, PositionSize(),
+      Internal::Adaptor::Framework::NORMAL);
+    return Application(internal.Get());
+  }
 }
 
-Application Application::New(int* argc, char **argv[], const DeviceLayout& baseLayout)
+Application Application::New( int* argc, char **argv[], const std::string& stylesheet, WINDOW_MODE windowMode )
 {
-  Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, "Dali Application", baseLayout, OPAQUE );
-  return Application(internal.Get());
+  Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
+  if( internal )
+  {
+    if( argc && ( *argc > 0 ) )
+    {
+      internal->GetWindow().SetClass( (*argv)[0], "" );
+    }
+    internal->SetStyleSheet( stylesheet );
+
+    internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
+
+    return Application( internal.Get() );
+  }
+  else
+  {
+    internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, PositionSize(),
+      Internal::Adaptor::Framework::NORMAL);
+    return Application(internal.Get());
+  }
 }
 
-Application Application::New(int* argc, char **argv[], const std::string& name, const DeviceLayout& baseLayout)
+Application Application::New( int* argc, char **argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize )
 {
-  Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::New( argc, argv, name, baseLayout, OPAQUE );
-  return Application(internal.Get());
+  Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
+  if( internal )
+  {
+    if( argc && ( *argc > 0 ) )
+    {
+      internal->GetWindow().SetClass( (*argv)[0], "" );
+    }
+    internal->SetStyleSheet( stylesheet );
+
+    internal->GetWindow().SetTransparency( ( windowMode == Application::OPAQUE ? false : true ) );
+    internal->GetWindow().SetSize( Window::WindowSize( positionSize.width, positionSize.height ) );
+    internal->GetWindow().SetPosition( Window::WindowPosition( positionSize.x, positionSize.y ) );
+
+    return Application( internal.Get() );
+  }
+  else
+  {
+    internal = Internal::Adaptor::Application::New( argc, argv, stylesheet, windowMode, positionSize, Internal::Adaptor::Framework::NORMAL );
+    return Application( internal.Get() );
+  }
 }
 
 Application::~Application()
@@ -106,19 +162,9 @@ void Application::Quit()
   Internal::Adaptor::GetImplementation(*this).Quit();
 }
 
-Orientation Application::GetOrientation()
-{
-  Window window = GetWindow();
-  if( window )
-  {
-    return window.GetOrientation();
-  }
-  return Orientation();
-}
-
-bool Application::AddIdle(boost::function<void(void)> callBack)
+bool Application::AddIdle( CallbackBase* callback )
 {
-  return Internal::Adaptor::GetImplementation(*this).AddIdle(callBack);
+  return Internal::Adaptor::GetImplementation(*this).AddIdle( callback );
 }
 
 Window Application::GetWindow()
@@ -131,6 +177,21 @@ void Application::ReplaceWindow(PositionSize windowPosition, const std::string&
   Internal::Adaptor::GetImplementation(*this).ReplaceWindow(windowPosition, name);
 }
 
+std::string Application::GetResourcePath()
+{
+  return Internal::Adaptor::Application::GetResourcePath();
+}
+
+std::string Application::GetRegion() const
+{
+  return Internal::Adaptor::GetImplementation(*this).GetRegion();
+}
+
+std::string Application::GetLanguage() const
+{
+  return Internal::Adaptor::GetImplementation(*this).GetLanguage();
+}
+
 void Application::SetViewMode( ViewMode viewMode )
 {
   Internal::Adaptor::GetImplementation(*this).SetViewMode( viewMode );
@@ -178,14 +239,48 @@ Application::AppSignalType& Application::ResetSignal()
 
 Application::AppSignalType& Application::ResizeSignal()
 {
+  DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: ResizeSignal() is deprecated and will be removed from next release. Use Window::ResizedSignal() instead.\n" );
+
   return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
 }
 
+Application::AppControlSignalType & Application::AppControlSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
+}
+
 Application::AppSignalType& Application::LanguageChangedSignal()
 {
   return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
 }
 
+Application::AppSignalType& Application::RegionChangedSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
+}
+
+Application::AppSignalType& Application::BatteryLowSignal()
+{
+  DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: BatteryLowSignal() is deprecated and will be removed from next release. Use Application::LowBatterySignal() instead.\n" );
+  return Internal::Adaptor::GetImplementation(*this).BatteryLowSignal();
+}
+
+Application::AppSignalType& Application::MemoryLowSignal()
+{
+  DALI_LOG_WARNING_NOFN( "DEPRECATION WARNING: MemoryLowSignal() is deprecated and will be removed from next release. Use Application::LowMemorySignal() instead.\n" );
+  return Internal::Adaptor::GetImplementation(*this).MemoryLowSignal();
+}
+
+Application::LowBatterySignalType& Application::LowBatterySignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
+}
+
+Application::LowMemorySignalType& Application::LowMemorySignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
+}
+
 Application::Application(Internal::Adaptor::Application* application)
 : BaseHandle(application)
 {