kpixmapregionselectorwidget.h

00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2004 Antonio Larrosa <larrosa@kde.org
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library 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 GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef __KPIXMAPREGIONSELECTORWIDGET_H__
00021 #define __KPIXMAPREGIONSELECTORWIDGET_H__
00022 #include <qvbox.h>
00023 #include <qpixmap.h>
00024 #include <qrect.h>
00025 #include <qlabel.h>
00026 #include <kimageeffect.h>
00027 
00028 class KPopupMenu;
00029 
00030 #include <kdelibs_export.h>
00031 
00044 class KDEUI_EXPORT KPixmapRegionSelectorWidget : public QWidget
00045 {
00046    Q_OBJECT
00047 public:
00051    KPixmapRegionSelectorWidget( QWidget *parent = 0L, const char *name=0L);
00052 
00056    ~KPixmapRegionSelectorWidget();
00057 
00063    void setPixmap( const QPixmap &pixmap );
00064 
00069    QPixmap pixmap() const { return m_unzoomedPixmap; }
00070 
00074    void setSelectedRegion(const QRect &rect);
00075 
00079    QRect selectedRegion() const;
00080 
00084    QRect unzoomedSelectedRegion() const;
00085 
00089    void resetSelection();
00090 
00095    QImage selectedImage() const;
00096 
00102    void setSelectionAspectRatio(int width, int height);
00103 
00109    void setFreeSelectionAspectRatio();
00110  
00116    void setMaximumWidgetSize( int width, int height );
00117 
00124    void rotate(KImageEffect::RotateDirection direction);
00125 
00126 public slots:
00130    void rotateClockwise();
00134    void rotateCounterclockwise();
00135 
00136 protected:
00140    virtual KPopupMenu *createPopupMenu();
00141 
00142 private:
00143    bool eventFilter(QObject *obj, QEvent *ev);
00144 
00149    void updatePixmap();
00150 
00151    QRect calcSelectionRectangle( const QPoint &startPoint, const QPoint & endPoint );
00152 
00153    enum CursorState { None=0, Resizing, Moving };
00154    CursorState m_state;
00155 
00156    QPixmap m_unzoomedPixmap;
00157    QPixmap m_originalPixmap;
00158    QPixmap m_linedPixmap;
00159    QRect   m_selectedRegion;
00160    QLabel *m_label;
00161 
00162    QPoint m_tempFirstClick;
00163    double m_forcedAspectRatio;
00164 
00165    int m_maxWidth, m_maxHeight;
00166    double m_zoomFactor;
00167 };
00168 
00169 #endif
00170 
KDE Home | KDE Accessibility Home | Description of Access Keys