Merge "Binding ecore_wl2_window_keyboard_grab and ecore_wl2_window_keyboard_ungrab...
[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   /**
86    * @brief Create an uninitialized Clipboard.
87    * this can be initialized with one of the derived Clipboard's New() methods
88    */
89   Clipboard();
90
91   /**
92    * @brief Destructor
93    * This is non-virtual since derived Handle types must not contain data or virtual methods.
94    */
95   ~Clipboard();
96
97   /**
98    * @brief This constructor is used by Adaptor::GetClipboard().
99    * @param[in] clipboard A pointer to the clipboard.
100    */
101   explicit DALI_INTERNAL Clipboard(Internal::Adaptor::Clipboard* clipboard);
102
103   /**
104    * @brief Retrieve a handle to the Clipboard instance.
105    * @return A handle to the Clipboard
106    */
107   static Clipboard Get();
108
109   /**
110    * @brief Checks whether the clipboard is available.
111    * @return true if it is available, false otherwise.
112    */
113   static bool IsAvailable();
114
115   /**
116    * @brief This signal is emitted when the data send complete.
117    * @note
118    * SetData() opertion does not follow a synchronous call.
119    * It follows the sequence below.
120    * SetData() -> EcoreEventDataSend() -> SendData() -> DataSentSignal() Emit
121    */
122   DataSentSignalType& DataSentSignal();
123
124   /**
125    * @brief This signal is emitted when the data receive complete.
126    * @note
127    * GetData() opertion does not follow a synchronous call.
128    * It follows the sequence below.
129    * GetData() -> EcoreEventOfferDataReady() -> ReceiveData() -> DataReceivedSignal() Emit
130    */
131   DataReceivedSignalType& DataReceivedSignal();
132
133   /**
134    * @brief Send the given data to the clipboard.
135    * @param[in] clipData data to send to the clipboard
136    * @return bool true if the internal clipboard sending was successful.
137    */
138   bool SetData(const ClipData& clipData);
139
140   /**
141    * @brief Request data from the clipboard.
142    * @param[in] mimeType mime type of data to request.
143    * @return uint32_t Returns the data request id.
144    */
145   uint32_t GetData(const std::string& mimeType);
146
147   /**
148    * @brief Returns the number of item currently in the clipboard.
149    * @return size_t number of clipboard items.
150    */
151   size_t NumberOfItems();
152
153   /**
154    * @brief Show the clipboard window.
155    */
156   void ShowClipboard();
157
158   /**
159    * @brief Hide the clipboard window.
160    */
161   void HideClipboard();
162
163   /**
164   * @brief Retrieves the clipboard's visibility.
165   * @return bool true if the clipboard is visible.
166   */
167   bool IsVisible() const;
168 };
169 } // namespace Dali
170
171 #endif // DALI_CLIPBOARD_H