1 #include "ornamentedobj.h"
2 #include "texteditor.h"
4 #include "linkablemapobj.h"
6 extern TextEditor *textEditor;
7 extern FlagRowObj *systemFlagsDefault;
8 extern FlagRowObj *standardFlagsDefault;
11 /////////////////////////////////////////////////////////////////
13 /////////////////////////////////////////////////////////////////
15 OrnamentedObj::OrnamentedObj():LinkableMapObj()
17 // cout << "Const OrnamentedObj ()\n";
21 OrnamentedObj::OrnamentedObj(QCanvas* c) :LinkableMapObj(c)
23 // cout << "Const OrnamentedObj\n";
27 OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->canvas)
32 OrnamentedObj::~OrnamentedObj()
36 delete (standardFlags);
41 void OrnamentedObj::init ()
43 heading = new HeadingObj(canvas);
44 heading->move (absPos.x(), absPos.y());
47 note.setFontHint (textEditor->getFontHintDefault() );
49 systemFlags=new FlagRowObj(canvas);
50 systemFlags->clone(systemFlagsDefault);
51 systemFlags->setName ("systemFlags");
53 standardFlags=new FlagRowObj(canvas);
54 standardFlags->clone(standardFlagsDefault);
55 standardFlags->setName ("standardFlags");
61 void OrnamentedObj::copy (OrnamentedObj* other)
63 LinkableMapObj::copy(other);
64 heading->copy(other->heading);
65 setColor (other->heading->getColor(),false);
67 note.copy (other->note);
68 systemFlags->copy (other->systemFlags);
69 standardFlags->copy (other->standardFlags);
73 QString OrnamentedObj::getHeading()
75 return heading->text();
78 void OrnamentedObj::setLinkColor()
80 if (mapEditor->getLinkColorHint()==HeadingColor)
81 LinkableMapObj::setLinkColor (heading->getColor());
83 LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor());
86 QColor OrnamentedObj::getColor ()
88 return heading->getColor();
92 void OrnamentedObj::move (double x, double y)
95 double dx=frame->getBorder()/2; // care for border around object
96 double dy=frame->getBorder()/2;
97 systemFlags-> move (x + dx, y + dy);
99 // vertical align heading to bottom
100 int h=max (systemFlags->getBBox().height(), standardFlags->getBBox().height());
101 h=max (h,heading->getHeight());
102 heading->move (x + dx + systemFlags->getBBox().width(),
103 y + dy + h - heading->getHeight()
105 standardFlags->move (x + heading->getWidth() + systemFlags->getBBox().width(), y + dy );
111 void OrnamentedObj::move (QPoint p)
116 void OrnamentedObj::moveBy (double x, double y)
119 MapObj::moveBy (x,y);
121 systemFlags->moveBy (x,y);
122 standardFlags->moveBy (x,y);
123 heading->moveBy (x,y);
128 void OrnamentedObj::moveBy (QPoint p)
130 moveBy (p.x(), p.y());
133 void OrnamentedObj::move2RelPos(double x, double y)
136 move (parObj->getChildPos().x()+x, parObj->getChildPos().y()+y);
139 void OrnamentedObj::move2RelPos(QPoint p)
142 move (parObj->getChildPos().x() + p.x(), parObj->getChildPos().y() + p.y() );
145 void OrnamentedObj::setNote(QString s)
149 systemFlags->activate("note");
151 systemFlags->deactivate("note");
154 move (absPos.x(), absPos.y() );
158 void OrnamentedObj::setNote(NoteObj n)
162 systemFlags->activate("note");
164 systemFlags->deactivate("note");
167 move (absPos.x(), absPos.y() );
172 QString OrnamentedObj::getNote()
174 return note.getNote();
177 void OrnamentedObj::toggleStandardFlag(QString f)
179 standardFlags->toggle(f);
182 move (absPos.x(), absPos.y() );
186 void OrnamentedObj::activateStandardFlag(QString f)
188 standardFlags->activate(f);
191 move (absPos.x(), absPos.y() );
195 QString OrnamentedObj::getSystemFlagName(const QPoint &p)
197 return systemFlags->getFlagName(p);
200 void OrnamentedObj::updateNoteFlag()
202 // text in NoteEditor has changed, notify MapEditor
203 mapEditor->setChanged();
206 setNote( textEditor->getText() );
209 note.setFontHint (textEditor->getFontHint() );