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 <tqvbox.h> 00023 #include <tqpixmap.h> 00024 #include <tqrect.h> 00025 #include <tqlabel.h> 00026 #include <kimageeffect.h> 00027 00028 class TDEPopupMenu; 00029 00030 #include <tdelibs_export.h> 00031 00044 class TDEUI_EXPORT KPixmapRegionSelectorWidget : public TQWidget 00045 { 00046 Q_OBJECT 00047 public: 00051 KPixmapRegionSelectorWidget( TQWidget *parent = 0L, const char *name=0L); 00052 00056 ~KPixmapRegionSelectorWidget(); 00057 00063 void setPixmap( const TQPixmap &pixmap ); 00064 00069 TQPixmap pixmap() const { return m_unzoomedPixmap; } 00070 00074 void setSelectedRegion(const TQRect &rect); 00075 00079 TQRect selectedRegion() const; 00080 00084 TQRect unzoomedSelectedRegion() const; 00085 00089 void resetSelection(); 00090 00095 TQImage 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 TDEPopupMenu *createPopupMenu(); 00141 00142 private: 00143 bool eventFilter(TQObject *obj, TQEvent *ev); 00144 00149 void updatePixmap(); 00150 00151 TQRect calcSelectionRectangle( const TQPoint &startPoint, const TQPoint & endPoint ); 00152 00153 enum CursorState { None=0, Resizing, Moving }; 00154 CursorState m_state; 00155 00156 TQPixmap m_unzoomedPixmap; 00157 TQPixmap m_originalPixmap; 00158 TQPixmap m_linedPixmap; 00159 TQRect m_selectedRegion; 00160 TQLabel *m_label; 00161 00162 TQPoint m_tempFirstClick; 00163 double m_forcedAspectRatio; 00164 00165 int m_maxWidth, m_maxHeight; 00166 double m_zoomFactor; 00167 }; 00168 00169 #endif 00170