1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/frameobj.cpp Wed Jul 13 10:22:14 2005 +0000
1.3 @@ -0,0 +1,146 @@
1.4 +#include "frameobj.h"
1.5 +
1.6 +#include <qcolor.h>
1.7 +
1.8 +/////////////////////////////////////////////////////////////////
1.9 +// FrameObj
1.10 +/////////////////////////////////////////////////////////////////
1.11 +FrameObj::FrameObj() : MapObj()
1.12 +{
1.13 +// cout << "Const FrameObj ()\n";
1.14 + init ();
1.15 +}
1.16 +
1.17 +FrameObj::FrameObj(QCanvas* c) :MapObj(c)
1.18 +{
1.19 +// cout << "Const FrameObj\n";
1.20 + init ();
1.21 +}
1.22 +
1.23 +FrameObj::~FrameObj()
1.24 +{
1.25 + clear();
1.26 +}
1.27 +
1.28 +void FrameObj::init()
1.29 +{
1.30 + type=NoFrame;
1.31 + border=0;
1.32 +}
1.33 +
1.34 +void FrameObj::clear()
1.35 +{
1.36 + switch (type)
1.37 + {
1.38 + case NoFrame:
1.39 + break;
1.40 + case Rectangle:
1.41 + delete rectFrame;
1.42 + break;
1.43 + }
1.44 + type=NoFrame;
1.45 + border=0;
1.46 +}
1.47 +
1.48 +void FrameObj::move(double x, double y)
1.49 +{
1.50 + switch (type)
1.51 + {
1.52 + case NoFrame:
1.53 + break;
1.54 + case Rectangle:
1.55 + rectFrame->move (x,y);
1.56 + break;
1.57 + }
1.58 +}
1.59 +
1.60 +void FrameObj::moveBy(double x, double y)
1.61 +{
1.62 + MapObj::moveBy (x,y);
1.63 +}
1.64 +
1.65 +void FrameObj::positionBBox()
1.66 +{
1.67 +}
1.68 +
1.69 +void FrameObj::calcBBoxSize()
1.70 +{
1.71 +}
1.72 +
1.73 +void FrameObj::setRect(const QRect &r)
1.74 +{
1.75 + bbox=r;
1.76 + switch (type)
1.77 + {
1.78 + case NoFrame:
1.79 + break;
1.80 + case Rectangle:
1.81 + rectFrame->setX (bbox.x() );
1.82 + rectFrame->setY (bbox.y() );
1.83 + rectFrame->setSize (bbox.width(),bbox.height() );
1.84 + break;
1.85 + }
1.86 +}
1.87 +
1.88 +int FrameObj::getBorder()
1.89 +{
1.90 + return border;
1.91 +}
1.92 +
1.93 +FrameType FrameObj::getFrameType()
1.94 +{
1.95 + return type;
1.96 +}
1.97 +
1.98 +QString FrameObj::getFrameTypeName()
1.99 +{
1.100 + switch (type)
1.101 + {
1.102 + case Rectangle:
1.103 + return "Rectangle";
1.104 + break;
1.105 + default:
1.106 + return "NoFrame";
1.107 + }
1.108 +}
1.109 +
1.110 +void FrameObj::setFrameType(const FrameType &t)
1.111 +{
1.112 + if (t!=type)
1.113 + {
1.114 + clear();
1.115 + type=t;
1.116 + switch (type)
1.117 + {
1.118 + case NoFrame:
1.119 + border=0;
1.120 + break;
1.121 + case Rectangle:
1.122 + border=10;
1.123 + rectFrame = new QCanvasRectangle (canvas);
1.124 + rectFrame->setZ(Z_FRAME);
1.125 + rectFrame->setBrush( QColor("white") );
1.126 + rectFrame->setPen( QPen(QColor("black") ));
1.127 + if (visible)
1.128 + rectFrame->show();
1.129 + else
1.130 + rectFrame->hide();
1.131 + break;
1.132 + }
1.133 + }
1.134 +}
1.135 +
1.136 +void FrameObj::setFrameType(const QString &t)
1.137 +{
1.138 + if (t=="Rectangle")
1.139 + FrameObj::setFrameType (Rectangle);
1.140 + else
1.141 + FrameObj::setFrameType (NoFrame);
1.142 +}
1.143 +
1.144 +void FrameObj::setVisibility (bool v)
1.145 +{
1.146 + MapObj::setVisibility(v);
1.147 + setFrameType (type); // changes on visibility depend on type...
1.148 +}
1.149 +