075a37727cfcd30e3c502f7afc189e6275d5e34a
[platform/core/uifw/dali-adaptor.git] / adaptors / common / style-monitor-impl.h
1 #ifndef __DALI_INTERNAL_STYLE_MONITOR_H__
2 #define __DALI_INTERNAL_STYLE_MONITOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/integration-api/platform-abstraction.h>
25 #include <dali/devel-api/text-abstraction/font-client.h>
26
27 // INTERNAL INCLUDES
28 #include <style-monitor.h>
29
30 namespace Dali
31 {
32
33 namespace Internal
34 {
35
36 namespace Adaptor
37 {
38
39 /**
40  * This holds the platform's style information.
41  * It provides a signal when any aspect of the default style changes on the device.
42  */
43 class StyleMonitor : public BaseObject
44 {
45 public:
46
47   // Creation & Destruction
48
49   /**
50    * Constructor.
51    * @param[in]  platformAbstraction  The platform abstraction.
52    */
53   StyleMonitor(Integration::PlatformAbstraction& platformAbstraction);
54
55   /**
56    * Retrieve the initialized instance of the StyleMonitor.
57    * @return Handle to StyleMonitor.
58    */
59   static Dali::StyleMonitor Get();
60
61   // Style Change Notifications
62
63   /**
64    * Informs the Style Monitor that the style has changed.
65    * @param[in]  styleChange  The details of the change.
66    */
67   void StyleChanged( StyleChange::Type styleChange );
68
69   // Style Information
70
71   /**
72    * @copydoc Dali::StyleMonitor::GetDefaultFontFamily() const
73    */
74   std::string GetDefaultFontFamily() const;
75
76   /**
77    * @copydoc Dali::StyleMonitor::GetDefaultFontStyle() const
78    */
79   std::string GetDefaultFontStyle() const;
80
81   /**
82    * @copydoc Dali::StyleMonitor::GetDefaultFontSize() const
83    */
84   int GetDefaultFontSize() const;
85
86   /**
87    * @copydoc Dali::StyleMonitor::GetTheme() const
88    */
89   const std::string& GetTheme() const;
90
91   /**
92    * @copydoc Dali::StyleMonitor::SetTheme()
93    */
94   void SetTheme(const std::string& themeFilePath);
95
96   /**
97    * @copydoc Dali::StyleMonitor::LoadThemeFile()
98    */
99   bool LoadThemeFile( const std::string& filename, std::string& output );
100
101   /**
102    * @copydoc Dali::StyleMonitor::GetResourcePath()
103    */
104   std::string GetAppResourcePath();
105
106   // Signals
107
108   /**
109    * @copydoc Dali::StyleMonitor::StyleChangeSignal()
110    */
111   Dali::StyleMonitor::StyleChangeSignalType& StyleChangeSignal();
112
113 protected:
114
115   /**
116    * Virtual Destructor.
117    */
118   virtual ~StyleMonitor();
119
120 private:
121
122   /**
123    * Emit the style change signal.
124    * @param[in]  styleChange  The details of the style change
125    */
126   inline void EmitStyleChangeSignal( StyleChange::Type styleChange );
127
128 private:
129
130   Dali::StyleMonitor::StyleChangeSignalType mStyleChangeSignal; ///< Emitted when the style changes
131
132   Integration::PlatformAbstraction& mPlatformAbstraction; ///< Reference to the PlatformAbstraction (for retrieving defaults)
133
134   TextAbstraction::FontClient mFontClient;
135   std::string mDefaultFontFamily;        ///< The system default font family
136   std::string mDefaultFontStyle;         ///< The default font style
137   std::string mUserDefinedThemeFilePath; ///< String containing the user defined theme file path
138   int mDefaultFontSize;                  ///< The default accessibility font size e.g. 0 is smallest
139 };
140
141 } // namespace Adaptor
142
143 } // namespace Internal
144
145 // Additional Helpers for public-api forwarding methods
146
147 inline Internal::Adaptor::StyleMonitor& GetImplementation(Dali::StyleMonitor& monitor)
148 {
149   DALI_ASSERT_ALWAYS(monitor && "Monitor handle is empty");
150   BaseObject& handle = monitor.GetBaseObject();
151   return static_cast<Internal::Adaptor::StyleMonitor&>(handle);
152 }
153
154 inline const Internal::Adaptor::StyleMonitor& GetImplementation(const Dali::StyleMonitor& monitor)
155 {
156   DALI_ASSERT_ALWAYS(monitor && "Monitor handle is empty");
157   const BaseObject& handle = monitor.GetBaseObject();
158   return static_cast<const Internal::Adaptor::StyleMonitor&>(handle);
159 }
160
161 } // namespace Dali
162
163 #endif // __DALI_INTERNAL_STYLE_MONITOR_H__