[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / clipboard.h
1 #ifndef DALI_CLIPBOARD_H
2 #define DALI_CLIPBOARD_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/signals/dali-signal.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/dali-adaptor-common.h>
27
28 namespace Dali
29 {
30 namespace Internal DALI_INTERNAL
31 {
32 namespace Adaptor
33 {
34 class Clipboard;
35 }
36 } // namespace DALI_INTERNAL
37
38 /**
39  * @brief Interface to the device's clipboard.
40  *
41  * Clipboard class supports the copy and paste functionality for multi-window.
42  */
43
44 class DALI_ADAPTOR_API Clipboard : public BaseHandle
45 {
46 public:
47   /**
48    * @brief Structure that contains information about the clipboard data information.
49    */
50   struct ClipData
51   {
52     ClipData(const char* mimeType = nullptr, const char* data = nullptr)
53     {
54       this->mimeType = mimeType;
55       this->data     = data;
56     }
57     void SetMimeType(const char* mimeType)
58     {
59       this->mimeType = mimeType;
60     }
61     const char* GetMimeType() const
62     {
63       return mimeType;
64     }
65     void SetData(const char* data)
66     {
67       this->data = data;
68     }
69     const char* GetData() const
70     {
71       return data;
72     }
73
74   private:
75     const char* mimeType {nullptr}; ///< The mime type of clipboard data.
76     const char* data {nullptr};     ///< The clipboard data.
77   };
78
79   /// @brief Data send completed signal.
80   typedef Signal<void(const char*, const char*)> DataSentSignalType;
81
82   /// @brief Data receive completed signal.
83   typedef Signal<void(uint32_t, const char*, const char*)> DataReceivedSignalType;
84
85   /// @brief To catch data selection event.
86   typedef Signal<void(const char*)> DataSelectedSignalType;
87
88   /**
89    * @brief Create an uninitialized Clipboard.
90    * this can be initialized with one of the derived Clipboard's New() methods
91    */
92   Clipboard();
93
94   /**
95    * @brief Destructor
96    * This is non-virtual since derived Handle types must not contain data or virtual methods.
97    */
98   ~Clipboard();
99
100   /**
101    * @brief This constructor is used by Adaptor::GetClipboard().
102    * @param[in] clipboard A pointer to the clipboard.
103    */
104   explicit DALI_INTERNAL Clipboard(Internal::Adaptor::Clipboard* clipboard);
105
106   /**
107    * @brief Retrieve a handle to the Clipboard instance.
108    * @return A handle to the Clipboard
109    */
110   static Clipboard Get();
111
112   /**
113    * @brief Checks whether the clipboard is available.
114    * @return true if it is available, false otherwise.
115    */
116   static bool IsAvailable();
117
118   /**
119    * @brief This signal is emitted when the data send complete.
120    * @note
121    * SetData() opertion does not follow a synchronous call.
122    * It follows the sequence below.
123    * SetData() -> EcoreEventDataSend() -> SendData() -> DataSentSignal() Emit
124    */
125   DataSentSignalType& DataSentSignal();
126
127   /**
128    * @brief This signal is emitted when the data receive complete.
129    * @note
130    * GetData() opertion does not follow a synchronous call.
131    * It follows the sequence below.
132    * GetData() -> EcoreEventOfferDataReady() -> ReceiveData() -> DataReceivedSignal() Emit
133    */
134   DataReceivedSignalType& DataReceivedSignal();
135
136   /**
137    * @brief This signal is emitted when the data seleted.
138    */
139   DataSelectedSignalType& DataSelectedSignal();
140
141   /**
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.
145    */
146   bool HasType(const std::string& mimeType);
147
148   /**
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.
152    */
153   bool SetData(const ClipData& clipData);
154
155   /**
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.
159    */
160   uint32_t GetData(const std::string& mimeType);
161
162   /**
163    * @brief Returns the number of item currently in the clipboard.
164    * @return size_t number of clipboard items.
165    */
166   size_t NumberOfItems();
167
168   /**
169    * @brief Show the clipboard window.
170    */
171   void ShowClipboard();
172
173   /**
174    * @brief Hide the clipboard window.
175    */
176   void HideClipboard();
177
178   /**
179   * @brief Retrieves the clipboard's visibility.
180   * @return bool true if the clipboard is visible.
181   */
182   bool IsVisible() const;
183 };
184 } // namespace Dali
185
186 #endif // DALI_CLIPBOARD_H