karbon

vruler.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 VRULER_H_
21#define VRULER_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
31class TQPainter;
32
33class VRuler : public TQFrame {
34 TQ_OBJECT
35
36 typedef TQFrame super;
37
38public:
39 VRuler(TQt::Orientation, TQWidget *parent = 0, const char *name = 0);
40 virtual ~VRuler();
41
42public:
43 KoUnit::Unit unit() const;
44
45public slots:
46 void setZoom(double zoom);
47 void updatePointer(TQ_INT32 x, TQ_INT32 y);
48 void updateVisibleArea(TQ_INT32 xpos, TQ_INT32 ypos);
49 void setUnit(KoUnit::Unit u);
50 void hide();
51 void show();
52
53public:
54 virtual void paintEvent(TQPaintEvent *e);
55 virtual void resizeEvent(TQResizeEvent *e);
56
57protected:
58 void recalculateSize();
59 void drawRuler();
60 void initMarker(TQ_INT32 w, TQ_INT32 h);
61 void drawNums(TQPainter *gc, TQ_INT32 x, TQ_INT32 y, TQString& num, bool orientationHoriz);
62
63private:
64 KoUnit::Unit m_unit;
65 TQt::Orientation m_orientation;
66 TQ_INT32 m_firstVisible;
67 TQ_INT32 m_currentPosition;
68 TQPixmap *m_pixmapBuffer;
69 TQPixmap m_pixmapMarker;
70 TQPixmap m_pixmapNums;
71 double m_zoom;
72
73private:
74 static const char *m_nums[];
75};
76
77#endif // VRULER_H_
78