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>
29 #include <singleton-service-impl.h>
31 namespace //unnamed namespace
33 const char* const CBHM_WINDOW = "CBHM_XWIN";
34 const char* const CBHM_MSG = "CBHM_MSG";
35 const char* const CBHM_ITEM = "CBHM_ITEM";
36 const char* const CBHM_cCOUNT = "CBHM_cCOUNT";
37 const char* const CBHM_ERROR = "CBHM_ERROR";
38 const char* const SET_ITEM = "SET_ITEM";
39 const char* const SHOW = "show0";
40 const char* const HIDE = "cbhm_hide";
43 ///////////////////////////////////////////////////////////////////////////////////////////////////
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
60 BaseHandle handle( Clipboard::Get() );
64 TypeRegistration CLIPBOARD_TYPE( typeid(Dali::Clipboard), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
66 } // unnamed namespace
68 Clipboard::~Clipboard()
72 Dali::Clipboard Clipboard::Get()
74 Dali::Clipboard clipboard;
76 Dali::SingletonService service( SingletonService::Get() );
79 // Check whether the singleton is already created
80 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
83 // If so, downcast the handle
84 clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
90 bool Clipboard::SetItem(const std::string &itemData )
96 * Get string at given index of clipboard
98 std::string Clipboard::GetItem( unsigned int index ) // change string to a Dali::Text object.
100 if ( index >= NumberOfItems() )
105 std::string emptyString( "" );
108 snprintf( sendBuf, 20, "%s%d", CBHM_ITEM, index );
113 * Get number of items in clipboard
115 unsigned int Clipboard::NumberOfItems()
123 * Show clipboard window
124 * Function to send message to show the Clipboard (cbhm) as no direct API available
125 * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
127 void Clipboard::ShowClipboard()
131 void Clipboard::HideClipboard()
136 } // namespace Adaptor
138 } // namespace Internal