chalk

kis_ruler.h
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2000-2001 theKompany.com & Dave Marotti
4 * Copyright (C) 2002 Patrick Julien <freak@codepimps.org>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20#ifndef KIS_RULER_H_
21#define KIS_RULER_H_
22
23#include <tqframe.h>
24#include <tqpixmap.h>
25#include <KoUnit.h>
26
27// XXX: Make this look more like the KOffice ruler -- the KOffice
28// ruler is not quite suited to Chalk. Also: start units with 0,
29// print every 100 units.
30
31#define RULER_THICKNESS 20
32
33class TQPainter;
34
35class KisRuler : public TQFrame {
36 TQ_OBJECT
37
38 typedef TQFrame super;
39
40public:
41 KisRuler(TQt::Orientation, TQWidget *parent = 0, const char *name = 0);
42 virtual ~KisRuler();
43
44public:
45 KoUnit::Unit unit() const;
46
47public slots:
48 void setZoom(double zoom);
49 void updatePointer(TQ_INT32 x, TQ_INT32 y);
50 void updateVisibleArea(TQ_INT32 xpos, TQ_INT32 ypos);
51 void setUnit(KoUnit::Unit u);
52 void hide();
53 void show();
54
55protected:
56 virtual void paintEvent(TQPaintEvent *e);
57 virtual void resizeEvent(TQResizeEvent *e);
58 virtual void styleChange(TQStyle& oldStyle);
59 virtual void paletteChange(const TQPalette& oldPalette);
60
61 void recalculateSize();
62 void drawRuler();
63 void initMarker(TQ_INT32 w, TQ_INT32 h);
64 void drawNums(TQPainter *gc, TQ_INT32 x, TQ_INT32 y, TQString& num, bool orientationHoriz);
65
66private:
67 KoUnit::Unit m_unit;
68 TQt::Orientation m_orientation;
69 TQ_INT32 m_firstVisible;
70 TQ_INT32 m_currentPosition;
71 TQPixmap *m_pixmapBuffer;
72 TQPixmap m_pixmapMarker;
73 TQPixmap m_pixmapNums;
74 double m_zoom;
75
76private:
77 static const char *m_nums[];
78};
79
80#endif // KIS_RULER_H_
81