2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "toolkit-clipboard.h"
21 #include <dali/public-api/object/base-object.h>
33 * Implementation of the Clipboard
36 class Clipboard : public Dali::BaseObject
41 * @copydoc Dali::ClipboardEventNotifier::Get()
43 static Dali::Clipboard Get();
47 * @param[in] ecoreXwin, The window is created by application.
49 Clipboard(/*Ecore_X_Window ecoreXwin*/);
53 * @copydoc Dali::Clipboard::IsAvailable()
55 static bool IsAvailable();
58 * @copydoc Dali::Clipboard::DataSentSignal()
60 Dali::Clipboard::DataSentSignalType& DataSentSignal();
63 * @copydoc Dali::Clipboard::DataReceivedSignal()
65 Dali::Clipboard::DataReceivedSignalType& DataReceivedSignal();
68 * @copydoc Dali::Clipboard::SetData()
70 bool SetData(const Dali::Clipboard::ClipData& clipData);
73 * @copydoc Dali::Clipboard::GetData()
75 uint32_t GetData(const std::string &mimeType);
78 * @copydoc Dali::Clipboard::NumberOfClipboardItems()
80 size_t NumberOfItems();
83 * @copydoc Dali::Clipboard::ShowClipboard()
88 * @copydoc Dali::Clipboard::HideClipboard()
93 * @copydoc Dali::Clipboard::IsVisible()
95 bool IsVisible() const;
98 Clipboard( const Clipboard& );
99 Clipboard& operator=( Clipboard& );
101 static Dali::Clipboard mToolkitClipboard;
104 std::string mMimeType;
109 Dali::Clipboard::DataSentSignalType mDataSentSignal;
110 Dali::Clipboard::DataReceivedSignalType mDataReceivedSignal;
111 }; // class clipboard
114 Dali::Clipboard Dali::Internal::Adaptor::Clipboard::mToolkitClipboard;
117 Clipboard::Clipboard()
123 Clipboard::~Clipboard()
127 Dali::Clipboard Clipboard::Get()
129 if(!mToolkitClipboard)
131 mToolkitClipboard = Dali::Clipboard(new Dali::Internal::Adaptor::Clipboard());
133 return mToolkitClipboard;
136 bool Clipboard::IsAvailable()
138 if(mToolkitClipboard)
145 Dali::Clipboard::DataSentSignalType& Clipboard::DataSentSignal()
147 return mDataSentSignal;
150 Dali::Clipboard::DataReceivedSignalType& Clipboard::DataReceivedSignal()
152 return mDataReceivedSignal;
155 bool Clipboard::SetData(const Dali::Clipboard::ClipData& clipData)
157 mMimeType = clipData.GetMimeType();
158 mData = clipData.GetData();
166 mDataSentSignal.Emit(mMimeType.c_str(), mData.c_str());
171 uint32_t Clipboard::GetData(const std::string &mimeType)
173 if(!mMimeType.compare(mimeType.c_str()))
176 mDataReceivedSignal.Emit(mDataId, mMimeType.c_str(), mData.c_str());
182 size_t Clipboard::NumberOfItems()
187 void Clipboard::ShowClipboard()
192 void Clipboard::HideClipboard()
197 bool Clipboard::IsVisible() const
202 } // namespace Adaptor
204 } // namespace Internal
207 inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
209 // Bypass any passed in clipboard handle - it probably won't be initialized
210 Dali::Clipboard theClipboard = Dali::Clipboard::Get();
211 BaseObject& object = theClipboard.GetBaseObject();
212 return static_cast<Internal::Adaptor::Clipboard&>(object);
215 inline static const Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
217 // Bypass any passed in clipboard handle - it probably won't be initialized
218 Dali::Clipboard theClipboard = Dali::Clipboard::Get();
219 const BaseObject& object = theClipboard.GetBaseObject();
220 return static_cast<const Internal::Adaptor::Clipboard&>(object);
224 Clipboard::Clipboard()
227 Clipboard::~Clipboard()
230 Clipboard::Clipboard(Internal::Adaptor::Clipboard *impl)
235 Clipboard Clipboard::Get()
237 return Internal::Adaptor::Clipboard::Get();
240 size_t Clipboard::NumberOfItems()
242 return GetImplementation(*this).NumberOfItems();
245 void Clipboard::ShowClipboard()
247 GetImplementation(*this).ShowClipboard();
250 void Clipboard::HideClipboard()
252 GetImplementation(*this).HideClipboard();
255 bool Clipboard::IsVisible() const
257 return GetImplementation(*this).IsVisible();