krita

kis_ruler.h

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
00004  * Copyright (C) 2002 Patrick Julien <freak@codepimps.org>
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 #ifndef KIS_RULER_H_
00021 #define KIS_RULER_H_
00022 
00023 #include <qframe.h>
00024 #include <qpixmap.h>
00025 #include <KoUnit.h>
00026 
00027 // XXX: Make this look more like the KOffice ruler -- the KOffice
00028 // ruler is not quite suited to Krita. Also: start units with 0,
00029 // print every 100 units.
00030 
00031 #define RULER_THICKNESS 20
00032 
00033 class QPainter;
00034 
00035 class KisRuler : public QFrame {
00036     Q_OBJECT
00037     typedef QFrame super;
00038 
00039 public:
00040     KisRuler(Qt::Orientation, QWidget *parent = 0, const char *name = 0);
00041     virtual ~KisRuler();
00042 
00043 public:
00044     KoUnit::Unit unit() const;
00045 
00046 public slots:
00047     void setZoom(double zoom);
00048     void updatePointer(Q_INT32 x, Q_INT32 y);
00049     void updateVisibleArea(Q_INT32 xpos, Q_INT32 ypos);
00050     void setUnit(KoUnit::Unit u);
00051     void hide();
00052     void show();
00053 
00054 protected:
00055     virtual void paintEvent(QPaintEvent *e);
00056     virtual void resizeEvent(QResizeEvent *e);
00057     virtual void styleChange(QStyle& oldStyle);
00058     virtual void paletteChange(const QPalette& oldPalette);
00059 
00060     void recalculateSize();
00061     void drawRuler();
00062     void initMarker(Q_INT32 w, Q_INT32 h);
00063     void drawNums(QPainter *gc, Q_INT32 x, Q_INT32 y, QString& num, bool orientationHoriz);
00064 
00065 private:
00066     KoUnit::Unit m_unit;
00067     Qt::Orientation m_orientation;
00068     Q_INT32 m_firstVisible;
00069     Q_INT32 m_currentPosition;
00070     QPixmap *m_pixmapBuffer;
00071     QPixmap m_pixmapMarker;
00072     QPixmap m_pixmapNums;
00073     double m_zoom;
00074 
00075 private:
00076     static const char *m_nums[];
00077 };
00078 
00079 #endif // KIS_RULER_H_
00080 
KDE Home | KDE Accessibility Home | Description of Access Keys