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/text-clipboard-event-notifier.h>
34 * Implementation of the Clip Board
37 class TextClipboard : public Dali::BaseObject
42 * @copydoc Dali::TextClipboardEventNotifier::Get()
44 static Dali::TextClipboard Get();
48 * @param[in] ecoreXwin, The window is created by application.
50 TextClipboard(/*Ecore_X_Window ecoreXwin*/);
51 virtual ~TextClipboard();
54 * @copydoc Dali::TextClipboard::IsAvailable()
56 static bool IsAvailable();
59 * @copydoc Dali::TextClipboard::SetItem()
61 bool SetItem(const std::string &itemData);
64 * @copydoc Dali::TextClipboard::RequestItem()
69 * @copydoc Dali::TextClipboard::NumberOfClipboardItems()
71 unsigned int NumberOfItems();
74 * @copydoc Dali::TextClipboard::ShowClipboard()
79 * @copydoc Dali::TextClipboard::HideClipboard()
84 * @copydoc Dali::TextClipboard::IsVisible()
86 bool IsVisible() const;
89 TextClipboard( const TextClipboard& );
90 TextClipboard& operator=( TextClipboard& );
92 static Dali::TextClipboard mToolkitClipboard;
96 }; // class TextClipboard
99 Dali::TextClipboard Dali::Internal::Adaptor::TextClipboard::mToolkitClipboard;
102 TextClipboard::TextClipboard()
108 TextClipboard::~TextClipboard()
112 Dali::TextClipboard TextClipboard::Get()
114 if( ! mToolkitClipboard )
116 mToolkitClipboard = Dali::TextClipboard( new Dali::Internal::Adaptor::TextClipboard() );
118 return mToolkitClipboard;
121 bool TextClipboard::IsAvailable()
123 if(mToolkitClipboard)
130 bool TextClipboard::SetItem(const std::string &itemData )
137 void TextClipboard::RequestItem()
139 Dali::TextClipboardEventNotifier clipboardEventNotifier(Dali::TextClipboardEventNotifier::Get());
140 if ( clipboardEventNotifier )
142 clipboardEventNotifier.SetContent( mItem );
143 clipboardEventNotifier.EmitContentSelectedSignal();
147 unsigned int TextClipboard::NumberOfItems()
152 void TextClipboard::ShowClipboard()
157 void TextClipboard::HideClipboard()
162 bool TextClipboard::IsVisible() const
167 } // namespace Adaptor
169 } // namespace Internal
172 inline static Internal::Adaptor::TextClipboard& GetImplementation(Dali::TextClipboard& clipboard)
174 // Bypass any passed in clipboard handle - it probably won't be initialized
175 Dali::TextClipboard theClipboard = Dali::TextClipboard::Get();
176 BaseObject& object = theClipboard.GetBaseObject();
177 return static_cast<Internal::Adaptor::TextClipboard&>(object);
180 inline static const Internal::Adaptor::TextClipboard& GetImplementation(const Dali::TextClipboard& clipboard)
182 // Bypass any passed in clipboard handle - it probably won't be initialized
183 Dali::TextClipboard theClipboard = Dali::TextClipboard::Get();
184 const BaseObject& object = theClipboard.GetBaseObject();
185 return static_cast<const Internal::Adaptor::TextClipboard&>(object);
189 TextClipboard::TextClipboard()
192 TextClipboard::~TextClipboard()
195 TextClipboard::TextClipboard(Internal::Adaptor::TextClipboard *impl)
200 TextClipboard TextClipboard::Get()
202 return Internal::Adaptor::TextClipboard::Get();
204 bool TextClipboard::SetItem( const std::string &itemData)
206 return GetImplementation(*this).SetItem( itemData );
209 void TextClipboard::RequestItem()
211 GetImplementation(*this).RequestItem();
214 unsigned int TextClipboard::NumberOfItems()
216 return GetImplementation(*this).NumberOfItems();
219 void TextClipboard::ShowClipboard()
221 GetImplementation(*this).ShowClipboard();
224 void TextClipboard::HideClipboard()
226 GetImplementation(*this).HideClipboard();
229 bool TextClipboard::IsVisible() const
231 return GetImplementation(*this).IsVisible();