author | hash <hash> | 2002-08-22 16:30:01 (UTC) |
---|---|---|
committer | hash <hash> | 2002-08-22 16:30:01 (UTC) |
commit | 4b0db964f77e4b3caa1f95ea753c89094b86e0d6 (patch) (side-by-side diff) | |
tree | 1be74ef5d6bf3101815b5ecdafb21c0db470715e /inputmethods | |
parent | 8503abdc93f6f3ce93cee0f1176faa919dbd04f5 (diff) | |
download | opie-4b0db964f77e4b3caa1f95ea753c89094b86e0d6.zip opie-4b0db964f77e4b3caa1f95ea753c89094b86e0d6.tar.gz opie-4b0db964f77e4b3caa1f95ea753c89094b86e0d6.tar.bz2 |
xpm images now are the same color as the text
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 19 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 6 |
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 @@ -174,13 +174,13 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) 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) @@ -192,13 +192,13 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) 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); @@ -216,13 +216,13 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) 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)) @@ -241,15 +241,16 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) 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; @@ -1041,13 +1042,13 @@ void Keys::setKeysFromFile(const char * filename) { 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), ""); @@ -1087,13 +1088,13 @@ void Keys::setKeysFromFile(const char * filename) { 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); @@ -1156,13 +1157,13 @@ void Keys::setKeysFromFile(const char * filename) { } } // 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; @@ -1213,13 +1214,13 @@ ushort Keys::uni(const int row, const int col) { 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) { 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 @@ -60,17 +60,17 @@ public: 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: @@ -78,13 +78,13 @@ private: 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; |