Merge "(Orientation) Move to devel-api" into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / devel-api / adaptor-framework / style-monitor.h
1 #ifndef __DALI_STYLE_MONITOR_H__
2 #define __DALI_STYLE_MONITOR_H__
3
4 /*
5  * Copyright (c) 2015 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 <string>
23
24 #include <dali/public-api/object/base-handle.h>
25 #include <dali/public-api/signals/dali-signal.h>
26
27 // INTERNAL INCLUDES
28 #ifdef DALI_ADAPTOR_COMPILATION  // full path doesn't exist until adaptor is installed so we have to use relative
29 // @todo Make dali-adaptor code folder structure mirror the folder structure installed to dali-env
30 #include <style-change.h>
31 #else
32 #include <dali/public-api/adaptor-framework/style-change.h>
33 #endif
34
35 namespace Dali
36 {
37
38 namespace Internal DALI_INTERNAL
39 {
40 namespace Adaptor
41 {
42 class StyleMonitor;
43 }
44 }
45
46 /**
47  * @brief Monitors the platform for style changes.
48  *
49  * This is a handle to the adaptor's style monitor which holds the platform's style information.
50  * It provides a signal when any aspect of the default style changes on the device.
51  * @see Adaptor::GetStyleMonitor
52  */
53 class DALI_IMPORT_API StyleMonitor : public BaseHandle
54 {
55 public: // Typedefs
56
57   typedef Signal< void ( StyleMonitor, StyleChange::Type ) > StyleChangeSignalType;   ///< StyleChange Signal type
58
59 public: // Creation & Destruction
60
61   /**
62    * @brief Create an uninitialized StyleMonitor handle.
63    *
64    * Tthis can be set by retrieving the style monitor from the Adaptor
65    * or the Application classes.  Calling member functions when
66    * uninitialized is not allowed.
67    */
68   StyleMonitor();
69
70   /**
71    * @brief Creates a copy of the handle.
72    *
73    * The copy will point to the same implementation as the original.
74    * @param[in]  monitor  The Style Monitor to copy from.
75    */
76   StyleMonitor(const StyleMonitor& monitor);
77
78   /**
79    * @brief Retrieve the initialized instance of the StyleMonitor.
80    * @return Handle to StyleMonitor.
81    */
82   static StyleMonitor Get();
83
84   /**
85    * @brief Destructor
86    *
87    * This is non-virtual since derived Handle types must not contain data or virtual methods.
88    */
89   ~StyleMonitor();
90
91   /**
92    * @brief Downcast an Object handle to StyleMonitor handle.
93    *
94    * If handle points to a StyleMonitor object the downcast produces a
95    * valid handle. If not the returned handle is left uninitialized.
96    *
97    * @param[in] handle to An object @return handle to a Timer object
98    * or an uninitialized handle
99    */
100   static StyleMonitor DownCast( BaseHandle handle );
101
102 public: // Style Information
103
104   /**
105    * @brief Retrieves the default font family.
106    * @return The default font family.
107    */
108   std::string GetDefaultFontFamily() const;
109
110   /**
111    * @brief Retrieves the default font style.
112    * @return The default font style.
113    */
114   std::string GetDefaultFontStyle() const;
115
116   /**
117    * @brief Retrieves the default font size.
118    *
119    * This is an logical size, which is mapped to a UI Control specific point-size in stylesheets.
120    * For example if zero the smallest size, this could potentially map to TextLabel point-size 8.
121    * @return The default font size, or a negative value if not set.
122    */
123   int GetDefaultFontSize() const;
124
125   /**
126    * @brief Retrieves the user defined Theme.
127    * @return The user defined Theme.
128    */
129   const std::string& GetTheme() const;
130
131   /**
132    * @brief Sets an user defined Theme.
133    * @param[in] themeFilePath Path of the user defined theme
134    */
135   void SetTheme(const std::string& themeFilePath);
136
137   /**
138    * @brief Utility to load a theme file
139    * @param filename of the theme
140    * @param output to write the contents to
141    * @return true if the load is successful
142    */
143   bool LoadThemeFile( const std::string& filename, std::string& output );
144
145 public: // Signals
146
147   /**
148    * @brief This signal is emitted whenever the style changes on the device.
149    *
150    * A callback of the following type may be connected:
151    * @code
152    *   void YourCallbackName(StyleMonitor styleMonitor, StyleChange change);
153    * @endcode
154    * @return The signal to connect to.
155    */
156   StyleChangeSignalType& StyleChangeSignal();
157
158 public: // Operators
159
160   /**
161    * @brief Assignment operator.
162    *
163    * The handle points to the same implementation as the one being copied from.
164    * @param[in]  monitor  The Style Monitor to copy from.
165    * @return reference to this object
166    */
167   StyleMonitor& operator=(const StyleMonitor& monitor);
168
169 public: // Not intended for application developers
170   /**
171    * @brief This constructor is used internally to create a handle from an object pointer.
172    * @param [in] styleMonitor A pointer the internal style monitor.
173    */
174   explicit DALI_INTERNAL StyleMonitor(Internal::Adaptor::StyleMonitor* styleMonitor);
175 };
176
177 } // namespace Dali
178
179 #endif // __DALI_STYLE_MONITOR_H__