Diffstat (limited to 'noncore/apps/opie-reader/CDrawBuffer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/CDrawBuffer.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index ec36fb2..b137ac3 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -31,43 +31,43 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | |||
31 | 31 | ||
32 | segs.push_back(textsegment(st,next->style)); | 32 | segs.push_back(textsegment(st,next->style)); |
33 | } | 33 | } |
34 | } | 34 | } |
35 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; | 35 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; |
36 | (*this)[i-f] = '\0'; | 36 | (*this)[i-f] = '\0'; |
37 | len = i; | 37 | len = i; |
38 | } | 38 | } |
39 | 39 | ||
40 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) | 40 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) |
41 | { | 41 | { |
42 | int i; | 42 | int i; |
43 | // //qDebug("Trying 2"); | 43 | // //odebug << "Trying 2" << oendl; |
44 | len = rhs.len; | 44 | len = rhs.len; |
45 | m_maxstyle = rhs.m_maxstyle; | 45 | m_maxstyle = rhs.m_maxstyle; |
46 | m_ascent = rhs.m_ascent; | 46 | m_ascent = rhs.m_ascent; |
47 | m_descent = rhs.m_descent; | 47 | m_descent = rhs.m_descent; |
48 | m_lineSpacing = rhs.m_lineSpacing; | 48 | m_lineSpacing = rhs.m_lineSpacing; |
49 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; | 49 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; |
50 | while (!segs.isEmpty()) | 50 | while (!segs.isEmpty()) |
51 | { | 51 | { |
52 | segs.erase(0); | 52 | segs.erase(0); |
53 | } | 53 | } |
54 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) | 54 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) |
55 | { | 55 | { |
56 | segs.push_back(*iter); | 56 | segs.push_back(*iter); |
57 | } | 57 | } |
58 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; | 58 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; |
59 | (*this)[i] = '\0'; | 59 | (*this)[i] = '\0'; |
60 | len = i; | 60 | len = i; |
61 | // //qDebug("Tried 2"); | 61 | // //odebug << "Tried 2" << oendl; |
62 | return *this; | 62 | return *this; |
63 | } | 63 | } |
64 | 64 | ||
65 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) | 65 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) |
66 | { | 66 | { |
67 | int i; | 67 | int i; |
68 | while (!segs.isEmpty()) | 68 | while (!segs.isEmpty()) |
69 | { | 69 | { |
70 | segs.erase(0); | 70 | segs.erase(0); |
71 | } | 71 | } |
72 | segs.push_back(textsegment(0, CStyle())); | 72 | segs.push_back(textsegment(0, CStyle())); |
73 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; | 73 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; |
@@ -199,25 +199,25 @@ int CDrawBuffer::width(int numchars, bool onscreen, int scwidth, unsigned char _ | |||
199 | { | 199 | { |
200 | spacenumber++; | 200 | spacenumber++; |
201 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; | 201 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; |
202 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 202 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
203 | int lw = fm.width(nstr); | 203 | int lw = fm.width(nstr); |
204 | cx += lw+nexttoadd; | 204 | cx += lw+nexttoadd; |
205 | spacesofar += nexttoadd; | 205 | spacesofar += nexttoadd; |
206 | lastspace = nsp; | 206 | lastspace = nsp; |
207 | } | 207 | } |
208 | else | 208 | else |
209 | { | 209 | { |
210 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 210 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
211 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 211 | // odebug << "str:" << str << ": last:" << lastspace << " new:" << nsp << " nstr:" << nstr << ":" << oendl; |
212 | int lw = fm.width(nstr); | 212 | int lw = fm.width(nstr); |
213 | cx += lw; | 213 | cx += lw; |
214 | lastspace = nsp; | 214 | lastspace = nsp; |
215 | } | 215 | } |
216 | } | 216 | } |
217 | QString nstr = str.right(str.length()-1-lastspace); | 217 | QString nstr = str.right(str.length()-1-lastspace); |
218 | cx += fm.width(nstr); | 218 | cx += fm.width(nstr); |
219 | currentx = cx; | 219 | currentx = cx; |
220 | } | 220 | } |
221 | else | 221 | else |
222 | { | 222 | { |
223 | currentx += fm.width(str); | 223 | currentx += fm.width(str); |
@@ -308,25 +308,25 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
308 | extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width()); | 308 | extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width()); |
309 | if (extraspace == 0) just = false; | 309 | if (extraspace == 0) just = false; |
310 | } | 310 | } |
311 | } | 311 | } |
312 | CList<textsegment>::iterator textend = textstart; | 312 | CList<textsegment>::iterator textend = textstart; |
313 | do | 313 | do |
314 | { | 314 | { |
315 | textend++; | 315 | textend++; |
316 | int end = (textend != segs.end()) ? textend->start : len; | 316 | int end = (textend != segs.end()) ? textend->start : len; |
317 | CStyle currentstyle = textstart->style; | 317 | CStyle currentstyle = textstart->style; |
318 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); | 318 | QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); |
319 | //f.setUnderline(currentstyle.isUnderline()); | 319 | //f.setUnderline(currentstyle.isUnderline()); |
320 | //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); | 320 | //if (currentstyle.isUnderline()) odebug << "UNDERLINE" << oendl; |
321 | _p->setFont(f); | 321 | _p->setFont(f); |
322 | QString str = text.mid(textstart->start, end-textstart->start); | 322 | QString str = text.mid(textstart->start, end-textstart->start); |
323 | #if defined(OPIE) || !defined(USEQPE) | 323 | #if defined(OPIE) || !defined(USEQPE) |
324 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); | 324 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); |
325 | #else | 325 | #else |
326 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); | 326 | _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); |
327 | #endif | 327 | #endif |
328 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; | 328 | int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; |
329 | if (_bMono) | 329 | if (_bMono) |
330 | { | 330 | { |
331 | if (currentstyle.isUnderline()) | 331 | if (currentstyle.isUnderline()) |
332 | { | 332 | { |
@@ -399,35 +399,35 @@ void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int | |||
399 | if (just) | 399 | if (just) |
400 | { | 400 | { |
401 | int lastspace = -1; | 401 | int lastspace = -1; |
402 | int nsp = 0; | 402 | int nsp = 0; |
403 | int cx = currentx; | 403 | int cx = currentx; |
404 | while ((nsp = str.find(" ", lastspace+1)) >= 0) | 404 | while ((nsp = str.find(" ", lastspace+1)) >= 0) |
405 | { | 405 | { |
406 | if (nsp+textstart->start >= nonspace) | 406 | if (nsp+textstart->start >= nonspace) |
407 | { | 407 | { |
408 | spacenumber++; | 408 | spacenumber++; |
409 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; | 409 | int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; |
410 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 410 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
411 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 411 | // odebug << "str:" << str << ": last:" << lastspace << " new:" << nsp << " nstr:" << nstr << ":" << oendl; |
412 | int lw = fm.width(nstr); | 412 | int lw = fm.width(nstr); |
413 | _p->drawText( cx, _y+voffset, nstr); | 413 | _p->drawText( cx, _y+voffset, nstr); |
414 | cx += lw+nexttoadd; | 414 | cx += lw+nexttoadd; |
415 | spacesofar += nexttoadd; | 415 | spacesofar += nexttoadd; |
416 | lastspace = nsp; | 416 | lastspace = nsp; |
417 | } | 417 | } |
418 | else | 418 | else |
419 | { | 419 | { |
420 | QString nstr = str.mid(lastspace+1, nsp-lastspace); | 420 | QString nstr = str.mid(lastspace+1, nsp-lastspace); |
421 | // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); | 421 | // odebug << "str:" << str << ": last:" << lastspace << " new:" << nsp << " nstr:" << nstr << ":" << oendl; |
422 | int lw = fm.width(nstr); | 422 | int lw = fm.width(nstr); |
423 | _p->drawText( cx, _y+voffset, nstr); | 423 | _p->drawText( cx, _y+voffset, nstr); |
424 | cx += lw; | 424 | cx += lw; |
425 | lastspace = nsp; | 425 | lastspace = nsp; |
426 | } | 426 | } |
427 | } | 427 | } |
428 | QString nstr = str.right(str.length()-1-lastspace); | 428 | QString nstr = str.right(str.length()-1-lastspace); |
429 | _p->drawText( cx, _y+voffset, nstr); | 429 | _p->drawText( cx, _y+voffset, nstr); |
430 | cx += fm.width(nstr); | 430 | cx += fm.width(nstr); |
431 | w = cx - currentx; | 431 | w = cx - currentx; |
432 | } | 432 | } |
433 | else | 433 | else |
@@ -461,32 +461,32 @@ CStyle CDrawBuffer::laststyle() | |||
461 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt) | 461 | linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt) |
462 | { | 462 | { |
463 | int end = 0; | 463 | int end = 0; |
464 | CStyle currentstyle; | 464 | CStyle currentstyle; |
465 | CList<textsegment>::iterator textstart = segs.begin(); | 465 | CList<textsegment>::iterator textstart = segs.begin(); |
466 | CList<textsegment>::iterator textend = textstart; | 466 | CList<textsegment>::iterator textend = textstart; |
467 | do | 467 | do |
468 | { | 468 | { |
469 | textend++; | 469 | textend++; |
470 | end = (textend != segs.end()) ? textend->start : len; | 470 | end = (textend != segs.end()) ? textend->start : len; |
471 | currentstyle = textstart->style; | 471 | currentstyle = textstart->style; |
472 | /* | 472 | /* |
473 | if (currentstyle.isPicture()) qDebug("Passed thru picture"); | 473 | if (currentstyle.isPicture()) odebug << "Passed thru picture" << oendl; |
474 | if (currentstyle.getLink()) qDebug("Passed thru link"); | 474 | if (currentstyle.getLink()) odebug << "Passed thru link" << oendl; |
475 | //qDebug("islink:%d - %d", numchars, end); | 475 | //odebug << "islink:" << numchars << " - " << end << "" << oendl; |
476 | */ | 476 | */ |
477 | textstart = textend; | 477 | textstart = textend; |
478 | } | 478 | } |
479 | while (textend != segs.end() && end <= numchars); | 479 | while (textend != segs.end() && end <= numchars); |
480 | // if (currentstyle.isPicture()) qDebug("Clicked on picture"); | 480 | // if (currentstyle.isPicture()) odebug << "Clicked on picture" << oendl; |
481 | if (currentstyle.getPictureLink()) | 481 | if (currentstyle.getPictureLink()) |
482 | { | 482 | { |
483 | tgt = currentstyle.getPictureLinkData(); | 483 | tgt = currentstyle.getPictureLinkData(); |
484 | return ePicture; | 484 | return ePicture; |
485 | } | 485 | } |
486 | if (currentstyle.getLink()) | 486 | if (currentstyle.getLink()) |
487 | { | 487 | { |
488 | tgt = currentstyle.getData(); | 488 | tgt = currentstyle.getData(); |
489 | return eLink; | 489 | return eLink; |
490 | } | 490 | } |
491 | return eNone; | 491 | return eNone; |
492 | } | 492 | } |
@@ -530,17 +530,17 @@ void CDrawBuffer::resize() | |||
530 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; | 530 | m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; |
531 | } | 531 | } |
532 | int lead = fc->getlead(); | 532 | int lead = fc->getlead(); |
533 | if (lead != 0) | 533 | if (lead != 0) |
534 | { | 534 | { |
535 | int xt = (lead*m_lineSpacing+5)/10; | 535 | int xt = (lead*m_lineSpacing+5)/10; |
536 | m_descent += xt; | 536 | m_descent += xt; |
537 | m_lineSpacing += xt; | 537 | m_lineSpacing += xt; |
538 | } | 538 | } |
539 | if (m_bSop) | 539 | if (m_bSop) |
540 | { | 540 | { |
541 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; | 541 | int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10; |
542 | //qDebug("ExtraSpace:%d", xt); | 542 | //odebug << "ExtraSpace:" << xt << "" << oendl; |
543 | m_ascent += xt; | 543 | m_ascent += xt; |
544 | m_lineSpacing += xt; | 544 | m_lineSpacing += xt; |
545 | } | 545 | } |
546 | } | 546 | } |