karbon

vruler.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 VRULER_H_
00021 #define VRULER_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 class QPainter;
00032 
00033 class VRuler : public QFrame {
00034     Q_OBJECT
00035     typedef QFrame super;
00036 
00037 public:
00038     VRuler(Qt::Orientation, QWidget *parent = 0, const char *name = 0);
00039     virtual ~VRuler();
00040 
00041 public:
00042     KoUnit::Unit unit() const;
00043 
00044 public slots:
00045     void setZoom(double zoom);
00046     void updatePointer(Q_INT32 x, Q_INT32 y);
00047     void updateVisibleArea(Q_INT32 xpos, Q_INT32 ypos);
00048     void setUnit(KoUnit::Unit u);
00049     void hide();
00050     void show();
00051 
00052 public:
00053     virtual void paintEvent(QPaintEvent *e);
00054     virtual void resizeEvent(QResizeEvent *e);
00055 
00056 protected:
00057     void recalculateSize();
00058     void drawRuler();
00059     void initMarker(Q_INT32 w, Q_INT32 h);
00060     void drawNums(QPainter *gc, Q_INT32 x, Q_INT32 y, QString& num, bool orientationHoriz);
00061 
00062 private:
00063     KoUnit::Unit m_unit;
00064     Qt::Orientation m_orientation;
00065     Q_INT32 m_firstVisible;
00066     Q_INT32 m_currentPosition;
00067     QPixmap *m_pixmapBuffer;
00068     QPixmap m_pixmapMarker;
00069     QPixmap m_pixmapNums;
00070     double m_zoom;
00071 
00072 private:
00073     static const char *m_nums[];
00074 };
00075 
00076 #endif // VRULER_H_
00077 
KDE Home | KDE Accessibility Home | Description of Access Keys