(AutomatedTests) Ensure warnings are shown as errors
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-style-monitor.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 #include "toolkit-style-monitor.h"
19
20 #include <dali/public-api/common/dali-common.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <dali/public-api/signals/dali-signal.h>
23
24 namespace Dali
25 {
26
27
28 namespace Internal
29 {
30 namespace Adaptor
31 {
32 /**
33  * Stub for the StyleMonitor
34  */
35 class StyleMonitor : public BaseObject
36 {
37 public: // Creation & Destruction
38   static Dali::StyleMonitor Get();
39   StyleMonitor();
40   ~StyleMonitor();
41
42 public: // Style Information
43   std::string GetDefaultFontFamily() const;
44   float GetDefaultFontSize() const;
45   const std::string& GetTheme() const;
46   void SetTheme(std::string theme);
47
48 public: // Signals
49   Dali::StyleMonitor::StyleChangeSignalType& StyleChangeSignal();
50
51   void EmitStyleChangeSignal(StyleChange::Type styleChange)
52   {
53     mStyleChangeSignal.Emit(Dali::StyleMonitor(this), styleChange);
54   }
55
56 private:
57   Dali::StyleMonitor::StyleChangeSignalType mStyleChangeSignal;
58   static Dali::StyleMonitor mToolkitStyleMonitor;
59   std::string mTheme;
60 };
61
62 Dali::StyleMonitor StyleMonitor::mToolkitStyleMonitor;
63
64 Dali::StyleMonitor StyleMonitor::Get()
65 {
66   if( ! mToolkitStyleMonitor )
67   {
68     mToolkitStyleMonitor = Dali::StyleMonitor( new Dali::Internal::Adaptor::StyleMonitor() );
69   }
70   return mToolkitStyleMonitor;
71 }
72
73 StyleMonitor::StyleMonitor()
74 : mTheme("default")
75 {
76 }
77
78 StyleMonitor::~StyleMonitor()
79 {
80 }
81
82 std::string StyleMonitor::GetDefaultFontFamily() const
83 {
84   return Dali::StyleMonitor::DEFAULT_FONT_FAMILY;
85 }
86
87 float StyleMonitor::GetDefaultFontSize() const
88 {
89   return Dali::StyleMonitor::DEFAULT_FONT_SIZE;
90 }
91
92 const std::string& StyleMonitor::GetTheme() const
93 {
94   return mTheme;
95 }
96
97 void StyleMonitor::SetTheme(std::string path)
98 {
99   mTheme = path;
100   EmitStyleChangeSignal( StyleChange::THEME_CHANGE );
101 }
102
103 Dali::StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal()
104 {
105   return mStyleChangeSignal;
106 }
107
108 } // namespace Adaptor
109 } // namespace Internal
110
111 ////////////////////////////////////////////////////////////////////////////////////////////////////
112
113 Internal::Adaptor::StyleMonitor& GetImplementation(Dali::StyleMonitor& monitor)
114 {
115   BaseObject& object = monitor.GetBaseObject();
116   return static_cast<Internal::Adaptor::StyleMonitor&>(object);
117 }
118 const Internal::Adaptor::StyleMonitor& GetImplementation(const Dali::StyleMonitor& monitor)
119 {
120   const BaseObject& object = monitor.GetBaseObject();
121   return static_cast<const Internal::Adaptor::StyleMonitor&>(object);
122 }
123
124 const std::string Dali::StyleMonitor::DEFAULT_FONT_FAMILY("DefaultFont");
125 const float       Dali::StyleMonitor::DEFAULT_FONT_SIZE(1.0f);
126
127 StyleMonitor::StyleMonitor()
128 {
129 }
130
131 StyleMonitor::StyleMonitor(const StyleMonitor& monitor)
132 : BaseHandle(monitor)
133 {
134 }
135
136 StyleMonitor StyleMonitor::StyleMonitor::Get()
137 {
138   return Internal::Adaptor::StyleMonitor::Get();
139 }
140
141 StyleMonitor::~StyleMonitor()
142 {
143 }
144
145 std::string StyleMonitor::GetDefaultFontFamily() const
146 {
147   return GetImplementation(*this).GetDefaultFontFamily();
148 }
149
150 float StyleMonitor::GetDefaultFontSize() const
151 {
152   return GetImplementation(*this).GetDefaultFontSize();
153 }
154
155 const std::string& StyleMonitor::GetTheme() const
156 {
157   return GetImplementation(*this).GetTheme();
158 }
159
160 void StyleMonitor::SetTheme(std::string themeFilePath)
161 {
162   GetImplementation(*this).SetTheme(themeFilePath);
163 }
164
165 StyleMonitor::StyleChangeSignalType& StyleMonitor::StyleChangeSignal()
166 {
167   return GetImplementation(*this).StyleChangeSignal();
168 }
169
170 void StyleMonitor::EmitStyleChangeSignal(StyleChange::Type styleChange)
171 {
172   GetImplementation(*this).EmitStyleChangeSignal(styleChange);
173 }
174
175 StyleMonitor& StyleMonitor::operator=(const StyleMonitor& monitor)
176 {
177   if( *this != monitor )
178   {
179     BaseHandle::operator=(monitor);
180   }
181   return *this;
182 }
183
184 StyleMonitor::StyleMonitor(Internal::Adaptor::StyleMonitor* internal)
185 : BaseHandle(internal)
186 {
187 }
188
189 } // namespace Dali