1 /***************************************************************************
2 * Copyright (C) 2004-2005 by Enrico Ros <eros.kde@email.it> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef _PAGEVIEW_UTILS_H_
11 #define _PAGEVIEW_UTILS_H_
17 #include <qtoolbutton.h>
21 #include "core/area.h"
26 class FormWidgetIface
;
35 * @short PageViewItem represents graphically a page into the PageView.
37 * It has methods for settings Item's geometry and other visual properties such
38 * as the individual zoom factor.
43 PageViewItem( const Okular::Page
* page
);
46 const Okular::Page
* page() const;
47 int pageNumber() const;
48 double zoomFactor() const;
49 bool isVisible() const;
50 QHash
<int, FormWidgetIface
*>& formWidgets();
51 QHash
< Okular::Movie
*, VideoWidget
* >& videoWidgets();
53 /* The page is cropped as follows: */
54 const Okular::NormalizedRect
& crop() const;
56 /* Real geometry into which the cropped page is rendered: */
57 const QRect
& croppedGeometry() const;
58 int croppedWidth() const;
59 int croppedHeight() const;
61 /* "Uncropped" geometry:
62 * If the whole page was rendered into the uncropped geometry then the
63 * cropped page would be rendered into the real geometry.
64 * (Hence, uncropped always contains cropped, and they are equal only if
65 * the page is uncropped.) This is just for convenience in calculations.
67 const QRect
& uncroppedGeometry() const;
68 int uncroppedWidth() const;
69 int uncroppedHeight() const;
71 /* Convert absolute geometry coordinates to normalized [0,1] page coordinates: */
72 double absToPageX(double absX
) const;
73 double absToPageY(double absY
) const;
75 void setWHZC( int w
, int h
, double zoom
, const Okular::NormalizedRect
& c
);
76 void moveTo( int x
, int y
);
77 void setVisible( bool visible
);
79 bool setFormWidgetsVisible( bool visible
);
82 const Okular::Page
* m_page
;
86 QRect m_croppedGeometry
;
87 QRect m_uncroppedGeometry
;
88 Okular::NormalizedRect m_crop
;
89 QHash
<int, FormWidgetIface
*> m_formWidgets
;
90 QHash
< Okular::Movie
*, VideoWidget
* > m_videoWidgets
;
95 * @short A widget that displays messages in the top-left corner.
97 * This is a widget with thin border and rounded corners that displays a given
98 * text along as an icon. It's meant to be used for displaying messages to the
99 * user by placing this above other widgets.
101 class PageViewMessage
: public QWidget
104 PageViewMessage( QWidget
* parent
);
106 enum Icon
{ None
, Info
, Warning
, Error
, Find
, Annotation
};
107 void display( const QString
& message
, Icon icon
= Info
, int durationMs
= 4000 );
110 void paintEvent( QPaintEvent
* e
);
111 void mousePressEvent( QMouseEvent
* e
);
121 * @short A widget that displays messages in the top part of the page view.
125 class PageViewTopMessage
: public QWidget
129 PageViewTopMessage( QWidget
* parent
);
131 void setup( const QString
& message
, const KIcon
& icon
= KIcon() );
132 void setIconSize( int size
);
133 void setActionButton( QAction
* action
);
141 QToolButton
* m_button
;
145 struct AnnotationToolItem
148 : id( -1 ), isText( false )
159 class ToolBarButton
: public QToolButton
163 static const int iconSize
= 32;
164 static const int buttonSize
= 40;
166 ToolBarButton( QWidget
* parent
, const AnnotationToolItem
&item
);
167 int buttonID() const { return m_id
; }
168 bool isText() const { return m_isText
; }
176 * @short A widget containing exclusive buttons, that slides in from a side.
178 * This is a shaped widget that slides in from a side of the 'anchor widget'
179 * it's attached to. It can be dragged and docked on {left,top,right,bottom}
180 * sides and contains toggable exclusive buttons.
181 * When a 'tool' of this 'toolBar' is selected, a signal is emitted.
183 class PageViewToolBar
: public QWidget
187 PageViewToolBar( QWidget
* parent
, QWidget
* anchorWidget
);
190 // animated widget controls
191 enum Side
{ Left
= 0, Top
= 1, Right
= 2, Bottom
= 3 };
193 void setItems( const QLinkedList
<AnnotationToolItem
> &items
);
194 void setSide( Side side
);
196 void showAndAnimate();
197 void hideAndDestroy();
199 void selectButton( int id
);
201 void setToolsEnabled( bool on
);
202 void setTextToolsEnabled( bool on
);
207 // the tool 'toolID' has been selected
208 void toolSelected( int toolID
);
209 // orientation has been changed
210 void orientationChanged( int side
);
213 // handle widget events { anchor_resize, paint, animation, drag }
214 bool eventFilter( QObject
* o
, QEvent
* e
);
215 void paintEvent( QPaintEvent
* );
216 void mousePressEvent( QMouseEvent
* e
);
217 void mouseMoveEvent( QMouseEvent
* e
);
218 void mouseReleaseEvent( QMouseEvent
* e
);
222 friend class ToolBarPrivate
;
223 class ToolBarPrivate
* d
;
227 void slotButtonClicked();