Tizen 2.1 base
[framework/uifw/ise-engine-anthy.git] / src / scim_anthy_nicola.h
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  *  Copyright (C) 2004 Hiroyuki Ikezoe
4  *  Copyright (C) 2004 Takuro Ashie
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __SCIM_ANTHY_NICOLA_H__
22 #define __SCIM_ANTHY_NICOLA_H__
23
24 #define Uses_SCIM_ICONV
25 #define Uses_SCIM_EVENT
26 #include <scim.h>
27 #include <sys/time.h>
28
29 #include "scim_anthy_key2kana_base.h"
30 #include "scim_anthy_key2kana_table.h"
31
32 using namespace scim;
33
34 class AnthyInstance;
35
36 namespace scim_anthy {
37
38 typedef enum {
39     SCIM_ANTHY_NICOLA_SHIFT_NONE,
40     SCIM_ANTHY_NICOLA_SHIFT_LEFT,
41     SCIM_ANTHY_NICOLA_SHIFT_RIGHT,
42 } NicolaShiftType;
43
44 class NicolaConvertor : public Key2KanaConvertorBase
45 {
46 public:
47     NicolaConvertor                     (AnthyInstance    & anthy,
48                                          Key2KanaTableSet & tables);
49     virtual ~NicolaConvertor            ();
50
51     bool       can_append               (const KeyEvent   & key,
52                                          bool               ignore_space = false);
53     bool       append                   (const KeyEvent   & key,
54                                          WideString       & result,
55                                          WideString       & pending,
56                                          String           & raw);
57     bool       append                   (const String     & raw,
58                                          WideString       & result,
59                                          WideString       & pending);
60     void       clear                    (void);
61
62     bool       is_pending               (void);
63     WideString get_pending              (void);
64     WideString flush_pending            (void);
65     void       reset_pending            (const WideString & result,
66                                          const String     & raw);
67
68 public:
69     void       process_timeout          (void);
70
71 private:
72     void       search                   (const KeyEvent     key,
73                                          NicolaShiftType    shift_type,
74                                          WideString       & result,
75                                          String           & raw);
76     bool       handle_voiced_consonant  (WideString       & result,
77                                          WideString       & pending);
78     bool       is_char_key              (const KeyEvent     key);
79     bool       is_thumb_key             (const KeyEvent     key);
80     bool       is_left_thumb_key        (const KeyEvent     key);
81     bool       is_right_thumb_key       (const KeyEvent     key);
82     NicolaShiftType
83                get_thumb_key_type       (const KeyEvent     key);
84
85     void       on_key_repeat            (const KeyEvent     key,
86                                          WideString       & result,
87                                          String           & raw);
88     void       on_both_key_pressed      (const KeyEvent     key,
89                                          WideString       & result,
90                                          String           & raw);
91     void       on_thumb_key_pressed     (const KeyEvent     key,
92                                          WideString       & result,
93                                          String           & raw);
94     void       on_char_key_pressed      (const KeyEvent     key,
95                                          WideString       & result,
96                                          String           & raw);
97     void       on_no_key_pressed        (const KeyEvent     key);
98
99     bool       is_repeating             (void);
100     void       emit_key_event           (const KeyEvent   & key);
101     void       set_alarm                (int                time_msec);
102
103 private:
104     Key2KanaTableSet &m_tables;
105
106     AnthyInstance    &m_anthy;
107
108     // state
109     KeyEvent          m_prev_char_key;
110     KeyEvent          m_prev_thumb_key;
111
112     KeyEvent          m_repeat_char_key;
113     KeyEvent          m_repeat_thumb_key;
114     bool              m_is_repeating;
115
116     struct timeval    m_time_char;
117     struct timeval    m_time_thumb;
118
119     KeyEvent          m_through_key_event;
120
121     uint32            m_timer_id;
122     bool              m_processing_timeout;
123
124     WideString        m_pending;
125 };
126
127 }
128 #endif /* __SCIM_ANTHY_NICOLA_H__ */
129 /*
130 vi:ts=4:nowrap:ai:expandtab
131 */