-rw-r--r-- | inputmethods/unikeyboard/.cvsignore | 3 | ||||
-rw-r--r-- | inputmethods/unikeyboard/Makefile.in | 115 | ||||
-rw-r--r-- | inputmethods/unikeyboard/qpe-unikeyboard.control | 9 | ||||
-rwxr-xr-x | inputmethods/unikeyboard/qpe-unikeyboard.postinst | 2 | ||||
-rwxr-xr-x | inputmethods/unikeyboard/qpe-unikeyboard.postrm | 2 | ||||
-rw-r--r-- | inputmethods/unikeyboard/unikeyboard.cpp | 278 | ||||
-rw-r--r-- | inputmethods/unikeyboard/unikeyboard.h | 77 | ||||
-rw-r--r-- | inputmethods/unikeyboard/unikeyboard.pro | 12 | ||||
-rw-r--r-- | inputmethods/unikeyboard/unikeyboardimpl.cpp | 105 | ||||
-rw-r--r-- | inputmethods/unikeyboard/unikeyboardimpl.h | 49 |
10 files changed, 652 insertions, 0 deletions
diff --git a/inputmethods/unikeyboard/.cvsignore b/inputmethods/unikeyboard/.cvsignore new file mode 100644 index 0000000..edfa921 --- a/dev/null +++ b/inputmethods/unikeyboard/.cvsignore | |||
@@ -0,0 +1,3 @@ | |||
1 | moc_* | ||
2 | *.moc | ||
3 | Makefile | ||
diff --git a/inputmethods/unikeyboard/Makefile.in b/inputmethods/unikeyboard/Makefile.in new file mode 100644 index 0000000..ebbab50 --- a/dev/null +++ b/inputmethods/unikeyboard/Makefile.in | |||
@@ -0,0 +1,115 @@ | |||
1 | ############################################################################# | ||
2 | |||
3 | ####### Compiler, tools and options | ||
4 | |||
5 | CXX =$(SYSCONF_CXX) $(QT_CXX_MT) | ||
6 | CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB) | ||
7 | CC =$(SYSCONF_CC) $(QT_C_MT) | ||
8 | CFLAGS =$(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB) | ||
9 | INCPATH =-I$(QPEDIR)/include | ||
10 | LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) | ||
11 | LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP) | ||
12 | MOC =$(SYSCONF_MOC) | ||
13 | UIC =$(SYSCONF_UIC) | ||
14 | |||
15 | ####### Target | ||
16 | |||
17 | DESTDIR = ../../plugins/inputmethods/ | ||
18 | VER_MAJ = 1 | ||
19 | VER_MIN = 0 | ||
20 | VER_PATCH = 0 | ||
21 | TARGET= qunikeyboard | ||
22 | TARGET1 = lib$(TARGET).so.$(VER_MAJ) | ||
23 | |||
24 | ####### Files | ||
25 | |||
26 | HEADERS =unikeyboard.h \ | ||
27 | unikeyboardimpl.h | ||
28 | SOURCES =unikeyboard.cpp \ | ||
29 | unikeyboardimpl.cpp | ||
30 | OBJECTS =unikeyboard.o \ | ||
31 | unikeyboardimpl.o | ||
32 | INTERFACES = | ||
33 | UICDECLS = | ||
34 | UICIMPLS = | ||
35 | SRCMOC =moc_unikeyboard.cpp | ||
36 | OBJMOC =moc_unikeyboard.o | ||
37 | |||
38 | |||
39 | ####### Implicit rules | ||
40 | |||
41 | .SUFFIXES: .cpp .cxx .cc .C .c | ||
42 | |||
43 | .cpp.o: | ||
44 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
45 | |||
46 | .cxx.o: | ||
47 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
48 | |||
49 | .cc.o: | ||
50 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
51 | |||
52 | .C.o: | ||
53 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
54 | |||
55 | .c.o: | ||
56 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
57 | |||
58 | ####### Build rules | ||
59 | |||
60 | |||
61 | all: $(DESTDIR)$(SYSCONF_LINK_TARGET) | ||
62 | |||
63 | $(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
64 | $(SYSCONF_LINK_LIB) | ||
65 | |||
66 | moc: $(SRCMOC) | ||
67 | |||
68 | tmake: | ||
69 | tmake unikeyboard.pro | ||
70 | |||
71 | clean: | ||
72 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | ||
73 | -rm -f *~ core | ||
74 | -rm -f allmoc.cpp | ||
75 | |||
76 | ####### Extension Modules | ||
77 | |||
78 | listpromodules: | ||
79 | @echo | ||
80 | |||
81 | listallmodules: | ||
82 | @echo | ||
83 | |||
84 | listaddonpromodules: | ||
85 | @echo | ||
86 | |||
87 | listaddonentmodules: | ||
88 | @echo | ||
89 | |||
90 | |||
91 | REQUIRES= | ||
92 | |||
93 | ####### Sub-libraries | ||
94 | |||
95 | |||
96 | ###### Combined headers | ||
97 | |||
98 | |||
99 | |||
100 | ####### Compile | ||
101 | |||
102 | unikeyboard.o: unikeyboard.cpp \ | ||
103 | unikeyboard.h | ||
104 | |||
105 | unikeyboardimpl.o: unikeyboardimpl.cpp \ | ||
106 | unikeyboard.h \ | ||
107 | unikeyboardimpl.h | ||
108 | |||
109 | moc_unikeyboard.o: moc_unikeyboard.cpp \ | ||
110 | unikeyboard.h | ||
111 | |||
112 | moc_unikeyboard.cpp: unikeyboard.h | ||
113 | $(MOC) unikeyboard.h -o moc_unikeyboard.cpp | ||
114 | |||
115 | |||
diff --git a/inputmethods/unikeyboard/qpe-unikeyboard.control b/inputmethods/unikeyboard/qpe-unikeyboard.control new file mode 100644 index 0000000..a8c9bd3 --- a/dev/null +++ b/inputmethods/unikeyboard/qpe-unikeyboard.control | |||
@@ -0,0 +1,9 @@ | |||
1 | Files: plugins/inputmethods/libqunikeyboard.so* | ||
2 | Priority: optional | ||
3 | Section: qpe/inputmethods | ||
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-3 | ||
7 | Depends: qpe-base ($QPE_VERSION) | ||
8 | Description: Unicode input method | ||
9 | Basic unicode input method for the Qtopia environment. | ||
diff --git a/inputmethods/unikeyboard/qpe-unikeyboard.postinst b/inputmethods/unikeyboard/qpe-unikeyboard.postinst new file mode 100755 index 0000000..c254b01 --- a/dev/null +++ b/inputmethods/unikeyboard/qpe-unikeyboard.postinst | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/sh | ||
2 | /opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadInputMethods()" | ||
diff --git a/inputmethods/unikeyboard/qpe-unikeyboard.postrm b/inputmethods/unikeyboard/qpe-unikeyboard.postrm new file mode 100755 index 0000000..c254b01 --- a/dev/null +++ b/inputmethods/unikeyboard/qpe-unikeyboard.postrm | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/sh | ||
2 | /opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadInputMethods()" | ||
diff --git a/inputmethods/unikeyboard/unikeyboard.cpp b/inputmethods/unikeyboard/unikeyboard.cpp new file mode 100644 index 0000000..aa74c66 --- a/dev/null +++ b/inputmethods/unikeyboard/unikeyboard.cpp | |||
@@ -0,0 +1,278 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "unikeyboard.h" | ||
22 | |||
23 | #include <qpe/fontmanager.h> | ||
24 | |||
25 | #include <qpainter.h> | ||
26 | #include <qfontmetrics.h> | ||
27 | #include <qcombobox.h> | ||
28 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | ||
29 | #include <qwindowsystem_qws.h> | ||
30 | #endif | ||
31 | |||
32 | static const int nw = 8; | ||
33 | |||
34 | typedef struct BlockMap { | ||
35 | ushort start; | ||
36 | ushort stop; | ||
37 | const char *name; | ||
38 | }; | ||
39 | |||
40 | //# Start Code; Block Name | ||
41 | |||
42 | static const BlockMap blockMap[] = | ||
43 | { | ||
44 | {0x0000, 0x007F, "Basic Latin"}, | ||
45 | {0x0080, 0x00FF, "Latin-1 Supplement"}, | ||
46 | {0x0100, 0x017F, "Latin Extended-A"}, | ||
47 | {0x0180, 0x024F, "Latin Extended-B"}, | ||
48 | {0x0250, 0x02AF, "IPA Extensions"}, | ||
49 | {0x02B0, 0x02FF, "Spacing Modifier Letters"}, | ||
50 | {0x0300, 0x036F, "Combining Diacritical Marks"}, | ||
51 | {0x0370, 0x03FF, "Greek"}, | ||
52 | {0x0400, 0x04FF, "Cyrillic"}, | ||
53 | {0x0530, 0x058F, "Armenian"}, | ||
54 | {0x0590, 0x05FF, "Hebrew"}, | ||
55 | {0x0600, 0x06FF, "Arabic"}, | ||
56 | {0x0700, 0x074F, "Syriac "}, | ||
57 | {0x0780, 0x07BF, "Thaana"}, | ||
58 | {0x0900, 0x097F, "Devanagari"}, | ||
59 | {0x0980, 0x09FF, "Bengali"}, | ||
60 | {0x0A00, 0x0A7F, "Gurmukhi"}, | ||
61 | {0x0A80, 0x0AFF, "Gujarati"}, | ||
62 | {0x0B00, 0x0B7F, "Oriya"}, | ||
63 | {0x0B80, 0x0BFF, "Tamil"}, | ||
64 | {0x0C00, 0x0C7F, "Telugu"}, | ||
65 | {0x0C80, 0x0CFF, "Kannada"}, | ||
66 | {0x0D00, 0x0D7F, "Malayalam"}, | ||
67 | {0x0D80, 0x0DFF, "Sinhala"}, | ||
68 | {0x0E00, 0x0E7F, "Thai"}, | ||
69 | {0x0E80, 0x0EFF, "Lao"}, | ||
70 | {0x0F00, 0x0FFF, "Tibetan"}, | ||
71 | {0x1000, 0x109F, "Myanmar "}, | ||
72 | {0x10A0, 0x10FF, "Georgian"}, | ||
73 | {0x1100, 0x11FF, "Hangul Jamo"}, | ||
74 | {0x1200, 0x137F, "Ethiopic"}, | ||
75 | {0x13A0, 0x13FF, "Cherokee"}, | ||
76 | {0x1400, 0x167F, "Unified Canadian Aboriginal Syllabics"}, | ||
77 | {0x1680, 0x169F, "Ogham"}, | ||
78 | {0x16A0, 0x16FF, "Runic"}, | ||
79 | {0x1780, 0x17FF, "Khmer"}, | ||
80 | {0x1800, 0x18AF, "Mongolian"}, | ||
81 | {0x1E00, 0x1EFF, "Latin Extended Additional"}, | ||
82 | {0x1F00, 0x1FFF, "Greek Extended"}, | ||
83 | {0x2000, 0x206F, "General Punctuation"}, | ||
84 | {0x2070, 0x209F, "Superscripts and Subscripts"}, | ||
85 | {0x20A0, 0x20CF, "Currency Symbols"}, | ||
86 | {0x20D0, 0x20FF, "Combining Marks for Symbols"}, | ||
87 | {0x2100, 0x214F, "Letterlike Symbols"}, | ||
88 | {0x2150, 0x218F, "Number Forms"}, | ||
89 | {0x2190, 0x21FF, "Arrows"}, | ||
90 | {0x2200, 0x22FF, "Mathematical Operators"}, | ||
91 | {0x2300, 0x23FF, "Miscellaneous Technical"}, | ||
92 | {0x2400, 0x243F, "Control Pictures"}, | ||
93 | {0x2440, 0x245F, "Optical Character Recognition"}, | ||
94 | {0x2460, 0x24FF, "Enclosed Alphanumerics"}, | ||
95 | {0x2500, 0x257F, "Box Drawing"}, | ||
96 | {0x2580, 0x259F, "Block Elements"}, | ||
97 | {0x25A0, 0x25FF, "Geometric Shapes"}, | ||
98 | {0x2600, 0x26FF, "Miscellaneous Symbols"}, | ||
99 | {0x2700, 0x27BF, "Dingbats"}, | ||
100 | {0x2800, 0x28FF, "Braille Patterns"}, | ||
101 | {0x2E80, 0x2EFF, "CJK Radicals Supplement"}, | ||
102 | {0x2F00, 0x2FDF, "Kangxi Radicals"}, | ||
103 | {0x2FF0, 0x2FFF, "Ideographic Description Characters"}, | ||
104 | {0x3000, 0x303F, "CJK Symbols and Punctuation"}, | ||
105 | {0x3040, 0x309F, "Hiragana"}, | ||
106 | {0x30A0, 0x30FF, "Katakana"}, | ||
107 | {0x3100, 0x312F, "Bopomofo"}, | ||
108 | {0x3130, 0x318F, "Hangul Compatibility Jamo"}, | ||
109 | {0x3190, 0x319F, "Kanbun"}, | ||
110 | {0x31A0, 0x31BF, "Bopomofo Extended"}, | ||
111 | {0x3200, 0x32FF, "Enclosed CJK Letters and Months"}, | ||
112 | {0x3300, 0x33FF, "CJK Compatibility"}, | ||
113 | {0x3400, 0x4DB5, "CJK Unified Ideographs Extension A"}, | ||
114 | {0x4E00, 0x9FFF, "CJK Unified Ideographs"}, | ||
115 | {0xA000, 0xA48F, "Yi Syllables"}, | ||
116 | {0xA490, 0xA4CF, "Yi Radicals"}, | ||
117 | {0xAC00, 0xD7A3, "Hangul Syllables"}, | ||
118 | {0xD800, 0xDB7F, "High Surrogates"}, | ||
119 | {0xDB80, 0xDBFF, "High Private Use Surrogates"}, | ||
120 | {0xDC00, 0xDFFF, "Low Surrogates"}, | ||
121 | {0xE000, 0xF8FF, "Private Use"}, | ||
122 | {0xF900, 0xFAFF, "CJK Compatibility Ideographs"}, | ||
123 | {0xFB00, 0xFB4F, "Alphabetic Presentation Forms"}, | ||
124 | {0xFB50, 0xFDFF, "Arabic Presentation Forms-A"}, | ||
125 | {0xFE20, 0xFE2F, "Combining Half Marks"}, | ||
126 | {0xFE30, 0xFE4F, "CJK Compatibility Forms"}, | ||
127 | {0xFE50, 0xFE6F, "Small Form Variants"}, | ||
128 | {0xFE70, 0xFEFE, "Arabic Presentation Forms-B"}, | ||
129 | {0xFF00, 0xFEFF, "Halfwidth and Fullwidth Forms"}, | ||
130 | {0xFFF0, 0xFFEF, "Specials"}, | ||
131 | {0xFFFF, 0xFFFF, 0} }; | ||
132 | |||
133 | |||
134 | UniScrollview::UniScrollview(QWidget* parent, const char* name, int f) : | ||
135 | QScrollView(parent, name, f) | ||
136 | { | ||
137 | // smallFont.setRawName( "-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1" ); //###### | ||
138 | smallFont = QFont( "Helvetica", 8 ); | ||
139 | QFontMetrics sfm( smallFont ); | ||
140 | xoff = sfm.width( "AAA" ); | ||
141 | setFont( FontManager::unicodeFont( FontManager::Fixed ) ); | ||
142 | QFontMetrics fm( font() ); | ||
143 | cellsize = fm.lineSpacing() + 2; | ||
144 | resizeContents( cellsize*nw, cellsize*65536/nw ); | ||
145 | verticalScrollBar()->setLineStep(cellsize); | ||
146 | |||
147 | viewport()->setBackgroundMode( QWidget::PaletteBase ); | ||
148 | } | ||
149 | |||
150 | |||
151 | |||
152 | void UniScrollview::contentsMousePressEvent(QMouseEvent* e) | ||
153 | { | ||
154 | if ( e->x() < xoff || e->x() > xoff + nw*cellsize ) | ||
155 | return; | ||
156 | int row = e->y()/cellsize; | ||
157 | int col = (e->x()-xoff)/cellsize; | ||
158 | int u = row*nw+col; | ||
159 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | ||
160 | emit key( u, 0, 0, true, false ); | ||
161 | emit key( u, 0, 0, false, false ); | ||
162 | #endif | ||
163 | } | ||
164 | |||
165 | |||
166 | void UniScrollview::contentsMouseReleaseEvent(QMouseEvent*) | ||
167 | { | ||
168 | } | ||
169 | |||
170 | void UniScrollview::scrollTo( int unicode ) | ||
171 | { | ||
172 | int row = unicode / nw; | ||
173 | setContentsPos( 0, row*cellsize ); | ||
174 | } | ||
175 | |||
176 | |||
177 | void UniScrollview::drawContents( QPainter *p, int /*cx*/, int cy, int /*cw*/, int ch ) | ||
178 | { | ||
179 | QFontMetrics fm = fontMetrics(); | ||
180 | int row = cy / cellsize; | ||
181 | int y = row*cellsize; | ||
182 | while ( y < cy+ch ) { | ||
183 | p->drawLine( xoff, y, xoff+nw*cellsize, y ); | ||
184 | if ( row*nw%16 == 0 ) { | ||
185 | p->setFont( smallFont ); | ||
186 | QString s; | ||
187 | s.sprintf( "%03X", row*nw/16 ); | ||
188 | p->drawText( 0, y, xoff, cellsize, AlignLeft, s ); | ||
189 | p->setFont( font() ); | ||
190 | } | ||
191 | for ( int i = 0; i < nw; i++ ) { | ||
192 | p->drawLine( xoff+i*cellsize, y, xoff+i*cellsize, y+cellsize ); | ||
193 | QChar u = row*nw + i; | ||
194 | if ( fm.inFont( u ) ) | ||
195 | p->drawText( xoff+i*cellsize, y, cellsize, cellsize, AlignCenter, | ||
196 | u ); | ||
197 | } | ||
198 | p->drawLine( xoff+nw*cellsize, y, xoff+nw*cellsize, y+cellsize ); | ||
199 | row++; | ||
200 | y += cellsize; | ||
201 | } | ||
202 | } | ||
203 | |||
204 | |||
205 | |||
206 | |||
207 | UniKeyboard::UniKeyboard(QWidget* parent, const char* name, int f ) | ||
208 | : QFrame( parent, name, f ) | ||
209 | { | ||
210 | setFrameStyle( NoFrame ); | ||
211 | sv = new UniScrollview( this ); | ||
212 | cb = new QComboBox( FALSE, this ); | ||
213 | currentBlock = 0; | ||
214 | QFontMetrics fm = sv->fontMetrics(); | ||
215 | cbmap = new int[sizeof(blockMap)/sizeof(blockMap[0])]; | ||
216 | for ( int i = 0; blockMap[i].name; i++ ) { | ||
217 | bool any=FALSE; | ||
218 | for ( int c=blockMap[i].start; !any && c<=blockMap[i].stop; c++ ) | ||
219 | any = fm.inFont(QChar(c)); | ||
220 | if ( any ) { | ||
221 | cbmap[cb->count()]=i; | ||
222 | cb->insertItem( blockMap[i].name ); | ||
223 | } | ||
224 | } | ||
225 | connect( cb, SIGNAL( activated(int)), this, SLOT( handleCombo(int)) ); | ||
226 | connect( sv, SIGNAL( contentsMoving(int,int)), this, SLOT( svMove(int,int)) ); | ||
227 | connect( sv, SIGNAL( key(ushort,ushort,ushort,bool,bool)), | ||
228 | this, SIGNAL( key(ushort,ushort,ushort,bool,bool)) ); | ||
229 | } | ||
230 | |||
231 | UniKeyboard::~UniKeyboard() | ||
232 | { | ||
233 | delete [] cbmap; | ||
234 | } | ||
235 | |||
236 | void UniKeyboard::resizeEvent(QResizeEvent *) | ||
237 | { | ||
238 | int d = frameWidth(); | ||
239 | cb->setGeometry( d, d, width()-2*d, cb->sizeHint().height() ); | ||
240 | sv->setGeometry( d, cb->height()+d, width()-2*d, height()-cb->height()-2*d ); | ||
241 | } | ||
242 | |||
243 | void UniKeyboard::svMove( int /*x*/, int y ) | ||
244 | { | ||
245 | int cs = sv->cellSize(); | ||
246 | int u = ((y+cs-1)/cs) * nw; | ||
247 | int i = currentBlock; | ||
248 | while ( i > 0 && blockMap[i].start > u ) { | ||
249 | i--; | ||
250 | } | ||
251 | while ( blockMap[i+1].name && blockMap[i+1].start < u ) { | ||
252 | i++; | ||
253 | } | ||
254 | if ( i != currentBlock ) { | ||
255 | currentBlock = i; | ||
256 | for (int ind=0; ind<cb->count(); ind++) { | ||
257 | if ( cbmap[ind] == i ) { | ||
258 | cb->setCurrentItem( ind ); | ||
259 | break; | ||
260 | } | ||
261 | } | ||
262 | } | ||
263 | } | ||
264 | |||
265 | void UniKeyboard::handleCombo( int i ) | ||
266 | { | ||
267 | currentBlock = cbmap[i]; | ||
268 | sv->scrollTo( blockMap[currentBlock].start ); | ||
269 | } | ||
270 | |||
271 | void UniKeyboard::resetState() | ||
272 | { | ||
273 | } | ||
274 | |||
275 | QSize UniKeyboard::sizeHint() const | ||
276 | { | ||
277 | return QSize( 240, 2+sv->cellSize()*4+cb->sizeHint().height() ); | ||
278 | } | ||
diff --git a/inputmethods/unikeyboard/unikeyboard.h b/inputmethods/unikeyboard/unikeyboard.h new file mode 100644 index 0000000..1a716c0 --- a/dev/null +++ b/inputmethods/unikeyboard/unikeyboard.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include <qscrollview.h> | ||
21 | |||
22 | class QComboBox; | ||
23 | |||
24 | class UniScrollview : public QScrollView { | ||
25 | Q_OBJECT | ||
26 | public: | ||
27 | UniScrollview(QWidget* parent=0, const char* name=0, int f=0); | ||
28 | int cellSize() const { return cellsize; } | ||
29 | |||
30 | signals: | ||
31 | void key( ushort unicode, ushort scancode, ushort modifiers, bool, bool ); | ||
32 | |||
33 | public slots: | ||
34 | void scrollTo( int unicode ); | ||
35 | |||
36 | protected: | ||
37 | void contentsMousePressEvent(QMouseEvent*); | ||
38 | void contentsMouseReleaseEvent(QMouseEvent*); | ||
39 | void drawContents( QPainter *, int cx, int cy, int cw, int ch ) ; | ||
40 | |||
41 | private: | ||
42 | int cellsize; | ||
43 | QFont smallFont; | ||
44 | int xoff; | ||
45 | }; | ||
46 | |||
47 | |||
48 | class UniKeyboard : public QFrame | ||
49 | { | ||
50 | Q_OBJECT | ||
51 | public: | ||
52 | UniKeyboard(QWidget* parent=0, const char* name=0, int f=0); | ||
53 | ~UniKeyboard(); | ||
54 | |||
55 | void resetState(); | ||
56 | |||
57 | QSize sizeHint() const; | ||
58 | |||
59 | signals: | ||
60 | void key( ushort, ushort, ushort, bool, bool ); | ||
61 | |||
62 | protected: | ||
63 | void resizeEvent(QResizeEvent *); | ||
64 | |||
65 | private slots: | ||
66 | void handleCombo( int ); | ||
67 | void svMove( int, int ); | ||
68 | |||
69 | private: | ||
70 | UniScrollview *sv; | ||
71 | QComboBox *cb; | ||
72 | int currentBlock; | ||
73 | int* cbmap; | ||
74 | }; | ||
75 | |||
76 | |||
77 | |||
diff --git a/inputmethods/unikeyboard/unikeyboard.pro b/inputmethods/unikeyboard/unikeyboard.pro new file mode 100644 index 0000000..c0aad42 --- a/dev/null +++ b/inputmethods/unikeyboard/unikeyboard.pro | |||
@@ -0,0 +1,12 @@ | |||
1 | TEMPLATE= lib | ||
2 | CONFIG += qt warn_on release | ||
3 | HEADERS= unikeyboard.h unikeyboardimpl.h | ||
4 | SOURCES= unikeyboard.cpp unikeyboardimpl.cpp | ||
5 | TARGET = qunikeyboard | ||
6 | DESTDIR = ../../plugins/inputmethods | ||
7 | INCLUDEPATH += $(QPEDIR)/include | ||
8 | DEPENDPATH += ../$(QPEDIR)/include ../../taskbar | ||
9 | LIBS += -lqpe | ||
10 | VERSION = 1.0.0 | ||
11 | |||
12 | TRANSLATIONS += ../../i18n/de/libqunikeyboard.ts | ||
diff --git a/inputmethods/unikeyboard/unikeyboardimpl.cpp b/inputmethods/unikeyboard/unikeyboardimpl.cpp new file mode 100644 index 0000000..fe601e0 --- a/dev/null +++ b/inputmethods/unikeyboard/unikeyboardimpl.cpp | |||
@@ -0,0 +1,105 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include <qapplication.h> | ||
21 | #include <qobject.h> | ||
22 | #include <qpixmap.h> | ||
23 | #include "unikeyboard.h" | ||
24 | #include "unikeyboardimpl.h" | ||
25 | |||
26 | /* XPM */ | ||
27 | static const char * uni_xpm[]={ | ||
28 | "28 13 2 1", | ||
29 | "# c #000000", | ||
30 | ". c None", | ||
31 | "............................", | ||
32 | "...####....#####.....####...", | ||
33 | "...####....######....####...", | ||
34 | "...####....#######..........", | ||
35 | "...####....########..####...", | ||
36 | "...####....####.####.####...", | ||
37 | "...####....####..########...", | ||
38 | "...####....####...#######...", | ||
39 | "...####....####....######...", | ||
40 | "...#####..#####.....#####...", | ||
41 | "....##########.......####...", | ||
42 | "......######..........###...", | ||
43 | "............................"}; | ||
44 | |||
45 | UniKeyboardImpl::UniKeyboardImpl() | ||
46 | : input(0), icn(0), ref(0) | ||
47 | { | ||
48 | } | ||
49 | |||
50 | UniKeyboardImpl::~UniKeyboardImpl() | ||
51 | { | ||
52 | delete input; | ||
53 | delete icn; | ||
54 | } | ||
55 | |||
56 | QWidget *UniKeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) | ||
57 | { | ||
58 | if ( !input ) | ||
59 | input = new UniKeyboard( parent, "UniKeyboard", f ); | ||
60 | return input; | ||
61 | } | ||
62 | |||
63 | void UniKeyboardImpl::resetState() | ||
64 | { | ||
65 | if ( input ) | ||
66 | input->resetState(); | ||
67 | } | ||
68 | |||
69 | QPixmap *UniKeyboardImpl::icon() | ||
70 | { | ||
71 | if ( !icn ) | ||
72 | icn = new QPixmap( (const char **)uni_xpm ); | ||
73 | return icn; | ||
74 | } | ||
75 | |||
76 | QString UniKeyboardImpl::name() | ||
77 | { | ||
78 | return qApp->translate( "InputMethods", "Unicode" ); | ||
79 | } | ||
80 | |||
81 | void UniKeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) | ||
82 | { | ||
83 | if ( input ) | ||
84 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); | ||
85 | } | ||
86 | |||
87 | QRESULT UniKeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
88 | { | ||
89 | *iface = 0; | ||
90 | if ( uuid == IID_QUnknown ) | ||
91 | *iface = this; | ||
92 | else if ( uuid == IID_InputMethod ) | ||
93 | *iface = this; | ||
94 | |||
95 | if ( *iface ) | ||
96 | (*iface)->addRef(); | ||
97 | return QS_OK; | ||
98 | } | ||
99 | |||
100 | Q_EXPORT_INTERFACE() | ||
101 | { | ||
102 | Q_CREATE_INSTANCE( UniKeyboardImpl ) | ||
103 | } | ||
104 | |||
105 | |||
diff --git a/inputmethods/unikeyboard/unikeyboardimpl.h b/inputmethods/unikeyboard/unikeyboardimpl.h new file mode 100644 index 0000000..97b1ff6 --- a/dev/null +++ b/inputmethods/unikeyboard/unikeyboardimpl.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef UNIKEYBOARDIMPL_H | ||
21 | #define UNIKEYBOARDIMPL_H | ||
22 | |||
23 | #include <qpe/inputmethodinterface.h> | ||
24 | |||
25 | class UniKeyboard; | ||
26 | class QPixmap; | ||
27 | |||
28 | class UniKeyboardImpl : public InputMethodInterface | ||
29 | { | ||
30 | public: | ||
31 | UniKeyboardImpl(); | ||
32 | virtual ~UniKeyboardImpl(); | ||
33 | |||
34 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
35 | Q_REFCOUNT | ||
36 | |||
37 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); | ||
38 | virtual void resetState(); | ||
39 | virtual QPixmap *icon(); | ||
40 | virtual QString name(); | ||
41 | virtual void onKeyPress( QObject *receiver, const char *slot ); | ||
42 | |||
43 | private: | ||
44 | UniKeyboard *input; | ||
45 | QPixmap *icn; | ||
46 | ulong ref; | ||
47 | }; | ||
48 | |||
49 | #endif | ||