Merge "stop using double variant of pow" into tizen
[platform/core/uifw/dali-core.git] / dali / public-api / events / key-event.h
1 #ifndef __DALI_KEY_EVENT_H__
2 #define __DALI_KEY_EVENT_H__
3
4 /*
5  * Copyright (c) 2014 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 <string>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/dali-common.h>
26
27 namespace Dali
28 {
29
30 /**
31  * @brief The key event structure is used to store a key press.
32  *
33  * It facilitates processing of these key presses and passing to other
34  * libraries like Toolkit. The keyString is the actual character you
35  * might want to display while the key name is just a descriptive
36  * name.  There is a key modifier which relates to keys like alt,
37  * shift and control functions are supplied to check if they have been
38  * pressed.
39  *
40  * Currently KeyEvent is also being used to relay messages from the
41  * IMF keyboard to Core. In future IMF may communicate via its own
42  * module.
43  */
44 struct DALI_IMPORT_API KeyEvent
45 {
46   // Enumerations
47
48   /**
49    * @brief Specifies the state of the key event.
50    */
51   enum State
52   {
53     Down,        ///< Key down
54     Up,          ///< Key up
55     Last
56   };
57
58   /**
59    * @brief Default constructor
60    */
61   KeyEvent();
62
63   /**
64    * @brief Constructor.
65    *
66    * @param[in]  keyName       The name of the key pressed or command from the IMF, if later then the some following parameters will be needed.
67    * @param[in]  keyString     A string of input characters or key pressed
68    * @param[in]  keyCode       The unique key code for the key pressed.
69    * @param[in]  keyModifier   The key modifier for special keys like shift and alt
70    * @param[in]  timeStamp The time (in ms) that the key event occurred.
71    * @param[in]  keyState The state of the key event.
72    */
73   KeyEvent(const std::string& keyName, const std::string& keyString, int keyCode, int keyModifier, unsigned long timeStamp, const State& keyState);
74
75   /**
76    * @brief Destructor.
77    */
78   ~KeyEvent();
79
80   /**
81    * @brief Check to see if Shift key modifier has been supplied.
82    *
83    * @return bool true if shift modifier
84    */
85   bool IsShiftModifier() const;
86
87   /**
88    * @brief Check to see if Ctrl (control) key modifier has been supplied.
89    *
90    * @return bool true if ctrl modifier
91    */
92   bool IsCtrlModifier() const;
93
94   /**
95    * @brief Check to see if Alt key modifier has been supplied.
96    *
97    * @return bool true if alt modifier
98    */
99   bool IsAltModifier() const;
100
101   // Data
102
103   /**
104    * @brief name given to the key pressed.
105    */
106   std::string keyPressedName;
107
108   /**
109    * @brief The actual string returned that should be used for input editors.
110    */
111   std::string keyPressed;
112
113   /**
114    * @brief Keycode for the key pressed.
115    */
116   int  keyCode;
117
118   /**
119    * @brief special keys like shift, alt and control which modify the next key pressed.
120    */
121   int  keyModifier;
122
123   /**
124    * @brief The time (in ms) that the key event occurred.
125    */
126   unsigned long time;
127
128   /**
129    * @brief State of the key event.
130    *
131    * @see State
132    */
133   State state;
134
135 };
136
137 } // namespace Dali
138
139 #endif // __DALI_KEY_EVENT_H__