Mercurial > hg > octave-lyh
comparison gui/src/terminal/TerminalDisplay.cpp @ 13515:7eb8cd35454c
Removed unused code in order shrink down the terminal code and hopefully nearing the goal to replace it.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Mon, 18 Jul 2011 22:04:40 +0200 |
parents | c70511cf64ee |
children | d53287c44e5a |
comparison
equal
deleted
inserted
replaced
13514:9accc22fd9b0 | 13515:7eb8cd35454c |
---|---|
428 BotL = (1 << 21), | 428 BotL = (1 << 21), |
429 BotC = (1 << 22), | 429 BotC = (1 << 22), |
430 BotR = (1 << 23) | 430 BotR = (1 << 23) |
431 }; | 431 }; |
432 | 432 |
433 #include "LineFont.h" | |
434 | |
435 static void | |
436 drawLineChar (QPainter & paint, int x, int y, int w, int h, uchar code) | |
437 { | |
438 //Calculate cell midpoints, end points. | |
439 int cx = x + w / 2; | |
440 int cy = y + h / 2; | |
441 int ex = x + w - 1; | |
442 int ey = y + h - 1; | |
443 | |
444 quint32 toDraw = LineChars[code]; | |
445 | |
446 //Top _lines: | |
447 if (toDraw & TopL) | |
448 paint.drawLine (cx - 1, y, cx - 1, cy - 2); | |
449 if (toDraw & TopC) | |
450 paint.drawLine (cx, y, cx, cy - 2); | |
451 if (toDraw & TopR) | |
452 paint.drawLine (cx + 1, y, cx + 1, cy - 2); | |
453 | |
454 //Bot _lines: | |
455 if (toDraw & BotL) | |
456 paint.drawLine (cx - 1, cy + 2, cx - 1, ey); | |
457 if (toDraw & BotC) | |
458 paint.drawLine (cx, cy + 2, cx, ey); | |
459 if (toDraw & BotR) | |
460 paint.drawLine (cx + 1, cy + 2, cx + 1, ey); | |
461 | |
462 //Left _lines: | |
463 if (toDraw & LeftT) | |
464 paint.drawLine (x, cy - 1, cx - 2, cy - 1); | |
465 if (toDraw & LeftC) | |
466 paint.drawLine (x, cy, cx - 2, cy); | |
467 if (toDraw & LeftB) | |
468 paint.drawLine (x, cy + 1, cx - 2, cy + 1); | |
469 | |
470 //Right _lines: | |
471 if (toDraw & RightT) | |
472 paint.drawLine (cx + 2, cy - 1, ex, cy - 1); | |
473 if (toDraw & RightC) | |
474 paint.drawLine (cx + 2, cy, ex, cy); | |
475 if (toDraw & RightB) | |
476 paint.drawLine (cx + 2, cy + 1, ex, cy + 1); | |
477 | |
478 //Intersection points. | |
479 if (toDraw & Int11) | |
480 paint.drawPoint (cx - 1, cy - 1); | |
481 if (toDraw & Int12) | |
482 paint.drawPoint (cx, cy - 1); | |
483 if (toDraw & Int13) | |
484 paint.drawPoint (cx + 1, cy - 1); | |
485 | |
486 if (toDraw & Int21) | |
487 paint.drawPoint (cx - 1, cy); | |
488 if (toDraw & Int22) | |
489 paint.drawPoint (cx, cy); | |
490 if (toDraw & Int23) | |
491 paint.drawPoint (cx + 1, cy); | |
492 | |
493 if (toDraw & Int31) | |
494 paint.drawPoint (cx - 1, cy + 1); | |
495 if (toDraw & Int32) | |
496 paint.drawPoint (cx, cy + 1); | |
497 if (toDraw & Int33) | |
498 paint.drawPoint (cx + 1, cy + 1); | |
499 | |
500 } | |
501 | |
502 void | |
503 TerminalDisplay::drawLineCharString (QPainter & painter, int x, int y, | |
504 const QString & str, | |
505 const Character * attributes) | |
506 { | |
507 const QPen & currentPen = painter.pen (); | |
508 | |
509 if ((attributes->rendition & RE_BOLD) && _boldIntense) | |
510 { | |
511 QPen boldPen (currentPen); | |
512 boldPen.setWidth (3); | |
513 painter.setPen (boldPen); | |
514 } | |
515 | |
516 for (int i = 0; i < str.length (); i++) | |
517 { | |
518 uchar code = str[i].cell (); | |
519 if (LineChars[code]) | |
520 drawLineChar (painter, x + (_fontWidth * i), y, _fontWidth, | |
521 _fontHeight, code); | |
522 } | |
523 | |
524 painter.setPen (currentPen); | |
525 } | |
526 | |
527 void | 433 void |
528 TerminalDisplay::setKeyboardCursorShape (KeyboardCursorShape shape) | 434 TerminalDisplay::setKeyboardCursorShape (KeyboardCursorShape shape) |
529 { | 435 { |
530 _cursorShape = shape; | 436 _cursorShape = shape; |
531 } | 437 } |
532 | 438 |
533 TerminalDisplay::KeyboardCursorShape TerminalDisplay::keyboardCursorShape () const | 439 TerminalDisplay::KeyboardCursorShape TerminalDisplay::keyboardCursorShape () const |
534 { | 440 { |
535 return _cursorShape; | 441 return _cursorShape; |
536 } | |
537 | |
538 void | |
539 TerminalDisplay::setKeyboardCursorColor (bool useForegroundColor, | |
540 const QColor & color) | |
541 { | |
542 if (useForegroundColor) | |
543 _cursorColor = QColor (); // an invalid color means that | |
544 // the foreground color of the | |
545 // current character should | |
546 // be used | |
547 | |
548 else | |
549 _cursorColor = color; | |
550 } | |
551 | |
552 QColor | |
553 TerminalDisplay::keyboardCursorColor () const | |
554 { | |
555 return _cursorColor; | |
556 } | |
557 | |
558 void | |
559 TerminalDisplay::setOpacity (qreal opacity) | |
560 { | |
561 QColor color (_blendColor); | |
562 color.setAlphaF (opacity); | |
563 | |
564 // enable automatic background filling to prevent the display | |
565 // flickering if there is no transparency | |
566 /*if ( color.alpha() == 255 ) | |
567 { | |
568 setAutoFillBackground(true); | |
569 } | |
570 else | |
571 { | |
572 setAutoFillBackground(false); | |
573 } */ | |
574 | |
575 _blendColor = color.rgba (); | |
576 } | 442 } |
577 | 443 |
578 void | 444 void |
579 TerminalDisplay::drawBackground (QPainter & painter, const QRect & rect, | 445 TerminalDisplay::drawBackground (QPainter & painter, const QRect & rect, |
580 const QColor & backgroundColor, | 446 const QColor & backgroundColor, |
701 { | 567 { |
702 pen.setColor (color); | 568 pen.setColor (color); |
703 painter.setPen (color); | 569 painter.setPen (color); |
704 } | 570 } |
705 | 571 |
706 // draw text | 572 if (_bidiEnabled) |
707 if (isLineCharString (text)) | 573 painter.drawText (rect, 0, text); |
708 drawLineCharString (painter, rect.x (), rect.y (), text, style); | |
709 else | 574 else |
710 { | 575 painter.drawText (rect, 0, LTR_OVERRIDE_CHAR + text); |
711 // the drawText(rect,flags,string) overload is used here with null flags | |
712 // instead of drawText(rect,string) because the (rect,string) overload causes | |
713 // the application's default layout direction to be used instead of | |
714 // the widget-specific layout direction, which should always be | |
715 // Qt::LeftToRight for this widget | |
716 // This was discussed in: http://lists.kde.org/?t=120552223600002&r=1&w=2 | |
717 if (_bidiEnabled) | |
718 painter.drawText (rect, 0, text); | |
719 else | |
720 painter.drawText (rect, 0, LTR_OVERRIDE_CHAR + text); | |
721 } | |
722 } | 576 } |
723 | 577 |
724 void | 578 void |
725 TerminalDisplay::drawTextFragment (QPainter & painter, | 579 TerminalDisplay::drawTextFragment (QPainter & painter, |
726 const QRect & rect, | 580 const QRect & rect, |