Add post processor
[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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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
18 #include "toolkit-clipboard.h"
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/object/base-object.h>
22 #include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 namespace Adaptor
31 {
32
33 /**
34  * Implementation of the Clip Board
35  */
36
37 class Clipboard :  public Dali::BaseObject
38 {
39 public:
40
41   /**
42    * @copydoc Dali::ClipboardEventNotifier::Get()
43    */
44   static Dali::Clipboard Get();
45
46   /**
47    * Constructor
48    * @param[in] ecoreXwin, The window is created by application.
49    */
50   Clipboard(/*Ecore_X_Window ecoreXwin*/);
51   virtual ~Clipboard();
52
53   /**
54    * @copydoc Dali::Clipboard::SetItem()
55    */
56   bool SetItem(const std::string &itemData);
57
58   /**
59    * @copydoc Dali::Clipboard::RequestItem()
60    */
61   void RequestItem();
62
63   /**
64    * @copydoc Dali::Clipboard::NumberOfClipboardItems()
65    */
66   unsigned int NumberOfItems();
67
68   /**
69    * @copydoc Dali::Clipboard::ShowClipboard()
70    */
71   void ShowClipboard();
72
73   /**
74    * @copydoc Dali::Clipboard::HideClipboard()
75    */
76   void HideClipboard();
77
78   /**
79   * @copydoc Dali::Clipboard::IsVisible()
80   */
81   bool IsVisible() const;
82
83 private:
84   Clipboard( const Clipboard& );
85   Clipboard& operator=( Clipboard& );
86
87   static Dali::Clipboard mToolkitClipboard;
88   bool mVisible;
89   std::string mItem;
90   int mCount;
91 }; // class clipboard
92
93
94 Dali::Clipboard Dali::Internal::Adaptor::Clipboard::mToolkitClipboard;
95
96
97 Clipboard::Clipboard()
98 {
99   mVisible = false;
100   mCount = 0;
101 }
102
103 Clipboard::~Clipboard()
104 {
105 }
106
107 Dali::Clipboard Clipboard::Get()
108 {
109   if( ! mToolkitClipboard )
110   {
111     mToolkitClipboard = Dali::Clipboard( new Dali::Internal::Adaptor::Clipboard() );
112   }
113   return mToolkitClipboard;
114 }
115
116 bool Clipboard::SetItem(const std::string &itemData )
117 {
118   mItem = itemData;
119   mCount = 1;
120   return true;
121 }
122
123 void Clipboard::RequestItem()
124 {
125   Dali::ClipboardEventNotifier clipboardEventNotifier(Dali::ClipboardEventNotifier::Get());
126   if ( clipboardEventNotifier )
127   {
128     clipboardEventNotifier.SetContent( mItem );
129     clipboardEventNotifier.EmitContentSelectedSignal();
130   }
131 }
132
133 unsigned int Clipboard::NumberOfItems()
134 {
135   return mCount;
136 }
137
138 void Clipboard::ShowClipboard()
139 {
140   mVisible = true;
141 }
142
143 void Clipboard::HideClipboard()
144 {
145   mVisible = false;
146 }
147
148 bool Clipboard::IsVisible() const
149 {
150   return mVisible;
151 }
152
153 } // namespace Adaptor
154
155 } // namespace Internal
156
157
158 inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
159 {
160   // Bypass any passed in clipboard handle - it probably won't be initialized
161   Dali::Clipboard theClipboard = Dali::Clipboard::Get();
162   BaseObject& object = theClipboard.GetBaseObject();
163   return static_cast<Internal::Adaptor::Clipboard&>(object);
164 }
165
166 inline static const  Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
167 {
168   // Bypass any passed in clipboard handle - it probably won't be initialized
169   Dali::Clipboard theClipboard = Dali::Clipboard::Get();
170   const BaseObject& object = theClipboard.GetBaseObject();
171   return static_cast<const Internal::Adaptor::Clipboard&>(object);
172 }
173
174
175 Clipboard::Clipboard()
176 {
177 }
178 Clipboard::~Clipboard()
179 {
180 }
181 Clipboard::Clipboard(Internal::Adaptor::Clipboard *impl)
182   : BaseHandle(impl)
183 {
184 }
185
186 Clipboard Clipboard::Get()
187 {
188   return Internal::Adaptor::Clipboard::Get();
189 }
190 bool Clipboard::SetItem( const std::string &itemData)
191 {
192   return GetImplementation(*this).SetItem( itemData );
193 }
194
195 void Clipboard::RequestItem()
196 {
197   GetImplementation(*this).RequestItem();
198 }
199
200 unsigned int Clipboard::NumberOfItems()
201 {
202   return GetImplementation(*this).NumberOfItems();
203 }
204
205 void Clipboard::ShowClipboard()
206 {
207   GetImplementation(*this).ShowClipboard();
208 }
209
210 void Clipboard::HideClipboard()
211 {
212   GetImplementation(*this).HideClipboard();
213 }
214
215 bool Clipboard::IsVisible() const
216 {
217   return GetImplementation(*this).IsVisible();
218 }
219
220 } // namespace Dali