author | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
---|---|---|
committer | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
commit | 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (unidiff) | |
tree | 96e66fdc18dca4d4ab8611133e072f57dea224b9 /noncore/apps/opie-reader/CDrawBuffer.cpp | |
parent | 279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff) | |
download | opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.zip opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.gz opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.bz2 |
new opie-reader sources with support for ArriereGo, Reb input and flite output plugins
Diffstat (limited to 'noncore/apps/opie-reader/CDrawBuffer.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CDrawBuffer.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index bfb3027..227f0f6 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -355,24 +355,25 @@ int CDrawBuffer::offset(int scwidth, unsigned short _lborder, unsigned short _rb | |||
355 | } | 355 | } |
356 | break; | 356 | break; |
357 | case m_AlignCentre: | 357 | case m_AlignCentre: |
358 | { | 358 | { |
359 | currentx = ( | 359 | currentx = ( |
360 | scwidth - _lborder -_rborder + | 360 | scwidth - _lborder -_rborder + |
361 | leftMargin() - rightMargin() | 361 | leftMargin() - rightMargin() |
362 | - width(availht))/2 + _lborder; | 362 | - width(availht))/2 + _lborder; |
363 | } | 363 | } |
364 | break; | 364 | break; |
365 | case m_AlignJustify: | 365 | case m_AlignJustify: |
366 | case m_AlignLeft: | 366 | case m_AlignLeft: |
367 | case m_AlignNone: | ||
367 | currentx = _lborder + leftMargin(); | 368 | currentx = _lborder + leftMargin(); |
368 | break; | 369 | break; |
369 | } | 370 | } |
370 | return currentx; | 371 | return currentx; |
371 | } | 372 | } |
372 | 373 | ||
373 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned short _lborder, unsigned short _rborder, const QColor& _bg, int availht) | 374 | void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned short _lborder, unsigned short _rborder, const QColor& _bg, int availht) |
374 | { | 375 | { |
375 | CList<textsegment>::iterator textstart = segs.begin(); | 376 | CList<textsegment>::iterator textstart = segs.begin(); |
376 | QColor paperColour = QColor(qRgb(textstart->style.pRed(), | 377 | QColor paperColour = QColor(qRgb(textstart->style.pRed(), |
377 | textstart->style.pGreen(), | 378 | textstart->style.pGreen(), |
378 | textstart->style.pBlue())); | 379 | textstart->style.pBlue())); |
@@ -475,25 +476,25 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
475 | currentstyle.bGreen(), | 476 | currentstyle.bGreen(), |
476 | currentstyle.bBlue())); | 477 | currentstyle.bBlue())); |
477 | drawBackground = !(bgColour == _bg); | 478 | drawBackground = !(bgColour == _bg); |
478 | 479 | ||
479 | // if (drawBackground) qDebug("Drawing background"); | 480 | // if (drawBackground) qDebug("Drawing background"); |
480 | 481 | ||
481 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 482 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
482 | //f.setUnderline(currentstyle.isUnderline()); | 483 | //f.setUnderline(currentstyle.isUnderline()); |
483 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); | 484 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); |
484 | _p->setFont(f); | 485 | _p->setFont(f); |
485 | QString str = text.mid(textstart->start, end-textstart->start); | 486 | QString str = text.mid(textstart->start, end-textstart->start); |
486 | #if defined(OPIE) || !defined(USEQPE) | 487 | #if defined(OPIE) || !defined(USEQPE) |
487 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); | 488 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10/*0*/)); |
488 | #else | 489 | #else |
489 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); | 490 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); |
490 | #endif | 491 | #endif |
491 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; | 492 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; |
492 | 493 | ||
493 | if (_bMono) | 494 | if (_bMono) |
494 | { | 495 | { |
495 | 496 | ||
496 | Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour); | 497 | Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour); |
497 | if (currentstyle.isUnderline()) | 498 | if (currentstyle.isUnderline()) |
498 | { | 499 | { |
499 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); | 500 | _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); |
@@ -649,25 +650,25 @@ void CDrawBuffer::Highlight(QPainter* _p, bool drawBackground, int _x, int _y, i | |||
649 | } | 650 | } |
650 | 651 | ||
651 | CStyle CDrawBuffer::laststyle() | 652 | CStyle CDrawBuffer::laststyle() |
652 | { | 653 | { |
653 | return segs.last().style; | 654 | return segs.last().style; |
654 | } | 655 | } |
655 | 656 | ||
656 | CStyle CDrawBuffer::firststyle() | 657 | CStyle CDrawBuffer::firststyle() |
657 | { | 658 | { |
658 | return segs.first().style; | 659 | return segs.first().style; |
659 | } | 660 | } |
660 | 661 | ||
661 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img) | 662 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img, size_t& tabletgt) |
662 | { | 663 | { |
663 | linkType ret = eNone; | 664 | linkType ret = eNone; |
664 | int end = 0; | 665 | int end = 0; |
665 | CStyle currentstyle; | 666 | CStyle currentstyle; |
666 | CList<textsegment>::iterator textstart = segs.begin(); | 667 | CList<textsegment>::iterator textstart = segs.begin(); |
667 | CList<textsegment>::iterator textend = textstart; | 668 | CList<textsegment>::iterator textend = textstart; |
668 | do | 669 | do |
669 | { | 670 | { |
670 | textend++; | 671 | textend++; |
671 | end = (textend != segs.end()) ? textend->start : len; | 672 | end = (textend != segs.end()) ? textend->start : len; |
672 | currentstyle = textstart->style; | 673 | currentstyle = textstart->style; |
673 | /* | 674 | /* |
@@ -681,24 +682,29 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, siz | |||
681 | img = currentstyle.getPicture(); | 682 | img = currentstyle.getPicture(); |
682 | if (currentstyle.getPictureLink()) | 683 | if (currentstyle.getPictureLink()) |
683 | { | 684 | { |
684 | pictgt = currentstyle.getPictureLinkData(); | 685 | pictgt = currentstyle.getPictureLinkData(); |
685 | ret |= ePicture; | 686 | ret |= ePicture; |
686 | } | 687 | } |
687 | if (currentstyle.getLink()) | 688 | if (currentstyle.getLink()) |
688 | { | 689 | { |
689 | tgt = currentstyle.getData(); | 690 | tgt = currentstyle.getData(); |
690 | offset = currentstyle.getOffset(); | 691 | offset = currentstyle.getOffset(); |
691 | ret |= eLink; | 692 | ret |= eLink; |
692 | } | 693 | } |
694 | if (currentstyle.isTable()) | ||
695 | { | ||
696 | tabletgt = currentstyle.getTable(); | ||
697 | ret |= eTable; | ||
698 | } | ||
693 | return ret; | 699 | return ret; |
694 | } | 700 | } |
695 | 701 | ||
696 | void CDrawBuffer::resize(int availht) | 702 | void CDrawBuffer::resize(int availht) |
697 | { | 703 | { |
698 | int gzoom = fc->gzoom(); | 704 | int gzoom = fc->gzoom(); |
699 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 705 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
700 | /* | 706 | /* |
701 | int t_ascent = 0; | 707 | int t_ascent = 0; |
702 | int t_descent = 0; | 708 | int t_descent = 0; |
703 | int t_lineExtraSpacing = 0; | 709 | int t_lineExtraSpacing = 0; |
704 | */ | 710 | */ |
@@ -707,25 +713,25 @@ void CDrawBuffer::resize(int availht) | |||
707 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) | 713 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) |
708 | { | 714 | { |
709 | CStyle _style = iter->style; | 715 | CStyle _style = iter->style; |
710 | if (!_style.isPicture()) | 716 | if (!_style.isPicture()) |
711 | { | 717 | { |
712 | m_hastext = true; | 718 | m_hastext = true; |
713 | break; | 719 | break; |
714 | } | 720 | } |
715 | iter++; | 721 | iter++; |
716 | } | 722 | } |
717 | if (m_hastext) | 723 | if (m_hastext) |
718 | { | 724 | { |
719 | 725 | int p_linespacing = 0; | |
720 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) | 726 | for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) |
721 | { | 727 | { |
722 | CList<textsegment>::iterator next = iter; | 728 | CList<textsegment>::iterator next = iter; |
723 | iter++; | 729 | iter++; |
724 | int st = next->start; | 730 | int st = next->start; |
725 | if (st < 0) st = 0; | 731 | if (st < 0) st = 0; |
726 | 732 | ||
727 | CStyle _style = next->style; | 733 | CStyle _style = next->style; |
728 | 734 | ||
729 | int linespacing, ascent, descent, extra; | 735 | int linespacing, ascent, descent, extra; |
730 | 736 | ||
731 | ascent = fc->ascent(_style); | 737 | ascent = fc->ascent(_style); |
@@ -747,41 +753,52 @@ void CDrawBuffer::resize(int availht) | |||
747 | bool willscale = false; | 753 | bool willscale = false; |
748 | if (ht > availht) | 754 | if (ht > availht) |
749 | { | 755 | { |
750 | wt = (wt*availht)/ht; | 756 | wt = (wt*availht)/ht; |
751 | ht = availht; | 757 | ht = availht; |
752 | willscale = true; | 758 | willscale = true; |
753 | } | 759 | } |
754 | if (willscale || _style.canScale()) | 760 | if (willscale || _style.canScale()) |
755 | { | 761 | { |
756 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; | 762 | descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; |
757 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; | 763 | ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; |
758 | } | 764 | } |
765 | else | ||
766 | { | ||
767 | descent = (_style.getPicture()->height()-ascent)/2; | ||
768 | ascent = (_style.getPicture()->height()+ascent)/2; | ||
769 | } | ||
770 | int lineSpacing = ascent+descent; | ||
771 | if (lineSpacing > p_linespacing) | ||
772 | { | ||
773 | p_linespacing = lineSpacing; | ||
774 | } | ||
775 | extra = 0; | ||
759 | } | 776 | } |
760 | 777 | ||
761 | /* | 778 | /* |
762 | else if (fc != NULL) | 779 | else if (fc != NULL) |
763 | { | 780 | { |
764 | ascent = fc->ascent(_style); | 781 | ascent = fc->ascent(_style); |
765 | descent = fc->descent(_style); | 782 | descent = fc->descent(_style); |
766 | linespacing = fc->lineSpacing(_style); | 783 | linespacing = fc->lineSpacing(_style); |
767 | extra = linespacing - ascent - descent; | 784 | extra = linespacing - ascent - descent; |
768 | } | 785 | } |
769 | */ | 786 | */ |
770 | if (ascent > m_ascent) m_ascent = ascent; | 787 | if (ascent > m_ascent) m_ascent = ascent; |
771 | if (descent > m_descent) m_descent = descent; | 788 | if (descent > m_descent) m_descent = descent; |
772 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; | 789 | if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; |
773 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; | 790 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; |
774 | } | 791 | } |
775 | m_showPartial = (m_lineSpacing > t_lineSpacing); | 792 | m_showPartial = (p_linespacing > t_lineSpacing); |
776 | int lead = fc->getlead(); | 793 | int lead = fc->getlead(); |
777 | if (lead != 0) | 794 | if (lead != 0) |
778 | { | 795 | { |
779 | int xt = (lead*t_lineSpacing+5)/10; | 796 | int xt = (lead*t_lineSpacing+5)/10; |
780 | m_lineExtraSpacing += xt; | 797 | m_lineExtraSpacing += xt; |
781 | m_lineSpacing += xt; | 798 | m_lineSpacing += xt; |
782 | } | 799 | } |
783 | if (m_bSop) | 800 | if (m_bSop) |
784 | { | 801 | { |
785 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; | 802 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; |
786 | //qDebug("ExtraSpace:%d", xt); | 803 | //qDebug("ExtraSpace:%d", xt); |
787 | m_ascent += xt; | 804 | m_ascent += xt; |