krita
imageviewer.h
00001 /*************************************************************************** 00002 * Copyright (C) 2005 Eyal Lotem <eyal.lotem@gmail.com> * 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU General Public License as published by * 00006 * the Free Software Foundation; either version 2 of the License, or * 00007 * (at your option) any later version. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU General Public License * 00015 * along with this program; if not, write to the * 00016 * Free Software Foundation, Inc., * 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00018 ***************************************************************************/ 00019 #ifndef PIXMAPVIEWER_H 00020 #define PIXMAPVIEWER_H 00021 00022 #include <qscrollview.h> 00023 #include <qimage.h> 00024 00025 class QLabel; 00026 00033 class ImageViewer : public QScrollView { 00034 Q_OBJECT 00035 00036 public: 00037 ImageViewer(QWidget *widget, const char * name = 0); 00038 00039 void setImage(QImage & image); 00040 00041 void contentsMousePressEvent(QMouseEvent *event); 00042 void contentsMouseReleaseEvent(QMouseEvent *event); 00043 void contentsMouseMoveEvent(QMouseEvent *event); 00044 void wheelEvent(QWheelEvent * event) { event->ignore(); }; 00045 private: 00046 QLabel* m_label; 00047 bool m_isDragging; 00048 QPoint m_currentPos; 00049 QPixmap m_image; 00050 }; 00051 00052 #endif