1 #ifndef DALI_CLIPBOARD_H
2 #define DALI_CLIPBOARD_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
26 #include <dali/public-api/dali-adaptor-common.h>
30 namespace Internal DALI_INTERNAL
36 } // namespace DALI_INTERNAL
39 * @brief Interface to the device's clipboard.
41 * Clipboard class supports the copy and paste functionality for multi-window.
44 class DALI_ADAPTOR_API Clipboard : public BaseHandle
48 * @brief Structure that contains information about the clipboard data information.
52 ClipData(const char* mimeType = nullptr, const char* data = nullptr)
54 this->mimeType = mimeType;
57 void SetMimeType(const char* mimeType)
59 this->mimeType = mimeType;
61 const char* GetMimeType() const
65 void SetData(const char* data)
69 const char* GetData() const
75 const char* mimeType {nullptr}; ///< The mime type of clipboard data.
76 const char* data {nullptr}; ///< The clipboard data.
79 /// @brief Data send completed signal.
80 typedef Signal<void(const char*, const char*)> DataSentSignalType;
82 /// @brief Data receive completed signal.
83 typedef Signal<void(uint32_t, const char*, const char*)> DataReceivedSignalType;
85 /// @brief To catch data selection event.
86 typedef Signal<void(const char*)> DataSelectedSignalType;
89 * @brief Create an uninitialized Clipboard.
90 * this can be initialized with one of the derived Clipboard's New() methods
96 * This is non-virtual since derived Handle types must not contain data or virtual methods.
101 * @brief This constructor is used by Adaptor::GetClipboard().
102 * @param[in] clipboard A pointer to the clipboard.
104 explicit DALI_INTERNAL Clipboard(Internal::Adaptor::Clipboard* clipboard);
107 * @brief Retrieve a handle to the Clipboard instance.
108 * @return A handle to the Clipboard
110 static Clipboard Get();
113 * @brief Checks whether the clipboard is available.
114 * @return true if it is available, false otherwise.
116 static bool IsAvailable();
119 * @brief This signal is emitted when the data send complete.
121 * SetData() opertion does not follow a synchronous call.
122 * It follows the sequence below.
123 * SetData() -> EcoreEventDataSend() -> SendData() -> DataSentSignal() Emit
125 DataSentSignalType& DataSentSignal();
128 * @brief This signal is emitted when the data receive complete.
130 * GetData() opertion does not follow a synchronous call.
131 * It follows the sequence below.
132 * GetData() -> EcoreEventOfferDataReady() -> ReceiveData() -> DataReceivedSignal() Emit
134 DataReceivedSignalType& DataReceivedSignal();
137 * @brief This signal is emitted when the data seleted.
139 DataSelectedSignalType& DataSelectedSignal();
142 * @brief Check if there is data in the clipboard with a given mime type.
143 * @param[in] mimeType mime type to search for.
144 * @return bool true if there is data, otherwise false.
146 bool HasType(const std::string& mimeType);
149 * @brief Send the given data to the clipboard.
150 * @param[in] clipData data to send to the clipboard
151 * @return bool true if the internal clipboard sending was successful.
153 bool SetData(const ClipData& clipData);
156 * @brief Request data from the clipboard.
157 * @param[in] mimeType mime type of data to request.
158 * @return uint32_t Returns the data request id.
160 uint32_t GetData(const std::string& mimeType);
163 * @brief Returns the number of item currently in the clipboard.
164 * @return size_t number of clipboard items.
166 size_t NumberOfItems();
169 * @brief Show the clipboard window.
171 void ShowClipboard();
174 * @brief Hide the clipboard window.
176 void HideClipboard();
179 * @brief Retrieves the clipboard's visibility.
180 * @return bool true if the clipboard is visible.
182 bool IsVisible() const;
186 #endif // DALI_CLIPBOARD_H