author | insilmaril |
Sat, 09 Apr 2005 22:50:08 +0000 | |
changeset 94 | 6783e13bb05d |
parent 0 | 7a96bd401351 |
child 2 | 608f976aa7bb |
child 140 | cf1e44192f1e |
permissions | -rw-r--r-- |
1 #include "frameobj.h"
3 #include <qcolor.h>
5 /////////////////////////////////////////////////////////////////
6 // FrameObj
7 /////////////////////////////////////////////////////////////////
8 FrameObj::FrameObj() : MapObj()
9 {
10 // cout << "Const FrameObj ()\n";
11 init ();
12 }
14 FrameObj::FrameObj(QCanvas* c) :MapObj(c)
15 {
16 // cout << "Const FrameObj\n";
17 init ();
18 }
20 FrameObj::~FrameObj()
21 {
22 clear();
23 }
25 void FrameObj::init()
26 {
27 type=NoFrame;
28 border=0;
29 }
31 void FrameObj::clear()
32 {
33 switch (type)
34 {
35 case NoFrame:
36 break;
37 case Rectangle:
38 delete rectFrame;
39 break;
40 }
41 type=NoFrame;
42 border=0;
43 }
45 void FrameObj::move(double x, double y)
46 {
47 switch (type)
48 {
49 case NoFrame:
50 break;
51 case Rectangle:
52 rectFrame->move (x,y);
53 break;
54 }
55 }
57 void FrameObj::moveBy(double x, double y)
58 {
59 MapObj::moveBy (x,y);
60 }
62 void FrameObj::positionBBox()
63 {
64 }
66 void FrameObj::calcBBoxSize()
67 {
68 }
70 void FrameObj::setRect(const QRect &r)
71 {
72 bbox=r;
73 switch (type)
74 {
75 case NoFrame:
76 break;
77 case Rectangle:
78 rectFrame->setX (bbox.x() );
79 rectFrame->setY (bbox.y() );
80 rectFrame->setSize (bbox.width(),bbox.height() );
81 break;
82 }
83 }
85 int FrameObj::getBorder()
86 {
87 return border;
88 }
90 FrameType FrameObj::getFrameType()
91 {
92 return type;
93 }
95 QString FrameObj::getFrameTypeName()
96 {
97 switch (type)
98 {
99 case Rectangle:
100 return "Rectangle";
101 break;
102 default:
103 return "NoFrame";
104 }
105 }
107 void FrameObj::setFrameType(const FrameType &t)
108 {
109 if (t!=type)
110 {
111 clear();
112 type=t;
113 switch (type)
114 {
115 case NoFrame:
116 border=0;
117 break;
118 case Rectangle:
119 border=10;
120 rectFrame = new QCanvasRectangle (canvas);
121 rectFrame->setZ(Z_FRAME);
122 rectFrame->setBrush( QColor("white") );
123 rectFrame->setPen( QPen(QColor("black") ));
124 if (visible)
125 rectFrame->show();
126 else
127 rectFrame->hide();
128 break;
129 }
130 }
131 }
133 void FrameObj::setFrameType(const QString &t)
134 {
135 if (t=="Rectangle")
136 FrameObj::setFrameType (Rectangle);
137 else
138 FrameObj::setFrameType (NoFrame);
139 }
141 void FrameObj::setVisibility (bool v)
142 {
143 MapObj::setVisibility(v);
144 setFrameType (type); // changes on visibility depend on type...
145 }