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

libs/libksane/libksane

  • sources
  • kde-4.14
  • kdegraphics
  • libs
  • libksane
  • libksane
  • widgets
gamma_disp.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the KDE project
4  *
5  * Date : 2007-09-13
6  * Description : Sane interface for KDE
7  *
8  * Copyright (C) 2007-2008 by Kare Sars <kare.sars@iki .fi>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) version 3, or any
14  * later version accepted by the membership of KDE e.V. (or its
15  * successor approved by the membership of KDE e.V.), which shall
16  * act as a proxy defined in Section 6 of version 3 of the license.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this program. If not, see <http://www.gnu.org/licenses/>.
25  *
26  * ============================================================ */
27 
28 // Local includes
29 #include "gamma_disp.h"
30 #include "gamma_disp.moc"
31 
32 // Qt includes
33 #include <QPainter>
34 
35 namespace KSaneIface
36 {
37 
38 GammaDisp::GammaDisp(QWidget *parent, QVector<int> *tbl)
39  : QWidget(parent)
40 {
41  gam_tbl = tbl;
42  gam_color.setRgb(0,0,0);
43 }
44 
45 QSize GammaDisp::minimumSizeHint() const
46 {
47  return QSize(75, 75);
48 }
49 
50 QSize GammaDisp::sizeHint() const
51 {
52  return QSize(75, 75);
53 }
54 
55 void GammaDisp::setColor(const QColor &color)
56 {
57  gam_color = color;
58 }
59 
60 void GammaDisp::resizeEvent (QResizeEvent*)
61 {
62  repaint();
63 }
64 
65 void GammaDisp::paintEvent(QPaintEvent *)
66 {
67 /* QMemArray<QRect> rects = event->region().rects();
68  for (int i = 0; i < (int)rects.size(); i++) {
69  bitBlt(this, rects[i].topLeft(), &pixmap, rects[i]);
70  }*/
71  QPointF p1, p2;
72  QPainter painter(this);
73  painter.fillRect(rect(), QBrush(Qt::white));
74 
75  double xscale = (double)(size().width()-1) / (double)gam_tbl->size();
76  double yscale = (double)(size().height()-1) / (double)gam_tbl->size();
77 
78  painter.setPen(gam_color);
79  for (int i=0; i<gam_tbl->size()-1; i++) {
80  p1.setX(i*xscale);
81  p1.setY(size().height()- 1 - (gam_tbl->at(i) * yscale));
82 
83  p2.setX((i+1)*xscale);
84  p2.setY(size().height()- 1 - (gam_tbl->at(i+1) * yscale));
85 
86  painter.drawLine(p1, p2);
87  }
88 }
89 
90 } // NameSpace KSaneIface
QResizeEvent
QWidget
QSize::width
int width() const
QPainter::fillRect
void fillRect(const QRectF &rectangle, const QBrush &brush)
QBrush
KSaneIface::GammaDisp::sizeHint
QSize sizeHint() const
Definition: gamma_disp.cpp:50
QPainter::drawLine
void drawLine(const QLineF &line)
KSaneIface::GammaDisp::minimumSizeHint
QSize minimumSizeHint() const
Definition: gamma_disp.cpp:45
QColor::setRgb
void setRgb(int r, int g, int b, int a)
KSaneIface::GammaDisp::setColor
void setColor(const QColor &color)
Definition: gamma_disp.cpp:55
gamma_disp.h
QPointF
QWidget::size
QSize size() const
QPainter::setPen
void setPen(const QColor &color)
QPainter
KSaneIface::GammaDisp::paintEvent
void paintEvent(QPaintEvent *)
Definition: gamma_disp.cpp:65
QColor
QWidget::rect
QRect rect() const
QSize
QWidget::repaint
void repaint()
QVector::at
const T & at(int i) const
QVector< int >
QPointF::setX
void setX(qreal x)
QPointF::setY
void setY(qreal y)
QSize::height
int height() const
KSaneIface::GammaDisp::resizeEvent
void resizeEvent(QResizeEvent *)
Definition: gamma_disp.cpp:60
KSaneIface::GammaDisp::GammaDisp
GammaDisp(QWidget *parent, QVector< int > *tbl)
Create a gamma display.
Definition: gamma_disp.cpp:38
QPaintEvent
QVector::size
int size() const
QWidget::height
int height() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:47 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libs/libksane/libksane

Skip menu "libs/libksane/libksane"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegraphics API Reference

Skip menu "kdegraphics API Reference"
  •     libkdcraw
  •     libkexiv2
  •     libkipi
  •     libksane
  • okular

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