2
2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
4
* Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
6
6
* The contents of this file are subject to the terms of either the GNU Lesser
7
7
* General Public License Version 2.1 only ("LGPL") or the Common Development and
8
8
* Distribution License ("CDDL")(collectively, the "License"). You may not use this
9
9
* file except in compliance with the License. You can obtain a copy of the CDDL at
10
10
* http://www.opensource.org/licenses/cddl1.php and a copy of the LGPLv2.1 at
11
* http://www.opensource.org/licenses/lgpl-license.php. See the License for the
11
* http://www.opensource.org/licenses/lgpl-license.php. See the License for the
12
12
* specific language governing permissions and limitations under the License. When
13
13
* distributing the software, include this License Header Notice in each file and
14
14
* include the full text of the License in the License file as well as the
15
15
* following notice:
17
17
* NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
19
19
* For Covered Software in this distribution, this License shall be governed by the
57
56
m_pageUpKeys.clear();
58
57
m_pageDownKeys.clear();
59
58
m_modeSwitchKeys.clear();
62
void addPageUpKey (const CKeyEvent& key)
64
m_pageUpKeys.insert (key);
67
void removePageUpKey (const CKeyEvent& key)
69
m_pageUpKeys.erase (key);
72
bool isPageUpKey (const CKeyEvent& key) const
74
return (m_pageUpKeys.find (key) != m_pageUpKeys.end());
77
void addPageDownKey (const CKeyEvent& key)
79
m_pageDownKeys.insert (key);
82
void removePageDownKey (const CKeyEvent& key)
84
m_pageDownKeys.erase (key);
87
bool isPageDownKey (const CKeyEvent& key) const
89
return (m_pageDownKeys.find (key) != m_pageDownKeys.end());
92
void addModeSwitchKey (const CKeyEvent& key)
94
m_modeSwitchKeys.insert (key);
97
void removeModeSwitchKey (const CKeyEvent& key)
99
m_modeSwitchKeys.erase (key);
102
bool isModeSwitchKey (const CKeyEvent& key) const
61
void addPageUpKey(const CKeyEvent& key){
62
m_pageUpKeys.insert(key);
65
void removePageUpKey(const CKeyEvent& key){
66
m_pageUpKeys.erase(key);
69
bool isPageUpKey(const CKeyEvent& key) const {
70
return(m_pageUpKeys.find(key) != m_pageUpKeys.end());
73
void addPageDownKey(const CKeyEvent& key){
74
m_pageDownKeys.insert(key);
77
void removePageDownKey(const CKeyEvent& key){
78
m_pageDownKeys.erase(key);
81
bool isPageDownKey(const CKeyEvent& key) const {
82
return(m_pageDownKeys.find(key) != m_pageDownKeys.end());
85
void addModeSwitchKey(const CKeyEvent& key){
86
m_modeSwitchKeys.insert(key);
89
void removeModeSwitchKey(const CKeyEvent& key){
90
m_modeSwitchKeys.erase(key);
93
bool isModeSwitchKey(const CKeyEvent& key) const {
104
94
std::set<CKeyEvent>::const_iterator end(m_modeSwitchKeys.end());
105
95
for (std::set<CKeyEvent>::const_iterator it = m_modeSwitchKeys.begin();
106
96
it != end; ++it) {
113
void setPunctSwitchKey (const CKeyEvent& key)
103
void setPunctSwitchKey(const CKeyEvent& key){
115
104
m_punctSwitchKey = key;
118
bool isPunctSwitchKey (const CKeyEvent& key) const
107
bool isPunctSwitchKey(const CKeyEvent& key) const {
120
108
return matches(m_punctSwitchKey, key);
123
void setSymbolSwitchKey (const CKeyEvent& key)
111
void setSymbolSwitchKey(const CKeyEvent& key){
125
112
m_symbolSwitchKey = key;
128
bool isSymbolSwitchKey (const CKeyEvent& key) const
115
bool isSymbolSwitchKey(const CKeyEvent& key) const {
130
116
return matches(m_symbolSwitchKey, key);
133
void rememberLastKey(const CKeyEvent& key)
119
void rememberLastKey(const CKeyEvent& key){
138
void setCandiDeleteKey (const CKeyEvent& key)
123
void setCandiDeleteKey(const CKeyEvent& key){
140
124
m_candiDeleteKey = key;
143
bool isCandiDeleteKey (const CKeyEvent& key, unsigned candiWndSize)
127
bool isCandiDeleteKey(const CKeyEvent& key, unsigned candiWndSize){
145
128
return (key.modifiers == m_candiDeleteKey.modifiers) &&
146
(key.value >= '0' && key.value <= '9') &&
129
(key.value >= '0' && key.value <= '9') &&
147
130
(candiWndSize >= 10 || key.value < ('1' + candiWndSize));
151
bool matches(const CKeyEvent& lhs, const CKeyEvent& rhs) const
134
bool matches(const CKeyEvent& lhs, const CKeyEvent& rhs) const {
154
return ( !(lhs.modifiers & IM_RELEASE_MASK) ||
155
m_prevKey.code == rhs.code );
136
return(!(lhs.modifiers & IM_RELEASE_MASK) ||
137
m_prevKey.code == rhs.code);
160
142
std::set<CKeyEvent> m_pageUpKeys;
161
143
std::set<CKeyEvent> m_pageDownKeys;
162
144
std::set<CKeyEvent> m_modeSwitchKeys;
163
CKeyEvent m_punctSwitchKey;
164
CKeyEvent m_symbolSwitchKey;
165
CKeyEvent m_candiDeleteKey;
145
CKeyEvent m_punctSwitchKey;
146
CKeyEvent m_symbolSwitchKey;
147
CKeyEvent m_candiDeleteKey;
172
154
KEYEVENT_USED = (1),
173
PREEDIT_MASK = (1<<2),
174
CANDIDATE_MASK = (1<<3)
155
PREEDIT_MASK = (1 << 2),
156
CANDIDATE_MASK = (1 << 3)
179
161
virtual ~CIMIView() {}
181
void attachIC(CIMIContext* pIC) {m_pIC = pIC;}
182
CIMIContext* getIC(void) {return m_pIC;}
184
void setPySegmentor (IPySegmentor *p) {m_pPySegmentor = p;}
185
IPySegmentor* getPySegmentor () {return m_pPySegmentor;}
187
void attachWinHandler(CIMIWinHandler* wh) {m_pWinHandler = wh;}
188
CIMIWinHandler* getWinHandler(void) {return m_pWinHandler;}
190
void setHotkeyProfile (CHotkeyProfile *prof) { m_pHotkeyProfile = prof;}
191
void setCandiWindowSize (unsigned size) {m_candiWindowSize = size;}
163
void attachIC(CIMIContext* pIC) { m_pIC = pIC; }
164
CIMIContext* getIC(void) const { return m_pIC; }
166
void setPySegmentor(IPySegmentor *p) { m_pPySegmentor = p; }
167
IPySegmentor* getPySegmentor() const { return m_pPySegmentor; }
169
void attachWinHandler(CIMIWinHandler* wh) { m_pWinHandler = wh; }
170
CIMIWinHandler* getWinHandler(void) const { return m_pWinHandler; }
172
void setHotkeyProfile(CHotkeyProfile *prof) { m_pHotkeyProfile = prof; }
173
void setCandiWindowSize(unsigned size) {
174
m_candiWindowSize = size;
192
177
CHotkeyProfile* getHotkeyProfile() { return m_pHotkeyProfile; }
193
unsigned getCandiWindowSize() { return m_candiWindowSize; }
178
unsigned getCandiWindowSize() const { return m_candiWindowSize; }
195
180
void setCancelOnBackspace(bool backspaceCancel)
196
181
{ m_backspaceCancel = backspaceCancel; }
197
bool getCancelOnBackspace() { return m_backspaceCancel; }
199
virtual unsigned clearIC(void) {m_pIC->clear(); return 0;}
200
virtual bool onKeyEvent(const CKeyEvent&) {return false;}
182
bool getCancelOnBackspace() const { return m_backspaceCancel; }
184
void setSmartPunct(bool smart) { m_smartPunct = smart; }
185
bool getSmartPunct() const { return m_smartPunct; }
187
virtual unsigned clearIC(void) { m_pIC->clear(); return 0; }
188
virtual bool onKeyEvent(const CKeyEvent&) { return false; }
202
190
virtual void setStatusAttrValue(int key, int value);
203
191
virtual int getStatusAttrValue(int key);
204
virtual void updateWindows(unsigned mask) = 0;
192
virtual void updateWindows(unsigned mask = CANDIDATE_MASK) = 0;
206
194
virtual void getPreeditString(IPreeditString& ps) = 0;
207
195
virtual void getCandidateList(ICandidateList& cl, int start, int size) = 0;
209
197
virtual int onCandidatePageRequest(int pgno, bool relative) = 0; //pgno == -1, relative == false means last page
210
198
virtual int onCandidateSelectRequest(int index) = 0;
200
virtual void handlerUpdatePreedit(const IPreeditString* ppd);
201
virtual void handlerUpdateCandidates(IPreeditString* ppd,
202
ICandidateList* pcl);
203
virtual void handlerCommit(const wstring& wstr);
205
void _pluginProvideCandidates(wstring preedit, ICandidateList* pcl);
206
void _pluginTranslateCandidate(ICandidateList* pcl);
213
208
CIMIContext *m_pIC;
214
209
CIMIWinHandler *m_pWinHandler;
215
210
IPySegmentor *m_pPySegmentor;
216
211
CHotkeyProfile *m_pHotkeyProfile;
218
unsigned m_candiWindowSize;
213
unsigned m_candiWindowSize;
223
bool m_backspaceCancel;
218
bool m_backspaceCancel;