kpixmapregionselectorwidget.h
00001 /* 00002 This file is part of libtdepim. 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 <tqvbox.h> 00026 #include <tqpixmap.h> 00027 #include <tqrect.h> 00028 #include <tqlabel.h> 00029 #include <kimageeffect.h> 00030 00031 class TDEPopupMenu; 00032 00033 namespace KPIM { 00034 00047 class KPixmapRegionSelectorWidget : public TQWidget 00048 { 00049 Q_OBJECT 00050 00051 00052 public: 00056 KPixmapRegionSelectorWidget( TQWidget *parent = 0L, const char *name=0L); 00057 00061 ~KPixmapRegionSelectorWidget(); 00062 00067 void setPixmap( const TQPixmap &pixmap ); 00068 00073 TQPixmap pixmap() const { return m_unzoomedPixmap; } 00074 00078 void setSelectedRegion(const TQRect &rect); 00079 00083 TQRect selectedRegion() const; 00084 00088 TQRect unzoomedSelectedRegion() const; 00089 00093 void resetSelection(); 00094 00099 TQImage selectedImage() const; 00100 00106 void setSelectionAspectRatio(int width, int height); 00107 00113 void setFreeSelectionAspectRatio(); 00114 00120 void setMaximumWidgetSize( int width, int height ); 00121 00128 void rotate(KImageEffect::RotateDirection direction); 00129 00130 public slots: 00134 void rotateClockwise(); 00138 void rotateCounterclockwise(); 00139 00140 protected: 00144 virtual TDEPopupMenu *createPopupMenu(); 00145 00146 00147 private: 00148 bool eventFilter(TQObject *obj, TQEvent *ev); 00149 00154 void updatePixmap(); 00155 00156 TQRect calcSelectionRectangle( const TQPoint &startPoint, const TQPoint & endPoint ); 00157 00158 enum CursorState { None=0, Resizing, Moving }; 00159 CursorState m_state; 00160 00161 TQPixmap m_unzoomedPixmap; 00162 TQPixmap m_originalPixmap; 00163 TQPixmap m_linedPixmap; 00164 TQRect m_selectedRegion; 00165 TQLabel *m_label; 00166 00167 TQPoint m_tempFirstClick; 00168 double m_forcedAspectRatio; 00169 00170 int m_maxWidth, m_maxHeight; 00171 double m_zoomFactor; 00172 }; 00173 00174 } // for namespace 00175 00176 #endif