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>
22 #include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
34 * Implementation of the Clip Board
37 class Clipboard : public Dali::BaseObject
42 * @copydoc Dali::ClipboardEventNotifier::Get()
44 static Dali::Clipboard Get();
48 * @param[in] ecoreXwin, The window is created by application.
50 Clipboard(/*Ecore_X_Window ecoreXwin*/);
54 * @copydoc Dali::Clipboard::SetItem()
56 bool SetItem(const std::string &itemData);
59 * @copydoc Dali::Clipboard::RequestItem()
64 * @copydoc Dali::Clipboard::NumberOfClipboardItems()
66 unsigned int NumberOfItems();
69 * @copydoc Dali::Clipboard::ShowClipboard()
74 * @copydoc Dali::Clipboard::HideClipboard()
79 * @copydoc Dali::Clipboard::IsVisible()
81 bool IsVisible() const;
84 Clipboard( const Clipboard& );
85 Clipboard& operator=( Clipboard& );
87 static Dali::Clipboard mToolkitClipboard;
94 Dali::Clipboard Dali::Internal::Adaptor::Clipboard::mToolkitClipboard;
97 Clipboard::Clipboard()
103 Clipboard::~Clipboard()
107 Dali::Clipboard Clipboard::Get()
109 if( ! mToolkitClipboard )
111 mToolkitClipboard = Dali::Clipboard( new Dali::Internal::Adaptor::Clipboard() );
113 return mToolkitClipboard;
116 bool Clipboard::SetItem(const std::string &itemData )
123 void Clipboard::RequestItem()
125 Dali::ClipboardEventNotifier clipboardEventNotifier(Dali::ClipboardEventNotifier::Get());
126 if ( clipboardEventNotifier )
128 clipboardEventNotifier.SetContent( mItem );
129 clipboardEventNotifier.EmitContentSelectedSignal();
133 unsigned int Clipboard::NumberOfItems()
138 void Clipboard::ShowClipboard()
143 void Clipboard::HideClipboard()
148 bool Clipboard::IsVisible() const
153 } // namespace Adaptor
155 } // namespace Internal
158 inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
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);
166 inline static const Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
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);
175 Clipboard::Clipboard()
178 Clipboard::~Clipboard()
181 Clipboard::Clipboard(Internal::Adaptor::Clipboard *impl)
186 Clipboard Clipboard::Get()
188 return Internal::Adaptor::Clipboard::Get();
190 bool Clipboard::SetItem( const std::string &itemData)
192 return GetImplementation(*this).SetItem( itemData );
195 void Clipboard::RequestItem()
197 GetImplementation(*this).RequestItem();
200 unsigned int Clipboard::NumberOfItems()
202 return GetImplementation(*this).NumberOfItems();
205 void Clipboard::ShowClipboard()
207 GetImplementation(*this).ShowClipboard();
210 void Clipboard::HideClipboard()
212 GetImplementation(*this).HideClipboard();
215 bool Clipboard::IsVisible() const
217 return GetImplementation(*this).IsVisible();