You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
4.2 KiB
128 lines
4.2 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
Copyright (C) 2004 Antonio Larrosa <larrosa@kde.org
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include "kpixmapregionselectordialog.h"
|
||
|
#include <kdialogbase.h>
|
||
14 years ago
|
#include <tqdialog.h>
|
||
|
#include <tqdesktopwidget.h>
|
||
15 years ago
|
#include <klocale.h>
|
||
|
#include <kdialog.h>
|
||
|
|
||
14 years ago
|
KPixmapRegionSelectorDialog::KPixmapRegionSelectorDialog(TQWidget *parent,
|
||
15 years ago
|
const char *name, bool modal ) : KDialogBase(parent, name, modal, i18n("Select Region of Image"), Help|Ok|Cancel, Ok, true )
|
||
|
{
|
||
14 years ago
|
TQVBox *vbox=new TQVBox(this);
|
||
|
new TQLabel(i18n("Please click and drag on the image to select the region of interest:"), vbox);
|
||
15 years ago
|
m_pixmapSelectorWidget= new KPixmapRegionSelectorWidget(vbox);
|
||
|
|
||
|
vbox->setSpacing( KDialog::spacingHint() );
|
||
|
|
||
|
setMainWidget(vbox);
|
||
|
}
|
||
|
|
||
|
KPixmapRegionSelectorDialog::~KPixmapRegionSelectorDialog()
|
||
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
TQRect KPixmapRegionSelectorDialog::getSelectedRegion(const TQPixmap &pixmap, TQWidget *parent )
|
||
15 years ago
|
{
|
||
|
KPixmapRegionSelectorDialog dialog(parent);
|
||
|
|
||
|
dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
|
||
|
|
||
14 years ago
|
TQDesktopWidget desktopWidget;
|
||
|
TQRect screen=desktopWidget.availableGeometry();
|
||
15 years ago
|
dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
|
||
|
(int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
|
||
|
|
||
|
int result = dialog.exec();
|
||
|
|
||
14 years ago
|
TQRect rect;
|
||
15 years ago
|
|
||
14 years ago
|
if ( result == TQDialog::Accepted )
|
||
15 years ago
|
rect = dialog.pixmapRegionSelectorWidget()->unzoomedSelectedRegion();
|
||
|
|
||
|
return rect;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQRect KPixmapRegionSelectorDialog::getSelectedRegion(const TQPixmap &pixmap, int aspectRatioWidth, int aspectRatioHeight, TQWidget *parent )
|
||
15 years ago
|
{
|
||
|
KPixmapRegionSelectorDialog dialog(parent);
|
||
|
|
||
|
dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
|
||
|
dialog.pixmapRegionSelectorWidget()->setSelectionAspectRatio(aspectRatioWidth,aspectRatioHeight);
|
||
|
|
||
14 years ago
|
TQDesktopWidget desktopWidget;
|
||
|
TQRect screen=desktopWidget.availableGeometry();
|
||
15 years ago
|
dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
|
||
|
(int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
|
||
|
|
||
|
int result = dialog.exec();
|
||
|
|
||
14 years ago
|
TQRect rect;
|
||
15 years ago
|
|
||
14 years ago
|
if ( result == TQDialog::Accepted )
|
||
15 years ago
|
rect = dialog.pixmapRegionSelectorWidget()->unzoomedSelectedRegion();
|
||
|
|
||
|
return rect;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQImage KPixmapRegionSelectorDialog::getSelectedImage(const TQPixmap &pixmap, TQWidget *parent )
|
||
15 years ago
|
{
|
||
|
KPixmapRegionSelectorDialog dialog(parent);
|
||
|
|
||
|
dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
|
||
|
|
||
14 years ago
|
TQDesktopWidget desktopWidget;
|
||
|
TQRect screen=desktopWidget.availableGeometry();
|
||
15 years ago
|
dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
|
||
|
(int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
|
||
|
int result = dialog.exec();
|
||
|
|
||
14 years ago
|
TQImage image;
|
||
15 years ago
|
|
||
14 years ago
|
if ( result == TQDialog::Accepted )
|
||
15 years ago
|
image = dialog.pixmapRegionSelectorWidget()->selectedImage();
|
||
|
|
||
|
return image;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQImage KPixmapRegionSelectorDialog::getSelectedImage(const TQPixmap &pixmap, int aspectRatioWidth, int aspectRatioHeight, TQWidget *parent )
|
||
15 years ago
|
{
|
||
|
KPixmapRegionSelectorDialog dialog(parent);
|
||
|
|
||
|
dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
|
||
|
dialog.pixmapRegionSelectorWidget()->setSelectionAspectRatio(aspectRatioWidth,aspectRatioHeight);
|
||
|
|
||
14 years ago
|
TQDesktopWidget desktopWidget;
|
||
|
TQRect screen=desktopWidget.availableGeometry();
|
||
15 years ago
|
dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
|
||
|
(int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
|
||
|
|
||
|
int result = dialog.exec();
|
||
|
|
||
14 years ago
|
TQImage image;
|
||
15 years ago
|
|
||
14 years ago
|
if ( result == TQDialog::Accepted )
|
||
15 years ago
|
image = dialog.pixmapRegionSelectorWidget()->selectedImage();
|
||
|
|
||
|
return image;
|
||
|
}
|
||
|
|