summaryrefslogtreecommitdiff
path: root/inputmethods
authorhash <hash>2002-08-27 07:41:59 (UTC)
committer hash <hash>2002-08-27 07:41:59 (UTC)
commit8760fbdfefe1b6c60400cdeee45a6ba892d40751 (patch) (unidiff)
tree50e8ad9d74c0332c5826a429abdeceb3142283b5 /inputmethods
parent2bd07423a53f1b564b898dc9cf4dfbd6f1e337da (diff)
downloadopie-8760fbdfefe1b6c60400cdeee45a6ba892d40751.zip
opie-8760fbdfefe1b6c60400cdeee45a6ba892d40751.tar.gz
opie-8760fbdfefe1b6c60400cdeee45a6ba892d40751.tar.bz2
pixmaps centered better
Diffstat (limited to 'inputmethods') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index c3ee8f3..92ea896 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -173,49 +173,49 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
173 int keyWidth = keys->width(row, col); 173 int keyWidth = keys->width(row, col);
174 174
175 p.fillRect(x + 1, y + 1, 175 p.fillRect(x + 1, y + 1,
176 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 176 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
177 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 177 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
178 178
179 QImage *pix = keys->pix(row,col); 179 QImage *pix = keys->pix(row,col);
180 180
181 ushort c = keys->uni(row, col); 181 ushort c = keys->uni(row, col);
182 182
183 p.setPen(textcolor); 183 p.setPen(textcolor);
184 if (!pix) { 184 if (!pix) {
185 if (shift || lock) 185 if (shift || lock)
186 c = keys->shift(c); 186 c = keys->shift(c);
187 if (meta) { 187 if (meta) {
188 188
189 c = keys->meta(c); 189 c = keys->meta(c);
190 } 190 }
191 p.drawText(x, y, 191 p.drawText(x, y,
192 defaultKeyWidth * keyWidth + 3, keyHeight, 192 defaultKeyWidth * keyWidth + 3, keyHeight,
193 AlignCenter, (QChar)c); 193 AlignCenter, (QChar)c);
194 } 194 }
195 else 195 else
196 // center the image in the middle of the key 196 // center the image in the middle of the key
197 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2, 197 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
198 y + (keyHeight - pix->height())/2 + 1, 198 y + (keyHeight - pix->height())/2 + 1,
199 *pix ); 199 *pix );
200 200
201 // this fixes the problem that the very right end of the board's vertical line 201 // this fixes the problem that the very right end of the board's vertical line
202 // gets painted over, because it's one pixel shorter than all other keys 202 // gets painted over, because it's one pixel shorter than all other keys
203 p.setPen(keycolor_lines); 203 p.setPen(keycolor_lines);
204 p.drawLine(width() - 1, 0, width() - 1, height()); 204 p.drawLine(width() - 1, 0, width() - 1, height());
205 205
206 } else { 206 } else {
207 207
208 208
209 p.fillRect(0, 0, width(), height(), keycolor); 209 p.fillRect(0, 0, width(), height(), keycolor);
210 210
211 for (row = 1; row <= 5; row++) { 211 for (row = 1; row <= 5; row++) {
212 212
213 int x = 0; 213 int x = 0;
214 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 214 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
215 215
216 p.setPen(keycolor_lines); 216 p.setPen(keycolor_lines);
217 p.drawLine(x, y, x + width(), y); 217 p.drawLine(x, y, x + width(), y);
218 218
219 for (int col = 0; col < keys->numKeys(row); col++) { 219 for (int col = 0; col < keys->numKeys(row); col++) {
220 220
221 QImage *pix = keys->pix(row, col); 221 QImage *pix = keys->pix(row, col);
@@ -223,49 +223,49 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
223 223
224 224
225 int keyWidthPix = defaultKeyWidth * keyWidth; 225 int keyWidthPix = defaultKeyWidth * keyWidth;
226 226
227 if (keys->pressed(row, col)) 227 if (keys->pressed(row, col))
228 p.fillRect(x+1, y+1, keyWidthPix - 1, 228 p.fillRect(x+1, y+1, keyWidthPix - 1,
229 keyHeight - 1, keycolor_pressed); 229 keyHeight - 1, keycolor_pressed);
230 230
231 ushort c = keys->uni(row, col); 231 ushort c = keys->uni(row, col);
232 232
233 p.setPen(textcolor); 233 p.setPen(textcolor);
234 if (!pix) { 234 if (!pix) {
235 if ((shift || lock) && keys->shift(c)) 235 if ((shift || lock) && keys->shift(c))
236 c = keys->shift(c); 236 c = keys->shift(c);
237 else if (meta && keys->meta(c)) 237 else if (meta && keys->meta(c))
238 c = keys->meta(c); 238 c = keys->meta(c);
239 239
240 p.drawText(x, y, 240 p.drawText(x, y,
241 keyWidthPix + 3, keyHeight, 241 keyWidthPix + 3, keyHeight,
242 AlignCenter, (QChar)c); 242 AlignCenter, (QChar)c);
243 } 243 }
244 else { 244 else {
245 // center the image in the middle of the key 245 // center the image in the middle of the key
246 pix->setColor(1, textcolor.rgb()); 246 pix->setColor(1, textcolor.rgb());
247 p.drawImage( x + (keyWidthPix - pix->width())/2, 247 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
248 y + (keyHeight - pix->height())/2 + 1, 248 y + (keyHeight - pix->height())/2 + 1,
249 QImage(*pix) ); 249 QImage(*pix) );
250 } 250 }
251 251
252 p.setPen(keycolor_lines); 252 p.setPen(keycolor_lines);
253 p.drawLine(x, y, x, y + keyHeight); 253 p.drawLine(x, y, x, y + keyHeight);
254 254
255 x += keyWidthPix; 255 x += keyWidthPix;
256 } 256 }
257 257
258 258
259 } 259 }
260 p.setPen(keycolor_lines); 260 p.setPen(keycolor_lines);
261 p.drawLine(0, height() - 1, width(), height() - 1); 261 p.drawLine(0, height() - 1, width(), height() - 1);
262 p.drawLine(width() - 1, 0, width() - 1, height()); 262 p.drawLine(width() - 1, 0, width() - 1, height());
263 } 263 }
264 264
265} 265}
266 266
267 267
268/* Keyboard::mousePressEvent {{{1 */ 268/* Keyboard::mousePressEvent {{{1 */
269void Keyboard::mousePressEvent(QMouseEvent *e) 269void Keyboard::mousePressEvent(QMouseEvent *e)
270{ 270{
271 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 271 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;