diff -r 7a96bd401351 -r 608f976aa7bb headingobj.cpp --- a/headingobj.cpp Sun Jan 30 12:58:47 2005 +0000 +++ b/headingobj.cpp Tue Jun 06 14:58:11 2006 +0000 @@ -1,4 +1,5 @@ #include "headingobj.h" +#include ///////////////////////////////////////////////////////////////// // HeadingObj @@ -9,7 +10,7 @@ init (); } -HeadingObj::HeadingObj(QCanvas* c) :MapObj(c) +HeadingObj::HeadingObj(Q3Canvas* c) :MapObj(c) { // cout << "Const HeadingObj\n"; init (); @@ -26,6 +27,7 @@ textwidth=40; color=QColor ("black"); font=QFont(); + heading=""; } void HeadingObj::copy(HeadingObj *other) @@ -40,13 +42,15 @@ void HeadingObj::move(double x, double y) { MapObj::move(x,y); + int h; // height of a textline int ho; // offset of height while drawing all lines + if (textline.first() ) h=textline.first()->boundingRect().height(); else h=2; - QCanvasText *t; + Q3CanvasText *t; ho=0; for (t=textline.first(); t; t=textline.next() ) { @@ -76,7 +80,7 @@ // then no selection would be visible, thus we prevent it in ::setText() if (!textline.isEmpty() ) { - QCanvasText *t; + Q3CanvasText *t; for (t=textline.first(); t; t=textline.next() ) { h+=t->boundingRect().height(); @@ -87,14 +91,15 @@ bbox.setSize (QSize(w,h)); } -QCanvasText* HeadingObj::newLine(QString s) +Q3CanvasText* HeadingObj::newLine(QString s) { - QCanvasText *t; - t = new QCanvasText(canvas); + Q3CanvasText *t; + t = new Q3CanvasText(canvas); t->setFont (font); t->setColor (color); t->setZ(Z_TEXT); t->setText(s); + t->setTextFlags(Qt::AlignLeft); t->show(); return t; } @@ -114,15 +119,17 @@ int j=0; // index of last ws int k=0; // index of "
" or similar linebreak int br=0; // width of found break, e.g. for
it is 4 + QRegExp re(""); + re.setMinimal (true); // set the text and wrap lines while (s.length()>0) { // ok, some people wanted manual linebreaks, here we go - k=s.find ("
",i,false); + k=re.search (s,i); if (k>=0) { - br=4; + br=re.cap(0).length(); i=k; } else i=s.find (" ",i,false); @@ -184,6 +191,7 @@ } } setVisibility (visible); + move (absPos.x(),absPos.y()); calcBBoxSize(); } @@ -212,7 +220,7 @@ if (color!=c) { color=c; - QCanvasText *t; + Q3CanvasText *t; for (t=textline.first(); t; t=textline.next() ) t->setColor(c); } @@ -226,7 +234,7 @@ void HeadingObj::setVisibility (bool v) { MapObj::setVisibility(v); - QCanvasText *t; + Q3CanvasText *t; for (t=textline.first(); t; t=textline.next() ) if (v) t->show();