2008-11-04 00:08:39 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
|
|
|
|
* Copyright © 2008 Marco Martin <notmart@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "scrollbar.h"
|
|
|
|
|
2008-11-15 08:08:30 +01:00
|
|
|
#include <plasma/private/style_p.h>
|
2008-11-04 00:08:39 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-11-15 08:08:30 +01:00
|
|
|
class ScrollBarPrivate
|
|
|
|
{
|
|
|
|
public:
|
2008-12-15 22:17:43 +01:00
|
|
|
Plasma::Style::Ptr style;
|
2008-11-15 08:08:30 +01:00
|
|
|
};
|
|
|
|
|
2008-12-15 21:34:03 +01:00
|
|
|
ScrollBar::ScrollBar(QGraphicsWidget *parent)
|
|
|
|
: QGraphicsProxyWidget(parent),
|
|
|
|
d(new ScrollBarPrivate)
|
2008-11-04 00:08:39 +01:00
|
|
|
{
|
2008-12-15 21:34:03 +01:00
|
|
|
QScrollBar *scrollbar = new QScrollBar();
|
2008-11-04 00:08:39 +01:00
|
|
|
scrollbar->setAttribute(Qt::WA_NoSystemBackground);
|
|
|
|
setWidget(scrollbar);
|
2008-12-15 22:17:43 +01:00
|
|
|
d->style = Plasma::Style::sharedStyle();
|
|
|
|
scrollbar->setStyle(d->style.data());
|
2008-12-05 22:04:33 +01:00
|
|
|
|
|
|
|
scrollbar->resize(scrollbar->sizeHint());
|
2008-12-15 21:34:03 +01:00
|
|
|
connect(scrollbar, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ScrollBar::~ScrollBar()
|
|
|
|
{
|
2008-11-15 08:39:59 +01:00
|
|
|
delete d;
|
2008-12-15 22:17:43 +01:00
|
|
|
Plasma::Style::doneWithSharedStyle();
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::setRange(int min, int max)
|
|
|
|
{
|
|
|
|
static_cast<QScrollBar*>(widget())->setRange(min, max);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::setSingleStep(int val)
|
|
|
|
{
|
|
|
|
static_cast<QScrollBar*>(widget())->setSingleStep(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ScrollBar::singleStep()
|
|
|
|
{
|
|
|
|
return static_cast<QScrollBar*>(widget())->singleStep();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::setPageStep(int val)
|
|
|
|
{
|
|
|
|
static_cast<QScrollBar*>(widget())->setPageStep(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ScrollBar::pageStep()
|
|
|
|
{
|
|
|
|
return static_cast<QScrollBar*>(widget())->pageStep();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::setValue(int val)
|
|
|
|
{
|
|
|
|
static_cast<QScrollBar*>(widget())->setValue(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ScrollBar::value() const
|
|
|
|
{
|
|
|
|
return static_cast<QScrollBar*>(widget())->value();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ScrollBar::minimum() const
|
|
|
|
{
|
|
|
|
return static_cast<QScrollBar*>(widget())->minimum();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ScrollBar::maximum() const
|
|
|
|
{
|
|
|
|
return static_cast<QScrollBar*>(widget())->maximum();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScrollBar::setStyleSheet(const QString &stylesheet)
|
|
|
|
{
|
|
|
|
widget()->setStyleSheet(stylesheet);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ScrollBar::styleSheet()
|
|
|
|
{
|
|
|
|
return widget()->styleSheet();
|
|
|
|
}
|
|
|
|
|
|
|
|
QScrollBar *ScrollBar::nativeWidget() const
|
|
|
|
{
|
2009-08-16 22:15:25 +02:00
|
|
|
return static_cast<QScrollBar *>(widget());
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
2008-12-15 21:34:03 +01:00
|
|
|
void ScrollBar::setOrientation(Qt::Orientation orientation)
|
|
|
|
{
|
2009-08-16 22:15:25 +02:00
|
|
|
QScrollBar *native = static_cast<QScrollBar *>(widget());
|
|
|
|
native->setOrientation(orientation);
|
|
|
|
resize(native->sizeHint());
|
2008-12-15 21:34:03 +01:00
|
|
|
}
|
|
|
|
|
2008-11-04 00:08:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#include <scrollbar.moc>
|