summaryrefslogtreecommitdiffstats
path: root/kpdf/ui/pageview.h
blob: 267c58f5c23829f81f36392facfafb0e0659f8a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/***************************************************************************
 *   Copyright (C) 2004 by Enrico Ros <eros.kde@email.it>                  *
 *   Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es>            *
 *                                                                         *
 *   With portions of code from kpdf/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>              *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/
// This file follows coding style described in tdebase/kicker/HACKING

#ifndef _KPDF_PAGEVIEW_H_
#define _KPDF_PAGEVIEW_H_

#include <tqscrollview.h>
#include <tqvaluevector.h>
#include "core/observer.h"

class KURL;
class TDEActionCollection;

class KPDFDocument;
class PageViewItem;
class PageViewPrivate;
class PageViewTip;

/**
 * @short The main view. Handles zoom and continuous mode.. oh, and page
 * @short display of course :-)
 * ...
 */
class PageView : public TQScrollView, public DocumentObserver
{
    Q_OBJECT
  

        friend class PageViewTip;

    public:
        PageView( TQWidget *parent, KPDFDocument *document );
        ~PageView();

        // Zoom mode ( last 4 are internally used only! )
        enum ZoomMode { ZoomFixed, ZoomFitWidth, ZoomFitPage, ZoomFitText,
                        ZoomIn, ZoomOut, ZoomRefreshCurrent };
        enum MouseMode { MouseNormal, MouseZoom, MouseSelect, MouseEdit };

        // create actions that interact with this widget
        void setupActions( TDEActionCollection * collection );

        // used from RMB menu
        bool canFitPageWidth();
        void fitPageWidth( int page );

        // inherited from DocumentObserver
        uint observerId() const { return PAGEVIEW_ID; }
        void notifySetup( const TQValueVector< KPDFPage * > & pages, bool documentChanged );
        void notifyViewportChanged( bool smoothMove );
        void notifyPageChanged( int pageNumber, int changedFlags );
        void notifyContentsCleared( int changedFlags );
        bool canUnloadPixmap( int pageNum );

        void showText( const TQString &text, int ms );

    signals:
        void urlDropped( const KURL& );
        void rightClick( const KPDFPage *, const TQPoint & );

    protected:
        // main draw loop, draws pageViews on viewport
        void viewportPaintEvent( TQPaintEvent * pe );
        void viewportResizeEvent( TQResizeEvent* );

        // mouse / keyboard events
        void keyPressEvent( TQKeyEvent* );
        void imEndEvent( TQIMEvent * );
        void contentsMouseMoveEvent( TQMouseEvent* );
        void contentsMousePressEvent( TQMouseEvent* );
        void contentsMouseReleaseEvent( TQMouseEvent* );
        void wheelEvent( TQWheelEvent* );

        // drag and drop related events
        void dragEnterEvent( TQDragEnterEvent* );
        void dropEvent( TQDropEvent* );

    private:
        // draw items on the opened qpainter
        void paintItems( TQPainter * p, const TQRect & clipRect );
        // update item width and height using current zoom parameters
        void updateItemSize( PageViewItem * item, int columnWidth, int rowHeight );
        // return the widget placed on a certain point or 0 if clicking on empty space
        PageViewItem * pickItemOnPoint( int x, int y );
        // start / modify / clear selection rectangle
        void selectionStart( int x, int y, const TQColor & color, bool aboveAll = false );
        void selectionEndPoint( int x, int y );
        void selectionClear();
        // update internal zoom values and end in a slotRelayoutPages();
        void updateZoom( ZoomMode newZm );
        // update the text on the label using global zoom value or current page's one
        void updateZoomText();
        // updates cursor
        void updateCursor( const TQPoint &p );
        // does the type ahead search
        void doTypeAheadSearch();

        // don't want to expose classes in here
        class PageViewPrivate * d;

    private slots:
        // activated either directly or via TQTimer on the viewportResizeEvent
        void slotRelayoutPages();
        // activated either directly or via the contentsMoving(int,int) signal
        void slotRequestVisiblePixmaps( int left = -1, int top = -1 );
        // activated by the viewport move timer
        void slotMoveViewport();
        // activated by the autoscroll timer (Shift+Up/Down keys)
        void slotAutoScoll();
        // activated by the dragScroll timer
        void slotDragScroll();
        // type-ahead find timeout
        void findAheadStop();
        // show the welcome message
        void slotShowWelcome();

        // connected to local actions (toolbar, menu, ..)
        void slotZoom();
        void slotZoomIn();
        void slotZoomOut();
        void slotFitToWidthToggled( bool );
        void slotFitToPageToggled( bool );
        void slotFitToTextToggled( bool );
        void slotRotateRight();
        void slotRotateLeft();
        void slotTwoPagesToggled( bool );
        void slotContinuousToggled( bool );
	void slotCoverPageToggled( bool );
        void slotSetMouseNormal();
        void slotSetMouseZoom();
        void slotSetMouseSelect();
        void slotSetMouseDraw();
        void slotScrollUp();
        void slotScrollDown();
};

#endif