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.
19 #include "clipboard-impl.h"
23 #include <Ecore_Wayland.h>
24 #include <dali/public-api/object/any.h>
25 #include <dali/public-api/object/type-registry.h>
26 #include <dali/integration-api/debug.h>
30 #include <singleton-service-impl.h>
32 #define CLIPBOARD_STR "CLIPBOARD_STR"
34 ///////////////////////////////////////////////////////////////////////////////////////////////////
36 ///////////////////////////////////////////////////////////////////////////////////////////////////
47 struct Clipboard::Impl
51 mBundle = bundle_create();
54 void SetItem(const char *data)
56 bundle_add_str(mBundle, CLIPBOARD_STR, data);
63 if ( bundle_get_count(mBundle) )
65 bundle_get_str(mBundle, CLIPBOARD_STR, &data);
72 return bundle_get_count(mBundle);
78 Clipboard::Clipboard(Impl* impl)
83 Clipboard::~Clipboard()
87 Dali::Clipboard Clipboard::Get()
89 Dali::Clipboard clipboard;
91 Dali::SingletonService service( SingletonService::Get() );
94 // Check whether the singleton is already created
95 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
98 // If so, downcast the handle
99 clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
103 Clipboard::Impl* impl( new Clipboard::Impl() );
104 clipboard = Dali::Clipboard( new Clipboard(impl) );
105 service.Register( typeid(Dali::Clipboard), clipboard );
112 bool Clipboard::SetItem(const std::string &itemData )
114 mImpl->SetItem( const_cast<char*>( itemData.c_str()) );
119 * Get string at given index of clipboard
121 std::string Clipboard::GetItem( unsigned int index ) // change string to a Dali::Text object.
123 std::string clipboardString(mImpl->GetItem());
124 return clipboardString;
128 * Get number of items in clipboard
130 unsigned int Clipboard::NumberOfItems()
132 return mImpl->GetCount();
136 * Show clipboard window
137 * Function to send message to show the Clipboard (cbhm) as no direct API available
138 * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
140 void Clipboard::ShowClipboard()
144 void Clipboard::HideClipboard()
149 } // namespace Adaptor
151 } // namespace Internal