##// END OF EJS Templates
Adds missing license headers
Michal Klocek -
r1535:954f1e6a64d9
parent child
Show More
@@ -1,144 +1,164
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 21 #include "chartlayout_p.h"
2 22 #include "chartpresenter_p.h"
3 23 #include "chartaxis_p.h"
4 #include <QDebug>
24
5 25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 26
7 27 ChartLayout::ChartLayout(ChartPresenter* presenter):
8 28 m_presenter(presenter),
9 29 m_marginBig(60),
10 30 m_marginSmall(20),
11 31 m_marginTiny(10),
12 32 m_chartMargins(QPointF(m_marginBig,m_marginBig),QPointF(m_marginBig,m_marginBig))
13 33 {
14 34
15 35 }
16 36
17 37 ChartLayout::~ChartLayout()
18 38 {
19 39
20 40 }
21 41
22 42 void ChartLayout::setGeometry(const QRectF& rect)
23 43 {
24 44 if (!rect.isValid()) return;
25 45
26 46 QGraphicsLayout::setGeometry(rect);
27 47
28 48 // check title size
29 49
30 50 QSize titleSize = QSize(0,0);
31 51
32 52 if (m_presenter->titleItem()) {
33 53 titleSize= m_presenter->titleItem()->boundingRect().size().toSize();
34 54 }
35 55
36 56 qreal axisHeight = 0;
37 57 qreal axisWidth = 0;
38 58
39 59 // check axis size
40 60
41 61 foreach (ChartAxis* axis,m_presenter->axisItems()){
42 62 if(axis->axisType() == ChartAxis::X_AXIS)
43 63 axisHeight = qMax(axis->minimumHeight(),axisHeight);
44 64 else
45 65 axisWidth = qMax(axis->minimumWidth(),axisWidth);
46 66 }
47 67
48 68 QLegend* legend = m_presenter->legend();
49 69
50 70 qreal titlePadding = m_chartMargins.top()/2;
51 71
52 72 QRectF chartMargins = m_chartMargins;
53 73
54 74 // recalculate legend position
55 75 if (legend != 0 && legend->isVisible() && legend->isAttachedToChart()) {
56 76
57 77 // Reserve some space for legend
58 78 switch (legend->alignment()) {
59 79
60 80 case Qt::AlignTop: {
61 81 QSizeF legendSize = legend->effectiveSizeHint(Qt::PreferredSize,QSizeF(rect.width(),-1));
62 82 int topMargin = 2*m_marginTiny + titleSize.height() + legendSize.height() + m_marginTiny;
63 83 chartMargins = QRect(QPoint(m_chartMargins.left(),topMargin),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
64 84 m_legendMargins = QRect(QPoint(chartMargins.left(),topMargin - (legendSize.height() + m_marginTiny)),QPoint(chartMargins.right(),rect.height()-topMargin + m_marginTiny));
65 85 titlePadding = m_marginTiny + m_marginTiny;
66 86 break;
67 87 }
68 88 case Qt::AlignBottom: {
69 89 QSizeF legendSize = legend->effectiveSizeHint(Qt::PreferredSize,QSizeF(rect.width(),-1));
70 90 int bottomMargin = m_marginTiny + m_marginSmall + legendSize.height() + m_marginTiny + axisHeight;
71 91 chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(m_chartMargins.right(),bottomMargin));
72 92 m_legendMargins = QRect(QPoint(chartMargins.left(),rect.height()-bottomMargin + m_marginTiny + axisHeight),QPoint(chartMargins.right(),m_marginTiny + m_marginSmall));
73 93 titlePadding = chartMargins.top()/2;
74 94 break;
75 95 }
76 96 case Qt::AlignLeft: {
77 97 QSizeF legendSize = legend->effectiveSizeHint(Qt::PreferredSize,QSizeF(-1,rect.height()));
78 98 int leftPadding = m_marginTiny + m_marginSmall + legendSize.width() + m_marginTiny + axisWidth;
79 99 chartMargins = QRect(QPoint(leftPadding,m_chartMargins.top()),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
80 100 m_legendMargins = QRect(QPoint(m_marginTiny + m_marginSmall,chartMargins.top()),QPoint(rect.width()-leftPadding + m_marginTiny + axisWidth,chartMargins.bottom()));
81 101 titlePadding = chartMargins.top()/2;
82 102 break;
83 103 }
84 104 case Qt::AlignRight: {
85 105 QSizeF legendSize = legend->effectiveSizeHint(Qt::PreferredSize,QSizeF(-1,rect.height()));
86 106 int rightPadding = m_marginTiny + m_marginSmall + legendSize.width() + m_marginTiny;
87 107 chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(rightPadding,m_chartMargins.bottom()));
88 108 m_legendMargins = QRect(QPoint(rect.width()- rightPadding+ m_marginTiny ,chartMargins.top()),QPoint(m_marginTiny + m_marginSmall,chartMargins.bottom()));
89 109 titlePadding = chartMargins.top()/2;
90 110 break;
91 111 }
92 112 default: {
93 113 break;
94 114 }
95 115 }
96 116
97 117 legend->setGeometry(rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom()));
98 118 }
99 119
100 120 // recalculate title position
101 121 if (m_presenter->titleItem()) {
102 122 QPointF center = rect.center() - m_presenter->titleItem()->boundingRect().center();
103 123 m_presenter->titleItem()->setPos(center.x(),titlePadding);
104 124 }
105 125
106 126 //recalculate background gradient
107 127 if (m_presenter->backgroundItem()) {
108 128 m_presenter->backgroundItem()->setRect(rect.adjusted(m_marginTiny,m_marginTiny, -m_marginTiny, -m_marginTiny));
109 129 }
110 130
111 131 QRectF chartRect = rect.adjusted(chartMargins.left(),chartMargins.top(),-chartMargins.right(),-chartMargins.bottom());
112 132
113 133 if(m_presenter->geometry()!=chartRect && chartRect.isValid()){
114 134 m_presenter->setGeometry(chartRect);
115 135 }else if(chartRect.size().isEmpty()){
116 136 m_presenter->setGeometry(QRect(rect.width()/2,rect.height()/2,1,1));
117 137 }
118 138
119 139 }
120 140
121 141
122 142 QSizeF ChartLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint) const
123 143 {
124 144 Q_UNUSED(constraint);
125 145 if(which == Qt::MinimumSize)
126 146 return QSize(2*(m_chartMargins.top()+m_chartMargins.bottom()),2*(m_chartMargins.top() + m_chartMargins.bottom()));
127 147 else
128 148 return QSize(-1,-1);
129 149 }
130 150
131 151 void ChartLayout::setMarginsMinimum(const QRectF& margins)
132 152 {
133 153 if(m_chartMargins != margins){
134 154 m_chartMargins = margins;
135 155 updateGeometry();
136 156 }
137 157 }
138 158
139 159 QRectF ChartLayout::margins() const
140 160 {
141 161 return m_chartMargins;
142 162 }
143 163
144 164 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,43 +1,63
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 21 #ifndef CHARTLAYOUT_H_
2 22 #define CHARTLAYOUT_H_
3 23 #include <QGraphicsLayout>
4 24 #include "qchartglobal.h"
5 25
6 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 27
8 28 class ChartPresenter;
9 29
10 30 class ChartLayout : public QGraphicsLayout
11 31 {
12 32 public:
13 33
14 34 ChartLayout(ChartPresenter* presenter);
15 35 virtual ~ChartLayout();
16 36
17 37 void setMarginsMinimum(const QRectF& margins);
18 38 QRectF margins() const;
19 39
20 40 void setGeometry(const QRectF& rect);
21 41
22 42 protected:
23 43 QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const;
24 44 int count() const { return 0; }
25 45 QGraphicsLayoutItem* itemAt(int) const { return 0; };
26 46 void removeAt(int){};
27 47
28 48 private:
29 49 ChartPresenter* m_presenter;
30 50 int m_marginBig;
31 51 int m_marginSmall;
32 52 int m_marginTiny;
33 53
34 54 QRectF m_chartMargins;
35 55 QRectF m_legendMargins;
36 56
37 57
38 58
39 59 };
40 60
41 61 QTCOMMERCIALCHART_END_NAMESPACE
42 62
43 63 #endif
@@ -1,348 +1,368
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 21 #include "legendlayout_p.h"
2 22 #include "chartpresenter_p.h"
3 23 #include "legendmarker_p.h"
4 24 #include "qlegend_p.h"
5 #include <QDebug>
25
6 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 27
8 28 LegendLayout::LegendLayout(QLegend* legend):
9 29 m_legend(legend)
10 30 {
11 31
12 32 }
13 33
14 34 LegendLayout::~LegendLayout()
15 35 {
16 36
17 37 }
18 38
19 39 void LegendLayout::setOffset(qreal x, qreal y)
20 40 {
21 41 bool scrollHorizontal = true;
22 42 switch(m_legend->alignment()) {
23 43 case Qt::AlignTop:
24 44 case Qt::AlignBottom: {
25 45 scrollHorizontal = true;
26 46 break;
27 47 }
28 48 case Qt::AlignLeft:
29 49 case Qt::AlignRight: {
30 50 scrollHorizontal = false;
31 51 break;
32 52 }
33 53 }
34 54
35 55 // If detached, the scrolling direction is vertical instead of horizontal and vice versa.
36 56 if (!m_legend->isAttachedToChart()) {
37 57 scrollHorizontal = !scrollHorizontal;
38 58 }
39 59
40 60 QRectF boundingRect = geometry();
41 61
42 62 // Limit offset between m_minOffset and m_maxOffset
43 63 if (scrollHorizontal) {
44 64 if(m_width<=boundingRect.width()) return;
45 65
46 66 if (x != m_offsetX) {
47 67 m_offsetX = qBound(m_minOffsetX, x, m_maxOffsetX);
48 68 m_legend->d_ptr->items()->setPos(-m_offsetX,boundingRect.top());
49 69 }
50 70 }
51 71 else {
52 72 if(m_height<=boundingRect.height()) return;
53 73
54 74 if (y != m_offsetY) {
55 75 m_offsetY = qBound(m_minOffsetY, y, m_maxOffsetY);
56 76 m_legend->d_ptr->items()->setPos(boundingRect.left(),-m_offsetY);
57 77 }
58 78 }
59 79 }
60 80
61 81 QPointF LegendLayout::offset() const
62 82 {
63 83 return QPointF(m_offsetX,m_offsetY);
64 84 }
65 85
66 86 void LegendLayout::setGeometry(const QRectF& rect)
67 87 {
68 88 if (!rect.isValid()) return;
69 89
70 90 QGraphicsLayout::setGeometry(rect);
71 91
72 92 if(m_legend->isAttachedToChart()) {
73 93 setAttachedGeometry(rect);
74 94 }
75 95 else {
76 96 setDettachedGeometry(rect);
77 97 }
78 98 }
79 99
80 100 void LegendLayout::setAttachedGeometry(const QRectF& rect)
81 101 {
82 102
83 103 m_offsetX=0;
84 104 m_offsetY=0;
85 105
86 106 QSizeF size(0,0);
87 107
88 108 if( m_legend->d_ptr->markers().isEmpty()) return;
89 109
90 110 m_width=0;
91 111 m_height=0;
92 112
93 113 switch(m_legend->alignment()) {
94 114
95 115 case Qt::AlignTop:
96 116
97 117 case Qt::AlignBottom: {
98 118 QPointF point(0,0);
99 119 foreach (LegendMarker* marker, m_legend->d_ptr->markers()) {
100 120 if (marker->isVisible()) {
101 121 marker->setGeometry(QRectF(QPoint(0,0),marker->effectiveSizeHint(Qt::PreferredSize)));
102 122 marker->setPos(point.x(),rect.height()/2 - marker->boundingRect().height()/2);
103 123 const QRectF& rect = marker->boundingRect();
104 124 size = size.expandedTo(rect.size());
105 125 qreal w = rect.width();
106 126 m_width+=w;
107 127 point.setX(point.x() + w);
108 128 }
109 129 }
110 130 if(m_width<rect.width()) {
111 131 m_legend->d_ptr->items()->setPos(rect.width()/2-m_width/2,rect.top());
112 132
113 133 }
114 134 else {
115 135 m_legend->d_ptr->items()->setPos(rect.topLeft());
116 136 }
117 137 m_height=size.height();
118 138 }
119 139 break;
120 140 case Qt::AlignLeft:
121 141 case Qt::AlignRight: {
122 142 QPointF point(0,0);
123 143 foreach (LegendMarker* marker, m_legend->d_ptr->markers()) {
124 144 if (marker->isVisible()) {
125 145 marker->setGeometry(QRectF(QPoint(0,0),marker->effectiveSizeHint(Qt::PreferredSize)));
126 146 marker->setPos(point);
127 147 const QRectF& rect = marker->boundingRect();
128 148 qreal h = rect.height();
129 149 size = size.expandedTo(rect.size());
130 150 m_height+=h;
131 151 point.setY(point.y() + h);
132 152 }
133 153 }
134 154 if(m_height<rect.height()) {
135 155 m_legend->d_ptr->items()->setPos(rect.left(),rect.height()/2-m_height/2);
136 156 }
137 157 else {
138 158 m_legend->d_ptr->items()->setPos(rect.topLeft());
139 159 }
140 160 m_width=size.width();
141 161 }
142 162 break;
143 163 }
144 164
145 165 m_minOffsetX = 0;
146 166 m_minOffsetY = 0;
147 167 m_maxOffsetX = m_width - rect.width();
148 168 m_maxOffsetY = m_height - rect.height();
149 169 }
150 170
151 171 void LegendLayout::setDettachedGeometry(const QRectF& rect)
152 172 {
153 173 // Detached layout is different.
154 174 // In detached mode legend may have multiple rows and columns, so layout calculations
155 175 // differ a log from attached mode.
156 176 // Also the scrolling logic is bit different.
157 177
158 178 m_offsetX=0;
159 179 m_offsetY=0;
160 180
161 181 QSizeF size(0,0);
162 182
163 183 if( m_legend->d_ptr->markers().isEmpty()) return;
164 184
165 185 QList<QGraphicsItem *> items = m_legend->d_ptr->items()->childItems();
166 186
167 187 switch (m_legend->alignment()) {
168 188 case Qt::AlignTop: {
169 189 QPointF point = rect.topLeft();
170 190 m_width = 0;
171 191 m_height = 0;
172 192 for (int i=0; i<items.count(); i++) {
173 193 QGraphicsItem *item = items.at(i);
174 194 if (item->isVisible()) {
175 195 const QRectF& boundingRect = item->boundingRect();
176 196 qreal w = boundingRect.width();
177 197 qreal h = boundingRect.height();
178 198 m_width = qMax(m_width,w);
179 199 m_height = qMax(m_height,h);
180 200 item->setPos(point.x(),point.y());
181 201 point.setX(point.x() + w);
182 202 if (point.x() + w > rect.topLeft().x() + rect.width()) {
183 203 // Next item would go off rect.
184 204 point.setX(rect.topLeft().x());
185 205 point.setY(point.y() + h);
186 206 if (i+1 < items.count()) {
187 207 m_height += h;
188 208 }
189 209 }
190 210 }
191 211 }
192 212 m_legend->d_ptr->items()->setPos(rect.topLeft());
193 213
194 214 m_minOffsetX = 0;
195 215 m_minOffsetY = 0;
196 216 m_maxOffsetX = m_width - rect.width();
197 217 m_maxOffsetY = m_height - rect.height();
198 218 }
199 219 break;
200 220 case Qt::AlignBottom: {
201 221 QPointF point = rect.bottomLeft();
202 222 m_width = 0;
203 223 m_height = 0;
204 224 for (int i=0; i<items.count(); i++) {
205 225 QGraphicsItem *item = items.at(i);
206 226 if (item->isVisible()) {
207 227 const QRectF& boundingRect = item->boundingRect();
208 228 qreal w = boundingRect.width();
209 229 qreal h = boundingRect.height();
210 230 m_width = qMax(m_width,w);
211 231 m_height = qMax(m_height,h);
212 232 item->setPos(point.x(),point.y() - h);
213 233 point.setX(point.x() + w);
214 234 if (point.x() + w > rect.bottomLeft().x() + rect.width()) {
215 235 // Next item would go off rect.
216 236 point.setX(rect.bottomLeft().x());
217 237 point.setY(point.y() - h);
218 238 if (i+1 < items.count()) {
219 239 m_height += h;
220 240 }
221 241 }
222 242 }
223 243 }
224 244 m_legend->d_ptr->items()->setPos(rect.topLeft());
225 245
226 246 m_minOffsetX = 0;
227 247 m_minOffsetY = qMin(rect.topLeft().y(), rect.topLeft().y() - m_height + rect.height());
228 248 m_maxOffsetX = m_width - rect.width();
229 249 m_maxOffsetY = 0;
230 250 }
231 251 break;
232 252 case Qt::AlignLeft: {
233 253 QPointF point = rect.topLeft();
234 254 m_width = 0;
235 255 m_height = 0;
236 256 qreal maxWidth = 0;
237 257 for (int i=0; i<items.count(); i++) {
238 258 QGraphicsItem *item = items.at(i);
239 259 if (item->isVisible()) {
240 260 const QRectF& boundingRect = item->boundingRect();
241 261 qreal w = boundingRect.width();
242 262 qreal h = boundingRect.height();
243 263 m_height = qMax(m_height,h);
244 264 maxWidth = qMax(maxWidth,w);
245 265 item->setPos(point.x(),point.y());
246 266 point.setY(point.y() + h);
247 267 if (point.y() + h > rect.topLeft().y() + rect.height()) {
248 268 // Next item would go off rect.
249 269 point.setX(point.x() + maxWidth);
250 270 point.setY(rect.topLeft().y());
251 271 if (i+1 < items.count()) {
252 272 m_width += maxWidth;
253 273 maxWidth = 0;
254 274 }
255 275 }
256 276 }
257 277 }
258 278 m_width += maxWidth;
259 279 m_legend->d_ptr->items()->setPos(rect.topLeft());
260 280
261 281 m_minOffsetX = 0;
262 282 m_minOffsetY = 0;
263 283 m_maxOffsetX = m_width - rect.width();
264 284 m_maxOffsetY = m_height - rect.height();
265 285 }
266 286 break;
267 287 case Qt::AlignRight: {
268 288 QPointF point = rect.topRight();
269 289 m_width = 0;
270 290 m_height = 0;
271 291 qreal maxWidth = 0;
272 292 for (int i=0; i<items.count(); i++) {
273 293 QGraphicsItem *item = items.at(i);
274 294 if (item->isVisible()) {
275 295 const QRectF& boundingRect = item->boundingRect();
276 296 qreal w = boundingRect.width();
277 297 qreal h = boundingRect.height();
278 298 m_height = qMax(m_height,h);
279 299 maxWidth = qMax(maxWidth,w);
280 300 item->setPos(point.x() - w,point.y());
281 301 point.setY(point.y() + h);
282 302 if (point.y() + h > rect.topLeft().y() + rect.height()) {
283 303 // Next item would go off rect.
284 304 point.setX(point.x() - maxWidth);
285 305 point.setY(rect.topLeft().y());
286 306 if (i+1 < items.count()) {
287 307 m_width += maxWidth;
288 308 maxWidth = 0;
289 309 }
290 310 }
291 311 }
292 312 }
293 313 m_width += maxWidth;
294 314 m_legend->d_ptr->items()->setPos(rect.topLeft());
295 315
296 316 m_minOffsetX = qMin(rect.topLeft().x(), rect.topLeft().x() - m_width + rect.width());
297 317 m_minOffsetY = 0;
298 318 m_maxOffsetX = 0;
299 319 m_maxOffsetY = m_height - rect.height();
300 320 }
301 321 break;
302 322 default:
303 323 break;
304 324 }
305 325
306 326 }
307 327
308 328 QSizeF LegendLayout::sizeHint ( Qt::SizeHint which, const QSizeF & constraint) const
309 329 {
310 330 QSizeF size(0, 0);
311 331 qreal left, top, right, bottom;
312 332 getContentsMargins(&left, &top, &right, &bottom);
313 333
314 334 if(constraint.isValid()) {
315 335 foreach(LegendMarker* marker, m_legend->d_ptr->markers()) {
316 336 size = size.expandedTo(marker->effectiveSizeHint(which));
317 337 }
318 338 size = size.boundedTo(constraint);
319 339 }
320 340 else if (constraint.width() >= 0) {
321 341 qreal width = 0;
322 342 qreal height = 0;
323 343 foreach(LegendMarker* marker, m_legend->d_ptr->markers()) {
324 344 width+=marker->effectiveSizeHint(which).width();
325 345 height=qMax(height,marker->effectiveSizeHint(which).height());
326 346 }
327 347
328 348 size = QSizeF(qMin(constraint.width(),width), height);
329 349 }
330 350 else if (constraint.height() >= 0) {
331 351 qreal width = 0;
332 352 qreal height = 0;
333 353 foreach(LegendMarker* marker, m_legend->d_ptr->markers()) {
334 354 width=qMax(width,marker->effectiveSizeHint(which).width());
335 355 height+=height,marker->effectiveSizeHint(which).height();
336 356 }
337 357 size = QSizeF(width,qMin(constraint.height(),height));
338 358 }
339 359 else {
340 360 foreach(LegendMarker* marker, m_legend->d_ptr->markers()) {
341 361 size = size.expandedTo(marker->effectiveSizeHint(which));
342 362 }
343 363 }
344 364 size += QSize(left + right, top + bottom);
345 365 return size;
346 366 }
347 367
348 368 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,50 +1,70
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
14 **
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
18 **
19 ****************************************************************************/
20
1 21 #ifndef LEGENDLAYOUT_H_
2 22 #define LEGENDLAYOUT_H_
3 23 #include <QGraphicsLayout>
4 24 #include "qchartglobal.h"
5 25
6 26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 27
8 28 class QLegend;
9 29
10 30 class LegendLayout : public QGraphicsLayout
11 31 {
12 32 public:
13 33
14 34 LegendLayout(QLegend* legend);
15 35 virtual ~LegendLayout();
16 36
17 37 void setGeometry(const QRectF& rect);
18 38
19 39 void setOffset(qreal x, qreal y);
20 40 QPointF offset() const;
21 41
22 42 protected:
23 43 QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint = QSizeF() ) const;
24 44 int count() const { return 0; }
25 45 QGraphicsLayoutItem* itemAt(int) const { return 0; };
26 46 void removeAt(int){};
27 47
28 48 private:
29 49 void setAttachedGeometry(const QRectF& rect);
30 50 void setDettachedGeometry(const QRectF& rect);
31 51
32 52 private:
33 53 QLegend* m_legend;
34 54 int m_marginBig;
35 55 int m_marginSmall;
36 56 int m_marginTiny;
37 57 qreal m_offsetX;
38 58 qreal m_offsetY;
39 59 qreal m_minOffsetX;
40 60 qreal m_minOffsetY;
41 61 qreal m_maxOffsetX;
42 62 qreal m_maxOffsetY;
43 63 qreal m_width;
44 64 qreal m_height;
45 65
46 66 };
47 67
48 68 QTCOMMERCIALCHART_END_NAMESPACE
49 69
50 70 #endif
General Comments 0
You need to be logged in to leave comments. Login now