compile
[kdegraphics.git] / okular / ui / annotationtools.h
blob1ee32801e7a42055bd587067400e911d688e7333
1 /***************************************************************************
2 * Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef _OKULAR_ANNOTATIONTOOLS_H_
11 #define _OKULAR_ANNOTATIONTOOLS_H_
13 #include <qdom.h>
14 #include <qlinkedlist.h>
15 #include <qrect.h>
17 #include "core/area.h"
19 class QPainter;
20 class PageViewItem;
21 namespace Okular {
22 class Annotation;
23 class Page;
26 /**
27 * @short Engine: filter events to distill Annotation's.
29 class AnnotatorEngine
31 public:
32 AnnotatorEngine( const QDomElement & engineElement );
33 virtual ~AnnotatorEngine();
35 // enum definitions
36 enum EventType { Press, Move, Release };
37 enum Button { None, Left, Right };
39 // perform operations
40 virtual QRect event( EventType type, Button button, double nX, double nY, double xScale, double yScale, const Okular::Page * page ) = 0;
41 virtual void paint( QPainter * painter, double xScale, double yScale, const QRect & clipRect ) = 0;
42 virtual QList< Okular::Annotation* > end() = 0;
44 // query creation state
45 //PageViewItem * editingItem() const { return m_lockedItem; }
46 bool creationCompleted() const { return m_creationCompleted; }
48 void setItem( PageViewItem * item ) { m_item = item; }
50 protected:
51 PageViewItem * item() { return m_item; }
53 // common engine attributes (the element includes annotation desc)
54 QDomElement m_engineElement;
55 QDomElement m_annotElement;
56 QColor m_engineColor;
57 // other vars (remove this!)
58 bool m_creationCompleted;
60 private:
61 PageViewItem * m_item;
64 /** @short SmoothPathEngine */
65 class SmoothPathEngine
66 : public AnnotatorEngine
68 public:
69 SmoothPathEngine( const QDomElement & engineElement );
71 QRect event( EventType type, Button button, double nX, double nY, double xScale, double yScale, const Okular::Page * /*page*/ );
73 void paint( QPainter * painter, double xScale, double yScale, const QRect & /*clipRect*/ );
75 QList< Okular::Annotation* > end();
77 private:
78 // data
79 QLinkedList<Okular::NormalizedPoint> points;
80 Okular::NormalizedRect totalRect;
81 Okular::NormalizedPoint lastPoint;
84 #endif