krita
kis_ruler.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00028
00029
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
|