Merge "Ensure join of font thread" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / text-clipboard / common / text-clipboard-event-notifier-impl.h
1 #ifndef DALI_INTERNAL_TEXT_CLIPBOARD_EVENT_NOTIFIER_H
2 #define DALI_INTERNAL_TEXT_CLIPBOARD_EVENT_NOTIFIER_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/math/vector2.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <string>
25
26 // INTERNAL INCLUDES
27 #include <dali/devel-api/adaptor-framework/text-clipboard-event-notifier.h>
28 #include <dali/public-api/dali-adaptor-common.h>
29
30 namespace Dali
31 {
32 namespace Internal
33 {
34 namespace Adaptor
35 {
36 /**
37  * This class listens to TextClipboard events.
38  */
39 class TextClipboardEventNotifier : public Dali::BaseObject
40 {
41 public:
42   typedef Dali::TextClipboardEventNotifier::TextClipboardEventSignalType TextClipboardEventSignalType;
43
44   // Creation
45
46   /**
47    * Create a TextClipboardEventNotifier.
48    * @return A newly allocated text-clipboard-event-notifier.
49    */
50   static Dali::TextClipboardEventNotifier New();
51
52   /**
53    * @copydoc Dali::TextClipboardEventNotifier::Get()
54    */
55   static Dali::TextClipboardEventNotifier Get();
56
57   // Public API
58
59   /**
60    * @copydoc Dali::TextClipboardEventNotifier::GetContent() const
61    */
62   const std::string& GetContent() const;
63
64   /**
65    * Sets the selected content.
66    * @param[in] content  A string that represents the content that has been selected.
67    */
68   void SetContent(const std::string& content);
69
70   /**
71    * Clears the stored content.
72    */
73   void ClearContent();
74
75   /**
76    * Called when content is selected in the clipboard.
77    */
78   void EmitContentSelectedSignal();
79
80 public: // Signals
81   /**
82    * @copydoc Dali::TextClipboardEventNotifier::ContentSelectedSignal
83    */
84   TextClipboardEventSignalType& ContentSelectedSignal()
85   {
86     return mContentSelectedSignal;
87   }
88
89 private:
90   // Construction & Destruction
91
92   /**
93    * Constructor.
94    */
95   TextClipboardEventNotifier();
96
97   /**
98    * Destructor.
99    */
100   ~TextClipboardEventNotifier() override;
101
102   // Undefined
103   TextClipboardEventNotifier(const TextClipboardEventNotifier&);
104   TextClipboardEventNotifier& operator=(TextClipboardEventNotifier&);
105
106 private:
107   std::string mContent; ///< The current selected content.
108
109   TextClipboardEventSignalType mContentSelectedSignal;
110
111 public:
112   // Helpers for public-api forwarding methods
113
114   inline static Internal::Adaptor::TextClipboardEventNotifier& GetImplementation(Dali::TextClipboardEventNotifier& detector)
115   {
116     DALI_ASSERT_ALWAYS(detector && "TextClipboardEventNotifier handle is empty");
117
118     BaseObject& handle = detector.GetBaseObject();
119
120     return static_cast<Internal::Adaptor::TextClipboardEventNotifier&>(handle);
121   }
122
123   inline static const Internal::Adaptor::TextClipboardEventNotifier& GetImplementation(const Dali::TextClipboardEventNotifier& detector)
124   {
125     DALI_ASSERT_ALWAYS(detector && "TextClipboardEventNotifier handle is empty");
126
127     const BaseObject& handle = detector.GetBaseObject();
128
129     return static_cast<const Internal::Adaptor::TextClipboardEventNotifier&>(handle);
130   }
131 };
132
133 } // namespace Adaptor
134
135 } // namespace Internal
136
137 } // namespace Dali
138
139 #endif // DALI_INTERNAL_TEXT_CLIPBOARD_EVENT_NOTIFIER_H