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");
58 void OrnamentedObj::copy (OrnamentedObj* other)
60 LinkableMapObj::copy(other);
61 heading->copy(other->heading);
62 setColor (other->heading->getColor(),false);
64 note.copy (other->note);
65 systemFlags->copy (other->systemFlags);
66 standardFlags->copy (other->standardFlags);
70 QString OrnamentedObj::getHeading()
72 return heading->text();
75 void OrnamentedObj::setLinkColor()
77 if (mapEditor->getLinkColorHint()==HeadingColor)
78 LinkableMapObj::setLinkColor (heading->getColor());
80 LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor());
83 QColor OrnamentedObj::getColor ()
85 return heading->getColor();
89 void OrnamentedObj::positionContents()
91 double d=frame->getBorder()/2;
94 systemFlags-> move (x + d, y + d );
96 // vertical align heading to bottom
97 int h=max (systemFlags->getBBox().height(), standardFlags->getBBox().height());
98 h=max (h,heading->getHeight());
99 heading->move (x + d + systemFlags->getBBox().width(),
100 y + d + h - heading->getHeight()
102 standardFlags->move (x + heading->getWidth() + systemFlags->getBBox().width() + d , y + d );
105 void OrnamentedObj::move (double x, double y)
113 void OrnamentedObj::move (QPoint p)
118 void OrnamentedObj::moveBy (double x, double y)
121 MapObj::moveBy (x,y);
123 systemFlags->moveBy (x,y);
124 standardFlags->moveBy (x,y);
125 heading->moveBy (x,y);
130 void OrnamentedObj::moveBy (QPoint p)
132 moveBy (p.x(), p.y());
135 void OrnamentedObj::move2RelPos(double x, double y)
138 move (parObj->getChildPos().x()+x, parObj->getChildPos().y()+y);
141 void OrnamentedObj::move2RelPos(QPoint p)
144 move (parObj->getChildPos().x() + p.x(), parObj->getChildPos().y() + p.y() );
147 void OrnamentedObj::setNote(QString s)
151 systemFlags->activate("note");
153 systemFlags->deactivate("note");
156 move (absPos.x(), absPos.y() );
160 void OrnamentedObj::setNote(NoteObj n)
164 systemFlags->activate("note");
166 systemFlags->deactivate("note");
169 move (absPos.x(), absPos.y() );
174 QString OrnamentedObj::getNote()
176 return note.getNote();
179 QString OrnamentedObj::getNoteASCII()
181 return note.getNoteASCII();
184 QString OrnamentedObj::getNoteOpenDoc()
186 return note.getNoteOpenDoc();
189 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
191 standardFlags->toggle(f,exclusive);
194 move (absPos.x(), absPos.y() );
198 void OrnamentedObj::activateStandardFlag(QString f)
200 standardFlags->activate(f);
203 move (absPos.x(), absPos.y() );
207 QString OrnamentedObj::getSystemFlagName(const QPoint &p)
209 return systemFlags->getFlagName(p);
212 void OrnamentedObj::updateNoteFlag()
216 // text in NoteEditor has changed, notify MapEditor
217 mapEditor->setChanged();
220 setNote( textEditor->getText() );
223 note.setFontHint (textEditor->getFontHint() );