1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Copyright (C) 2005 Takuro Ashie
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)
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.
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.
20 #ifndef __SCIM_ANTHY_CONVERSION_H__
21 #define __SCIM_ANTHY_CONVERSION_H__
23 #define Uses_SCIM_ICONV
24 #define Uses_SCIM_ATTRIBUTE
25 #define Uses_SCIM_LOOKUP_TABLE
27 #include <anthy/anthy.h>
29 #include "scim_anthy_reading.h"
35 namespace scim_anthy {
38 SCIM_ANTHY_CANDIDATE_DEFAULT = 0,
39 SCIM_ANTHY_CANDIDATE_LATIN = -1,
40 SCIM_ANTHY_CANDIDATE_WIDE_LATIN = -2,
41 SCIM_ANTHY_CANDIDATE_HIRAGANA = -3,
42 SCIM_ANTHY_CANDIDATE_KATAKANA = -4,
43 SCIM_ANTHY_CANDIDATE_HALF_KATAKANA = -5,
44 SCIM_ANTHY_CANDIDATE_HALF = -6,
45 SCIM_ANTHY_LAST_SPECIAL_CANDIDATE = -7,
48 class ConversionSegment
51 ConversionSegment (WideString str,
53 unsigned int reading_len);
54 virtual ~ConversionSegment ();
56 WideString & get_string (void);
57 int get_candidate_id (void);
58 unsigned int get_reading_length (void);
60 void set (WideString str,
62 void set_reading_length (unsigned int len);
67 unsigned int m_reading_len;
69 typedef std::vector<ConversionSegment> ConversionSegments;
74 Conversion (AnthyInstance &anthy, Reading &reading);
75 virtual ~Conversion ();
77 // starting and finishing
78 void convert (WideString source,
81 void convert (CandidateType type
82 = SCIM_ANTHY_CANDIDATE_DEFAULT,
83 bool single_segment = false);
84 void convert (const WideString &source,
85 bool single_segment = false);
87 void clear (int segment_id = -1);
88 void commit (int segment_id = -1,
92 bool is_converting (void);
93 bool is_predicting (void);
95 WideString get (void);
96 unsigned int get_length (void);
97 AttributeList get_attribute_list (void);
99 // segments of the converted sentence
100 int get_nr_segments (void);
101 WideString get_segment_string (int segment_id = -1,
103 = SCIM_ANTHY_LAST_SPECIAL_CANDIDATE);
104 int get_selected_segment (void);
105 void select_segment (int segment_id);
106 int get_segment_size (int segment_id = -1);
107 void resize_segment (int relative_size,
108 int segment_id = -1);
109 unsigned int get_segment_position (int segment_id = -1);
111 // candidates for a segment or prediction
112 void get_candidates (CommonLookupTable &table,
113 int segment_id = -1);
114 int get_selected_candidate (int segment_id = -1);
115 void select_candidate (int candidate_id,
116 int segment_id = -1);
119 bool set_dict_encoding (String type);
122 void get_reading_substr (WideString &string,
127 WideString get_prediction_string (int candidate_id);
128 void join_all_segments (void);
131 AnthyInstance &m_anthy;
136 anthy_context_t m_anthy_context;
139 ConversionSegments m_segments;
140 int m_start_id; // number of commited segments
141 int m_cur_segment; // relative position from m_start_id
147 #endif /* __SCIM_ANTHY_READING_H__ */
149 vi:ts=4:nowrap:ai:expandtab