summaryrefslogtreecommitdiff
path: root/inputmethods/kjumpx/keyboard.cpp
authordrw <drw>2005-06-15 22:54:50 (UTC)
committer drw <drw>2005-06-15 22:54:50 (UTC)
commit7ff2e7bd4620a574f3ff22a951a5904310cfd920 (patch) (side-by-side diff)
tree6d8ffd28aadf00901b3ab560464794aded3efc76 /inputmethods/kjumpx/keyboard.cpp
parente0205bac48b9d23af9feb48004c24fcf7a5e8200 (diff)
downloadopie-7ff2e7bd4620a574f3ff22a951a5904310cfd920.zip
opie-7ff2e7bd4620a574f3ff22a951a5904310cfd920.tar.gz
opie-7ff2e7bd4620a574f3ff22a951a5904310cfd920.tar.bz2
Resource -> OResource
Diffstat (limited to 'inputmethods/kjumpx/keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/kjumpx/keyboard.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/inputmethods/kjumpx/keyboard.cpp b/inputmethods/kjumpx/keyboard.cpp
index dc44805..4e99f40 100644
--- a/inputmethods/kjumpx/keyboard.cpp
+++ b/inputmethods/kjumpx/keyboard.cpp
@@ -1,62 +1,62 @@
/**************************************************************************************94x78**
**
** 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.
**
*********************************************************************************************/
#include "keyboard.h"
-#include <qpe/resource.h>
+#include <opie2/oresource.h>
//#include <iostream.h>
static const int autorepeatDelaytime = 500; // ms
static const int autorepeatRate = 20; // chars per second
static const int mod1x1 = 0;
static const int mod1x2 = 23;
static const int mod1w = mod1x2 - mod1x1;
static const int letterx1 = 27;
static const int letterx2 = 129;
static const int letterw = 17;
static const int letterh = 14;
static const int num1x1 = 130;
static const int num1x2 = 137;
static const int num1w = num1x2 - num1x1;
static const int specialx1 = 138;
static const int specialx2 = 170;
static const int specialw = 16;
static const int num2x1 = 171;
static const int num2x2 = 178;
static const int num2w = num2x2 - num2x1;
static const int mod2x1 = 179;
static const int mod2x2 = 203;
static const int mod2w = mod2x2 - mod2x1;
static const int cursorx1 = 207;
static const int cursorw = 16;
static const int myParenID = -10;
typedef struct mapElement
{
int qcode;
ushort unicode;
};
static const mapElement mod1Map[] = {
{ Qt::Key_Escape, 27 },
{ Qt::Key_Tab, 9 },
{ Qt::Key_Return, 13 },
@@ -108,115 +108,115 @@ static const uchar *const specialMap[] = {
static const uchar *const specialMapShift[] = {
(const uchar *const)"_=",
(const uchar *const)"#?",
(const uchar *const)";\"",
(const uchar *const)":|",
(const uchar *const)"\\&",
};
static const uchar *const specialMapParen[] = {
(const uchar *const)"()",
(const uchar *const)"[]",
(const uchar *const)"{}",
(const uchar *const)"<>",
(const uchar *const)"@~",
};
static const uchar *const num2Map = (const uchar *const)"67890";
static const mapElement mod2Map[] = {
{ Qt::Key_Backspace, 8 },
{ Qt::Key_Delete, 0 },
{ Qt::Key_Return, 13 },
{ Qt::Key_Shift, 0 },
{ myParenID, 0 },
};
static const int cursorMap[][2] = {
{ Qt::Key_Home, Qt::Key_PageUp },
{ Qt::Key_End, Qt::Key_PageDown },
{ Qt::Key_Up, Qt::Key_Up },
{ Qt::Key_Left, Qt::Key_Right },
{ Qt::Key_Down, Qt::Key_Down },
};
using namespace KJumpX;
Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) :
QFrame(parent, name, f),
shift(0), paren(0), ctrl(0), alt(0), lang(1), lastKey(0),
pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0),
isnoncont(false),
slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0),
enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL),
releasedPix(NULL), pressedPix(NULL)
{
//setPalette(QPalette(QColor(240,240,230))); // Beige!
- releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("kjumpx/released");
- pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("kjumpx/pressed");
- pressedDigit = Resource::loadPixmap("kjumpx/pressed");
+ releasedPlain = releasedShift = releasedParen = Opie::Core::OResource::loadPixmap("kjumpx/released");
+ pressedPlain = pressedShift = pressedParen = Opie::Core::OResource::loadPixmap("kjumpx/pressed");
+ pressedDigit = Opie::Core::OResource::loadPixmap("kjumpx/pressed");
QPixmap tmp;
- tmp = Resource::loadPixmap("kjumpx/releasedShift");
+ tmp = Opie::Core::OResource::loadPixmap("kjumpx/releasedShift");
bitBlt(&releasedShift, letterx1, 0, &tmp);
- tmp = Resource::loadPixmap("kjumpx/releasedParen");
+ tmp = Opie::Core::OResource::loadPixmap("kjumpx/releasedParen");
bitBlt(&releasedParen, specialx1, 0, &tmp);
- tmp = Resource::loadPixmap("kjumpx/pressedShift");
+ tmp = Opie::Core::OResource::loadPixmap("kjumpx/pressedShift");
bitBlt(&pressedShift, letterx1, 0, &tmp);
- tmp = Resource::loadPixmap("kjumpx/pressedParen");
+ tmp = Opie::Core::OResource::loadPixmap("kjumpx/pressedParen");
bitBlt(&pressedParen, specialx1, 0, &tmp);
- tmp = Resource::loadPixmap("kjumpx/pressedDigit");
+ tmp = Opie::Core::OResource::loadPixmap("kjumpx/pressedDigit");
bitBlt(&pressedDigit, specialx1, 0, &tmp);
offscreen = QPixmap( releasedPlain );
releasedPix = &releasedPlain;
pressedPix = &pressedPlain;
slidePix = &pressedPlain;
delayTimer = new QTimer(this);
rateTimer = new QTimer(this);
connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) );
connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) );
}
void Keyboard::resizeEvent(QResizeEvent*)
{
//cout << "resizeEvent()" << endl;
}
void Keyboard::paintEvent(QPaintEvent*)
{
bitBlt(this, 0, 0, &offscreen);
}
void Keyboard::mousePressEvent(QMouseEvent *e)
{
pressedx = -1;
pressedKeyUnicode = pressedKeyQcode = pressedMod = 0;
int x = e->x();
int y = e->y();
int row = (y - 1) / letterh;
if ( x <= mod1x2 ) // mod1
{
pressedx = mod1x1;
pressedy = row * letterh;
pressedw = mod1w + 1;
pressedh = letterh + 1;
if ( row == 2 ) // return
{
pressed2x = mod2x1;
pressed2y = 2 * letterh;
pressed2w = mod2w + 1;
pressed2h = letterh + 1;
isnoncont = true;
}
@@ -519,185 +519,185 @@ void Keyboard::mouseMoveEvent(QMouseEvent *e)
rateTimer->stop();
bitBlt( &offscreen, pressedx, pressedy,
slidePix, pressedx, pressedy, pressedw, pressedh );
emit key( 8, Qt::Key_Backspace, pressedMod, true, false );
emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false );
delayTimer->start( autorepeatDelaytime, true );
repaint( false );
}
void Keyboard::delayTimerDone()
{
emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true );
rateTimer->start( 1000/autorepeatRate, false );
}
void Keyboard::rateTimerDone()
{
emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true );
}
QSize Keyboard::sizeHint() const
{
return offscreen.size();
}
void Keyboard::resetState()
{
//cout << "resetState()" << endl;
}
/*
*
* TODO
* one major problem with this implementation is that you can't move the
* cursor after inputing korean chars, otherwise it will eat up and replace
* the char before the cursor you move to. fix that
*
* make a kor/eng swaping key
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* how korean input works
*
* all following chars means unicode char value and are in hex
*
- * ÃÊÀ½ = schar (start char)
- * ÁßÀ½ = mchar (middle char)
- * ³¡À½ = echar (end char)
+ * �= = schar (start char)
+ * �= = mchar (middle char)
+ * = = echar (end char)
*
* there are 19 schars. unicode position is at 1100 - 1112
* there are 21 mchars. unicode position is at 1161 - 1175
* there are 27 echars. unicode position is at 11a8 - 11c2
*
* the map with everything combined is at ac00 - d7a3
*
* to find a combination of schar + mchar in the map, lookup
* ((schar - 0x1100) * 587) + ((mchar - 0x1161) * 27) + (echar - 0x11a8) + 0xac00)
*
*/
QChar Keyboard::parseKoreanInput (ushort c) {
static ushort schar, mchar, echar;
if ((lastKey < 0x1100 || 0x11c2 < lastKey) && (lastKey < 0xac00 || 0xd7a3 < lastKey)
&& !(lastKey == 0 && (shift || paren || ctrl || alt))) {
//printf ("reset...\n");
schar = 0, mchar = 0, echar = 0;
}
//printf ("in %x %x %x %x %x\n", schar, mchar, echar, c, lastKey);
if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
if (schar == 0 || (schar != 0 && mchar == 0)) {
schar = c; mchar = 0; echar = 0;
return QChar(c);
}
else if (mchar != 0) {
if (echar == 0) {
if (!(echar = constoe(c))) {
schar = c; mchar = 0; echar = 0;
return QChar(c);
}
}
else { // must figure out what the echar is
- if (echar == 0x11a8) { // ¤¡
+ if (echar == 0x11a8) { //
- if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡
- else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ
+ if (c == 0x1100) echar = 0x11a9; // +
+ else if (c == 0x1109) echar = 0x11aa; // +
else {
schar = c; mchar = 0; echar = 0;
return QChar(c);
}
- } else if (echar == 0x11ab) { // ¤¤
+ } else if (echar == 0x11ab) { //
- if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸
- else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾
+ if (c == 0x110c) echar = 0x11ac; // +
+ else if (c == 0x1112) echar = 0x11ad; // +
else {
schar = c; mchar = 0; echar = 0;
return QChar(c);
}
- } else if (echar == 0x11af) { // ¤©
+ } else if (echar == 0x11af) { //
- if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡
- else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤±
- else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤²
- else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ
- else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼
- else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½
- else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾
+ if (c == 0x1100) echar = 0x11b0; // +
+ else if (c == 0x1106) echar = 0x11b1; // +
+ else if (c == 0x1107) echar = 0x11b2; // +
+ else if (c == 0x1109) echar = 0x11b3; // +
+ else if (c == 0x1110) echar = 0x11b4; // +
+ else if (c == 0x1111) echar = 0x11b5; // +
+ else if (c == 0x1112) echar = 0x11b6; // +
else {
schar = c; mchar = 0; echar = 0;
return QChar(c);
}
- } else if (echar == 0x11b8) { // ¤²
+ } else if (echar == 0x11b8) { //
- if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ
+ if (c == 0x1109) echar = 0x11b9; // +
else {
schar = c; mchar = 0; echar = 0;
return QChar(c);
}
- } else if (echar == 0x11ba) { // ¤µ
+ } else if (echar == 0x11ba) { //
- if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ
+ if (c == 0x1109) echar = 0x11bb; // +
else {
schar = c; mchar = 0; echar = 0;
return QChar(c);
}
} else { // if any other char, cannot combine chars
schar = c; mchar = 0; echar = 0;
return QChar(c);
}
lastKey = echar;
}
}
}
else if (0x1161 <= c && c <= 0x1175) { // mchar was input
if (schar != 0 && mchar == 0) { mchar = c; }
else if (schar != 0 && mchar != 0 && echar == 0) {
switch (mchar) {
case 0x1169:
if (c == 0x1161) mchar = 0x116a;
else if (c == 0x1162) mchar = 0x116b;
else if (c == 0x1175) mchar = 0x116c;
else {
schar = 0; mchar = 0; echar = 0;
return QChar(c);
}
break;
case 0x116e:
if (c == 0x1165) mchar = 0x116f;
else if (c == 0x1166) mchar = 0x1170;
else if (c == 0x1175) mchar = 0x1171;
else {
schar = 0; mchar = 0; echar = 0;
return QChar(c);
}
break;
case 0x1173:
if (c == 0x1175) mchar = 0x1174;
else {
schar = 0; mchar = 0; echar = 0;
return QChar(c);
}
break;