Merge "Implemented the Handle assignment operators properly" into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / style-monitor.h
1 #ifndef __DALI_STYLE_MONITOR_H__
2 #define __DALI_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 /**
22  * @addtogroup CAPI_DALI_ADAPTOR_MODULE
23  * @{
24  */
25
26 // EXTERNAL INCLUDES
27 #include <boost/function.hpp>
28 #include <string>
29
30 #include <dali/public-api/object/base-handle.h>
31 #include <dali/public-api/signals/dali-signal-v2.h>
32
33 // INTERNAL INCLUDES
34 #include "style-change.h"
35
36 namespace Dali DALI_IMPORT_API
37 {
38
39 namespace Internal DALI_INTERNAL
40 {
41 namespace Adaptor
42 {
43 class StyleMonitor;
44 }
45 }
46
47 /**
48  * @brief Monitors the platform for style changes.
49  *
50  * This is a handle to the adaptor's style monitor which holds the platform's style information.
51  * It provides a signal when any aspect of the default style changes on the device.
52  * @see Adaptor::GetStyleMonitor
53  */
54 class StyleMonitor : public BaseHandle
55 {
56 public: // Typedefs
57
58   typedef SignalV2< void (StyleMonitor, StyleChange) > StyleChangeSignalV2;   ///< StyleChange Signal type
59
60 public: // Creation & Destruction
61
62   /**
63    * @brief Create an uninitialized StyleMonitor handle.
64    *
65    * Tthis can be set by retrieving the style monitor from the Adaptor
66    * or the Application classes.  Calling member functions when
67    * uninitialized is not allowed.
68    */
69   StyleMonitor();
70
71   /**
72    * @brief Creates a copy of the handle.
73    *
74    * The copy will point to the same implementation as the original.
75    * @param[in]  monitor  The Style Monitor to copy from.
76    */
77   StyleMonitor(const StyleMonitor& monitor);
78
79   /**
80    * @brief Retrieve the initialized instance of the StyleMonitor.
81    * @return Handle to StyleMonitor.
82    */
83   static StyleMonitor Get();
84
85   /**
86    * @brief Destructor
87    *
88    * This is non-virtual since derived Handle types must not contain data or virtual methods.
89    */
90   ~StyleMonitor();
91
92   /**
93    * @brief Downcast an Object handle to StyleMonitor handle.
94    *
95    * If handle points to a StyleMonitor object the downcast produces a
96    * valid handle. If not the returned handle is left uninitialized.
97    *
98    * @param[in] handle to An object @return handle to a Timer object
99    * or an uninitialized handle
100    */
101   static StyleMonitor DownCast( BaseHandle handle );
102
103 public: // Style Information
104
105   /**
106    * @brief Retrieves the default font family.
107    * @return The default font family.
108    */
109   std::string GetDefaultFontFamily() const;
110
111   /**
112    * @brief Retrieves the default font size
113    * @return The default font size.
114    */
115   float GetDefaultFontSize() const;
116
117   /**
118    * @brief Retrieves the user defined Theme.
119    * @return The user defined Theme.
120    */
121   const std::string& GetTheme() const;
122
123   /**
124    * @brief Sets an user defined Theme.
125    * @param[in] themeFilePath Path of the user defined theme
126    */
127   void SetTheme(const std::string& themeFilePath);
128
129 public: // Signals
130
131   /**
132    * @brief This signal is emitted whenever the style changes on the device.
133    *
134    * A callback of the following type may be connected:
135    * @code
136    *   void YourCallbackName(StyleMonitor styleMonitor, StyleChange change);
137    * @endcode
138    * @return The signal to connect to.
139    */
140   StyleChangeSignalV2& StyleChangeSignal();
141
142 public: // Operators
143
144   /**
145    * @brief Assignment operator.
146    *
147    * The handle points to the same implementation as the one being copied from.
148    * @param[in]  monitor  The Style Monitor to copy from.
149    * @return reference to this object
150    */
151   StyleMonitor& operator=(const StyleMonitor& monitor);
152
153   /**
154    * @brief This method is defined to allow assignment of the NULL value,
155    * and will throw an exception if passed any other value.
156    *
157    * Assigning to NULL is an alias for Reset().
158    * @param [in] rhs  A NULL pointer
159    * @return A reference to this handle
160    */
161   StyleMonitor& operator=(BaseHandle::NullType* rhs);
162
163 public: // Not intended for application developers
164   /**
165    * @brief This constructor is used internally to create a handle from an object pointer.
166    * @param [in] styleMonitor A pointer the internal style monitor.
167    */
168   explicit DALI_INTERNAL StyleMonitor(Internal::Adaptor::StyleMonitor* styleMonitor);
169 };
170
171 } // namespace Dali
172
173 /**
174  * @}
175  */
176 #endif // __DALI_STYLE_MONITOR_H__