From c20639405a265fbac9aeb2ddd49fcb24a7da6801 Mon Sep 17 00:00:00 2001 From: Matthias Hoelzer-Kluepfel Date: Mon, 15 May 2000 06:51:49 +0000 Subject: [PATCH] dviWindow now no longer inherits from QScrollView, as scrolling is done in the framework. svn path=/trunk/kdegraphics/kdvi/; revision=49517 --- dviwin.cpp | 51 +++++++++++++++++---------------------------------- dviwin.h | 15 ++++++--------- 2 files changed, 23 insertions(+), 43 deletions(-) diff --git a/dviwin.cpp b/dviwin.cpp index fc11e0ddd..918967d65 100644 --- a/dviwin.cpp +++ b/dviwin.cpp @@ -98,17 +98,16 @@ extern void qt_processEvents(void) //------ now comes the dviWindow class implementation ---------- -dviWindow::dviWindow( int bdpi, int zoom, const char *mfm, const char *ppr, int mkpk, QWidget *parent, const char *name ) : QScrollView( parent, name ) +dviWindow::dviWindow( int bdpi, int zoom, const char *mfm, const char *ppr, int mkpk, QWidget *parent, const char *name ) + : QWidget( parent, name ) { + setBackgroundMode(NoBackground); + ChangesPossible = 1; FontPath = QString::null; - viewport()->setBackgroundColor( white ); setFocusPolicy(QWidget::StrongFocus); setFocus(); - setHScrollBarMode(QScrollView::AlwaysOff); - setVScrollBarMode(QScrollView::AlwaysOff); - // initialize the dvi machinery setResolution( bdpi ); @@ -129,6 +128,8 @@ dviWindow::dviWindow( int bdpi, int zoom, const char *mfm, const char *ppr, int double xres = ((double)(DisplayWidth(DISP,(int)DefaultScreen(DISP)) *25.4)/DisplayWidthMM(DISP,(int)DefaultScreen(DISP)) ); //@@@ double s = (basedpi * 100)/(xres*(double)zoom); mane.shrinkfactor = currwin.shrinkfactor = s; + + resize(0,0); } dviWindow::~dviWindow() @@ -284,8 +285,8 @@ extern jmp_buf dvi_env; /* mechanism to communicate dvi file errors */ extern char *dvi_oops_msg; extern QDateTime dvi_time; -//------ this function calls the dvi interpreter ---------- +//------ this function calls the dvi interpreter ---------- void dviWindow::drawPage() { @@ -311,6 +312,7 @@ void dviWindow::drawPage() changePageSize(); return; } + min_x = 0; min_y = 0; max_x = page_w; @@ -318,6 +320,7 @@ void dviWindow::drawPage() if ( !pixmap ) return; + if ( !pixmap->paintingActive() ) { QPainter paint; paint.begin( pixmap ); @@ -340,7 +343,7 @@ void dviWindow::drawPage() paint.end(); } resize(pixmap->width(), pixmap->height()); - repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight(), FALSE); + repaint(); } @@ -375,30 +378,7 @@ void dviWindow::changePageSize() pixmap = new QPixmap( (int)page_w, (int)page_h ); pixmap->fill( white ); - // Resize the QScrollview. Be careful to maintain the locical positon - // on the ScrollView. This looks kind of complicated, but my experience - // shows that this is what most users intuitively expect. - // -- Stefan Kebekus. - int new_x = 0; - if ( page_w > visibleWidth() ) { - if ( old_width < visibleWidth() ) {// First time the Pixmap is wider than the ScrollView? - // Yes. We center horizonzally by default. - // Don't ask me why I need to subtract 30. It just works better (with qt 2.1 b4, that is). - if (contentsWidth() < 10) - new_x = ( page_w - visibleWidth() ) / 2 - 30; - else - new_x = ( page_w - visibleWidth() ) / 2; - } else - // Otherwise maintain the logical horizontal position - // -- that is, the horizontal center of the screen stays where it is. - new_x = ((contentsX()+visibleWidth()/2)*page_w)/contentsWidth() - visibleWidth()/2; - } - // We are not that particular about the vertical position - // -- just keep the upper corner where it is. - int new_y = (contentsY()*page_h) / contentsHeight(); - - resizeContents( page_w, page_h ); - setContentsPos( new_x > 0 ? new_x : 0, new_y > 0 ? new_y : 0 ); + resize( page_w, page_h ); currwin.win = mane.win = pixmap->handle(); drawPage(); } @@ -455,8 +435,11 @@ void dviWindow::setZoom(int zoom) } -void dviWindow::drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph ) +void dviWindow::paintEvent(QPaintEvent *ev) { - if ( pixmap ) - p->drawPixmap(clipx, clipy, *pixmap, clipx, clipy, clipw, cliph); + if (pixmap) + { + QPainter p(this); + p.drawPixmap(QPoint(0, 0), *pixmap); + } } diff --git a/dviwin.h b/dviwin.h index ae8433196..5d78b29d8 100644 --- a/dviwin.h +++ b/dviwin.h @@ -7,14 +7,14 @@ #ifndef _dviwin_h_ #define _dviwin_h_ + #include "../config.h" #include #include -#include -#include -#include +#include + -class dviWindow : public QScrollView +class dviWindow : public QWidget { Q_OBJECT @@ -53,19 +53,16 @@ public slots: void drawPage(); protected: - void drawContents ( QPainter *p, - int clipx, int clipy, - int clipw, int cliph ); + void paintEvent(QPaintEvent *ev); + private: bool correctDVI(); void initDVI(); void changePageSize(); - QPoint mouse; QString filename; int basedpi, makepk; QPixmap * pixmap; - QTimer * timer; QString MetafontMode; QString FontPath; QString paper_type;