clean db
[platform/upstream/ibus-libpinyin.git] / src / PYEnglishEditor.h
1 /* vim:set et ts=4 sts=4:
2  *
3  * ibus-pinyin - The Chinese PinYin engine for IBus
4  *
5  * Copyright (c) 2010-2011 Peng Wu <alexepico@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 #ifndef __PY_ENGLISH_EDITOR_
23 #define __PY_ENGLISH_EDITOR_
24
25 #include "PYEditor.h"
26 #include "PYLookupTable.h"
27
28 namespace PY {
29
30 class EnglishDatabase;
31
32 class EnglishEditor : public Editor {
33 private:
34     const float m_train_factor;
35 public:
36     EnglishEditor (PinyinProperties &props, Config & config);
37     virtual ~EnglishEditor();
38
39     virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifers);
40     virtual void pageUp (void);
41     virtual void pageDown (void);
42     virtual void cursorUp (void);
43     virtual void cursorDown (void);
44     virtual void update (void);
45     virtual void reset (void);
46     virtual void candidateClicked (guint index, guint button, guint state);
47
48 private:
49     gboolean updateStateFromInput (void);
50
51     void clearLookupTable (void);
52     void updateLookupTable (void);
53     void updatePreeditText (void);
54     void updateAuxiliaryText (void);
55
56     gboolean selectCandidateInPage (guint index);
57     gboolean selectCandidate (guint index);
58
59     gboolean processSpace(guint keyval);
60     gboolean processEnter(guint keyval);
61
62     gboolean removeCharBefore (void);
63     gboolean removeCharAfter (void);
64
65     gboolean processLabelKey(guint keyval);
66     gboolean processEditKey(guint keyval);
67     gboolean processPageKey(guint keyval);
68
69     gboolean train(const char *word, float delta);
70
71     /* variables */
72     LookupTable m_lookup_table;
73
74     String m_preedit_text;
75     String m_auxiliary_text;
76
77     EnglishDatabase *m_english_database;
78 };
79
80 };
81
82 #endif