summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CDrawBuffer.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/CDrawBuffer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.cpp281
1 files changed, 226 insertions, 55 deletions
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp
index ca220e6..77b76fb 100644
--- a/noncore/apps/opie-reader/CDrawBuffer.cpp
+++ b/noncore/apps/opie-reader/CDrawBuffer.cpp
@@ -1,11 +1,13 @@
1#include "CDrawBuffer.h" 1#include "CDrawBuffer.h"
2#include "FontControl.h" 2#include "FontControl.h"
3#include <qfontmetrics.h> 3#include <qfontmetrics.h>
4#include <qpainter.h> 4#include <qpainter.h>
5#include <qpixmap.h> 5#include <qpixmap.h>
6#include <qimage.h>
7#include "useqpe.h"
6#include "opie.h" 8#include "opie.h"
7 9
8CDrawBuffer::~CDrawBuffer() 10CDrawBuffer::~CDrawBuffer()
9{ 11{
10 while (!segs.isEmpty()) segs.erase(0); 12 while (!segs.isEmpty()) segs.erase(0);
11} 13}
@@ -39,13 +41,13 @@ void CDrawBuffer::setright(CDrawBuffer& rhs, int f)
39 len = i; 41 len = i;
40} 42}
41 43
42CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) 44CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
43{ 45{
44 int i; 46 int i;
45// qDebug("Trying 2"); 47// //qDebug("Trying 2");
46 len = rhs.len; 48 len = rhs.len;
47 m_maxstyle = rhs.m_maxstyle; 49 m_maxstyle = rhs.m_maxstyle;
48 m_ascent = rhs.m_ascent; 50 m_ascent = rhs.m_ascent;
49 m_descent = rhs.m_descent; 51 m_descent = rhs.m_descent;
50 m_lineSpacing = rhs.m_lineSpacing; 52 m_lineSpacing = rhs.m_lineSpacing;
51 m_lineExtraSpacing = rhs.m_lineExtraSpacing; 53 m_lineExtraSpacing = rhs.m_lineExtraSpacing;
@@ -57,13 +59,13 @@ CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs)
57 { 59 {
58 segs.push_back(*iter); 60 segs.push_back(*iter);
59 } 61 }
60 for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; 62 for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i];
61 (*this)[i] = '\0'; 63 (*this)[i] = '\0';
62 len = i; 64 len = i;
63// qDebug("Tried 2"); 65// //qDebug("Tried 2");
64 return *this; 66 return *this;
65} 67}
66 68
67CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) 69CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp)
68{ 70{
69 int i; 71 int i;
@@ -77,12 +79,14 @@ CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp)
77 len = i; 79 len = i;
78 return *this; 80 return *this;
79} 81}
80 82
81void CDrawBuffer::empty() 83void CDrawBuffer::empty()
82{ 84{
85 m_bSop = false;
86 m_bEop = false;
83 len = 0; 87 len = 0;
84 (*this)[0] = 0; 88 (*this)[0] = 0;
85 while (!segs.isEmpty()) 89 while (!segs.isEmpty())
86 { 90 {
87 segs.erase(0); 91 segs.erase(0);
88 } 92 }
@@ -108,199 +112,352 @@ void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/)
108void CDrawBuffer::truncate(int n) 112void CDrawBuffer::truncate(int n)
109{ 113{
110 len = n; 114 len = n;
111 (*this)[n] = 0; 115 (*this)[n] = 0;
112} 116}
113 117
114int CDrawBuffer::width(int numchars) 118int CDrawBuffer::width(int numchars, bool onscreen, int scwidth, unsigned char _border)
115{ 119{
120 int gzoom = fc->gzoom();
116 int currentx = 0, end = 0; 121 int currentx = 0, end = 0;
117 QString text = toQString(data()); 122 QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars);
118 CList<textsegment>::iterator textstart = segs.begin(); 123 CList<textsegment>::iterator textstart = segs.begin();
124 int extraspace = 0;
125 bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify);
126 int spaces = 0;
127 int spacesofar = 0;
128 int spacenumber = 0;
129 int nonspace = 0;
130 if (just)
131 {
132 for (int i = 0; i < len; i++)
133 {
134 if ((*this)[i] != ' ')
135 {
136 nonspace = i;
137 break;
138 }
139 }
140#ifdef _WINDOWS
141 for (i = nonspace; i < len; i++)
142#else
143 for (int i = nonspace; i < len; i++)
144#endif
145 {
146 if ((*this)[i] == ' ')
147 {
148 spaces++;
149 }
150 }
151 if (spaces == 0)
152 {
153 just = false;
154 }
155 else
156 {
157 extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width());
158 if (extraspace == 0) just = false;
159 }
160 }
119 CList<textsegment>::iterator textend = textstart; 161 CList<textsegment>::iterator textend = textstart;
120 do 162 do
121 { 163 {
122 textend++; 164 textend++;
123 end = (textend != segs.end()) ? textend->start : length(); 165 end = (textend != segs.end()) ? textend->start : len;
124 if (numchars >= 0 && end > numchars) 166 if (numchars >= 0 && end > numchars)
125 { 167 {
126 end = numchars; 168 end = numchars;
127 } 169 }
128 CStyle currentstyle = textstart->style; 170 CStyle currentstyle = textstart->style;
129 if (currentstyle.isPicture()) 171 if (currentstyle.isPicture())
130 { 172 {
131 currentx += currentstyle.getPicture()->width(); 173 if (currentstyle.canScale())
174 {
175 currentx += (gzoom*currentstyle.getPicture()->width())/100;
176 }
177 else
178 {
179 currentx += currentstyle.getPicture()->width();
180 }
132 } 181 }
133 else 182 else
134 { 183 {
135 if (currentstyle.isMono() && !fc->hasCourier()) 184 if (currentstyle.isMono() && !fc->hasCourier())
136 { 185 {
137 int cw = (7*fc->getsize(currentstyle))/10; 186 int cw = (7*fc->getsize(currentstyle))/10;
138 currentx += cw*(end-textstart->start); 187 currentx += cw*(end-textstart->start);
139 } 188 }
140 else 189 else
141 { 190 {
142 QFont f(currentstyle.isMono() ? QString("courier") : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 191 QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
143 // f.setUnderline(currentstyle.isUnderline()); 192 // f.setUnderline(currentstyle.isUnderline());
144 QString str = text.mid(textstart->start, end-textstart->start); 193 QString str = text.mid(textstart->start, end-textstart->start);
145 QFontMetrics fm(f); 194 QFontMetrics fm(f);
146 currentx += fm.width(str); 195 if (just)
196 {
197 int lastspace = -1;
198 int nsp = 0;
199 int cx = currentx;
200 while ((nsp = str.find(" ", lastspace+1)) >= 0)
201 {
202 if (nsp > nonspace)
203 {
204 spacenumber++;
205 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
206 QString nstr = str.mid(lastspace+1, nsp-lastspace);
207 int lw = fm.width(nstr);
208 cx += lw+nexttoadd;
209 spacesofar += nexttoadd;
210 lastspace = nsp;
211 }
212 else
213 {
214 QString nstr = str.mid(lastspace+1, nsp-lastspace);
215 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
216 int lw = fm.width(nstr);
217 cx += lw;
218 lastspace = nsp;
219 }
220 }
221 QString nstr = str.right(str.length()-1-lastspace);
222 cx += fm.width(nstr);
223 currentx = cx;
224 }
225 else
226 {
227 currentx += fm.width(str);
228 }
147 } 229 }
148 } 230 }
149 textstart = textend; 231 textstart = textend;
150 } 232 }
151 while (textend != segs.end() && end != numchars); 233 while (textend != segs.end() && end != numchars && textstart->start < len);
152 return currentx; 234 return currentx;
153} 235}
154 236
155int CDrawBuffer::leftMargin() 237int CDrawBuffer::leftMargin()
156{ 238{
157 return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style))/6; 239 return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style)+3)/6;
158} 240}
159 241
160int CDrawBuffer::rightMargin() 242int CDrawBuffer::rightMargin()
161{ 243{
162 return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style))/6; 244 return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style)+3)/6;
163} 245}
164 246
165int CDrawBuffer::offset(int scwidth) 247int CDrawBuffer::offset(int scwidth, unsigned char _border)
166{ 248{
167 int currentx = BORDER; 249 int currentx = _border;
168 switch(segs.begin()->style.getJustify()) 250 switch(segs.begin()->style.getJustify())
169 { 251 {
170 case m_AlignRight: 252 case m_AlignRight:
171 { 253 {
172 currentx = scwidth - BORDER - rightMargin() - width(); 254 currentx = scwidth - _border - rightMargin() - width();
173 } 255 }
174 break; 256 break;
175 case m_AlignCentre: 257 case m_AlignCentre:
176 { 258 {
177 currentx = ( 259 currentx = (
178 scwidth + 260 scwidth +
179 leftMargin() - rightMargin() 261 leftMargin() - rightMargin()
180 - width())/2; 262 - width())/2;
181 } 263 }
182 break; 264 break;
183 case m_AlignJustify: 265 case m_AlignJustify:
184 case m_AlignLeft: 266 case m_AlignLeft:
185 currentx = BORDER + leftMargin(); 267 currentx = _border + leftMargin();
186 break; 268 break;
187 } 269 }
188 return currentx; 270 return currentx;
189} 271}
190 272
191void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth) 273void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned char _border)
192{ 274{
193 int currentx = offset(scwidth); 275 int gzoom = fc->gzoom();
276 int currentx = offset(scwidth, _border);
194 QString text = toQString(data()); 277 QString text = toQString(data());
195 CList<textsegment>::iterator textstart = segs.begin(); 278 CList<textsegment>::iterator textstart = segs.begin();
196/* 279 int extraspace = 0;
197 StyleType align = textstart->style.getJustify(); 280 bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify);
198 switch (align) 281 int spaces = 0;
282 int spacesofar = 0;
283 int spacenumber = 0;
284 int nonspace = 0;
285 if (just)
199 { 286 {
200 case CStyle::m_AlignRight: 287 for (int i = 0; i < len; i++)
201 { 288 {
202 currentx = scwidth - width() - 2*BORDER; 289 if ((*this)[i] != ' ')
290 {
291 nonspace = i;
292 break;
293 }
203 } 294 }
204 break; 295#ifdef _WINDOWS
205 case CStyle::m_AlignCentre: 296 for (i = nonspace; i < len; i++)
297#else
298 for (int i = nonspace; i < len; i++)
299#endif
206 { 300 {
207 currentx = (scwidth - width())/2 - BORDER; 301 if ((*this)[i] == ' ')
302 {
303 spaces++;
304 }
305 }
306 if (spaces == 0)
307 {
308 just = false;
309 }
310 else
311 {
312 extraspace = (scwidth - 2*_border - rightMargin() - leftMargin() - width());
313 if (extraspace == 0) just = false;
208 } 314 }
209 break;
210 case CStyle::m_AlignJustify:
211 case CStyle::m_AlignLeft:
212 break;
213 } 315 }
214*/
215 CList<textsegment>::iterator textend = textstart; 316 CList<textsegment>::iterator textend = textstart;
216 do 317 do
217 { 318 {
218 textend++; 319 textend++;
219 int end = (textend != segs.end()) ? textend->start : length(); 320 int end = (textend != segs.end()) ? textend->start : len;
220 CStyle currentstyle = textstart->style; 321 CStyle currentstyle = textstart->style;
221 QFont f((currentstyle.isMono() && fc->hasCourier()) ? QString("courier") : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 322 QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
222 //f.setUnderline(currentstyle.isUnderline()); 323 //f.setUnderline(currentstyle.isUnderline());
223 //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); 324 //if (currentstyle.isUnderline()) qDebug("UNDERLINE");
224 _p->setFont(f); 325 _p->setFont(f);
225 QString str = text.mid(textstart->start, end-textstart->start); 326 QString str = text.mid(textstart->start, end-textstart->start);
226#ifdef OPIE 327#if defined(OPIE) || !defined(USEQPE)
227 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); 328 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100));
228#else 329#else
229 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); 330 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10));
230#endif 331#endif
332 int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2;
231 if (_bMono) 333 if (_bMono)
232 { 334 {
233 if (currentstyle.isUnderline()) 335 if (currentstyle.isUnderline())
234 { 336 {
235 _p->drawLine( currentx, _y, currentx + str.length()*_charWidth, _y); 337 _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset);
236 } 338 }
237 if (currentstyle.isStrikethru()) 339 if (currentstyle.isStrikethru())
238 { 340 {
239 int ascent = fc->ascent(currentstyle)/3; 341 int ascent = fc->ascent(currentstyle)/3;
240 _p->drawLine( currentx, _y-ascent, currentx + str.length()*_charWidth, _y-ascent); 342 _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset);
241 } 343 }
242 for (int i = 0; i < str.length(); i++) 344 for (int i = 0; i < str.length(); i++)
243 { 345 {
244 _p->drawText( currentx + i*_charWidth, _y, QString(str[i])); 346 _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i]));
245 } 347 }
246 currentx += str.length()*_charWidth; 348 currentx += str.length()*_charWidth;
247 } 349 }
248 else 350 else
249 { 351 {
250 if (currentstyle.isPicture()) 352 if (currentstyle.isPicture())
251 { 353 {
354 int ht = (gzoom*currentstyle.getPicture()->height())/100;
355 int wt = (gzoom*currentstyle.getPicture()->width())/100;
252 int ascent = fc->ascent(currentstyle)/2; 356 int ascent = fc->ascent(currentstyle)/2;
253 int yoffset = currentstyle.getPicture()->height()/2 + ascent; 357 int yoffset = ht/2 + ascent;
254 _p->drawPixmap( currentx, _y-yoffset, *(currentstyle.getPicture())); 358
255 currentx += currentstyle.getPicture()->width(); 359 QPixmap pc;
360 if (gzoom != 100 && currentstyle.canScale())
361 {
362 QImage im = currentstyle.getPicture()->smoothScale(wt,ht);
363 pc.convertFromImage(im);
364 }
365 else
366 {
367 pc.convertFromImage(*currentstyle.getPicture());
368 }
369 _p->drawPixmap( currentx, _y-yoffset, pc );
370 currentx += wt;
256 } 371 }
257 else 372 else
258 { 373 {
259 if (currentstyle.isMono() && !fc->hasCourier()) 374 if (currentstyle.isMono() && !fc->hasCourier())
260 { 375 {
261 int cw = (7*fc->getsize(currentstyle))/10; 376 int cw = (7*fc->getsize(currentstyle))/10;
262 int w = cw*(end-textstart->start); 377 int w = cw*(end-textstart->start);
263 if (currentstyle.isUnderline()) 378 if (currentstyle.isUnderline())
264 { 379 {
265 _p->drawLine( currentx, _y, currentx + w, _y); 380 _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset);
266 } 381 }
267 if (currentstyle.isStrikethru()) 382 if (currentstyle.isStrikethru())
268 { 383 {
269 int ascent = fc->ascent(currentstyle)/3; 384 int ascent = fc->ascent(currentstyle)/3;
270 _p->drawLine( currentx, _y-ascent, currentx + w, _y-ascent); 385 _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset);
271 } 386 }
272 QString str = text.mid(textstart->start, end-textstart->start); 387 QString str = text.mid(textstart->start, end-textstart->start);
273 388
274 for (int i = 0; i < str.length(); i++) 389 for (unsigned int i = 0; i < str.length(); i++)
275 { 390 {
276 _p->drawText( currentx, _y, QString(str[i])); 391#ifdef _WINDOWS
392 _p->drawText( currentx, _y+voffset, QString(str.at(i)));
393#else
394 _p->drawText( currentx, _y+voffset, QString(str[i]));
395#endif
277 currentx += cw; 396 currentx += cw;
278 } 397 }
279 } 398 }
280 else 399 else
281 { 400 {
282 QFontMetrics fm(f); 401 QFontMetrics fm(f);
283 int w = fm.width(str); 402 int w;
403 if (just)
404 {
405 int lastspace = -1;
406 int nsp = 0;
407 int cx = currentx;
408 while ((nsp = str.find(" ", lastspace+1)) >= 0)
409 {
410 if (nsp+textstart->start >= nonspace)
411 {
412 spacenumber++;
413 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
414 QString nstr = str.mid(lastspace+1, nsp-lastspace);
415 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
416 int lw = fm.width(nstr);
417 _p->drawText( cx, _y+voffset, nstr);
418 cx += lw+nexttoadd;
419 spacesofar += nexttoadd;
420 lastspace = nsp;
421 }
422 else
423 {
424 QString nstr = str.mid(lastspace+1, nsp-lastspace);
425 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
426 int lw = fm.width(nstr);
427 _p->drawText( cx, _y+voffset, nstr);
428 cx += lw;
429 lastspace = nsp;
430 }
431 }
432 QString nstr = str.right(str.length()-1-lastspace);
433 _p->drawText( cx, _y+voffset, nstr);
434 cx += fm.width(nstr);
435 w = cx - currentx;
436 }
437 else
438 {
439 _p->drawText( currentx, _y+voffset, str);
440 w = fm.width(str);
441 }
284 if (currentstyle.isUnderline()) 442 if (currentstyle.isUnderline())
285 { 443 {
286 _p->drawLine( currentx, _y, currentx + w, _y); 444 _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset);
287 } 445 }
288 if (currentstyle.isStrikethru()) 446 if (currentstyle.isStrikethru())
289 { 447 {
290 int ascent = fc->ascent(currentstyle)/3; 448 int ascent = fc->ascent(currentstyle)/3;
291 _p->drawLine( currentx, _y-ascent, currentx + w, _y-ascent); 449 _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset);
292 } 450 }
293 _p->drawText( currentx, _y, str);
294 currentx += w; 451 currentx += w;
295 } 452 }
296 } 453 }
297 } 454 }
298 textstart = textend; 455 textstart = textend;
299 } 456 }
300 while (textend != segs.end() && textstart->start < length()-1); 457 while (textend != segs.end() && textstart->start < len);
301} 458}
302 459
303CStyle CDrawBuffer::laststyle() 460CStyle CDrawBuffer::laststyle()
304{ 461{
305 return segs.last().style; 462 return segs.last().style;
306} 463}
@@ -311,18 +468,18 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt)
311 CStyle currentstyle; 468 CStyle currentstyle;
312 CList<textsegment>::iterator textstart = segs.begin(); 469 CList<textsegment>::iterator textstart = segs.begin();
313 CList<textsegment>::iterator textend = textstart; 470 CList<textsegment>::iterator textend = textstart;
314 do 471 do
315 { 472 {
316 textend++; 473 textend++;
317 end = (textend != segs.end()) ? textend->start : length(); 474 end = (textend != segs.end()) ? textend->start : len;
318 currentstyle = textstart->style; 475 currentstyle = textstart->style;
319/* 476/*
320 if (currentstyle.isPicture()) qDebug("Passed thru picture"); 477 if (currentstyle.isPicture()) qDebug("Passed thru picture");
321 if (currentstyle.getLink()) qDebug("Passed thru link"); 478 if (currentstyle.getLink()) qDebug("Passed thru link");
322 qDebug("islink:%d - %d", numchars, end); 479 //qDebug("islink:%d - %d", numchars, end);
323*/ 480*/
324 textstart = textend; 481 textstart = textend;
325 } 482 }
326 while (textend != segs.end() && end <= numchars); 483 while (textend != segs.end() && end <= numchars);
327// if (currentstyle.isPicture()) qDebug("Clicked on picture"); 484// if (currentstyle.isPicture()) qDebug("Clicked on picture");
328 if (currentstyle.getPictureLink()) 485 if (currentstyle.getPictureLink())
@@ -337,15 +494,15 @@ linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt)
337 } 494 }
338 return eNone; 495 return eNone;
339} 496}
340 497
341void CDrawBuffer::resize() 498void CDrawBuffer::resize()
342{ 499{
343 int i; 500 int gzoom = fc->gzoom();
344 m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; 501 m_maxstyle = m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0;
345 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= length(); ) 502 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; )
346 { 503 {
347 CList<textsegment>::iterator next = iter; 504 CList<textsegment>::iterator next = iter;
348 iter++; 505 iter++;
349 int st = next->start; 506 int st = next->start;
350 if (st < 0) st = 0; 507 if (st < 0) st = 0;
351 508
@@ -354,16 +511,16 @@ void CDrawBuffer::resize()
354 int linespacing, ascent, descent, extra; 511 int linespacing, ascent, descent, extra;
355 512
356 ascent = fc->ascent(_style); 513 ascent = fc->ascent(_style);
357 descent = fc->descent(_style); 514 descent = fc->descent(_style);
358 linespacing = fc->lineSpacing(_style); 515 linespacing = fc->lineSpacing(_style);
359 extra = linespacing - ascent - descent; 516 extra = linespacing - ascent - descent;
360 if (_style.isPicture()) 517 if (_style.isPicture() && _style.canScale())
361 { 518 {
362 descent = (_style.getPicture()->height()-ascent)/2; 519 descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2;
363 ascent = (_style.getPicture()->height()+ascent)/2; 520 ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2;
364 } 521 }
365/* 522/*
366 else if (fc != NULL) 523 else if (fc != NULL)
367 { 524 {
368 ascent = fc->ascent(_style); 525 ascent = fc->ascent(_style);
369 descent = fc->descent(_style); 526 descent = fc->descent(_style);
@@ -373,7 +530,21 @@ void CDrawBuffer::resize()
373*/ 530*/
374 if (ascent > m_ascent) m_ascent = ascent; 531 if (ascent > m_ascent) m_ascent = ascent;
375 if (descent > m_descent) m_descent = descent; 532 if (descent > m_descent) m_descent = descent;
376 if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; 533 if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra;
377 m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; 534 m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing;
378 } 535 }
536 int lead = fc->getlead();
537 if (lead != 0)
538 {
539 int xt = (lead*m_lineSpacing+5)/10;
540 m_descent += xt;
541 m_lineSpacing += xt;
542 }
543 if (m_bSop)
544 {
545 int xt = ((segs.begin()->style.getExtraSpace()+fc->getextraspace())*fc->getsize(segs.begin()->style)+5)/10;
546 //qDebug("ExtraSpace:%d", xt);
547 m_ascent += xt;
548 m_lineSpacing += xt;
549 }
379} 550}