1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Copyright (C) 2004 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_PREEDIT_H__
21 #define __SCIM_ANTHY_PREEDIT_H__
23 #define Uses_SCIM_ICONV
24 #define Uses_SCIM_EVENT
25 #define Uses_SCIM_ATTRIBUTE
26 #define Uses_SCIM_LOOKUP_TABLE
27 #include <anthy/anthy.h>
29 #include "scim_anthy_reading.h"
30 #include "scim_anthy_conversion.h"
32 #define SCIM_ANTHY_PSEUDO_ASCII_TRIGGERED_CAPITALIZED (1 << 0)
33 #define SCIM_ANTHY_PSEUDO_ASCII_TRIGGERED_COUPLE_OF_CAPITAL (1 << 1)
39 namespace scim_anthy {
42 SCIM_ANTHY_MODE_HIRAGANA,
43 SCIM_ANTHY_MODE_KATAKANA,
44 SCIM_ANTHY_MODE_HALF_KATAKANA,
45 SCIM_ANTHY_MODE_LATIN,
46 SCIM_ANTHY_MODE_WIDE_LATIN,
52 Preedit (AnthyInstance &anthy);
56 virtual unsigned int get_length (void);
57 virtual WideString get_string (void);
58 virtual AttributeList get_attribute_list (void);
59 virtual Reading &get_reading (void);
61 virtual bool is_preediting (void);
62 virtual bool is_converting (void);
63 virtual bool is_predicting (void);
64 virtual bool is_reconverting (void);
66 // for handling the preedit string
67 virtual bool can_process_key_event (const KeyEvent & key);
68 // return true if commiting is needed.
69 virtual bool process_key_event (const KeyEvent & key);
70 virtual bool append (const KeyEvent & key,
71 const String & string);
72 virtual void erase (bool backward = true);
73 virtual void finish (void);
75 // for handling the conversion string
76 virtual void convert (CandidateType type
77 = SCIM_ANTHY_CANDIDATE_DEFAULT,
78 bool single_segment = false);
79 virtual void convert (const WideString &source,
80 bool single_segment = false);
81 virtual void revert (void);
82 virtual void commit (int segment_id = -1,
86 virtual void predict (void);
88 // segments of the converted sentence
89 virtual int get_nr_segments (void);
90 virtual WideString get_segment_string (int segment_id = -1);
91 virtual int get_selected_segment (void);
92 virtual void select_segment (int segment_id);
93 virtual int get_segment_size (int segment_id = -1);
94 virtual void resize_segment (int relative_size,
97 // candidates for a segment
98 virtual void get_candidates (CommonLookupTable &table,
100 virtual int get_selected_candidate (int segment_id = -1);
101 virtual void select_candidate (int candidate_id,
102 int segment_id = -1);
104 // for handling the caret
105 virtual unsigned int get_caret_pos (void);
106 virtual void set_caret_pos (unsigned int pos);
107 virtual void move_caret (int len);
109 // clear all or part of the string.
110 virtual void clear (int segment_id = -1);
113 virtual void set_input_mode (InputMode mode);
114 virtual InputMode get_input_mode (void);
115 virtual void set_typing_method (TypingMethod method);
116 virtual TypingMethod get_typing_method (void);
117 virtual void set_period_style (PeriodStyle style);
118 virtual PeriodStyle get_period_style (void);
119 virtual void set_comma_style (CommaStyle style);
120 virtual CommaStyle get_comma_style (void);
121 virtual void set_bracket_style (BracketStyle style);
122 virtual BracketStyle get_bracket_style (void);
123 virtual void set_slash_style (SlashStyle style);
124 virtual SlashStyle get_slash_style (void);
125 virtual void set_symbol_width (bool half);
126 virtual bool get_symbol_width (void);
127 virtual void set_number_width (bool half);
128 virtual bool get_number_width (void);
129 virtual void set_pseudo_ascii_mode (int mode);
130 virtual bool is_pseudo_ascii_mode (void);
131 virtual void reset_pseudo_ascii_mode(void);
132 virtual void set_dict_encoding (String type);
135 void get_reading_substr (WideString & substr,
139 bool is_comma_or_period (const String & str);
142 AnthyInstance &m_anthy;
146 Conversion m_conversion;
149 InputMode m_input_mode;
151 // source string for reconversion
157 #endif /* __SCIM_ANTHY_PREEDIT_H__ */
159 vi:ts=4:nowrap:ai:expandtab