2004-08-26 21:17:24 +00:00
|
|
|
/***************************************************************************
|
2004-09-27 21:36:25 +00:00
|
|
|
* Copyright (C) 2004 by Enrico Ros <eros.kde@email.it> *
|
2004-08-26 21:17:24 +00:00
|
|
|
* Copyright (C) 2004 by Albert Astals Cid <tsdgeos@terra.es> *
|
|
|
|
* *
|
2005-01-02 14:29:37 +00:00
|
|
|
* With portions of code from kpdf/kpdf_pagewidget.h by: *
|
2004-09-27 21:36:25 +00:00
|
|
|
* 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> *
|
|
|
|
* *
|
2004-08-26 21:17:24 +00:00
|
|
|
* 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. *
|
|
|
|
***************************************************************************/
|
2004-10-29 21:52:06 +00:00
|
|
|
// This file follows coding style described in kdebase/kicker/HACKING
|
2004-08-26 21:17:24 +00:00
|
|
|
|
2004-09-23 17:16:04 +00:00
|
|
|
#ifndef _KPDF_PAGEVIEW_H_
|
|
|
|
#define _KPDF_PAGEVIEW_H_
|
2002-08-30 09:14:01 +00:00
|
|
|
|
2003-07-01 06:08:27 +00:00
|
|
|
#include <qscrollview.h>
|
2004-09-12 23:19:03 +00:00
|
|
|
#include <qvaluevector.h>
|
2005-01-02 14:55:14 +00:00
|
|
|
#include "core/observer.h"
|
2004-08-28 09:27:38 +00:00
|
|
|
|
2004-09-04 22:52:25 +00:00
|
|
|
class KURL;
|
2004-09-11 15:59:32 +00:00
|
|
|
class KActionCollection;
|
2004-09-04 22:28:14 +00:00
|
|
|
|
2005-01-02 14:55:14 +00:00
|
|
|
class KPDFDocument;
|
2004-10-30 20:54:48 +00:00
|
|
|
class PageViewItem;
|
2004-09-26 23:39:39 +00:00
|
|
|
class PageViewPrivate;
|
2003-09-14 14:32:05 +00:00
|
|
|
|
2004-09-26 23:39:39 +00:00
|
|
|
/**
|
2005-03-05 15:59:15 +00:00
|
|
|
* @short The main view. Handles zoom and continuous mode.. oh, and page
|
2004-10-20 16:41:13 +00:00
|
|
|
* @short display of course :-)
|
2004-10-29 21:52:06 +00:00
|
|
|
* ...
|
2004-09-26 23:39:39 +00:00
|
|
|
*/
|
2005-01-09 23:37:07 +00:00
|
|
|
class PageView : public QScrollView, public DocumentObserver
|
2004-09-12 23:19:03 +00:00
|
|
|
{
|
2004-10-29 21:52:06 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
PageView( QWidget *parent, KPDFDocument *document );
|
|
|
|
~PageView();
|
|
|
|
|
|
|
|
// Zoom mode ( last 4 are internally used only! )
|
2005-06-24 16:43:19 +00:00
|
|
|
enum ZoomMode { ZoomFixed = 0, ZoomFitWidth = 1, ZoomFitPage = 2, ZoomFitText,
|
2004-11-03 17:35:48 +00:00
|
|
|
ZoomIn, ZoomOut, ZoomRefreshCurrent };
|
2005-02-18 18:24:45 +00:00
|
|
|
enum MouseMode { MouseNormal, MouseZoom, MouseSelect };
|
2004-10-29 21:52:06 +00:00
|
|
|
|
|
|
|
// create actions that interact with this widget
|
|
|
|
void setupActions( KActionCollection * collection );
|
|
|
|
|
2005-03-04 23:06:24 +00:00
|
|
|
// misc methods (from RMB menu/children)
|
2005-01-10 13:43:44 +00:00
|
|
|
bool canFitPageWidth();
|
2005-01-09 23:37:07 +00:00
|
|
|
void fitPageWidth( int page );
|
2005-03-04 23:06:24 +00:00
|
|
|
void displayMessage( const QString & message );
|
2004-12-04 23:23:18 +00:00
|
|
|
|
2005-01-09 23:37:07 +00:00
|
|
|
// inherited from DocumentObserver
|
2004-10-29 21:52:06 +00:00
|
|
|
uint observerId() const { return PAGEVIEW_ID; }
|
2005-01-09 23:37:07 +00:00
|
|
|
void notifySetup( const QValueVector< KPDFPage * > & pages, bool documentChanged );
|
2005-02-01 18:23:55 +00:00
|
|
|
void notifyViewportChanged( bool smoothMove );
|
2005-01-09 23:37:07 +00:00
|
|
|
void notifyPageChanged( int pageNumber, int changedFlags );
|
|
|
|
void notifyContentsCleared( int changedFlags );
|
2004-12-21 12:38:52 +00:00
|
|
|
bool canUnloadPixmap( int pageNum );
|
2004-10-29 21:52:06 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void urlDropped( const KURL& );
|
2005-01-26 10:42:07 +00:00
|
|
|
void rightClick( const KPDFPage *, const QPoint & );
|
2004-10-29 21:52:06 +00:00
|
|
|
|
|
|
|
protected:
|
2005-02-12 17:42:54 +00:00
|
|
|
// viewport events
|
2004-10-31 12:43:13 +00:00
|
|
|
void viewportPaintEvent( QPaintEvent * pe );
|
2004-10-29 21:52:06 +00:00
|
|
|
void viewportResizeEvent( QResizeEvent* );
|
|
|
|
|
|
|
|
// mouse / keyboard events
|
|
|
|
void keyPressEvent( QKeyEvent* );
|
|
|
|
void contentsMouseMoveEvent( QMouseEvent* );
|
|
|
|
void contentsMousePressEvent( QMouseEvent* );
|
|
|
|
void contentsMouseReleaseEvent( QMouseEvent* );
|
|
|
|
void wheelEvent( QWheelEvent* );
|
|
|
|
|
|
|
|
// drag and drop related events
|
|
|
|
void dragEnterEvent( QDragEnterEvent* );
|
|
|
|
void dropEvent( QDropEvent* );
|
|
|
|
|
|
|
|
private:
|
2005-04-01 16:24:11 +00:00
|
|
|
// draw background and items on the opened qpainter
|
|
|
|
void drawDocumentOnPainter( const QRect & pageViewRect, QPainter * p );
|
2004-10-30 20:54:48 +00:00
|
|
|
// 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 );
|
2004-11-03 17:35:48 +00:00
|
|
|
// start / modify / clear selection rectangle
|
2005-01-29 12:32:59 +00:00
|
|
|
void selectionStart( int x, int y, const QColor & color, bool aboveAll = false );
|
2004-11-03 17:35:48 +00:00
|
|
|
void selectionEndPoint( int x, int y );
|
|
|
|
void selectionClear();
|
2004-10-29 21:52:06 +00:00
|
|
|
// 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();
|
2004-12-26 21:20:17 +00:00
|
|
|
// updates cursor
|
|
|
|
void updateCursor( const QPoint &p );
|
2005-01-28 17:21:28 +00:00
|
|
|
|
2004-10-29 21:52:06 +00:00
|
|
|
// don't want to expose classes in here
|
|
|
|
class PageViewPrivate * d;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
// activated either directly or via QTimer on the viewportResizeEvent
|
|
|
|
void slotRelayoutPages();
|
|
|
|
// activated either directly or via the contentsMoving(int,int) signal
|
|
|
|
void slotRequestVisiblePixmaps( int left = -1, int top = -1 );
|
2005-02-01 18:24:16 +00:00
|
|
|
// activated by the viewport move timer
|
|
|
|
void slotMoveViewport();
|
2004-10-29 21:52:06 +00:00
|
|
|
// activated by the autoscroll timer (Shift+Up/Down keys)
|
|
|
|
void slotAutoScoll();
|
2005-01-28 17:21:28 +00:00
|
|
|
// type-ahead find timeout
|
2005-02-18 18:24:45 +00:00
|
|
|
void slotStopFindAhead();
|
2005-01-28 17:21:28 +00:00
|
|
|
|
2005-02-01 18:24:16 +00:00
|
|
|
// connected to local actions (toolbar, menu, ..)
|
2004-10-29 21:52:06 +00:00
|
|
|
void slotZoom();
|
|
|
|
void slotZoomIn();
|
|
|
|
void slotZoomOut();
|
|
|
|
void slotFitToWidthToggled( bool );
|
|
|
|
void slotFitToPageToggled( bool );
|
|
|
|
void slotFitToTextToggled( bool );
|
|
|
|
void slotTwoPagesToggled( bool );
|
2005-03-05 15:59:15 +00:00
|
|
|
void slotContinuousToggled( bool );
|
2004-10-29 21:52:06 +00:00
|
|
|
void slotSetMouseNormal();
|
2004-11-03 17:35:48 +00:00
|
|
|
void slotSetMouseZoom();
|
2004-11-16 17:36:02 +00:00
|
|
|
void slotSetMouseSelect();
|
2005-03-04 23:06:24 +00:00
|
|
|
void slotToggleAnnotator( bool );
|
2004-10-29 21:52:06 +00:00
|
|
|
void slotScrollUp();
|
|
|
|
void slotScrollDown();
|
2004-09-12 23:19:03 +00:00
|
|
|
};
|
2004-08-26 23:25:52 +00:00
|
|
|
|
2002-08-30 09:14:01 +00:00
|
|
|
#endif
|