kpdf_part.h 1.81 KB
Newer Older
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
#ifndef _KPDF_PART_H_
#define _KPDF_PART_H_

#include <qpainter.h>
#include <qpixmap.h>
#include <qwidget.h>

#include <kparts/part.h>

class QPainter;
class QPixmap;
class QWidget;

class KAboutData;
class KAction;
class KURL;
class KToggleAction;

class LinkAction;
class LinkDest;
class PDFDoc;
class XOutputDev;

namespace KPDF
{
26
  class Canvas;
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
  class PageWidget;

  /**
   * This is a "Part".  It that does all the real work in a KPart
   * application.
   *
   * @short Main Part
   * @author Wilco Greven <greven@kde.org>
   * @version 0.1
   */
  class Part : public KParts::ReadOnlyPart
  {
    Q_OBJECT

  public:
     // Do with these first. We can always add the other zoommodes which can
     // be specified in a Destination later.
     enum ZoomMode { FitInWindow, FitWidth, FitVisible, FixedFactor };

    /**
     * Default constructor
     */
    Part(QWidget* parentWidget, const char* widgetName,
         QObject* parent, const char* name, const QStringList& args);

    /**
     * Destructor
     */
    virtual ~Part();

    static KAboutData* createAboutData();

59 60
    bool closeURL();

61 62 63 64 65 66 67 68 69 70 71 72
    void displayPage(int pageNumber, float zoomFactor = 1.0);
    void displayDestination(LinkDest*);

  protected:
    /**
     * This must be implemented by each part
     */
    virtual bool openFile();

  protected slots:
    void fileOpen();
    void fileSaveAs();
73
    void filePrint();
74 75 76 77 78 79 80

    void displayNextPage();
    void displayPreviousPage();

    void executeAction(LinkAction*);

  private:
81 82 83 84 85
    Canvas*     m_canvas;
    QPixmap     m_pagePixmap;
    PageWidget* m_pageWidget;
    PDFDoc*     m_doc;
    XOutputDev* m_outputDev;
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101

    KToggleAction* m_fitWidth;

    int   m_currentPage;

    ZoomMode m_zoomMode;
    float    m_zoomFactor;

  private slots:
    void fitWidthToggled();
  };
}

#endif

// vim:ts=2:sw=2:tw=78:et