3 #include "ornamentedobj.h"
4 #include "texteditor.h"
6 #include "linkablemapobj.h"
8 extern TextEditor *textEditor;
10 /////////////////////////////////////////////////////////////////
12 /////////////////////////////////////////////////////////////////
14 OrnamentedObj::OrnamentedObj():LinkableMapObj()
16 // cout << "Const OrnamentedObj ()\n";
20 OrnamentedObj::OrnamentedObj(QGraphicsScene* s) :LinkableMapObj(s)
22 // cout << "Const OrnamentedObj (s)\n";
26 OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->scene)
31 OrnamentedObj::~OrnamentedObj()
40 void OrnamentedObj::init ()
42 heading = new HeadingObj(scene);
43 heading->move (absPos.x(), absPos.y());
45 systemFlags=new FlagRowObj(scene);
46 standardFlags=new FlagRowObj(scene);
48 frame = new FrameObj (scene);
51 void OrnamentedObj::copy (OrnamentedObj* other)
53 LinkableMapObj::copy(other);
54 heading->copy(other->heading);
55 setColor (other->heading->getColor());
57 systemFlags->copy (other->systemFlags);
58 standardFlags->copy (other->standardFlags);
60 ornamentsBBox=other->ornamentsBBox;
63 void OrnamentedObj::setLinkColor()
65 if (model->getMapLinkColorHint()==HeadingColor)
66 LinkableMapObj::setLinkColor (heading->getColor());
68 LinkableMapObj::setLinkColor (model->getMapDefLinkColor());
71 void OrnamentedObj::setColor (QColor col)
73 heading->setColor(col);
77 QColor OrnamentedObj::getColor ()
79 return heading->getColor();
82 FrameObj::FrameType OrnamentedObj::getFrameType()
84 return frame->getFrameType();
87 QString OrnamentedObj::getFrameTypeName()
89 return frame->getFrameTypeName();
92 void OrnamentedObj::setFrameType(const FrameObj::FrameType &t)
94 frame->setFrameType(t);
95 if (t == FrameObj::NoFrame)
96 linkpos=LinkableMapObj::Bottom;
98 linkpos=LinkableMapObj::Middle;
105 void OrnamentedObj::setFrameType(const QString &t)
107 frame->setFrameType(t);
108 if (frame->getFrameType() == FrameObj::NoFrame)
109 linkpos=LinkableMapObj::Bottom;
111 linkpos=LinkableMapObj::Middle;
118 void OrnamentedObj::setFramePadding (const int &i)
120 frame->setPadding (i);
126 int OrnamentedObj::getFramePadding ()
128 return frame->getPadding();
131 void OrnamentedObj::setFrameBorderWidth (const int &i)
133 frame->setBorderWidth(i);
139 int OrnamentedObj::getFrameBorderWidth()
141 return frame->getBorderWidth();
144 void OrnamentedObj::setFramePenColor(QColor col)
146 frame->setPenColor (col);
149 QColor OrnamentedObj::getFramePenColor()
151 return frame->getPenColor ();
154 void OrnamentedObj::setFrameBrushColor(QColor col)
156 frame->setBrushColor (col);
159 QColor OrnamentedObj::getFrameBrushColor()
161 return frame->getBrushColor ();
164 void OrnamentedObj::positionContents()
166 double d=frame->getPadding()/2;
170 double ox,oy; // Offset due to padding
175 systemFlags-> move (ox +x , oy + y );
177 // vertical align heading to bottom
178 heading->move (ox + x + systemFlags->getBBox().width(),
179 oy + y + ornamentsBBox.height() - heading->getHeight()
181 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
183 ornamentsBBox.moveTopLeft ( QPointF ((int)(ox+x),(int)(oy+y)));
184 clickBox.moveTopLeft (QPointF ((int)(ox + x), (int)(oy + y)));
187 void OrnamentedObj::move (double x, double y)
195 void OrnamentedObj::move (QPointF p)
200 void OrnamentedObj::moveBy (double x, double y)
203 MapObj::moveBy (x,y);
205 systemFlags->moveBy (x,y);
206 standardFlags->moveBy (x,y);
207 heading->moveBy (x,y);
212 void OrnamentedObj::moveBy (QPointF p)
214 moveBy (p.x(), p.y());
217 void OrnamentedObj::move2RelPos(double x, double y)
219 setRelPos (QPointF(x,y));
222 QPointF p=parObj->getChildPos();
223 move (p.x()+x, p.y() +y);
227 void OrnamentedObj::move2RelPos(QPointF p)
229 move2RelPos (p.x(),p.y());
232 void OrnamentedObj::activateStandardFlag(Flag *flag)
234 standardFlags->activate(flag);
237 move (absPos.x(), absPos.y() );
241 void OrnamentedObj::deactivateStandardFlag(const QString &name)
243 standardFlags->deactivate(name);
246 move (absPos.x(), absPos.y() );
251 QString OrnamentedObj::getSystemFlagName(const QPointF &p)
253 return systemFlags->getFlagName(p);
256 /* FIXME-3 should move to VymView ?! void OrnamentedObj::getNoteFromTextEditor ()
258 note.setFilenameHint (textEditor->getFilename());
259 note.setFontHint (textEditor->getFontHint() );
260 setNote( textEditor->getText() );
264 QString OrnamentedObj::getOrnXMLAttr() //FIXME-2
268 if (treeItem->depth()==0)
270 attribut("absPosX",QString().setNum(absPos.x())) +
271 attribut("absPosY",QString().setNum(absPos.y()));
274 if (treeItem->depth()==1 || typeid (*this)==typeid (FloatImageObj))
276 if (relPos.x()==0 && relPos.y()==0)
279 attribut("relPosX",QString().setNum(relPos.x())) +
280 attribut("relPosY",QString().setNum(relPos.y()));
285 /* FIXME-2 QString hideExpAttr;
287 hideExpAttr= attribut("hideInExport","true");
291 return posAttr +getLinkAttr() ;//+hideExpAttr;