forked from EasyIME/PIME
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImeModule.h
140 lines (110 loc) · 3.48 KB
/
ImeModule.h
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//
// Copyright (C) 2013 Hong Jen Yee (PCMan) <[email protected]>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the
// Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301, USA.
//
#ifndef IME_IME_MODULE_H
#define IME_IME_MODULE_H
#include <Unknwn.h>
#include <Windows.h>
#include <Ctffunc.h>
#include <list>
#include "WindowsVersion.h"
#include <string>
namespace Ime {
class TextService;
class DisplayAttributeInfo;
// language profile info, used to register new language profiles
struct LangProfileInfo {
std::wstring name; // should not exceed 32 chars
GUID profileGuid;
LANGID languageId;
std::wstring iconFile;
int iconIndex;
};
class ImeModule:
public IClassFactory,
public ITfFnConfigure {
public:
ImeModule(HMODULE module, const CLSID& textServiceClsid);
virtual ~ImeModule(void);
// public methods
HINSTANCE hInstance() const {
return hInstance_;
}
const CLSID& textServiceClsid() const {
return textServiceClsid_;
}
bool isWindows8Above() {
return winVer_.isWindows8Above();
}
WindowsVersion windowsVersion() const {
return winVer_;
}
// Dll entry points implementations
HRESULT canUnloadNow();
HRESULT getClassObject(REFCLSID rclsid, REFIID riid, void **ppvObj);
HRESULT registerServer(wchar_t* imeName, LangProfileInfo* langs, int count);
HRESULT registerLangProfiles(LangProfileInfo* langs, int count);
HRESULT unregisterServer();
// should be override by IME implementors
virtual TextService* createTextService() = 0;
void freeTextService(TextService* service);
// called when config dialog needs to be launched
virtual bool onConfigure(HWND hwndParent, LANGID langid, REFGUID rguidProfile);
// display attributes for composition string
std::list<DisplayAttributeInfo*>& displayAttrInfos() {
return displayAttrInfos_;
}
bool registerDisplayAttributeInfos();
DisplayAttributeInfo* inputAttrib() {
return inputAttrib_;
}
/*
DisplayAttributeInfo* convertedAttrib() {
return convertedAttrib_;
}
*/
const std::list<TextService*>& textServices() const {
return textServices_;
}
// COM-related stuff
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
protected:
// IClassFactory
STDMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObj);
STDMETHODIMP LockServer(BOOL fLock);
// ITfFunction
STDMETHODIMP GetDisplayName(BSTR *pbstrName);
// ITfFnConfigure
STDMETHODIMP Show(HWND hwndParent, LANGID langid, REFGUID rguidProfile);
private:
volatile unsigned long refCount_;
HINSTANCE hInstance_;
CLSID textServiceClsid_;
wchar_t* tooltip_;
// display attributes
std::list<DisplayAttributeInfo*> displayAttrInfos_; // display attribute info
DisplayAttributeInfo* inputAttrib_;
// DisplayAttributeInfo* convertedAttrib_;
WindowsVersion winVer_;
std::list<TextService*> textServices_;
};
}
#endif