2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "style-monitor-impl.h"
22 #include <dali/public-api/object/type-registry.h>
25 #include <adaptor-impl.h>
26 #include <singleton-service-impl.h>
42 BaseHandle handle( StyleMonitor::Get() );
44 if ( !handle && Adaptor::IsAvailable() )
46 Dali::SingletonService service( SingletonService::Get() );
49 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
50 Dali::StyleMonitor styleMonitor = Dali::StyleMonitor( new StyleMonitor( adaptorImpl.GetPlatformAbstraction() ) );
51 service.Register( typeid( styleMonitor ), styleMonitor );
52 handle = styleMonitor;
58 TypeRegistration STYLE_MONITOR_TYPE( typeid(Dali::StyleMonitor), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
60 } // unnamed namespace
62 Dali::StyleMonitor StyleMonitor::Get()
64 Dali::StyleMonitor styleMonitor;
66 Dali::SingletonService service( SingletonService::Get() );
69 // Check whether the singleton is already created
70 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::StyleMonitor ) );
73 // If so, downcast the handle
74 styleMonitor = Dali::StyleMonitor( dynamic_cast< StyleMonitor* >( handle.GetObjectPtr() ) );
81 StyleMonitor::StyleMonitor(Integration::PlatformAbstraction& platformAbstraction)
82 : mPlatformAbstraction(platformAbstraction)
86 StyleMonitor::~StyleMonitor()
90 void StyleMonitor::StyleChanged(StyleChange styleChange)
92 if (styleChange.defaultFontChange || styleChange.defaultFontSizeChange)
94 //mPlatformAbstraction.UpdateDefaultsFromDevice();
97 EmitStyleChangeSignal(styleChange);
100 std::string StyleMonitor::GetDefaultFontFamily() const
102 //return mPlatformAbstraction.GetDefaultFontFamily();
103 return std::string();
106 float StyleMonitor::GetDefaultFontSize() const
108 //return mPlatformAbstraction.GetDefaultFontSize();
112 const std::string& StyleMonitor::GetTheme() const
114 return mUserDefinedThemeFilePath;
117 void StyleMonitor::SetTheme(const std::string& path)
119 StyleChange styleChange;
120 styleChange.themeChange = true;
121 styleChange.themeFilePath = path;
122 mUserDefinedThemeFilePath = path;
124 EmitStyleChangeSignal(styleChange);
127 Dali::StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal()
129 return mStyleChangeSignal;
132 void StyleMonitor::EmitStyleChangeSignal(StyleChange styleChange)
134 if( !mStyleChangeSignal.Empty() )
136 Dali::StyleMonitor handle( this );
137 mStyleChangeSignal.Emit( handle, styleChange );
141 } // namespace Adaptor
143 } // namespace Internal