1.1 --- a/branchobj.cpp Mon Oct 10 11:20:25 2005 +0000
1.2 +++ b/branchobj.cpp Wed Feb 15 12:54:55 2006 +0000
1.3 @@ -102,6 +102,9 @@
1.4 scrolled=false;
1.5 tmpUnscrolled=false;
1.6
1.7 + includeImagesVer=false;
1.8 + includeImagesHor=false;
1.9 +
1.10 url="";
1.11 vymLink="";
1.12 }
1.13 @@ -544,6 +547,9 @@
1.14 void BranchObj::move (double x, double y)
1.15 {
1.16 OrnamentedObj::move (x,y);
1.17 + FloatImageObj *fio;
1.18 + for (fio=floatimage.first(); fio; fio=floatimage.next() )
1.19 + fio->reposition();
1.20 positionBBox();
1.21 }
1.22
1.23 @@ -577,17 +583,13 @@
1.24 cout << "BO::positionBBox (noHeading)\n";
1.25 */
1.26
1.27 - // Position contents by moving OO
1.28 - OrnamentedObj::move (absPos.x(),absPos.y());
1.29 -
1.30 - // It seems that setting x,y also affects width,height
1.31 - int w_old=bbox.width();
1.32 - int h_old=bbox.height();
1.33 - bbox.setX (absPos.x() );
1.34 - bbox.setY (absPos.y() );
1.35 - bbox.setWidth(w_old);
1.36 - bbox.setHeight(h_old);
1.37 + positionContents();
1.38 +
1.39 + int d=frame->getBorder()/2;
1.40
1.41 + bbox.moveTopLeft (QPoint (absPos.x(), absPos.y() - topPad));
1.42 + clickBox.moveTopLeft(QPoint (absPos.x()+d, absPos.y()+d ));
1.43 +
1.44 setSelBox();
1.45
1.46 // set the frame
1.47 @@ -619,8 +621,38 @@
1.48 h=max (sysflags_h,stanflags_h);
1.49 h=max (h,heading_h);
1.50
1.51 + clickBox.setSize (QSize (w,h));
1.52 +
1.53 + // Floatimages
1.54 + QPoint rp;
1.55 + FloatImageObj *foi;
1.56 +
1.57 + topPad=botPad=leftPad=rightPad=0;
1.58 + if (includeImagesVer || includeImagesHor)
1.59 + {
1.60 + if (countFloatImages()>0)
1.61 + {
1.62 + for (foi=floatimage.first(); foi; foi=floatimage.next() )
1.63 + {
1.64 + rp=foi->getRelPos();
1.65 + if (includeImagesVer)
1.66 + {
1.67 + if (rp.y() < 0)
1.68 + topPad=max (topPad,-rp.y());
1.69 + if (rp.y()+foi->height() > h)
1.70 + botPad=max (botPad,rp.y()+foi->height()-h);
1.71 + }
1.72 + }
1.73 + }
1.74 +
1.75 + h+=topPad+botPad;
1.76 + }
1.77 +
1.78 + // Frame thickness
1.79 w+=frame->getBorder();
1.80 h+=frame->getBorder();
1.81 +
1.82 + // Finally set size
1.83 bbox.setSize (QSize (w,h));
1.84 }
1.85
1.86 @@ -636,13 +668,13 @@
1.87 }
1.88
1.89 // Search myself
1.90 - if (inBBox (p) && (this != excludeLMO) && isVisibleObj() )
1.91 + if (inBox (p) && (this != excludeLMO) && isVisibleObj() )
1.92 return this;
1.93
1.94 // Search float images
1.95 FloatImageObj *foi;
1.96 for (foi=floatimage.first(); foi; foi=floatimage.next() )
1.97 - if (foi->inBBox(p) &&
1.98 + if (foi->inBox(p) &&
1.99 (foi != excludeLMO) &&
1.100 foi->getParObj()!= excludeLMO &&
1.101 foi->isVisibleObj()
1.102 @@ -653,11 +685,6 @@
1.103
1.104 void BranchObj::setHeading(QString s)
1.105 {
1.106 -/* FIXME testing only
1.107 - cout << "BO::setHeading ("<<s<<")\n";
1.108 - cout << " bo.pos="<<absPos<<endl;
1.109 - cout << " ho.pos="<<heading->getPos()<<endl;
1.110 -*/
1.111 heading->setText(s); // set new heading
1.112 calcBBoxSize(); // recalculate bbox
1.113 positionBBox(); // rearrange contents
1.114 @@ -732,7 +759,8 @@
1.115 else
1.116 posAttr="";
1.117
1.118 - QString linkAttr=getLinkAttr();
1.119 + QString linkAttr=getLinkAttr()+" "+getIncludeImageAttr();
1.120 +
1.121
1.122 QString urlAttr;
1.123 if (!url.isEmpty())
1.124 @@ -761,7 +789,14 @@
1.125 } else
1.126 areaAttr="";
1.127
1.128 - s=beginElement ("branch" +scrolledAttr +posAttr +linkAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr );
1.129 + // Providing an ID for a branch makes export to XHTML easier
1.130 + QString idAttr;
1.131 + if (countXLinks()>0)
1.132 + idAttr=attribut ("id",getSelectString());
1.133 + else
1.134 + idAttr="";
1.135 +
1.136 + s=beginElement ("branch" +scrolledAttr +posAttr +linkAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr +idAttr);
1.137 incIndent();
1.138
1.139 // save heading
1.140 @@ -837,6 +872,48 @@
1.141 return NULL;
1.142 }
1.143
1.144 +void BranchObj::setIncludeImagesVer(bool b)
1.145 +{
1.146 + includeImagesVer=b;
1.147 + calcBBoxSize();
1.148 + positionBBox();
1.149 + requestReposition();
1.150 + // FIMXE undo needed
1.151 +}
1.152 +
1.153 +bool BranchObj::getIncludeImagesVer()
1.154 +{
1.155 + return includeImagesVer;
1.156 +}
1.157 +
1.158 +void BranchObj::setIncludeImagesHor(bool b)
1.159 +{
1.160 + includeImagesHor=b;
1.161 + calcBBoxSize();
1.162 + positionBBox();
1.163 + requestReposition();
1.164 + // FIMXE undo needed
1.165 +}
1.166 +
1.167 +bool BranchObj::getIncludeImagesHor()
1.168 +{
1.169 + return includeImagesHor;
1.170 +}
1.171 +
1.172 +QString BranchObj::getIncludeImageAttr()
1.173 +{
1.174 + QString a;
1.175 + if (includeImagesVer)
1.176 + a=attribut ("incImgV","true");
1.177 + else
1.178 + a=attribut ("incImgV","false");
1.179 + if (includeImagesHor)
1.180 + a+=" "+attribut ("incImgH","true");
1.181 + else
1.182 + a+=" "+attribut ("incImgH","false");
1.183 + return a;
1.184 +}
1.185 +
1.186 LinkableMapObj* BranchObj::addFloatImage ()
1.187 {
1.188 FloatImageObj *newfi=new FloatImageObj (canvas,this);
1.189 @@ -845,8 +922,11 @@
1.190 newfi->setVisibility (false);
1.191 else
1.192 newfi->setVisibility(visible);
1.193 + calcBBoxSize();
1.194 + positionBBox();
1.195 requestReposition();
1.196 return newfi;
1.197 + // FIMXE undo needed
1.198 }
1.199
1.200 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
1.201 @@ -858,8 +938,11 @@
1.202 newfi->setVisibility (false);
1.203 else
1.204 newfi->setVisibility(visible);
1.205 + calcBBoxSize();
1.206 + positionBBox();
1.207 requestReposition();
1.208 return newfi;
1.209 + // FIMXE undo needed
1.210 }
1.211
1.212 FloatImageObj* BranchObj::getFirstFloatImage ()
1.213 @@ -880,7 +963,10 @@
1.214 void BranchObj::removeFloatImage (FloatImageObj *fio)
1.215 {
1.216 floatimage.remove (fio);
1.217 + calcBBoxSize();
1.218 + positionBBox();
1.219 requestReposition();
1.220 + // FIMXE undo needed
1.221 }
1.222
1.223 void BranchObj::savePosInAngle ()
1.224 @@ -1129,14 +1215,19 @@
1.225
1.226 void BranchObj::alignRelativeTo (QPoint ref)
1.227 {
1.228 + int th = bboxTotal.height();
1.229 /* TODO testing
1.230 if (!getHeading().isEmpty())
1.231 cout << "BO::alignRelTo "<<getHeading()<<endl;
1.232 else
1.233 cout << "BO::alignRelTo ???"<<endl;
1.234 - cout << " d="<<depth<<endl;
1.235 + cout << " d="<<depth<<
1.236 + // " ref="<<ref<<
1.237 + // " bbTot="<<bboxTotal.topLeft()<<
1.238 + // " absPos="<<absPos<<
1.239 + " pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
1.240 + " th="<<th<<endl;
1.241 */
1.242 - int th = bboxTotal.height();
1.243
1.244 // If I am the mapcenter or a mainbranch, reposition heading
1.245 if (depth<2)
1.246 @@ -1149,7 +1240,7 @@
1.247 // around mapcenter
1.248 angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ),
1.249 (int)(y() - parObj->getChildPos().y() ) ) );
1.250 - }
1.251 + }
1.252 }
1.253 else
1.254 {
1.255 @@ -1158,10 +1249,10 @@
1.256 switch (orientation)
1.257 {
1.258 case OrientLeftOfCenter:
1.259 - move (ref.x()-bbox.width(), ref.y() + (th-bbox.height())/2 );
1.260 + move (ref.x()-bbox.width(), ref.y() + (th-bbox.height())/2 +topPad);
1.261 break;
1.262 case OrientRightOfCenter:
1.263 - move (ref.x(), ref.y() + (th-bbox.height())/2 );
1.264 + move (ref.x(), ref.y() + (th-bbox.height())/2 + topPad);
1.265 break;
1.266 default:
1.267 cout <<"LMO::alignRelativeTo: oops, no orientation given...\n";
1.268 @@ -1169,10 +1260,6 @@
1.269 }
1.270 }
1.271
1.272 - FloatImageObj *fio;
1.273 - for (fio=floatimage.first(); fio; fio=floatimage.next() )
1.274 - fio->reposition();
1.275 -
1.276 if (scrolled) return;
1.277
1.278 // Set reference point for alignment of childs
1.279 @@ -1214,6 +1301,10 @@
1.280 alignRelativeTo ( QPoint (absPos.x(),
1.281 absPos.y()-(bboxTotal.height()-bbox.height())/2) );
1.282 branch.sort();
1.283 +
1.284 + // After load, the floats might be at wrong position, force
1.285 + // them to move, too
1.286 + move (absPos);
1.287 } else
1.288 {
1.289 // This is only important for moving branches:
1.290 @@ -1247,14 +1338,14 @@
1.291 }
1.292
1.293 void BranchObj::calcBBoxSizeWithChilds()
1.294 -{
1.295 - // This is called only from reposition and
1.296 +{
1.297 + // This is initially called only from reposition and
1.298 // and only for mapcenter. So it won't be
1.299 // called more than once for a single user
1.300 // action
1.301
1.302 +
1.303 // Calculate size of LMO including all childs (to align them later)
1.304 -
1.305 bboxTotal.setX(bbox.x() );
1.306 bboxTotal.setY(bbox.y() );
1.307
1.308 @@ -1287,8 +1378,10 @@
1.309 bboxTotal.setWidth (bbox.width() + r.width() );
1.310 else
1.311 bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
1.312 - bboxTotal.setHeight(max (r.height(), bbox.height() ) );
1.313 +
1.314 + bboxTotal.setHeight(max (r.height(), bbox.height()));
1.315 // frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
1.316 +
1.317 }
1.318
1.319 void BranchObj::select()