pageview.h 4.31 KB
Newer Older
1
/***************************************************************************
2
 *   Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>                  *
3 4
 *   Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es>            *
 *                                                                         *
5 6 7 8 9 10 11
 *   With portions of code from kpdf_pagewidget.h by:                      *
 *     Copyright (C) 2002 by Wilco Greven <greven@kde.org>                 *
 *     Copyright (C) 2003 by Christophe Devriese                           *
 *                           <Christophe.Devriese@student.kuleuven.ac.be>  *
 *     Copyright (C) 2003 by Laurent Montel <montel@kde.org>               *
 *     Copyright (C) 2003 by Kurt Pfeifle <kpfeifle@danka.de>              *
 *                                                                         *
12 13 14 15 16 17
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

18 19
#ifndef _KPDF_PAGEVIEW_H_
#define _KPDF_PAGEVIEW_H_
20

21
#include <qscrollview.h>
22
#include <qvaluevector.h>
23

24
//#include "CharTypes.h"
25
#include "document.h"
Albert Astals Cid's avatar
Albert Astals Cid committed
26

Albert Astals Cid's avatar
Albert Astals Cid committed
27
class KURL;
28
class KActionCollection;
29

30
class PageWidget;
31
class PageViewPrivate;
32
class KToggleAction;
Laurent Montel's avatar
Laurent Montel committed
33

34
/**
35 36
 * @short The main view. Handles zoom and continous mode.. oh, and page
 * @short display of course :-)
37 38
 *
 */
39
class PageView : public QScrollView, public KPDFDocumentObserver
40
{
41
Q_OBJECT
42

43
public:
44 45
    PageView( QWidget *parent, KPDFDocument *document );
    ~PageView();
Laurent Montel's avatar
Laurent Montel committed
46

47 48 49
    // Zoom mode ( last 4 are internally used only! )
    enum ZoomMode { ZoomFixed, ZoomFitWidth, ZoomFitPage, ZoomFitText,
                    ZoomIn, ZoomOut, ZoomRefreshCurrent, ZoomRect };
50
    enum MouseMode { MouseNormal, MouseSelection, MouseEdit };
51

52
    // create actions that interact with this widget
53 54
    void setupActions( KActionCollection * collection );
    void saveSettings();
55 56

    // inherited from KPDFDocumentObserver
Laurent Montel's avatar
Laurent Montel committed
57
    uint observerId() const { return PAGEVIEW_ID; }
58
    void pageSetup( const QValueVector<KPDFPage*> & pages, bool documentChanged );
Enrico Ros's avatar
Enrico Ros committed
59
    void pageSetCurrent( int pageNumber, const QRect & viewport );
60
    void notifyPixmapChanged( int pageNumber );
Laurent Montel's avatar
Laurent Montel committed
61

62
protected:
63 64 65
    void contentsMousePressEvent( QMouseEvent* );
    void contentsMouseReleaseEvent( QMouseEvent* );
    void contentsMouseMoveEvent( QMouseEvent* );
66

67 68
    void keyPressEvent( QKeyEvent* );
    void wheelEvent( QWheelEvent* );
69
    void viewportResizeEvent( QResizeEvent* );
70

71 72
    void dragEnterEvent( QDragEnterEvent* );
    void dropEvent( QDropEvent* );
73

74 75 76 77
signals:
    void urlDropped( const KURL& );
    void rightClick();

78
private slots:
79
    // connected to local actions
80
    void slotZoom();
81 82 83
    void slotZoomIn();
    void slotZoomOut();
    void slotFitToWidthToggled( bool );
84 85
    void slotFitToPageToggled( bool );
    void slotFitToTextToggled( bool );
86
    void slotFitToRectToggled( bool );
87 88 89 90 91
    void slotTwoPagesToggled( bool );
    void slotContinousToggled( bool );
    void slotSetMouseNormal();
    void slotSetMouseSelect();
    void slotSetMouseDraw();
92 93
    void slotScrollUp();
    void slotScrollDown();
94 95 96
    void slotToggleScrollBars( bool on );

    // activated either directly or via QTimer on the viewportResizeEvent
97
    void slotRelayoutPages();
98 99
    // activated either directly or via the contentsMoving(int,int) signal
    void slotRequestVisiblePixmaps( int left = -1, int top = -1 );
100 101
    // activated by the autoscroll timer (Shift+Up/Down keys)
    void slotAutoScoll();
Enrico Ros's avatar
Enrico Ros committed
102

103
private:
104
    // update internal zoom values and end in a slotRelayoutPages();
105
    void updateZoom( ZoomMode newZm );
106
    // update the text on the label using global zoom value or current page's one
107
    void updateZoomText();
108
    // return the widget placed on a certain point or 0 if clicking on empty space
109
    PageWidget * pickPageOnPoint( int x, int y );
110 111 112 113 114 115

    // FIXME REMOVE ME what does atTop() means if I see 4 tiled pages on screen ?
    bool atTop()    const;
    bool atBottom() const;
    void scrollUp();
    void scrollDown();
116
    KToggleAction * md;
117
    // don't want to expose classes in here
118
    class PageViewPrivate * d;
119
};
120

121
#endif