~ubuntu-branches/ubuntu/saucy/ibus-pinyin/saucy-proposed

« back to all changes in this revision

Viewing changes to src/PhoneticEditor.h

  • Committer: Bazaar Package Importer
  • Author(s): LI Daobing, Asias He
  • Date: 2010-09-08 21:38:54 UTC
  • mfrom: (1.2.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100908213854-q4wlx8zlcyqxvelz
Tags: 1.3.11-1
[ Asias He ]
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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_PHONETIC_EDITOR_H_
22
 
#define __PY_PHONETIC_EDITOR_H_
23
 
 
24
 
#include "LookupTable.h"
25
 
#include "Editor.h"
26
 
#include "PinyinParser.h"
27
 
#include "PhraseEditor.h"
28
 
#include "SpecialPhraseTable.h"
29
 
 
30
 
namespace PY {
31
 
 
32
 
class SpecialPhraseTable;
33
 
 
34
 
class PhoneticEditor : public Editor {
35
 
public:
36
 
    PhoneticEditor (PinyinProperties & props, Config & config);
37
 
 
38
 
public:
39
 
    /* virtual functions */
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
 
    virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
48
 
    virtual gboolean processSpace (guint keyval, guint keycode, guint modifiers);
49
 
    virtual gboolean processFunctionKey (guint keyval, guint keycode, guint modifiers);
50
 
    virtual void updateLookupTable ();
51
 
    virtual void updateLookupTableFast ();
52
 
    virtual gboolean fillLookupTableByPage ();
53
 
 
54
 
protected:
55
 
 
56
 
    gboolean updateSpecialPhrases ();
57
 
    gboolean selectCandidate (guint i);
58
 
    gboolean selectCandidateInPage (guint i);
59
 
    gboolean resetCandidate (guint i);
60
 
    gboolean resetCandidateInPage (guint i);
61
 
 
62
 
    void commit (const gchar *str);
63
 
 
64
 
    /* inline functions */
65
 
    void updatePhraseEditor ()
66
 
    {
67
 
        m_phrase_editor.update (m_pinyin);
68
 
    }
69
 
 
70
 
    const gchar * textAfterPinyin () const
71
 
    {
72
 
        return (const gchar *)m_text + m_pinyin_len;
73
 
    }
74
 
 
75
 
    const gchar * textAfterPinyin (guint i) const
76
 
    {
77
 
        g_assert (i <= m_pinyin.size ());
78
 
        if ( G_UNLIKELY (i == 0))
79
 
            return m_text;
80
 
        i--;
81
 
        return (const gchar *)m_text + m_pinyin[i].begin + m_pinyin[i].len;
82
 
    }
83
 
 
84
 
    const gchar * textAfterCursor () const
85
 
    {
86
 
        return (const gchar *)m_text + m_cursor;
87
 
    }
88
 
 
89
 
    /* pure virtual functions */
90
 
    virtual gboolean insert (gint ch) = 0;
91
 
    virtual gboolean removeCharBefore (void) = 0;
92
 
    virtual gboolean removeCharAfter (void) = 0;
93
 
    virtual gboolean removeWordBefore (void) = 0;
94
 
    virtual gboolean removeWordAfter (void) = 0;
95
 
    virtual gboolean moveCursorLeft (void) = 0;
96
 
    virtual gboolean moveCursorRight (void) = 0;
97
 
    virtual gboolean moveCursorLeftByWord (void) = 0;
98
 
    virtual gboolean moveCursorRightByWord (void) = 0;
99
 
    virtual gboolean moveCursorToBegin (void) = 0;
100
 
    virtual gboolean moveCursorToEnd (void) = 0;
101
 
    virtual void commit (void) = 0;
102
 
    virtual void updateAuxiliaryText (void) = 0;
103
 
    virtual void updatePreeditText (void) = 0;
104
 
 
105
 
    /* varibles */
106
 
    PinyinArray                 m_pinyin;
107
 
    guint                       m_pinyin_len;
108
 
    String                      m_buffer;
109
 
    LookupTable                 m_lookup_table;
110
 
    PhraseEditor                m_phrase_editor;
111
 
    std::vector<std::string>    m_special_phrases;
112
 
    std::string                 m_selected_special_phrase;
113
 
};
114
 
};
115
 
 
116
 
#endif