bf347d509760008c9c2a330f57d63d174b8f073b
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-clipboard.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 #include "toolkit-clipboard.h"
18
19 // EXTERNAL INCLUDES
20 #include <dali/public-api/object/base-object.h>
21
22
23 namespace Dali
24 {
25
26 namespace Internal
27 {
28
29 namespace Adaptor
30 {
31
32 /**
33  * Implementation of the Clip Board
34  */
35
36 class Clipboard :  public Dali::BaseObject
37 {
38 public:
39
40   /**
41    * @copydoc Dali::ClipboardEventNotifier::Get()
42    */
43   static Dali::Clipboard Get();
44
45   /**
46    * Constructor
47    * @param[in] ecoreXwin, The window is created by application.
48    */
49   Clipboard(/*Ecore_X_Window ecoreXwin*/);
50   virtual ~Clipboard();
51
52   /**
53    * @copydoc Dali::Clipboard::SetItem()
54    */
55   bool SetItem(const std::string &itemData);
56
57   /**
58    * @copydoc Dali::Clipboard::GetItem()
59    */
60   std::string GetItem( unsigned int index );
61
62   /**
63    * @copydoc Dali::Clipboard::NumberOfClipboardItems()
64    */
65   unsigned int NumberOfItems();
66
67   /**
68    * @copydoc Dali::Clipboard::ShowClipboard()
69    */
70   void ShowClipboard();
71
72   /**
73    * @copydoc Dali::Clipboard::HideClipboard()
74    */
75   void HideClipboard();
76
77
78 private:
79   Clipboard( const Clipboard& );
80   Clipboard& operator=( Clipboard& );
81
82   static Dali::Clipboard mToolkitClipboard;
83 }; // class clipboard
84
85
86 Dali::Clipboard Dali::Internal::Adaptor::Clipboard::mToolkitClipboard;
87
88
89 Clipboard::Clipboard( /*Ecore_X_Window ecoreXwin*/)
90 {
91 }
92
93 Clipboard::~Clipboard()
94 {
95 }
96
97 Dali::Clipboard Clipboard::Get()
98 {
99   if( ! mToolkitClipboard )
100   {
101     mToolkitClipboard = Dali::Clipboard( new Dali::Internal::Adaptor::Clipboard() );
102   }
103   return mToolkitClipboard;
104 }
105
106 bool Clipboard::SetItem(const std::string &itemData )
107 {
108   return true;
109 }
110
111 std::string Clipboard::GetItem( unsigned int index )
112 {
113   return "";
114 }
115
116 unsigned int Clipboard::NumberOfItems()
117 {
118   return 0;
119 }
120
121 void Clipboard::ShowClipboard()
122 {
123 }
124
125 void Clipboard::HideClipboard()
126 {
127 }
128
129
130 } // namespace Adaptor
131
132 } // namespace Internal
133
134
135 inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
136 {
137   // Bypass any passed in clipboard handle - it probably won't be initialized
138   Dali::Clipboard theClipboard = Dali::Clipboard::Get();
139   BaseObject& object = theClipboard.GetBaseObject();
140   return static_cast<Internal::Adaptor::Clipboard&>(object);
141 }
142
143 inline static const  Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
144 {
145   // Bypass any passed in clipboard handle - it probably won't be initialized
146   Dali::Clipboard theClipboard = Dali::Clipboard::Get();
147   const BaseObject& object = theClipboard.GetBaseObject();
148   return static_cast<const Internal::Adaptor::Clipboard&>(object);
149 }
150
151
152 Clipboard::Clipboard()
153 {
154 }
155 Clipboard::~Clipboard()
156 {
157 }
158 Clipboard::Clipboard(Internal::Adaptor::Clipboard *impl)
159   : BaseHandle(impl)
160 {
161 }
162
163 Clipboard Clipboard::Get()
164 {
165   return Internal::Adaptor::Clipboard::Get();
166 }
167 bool Clipboard::SetItem( const std::string &itemData)
168 {
169   return GetImplementation(*this).SetItem( itemData );
170 }
171
172 std::string Clipboard::GetItem( unsigned int index )
173 {
174   return GetImplementation(*this).GetItem( index );
175 }
176
177 unsigned int Clipboard::NumberOfItems()
178 {
179   return GetImplementation(*this).NumberOfItems();
180 }
181
182 void Clipboard::ShowClipboard()
183 {
184   GetImplementation(*this).ShowClipboard();
185 }
186
187 void Clipboard::HideClipboard()
188 {
189   GetImplementation(*this).HideClipboard();
190 }
191
192 } // namespace Dali