summaryrefslogtreecommitdiff
authorhash <hash>2002-08-22 16:30:01 (UTC)
committer hash <hash>2002-08-22 16:30:01 (UTC)
commit4b0db964f77e4b3caa1f95ea753c89094b86e0d6 (patch) (side-by-side diff)
tree1be74ef5d6bf3101815b5ecdafb21c0db470715e
parent8503abdc93f6f3ce93cee0f1176faa919dbd04f5 (diff)
downloadopie-4b0db964f77e4b3caa1f95ea753c89094b86e0d6.zip
opie-4b0db964f77e4b3caa1f95ea753c89094b86e0d6.tar.gz
opie-4b0db964f77e4b3caa1f95ea753c89094b86e0d6.tar.bz2
xpm images now are the same color as the text
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp19
-rw-r--r--inputmethods/multikey/keyboard.h6
2 files changed, 13 insertions, 12 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index e3d3928..3f6f73b 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -168,94 +168,95 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
for (int i = 0; i < col; i++) {
x += keys->width(row, i) * defaultKeyWidth;
}
int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
int keyWidth = keys->width(row, col);
p.fillRect(x + 1, y + 1,
keyWidth * defaultKeyWidth - 1, keyHeight - 1,
pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
- QPixmap *pix = keys->pix(row,col);
+ QImage *pix = keys->pix(row,col);
ushort c = keys->uni(row, col);
p.setPen(textcolor);
if (!pix) {
if (shift || lock)
c = keys->shift(c);
if (meta) {
c = keys->meta(c);
}
p.drawText(x, y,
defaultKeyWidth * keyWidth + 3, keyHeight,
AlignCenter, (QChar)c);
}
else
// center the image in the middle of the key
- p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2,
+ p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2,
y + (keyHeight - pix->height())/2 + 1,
*pix );
// this fixes the problem that the very right end of the board's vertical line
// gets painted over, because it's one pixel shorter than all other keys
p.setPen(keycolor_lines);
p.drawLine(width() - 1, 0, width() - 1, height());
} else {
p.fillRect(0, 0, width(), height(), keycolor);
for (row = 1; row <= 5; row++) {
int x = 0;
int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
p.setPen(keycolor_lines);
p.drawLine(x, y, x + width(), y);
for (int col = 0; col < keys->numKeys(row); col++) {
- QPixmap *pix = keys->pix(row, col);
+ QImage *pix = keys->pix(row, col);
int keyWidth = keys->width(row, col);
int keyWidthPix = defaultKeyWidth * keyWidth;
if (keys->pressed(row, col))
p.fillRect(x+1, y+1, keyWidthPix - 1,
keyHeight - 1, keycolor_pressed);
ushort c = keys->uni(row, col);
p.setPen(textcolor);
if (!pix) {
if ((shift || lock) && keys->shift(c))
c = keys->shift(c);
else if (meta && keys->meta(c))
c = keys->meta(c);
p.drawText(x, y,
keyWidthPix + 3, keyHeight,
AlignCenter, (QChar)c);
}
else {
// center the image in the middle of the key
- p.drawPixmap( x + (keyWidthPix - pix->width())/2,
+ pix->setColor(1, textcolor.rgb());
+ p.drawImage( x + (keyWidthPix - pix->width())/2,
y + (keyHeight - pix->height())/2 + 1,
- QPixmap(*pix) );
+ QImage(*pix) );
}
p.setPen(keycolor_lines);
p.drawLine(x, y, x, y + keyHeight);
x += keyWidthPix;
}
}
p.setPen(keycolor_lines);
p.drawLine(0, height() - 1, width(), height() - 1);
@@ -1035,25 +1036,25 @@ void Keys::setKeysFromFile(const char * filename) {
QFile f(filename);
if (f.open(IO_ReadOnly)) {
QTextStream t(&f);
int row;
int qcode;
ushort unicode;
int width;
QString buf;
QString comment;
char * xpm[256]; //couldnt be larger than that... could it?
- QPixmap *xpm2pix = 0;
+ QImage *xpm2pix = 0;
buf = t.readLine();
while (buf) {
// get rid of comments
buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
// key definition
if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
// no $1 type referencing!!! this implementation of regexp sucks
// dont know of any sscanf() type funcs in Qt lib
@@ -1081,25 +1082,25 @@ void Keys::setKeysFromFile(const char * filename) {
j++;
}
}
// have to close that facker up
((char *)xpm[xpmLineCount])[j] = '\0';
xpmLineCount++;
buf = t.readLine();
}
if (xpmLineCount) {
- xpm2pix = new QPixmap((const char **)xpm);
+ xpm2pix = new QImage((const char **)xpm);
for (int i = 0; i < xpmLineCount; i++)
delete [] (xpm[i]);
}
setKey(row, qcode, unicode, width, xpm2pix);
}
// shift map
else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
QTextStream tmp (buf, IO_ReadOnly);
@@ -1150,25 +1151,25 @@ void Keys::setKeysFromFile(const char * filename) {
buf = t.readLine();
}
}
f.close();
}
}
// Keys::setKey {{{2
void Keys::setKey(const int row, const int qcode, const ushort unicode,
- const int width, QPixmap *pix) {
+ const int width, QImage *pix) {
Key * key;
key = new Key;
key->qcode = qcode;
key->unicode = unicode;
key->width = width;
// share key->pressed between same keys
bool found = 0;
for (int i = 1; i <= 5; i++) {
for (unsigned int j = 0; j < keys[i].count(); j++)
if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
@@ -1207,25 +1208,25 @@ int Keys::width(const int row, const int col) {
}
ushort Keys::uni(const int row, const int col) {
return keys[row].at(col)->unicode;
}
int Keys::qcode(const int row, const int col) {
return keys[row].at(col)->qcode;
}
-QPixmap *Keys::pix(const int row, const int col) {
+QImage *Keys::pix(const int row, const int col) {
return keys[row].at(col)->pix;
}
bool Keys::pressed(const int row, const int col) {
return *(keys[row].at(col)->pressed);
}
int Keys::numKeys(const int row) {
return keys[row].count();
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index b692975..1aa7a35 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -54,43 +54,43 @@ class Keys {
public:
Keys();
Keys(const char * filename);
~Keys();
ushort uni(const int row, const int col);
int qcode(const int row, const int col);
int width(const int row, const int col);
bool pressed(const int row, const int col);
bool *pressedPtr(const int row, const int col);
ushort shift(const ushort);
ushort meta(const ushort);
- QPixmap *pix(const int row, const int col);
+ QImage *pix(const int row, const int col);
int numKeys(const int row);
void setKeysFromFile(const char *filename);
void setKey(const int row, const int qcode, const ushort unicode,
- const int width, QPixmap *pix);
+ const int width, QImage *pix);
void setPressed(const int row, const int col, const bool pressed);
QString lang;
QString label;
private:
typedef struct Key {
int qcode; // are qt key codes just unicode values?
ushort unicode;
int width; // not pixels but relative key width. normal key is 2
// only needed for keys like ctrl that can have multiple keys pressed at once
bool *pressed;
- QPixmap *pix;
+ QImage *pix;
};
QList<Key> keys[6];
QMap<ushort,ushort> shiftMap;
QMap<ushort,ushort> metaMap;
};
class Keyboard : public QFrame
{
Q_OBJECT
public: