File: im_engine.h

package info (click to toggle)
scim-unikey 0.3.1+debian-3.1
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd, wheezy
  • size: 2,396 kB
  • ctags: 1,262
  • sloc: sh: 10,650; cpp: 7,490; makefile: 169; sed: 16
file content (103 lines) | stat: -rw-r--r-- 2,903 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**
   Scim-Unikey Input Method

   Copyright (C) 2008-2009 Ubuntu-VN <http://www.ubuntu-vn.org>
   Author: Le Quoc Tuan <mr.lequoctuan@gmail.com>
   Home: http://scim-unikey.googlecode.com
   License: GNU LESSER GENERAL PUBLIC LICENSE v2.1
*/

#if !defined (__SCIM_UNIKEY_IMENGINE_H)
#define __SCIM_UNIKEY_IMENGINE_H

#include "unikey.h"

using namespace scim;

class UnikeyFactory : public IMEngineFactoryBase
{
public:
    UnikeyFactory(int id);
    virtual ~UnikeyFactory();

    virtual WideString  get_name() const;
    virtual WideString  get_authors() const;
    virtual WideString  get_credits() const;
    virtual WideString  get_help() const;
    virtual String      get_uuid() const;
    virtual String      get_icon_file() const;

    virtual IMEngineInstancePointer create_instance(const String& encoding, int id = -1);

private:
    int m_id;
};


class UnikeyInstance : public IMEngineInstanceBase
{
    friend class UnikeyInstancePreedit;
    friend class UnikeyInstanceClassic;

public:
    UnikeyInstance(UnikeyFactory *factory, const String& encoding, int id);
    ~UnikeyInstance();

    virtual void reset();
    virtual void focus_in();
    virtual void trigger_property(const String &property);

private:
    PropertyList CreatePropertyList();

    int m_im;                             // input method
    int m_oc;                             // output charset
    UnikeyOptions m_ukopt;                // Unikey Options
    bool m_process_w_AtBeginWord;         // process W at Begin Word?
    bool m_lastkey_with_shift;            // last press key with modifier is shift
};


class UnikeyInstancePreedit : public UnikeyInstance
{
public:
    UnikeyInstancePreedit(UnikeyFactory *factory, const String& encoding, int id = -1);
    ~UnikeyInstancePreedit();

    virtual void reset();
    virtual void focus_in();
    virtual void focus_out();
    virtual bool process_key_event(const KeyEvent& key);
    virtual void trigger_property(const String &property);

private:
    bool unikey_process_key_event(const KeyEvent& key);
    void unikey_update_preedit_string(const WideString s, const bool visible);
    PropertyList CreatePropertyList();

    WideString m_preeditstring;           // store PreEdit String
    bool m_auto_commit;                   // auto commit?
};


class UnikeyInstanceClassic : public UnikeyInstance
{
public:
    UnikeyInstanceClassic(UnikeyFactory *factory, const String& encoding, int id = -1);
    ~UnikeyInstanceClassic();

    virtual void reset();
    virtual void focus_in();
    virtual void focus_out();
    virtual bool process_key_event(const KeyEvent& key);
    virtual void trigger_property(const String &property);

private:
    bool unikey_process_key_event(const KeyEvent& key);
    void unikey_send_backspace(int nBackspace);
    void unikey_commit_key_event(const KeyEvent& key);
    PropertyList CreatePropertyList();
};

#endif