1
/* This file is part of the KDE project
2
Copyright (C) 2003 Alexander Dymo <cloudtemple@mksat.net>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
21
#include <kglobalsettings.h>
30
#include "canvkutemplate.h"
32
#include "creportitem.h"
35
void CanvasBand::draw(QPainter &painter)
37
setX(((MyCanvas*)canvas())->templ->props["LeftMargin"]->value().toInt());
38
setSize(((MyCanvas*)canvas())->templ->width()
39
- ((MyCanvas*)canvas())->templ->props["RightMargin"]->value().toInt()
40
- ((MyCanvas*)canvas())->templ->props["LeftMargin"]->value().toInt(),
41
props["Height"]->value().toInt());
42
CanvasSection::draw(painter);
45
//arrange band and all sublings (items)
46
void CanvasBand::arrange(int base, bool destructive)
48
int diff = base - (int)y();
52
for (QCanvasItemList::Iterator it=items.begin(); it!=items.end(); ++it)
54
(*it)->moveBy(0, diff);
55
// ( (CanvasReportItem *)(*it) )->updateGeomProps();
62
int CanvasBand::minHeight()
65
for (QCanvasItemList::Iterator it=items.begin(); it!=items.end(); ++it)
67
result=QMAX(result,((QCanvasRectangle*)(*it))->y()+
68
((QCanvasRectangle*)(*it))->height());
73
QString CanvasBand::getXml()
76
std::map<QString, PropPtr >::const_iterator it;
77
for (it = props.begin(); it != props.end(); ++it)
79
if (it->second->allowSaving())
80
result += " " + it->first + "=" + "\"" + it->second->value() + "\"";
83
for (QCanvasItemList::Iterator it=items.begin(); it!=items.end(); ++it)
85
result += ((CanvasReportItem *)(*it))->getXml();
90
int CanvasBand::isInHolder(const QPoint p)
92
if (bottomMiddleResizableRect().contains(p)) return (ResizeBottom);
96
void CanvasBand::drawHolders(QPainter &painter)
98
painter.setPen(QColor(0, 0, 0));
100
painter.setBrush(KGlobalSettings::highlightColor());
102
painter.setBrush(QColor(160, 160, 160));
104
painter.drawRect(bottomMiddleResizableRect());
107
QRect CanvasBand::bottomMiddleResizableRect()
109
return QRect((int)(x()+width()/2-HolderSize/2.), (int)(y()+height()-HolderSize), HolderSize, HolderSize);
112
void CanvasBand::updateGeomProps()
114
props["Height"]->setValue(QString("%1").arg(height()));
115
((MyCanvas *)canvas())->templ->arrangeSections();
118
CanvasBand::~CanvasBand()
120
for (QCanvasItemList::Iterator it = items.begin(); it != items.end(); ++it)
123
((MyCanvas *)canvas())->selected.remove((CanvasBox*)(*it));
124
(*it)->setSelected(false);