Tizen 2.1 base
[framework/osp/uifw.git] / inc / FUiIKeyEventListener.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FUiIKeyEventListener.h
20  * @brief               This is the header file for the %IKeyEventListener interface.
21  *
22  * This header file contains the declarations of the %IKeyEventListener interface. @n
23  * If a key event is generated, a method of this interface is called. @n
24  * If an application performs tasks related to the key event, use the methods of this interface.
25  */
26
27 #ifndef _FUI_IKEY_EVENT_LISTENER_H_
28 #define _FUI_IKEY_EVENT_LISTENER_H_
29
30 #include <FBaseRtIEventListener.h>
31 #include <FBaseTypes.h>
32
33 namespace Tizen {namespace Ui
34 {
35 class Control;
36 /**
37  * @enum        KeyCode
38  *
39  * Defines the list of keys supported by the system. @n
40  * Note that certain keys may not be available on all devices. @n
41  * Please use the Tizen::Ui::KeyboardMap class to query the availability of a specific key on the target device.
42  *
43  * @since       2.0
44  */
45 enum KeyCode
46 {
47         /**
48          *      The invalid key
49          */
50         KEY_INVALID             = 0x0000,
51
52         /**
53          *      The up side key
54          */
55         KEY_SIDE_UP,
56
57         /**
58          *      The down side key
59          */
60         KEY_SIDE_DOWN,
61
62         /**
63          *      The Ok key
64          */
65         KEY_OK,
66
67         /**
68          *      The clear key
69          */
70         KEY_CLEAR,
71
72         /**
73          *      The camera key
74          */
75         KEY_CAMERA,
76
77         /**
78         *       The task switcher key
79         */
80         KEY_SWITCH,
81
82         /**
83         *       The 0 key
84         */
85         KEY_0,
86
87         /**
88         *       The 1 key
89         */
90         KEY_1,
91
92         /**
93         *       The 2 key
94         */
95         KEY_2,
96
97         /**
98         *       The 3 key
99         */
100         KEY_3,
101
102         /**
103         *       The 4 key
104         */
105         KEY_4,
106
107         /**
108         *       The 5 key
109         */
110         KEY_5,
111
112         /**
113         *       The 6 key
114         */
115         KEY_6,
116
117         /**
118         *       The 7 key
119         */
120         KEY_7,
121
122         /**
123         *       The 8 key
124         */
125         KEY_8,
126
127         /**
128         *       The 9 key
129         */
130         KEY_9,
131
132         /**
133         *       The asterisk key
134         */
135         KEY_ASTERISK,
136
137         /**
138         *       The sharp key
139         */
140         KEY_SHARP,
141
142         /**
143         *       The left directional key
144         */
145         KEY_LEFT,
146
147         /**
148         *       The up directional key
149         */
150         KEY_UP,
151
152         /**
153         *       The down directional key
154         */
155         KEY_DOWN,
156
157         /**
158         *       The right directional key
159         */
160         KEY_RIGHT,
161
162         /*
163         *       The Placeholder
164         */
165         KEY_MAX,
166
167         /**
168         *       The A key
169         */
170         KEY_A,
171
172         /**
173         *       The B key
174         */
175         KEY_B,
176
177         /**
178         *       The C key
179         */
180         KEY_C,
181
182         /**
183         *       The D key
184         */
185         KEY_D,
186
187         /**
188         *       The E key
189         */
190         KEY_E,
191
192         /**
193         *       The F key
194         */
195         KEY_F,
196
197         /**
198         *       The G key
199         */
200         KEY_G,
201
202         /**
203         *       The H key
204         */
205         KEY_H,
206
207         /**
208         *       The I key
209         */
210         KEY_I,
211
212         /**
213         *       The J key
214         */
215         KEY_J,
216
217         /**
218         *       The K key
219         */
220         KEY_K,
221
222         /**
223         *       The L key
224         */
225         KEY_L,
226
227         /**
228         *       The M key
229         */
230         KEY_M,
231
232         /**
233         *       The N key
234         */
235         KEY_N,
236
237         /**
238         *       The O key
239         */
240         KEY_O,
241
242         /**
243         *       The P key
244         */
245         KEY_P,
246
247         /**
248         *       The Q key
249         */
250         KEY_Q,
251
252         /**
253         *       The R key
254         */
255         KEY_R,
256
257         /**
258         *       The S key
259         */
260         KEY_S,
261
262         /**
263         *       The T key
264         */
265         KEY_T,
266
267         /**
268         *       The U key
269         */
270         KEY_U,
271
272         /**
273         *       The V key
274         */
275         KEY_V,
276
277         /**
278         *       The W key
279         */
280         KEY_W,
281
282         /**
283         *       The Y key
284         */
285         KEY_Y,
286
287         /**
288         *       The X key
289         */
290         KEY_X,
291
292         /**
293         *       The Z key
294         */
295         KEY_Z,
296
297         /**
298         *       The backspace key
299         */
300         KEY_BACKSPACE,
301
302         /**
303         *       The comma key
304         */
305         KEY_COMMA,
306
307         /**
308         *       The enter key
309         */
310         KEY_ENTER,
311
312         /**
313         *       The Caps Lock key
314         */
315         KEY_CAPSLOCK,
316
317         /**
318         *       The Question key
319         */
320         KEY_QUESTION,
321
322         /**
323         *       The Alt key
324         */
325         KEY_ALT,
326
327         /**
328         *       The Language Symbol key
329         */
330         KEY_SYM,
331
332         /**
333         *       The Language Setting key
334         */
335         KEY_SETTING,
336
337         /**
338         *       The Space key
339         */
340         KEY_SPACE,
341
342         /**
343         *       The Dot key
344         */
345         KEY_DOT,
346
347         /**
348         *       The Function key
349         */
350         KEY_FN,
351
352         /**
353         *       The camera half shutter key
354         */
355         KEY_CAMERA_HALF_SHUTTER,
356
357         /**
358         *       The Character symbol 1 key
359         */
360         KEY_CHAR_SYM_1,
361
362         /**
363         *       The Character symbol 2 key
364         */
365         KEY_CHAR_SYM_2,
366
367         /**
368         * The Character symbol 3 key
369         */
370         KEY_CHAR_SYM_3,
371
372         /**
373         *       The Character symbol 4 key
374         */
375         KEY_CHAR_SYM_4,
376
377         /**
378         *       The Character symbol 5 key
379         */
380         KEY_CHAR_SYM_5,
381
382         /**
383         *       The Character symbol 6 key
384         */
385         KEY_CHAR_SYM_6,
386
387         /**
388         *       The Character symbol 7 key
389         */
390         KEY_CHAR_SYM_7,
391
392         /**
393         *       The Character symbol 8 key
394         */
395         KEY_CHAR_SYM_8,
396
397         /**
398         *       The Character symbol 9 key
399         */
400         KEY_CHAR_SYM_9,
401
402         /**
403         *       The Character symbol A key
404         */
405         KEY_CHAR_SYM_A,
406
407         /**
408         *       The Character symbol B key
409         */
410         KEY_CHAR_SYM_B,
411
412         /**
413         *       The Character symbol C key
414         */
415         KEY_CHAR_SYM_C,
416
417         /**
418         *       The Character symbol D key
419         */
420         KEY_CHAR_SYM_D,
421
422         /**
423         *       The Character symbol E key
424         */
425         KEY_CHAR_SYM_E,
426
427         /**
428         *       The Character symbol F key
429         */
430         KEY_CHAR_SYM_F,
431
432         /**
433         *       The Special function 1 key
434         */
435         KEY_FN_1,
436
437         /**
438         *       The Special function 2 key
439         */
440         KEY_FN_2,
441
442         /**
443         *       The Special function 3 key
444         */
445         KEY_FN_3,
446
447         /**
448         *       The Special function 4 key
449         */
450         KEY_FN_4,
451
452         /**
453         *       The Special function 5 key
454         */
455         KEY_FN_5,
456
457         /**
458         *        The power key
459         */
460         KEY_POWER_HOLD,
461
462         /**
463         *                The delete key
464         */
465         KEY_DELETE,
466
467         /*
468         *       placeholder key
469         */
470         KEY_HARDWARE_MAX
471 };
472
473
474 /**
475  * @enum        KeyState
476  *
477  *      Defines the state of the key.
478  *
479  * @since       2.0
480  */
481 enum KeyState
482 {
483         KEY_PRESSED = 0x0001,       /**< The key is pressed */
484         KEY_RELEASED = 0x0002,      /**< The key is released */
485         KEY_LONGPRESSED = 0x0003    /**< The key pressed and held down over a predefined duration */
486 };
487
488 /**
489  * @interface   IKeyEventListener
490  * @brief               This interface implements the listener for the key event.
491  *
492  * @since               2.0
493  *
494  * @remarks     Use the ITextEventListener interface to listen to key events related to the virtual keypad used with EditField and EditArea.
495  *
496  * The %IKeyEventListener interface is the listener interface for receiving key events, which are fired when hardware keyboard keys are pressed or
497  * released. The class that processes a key event implements this interface, and the instance created with that class is
498  * registered with a UI control, using the control's AddKeyEventListener() method. When the key event occurs, a method of that
499  * instance is invoked.
500  *
501  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/event_listener.htm">Event Listeners</a>.
502  *
503  *
504  */
505 class _OSP_EXPORT_ IKeyEventListener
506         : virtual public Tizen::Base::Runtime::IEventListener
507 {
508 public:
509         /**
510          * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
511          *
512          * @since               2.0
513          *
514          */
515         virtual ~IKeyEventListener(void) {}
516
517         /**
518          * Called when a key is pressed.
519          *
520          * @since               2.0
521          *
522          * @param[in]   source          The source of the event
523          * @param[in]   keyCode         The key code
524          */
525         virtual void OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode) = 0;
526
527         /**
528          * Called when a key is released.
529          *
530          * @since               2.0
531          *
532          * @param[in]   source          The source of the event
533          * @param[in]   keyCode         The key code
534          */
535         virtual void OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode) = 0;
536
537         /**
538          * Called when a key is pressed and held down for some time.
539          *
540          * @since               2.0
541          *
542          * @param[in]   source          The source of the event
543          * @param[in]   keyCode         The key code
544          * @remarks     The key long pressed event is fired after the key pressed event is initially generated.
545          */
546         virtual void OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode) = 0;
547
548 protected:
549         //
550         // This method is for internal use only. Using this method can cause behavioral, security-related,
551         // and consistency-related issues in the application.
552         //
553         // This method is reserved and may change its name at any time without
554         // prior notice.
555         //
556         virtual void IKeyEventListener_Reserved1(void) {}
557
558         //
559         // This method is for internal use only. Using this method can cause behavioral, security-related,
560         // and consistency-related issues in the application.
561         //
562         // This method is reserved and may change its name at any time without
563         // prior notice.
564         //
565         virtual void IKeyEventListener_Reserved2(void) {}
566
567         //
568         // This method is for internal use only. Using this method can cause behavioral, security-related,
569         // and consistency-related issues in the application.
570         //
571         // This method is reserved and may change its name at any time without
572         // prior notice.
573         //
574         virtual void IKeyEventListener_Reserved3(void) {}
575
576 }; // IKeyEventListener
577
578 }} // Tizen::Ui
579
580 #endif //_FUI_IKEY_EVENT_LISTENER_H_