clean db
[platform/upstream/ibus-libpinyin.git] / src / PYFallbackEditor.h
1 /* vim:set et ts=4 sts=4:
2  *
3  * ibus-pinyin - The Chinese PinYin engine for IBus
4  *
5  * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@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_FALLBACK_EDITOR_
22 #define __PY_FALLBACK_EDITOR_
23
24 #include "PYText.h"
25 #include "PYEditor.h"
26
27 namespace PY {
28
29 class FallbackEditor : public Editor {
30 public:
31     FallbackEditor (PinyinProperties &props, Config & config)
32         : Editor (props, config),
33           m_quote (TRUE),
34           m_double_quote (TRUE),
35           m_prev_committed_char (0) { }
36
37     gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
38     void reset (void);
39
40     void setPrevCommittedChar (gunichar ch)
41     {
42         m_prev_committed_char = ch;
43     }
44
45 private:
46     void commit (gchar ch)
47     {
48         gchar str[2] = {ch, 0};
49         StaticText text (str);
50         commitText (text);
51     }
52
53     void commit (gunichar ch)
54     {
55         Text text (ch);
56         commitText (text);
57     }
58
59     void commit (const gchar *str)
60     {
61         StaticText text (str);
62         commitText (text);
63     }
64
65     void commit (const String &str)
66     {
67         commit ((const gchar *)str);
68     }
69
70     gboolean processPunct (guint keyval, guint keycode, guint modifiers);
71     gboolean processPunctForSimplifiedChinese (guint keyval, guint keycode, guint modifiers);
72     gboolean processPunctForTraditionalChinese (guint keyval, guint keycode, guint modifiers);
73
74 private:
75     gboolean m_quote;
76     gboolean m_double_quote;
77     gunichar m_prev_committed_char;
78     
79 };
80
81 };
82 #endif