-rw-r--r-- | noncore/apps/opie-console/TEWidget.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp index d1ff85e..1c83710 100644 --- a/noncore/apps/opie-console/TEWidget.cpp +++ b/noncore/apps/opie-console/TEWidget.cpp | |||
@@ -262,192 +262,193 @@ static QChar identicalMap(QChar c) | |||
262 | 262 | ||
263 | void TEWidget::fontChange(const QFont &) | 263 | void TEWidget::fontChange(const QFont &) |
264 | { | 264 | { |
265 | QFontMetrics fm(font()); | 265 | QFontMetrics fm(font()); |
266 | font_h = fm.height(); | 266 | font_h = fm.height(); |
267 | font_w = fm.maxWidth(); | 267 | font_w = fm.maxWidth(); |
268 | font_a = fm.ascent(); | 268 | font_a = fm.ascent(); |
269 | //printf("font_h: %d\n",font_h); | 269 | //printf("font_h: %d\n",font_h); |
270 | //printf("font_w: %d\n",font_w); | 270 | //printf("font_w: %d\n",font_w); |
271 | //printf("font_a: %d\n",font_a); | 271 | //printf("font_a: %d\n",font_a); |
272 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | 272 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
273 | //printf("rawname: %s\n",font().rawName().ascii()); | 273 | //printf("rawname: %s\n",font().rawName().ascii()); |
274 | fontMap = | 274 | fontMap = |
275 | #if QT_VERSION < 300 | 275 | #if QT_VERSION < 300 |
276 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 276 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
277 | ? vt100extended | 277 | ? vt100extended |
278 | : | 278 | : |
279 | #endif | 279 | #endif |
280 | identicalMap; | 280 | identicalMap; |
281 | propagateSize(); | 281 | propagateSize(); |
282 | update(); | 282 | update(); |
283 | } | 283 | } |
284 | 284 | ||
285 | void TEWidget::setVTFont(const QFont& f) | 285 | void TEWidget::setVTFont(const QFont& f) |
286 | { | 286 | { |
287 | QFrame::setFont(f); | 287 | QFrame::setFont(f); |
288 | } | 288 | } |
289 | 289 | ||
290 | QFont TEWidget::getVTFont() { | 290 | QFont TEWidget::getVTFont() { |
291 | return font(); | 291 | return font(); |
292 | } | 292 | } |
293 | 293 | ||
294 | void TEWidget::setFont(const QFont &) | 294 | void TEWidget::setFont(const QFont &) |
295 | { | 295 | { |
296 | // ignore font change request if not coming from konsole itself | 296 | // ignore font change request if not coming from konsole itself |
297 | } | 297 | } |
298 | 298 | ||
299 | /* ------------------------------------------------------------------------- */ | 299 | /* ------------------------------------------------------------------------- */ |
300 | /* */ | 300 | /* */ |
301 | /* Constructor / Destructor */ | 301 | /* Constructor / Destructor */ |
302 | /* */ | 302 | /* */ |
303 | /* ----------------------------------------------------------------------- */ | 303 | /* ----------------------------------------------------------------------- */ |
304 | 304 | ||
305 | 305 | ||
306 | 306 | ||
307 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | 307 | TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) |
308 | { | 308 | { |
309 | #ifndef QT_NO_CLIPBOARD | 309 | #ifndef QT_NO_CLIPBOARD |
310 | cb = QApplication::clipboard(); | 310 | cb = QApplication::clipboard(); |
311 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 311 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
312 | this, SLOT(onClearSelection()) ); | 312 | this, SLOT(onClearSelection()) ); |
313 | #endif | 313 | #endif |
314 | 314 | ||
315 | 315 | ||
316 | scrollbar = new QScrollBar( this ); | 316 | scrollbar = new QScrollBar( this ); |
317 | scrollbar->setCursor( arrowCursor ); | 317 | scrollbar->setCursor( arrowCursor ); |
318 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 318 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
319 | 319 | ||
320 | hscrollbar = new QScrollBar( Qt::Horizontal, this ); | 320 | hscrollbar = new QScrollBar( Qt::Horizontal, this ); |
321 | hscrollbar->setCursor( arrowCursor ); | 321 | hscrollbar->setCursor( arrowCursor ); |
322 | connect(hscrollbar, SIGNAL(valueChanged(int)), this, SLOT(hscrollChanged(int))); | 322 | connect(hscrollbar, SIGNAL(valueChanged(int)), this, SLOT(hscrollChanged(int))); |
323 | 323 | ||
324 | m_cornerButton = new QPushButton( this ); | 324 | m_cornerButton = new QPushButton( this ); |
325 | m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); | 325 | m_cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); |
326 | m_cornerButton->setMaximumSize( 14, 14 ); | 326 | m_cornerButton->setMaximumSize( 14, 14 ); |
327 | m_cornerButton->hide(); | 327 | m_cornerButton->hide(); |
328 | 328 | ||
329 | Config cfg("Konsole"); | 329 | Config cfg("Konsole"); |
330 | cfg.setGroup("ScrollBar"); | 330 | cfg.setGroup("ScrollBar"); |
331 | switch( cfg.readNumEntry("Position",2)){ | 331 | switch( cfg.readNumEntry("Position",2)){ |
332 | case 0: | 332 | case 0: |
333 | scrollLoc = SCRNONE; | 333 | scrollLoc = SCRNONE; |
334 | break; | 334 | break; |
335 | case 1: | 335 | case 1: |
336 | scrollLoc = SCRLEFT; | 336 | scrollLoc = SCRLEFT; |
337 | break; | 337 | break; |
338 | case 2: | 338 | case 2: |
339 | scrollLoc = SCRRIGHT; | 339 | scrollLoc = SCRRIGHT; |
340 | break; | 340 | break; |
341 | }; | 341 | }; |
342 | 342 | ||
343 | blinkT = new QTimer(this); | 343 | blinkT = new QTimer(this); |
344 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | 344 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); |
345 | // blinking = FALSE; | 345 | // blinking = FALSE; |
346 | blinking = TRUE; | 346 | blinking = TRUE; |
347 | 347 | ||
348 | resizing = FALSE; | 348 | resizing = FALSE; |
349 | actSel = 0; | 349 | actSel = 0; |
350 | image = 0; | 350 | image = 0; |
351 | lines = 1; | 351 | lines = 1; |
352 | columns = 1; | 352 | columns = 1; |
353 | font_w = 1; | 353 | font_w = 1; |
354 | font_h = 1; | 354 | font_h = 1; |
355 | font_a = 1; | 355 | font_a = 1; |
356 | word_selection_mode = FALSE; | 356 | word_selection_mode = FALSE; |
357 | vcolumns = 0; | 357 | vcolumns = 0; |
358 | hposition = 0; | ||
358 | 359 | ||
359 | setMouseMarks(TRUE); | 360 | setMouseMarks(TRUE); |
360 | setVTFont( QFont("fixed") ); | 361 | setVTFont( QFont("fixed") ); |
361 | setColorTable(base_color_table); // init color table | 362 | setColorTable(base_color_table); // init color table |
362 | 363 | ||
363 | qApp->installEventFilter( this ); //FIXME: see below | 364 | qApp->installEventFilter( this ); //FIXME: see below |
364 | // KCursor::setAutoHideCursor( this, true ); | 365 | // KCursor::setAutoHideCursor( this, true ); |
365 | 366 | ||
366 | // Init DnD //////////////////////////////////////////////////////////////// | 367 | // Init DnD //////////////////////////////////////////////////////////////// |
367 | currentSession = NULL; | 368 | currentSession = NULL; |
368 | // setAcceptDrops(true); // attempt | 369 | // setAcceptDrops(true); // attempt |
369 | // m_drop = new QPopupMenu(this); | 370 | // m_drop = new QPopupMenu(this); |
370 | // m_drop->insertItem( QString("Paste"), 0); | 371 | // m_drop->insertItem( QString("Paste"), 0); |
371 | // m_drop->insertItem( QString("cd"), 1); | 372 | // m_drop->insertItem( QString("cd"), 1); |
372 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | 373 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); |
373 | 374 | ||
374 | // we need focus so that the auto-hide cursor feature works | 375 | // we need focus so that the auto-hide cursor feature works |
375 | setFocus(); | 376 | setFocus(); |
376 | setFocusPolicy( WheelFocus ); | 377 | setFocusPolicy( WheelFocus ); |
377 | } | 378 | } |
378 | 379 | ||
379 | //FIXME: make proper destructor | 380 | //FIXME: make proper destructor |
380 | // Here's a start (David) | 381 | // Here's a start (David) |
381 | TEWidget::~TEWidget() | 382 | TEWidget::~TEWidget() |
382 | { | 383 | { |
383 | qApp->removeEventFilter( this ); | 384 | qApp->removeEventFilter( this ); |
384 | if (image) free(image); | 385 | if (image) free(image); |
385 | } | 386 | } |
386 | 387 | ||
387 | /* ------------------------------------------------------------------------- */ | 388 | /* ------------------------------------------------------------------------- */ |
388 | /* */ | 389 | /* */ |
389 | /* Display Operations */ | 390 | /* Display Operations */ |
390 | /* */ | 391 | /* */ |
391 | /* ------------------------------------------------------------------------- */ | 392 | /* ------------------------------------------------------------------------- */ |
392 | 393 | ||
393 | /*! | 394 | /*! |
394 | attributed string draw primitive | 395 | attributed string draw primitive |
395 | */ | 396 | */ |
396 | 397 | ||
397 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, | 398 | void TEWidget::drawAttrStr(QPainter &paint, QRect rect, |
398 | QString& str, ca attr, BOOL pm, BOOL clear) | 399 | QString& str, ca attr, BOOL pm, BOOL clear) |
399 | { | 400 | { |
400 | if (pm && color_table[attr.b].transparent) | 401 | if (pm && color_table[attr.b].transparent) |
401 | { | 402 | { |
402 | paint.setBackgroundMode( TransparentMode ); | 403 | paint.setBackgroundMode( TransparentMode ); |
403 | if (clear) erase(rect); | 404 | if (clear) erase(rect); |
404 | } | 405 | } |
405 | else | 406 | else |
406 | { | 407 | { |
407 | if (blinking) | 408 | if (blinking) |
408 | paint.fillRect(rect, color_table[attr.b].color); | 409 | paint.fillRect(rect, color_table[attr.b].color); |
409 | else | 410 | else |
410 | { | 411 | { |
411 | paint.setBackgroundMode( OpaqueMode ); | 412 | paint.setBackgroundMode( OpaqueMode ); |
412 | paint.setBackgroundColor( color_table[attr.b].color ); | 413 | paint.setBackgroundColor( color_table[attr.b].color ); |
413 | } | 414 | } |
414 | } | 415 | } |
415 | 416 | ||
416 | if (color_table[attr.f].bold) | 417 | if (color_table[attr.f].bold) |
417 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | 418 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); |
418 | else | 419 | else |
419 | paint.setPen(color_table[attr.f].color); | 420 | paint.setPen(color_table[attr.f].color); |
420 | 421 | ||
421 | paint.drawText(rect.x(),rect.y()+font_a, str); | 422 | paint.drawText(rect.x(),rect.y()+font_a, str); |
422 | 423 | ||
423 | if (attr.r & RE_UNDERLINE) | 424 | if (attr.r & RE_UNDERLINE) |
424 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); | 425 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); |
425 | } | 426 | } |
426 | 427 | ||
427 | /*! | 428 | /*! |
428 | The image can only be set completely. | 429 | The image can only be set completely. |
429 | 430 | ||
430 | The size of the new image may or may not match the size of the widget. | 431 | The size of the new image may or may not match the size of the widget. |
431 | */ | 432 | */ |
432 | 433 | ||
433 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) | 434 | void TEWidget::setImage(const ca* const newimg, int lines, int columns) |
434 | { int y,x,len; | 435 | { int y,x,len; |
435 | const QPixmap* pm = backgroundPixmap(); | 436 | const QPixmap* pm = backgroundPixmap(); |
436 | QPainter paint; | 437 | QPainter paint; |
437 | setUpdatesEnabled(FALSE); | 438 | setUpdatesEnabled(FALSE); |
438 | paint.begin( this ); | 439 | paint.begin( this ); |
439 | HCNT("setImage"); | 440 | HCNT("setImage"); |
440 | 441 | ||
441 | QPoint tL = contentsRect().topLeft(); | 442 | QPoint tL = contentsRect().topLeft(); |
442 | int tLx = tL.x(); | 443 | int tLx = tL.x(); |
443 | int tLy = tL.y(); | 444 | int tLy = tL.y(); |
444 | hasBlinker = FALSE; | 445 | hasBlinker = FALSE; |
445 | 446 | ||
446 | int cf = -1; // undefined | 447 | int cf = -1; // undefined |
447 | int cb = -1; // undefined | 448 | int cb = -1; // undefined |
448 | int cr = -1; // undefined | 449 | int cr = -1; // undefined |
449 | 450 | ||
450 | int lins = QMIN(this->lines, QMAX(0,lines )); | 451 | int lins = QMIN(this->lines, QMAX(0,lines )); |
451 | int cols = QMIN(this->columns,QMAX(0,columns)); | 452 | int cols = QMIN(this->columns,QMAX(0,columns)); |
452 | QChar *disstrU = new QChar[cols]; | 453 | QChar *disstrU = new QChar[cols]; |
453 | 454 | ||