author | insilmaril |
Tue, 05 Sep 2006 11:53:54 +0000 | |
changeset 371 | ebefeea77f2f |
parent 366 | e95081c21da2 |
child 408 | c2a05fa925a1 |
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(Q3Canvas* 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 Q3CanvasRectangle (canvas);
121 rectFrame->setZ(Z_FRAME);
122 rectFrame->setBrush( QColor("white") );
123 rectFrame->setPen( QPen(QColor("black") ));
124 break;
125 }
126 setVisibility (visible);
127 }
128 }
130 void FrameObj::setFrameType(const QString &t)
131 {
132 if (t=="Rectangle")
133 FrameObj::setFrameType (Rectangle);
134 else
135 FrameObj::setFrameType (NoFrame);
136 }
138 void FrameObj::setVisibility (bool v)
139 {
140 MapObj::setVisibility(v);
141 switch (type)
142 {
143 case NoFrame:
144 break;
145 case Rectangle:
146 if (visible)
147 rectFrame->show();
148 else
149 rectFrame->hide();
150 break;
151 }
152 }