clean db
[platform/upstream/ibus-libpinyin.git] / src / PYPPhoneticEditor.h
1 /* vim:set et ts=4 sts=4:
2  *
3  * ibus-pinyin - The Chinese PinYin engine for IBus
4  *
5  * Copyright (c) 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 #ifndef __PY_LIB_PINYIN_BASE_EDITOR_H_
22 #define __PY_LIB_PINYIN_BASE_EDITOR_H_
23
24 #include <pinyin.h>
25 #include "PYLookupTable.h"
26 #include "PYEditor.h"
27
28
29 namespace PY {
30
31 class LibPinyinPhoneticEditor : public Editor {
32 public:
33     LibPinyinPhoneticEditor (PinyinProperties & props, Config & config);
34
35 public:
36     /* virtual functions */
37     virtual void pageUp (void);
38     virtual void pageDown (void);
39     virtual void cursorUp (void);
40     virtual void cursorDown (void);
41     virtual void update (void);
42     virtual void reset (void);
43     virtual void candidateClicked (guint index, guint button, guint state);
44     virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
45     virtual gboolean processSpace (guint keyval, guint keycode, guint modifiers);
46     virtual gboolean processFunctionKey (guint keyval, guint keycode, guint modifiers);
47     virtual void updateLookupTable ();
48     virtual void updateLookupTableFast ();
49     virtual gboolean fillLookupTableByPage ();
50
51 protected:
52     gboolean selectCandidate (guint i);
53     gboolean selectCandidateInPage (guint i);
54
55     void commit (const gchar *str);
56     guint getPinyinCursor (void);
57     guint getLookupCursor (void);
58
59     /* inline functions */
60
61     /* pure virtual functions */
62     virtual gboolean insert (gint ch) = 0;
63     virtual gboolean removeCharBefore (void);
64     virtual gboolean removeCharAfter (void);
65     virtual gboolean removeWordBefore (void);
66     virtual gboolean removeWordAfter (void);
67     virtual gboolean moveCursorLeft (void);
68     virtual gboolean moveCursorRight (void);
69     virtual gboolean moveCursorLeftByWord (void);
70     virtual gboolean moveCursorRightByWord (void);
71     virtual gboolean moveCursorToBegin (void);
72     virtual gboolean moveCursorToEnd (void);
73     virtual void commit (void) = 0;
74     virtual void updateAuxiliaryText (void) = 0;
75     virtual void updatePreeditText (void) = 0;
76     virtual void updatePinyin (void) = 0;
77
78     guint getCursorLeftByWord (void);
79     guint getCursorRightByWord (void);
80
81
82     /* varibles */
83 #if 0
84     PinyinArray                 m_pinyins;
85 #endif
86     guint                       m_pinyin_len;
87     LookupTable                 m_lookup_table;
88     String                      m_buffer;
89
90     /* use LibPinyinBackEnd here. */
91     pinyin_instance_t           *m_instance;
92     TokenVector                 m_candidates;
93 };
94
95 };
96
97 #endif