Merge "Renaming PropertyBuffer to VertexBuffer" into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / event / events / key-event-impl.h
1 #ifndef DALI_INTERNAL_KEY_EVENT_H
2 #define DALI_INTERNAL_KEY_EVENT_H
3
4 /*
5  * Copyright (c) 2020 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 // INTERNAL INCLUDES
22 #include <dali/public-api/events/key-event.h>
23 #include <dali/public-api/object/base-object.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 class KeyEvent;
32 typedef IntrusivePtr< KeyEvent > KeyEventPtr;
33
34 /**
35  * @copydoc Dali::KeyEvent
36  */
37 class KeyEvent : public BaseObject
38 {
39 public:
40
41   /**
42    * @brief Default constructor.
43    */
44   KeyEvent();
45
46   /**
47    * @brief Constructor.
48    *
49    * @param[in]  keyName         The name of the key pressed or command from the IMF, if later then the some following parameters will be needed.
50    * @param[in]  logicalKey      The logical key symbol (eg. shift + 1 == "exclamation")
51    * @param[in]  keyString       The string of input characters or key pressed
52    * @param[in]  keyCode         The unique key code for the key pressed.
53    * @param[in]  keyModifier     The key modifier for special keys like shift and alt
54    * @param[in]  timeStamp       The time (in ms) that the key event occurred.
55    * @param[in]  keyState        The state of the key event.
56    * @param[in]  compose         The key compose
57    * @param[in]  deviceName      The name of device the key event originated from
58    * @param[in]  deviceClass     The class of device the key event originated from
59    * @param[in]  deviceSubclass  The subclass of device the key event originated from
60    */
61   KeyEvent( const std::string& keyName,
62             const std::string& logicalKey,
63             const std::string& keyString,
64             int keyCode,
65             int keyModifier,
66             unsigned long timeStamp,
67             const Dali::KeyEvent::State& keyState,
68             const std::string& compose,
69             const std::string& deviceName,
70             const Device::Class::Type deviceClass,
71             const Device::Subclass::Type deviceSubclass );
72
73   /**
74    * @brief Destructor.
75    */
76   ~KeyEvent();
77
78   /**
79    * Create a new KeyEvent.
80    *
81    * @param[in]  keyName         The name of the key pressed or command from the IMF, if later then the some following parameters will be needed.
82    * @param[in]  logicalKey      The logical key symbol (eg. shift + 1 == "exclamation")
83    * @param[in]  keyString       The string of input characters or key pressed
84    * @param[in]  keyCode         The unique key code for the key pressed.
85    * @param[in]  keyModifier     The key modifier for special keys like shift and alt
86    * @param[in]  timeStamp       The time (in ms) that the key event occurred.
87    * @param[in]  keyState        The state of the key event.
88    * @param[in]  compose         The key compose
89    * @param[in]  deviceName      The name of device the key event originated from
90    * @param[in]  deviceClass     The class of device the key event originated from
91    * @param[in]  deviceSubclass  The subclass of device the key event originated from
92    * @return A smart-pointer to the newly allocated KeyEvent.
93    */
94   static KeyEventPtr New( const std::string& keyName,
95                           const std::string& logicalKey,
96                           const std::string& keyString,
97                           int keyCode,
98                           int keyModifier,
99                           unsigned long timeStamp,
100                           const Dali::KeyEvent::State& keyState,
101                           const std::string& compose,
102                           const std::string& deviceName,
103                           const Device::Class::Type deviceClass,
104                           const Device::Subclass::Type deviceSubclass );
105
106   /**
107    * @copydoc Dali::KeyEvent::IsShiftModifier()
108    */
109   bool IsShiftModifier() const;
110
111   /**
112    * @copydoc Dali::KeyEvent::IsCtrlModifier()
113    */
114   bool IsCtrlModifier() const;
115
116   /**
117    * @copydoc Dali::KeyEvent::IsAltModifier()
118    */
119   bool IsAltModifier() const;
120
121   /**
122    * @copydoc Dali::KeyEvent::GetCompose()
123    */
124   const std::string& GetCompose() const;
125
126   /**
127    * @copydoc Dali::KeyEvent::GetDeviceName()
128    */
129   const std::string& GetDeviceName() const;
130
131   /**
132    * @copydoc Dali::KeyEvent::GetDeviceClass()
133    */
134   Device::Class::Type GetDeviceClass() const;
135
136   /**
137    * @copydoc Dali::KeyEvent::GetDeviceSubclass()
138    */
139   Device::Subclass::Type GetDeviceSubclass() const;
140
141   /**
142    * @copydoc Dali::KeyEvent::GetKeyName()
143    */
144   const std::string& GetKeyName() const;
145
146   /**
147    * @copydoc Dali::KeyEvent::GetKeyString()
148    */
149   const std::string& GetKeyString() const;
150
151   /**
152    * @copydoc Dali::KeyEvent::GetLogicalKey()
153    */
154   const std::string& GetLogicalKey() const;
155
156   /**
157    * @copydoc Dali::KeyEvent::GetKeyCode()
158    */
159   int32_t GetKeyCode() const;
160
161   /**
162    * @copydoc Dali::KeyEvent::GetKeyModifier()
163    */
164   int32_t GetKeyModifier() const;
165
166   /**
167    * @copydoc Dali::KeyEvent::GetTime()
168    */
169   unsigned long GetTime() const;
170
171   /**
172    * @copydoc Dali::KeyEvent::GetState()
173    */
174   Dali::KeyEvent::State GetState() const;
175
176   /**
177    * @brief Set the name given to the key pressed
178    *
179    * @param[in] keyName The name given to the key pressed.
180    */
181   void SetKeyName( const std::string& keyName );
182
183   /**
184    * @brief Set the actual string of input characters that should be used for input editors.
185    *
186    * @param[in] The actual string of input characters
187    */
188   void SetKeyString( const std::string& keyString );
189
190   /**
191    * @brief Set the unique key code for the key pressed.
192    *
193    * @param[in] keyCode The unique key code for the key pressed
194    */
195   void SetKeyCode( int32_t keyCode );
196
197   /**
198    * @brief Set the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed.
199    *
200    * @param[in] keyModifier The key modifier
201    */
202   void SetKeyModifier( int32_t keyModifier );
203
204   /**
205    * @brief Set the time (in ms) that the key event occurred.
206    *
207    * @param[in] time The time (in ms)
208    */
209   void SetTime( unsigned long time );
210
211   /**
212    * @brief Set the state of the key event.
213    *
214    * @param[in] state The state of the key event
215    */
216   void SetState( const Dali::KeyEvent::State& state );
217
218 private:
219
220   // Not copyable or movable
221
222   KeyEvent( const KeyEvent& rhs ) = delete;             ///< Deleted copy constructor
223   KeyEvent( KeyEvent&& rhs ) = delete;                  ///< Deleted move constructor
224   KeyEvent& operator=( const KeyEvent& rhs ) = delete;  ///< Deleted copy assignment operator
225   KeyEvent& operator=( KeyEvent&& rhs ) = delete;       ///< Deleted move assignment operator
226
227 private:
228
229   std::string mKeyName;                      ///< The name of the key pressed
230   std::string mLogicalKey;                   ///< The logical key symbol
231   std::string mKeyString;                    ///< The string of input characters
232   int  mKeyCode;                             ///< TThe unique key code
233   int  mKeyModifier;                         ///< The key modifier
234   unsigned long mTime;                       ///< The time that the key event occurred.
235   Dali::KeyEvent::State mState;              ///< The state of the key event.
236   std::string mCompose;                      ///< The key compose
237   std::string mDeviceName;                   ///< The name of device the key event originated from
238   Device::Class::Type mDeviceClass;          ///< The class of device the key event originated from
239   Device::Subclass::Type mDeviceSubclass;    ///< The subclass of device the key event originated from
240 };
241
242 } // namespace Internal
243
244 // Helpers for public-api forwarding methods
245
246 inline Internal::KeyEvent& GetImplementation( Dali::KeyEvent& keyEvent )
247 {
248   DALI_ASSERT_ALWAYS( keyEvent && "Key Event handle is empty" );
249
250   BaseObject& object = keyEvent.GetBaseObject();
251
252   return static_cast< Internal::KeyEvent& >( object );
253 }
254
255 inline const Internal::KeyEvent& GetImplementation( const Dali::KeyEvent& keyEvent )
256 {
257   DALI_ASSERT_ALWAYS( keyEvent && "Key Event handle is empty" );
258
259   const BaseObject& object = keyEvent.GetBaseObject();
260
261   return static_cast< const Internal::KeyEvent& >( object );
262 }
263
264 } // namespace Dali
265
266 #endif // DALI_INTERNAL_KEY_EVENT_H