kviewshell
pageView.h
Go to the documentation of this file.00001 // -*- C++ -*- 00002 /* This file is part of the KDE project 00003 Copyright (C) 2001 Wilco Greven <greven@kde.org> 00004 Copyright (C) 2004-2005 Wilfried Huss <Wilfried.Huss@gmx.at> 00005 Copyright (C) 2005 Stefan Kebekus <kebekus@kde.org> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef PAGEVIEW_H 00024 #define PAGEVIEW_H 00025 00026 #include "documentWidget.h" 00027 00028 #include <qptrvector.h> 00029 #include <qscrollview.h> 00030 00031 class PageNumber; 00032 00033 /* 00034 * PageView is a customized QScrollView, which can hold one 00035 * page. This page will be centered on the viewport. 00036 */ 00037 class PageView : public QScrollView 00038 { 00039 Q_OBJECT 00040 00041 public: 00042 PageView( QWidget* parent = 0, const char* name = 0 ); 00043 ~PageView() {} 00044 00045 void addChild( QPtrVector<DocumentWidget> *wdgList ); 00046 00049 void setNrColumns( Q_UINT8 cols ); 00050 void setNrRows( Q_UINT8 rows ); 00051 00052 void setContinuousViewMode(bool continuous); 00053 bool fullScreenMode() { return fullScreen; } 00054 bool singlePageFullScreenMode(); 00055 bool overviewMode() { return !continuousViewmode && (nrRows > 1 || nrCols > 1); } 00056 00074 Q_UINT8 getNrColumns() const { return (widgetList==0) ? 1 : QMIN(nrCols, QMAX(1, widgetList->size())); } 00075 00076 Q_UINT8 getNrRows() const { return nrRows; } 00077 bool isContinuous() const { return continuousViewmode; } 00078 00080 bool atTop() const; 00081 bool atBottom() const; 00082 00085 int distanceBetweenPages() { return distanceBetweenWidgets; } 00086 00088 void moveViewportToWidget(QWidget* widget, int y = 0); 00089 00090 bool isMoveToolEnabled() const { return moveTool; } 00091 00092 public slots: 00093 void calculateCurrentPageNumber(); 00094 00095 bool readUp(); 00096 bool readDown(); 00097 void scrollUp(); 00098 void scrollDown(); 00099 void scrollRight(); 00100 void scrollLeft(); 00101 void scrollBottom(); 00102 void scrollTop(); 00103 00104 void setFullScreenMode(bool fullScreen); 00106 void slotShowScrollbars(bool); 00107 00110 void layoutPages(bool zoomChanged = false); 00111 00112 void slotEnableMoveTool(bool enable); 00113 00114 signals: 00115 void viewSizeChanged(const QSize& size); 00116 void pageSizeChanged(const QSize& size); 00117 00118 void currentPageChanged(const PageNumber&); 00119 00122 void wheelEventReceived( QWheelEvent * ); 00123 00124 protected: 00125 void keyPressEvent( QKeyEvent* ); 00126 00129 void viewportResizeEvent( QResizeEvent* ); 00130 void viewportPaintEvent(QPaintEvent*); 00131 00135 void contentsWheelEvent ( QWheelEvent * ); 00136 00137 void contentsMousePressEvent(QMouseEvent*); 00138 void contentsMouseReleaseEvent(QMouseEvent*); 00139 void contentsMouseMoveEvent(QMouseEvent*); 00140 00141 private slots: 00142 void calculateCurrentPageNumber(int x, int y); 00143 00144 private: 00147 QPoint dragGrabPos; 00148 00149 QPtrVector<DocumentWidget>* widgetList; 00150 00153 Q_UINT8 nrCols; 00154 Q_UINT8 nrRows; 00155 00156 bool continuousViewmode; 00157 bool fullScreen; 00158 00162 int oldFrameStyle; 00163 00166 QColor backgroundColor; 00167 00170 static const int distanceBetweenWidgets=10; 00171 00172 bool moveTool; 00173 }; 00174 00175 #endif