fa8b24ca99b0c21e094e09dfab0075a700e1ccce
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / factory / localized-control-factory-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_LOCALIZED_CONTROL_FACTORY_H__
2 #define __DALI_TOOLKIT_INTERNAL_LOCALIZED_CONTROL_FACTORY_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // EXTERNAL INCLUDES
21 #include <string>
22 #include <set>
23
24 // INTERNAL INCLUDES
25 #include <dali/dali.h>
26 #include <dali-toolkit/public-api/factory/localized-control-factory.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36
37 /**
38  * @copydoc Toolkit::LocalizedControlFactory
39  */
40 class LocalizedControlFactory : public Dali::BaseObject, public ConnectionTracker
41 {
42 public:
43
44   /**
45    * Structure used to store/retrieve localisation info.
46    */
47   struct LocalisedStringInfo
48   {
49     LocalisedStringInfo()
50     {
51     }
52
53     LocalisedStringInfo(std::string id, std::string domain, std::string theme)
54     : textID(id),
55       textDomain(domain),
56       textViewTheme(theme)
57     {
58
59     }
60
61     std::string textID;
62     std::string textDomain;
63     std::string textViewTheme;
64   };
65
66   typedef std::map< const Dali::RefObject*, LocalisedStringInfo > ObjectEntriesContainer;
67   typedef ObjectEntriesContainer::iterator ObjectEntriesIterator;
68   typedef ObjectEntriesContainer::const_iterator ObjectEntriesConstIterator;
69
70   /**
71    * Construct a new LocalizedControlFactory.
72    */
73   LocalizedControlFactory();
74
75   /**
76    * @copydoc Toolkit::LocalizedControlFactory::CreateLocalizedTextView
77    */
78   Dali::Toolkit::TextView CreateLocalizedTextView( const std::string& textID, const std::string& textDomain, const std::string& textViewTheme );
79
80 protected:
81
82   /**
83    * Destructor
84    */
85   virtual ~LocalizedControlFactory();
86
87 private:
88
89   /**
90    * Callback for Object destructed signal.
91    * @param objectPointer Pointer to a RefObject
92    */
93   void OnObjectDestruction( const Dali::RefObject* objectPointer );
94
95   /**
96    * Callback for language changed signal.
97    * @param adaptor Reference to a Dali::Adaptor instance
98    */
99   void OnLanguageChanged( Dali::Adaptor& adaptor);
100
101 private:
102
103   // Undefined
104   LocalizedControlFactory(const LocalizedControlFactory&);
105   LocalizedControlFactory& operator=(const LocalizedControlFactory& rhs);
106
107 private:
108
109   ObjectEntriesContainer mObjectEntries;
110   bool mSignalsConnected:1;
111
112 };
113
114 } // namespace Internal
115
116 inline Internal::LocalizedControlFactory& GetImpl(Dali::Toolkit::LocalizedControlFactory& obj)
117 {
118   DALI_ASSERT_ALWAYS(obj);
119
120   Dali::BaseObject& handle = obj.GetBaseObject();
121
122   return static_cast<Internal::LocalizedControlFactory&>(handle);
123 }
124
125 inline const Internal::LocalizedControlFactory& GetImpl(const Dali::Toolkit::LocalizedControlFactory& obj)
126 {
127   DALI_ASSERT_ALWAYS(obj);
128
129   const Dali::BaseObject& handle = obj.GetBaseObject();
130
131   return static_cast<const Internal::LocalizedControlFactory&>(handle);
132 }
133
134 } // namespace Toolkit
135
136 } // namespace Dali
137
138 #endif // __DALI_TOOLKIT_INTERNAL_LOCALIZED_CONTROL_FACTORY_H__