• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeui
 

tdeui

  • tdeui
kpixmapregionselectordialog.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2004 Antonio Larrosa <larrosa@kde.org
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "kpixmapregionselectordialog.h"
21 #include <kdialogbase.h>
22 #include <tqdialog.h>
23 #include <tqdesktopwidget.h>
24 #include <tdelocale.h>
25 #include <kdialog.h>
26 
27 KPixmapRegionSelectorDialog::KPixmapRegionSelectorDialog(TQWidget *parent,
28  const char *name, bool modal ) : KDialogBase(parent, name, modal, i18n("Select Region of Image"), Help|Ok|Cancel, Ok, true )
29 {
30  TQVBox *vbox=new TQVBox(this);
31  new TQLabel(i18n("Please click and drag on the image to select the region of interest:"), vbox);
32  m_pixmapSelectorWidget= new KPixmapRegionSelectorWidget(vbox);
33 
34  vbox->setSpacing( KDialog::spacingHint() );
35 
36  setMainWidget(vbox);
37 }
38 
39 KPixmapRegionSelectorDialog::~KPixmapRegionSelectorDialog()
40 {
41 }
42 
43 TQRect KPixmapRegionSelectorDialog::getSelectedRegion(const TQPixmap &pixmap, TQWidget *parent )
44 {
45  KPixmapRegionSelectorDialog dialog(parent);
46 
47  dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
48 
49  TQDesktopWidget desktopWidget;
50  TQRect screen=desktopWidget.availableGeometry();
51  dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
52  (int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
53 
54  int result = dialog.exec();
55 
56  TQRect rect;
57 
58  if ( result == TQDialog::Accepted )
59  rect = dialog.pixmapRegionSelectorWidget()->unzoomedSelectedRegion();
60 
61  return rect;
62 }
63 
64 TQRect KPixmapRegionSelectorDialog::getSelectedRegion(const TQPixmap &pixmap, int aspectRatioWidth, int aspectRatioHeight, TQWidget *parent )
65 {
66  KPixmapRegionSelectorDialog dialog(parent);
67 
68  dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
69  dialog.pixmapRegionSelectorWidget()->setSelectionAspectRatio(aspectRatioWidth,aspectRatioHeight);
70 
71  TQDesktopWidget desktopWidget;
72  TQRect screen=desktopWidget.availableGeometry();
73  dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
74  (int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
75 
76  int result = dialog.exec();
77 
78  TQRect rect;
79 
80  if ( result == TQDialog::Accepted )
81  rect = dialog.pixmapRegionSelectorWidget()->unzoomedSelectedRegion();
82 
83  return rect;
84 }
85 
86 TQImage KPixmapRegionSelectorDialog::getSelectedImage(const TQPixmap &pixmap, TQWidget *parent )
87 {
88  KPixmapRegionSelectorDialog dialog(parent);
89 
90  dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
91 
92  TQDesktopWidget desktopWidget;
93  TQRect screen=desktopWidget.availableGeometry();
94  dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
95  (int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
96  int result = dialog.exec();
97 
98  TQImage image;
99 
100  if ( result == TQDialog::Accepted )
101  image = dialog.pixmapRegionSelectorWidget()->selectedImage();
102 
103  return image;
104 }
105 
106 TQImage KPixmapRegionSelectorDialog::getSelectedImage(const TQPixmap &pixmap, int aspectRatioWidth, int aspectRatioHeight, TQWidget *parent )
107 {
108  KPixmapRegionSelectorDialog dialog(parent);
109 
110  dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
111  dialog.pixmapRegionSelectorWidget()->setSelectionAspectRatio(aspectRatioWidth,aspectRatioHeight);
112 
113  TQDesktopWidget desktopWidget;
114  TQRect screen=desktopWidget.availableGeometry();
115  dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
116  (int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
117 
118  int result = dialog.exec();
119 
120  TQImage image;
121 
122  if ( result == TQDialog::Accepted )
123  image = dialog.pixmapRegionSelectorWidget()->selectedImage();
124 
125  return image;
126 }
127 
KDialogBase
A dialog base class with standard buttons and predefined layouts.
Definition: kdialogbase.h:192
KDialogBase::setMainWidget
void setMainWidget(TQWidget *widget)
Sets the main user definable widget.
Definition: kdialogbase.cpp:1431
KDialog::spacingHint
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
Definition: kdialog.cpp:110
KPixmapRegionSelectorDialog
A dialog that uses a KPixmapRegionSelectorWidget to allow the user to select a region of an image.
Definition: kpixmapregionselectordialog.h:43
KPixmapRegionSelectorDialog::~KPixmapRegionSelectorDialog
~KPixmapRegionSelectorDialog()
The destructor of the dialog.
Definition: kpixmapregionselectordialog.cpp:39
KPixmapRegionSelectorDialog::getSelectedRegion
static TQRect getSelectedRegion(const TQPixmap &pixmap, TQWidget *parent=0L)
Creates a modal dialog, lets the user to select a region of the pixmap and returns when the dialog is...
Definition: kpixmapregionselectordialog.cpp:43
KPixmapRegionSelectorDialog::getSelectedImage
static TQImage getSelectedImage(const TQPixmap &pixmap, TQWidget *parent=0L)
Creates a modal dialog, lets the user to select a region of the pixmap and returns when the dialog is...
Definition: kpixmapregionselectordialog.cpp:86
KPixmapRegionSelectorDialog::pixmapRegionSelectorWidget
KPixmapRegionSelectorWidget * pixmapRegionSelectorWidget() const
Definition: kpixmapregionselectordialog.h:61
KPixmapRegionSelectorDialog::KPixmapRegionSelectorDialog
KPixmapRegionSelectorDialog(TQWidget *parent=0L, const char *name=0L, bool modal=false)
The constructor of an empty KPixmapRegionSelectorDialog, you have to call later the setPixmap method ...
Definition: kpixmapregionselectordialog.cpp:27
KPixmapRegionSelectorWidget
KPixmapRegionSelectorWidget is a widget that shows a picture and provides the user with a friendly wa...
Definition: kpixmapregionselectorwidget.h:45
KPixmapRegionSelectorWidget::selectedImage
TQImage selectedImage() const
Definition: kpixmapregionselectorwidget.cpp:396
KPixmapRegionSelectorWidget::unzoomedSelectedRegion
TQRect unzoomedSelectedRegion() const
Returns the selected region ( in unzoomed, original pixmap coordinates )
Definition: kpixmapregionselectorwidget.cpp:388
KPixmapRegionSelectorWidget::setSelectionAspectRatio
void setSelectionAspectRatio(int width, int height)
Sets the aspect ration that the selected subimage should have.
Definition: kpixmapregionselectorwidget.cpp:402
KPixmapRegionSelectorWidget::setPixmap
void setPixmap(const TQPixmap &pixmap)
Sets the pixmap which will be shown for the user to select a region from.
Definition: kpixmapregionselectorwidget.cpp:67
KPixmapRegionSelectorWidget::setMaximumWidgetSize
void setMaximumWidgetSize(int width, int height)
Sets the maximum size for the widget.
Definition: kpixmapregionselectorwidget.cpp:412
tdelocale.h

tdeui

Skip menu "tdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeui

Skip menu "tdeui"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeui by doxygen 1.9.1
This website is maintained by Timothy Pearson.