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

kalgebra

  • sources
  • kde-4.14
  • kdeedu
  • kalgebra
  • src
viewportwidget.cpp
Go to the documentation of this file.
1 /*************************************************************************************
2  * Copyright (C) 2009 by Aleix Pol <aleixpol@kde.org> *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License *
6  * as published by the Free Software Foundation; either version 2 *
7  * of the License, or (at your option) any later version. *
8  * *
9  * This program 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 *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the Free Software *
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
17  *************************************************************************************/
18 
19 #include "viewportwidget.h"
20 
21 #include <QFormLayout>
22 #include <KLocale>
23 #include <QDoubleSpinBox>
24 #include <KPushButton>
25 #include <QBoxLayout>
26 #include <limits>
27 
28 ViewportWidget::ViewportWidget(QWidget * parent, Qt::WFlags flags)
29  : QWidget (parent, flags)
30 {
31  const double LIMIT=std::numeric_limits<double>::max();
32 
33  m_top=new QDoubleSpinBox(this);
34  m_left=new QDoubleSpinBox(this);
35  m_width=new QDoubleSpinBox(this);
36  m_height=new QDoubleSpinBox(this);
37 
38  m_top->setRange(-LIMIT, LIMIT);
39  m_left->setRange(-LIMIT, LIMIT);
40  m_width->setRange(0, LIMIT);
41  m_height->setRange(0, LIMIT);
42 
43  QVBoxLayout* upperLayout=new QVBoxLayout;
44  setLayout(upperLayout);
45  QFormLayout* layout=new QFormLayout;
46  layout->addRow(i18n("Left:"), m_left);
47  layout->addRow(i18n("Top:"), m_top);
48  layout->addRow(i18n("Width:"), m_width);
49  layout->addRow(i18n("Height:"), m_height);
50 
51  QPushButton *apply=new KPushButton(KIcon("dialog-ok-apply"), i18n("Apply"), this);
52  connect(apply, SIGNAL(clicked()), SLOT(emitViewport()));
53 
54  upperLayout->addLayout(layout);
55  upperLayout->addWidget(apply);
56 }
57 
58 QRectF ViewportWidget::viewport() const
59 {
60  return QRectF(m_left->value(), m_top->value(),
61  m_width->value(), -m_height->value());
62 }
63 
64 void ViewportWidget::setViewport(const QRectF& current)
65 {
66  m_top->setValue(current.top());
67  m_left->setValue(current.left());
68  m_width->setValue(current.width());
69  m_height->setValue(-current.height());
70 }
71 
72 void ViewportWidget::emitViewport ()
73 {
74  emit viewportChange(viewport());
75 }
QWidget::layout
QLayout * layout() const
QWidget
ViewportWidget::ViewportWidget
ViewportWidget(QWidget *parent=0, Qt::WFlags flags=0)
Definition: viewportwidget.cpp:28
ViewportWidget::viewportChange
void viewportChange(const QRectF &newViewport)
ViewportWidget::viewport
QRectF viewport() const
Definition: viewportwidget.cpp:58
QRectF::top
qreal top() const
QDoubleSpinBox::setRange
void setRange(double minimum, double maximum)
QRectF::left
qreal left() const
QDoubleSpinBox
QBoxLayout::addWidget
void addWidget(QWidget *widget, int stretch, QFlags< Qt::AlignmentFlag > alignment)
QWidget::setLayout
void setLayout(QLayout *layout)
ViewportWidget::setViewport
void setViewport(const QRectF &current)
Definition: viewportwidget.cpp:64
QVBoxLayout
viewportwidget.h
QDoubleSpinBox::value
value
Qt::WFlags
typedef WFlags
QFormLayout::addRow
void addRow(QWidget *label, QWidget *field)
QRectF::width
qreal width() const
QRectF
QRectF::height
qreal height() const
QPushButton
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QBoxLayout::addLayout
void addLayout(QLayout *layout, int stretch)
QFormLayout
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:11:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalgebra

Skip menu "kalgebra"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

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