• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • sources
  • kde-4.12
  • kdelibs
  • plasma
  • widgets
scrollbar.cpp
Go to the documentation of this file.
1 /*
2  * Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
3  * Copyright © 2008 Marco Martin <notmart@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU Library General Public License as
7  * published by the Free Software Foundation; either version 2, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #include "scrollbar.h"
22 
23 #include <QApplication>
24 #include <QContextMenuEvent>
25 #include <QGraphicsSceneContextMenuEvent>
26 
27 #include <plasma/private/style_p.h>
28 
29 namespace Plasma
30 {
31 
32 class ScrollBarPrivate
33 {
34 public:
35  Plasma::Style::Ptr style;
36 };
37 
38 ScrollBar::ScrollBar(QGraphicsWidget *parent)
39  : QGraphicsProxyWidget(parent),
40  d(new ScrollBarPrivate)
41 {
42  QScrollBar *scrollbar = new QScrollBar();
43  scrollbar->setWindowFlags(scrollbar->windowFlags()|Qt::BypassGraphicsProxyWidget);
44  scrollbar->setAttribute(Qt::WA_NoSystemBackground);
45  setWidget(scrollbar);
46  scrollbar->setWindowIcon(QIcon());
47  d->style = Plasma::Style::sharedStyle();
48  scrollbar->setStyle(d->style.data());
49 
50  scrollbar->resize(scrollbar->sizeHint());
51  connect(scrollbar, SIGNAL(valueChanged(int)), this, SIGNAL(valueChanged(int)));
52  connect(scrollbar, SIGNAL(sliderMoved(int)), this, SIGNAL(sliderMoved(int)));
53 }
54 
55 ScrollBar::~ScrollBar()
56 {
57  delete d;
58  Plasma::Style::doneWithSharedStyle();
59 }
60 
61 void ScrollBar::setRange(int min, int max)
62 {
63  static_cast<QScrollBar*>(widget())->setRange(min, max);
64 }
65 
66 void ScrollBar::setSingleStep(int val)
67 {
68  static_cast<QScrollBar*>(widget())->setSingleStep(val);
69 }
70 
71 int ScrollBar::singleStep()
72 {
73  return static_cast<QScrollBar*>(widget())->singleStep();
74 }
75 
76 void ScrollBar::setPageStep(int val)
77 {
78  static_cast<QScrollBar*>(widget())->setPageStep(val);
79 }
80 
81 int ScrollBar::pageStep()
82 {
83  return static_cast<QScrollBar*>(widget())->pageStep();
84 }
85 
86 void ScrollBar::setValue(int val)
87 {
88  static_cast<QScrollBar*>(widget())->setValue(val);
89 }
90 
91 int ScrollBar::value() const
92 {
93  return static_cast<QScrollBar*>(widget())->value();
94 }
95 
96 int ScrollBar::minimum() const
97 {
98  return static_cast<QScrollBar*>(widget())->minimum();
99 }
100 
101 int ScrollBar::maximum() const
102 {
103  return static_cast<QScrollBar*>(widget())->maximum();
104 }
105 
106 void ScrollBar::setMinimum(const int min) const
107 {
108  static_cast<QScrollBar*>(widget())->setMinimum(min);
109 }
110 
111 void ScrollBar::setMaximum(const int max) const
112 {
113  static_cast<QScrollBar*>(widget())->setMaximum(max);
114 }
115 
116 void ScrollBar::setStyleSheet(const QString &stylesheet)
117 {
118  widget()->setStyleSheet(stylesheet);
119 }
120 
121 QString ScrollBar::styleSheet()
122 {
123  return widget()->styleSheet();
124 }
125 
126 QScrollBar *ScrollBar::nativeWidget() const
127 {
128  return static_cast<QScrollBar *>(widget());
129 }
130 
131 Qt::Orientation ScrollBar::orientation() const
132 {
133  return nativeWidget()->orientation();
134 }
135 
136 void ScrollBar::setOrientation(Qt::Orientation orientation)
137 {
138  QScrollBar *native = static_cast<QScrollBar *>(widget());
139  native->setOrientation(orientation);
140  resize(native->sizeHint());
141 }
142 
143 void ScrollBar::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
144 {
145  QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()),
146  event->pos().toPoint(), event->screenPos(), event->modifiers());
147  QApplication::sendEvent(nativeWidget(), &contextMenuEvent);
148 }
149 
150 }
151 
152 #include <scrollbar.moc>
Plasma::ScrollBar::valueChanged
void valueChanged(int value)
Emitted when the value of the slider changes.
Plasma::ScrollBar::setMaximum
void setMaximum(const int max) const
Definition: scrollbar.cpp:111
Plasma::ScrollBar::setRange
void setRange(int min, int max)
Sets the scrollbar minimum and maximum values.
Definition: scrollbar.cpp:61
Plasma::ScrollBar::contextMenuEvent
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
Definition: scrollbar.cpp:143
Plasma::ScrollBar::nativeWidget
QScrollBar * nativeWidget() const
Plasma::ScrollBar::setPageStep
void setPageStep(int val)
Sets the amount the slider will scroll when the user press page up or page down.
Definition: scrollbar.cpp:76
Plasma::ScrollBar::setSingleStep
void setSingleStep(int val)
Sets the amount of the single step i.e how much the slider will move when the user press an arrow but...
Definition: scrollbar.cpp:66
Plasma::ScrollBar::setStyleSheet
void setStyleSheet(const QString &stylesheet)
Sets the stylesheet used to control the visual display of this ScrollBar.
Definition: scrollbar.cpp:116
Plasma::ScrollBar::pageStep
int pageStep()
QGraphicsProxyWidget
Plasma::ScrollBar::~ScrollBar
~ScrollBar()
Definition: scrollbar.cpp:55
Plasma::ScrollBar::singleStep
int singleStep()
Plasma::ScrollBar::sliderMoved
void sliderMoved(int value)
Emitted when the slider has been moved by the user.
Plasma::ScrollBar::orientation
Qt::Orientation orientation() const
Plasma::ScrollBar::maximum
int maximum() const
Plasma::ScrollBar::setOrientation
void setOrientation(Qt::Orientation orientation)
Sets the orientation of the ScrollBar.
Definition: scrollbar.cpp:136
Plasma::ScrollBar::setMinimum
void setMinimum(const int min) const
Definition: scrollbar.cpp:106
Plasma::ScrollBar::setValue
void setValue(int val)
Sets the current value for the ScrollBar.
Definition: scrollbar.cpp:86
Plasma::ScrollBar::minimum
int minimum() const
scrollbar.h
Plasma::ScrollBar::styleSheet
QString styleSheet()
Plasma::ScrollBar::value
int value() const
Plasma::ScrollBar::ScrollBar
ScrollBar(QGraphicsWidget *parent=0)
Creates a scrollbar; the default orientation is vertical.
Definition: scrollbar.cpp:38
QGraphicsWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:34 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal