[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-clipboard.h
1 #ifndef  TOOLKIT_CLIPBOARD_H
2 #define  TOOLKIT_CLIPBOARD_H
3
4 /*
5  * Copyright (c) 2019 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 #define DALI_CLIPBOARD_H
22
23 // EXTERNAL INCLUDES
24 #include <dali/public-api/math/rect.h>
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/public-api/signals/dali-signal.h>
27
28 namespace Dali DALI_IMPORT_API
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33
34 namespace Adaptor
35 {
36 class Clipboard;
37 }
38 }
39
40 /**
41  * The Clipboard can operate using various funtion.
42  * Clipboard can manage it's item and set show / hide status.
43  */
44 class 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 clip data.
76     const char* data {nullptr};     ///< The clip 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   /**
87    * Create an uninitialized Clipboard;
88    *  this can be initialized with one of the derived Clipboard' New() methods
89    */
90   Clipboard();
91
92   /**
93    * Non virtual destructor.
94    */
95   ~Clipboard();
96
97   /**
98    * This constructor is used by Adaptor::GetClipboard().
99    * @param[in] clipboard A pointer to the clipboard.
100    */
101   Clipboard(Internal::Adaptor::Clipboard* clipboard);
102
103   /**
104    * Retrieve a handle to the ClipboardEventNotifier 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 Check if there is data in the clipboard with a given mime type.
135    * @param[in] mimeType mime type to search for.
136    * @return bool true if there is data, otherwise false.
137    */
138   bool HasType(const std::string& mimeType);
139
140   /**
141    * @brief Send the given data to the clipboard.
142    * @param[in] clipData data to send to the clipboard
143    * @return bool true if the internal clipboard sending was successful.
144    */
145   bool SetData(const ClipData& clipData);
146
147   /**
148    * @brief Request data from the clipboard.
149    * @param[in] mimeType mime type of data to request.
150    * @return uint32_t Returns the data request id.
151    */
152   uint32_t GetData(const std::string& mimeType);
153
154   /**
155    * @brief Returns the number of item currently in the clipboard.
156    * @return size_t number of clipboard items.
157    */
158   size_t NumberOfItems();
159
160   /**
161    * Show the clipboard window
162    */
163   void ShowClipboard();
164
165   /**
166    * Hide the clipboard window
167    */
168   void HideClipboard();
169
170   /**
171   * @brief Retrieves the clipboard's visibility
172   * @return bool true if the clipboard is visible.
173   */
174   bool IsVisible() const;
175
176 };
177 } // namespace Dali
178
179 #endif // TOOLKIT_CLIPBOARD_H