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

« back to all changes in this revision

Viewing changes to src/PYEngine.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_ENGINE_H_
 
22
#define __PY_ENGINE_H_
 
23
 
 
24
#include <ibus.h>
 
25
 
 
26
#include "PYPointer.h"
 
27
#include "PYLookupTable.h"
 
28
#include "PYProperty.h"
 
29
#include "PYEditor.h"
 
30
 
 
31
namespace PY {
 
32
 
 
33
#define IBUS_TYPE_PINYIN_ENGINE \
 
34
        (PY::ibus_pinyin_engine_get_type ())
 
35
 
 
36
GType   ibus_pinyin_engine_get_type    (void);
 
37
 
 
38
class Engine {
 
39
public:
 
40
    Engine (IBusEngine *engine) : m_engine (engine) { }
 
41
    virtual ~Engine (void);
 
42
 
 
43
    // virtual functions
 
44
    virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers) = 0;
 
45
    virtual void focusIn (void) = 0;
 
46
    virtual void focusOut (void) = 0;
 
47
    virtual void reset (void) = 0;
 
48
    virtual void enable (void) = 0;
 
49
    virtual void disable (void) = 0;
 
50
    virtual void pageUp (void) = 0;
 
51
    virtual void pageDown (void) = 0;
 
52
    virtual void cursorUp (void) = 0;
 
53
    virtual void cursorDown (void) = 0;
 
54
    virtual gboolean propertyActivate (const gchar *prop_name, guint prop_state) = 0;
 
55
    virtual void candidateClicked (guint index, guint button, guint state) = 0;
 
56
 
 
57
protected:
 
58
    void commitText (Text & text) const
 
59
    {
 
60
        ibus_engine_commit_text (m_engine, text);
 
61
    }
 
62
 
 
63
    void updatePreeditText (Text & text, guint cursor, gboolean visible) const
 
64
    {
 
65
        ibus_engine_update_preedit_text (m_engine, text, cursor, visible);
 
66
    }
 
67
 
 
68
    void showPreeditText (void) const
 
69
    {
 
70
        ibus_engine_show_preedit_text (m_engine);
 
71
    }
 
72
 
 
73
    void hidePreeditText (void) const
 
74
    {
 
75
        ibus_engine_hide_preedit_text (m_engine);
 
76
    }
 
77
 
 
78
    void updateAuxiliaryText (Text & text, gboolean visible) const
 
79
    {
 
80
        ibus_engine_update_auxiliary_text (m_engine, text, visible);
 
81
    }
 
82
 
 
83
    void showAuxiliaryText (void) const
 
84
    {
 
85
        ibus_engine_show_auxiliary_text (m_engine);
 
86
    }
 
87
 
 
88
    void hideAuxiliaryText (void) const
 
89
    {
 
90
        ibus_engine_hide_auxiliary_text (m_engine);
 
91
    }
 
92
 
 
93
    void updateLookupTable (LookupTable &table, gboolean visible) const
 
94
    {
 
95
        ibus_engine_update_lookup_table (m_engine, table, visible);
 
96
    }
 
97
 
 
98
    void updateLookupTableFast (LookupTable &table, gboolean visible) const
 
99
    {
 
100
        ibus_engine_update_lookup_table_fast (m_engine, table, visible);
 
101
    }
 
102
 
 
103
    void showLookupTable (void) const
 
104
    {
 
105
        ibus_engine_show_lookup_table (m_engine);
 
106
    }
 
107
 
 
108
    void hideLookupTable (void) const
 
109
    {
 
110
        ibus_engine_hide_lookup_table (m_engine);
 
111
    }
 
112
 
 
113
    void registerProperties (PropList & props) const
 
114
    {
 
115
        ibus_engine_register_properties (m_engine, props);
 
116
    }
 
117
 
 
118
    void updateProperty (Property & prop) const
 
119
    {
 
120
        ibus_engine_update_property (m_engine, prop);
 
121
    }
 
122
 
 
123
protected:
 
124
    Pointer<IBusEngine>  m_engine;      // engine pointer
 
125
};
 
126
 
 
127
};
 
128
#endif