kviewshell
documentWidget.h
Go to the documentation of this file.00001 // -*- C++ -*- 00002 // 00003 // Class: documentWidet 00004 // 00005 // Widget for displaying TeX DVI files. 00006 // Part of KDVI- A previewer for TeX DVI files. 00007 // 00008 // (C) 2004 Stefan Kebekus. 00009 // Copyright (C) 2004-2005 Wilfried Huss <Wilfried.Huss@gmx.at> 00010 // 00011 // Distributed under the GPL. 00012 00013 #ifndef _documentwidget_h_ 00014 #define _documentwidget_h_ 00015 00016 #include "selection.h" 00017 00018 #include <qregion.h> 00019 #include <qtimer.h> 00020 #include <qwidget.h> 00021 00022 class DocumentPageCache; 00023 class PageView; 00024 class QMouseEvent; 00025 class QPaintEvent; 00026 00027 00028 /* DocumentWidget */ 00029 00030 class DocumentWidget : public QWidget 00031 { 00032 Q_OBJECT 00033 00034 public: 00035 DocumentWidget(QWidget *parent, PageView *sv, DocumentPageCache *cache, const char *name); 00036 00037 void setPageNumber(Q_UINT16 pageNr); 00038 Q_UINT16 getPageNumber() const {return pageNr;} 00039 00041 QSize pageSize() const; 00043 QRect pageRect() const; 00044 00048 void drawScrollGuide(int ycoord); 00049 00051 bool isVisible(); 00052 00053 public slots: 00054 void slotEnableMoveTool(bool enable); 00055 00056 void select(const TextSelection&); 00057 void selectAll(); 00058 void flash(int); 00059 00062 void setPageSize(const QSize&); 00063 void setPageSize(int width, int height); 00064 00065 signals: 00067 void setStatusBarText( const QString& ); 00068 void localLink( const QString& ); 00069 00071 void resized(); 00072 00074 void clearSelection(); 00075 00076 protected: 00077 virtual void paintEvent (QPaintEvent *); 00078 virtual void mousePressEvent ( QMouseEvent * e ); 00079 virtual void mouseReleaseEvent (QMouseEvent *); 00080 00112 virtual void mouseMoveEvent (QMouseEvent *); 00113 00114 protected: 00115 void updateSelection(const TextSelection& newTextSelection); 00116 00119 int timerIdent; 00120 void timerEvent( QTimerEvent *e ); 00121 int animationCounter; 00122 int flashOffset; 00123 00124 Q_UINT16 pageNr; 00125 00126 /* This timer is used to delay clearing of the statusbar. Clearing 00127 the statusbar is delayed to avoid awful flickering when the mouse 00128 moves over a block of text that contains source hyperlinks. The 00129 signal timeout() is connected to the method clearStatusBar() of 00130 *this. */ 00131 QTimer clearStatusBarTimer; 00132 00133 /* Data structures used for marking text with the mouse */ 00134 QPoint firstSelectedPoint; 00135 QRect selectedRectangle; 00136 00140 PageView *scrollView; 00141 DocumentPageCache *documentCache; 00142 00144 QRegion selectedRegion; 00145 00149 int indexOfUnderlinedLink; 00150 00152 bool pixmapRequested; 00153 00156 virtual void setStandardCursor(); 00157 00158 private slots: 00162 void clearStatusBar(); 00163 00164 void delayedRequestPage(); 00165 00167 void clearScrollGuide(); 00168 00169 private: 00170 QRect linkFlashRect(); 00171 00173 int scrollGuide; 00174 00176 static QColor backgroundColorForCorners; 00177 00180 static const int bottom_right_corner[16]; 00181 static const int bottom_left_corner[16]; 00182 static const int shadow_strip[4]; 00183 00184 bool moveTool; 00185 00188 bool selectionNeedsUpdating; 00189 }; 00190 00191 00192 00193 #endif