Tizen 2.0 Release
[framework/uifw/ise-engine-anthy.git] / src / scim_anthy_key2kana_table.h
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  *  Copyright (C) 2005 Takuro Ashie
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __SCIM_ANTHY_KEY2KANA_TABLE_H__
21 #define __SCIM_ANTHY_KEY2KANA_TABLE_H__
22
23 #define Uses_SCIM_TYPES
24 #include <scim.h>
25 #include "scim_anthy_default_tables.h"
26
27 using namespace scim;
28
29 namespace scim_anthy {
30
31 typedef enum {
32     SCIM_ANTHY_PERIOD_JAPANESE,
33     SCIM_ANTHY_PERIOD_WIDE,
34     SCIM_ANTHY_PERIOD_HALF,
35 } PeriodStyle;
36
37 typedef enum {
38     SCIM_ANTHY_COMMA_JAPANESE,
39     SCIM_ANTHY_COMMA_WIDE,
40     SCIM_ANTHY_COMMA_HALF,
41 } CommaStyle;
42
43 typedef enum {
44     SCIM_ANTHY_BRACKET_JAPANESE,
45     SCIM_ANTHY_BRACKET_WIDE,
46 } BracketStyle;
47
48 typedef enum {
49     SCIM_ANTHY_SLASH_JAPANESE,
50     SCIM_ANTHY_SLASH_WIDE,
51 } SlashStyle;
52
53 typedef enum {
54     SCIM_ANTHY_TYPING_METHOD_ROMAJI,
55     SCIM_ANTHY_TYPING_METHOD_KANA,
56     SCIM_ANTHY_TYPING_METHOD_NICOLA,
57     SCIM_ANTHY_TYPING_METHOD_CUSTOM,
58 } TypingMethod;
59
60
61 class Key2KanaRule;
62 class Key2KanaTable;
63 class Key2KanaTableSet;
64
65 typedef std::vector<Key2KanaRule> Key2KanaRules;
66
67
68 class Key2KanaRule
69 {
70 public:
71     Key2KanaRule ();
72     Key2KanaRule (String sequence,
73                   const std::vector<String> &result);
74     virtual ~Key2KanaRule ();
75
76     String get_sequence        (void);
77     String get_result          (unsigned int idx);
78
79     void   clear               (void);
80
81     bool   is_empty            (void);
82
83 private:
84     String              m_sequence;
85     std::vector<String> m_result;
86 };
87
88
89 class Key2KanaTable
90 {
91 public:
92     Key2KanaTable (WideString  name);
93     Key2KanaTable (WideString  name,
94                    ConvRule   *table);
95     Key2KanaTable (WideString  name,
96                    NicolaRule *table);
97     virtual ~Key2KanaTable ();
98
99     Key2KanaRules & get_table   (void) { return m_rules; }
100
101     void            append_rule (String sequence,
102                                  const std::vector<String> &result);
103     void            append_rule (String sequence,
104                                  String result,
105                                  String cont);
106     void            append_rule (String sequence,
107                                  String normal,
108                                  String left_shift,
109                                  String right_shift);
110     void            clear       (void);
111
112 private:
113     WideString    m_name;
114     Key2KanaRules m_rules;
115 };
116
117
118 class Key2KanaTableSet
119 {
120 public:
121     Key2KanaTableSet ();
122     virtual ~Key2KanaTableSet ();
123
124     std::vector<Key2KanaTable*> &
125          get_tables (void) { return m_all_tables; };
126
127     void set_typing_method       (TypingMethod   method,
128                                   Key2KanaTable *fundamental_table = NULL);
129     void set_symbol_width        (bool           half);
130     void set_number_width        (bool           half);
131     void set_period_style        (PeriodStyle    style);
132     void set_comma_style         (CommaStyle     style);
133     void set_bracket_style       (BracketStyle   style);
134     void set_slash_style         (SlashStyle     style);
135
136     TypingMethod
137          get_typing_method       (void) { return m_typing_method; }
138     bool symbol_is_half          (void) { return m_use_half_symbol; }
139     bool number_is_half          (void) { return m_use_half_number;}
140     PeriodStyle
141          get_period_style        (void) { return m_period_style; }
142     CommaStyle
143          get_comma_style         (void) { return m_comma_style; }
144     BracketStyle
145          get_bracket_style       (void) { return m_bracket_style; }
146     SlashStyle
147          get_slash_style         (void) { return m_slash_style; }
148
149 #if 0
150     void set_use_consonant_table (bool use);
151     void set_use_symbol_table    (bool use);
152     void set_use_number_table    (bool use);
153     void set_use_period_table    (bool use);
154     void set_use_comma_table     (bool use);
155
156     bool get_use_consonant_table (void);
157     bool get_use_symbol_table    (void);
158     bool get_use_number_table    (void);
159     bool get_use_period_table    (void);
160     bool get_use_comma_table     (void);
161 #endif
162
163 private:
164     void reset_tables            (void);
165
166 private:
167     WideString m_name;
168
169     // tables
170     Key2KanaTable               *m_fundamental_table;
171     Key2KanaTable                m_voiced_consonant_table;
172     std::vector<Key2KanaTable*> *m_additional_table;
173     std::vector<Key2KanaTable*>  m_all_tables;
174
175     // flags
176     TypingMethod m_typing_method;
177     PeriodStyle  m_period_style;
178     CommaStyle   m_comma_style;
179     BracketStyle m_bracket_style;
180     SlashStyle   m_slash_style;
181     bool         m_use_half_symbol;
182     bool         m_use_half_number;
183 };
184
185 }
186
187 #endif /* __SCIM_ANTHY_KEY2KANA_TABLE_H__ */
188 /*
189 vi:ts=4:nowrap:ai:expandtab
190 */