libkdepim

kpixmapregionselectorwidget.h

00001 /*
00002     This file is part of libkdepim.
00003 
00004     Copyright (C) 2004 Antonio Larrosa <larrosa@kde.org
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef __KPIXMAPREGIONSELECTORWIDGET_H__
00023 #define __KPIXMAPREGIONSELECTORWIDGET_H__
00024 
00025 #include <qvbox.h>
00026 #include <qpixmap.h>
00027 #include <qrect.h>
00028 #include <qlabel.h>
00029 #include <kimageeffect.h>
00030 
00031 class KPopupMenu;
00032 
00033 namespace KPIM {
00034 
00047 class KPixmapRegionSelectorWidget : public QWidget
00048 {
00049    Q_OBJECT
00050 
00051 public:
00055    KPixmapRegionSelectorWidget( QWidget *parent = 0L, const char *name=0L);
00056 
00060    ~KPixmapRegionSelectorWidget();
00061 
00066    void setPixmap( const QPixmap &pixmap );
00067 
00072    QPixmap pixmap() const { return m_unzoomedPixmap; };
00073 
00077    void setSelectedRegion(const QRect &rect);
00078 
00082    QRect selectedRegion() const;
00083 
00087    QRect unzoomedSelectedRegion() const;
00088 
00092    void resetSelection();
00093 
00098    QImage selectedImage() const;
00099 
00105    void setSelectionAspectRatio(int width, int height);
00106 
00112    void setFreeSelectionAspectRatio();
00113 
00119    void setMaximumWidgetSize( int width, int height );
00120 
00127    void rotate(KImageEffect::RotateDirection direction);
00128 
00129 public slots:
00133    void rotateClockwise();
00137    void rotateCounterclockwise();
00138 
00139 protected:
00143    virtual KPopupMenu *createPopupMenu();
00144 
00145 
00146 private:
00147    bool eventFilter(QObject *obj, QEvent *ev);
00148 
00153    void updatePixmap();
00154 
00155    QRect calcSelectionRectangle( const QPoint &startPoint, const QPoint & endPoint );
00156 
00157    enum CursorState { None=0, Resizing, Moving };
00158    CursorState m_state;
00159 
00160    QPixmap m_unzoomedPixmap;
00161    QPixmap m_originalPixmap;
00162    QPixmap m_linedPixmap;
00163    QRect   m_selectedRegion;
00164    QLabel *m_label;
00165 
00166    QPoint m_tempFirstClick;
00167    double m_forcedAspectRatio;
00168 
00169    int m_maxWidth, m_maxHeight;
00170    double m_zoomFactor;
00171 };
00172 
00173 } // for namespace
00174 
00175 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys