diff --git a/core/Makefile.am b/core/Makefile.am index a21198b3a..6f1360f2f 100644 --- a/core/Makefile.am +++ b/core/Makefile.am @@ -5,8 +5,7 @@ INCLUDES = -I$(srcdir)/generator_pdf -I$(srcdir)/.. -I$(srcdir)/../xpdf -I$(srcd METASOURCES = AUTO libkpdfcore_la_LIBADD = ./generator_pdf/libgeneratorpdf.la -libkpdfcore_la_SOURCES = page.cpp document.cpp link.cpp annotations.cpp \ - pagetransition.cpp +libkpdfcore_la_SOURCES = document.cpp link.cpp page.cpp pagetransition.cpp noinst_LTLIBRARIES = libkpdfcore.la diff --git a/core/annotations.cpp b/core/annotations.cpp deleted file mode 100644 index 706f8ce25..000000000 --- a/core/annotations.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Enrico Ros * - * * - * 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. * - ***************************************************************************/ - -// qt / kde includes -#include -#include -#include -#include - -// local includes -#include "annotations.h" - -Annotation::Annotation() - : NormalizedRect() -{ -} - -Annotation::~Annotation() -{ -} -/* -void mousePressEvent( double x, double y, Qt::ButtonState b ); -void mouseMoveEvent( double x, double y, Qt::ButtonState b ); -void mouseReleaseEvent( double x, double y, Qt::ButtonState b ); -void overlayPaint( QPainter * painter ); -void finalPaint( QPixmap * pixmap, MouseState mouseState ); -*/ diff --git a/core/annotations.h b/core/annotations.h deleted file mode 100644 index 6889c1db7..000000000 --- a/core/annotations.h +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Enrico Ros * - * * - * 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. * - ***************************************************************************/ - -#ifndef _KPDF_ANNOTATIONS_H_ -#define _KPDF_ANNOTATIONS_H_ - -#include -#include -#include "page.h" - -/** - * @short Base options for an annotation (highlight, stamp, boxes, ..). - * - * From PDFreferece v.1.6: - * An annotation associates an object such as a note, sound, or movie with a - * location on a page of a PDF document ... - * - * Inherited classes must modify protected variables as appropriate. - * Other fields in pdf reference we dropped here: - * -subtype, rectangle(we are a rect), border stuff - */ -class Annotation : public NormalizedRect -{ - public: - Annotation(); - virtual ~Annotation(); - - enum State { Creating, Modifying, Closed, Opened }; - enum MouseState { Normal, Hovered, Pressed }; - enum Flags { Hidden, NoOpenable, Print, Locked, ReadOnly }; - - State state() const { return m_state; } - const QString & text() const { return m_text; } - const QString & uniqueName() const { return m_uniqueName; } - const QDateTime & creationDate() const { return m_creationDate; } - const QDateTime & modifyDate() const { return m_modifyDate; } - const QColor & baseColor() const { return m_baseColor; } - - // event handlers (must update state) - virtual void mousePressEvent( double x, double y, Qt::ButtonState b ) = 0; - virtual void mouseMoveEvent( double x, double y, Qt::ButtonState b ) = 0; - virtual void mouseReleaseEvent( double x, double y, Qt::ButtonState b ) = 0; - - // paint roughtly over a cleared area - virtual void overlayPaint( QPainter * painter ) = 0; - // cool-paint over a pixmap - virtual void finalPaint( QPixmap * pixmap, MouseState mouseState ) = 0; - - protected: - State m_state; - MouseState m_mouseState; - QString m_text; - QString m_uniqueName; - QDateTime m_modifyDate; - QColor m_baseColor; - - private: - QDateTime m_creationDate; -}; - -class TextAnnotation : public Annotation -{ - //Text (post-it like) - //FreeText (direct on page) - enum Type { InPlace, Popup }; -}; - -class LineAnnotation : public Annotation -{ - //Line (arrows too) -}; - -class GeomAnnotation : public Annotation -{ - //Square, Circle -}; - -class PathAnnotation : public Annotation -{ - //Ink (one or more disjoints paths) - //Polygon, PolyLine -}; - -class HighlightAnnotation : public Annotation -{ - //Highlight, Underline, Squiggly, StrikeOut, BLOCK - enum BrushHor { Horizontal, Vertical }; -}; - -class StampAnnotation : public Annotation -{ - // (14 default symbols + ours) -}; - -class MediaAnnotation : public Annotation -{ - //FileAttachment, Sound, Movie - enum Type { FileAttachment, Sound, Movie }; -}; - -#endif diff --git a/part.rc b/part.rc index 529618cee..d7824af1e 100644 --- a/part.rc +++ b/part.rc @@ -1,5 +1,5 @@ - + &File @@ -61,6 +61,5 @@ - diff --git a/ui/Makefile.am b/ui/Makefile.am index bbbbda359..5cbc6ba39 100644 --- a/ui/Makefile.am +++ b/ui/Makefile.am @@ -1,13 +1,10 @@ -SUBDIRS = icons - INCLUDES = -I$(srcdir)/.. -I$(top_builddir)/kpdf $(all_includes) METASOURCES = AUTO libkpdfui_la_SOURCES = pagepainter.cpp pageview.cpp pageviewutils.cpp \ - pageviewtoolbox.cpp minibar.cpp thumbnaillist.cpp \ - searchwidget.cpp toc.cpp propertiesdialog.cpp \ - presentationwidget.cpp + minibar.cpp thumbnaillist.cpp searchwidget.cpp \ + toc.cpp propertiesdialog.cpp presentationwidget.cpp noinst_LTLIBRARIES = libkpdfui.la diff --git a/ui/icons/Makefile.am b/ui/icons/Makefile.am deleted file mode 100644 index 94e295c2d..000000000 --- a/ui/icons/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -icons_DATA = highlight_green.png highlight_orange.png highlight_pink.png \ - highlight_yellow.png pencil.png pinnote.png -iconsdir = $(kde_datadir)/kpdf/pics diff --git a/ui/icons/highlight_green.png b/ui/icons/highlight_green.png deleted file mode 100644 index ebdb24888..000000000 Binary files a/ui/icons/highlight_green.png and /dev/null differ diff --git a/ui/icons/highlight_orange.png b/ui/icons/highlight_orange.png deleted file mode 100644 index 951904d1a..000000000 Binary files a/ui/icons/highlight_orange.png and /dev/null differ diff --git a/ui/icons/highlight_pink.png b/ui/icons/highlight_pink.png deleted file mode 100644 index d12146c69..000000000 Binary files a/ui/icons/highlight_pink.png and /dev/null differ diff --git a/ui/icons/highlight_yellow.png b/ui/icons/highlight_yellow.png deleted file mode 100644 index 413098bb7..000000000 Binary files a/ui/icons/highlight_yellow.png and /dev/null differ diff --git a/ui/icons/pencil.png b/ui/icons/pencil.png deleted file mode 100644 index 9ce6a8553..000000000 Binary files a/ui/icons/pencil.png and /dev/null differ diff --git a/ui/icons/pinnote.png b/ui/icons/pinnote.png deleted file mode 100644 index 0a9d20908..000000000 Binary files a/ui/icons/pinnote.png and /dev/null differ diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 694fab3a6..debf7024d 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -44,7 +44,6 @@ // local includes #include "pageview.h" #include "pageviewutils.h" -#include "pageviewtoolbox.h" #include "pagepainter.h" #include "core/document.h" #include "core/page.h" @@ -95,7 +94,6 @@ public: bool blockViewport; // prevents changes to viewport bool blockPixmapsRequest; // prevent pixmap requests PageViewMessage * messageWindow; // in pageviewutils.h - PageViewEditTools * editToolsWindow;// in pageviewtoolbox.h // actions KToggleAction * aMouseNormal; @@ -144,7 +142,6 @@ PageView::PageView( QWidget *parent, KPDFDocument *document ) d->blockViewport = false; d->blockPixmapsRequest = false; d->messageWindow = new PageViewMessage(this); - d->editToolsWindow = 0; d->aPrevAction = 0; // widget setup: setup focus, accept drops and track mouse @@ -216,8 +213,9 @@ void PageView::setupActions( KActionCollection * ac ) d->aMouseSelect = new KRadioAction( i18n("&Select"), "frame_edit", 0, this, SLOT( slotSetMouseSelect() ), ac, "mouse_select" ); d->aMouseSelect->setExclusiveGroup( "MouseType" ); - d->aMouseEdit = new KRadioAction( i18n("&Review"), "pencil", 0, this, SLOT( slotSetMouseDraw() ), ac, "mouse_edit" ); + d->aMouseEdit = new KRadioAction( i18n("Draw"), "edit", 0, this, SLOT( slotSetMouseDraw() ), ac, "mouse_draw" ); d->aMouseEdit->setExclusiveGroup("MouseType"); + d->aMouseEdit->setEnabled( false ); // implement feature before removing this line // Other actions KAction * su = new KAction( i18n("Scroll Up"), 0, this, SLOT( slotScrollUp() ), ac, "view_scroll_up" ); @@ -541,18 +539,12 @@ void PageView::viewportPaintEvent( QPaintEvent * pe ) void PageView::viewportResizeEvent( QResizeEvent * ) { // start a timer that will refresh the pixmap after 0.5s - if ( !d->items.isEmpty() ) + if ( !d->delayResizeTimer ) { - if ( !d->delayResizeTimer ) - { - d->delayResizeTimer = new QTimer( this ); - connect( d->delayResizeTimer, SIGNAL( timeout() ), this, SLOT( slotRelayoutPages() ) ); - } - d->delayResizeTimer->start( 333, true ); + d->delayResizeTimer = new QTimer( this ); + connect( d->delayResizeTimer, SIGNAL( timeout() ), this, SLOT( slotRelayoutPages() ) ); } - // update geometry of tools slider widget (if any) - if ( d->editToolsWindow ) - d->editToolsWindow->anchorChanged(); + d->delayResizeTimer->start( 333, true ); } void PageView::keyPressEvent( QKeyEvent * e ) @@ -1869,52 +1861,26 @@ void PageView::slotContinousToggled( bool on ) void PageView::slotSetMouseNormal() { d->mouseMode = MouseNormal; - // hide the messageWindow d->messageWindow->hide(); - // hide the 'tools overlay' if present - if ( d->editToolsWindow ) - { - d->editToolsWindow->hideAndDestroy(); - d->editToolsWindow = 0; - } } void PageView::slotSetMouseZoom() { d->mouseMode = MouseZoom; - // change the text in messageWindow (and show it if hidden) d->messageWindow->display( i18n( "Select zooming area. Right-click to zoom out." ), PageViewMessage::Info, -1 ); - // hide the 'tools overlay' if present - if ( d->editToolsWindow ) - { - d->editToolsWindow->hideAndDestroy(); - d->editToolsWindow = 0; - } } void PageView::slotSetMouseSelect() { d->mouseMode = MouseSelect; - // change the text in messageWindow (and show it if hidden) d->messageWindow->display( i18n( "Draw a rectangle around the text/graphics to copy." ), PageViewMessage::Info, -1 ); - // hide the 'tools overlay' if present - if ( d->editToolsWindow ) - { - d->editToolsWindow->hideAndDestroy(); - d->editToolsWindow = 0; - } } void PageView::slotSetMouseDraw() { d->mouseMode = MouseEdit; - // hide the messageWindow + d->aMouseEdit->setChecked( true ); d->messageWindow->hide(); - // reuse a previous instance if present or create a new one - if ( d->editToolsWindow ) - d->editToolsWindow->show(); - else - d->editToolsWindow = new PageViewEditTools( this, viewport() ); } void PageView::slotScrollUp() diff --git a/ui/pageview.h b/ui/pageview.h index 71ef41ff8..15d334174 100644 --- a/ui/pageview.h +++ b/ui/pageview.h @@ -68,7 +68,7 @@ class PageView : public QScrollView, public DocumentObserver void rightClick( const KPDFPage *, const QPoint & ); protected: - // viewport events + // main draw loop, draws pageViews on viewport void viewportPaintEvent( QPaintEvent * pe ); void viewportResizeEvent( QResizeEvent* ); diff --git a/ui/pageviewtoolbox.cpp b/ui/pageviewtoolbox.cpp deleted file mode 100644 index 5c30caa80..000000000 --- a/ui/pageviewtoolbox.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Enrico Ros * - * * - * 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. * - ***************************************************************************/ - -// qt/kde includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// system includes -#include - -// local includes -#include "pageviewtoolbox.h" -//#include "conf/settings.h" - -/** ToolboxButton **/ - -static const int ToolboxButtonIcon = 32; -static const int ToolboxButtonSize = 40; - -// a flat button that enlights on hover and has an ID -class ToolboxButton : public QPushButton -{ - public: - ToolboxButton( QWidget * parent, const ToolboxItem & item, const QPixmap & backPixmap ); - int toolboxID() const; - - protected: - void mouseMoveEvent( QMouseEvent * e ); - void mouseReleaseEvent( QMouseEvent * e ); - void paintEvent( QPaintEvent * e ); - - private: - int m_id; - bool m_hovering; - const QPixmap & m_background; -}; - -ToolboxButton::ToolboxButton( QWidget * parent, const ToolboxItem & item, const QPixmap & pix ) - : QPushButton( parent ), m_id( item.id ), m_hovering( false ), m_background( pix ) -{ - setMouseTracking( true ); - setToggleButton( true ); - resize( ToolboxButtonSize, ToolboxButtonSize ); - setPixmap( DesktopIcon( item.pixmap, ToolboxButtonIcon ) ); - QToolTip::add( this, item.text ); - setWFlags( Qt::WNoAutoErase ); -#if KDE_IS_VERSION(3,3,90) - KAcceleratorManager::setNoAccel( this ); -#endif -} - -int ToolboxButton::toolboxID() const -{ - return m_id; -} - -void ToolboxButton::mouseMoveEvent( QMouseEvent * e ) -{ - // check for mouse hovering - const QRect myGeom( 0,0, width(), height() ); - bool hover = myGeom.contains( e->pos() ); - - // if hover state changed update gfx - if ( m_hovering != hover ) - { - m_hovering = hover; - update(); - } -} - -void ToolboxButton::mouseReleaseEvent( QMouseEvent * e ) -{ - // call default handler - QPushButton::mouseReleaseEvent( e ); - - // reset hover state when clicking - m_hovering = false; - update(); -} - -void ToolboxButton::paintEvent( QPaintEvent * e ) -{ - // always not hovering in disabled state - if ( !isEnabled() ) - m_hovering = false; - - // paint button in different flavours - if ( isOn() || m_hovering ) - { - // if the button is pressed or we're hovering it, use QPushButton style - QPushButton::paintEvent( e ); - } - else - { - // else draw button's pixmap over the parent's background (fake transparency) - QPainter p( this ); - QRect backRect = e->rect(); - backRect.moveBy( x(), y() ); - p.drawPixmap( e->rect().topLeft(), m_background, backRect ); - drawButtonLabel( &p ); - } -} - -/** PageViewToolbox **/ - -static const int ToolboxGridSize = 40; - -PageViewToolbox::PageViewToolbox( QWidget * parent, QWidget * anchorWidget, bool vertical ) - : QWidget( parent, "", Qt::WNoAutoErase ), m_anchor( anchorWidget ), - m_vertical( vertical ), m_timerID( 0 ), m_hiding( false ) -{ -} - -void PageViewToolbox::setItems( const QValueList & items ) -{ -#ifndef NDEBUG - if ( !m_buttons.isEmpty() ) - kdDebug() << "PageViewToolbox: adding items over existing ones" << endl; -#endif - QValueList::const_iterator it = items.begin(), end = items.end(); - for ( ; it != end; ++it ) - { - ToolboxButton * button = new ToolboxButton( this, *it, m_pixmap ); - connect( button, SIGNAL( clicked() ), this, SLOT( slotButtonClicked() ) ); - m_buttons.append( button ); - } -} - -void PageViewToolbox::show() -{ - // rebuild pixmap and mask - buildGfx(); - QWidget::show(); - - // set scroll parameters - m_hiding = false; - m_currentPosition = getStartPoint(); - m_endPosition = getEndPoint(); - move( m_currentPosition ); - - // deselect all buttons - QValueList< ToolboxButton * >::iterator it = m_buttons.begin(), end = m_buttons.end(); - for ( ; it != end; ++it ) - (*it)->setOn( false ); - - // start scrolling in - if ( m_timerID ) - killTimer( m_timerID ); - m_timerID = startTimer( 20 ); -} - -void PageViewToolbox::hideAndDestroy() -{ - // set scroll parameters - m_hiding = true; - m_endPosition = getStartPoint(); - - // start scrolling out - if ( m_timerID ) - killTimer( m_timerID ); - m_timerID = startTimer( 10 ); -} - -void PageViewToolbox::anchorChanged() -{ - // stop timer - if ( m_timerID ) - { - killTimer( m_timerID ); - m_timerID = 0; - } - // if was hiding delete this - if ( m_hiding ) - delete this; - else - { - // else rebuild widget and set it completely visible - buildGfx(); - m_currentPosition = getEndPoint(); - move( m_currentPosition ); - // repaint all buttons (to update background) - QValueList< ToolboxButton * >::iterator it = m_buttons.begin(), end = m_buttons.end(); - for ( ; it != end; ++it ) - (*it)->update(); - } -} - -void PageViewToolbox::paintEvent( QPaintEvent * e ) -{ - // paint the internal pixmap over the widget - bitBlt( this, e->rect().topLeft(), &m_pixmap, e->rect() ); -} - -void PageViewToolbox::timerEvent( QTimerEvent * ) -{ - // move currentPosition towards endPosition - int dX = m_endPosition.x() - m_currentPosition.x(), - dY = m_endPosition.y() - m_currentPosition.y(); - dX = dX / 6 + QMAX( -2, QMIN( 2, dX) ); - dY = dY / 6 + QMAX( -2, QMIN( 2, dY) ); - m_currentPosition.setX( m_currentPosition.x() + dX ); - m_currentPosition.setY( m_currentPosition.y() + dY ); - - // move the widget - move( m_currentPosition ); - - // handle arrival to the end - if ( m_currentPosition == m_endPosition ) - { - killTimer( m_timerID ); - m_timerID = 0; - if ( m_hiding ) - delete this; - } -} - -QPoint PageViewToolbox::getStartPoint() -{ - if ( m_vertical ) - return QPoint( -width(), (m_anchor->height() - height()) / 2 ); - return QPoint( (m_anchor->width() - width()) / 2, -height() ); -} - -QPoint PageViewToolbox::getEndPoint() -{ - if ( m_vertical ) - return QPoint( 0, (m_anchor->height() - height()) / 2 ); - return QPoint( (m_anchor->width() - width()) / 2, 0 ); -} - -void PageViewToolbox::buildGfx() -{ - int buttonsNumber = m_buttons.count(), - parentWidth = m_anchor->width(), - parentHeight = m_anchor->height(), - myCols = 1, - myRows = 1; - - // 1. find out columns and rows we're going to use - if ( m_vertical ) - { - myCols = 1 + (buttonsNumber * ToolboxGridSize) / - (parentHeight - ToolboxGridSize); - myRows = (int)ceilf( (float)buttonsNumber / (float)myCols ); - } - else - { - myRows = 1 + (buttonsNumber * ToolboxGridSize) / - (parentWidth - ToolboxGridSize); - myCols = (int)ceilf( (float)buttonsNumber / (float)myRows ); - } - - // 2. compute widget size (from rows/cols) - int myWidth = myCols * ToolboxGridSize, - myHeight = myRows * ToolboxGridSize, - xOffset = (ToolboxGridSize - ToolboxButtonSize) / 2, - yOffset = (ToolboxGridSize - ToolboxButtonSize) / 2; - - if ( m_vertical ) - { - myHeight += 8; - myWidth += 4; - yOffset += 4; - } - else - { - myWidth += 8; - myHeight += 4; - xOffset += 4; - } - - // 3. resize pixmap, mask and widget - static QBitmap mask; - mask.resize( myWidth, myHeight ); - m_pixmap.resize( myWidth, myHeight ); - resize( myWidth, myHeight ); - - // 4. create and set transparency mask - QPainter maskPainter( &mask); - mask.fill( Qt::black ); - maskPainter.setBrush( Qt::white ); - if ( m_vertical ) - maskPainter.drawRoundRect( -10, 0, myWidth + 10, myHeight, 2000 / (myWidth + 10), 2000 / myHeight ); - else - maskPainter.drawRoundRect( 0, -10, myWidth, myHeight + 10, 2000 / myWidth, 2000 / (myHeight + 10) ); - setMask( mask ); - - // 5. draw background - QPainter bufferPainter( &m_pixmap ); - QPixmap gradientPattern; - // 5.1. draw horizontal/vertical gradient - if ( m_vertical ) - gradientPattern = KImageEffect::gradient( QSize( myWidth, 1), - palette().active().button(), palette().active().light(), - KImageEffect::HorizontalGradient ); - else - gradientPattern = KImageEffect::gradient( QSize( 1, myHeight ), - palette().active().button(), palette().active().light(), - KImageEffect::VerticalGradient ); - bufferPainter.drawTiledPixmap( 0, 0, myWidth, myHeight, gradientPattern ); - // 5.2. draw rounded border - bufferPainter.setPen( palette().active().dark() ); - if ( m_vertical ) - bufferPainter.drawRoundRect( -10, 0, myWidth + 10, myHeight, 2000 / (myWidth + 10), 2000 / myHeight ); - else - bufferPainter.drawRoundRect( 0, -10, myWidth, myHeight + 10, 2000 / myWidth, 2000 / (myHeight + 10) ); - - // 6. reposition buttons (in rows/col grid) - int gridX = 0, - gridY = 0; - QValueList< ToolboxButton * >::iterator it = m_buttons.begin(), end = m_buttons.end(); - for ( ; it != end; ++it ) - { - ToolboxButton * button = *it; - button->move( gridX * ToolboxGridSize + xOffset, - gridY * ToolboxGridSize + yOffset ); - if ( ++gridX == myCols ) - { - gridX = 0; - gridY++; - } - } -} - -void PageViewToolbox::slotButtonClicked() -{ - ToolboxButton * button = (ToolboxButton *)sender(); - if ( button ) - { - // deselect other buttons - QValueList< ToolboxButton * >::iterator it = m_buttons.begin(), end = m_buttons.end(); - for ( ; it != end; ++it ) - if ( *it != button ) - (*it)->setOn( false ); - // emit signal - if ( button->isOn() ) - emit toolSelected( button->toolboxID() ); - else - button->setOn( true ); - } -} - - -/** PageViewEditTools **/ - -PageViewEditTools::PageViewEditTools( QWidget * parent, QWidget * anchorWidget ) - : PageViewToolbox( parent, anchorWidget, true ) -{ - QValueList items; - items.push_back( ToolboxItem( 1, i18n("Text"), "pinnote" ) ); - items.push_back( ToolboxItem( 2, i18n("Yellow Highlighter"), "highlight_yellow" ) ); - items.push_back( ToolboxItem( 3, i18n("Orange Highlighter"), "highlight_orange" ) ); - items.push_back( ToolboxItem( 4, i18n("Green Highlighter"), "highlight_green" ) ); - items.push_back( ToolboxItem( 5, i18n("Pencil"), "pencil" ) ); - setItems( items ); - show(); -} - -#include "pageviewtoolbox.moc" diff --git a/ui/pageviewtoolbox.h b/ui/pageviewtoolbox.h deleted file mode 100644 index c4941cb9d..000000000 --- a/ui/pageviewtoolbox.h +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Enrico Ros * - * * - * 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. * - ***************************************************************************/ - -#ifndef _KPDF_PAGEVIEWTOOLBOX_H_ -#define _KPDF_PAGEVIEWTOOLBOX_H_ - -#include - -class ToolboxItem; -class ToolboxButton; - -/** - * @short A widget (containing exclusive buttons) that slides in from left/top. - */ -class PageViewToolbox : public QWidget -{ - Q_OBJECT - public: - PageViewToolbox( QWidget * parent, QWidget * anchorWidget, bool isVertical ); - - void setItems( const QValueList & items ); - void show(); - void hideAndDestroy(); - void anchorChanged(); - - void paintEvent( QPaintEvent * ); - void timerEvent( QTimerEvent * ); - - signals: - void toolSelected( int toolID ); - - private: - QPoint getStartPoint(); - QPoint getEndPoint(); - void buildGfx(); - - QWidget * m_anchor; - bool m_vertical; - QPoint m_currentPosition; - QPoint m_endPosition; - int m_timerID; - bool m_hiding; - QPixmap m_pixmap; - QValueList< ToolboxButton * > m_buttons; - - private slots: - void slotButtonClicked(); -}; - -class PageViewEditTools : public PageViewToolbox -{ - public: - PageViewEditTools( QWidget * parent, QWidget * anchorWidget ); - -}; - -struct ToolboxItem -{ - int id; - QString text; - QString pixmap; - - ToolboxItem() {}; - ToolboxItem( int _id, const QString & _text, const QString & _pixmap ) - : id( _id ), text( _text ), pixmap( _pixmap ) {}; -}; - -#endif diff --git a/ui/pageviewutils.cpp b/ui/pageviewutils.cpp index bc6ab3b87..09cbf94b5 100644 --- a/ui/pageviewutils.cpp +++ b/ui/pageviewutils.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2005 by Enrico Ros * + * Copyright (C) 2004 by Enrico Ros * * * * 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 * @@ -10,7 +10,9 @@ // qt/kde includes #include #include +#include #include +#include #include // local includes @@ -18,65 +20,6 @@ #include "core/page.h" #include "conf/settings.h" - -/** PageViewItem **/ - -PageViewItem::PageViewItem( const KPDFPage * page ) - : m_page( page ), m_zoomFactor( 1.0 ) -{ -} - -const KPDFPage * PageViewItem::page() const -{ - return m_page; -} - -int PageViewItem::pageNumber() const -{ - return m_page->number(); -} - -const QRect& PageViewItem::geometry() const -{ - return m_geometry; -} - -int PageViewItem::width() const -{ - return m_geometry.width(); -} - -int PageViewItem::height() const -{ - return m_geometry.height(); -} - -double PageViewItem::zoomFactor() const -{ - return m_zoomFactor; -} - -void PageViewItem::setGeometry( int x, int y, int width, int height ) -{ - m_geometry.setRect( x, y, width, height ); -} - -void PageViewItem::setWHZ( int w, int h, double z ) -{ - m_geometry.setWidth( w ); - m_geometry.setHeight( h ); - m_zoomFactor = z; -} - -void PageViewItem::moveTo( int x, int y ) -{ - m_geometry.moveLeft( x ); - m_geometry.moveTop( y ); -} - - -/** PageViewMessage **/ - PageViewMessage::PageViewMessage( QWidget * parent ) : QWidget( parent, "pageViewMessage" ), m_timer( 0 ) { @@ -179,8 +122,8 @@ void PageViewMessage::display( const QString & message, Icon icon, int durationM void PageViewMessage::paintEvent( QPaintEvent * e ) { - // paint the internal pixmap over the widget - bitBlt( this, e->rect().topLeft(), &m_pixmap, e->rect() ); + QPainter p( this ); + p.drawPixmap( e->rect().topLeft(), m_pixmap, e->rect() ); } void PageViewMessage::mousePressEvent( QMouseEvent * /*e*/ ) @@ -189,3 +132,58 @@ void PageViewMessage::mousePressEvent( QMouseEvent * /*e*/ ) m_timer->stop(); hide(); } + + + +PageViewItem::PageViewItem( const KPDFPage * page ) + : m_page( page ), m_zoomFactor( 1.0 ) +{ +} + +const KPDFPage * PageViewItem::page() const +{ + return m_page; +} + +int PageViewItem::pageNumber() const +{ + return m_page->number(); +} + +const QRect& PageViewItem::geometry() const +{ + return m_geometry; +} + +int PageViewItem::width() const +{ + return m_geometry.width(); +} + +int PageViewItem::height() const +{ + return m_geometry.height(); +} + +double PageViewItem::zoomFactor() const +{ + return m_zoomFactor; +} + +void PageViewItem::setGeometry( int x, int y, int width, int height ) +{ + m_geometry.setRect( x, y, width, height ); +} + +void PageViewItem::setWHZ( int w, int h, double z ) +{ + m_geometry.setWidth( w ); + m_geometry.setHeight( h ); + m_zoomFactor = z; +} + +void PageViewItem::moveTo( int x, int y ) +{ + m_geometry.moveLeft( x ); + m_geometry.moveTop( y ); +} diff --git a/ui/pageviewutils.h b/ui/pageviewutils.h index 51e06cc00..bde9b8d3b 100644 --- a/ui/pageviewutils.h +++ b/ui/pageviewutils.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2005 by Enrico Ros * + * Copyright (C) 2004 by Enrico Ros * * * * 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 * @@ -7,14 +7,17 @@ * (at your option) any later version. * ***************************************************************************/ -#ifndef _PAGEVIEW_UTILS_H_ -#define _PAGEVIEW_UTILS_H_ +#ifndef _PAGEVIEW_UTILS_H +#define _PAGEVIEW_UTILS_H #include #include +#include #include class QTimer; + +class PageView; class KPDFPage; /** @@ -48,10 +51,6 @@ class PageViewItem /** * @short A widget that displays messages in the top-left corner. - * - * 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. */ class PageViewMessage : public QWidget {