kpdf_pagewidget.h 2.23 KB
Newer Older
1 2 3 4 5
#ifndef _KPDF_PAGEWIDGET_H_
#define _KPDF_PAGEWIDGET_H_

#include <qpixmap.h>
#include <qwidget.h>
6
#include <qscrollview.h>
7

Kurt Pfeifle's avatar
Kurt Pfeifle committed
8 9
#include <kurl.h>

10 11 12
class LinkAction;
class PDFDoc;

13 14
class QOutputDevPixmap;

15 16
namespace KPDF
{
17 18 19 20 21 22
    /**
     * Widget displaying a pixmap containing a PDF page and Links.
     */
    class PageWidget : public QScrollView
    {
        Q_OBJECT
Laurent Montel's avatar
Laurent Montel committed
23

24
        enum ZoomMode { FitInWindow, FitWidth, FitVisible, FixedFactor };
25

26 27 28 29 30 31
    public:
        PageWidget(QWidget* parent = 0, const char* name = 0);
        ~PageWidget();
        void setPDFDocument(PDFDoc*);
        void setPixelsPerPoint(float);
        /* void setLinks(); */
Laurent Montel's avatar
Laurent Montel committed
32

33 34 35
        void setPage(int pagenum);
        int getPage() const { return m_currentPage; };
        void enableScrollBars( bool b );
36 37 38 39 40
        /**
         * Return true if the top resp. bottom of the page is visible.
         */
        bool atTop()    const;
        bool atBottom() const;
41 42 43 44 45
    public slots:
        void nextPage();
        void previousPage();
        void zoomIn();
        void zoomOut();
46

47
        void updatePixmap();
Laurent Montel's avatar
Laurent Montel committed
48 49 50 51 52 53
        void scrollUp();
        void scrollDown();
        void scrollRight();
        void scrollLeft();
        void scrollBottom();
        void scrollTop();
54 55
        bool readUp();
        bool readDown();
56 57
    signals:
        void linkClicked(LinkAction*);
58 59 60 61
        void ReadUp();
        void ReadDown();
        void ZoomOut();
        void ZoomIn();
62
        void rightClick();
Laurent Montel's avatar
Laurent Montel committed
63
        void urlDropped( const KURL& );
64

65
    protected:
Laurent Montel's avatar
Laurent Montel committed
66
        virtual void keyPressEvent( QKeyEvent* );
67 68 69
        void contentsMousePressEvent(QMouseEvent*);
        void contentsMouseReleaseEvent(QMouseEvent*);
        void contentsMouseMoveEvent(QMouseEvent*);
70
        virtual void wheelEvent( QWheelEvent * );
71
        virtual void drawContents ( QPainter *p, int, int, int, int );
Laurent Montel's avatar
Laurent Montel committed
72 73
        virtual void dragEnterEvent( QDragEnterEvent* );
        virtual void dropEvent( QDropEvent* );
74
    private:
75

76 77
        QOutputDevPixmap * m_outputdev;
        PDFDoc* m_doc;
78

79 80 81
        float   m_ppp; // Pixels per point
        float		m_zoomFactor;
        ZoomMode m_zoomMode;
Laurent Montel's avatar
Laurent Montel committed
82

83
        int m_currentPage;
84
        QPoint   m_dragGrabPos;
85 86
        LinkAction* m_pressedAction;
    };
87 88 89 90 91
}

#endif

// vim:ts=2:sw=2:tw=78:et