-
Notifications
You must be signed in to change notification settings - Fork 1
/
PinyinFrame.h
executable file
·142 lines (128 loc) · 3.88 KB
/
PinyinFrame.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
141
142
/**********************************************************************
** Copyright (C) 2004 MurphyTalk
**
** This file is part of the MurphyTalk PinYin Chinese input method,
** which is for the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**
** murphytalk@gmail.com
**
**********************************************************************/
#ifndef PINYINFRM_H
#define PINYINFRM_H
#include <qframe.h>
#include <qwindowsystem_qws.h>
#include "PinyinEngine.h"
class QPinyinFrame : public QFrame, public QWSServer::KeyboardFilter
{
Q_OBJECT
public:
QPinyinFrame(QWidget* parent=0, const char* name=0, WFlags f=0);
~QPinyinFrame();
void resetState(){
if(m_bMakingPhrase){
m_making_phrase_pinyin+=m_ime_info.pinyin;
}
m_ime_info.pinyin="";
m_ime_info.candidates_count=0;
m_engine.clear_key();
}
QSize sizeHint() const ;
public:
bool GetKey(int,int);
virtual void show();
virtual void hide();
void paintEvent(QPaintEvent * e);
void SendKey ( int , int c = 0);
void mouseReleaseEvent(QMouseEvent*);
void keyPressEvent(QKeyEvent*);
signals:
void key( ushort, ushort, ushort, bool, bool );
private:
PinyinEngine m_engine;
bool m_bEnglishMode;
bool m_bMakingPhrase;
QRect m_indicator_rect/*for English or Chinese mode*/;
QRect m_about_rect;/*the about text rect*/
QRect m_leftbtn_rect,m_rightbtn_rect;
typedef struct ime_info_struc{
String pinyin;
QString phrase;
unsigned int candidates_count;
unsigned int first_visible; //index of first visible candidate hanzi,start from 0
unsigned int candidates_on_page; //hanzi candidates on current page
unsigned int candidates_on_prev_page; //hanzi candidates on previous page
ime_info_struc(){
candidates_count = 0;
}
bool prev_page_available(){
return candidates_count>0&&first_visible>0;
}
bool next_page_available(){
return candidates_count>0&&(first_visible+candidates_on_page)<candidates_count;
}
}ime_info_t;
ime_info_t m_ime_info;
String m_making_phrase_pinyin;
private:
virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
int get_charunicode(unsigned int nIndexOnPage);
inline QChar QPinyinFrame::get_char(unsigned int nIndex/*this is global index*/){
return m_engine.get_char(nIndex);
}
inline QString QPinyinFrame::get_phrase(unsigned int nIndex/*this is global index*/){
return m_engine.get_phrase(nIndex);
}
bool prev_page();
bool next_page();
bool commit_selection(int k);
inline void search(){
m_ime_info.candidates_count=m_engine.search(m_ime_info.pinyin.c_str());
m_ime_info.first_visible=0;
#ifdef X86
printf("%s,%d matched\n",m_ime_info.pinyin.c_str(),m_ime_info.candidates_count);
#endif
}
int init_gui_dimention();
bool send_hanzi_mark(int ascii_mark);
};
#endif
/*
* Revision history
*
* $Log: PinyinFrame.h,v $
* Revision 1.7 2004/07/31 17:20:19 Lu Mu
* support chinese punctuations
*
* Revision 1.6 2004/07/20 11:26:05 Lu Mu
* (1)phrase frequency
* (2)self define phrase
*
* Revision 1.5 2004/07/17 07:11:54 Lu Mu
* 1)phrase support
* 2)candidates sequence number,changed to 1,2,..,9,0
* 3)space key to select first candidate
*
* Revision 1.4 2004/07/15 13:56:18 Lu Mu
* fixed : hanzi candidates overlapped by system task bar while default font is not efont
*
* Revision 1.3 2004/07/10 16:58:11 Lu Mu
* bug fix of displaying hanzi problem after the first page
*
* Revision 1.2 2004/07/10 15:02:23 Lu Mu
* v0.0.1 released
* TODO: phase support
*
* Revision 1.1.1.1 2004/07/07 16:24:13 Lu Mu
* Created
*
*
*/