Tizen 2.0 Release
[framework/uifw/ise-engine-anthy.git] / src / scim_anthy_reading.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_READING_H__
21 #define __SCIM_ANTHY_READING_H__
22
23 #define Uses_SCIM_ICONV
24 #define Uses_SCIM_EVENT
25 #include <scim.h>
26 #include "scim_anthy_key2kana.h"
27 #include "scim_anthy_kana.h"
28 #include "scim_anthy_nicola.h"
29
30 using namespace scim;
31
32 class AnthyInstance;
33
34 namespace scim_anthy {
35
36 typedef enum {
37     SCIM_ANTHY_STRING_LATIN,
38     SCIM_ANTHY_STRING_WIDE_LATIN,
39     SCIM_ANTHY_STRING_HIRAGANA,
40     SCIM_ANTHY_STRING_KATAKANA,
41     SCIM_ANTHY_STRING_HALF_KATAKANA,
42 } StringType;
43
44 class Reading;
45 class ReadingSegment;
46 typedef std::vector<ReadingSegment> ReadingSegments;
47
48 class ReadingSegment
49 {
50     friend class Reading;
51
52 public:
53     ReadingSegment (void);
54     virtual ~ReadingSegment ();
55
56     const WideString & get     (void) { return kana; }
57     const String     & get_raw (void) { return raw; }
58
59     void split (ReadingSegments &segments);
60
61 private:
62     String     raw;
63     WideString kana;
64 };
65
66 class Reading
67 {
68 public:
69     Reading (AnthyInstance &anthy);
70     virtual ~Reading ();
71
72     bool         can_process_key_event (const KeyEvent & key);
73     bool         process_key_event     (const KeyEvent & key);
74     void         finish                (void);
75     void         clear                 (void);
76
77     WideString   get                   (unsigned int     start  = 0,
78                                         int              length = -1,
79                                         StringType       type
80                                         = SCIM_ANTHY_STRING_HIRAGANA);
81     String       get_raw               (unsigned int     start  = 0,
82                                         int              length = -1);
83     bool         append                (const KeyEvent & key,
84                                         const String   & string);
85     void         erase                 (unsigned int     start  = 0,
86                                         int              length = -1,
87                                         bool             allow_split = false);
88
89     unsigned int get_length            (void);
90     unsigned int get_caret_pos         (void);
91     void         set_caret_pos         (unsigned int     pos);
92     void         move_caret            (int              step,
93                                         bool             allow_split = false);
94
95     void         set_typing_method     (TypingMethod     method);
96     TypingMethod get_typing_method     (void);
97     void         set_period_style      (PeriodStyle      style);
98     PeriodStyle  get_period_style      (void);
99     void         set_comma_style       (CommaStyle       style);
100     CommaStyle   get_comma_style       (void);
101     void         set_bracket_style     (BracketStyle     style);
102     BracketStyle get_bracket_style     (void);
103     void         set_slash_style       (SlashStyle       style);
104     SlashStyle   get_slash_style       (void);
105     void         set_symbol_width      (bool             half);
106     bool         get_symbol_width      (void);
107     void         set_number_width      (bool             half);
108     bool         get_number_width      (void);
109     void         set_pseudo_ascii_mode (int              mode);
110     bool         is_pseudo_ascii_mode  (void);
111     void         reset_pseudo_ascii_mode (void);
112
113 private:
114     void         reset_pending         (void);
115     void         split_segment         (unsigned int     seg_id);
116
117 private:
118     AnthyInstance         &m_anthy;
119
120     // tables
121     Key2KanaTableSet       m_key2kana_tables;
122     Key2KanaTableSet       m_nicola_tables;
123
124     // convertors
125     Key2KanaConvertor      m_key2kana_normal;
126     KanaConvertor          m_kana;
127     NicolaConvertor        m_nicola;
128     Key2KanaConvertorBase *m_key2kana;
129
130     // state
131     ReadingSegments        m_segments;
132     unsigned int           m_segment_pos;
133     unsigned int           m_caret_offset;
134 };
135
136 }
137
138 #endif /* __SCIM_ANTHY_READING_H__ */
139 /*
140 vi:ts=4:nowrap:ai:expandtab
141 */