2004-10-20 16:41:13 +00:00
|
|
|
/***************************************************************************
|
2005-02-12 17:42:54 +00:00
|
|
|
* Copyright (C) 2004-2005 by Enrico Ros <eros.kde@email.it> *
|
2004-10-20 16:41:13 +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. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2005-02-12 17:42:54 +00:00
|
|
|
#ifndef _PAGEVIEW_UTILS_H_
|
|
|
|
#define _PAGEVIEW_UTILS_H_
|
2004-10-20 16:41:13 +00:00
|
|
|
|
|
|
|
#include <qwidget.h>
|
|
|
|
#include <qpixmap.h>
|
|
|
|
#include <qrect.h>
|
|
|
|
|
|
|
|
class QTimer;
|
2006-09-21 08:45:36 +00:00
|
|
|
|
|
|
|
namespace Okular {
|
|
|
|
class Page;
|
|
|
|
}
|
2004-10-30 20:54:48 +00:00
|
|
|
|
2004-11-03 17:35:48 +00:00
|
|
|
/**
|
2006-09-21 08:45:36 +00:00
|
|
|
* @short PageViewItem represents graphically a page into the PageView.
|
2004-11-03 17:35:48 +00:00
|
|
|
*
|
|
|
|
* It has methods for settings Item's geometry and other visual properties such
|
|
|
|
* as the individual zoom factor.
|
|
|
|
*/
|
2004-10-30 20:54:48 +00:00
|
|
|
class PageViewItem
|
|
|
|
{
|
|
|
|
public:
|
2006-09-21 08:45:36 +00:00
|
|
|
PageViewItem( const Okular::Page * page );
|
2004-10-30 20:54:48 +00:00
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
const Okular::Page * page() const;
|
2004-11-03 17:35:48 +00:00
|
|
|
int pageNumber() const;
|
|
|
|
const QRect& geometry() const;
|
|
|
|
int width() const;
|
|
|
|
int height() const;
|
|
|
|
double zoomFactor() const;
|
2004-10-30 20:54:48 +00:00
|
|
|
|
2004-11-03 17:35:48 +00:00
|
|
|
void setGeometry( int x, int y, int width, int height );
|
|
|
|
void setWHZ( int w, int h, double zoom );
|
|
|
|
void moveTo( int x, int y );
|
2006-04-23 12:44:10 +00:00
|
|
|
void invalidate();
|
2004-10-30 20:54:48 +00:00
|
|
|
|
|
|
|
private:
|
2006-09-21 08:45:36 +00:00
|
|
|
const Okular::Page * m_page;
|
2004-10-30 20:54:48 +00:00
|
|
|
double m_zoomFactor;
|
|
|
|
QRect m_geometry;
|
|
|
|
};
|
|
|
|
|
2004-10-20 16:41:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @short A widget that displays messages in the top-left corner.
|
2005-02-12 17:42:54 +00:00
|
|
|
*
|
|
|
|
* This is a widget with thin border and rounded corners that displays a given
|
|
|
|
* text along as an icon. It's meant to be used for displaying messages to the
|
|
|
|
* user by placing this above other widgets.
|
2004-10-20 16:41:13 +00:00
|
|
|
*/
|
|
|
|
class PageViewMessage : public QWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PageViewMessage( QWidget * parent );
|
|
|
|
|
2005-02-18 18:24:45 +00:00
|
|
|
enum Icon { None, Info, Warning, Error, Find, Annotation };
|
2004-11-03 17:35:48 +00:00
|
|
|
void display( const QString & message, Icon icon = Info, int durationMs = 4000 );
|
2004-10-20 16:41:13 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent( QPaintEvent * e );
|
2004-10-31 17:04:04 +00:00
|
|
|
void mousePressEvent( QMouseEvent * e );
|
2004-10-20 16:41:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QPixmap m_pixmap;
|
|
|
|
QTimer * m_timer;
|
|
|
|
};
|
|
|
|
|
2005-02-26 18:05:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @short A widget containing exclusive buttons, that slides in from a side.
|
|
|
|
*
|
|
|
|
* This is a shaped widget that slides in from a side of the 'anchor widget'
|
|
|
|
* it's attached to. It can be dragged and docked on {left,top,right,bottom}
|
|
|
|
* sides and contains toggable exclusive buttons.
|
|
|
|
* When a 'tool' of this 'toolBar' is selected, a signal is emitted.
|
|
|
|
*/
|
|
|
|
struct ToolBarItem // FIXME TEMP: MOVE OUT OF HERE!
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
QString text;
|
|
|
|
QString pixmap;
|
2005-03-04 23:06:24 +00:00
|
|
|
QString shortcut;
|
2005-02-26 18:05:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PageViewToolBar : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
PageViewToolBar( QWidget * parent, QWidget * anchorWidget );
|
|
|
|
~PageViewToolBar();
|
|
|
|
|
|
|
|
// animated widget controls
|
|
|
|
enum Side { Left = 0, Top = 1, Right = 2, Bottom = 3 };
|
2006-03-23 20:43:38 +00:00
|
|
|
void showItems( Side side, const QLinkedList<ToolBarItem> & items );
|
2005-02-26 18:05:01 +00:00
|
|
|
void hideAndDestroy();
|
|
|
|
|
2005-03-04 23:06:24 +00:00
|
|
|
// query properties
|
|
|
|
|
2005-02-26 18:05:01 +00:00
|
|
|
signals:
|
|
|
|
// the tool 'toolID' has been selected
|
|
|
|
void toolSelected( int toolID );
|
2005-03-04 23:06:24 +00:00
|
|
|
// orientation has been changed
|
|
|
|
void orientationChanged( int side );
|
2005-02-26 18:05:01 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// handle widget events { anchor_resize, paint, animation, drag }
|
|
|
|
bool eventFilter( QObject * o, QEvent * e );
|
|
|
|
void paintEvent( QPaintEvent * );
|
|
|
|
void mousePressEvent( QMouseEvent * e );
|
|
|
|
void mouseMoveEvent( QMouseEvent * e );
|
|
|
|
void mouseReleaseEvent( QMouseEvent * e );
|
|
|
|
|
|
|
|
private:
|
|
|
|
// rebuild contents and reposition then widget
|
|
|
|
void buildToolBar();
|
|
|
|
void reposition();
|
|
|
|
// compute the visible and hidden positions along current side
|
|
|
|
QPoint getInnerPoint();
|
|
|
|
QPoint getOuterPoint();
|
|
|
|
|
|
|
|
// private variables
|
|
|
|
class ToolBarPrivate * d;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void slotAnimate();
|
|
|
|
void slotButtonClicked();
|
|
|
|
};
|
|
|
|
|
2004-10-20 16:41:13 +00:00
|
|
|
#endif
|