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);
68 ornamentsBBox=other->ornamentsBBox;
72 QString OrnamentedObj::getHeading()
74 return heading->text();
77 void OrnamentedObj::setLinkColor()
79 if (mapEditor->getLinkColorHint()==HeadingColor)
80 LinkableMapObj::setLinkColor (heading->getColor());
82 LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor());
85 QColor OrnamentedObj::getColor ()
87 return heading->getColor();
91 void OrnamentedObj::positionContents()
93 double d=frame->getBorder()/2;
97 double ox,oy; // Offset due to padding
102 systemFlags-> move (ox +x , oy + y );
104 // vertical align heading to bottom
105 heading->move (ox + x + systemFlags->getBBox().width(),
106 oy + y + ornamentsBBox.height() - heading->getHeight()
108 standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
110 ornamentsBBox.moveTopLeft ( QPoint (ox+x, oy+y));
111 clickBox.moveTopLeft (QPoint (ox + x, oy + y));
115 void OrnamentedObj::move (double x, double y)
123 void OrnamentedObj::move (QPoint p)
128 void OrnamentedObj::moveBy (double x, double y)
131 MapObj::moveBy (x,y);
133 systemFlags->moveBy (x,y);
134 standardFlags->moveBy (x,y);
135 heading->moveBy (x,y);
140 void OrnamentedObj::moveBy (QPoint p)
142 moveBy (p.x(), p.y());
145 void OrnamentedObj::move2RelPos(double x, double y)
148 move (parObj->getChildPos().x()+x, parObj->getChildPos().y()+y);
151 void OrnamentedObj::move2RelPos(QPoint p)
153 move2RelPos (p.x(),p.y());
156 void OrnamentedObj::setNote(QString s)
160 systemFlags->activate("note");
162 systemFlags->deactivate("note");
165 move (absPos.x(), absPos.y() );
169 void OrnamentedObj::setNote(NoteObj n)
173 systemFlags->activate("note");
175 systemFlags->deactivate("note");
178 move (absPos.x(), absPos.y() );
183 QString OrnamentedObj::getNote()
185 return note.getNote();
188 QString OrnamentedObj::getNoteASCII()
190 return note.getNoteASCII();
193 QString OrnamentedObj::getNoteOpenDoc()
195 return note.getNoteOpenDoc();
198 void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
200 standardFlags->toggle(f,exclusive);
203 move (absPos.x(), absPos.y() );
207 void OrnamentedObj::activateStandardFlag(QString f)
209 standardFlags->activate(f);
212 move (absPos.x(), absPos.y() );
216 QString OrnamentedObj::getSystemFlagName(const QPoint &p)
218 return systemFlags->getFlagName(p);
221 void OrnamentedObj::updateNoteFlag()
225 // text in NoteEditor has changed, notify MapEditor
226 mapEditor->setChanged();
229 setNote( textEditor->getText() );
232 note.setFontHint (textEditor->getFontHint() );