diff -r 8814a667241a -r aa48c7b52549 branchobj.cpp --- a/branchobj.cpp Tue Jan 03 09:44:41 2006 +0000 +++ b/branchobj.cpp Tue Jan 03 09:44:41 2006 +0000 @@ -102,6 +102,9 @@ scrolled=false; tmpUnscrolled=false; + includeImagesVer=false; + includeImagesHor=false; + url=""; vymLink=""; } @@ -544,6 +547,9 @@ void BranchObj::move (double x, double y) { OrnamentedObj::move (x,y); + FloatImageObj *fio; + for (fio=floatimage.first(); fio; fio=floatimage.next() ) + fio->reposition(); positionBBox(); } @@ -577,17 +583,13 @@ cout << "BO::positionBBox (noHeading)\n"; */ - // Position contents by moving OO - OrnamentedObj::move (absPos.x(),absPos.y()); - - // It seems that setting x,y also affects width,height - int w_old=bbox.width(); - int h_old=bbox.height(); - bbox.setX (absPos.x() ); - bbox.setY (absPos.y() ); - bbox.setWidth(w_old); - bbox.setHeight(h_old); + positionContents(); + + int d=frame->getBorder()/2; + bbox.moveTopLeft (QPoint (absPos.x(), absPos.y() - topPad)); + clickBox.moveTopLeft(QPoint (absPos.x()+d, absPos.y()+d )); + setSelBox(); // set the frame @@ -619,8 +621,38 @@ h=max (sysflags_h,stanflags_h); h=max (h,heading_h); + clickBox.setSize (QSize (w,h)); + + // Floatimages + QPoint rp; + FloatImageObj *foi; + + topPad=botPad=leftPad=rightPad=0; + if (includeImagesVer || includeImagesHor) + { + if (countFloatImages()>0) + { + for (foi=floatimage.first(); foi; foi=floatimage.next() ) + { + rp=foi->getRelPos(); + if (includeImagesVer) + { + if (rp.y() < 0) + topPad=max (topPad,-rp.y()); + if (rp.y()+foi->height() > h) + botPad=max (botPad,rp.y()+foi->height()-h); + } + } + } + + h+=topPad+botPad; + } + + // Frame thickness w+=frame->getBorder(); h+=frame->getBorder(); + + // Finally set size bbox.setSize (QSize (w,h)); } @@ -636,13 +668,13 @@ } // Search myself - if (inBBox (p) && (this != excludeLMO) && isVisibleObj() ) + if (inBox (p) && (this != excludeLMO) && isVisibleObj() ) return this; // Search float images FloatImageObj *foi; for (foi=floatimage.first(); foi; foi=floatimage.next() ) - if (foi->inBBox(p) && + if (foi->inBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO && foi->isVisibleObj() @@ -653,11 +685,6 @@ void BranchObj::setHeading(QString s) { -/* FIXME testing only - cout << "BO::setHeading ("<0) + idAttr=attribut ("id",getSelectString()); + else + idAttr=""; + + s=beginElement ("branch" +scrolledAttr +posAttr +linkAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr +idAttr); incIndent(); // save heading @@ -837,6 +872,48 @@ return NULL; } +void BranchObj::setIncludeImagesVer(bool b) +{ + includeImagesVer=b; + calcBBoxSize(); + positionBBox(); + requestReposition(); + // FIMXE undo needed +} + +bool BranchObj::getIncludeImagesVer() +{ + return includeImagesVer; +} + +void BranchObj::setIncludeImagesHor(bool b) +{ + includeImagesHor=b; + calcBBoxSize(); + positionBBox(); + requestReposition(); + // FIMXE undo needed +} + +bool BranchObj::getIncludeImagesHor() +{ + return includeImagesHor; +} + +QString BranchObj::getIncludeImageAttr() +{ + QString a; + if (includeImagesVer) + a=attribut ("incImgV","true"); + else + a=attribut ("incImgV","false"); + if (includeImagesHor) + a+=" "+attribut ("incImgH","true"); + else + a+=" "+attribut ("incImgH","false"); + return a; +} + LinkableMapObj* BranchObj::addFloatImage () { FloatImageObj *newfi=new FloatImageObj (canvas,this); @@ -845,8 +922,11 @@ newfi->setVisibility (false); else newfi->setVisibility(visible); + calcBBoxSize(); + positionBBox(); requestReposition(); return newfi; + // FIMXE undo needed } LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio) @@ -858,8 +938,11 @@ newfi->setVisibility (false); else newfi->setVisibility(visible); + calcBBoxSize(); + positionBBox(); requestReposition(); return newfi; + // FIMXE undo needed } FloatImageObj* BranchObj::getFirstFloatImage () @@ -880,7 +963,10 @@ void BranchObj::removeFloatImage (FloatImageObj *fio) { floatimage.remove (fio); + calcBBoxSize(); + positionBBox(); requestReposition(); + // FIMXE undo needed } void BranchObj::savePosInAngle () @@ -1129,14 +1215,19 @@ void BranchObj::alignRelativeTo (QPoint ref) { + int th = bboxTotal.height(); /* TODO testing if (!getHeading().isEmpty()) cout << "BO::alignRelTo "<reposition(); - if (scrolled) return; // Set reference point for alignment of childs @@ -1214,6 +1301,10 @@ alignRelativeTo ( QPoint (absPos.x(), absPos.y()-(bboxTotal.height()-bbox.height())/2) ); branch.sort(); + + // After load, the floats might be at wrong position, force + // them to move, too + move (absPos); } else { // This is only important for moving branches: @@ -1247,14 +1338,14 @@ } void BranchObj::calcBBoxSizeWithChilds() -{ - // This is called only from reposition and +{ + // This is initially called only from reposition and // and only for mapcenter. So it won't be // called more than once for a single user // action + // Calculate size of LMO including all childs (to align them later) - bboxTotal.setX(bbox.x() ); bboxTotal.setY(bbox.y() ); @@ -1287,8 +1378,10 @@ bboxTotal.setWidth (bbox.width() + r.width() ); else bboxTotal.setWidth (bbox.width() + r.width() + linkwidth); - bboxTotal.setHeight(max (r.height(), bbox.height() ) ); + + bboxTotal.setHeight(max (r.height(), bbox.height())); // frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); + } void BranchObj::select()