1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/ornamentedobj.cpp Thu Jul 17 12:55:24 2008 +0000
1.3 @@ -0,0 +1,211 @@
1.4 +#include "ornamentedobj.h"
1.5 +#include "texteditor.h"
1.6 +#include "mapeditor.h"
1.7 +#include "linkablemapobj.h"
1.8 +
1.9 +extern TextEditor *textEditor;
1.10 +extern FlagRowObj *systemFlagsDefault;
1.11 +extern FlagRowObj *standardFlagsDefault;
1.12 +
1.13 +
1.14 +/////////////////////////////////////////////////////////////////
1.15 +// OrnamentedObj
1.16 +/////////////////////////////////////////////////////////////////
1.17 +
1.18 +OrnamentedObj::OrnamentedObj():LinkableMapObj()
1.19 +{
1.20 + // cout << "Const OrnamentedObj ()\n";
1.21 + init ();
1.22 +}
1.23 +
1.24 +OrnamentedObj::OrnamentedObj(QCanvas* c) :LinkableMapObj(c)
1.25 +{
1.26 +// cout << "Const OrnamentedObj\n";
1.27 + init ();
1.28 +}
1.29 +
1.30 +OrnamentedObj::OrnamentedObj (OrnamentedObj* lmo) : LinkableMapObj (lmo->canvas)
1.31 +{
1.32 + copy (lmo);
1.33 +}
1.34 +
1.35 +OrnamentedObj::~OrnamentedObj()
1.36 +{
1.37 + delete (heading);
1.38 + delete (systemFlags);
1.39 + delete (standardFlags);
1.40 +
1.41 +}
1.42 +
1.43 +
1.44 +void OrnamentedObj::init ()
1.45 +{
1.46 + heading = new HeadingObj(canvas);
1.47 + heading->move (absPos.x(), absPos.y());
1.48 +
1.49 + note.setNote("");
1.50 + note.setFontHint (textEditor->getFontHintDefault() );
1.51 +
1.52 + systemFlags=new FlagRowObj(canvas);
1.53 + systemFlags->clone(systemFlagsDefault);
1.54 + systemFlags->setName ("systemFlags");
1.55 +
1.56 + standardFlags=new FlagRowObj(canvas);
1.57 + standardFlags->clone(standardFlagsDefault);
1.58 + standardFlags->setName ("standardFlags");
1.59 +
1.60 +
1.61 +
1.62 +}
1.63 +
1.64 +void OrnamentedObj::copy (OrnamentedObj* other)
1.65 +{
1.66 + LinkableMapObj::copy(other);
1.67 + heading->copy(other->heading);
1.68 + setColor (other->heading->getColor(),false);
1.69 +
1.70 + note.copy (other->note);
1.71 + systemFlags->copy (other->systemFlags);
1.72 + standardFlags->copy (other->standardFlags);
1.73 +
1.74 +}
1.75 +
1.76 +QString OrnamentedObj::getHeading()
1.77 +{
1.78 + return heading->text();
1.79 +}
1.80 +
1.81 +void OrnamentedObj::setLinkColor()
1.82 +{
1.83 + if (mapEditor->getLinkColorHint()==HeadingColor)
1.84 + LinkableMapObj::setLinkColor (heading->getColor());
1.85 + else
1.86 + LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor());
1.87 +}
1.88 +
1.89 +QColor OrnamentedObj::getColor ()
1.90 +{
1.91 + return heading->getColor();
1.92 +}
1.93 +
1.94 +
1.95 +void OrnamentedObj::move (double x, double y)
1.96 +{
1.97 + MapObj::move (x,y);
1.98 + double dx=frame->getBorder()/2; // care for border around object
1.99 + double dy=frame->getBorder()/2;
1.100 + systemFlags-> move (x + dx, y + dy);
1.101 +
1.102 + // vertical align heading to bottom
1.103 + int h=max (systemFlags->getBBox().height(), standardFlags->getBBox().height());
1.104 + h=max (h,heading->getHeight());
1.105 + heading->move (x + dx + systemFlags->getBBox().width(),
1.106 + y + dy + h - heading->getHeight()
1.107 + );
1.108 + standardFlags->move (x + heading->getWidth() + systemFlags->getBBox().width(), y + dy );
1.109 +
1.110 + updateLink();
1.111 + requestReposition();
1.112 +}
1.113 +
1.114 +void OrnamentedObj::move (QPoint p)
1.115 +{
1.116 + move (p.x(), p.y());
1.117 +}
1.118 +
1.119 +void OrnamentedObj::moveBy (double x, double y)
1.120 +{
1.121 +
1.122 + MapObj::moveBy (x,y);
1.123 + frame->moveBy (x,y);
1.124 + systemFlags->moveBy (x,y);
1.125 + standardFlags->moveBy (x,y);
1.126 + heading->moveBy (x,y);
1.127 + updateLink();
1.128 + requestReposition();
1.129 +}
1.130 +
1.131 +void OrnamentedObj::moveBy (QPoint p)
1.132 +{
1.133 + moveBy (p.x(), p.y());
1.134 +}
1.135 +
1.136 +void OrnamentedObj::move2RelPos(double x, double y)
1.137 +{
1.138 + if (!parObj) return;
1.139 + move (parObj->getChildPos().x()+x, parObj->getChildPos().y()+y);
1.140 +}
1.141 +
1.142 +void OrnamentedObj::move2RelPos(QPoint p)
1.143 +{
1.144 + if (!parObj) return;
1.145 + move (parObj->getChildPos().x() + p.x(), parObj->getChildPos().y() + p.y() );
1.146 +}
1.147 +
1.148 +void OrnamentedObj::setNote(QString s)
1.149 +{
1.150 + note.setNote(s);
1.151 + if (!note.isEmpty())
1.152 + systemFlags->activate("note");
1.153 + else
1.154 + systemFlags->deactivate("note");
1.155 + calcBBoxSize();
1.156 + positionBBox();
1.157 + move (absPos.x(), absPos.y() );
1.158 + forceReposition();
1.159 +}
1.160 +
1.161 +void OrnamentedObj::setNote(NoteObj n)
1.162 +{
1.163 + note=n;
1.164 + if (!note.isEmpty())
1.165 + systemFlags->activate("note");
1.166 + else
1.167 + systemFlags->deactivate("note");
1.168 + calcBBoxSize();
1.169 + positionBBox();
1.170 + move (absPos.x(), absPos.y() );
1.171 + forceReposition();
1.172 +
1.173 +}
1.174 +
1.175 +QString OrnamentedObj::getNote()
1.176 +{
1.177 + return note.getNote();
1.178 +}
1.179 +
1.180 +void OrnamentedObj::toggleStandardFlag(QString f)
1.181 +{
1.182 + standardFlags->toggle(f);
1.183 + calcBBoxSize();
1.184 + positionBBox();
1.185 + move (absPos.x(), absPos.y() );
1.186 + forceReposition();
1.187 +}
1.188 +
1.189 +void OrnamentedObj::activateStandardFlag(QString f)
1.190 +{
1.191 + standardFlags->activate(f);
1.192 + calcBBoxSize();
1.193 + positionBBox();
1.194 + move (absPos.x(), absPos.y() );
1.195 + forceReposition();
1.196 +}
1.197 +
1.198 +QString OrnamentedObj::getSystemFlagName(const QPoint &p)
1.199 +{
1.200 + return systemFlags->getFlagName(p);
1.201 +}
1.202 +
1.203 +void OrnamentedObj::updateNoteFlag()
1.204 +{
1.205 + // text in NoteEditor has changed, notify MapEditor
1.206 + mapEditor->setChanged();
1.207 +
1.208 + // save text
1.209 + setNote( textEditor->getText() );
1.210 +
1.211 + // save font
1.212 + note.setFontHint (textEditor->getFontHint() );
1.213 +}
1.214 +