AlbumShaper  1.0a3
selectionPlacementInterface.h
Go to the documentation of this file.
1 //==============================================
2 // copyright : (C) 2003-2005 by Will Stokes
3 //==============================================
4 // This program is free software; you can redistribute it
5 // and/or modify it under the terms of the GNU General
6 // Public License as published by the Free Software
7 // Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //==============================================
10 
11 #ifndef GUI_EDITING_SELECTIONPLACEMENTINTERFACE_H
12 #define GUI_EDITING_SELECTIONPLACEMENTINTERFACE_H
13 
14 //--------------------
15 //forward declarations
16 //--------------------
17 
18 #include <qwidget.h>
19 #include <qimage.h>
20 #include <qpoint.h>
21 #include <qsize.h>
22 //Added by qt3to4:
23 #include <QPaintEvent>
24 #include <QMouseEvent>
25 
26 //=====================================
28 //=====================================
30 {
31 Q_OBJECT
32 
33 public:
35  SelectionPlacementInterface(QString imageFilename,
36  QWidget *parent=0,
37  const char* name=0);
38 
41 
43  QRect getSelectedRegion();
44 
46  void setSelectedRegion(QRect selection);
47 
48  virtual QSize sizeHint() const;
49  virtual QSize minimumSizeHint() const;
50  //----------------------
51 protected:
52  void paintEvent( QPaintEvent *e);
53  void mousePressEvent( QMouseEvent *e);
54  void mouseReleaseEvent( QMouseEvent *);
55  void mouseMoveEvent( QMouseEvent *e);
56  //----------------------
57 private:
59  QRect imageToDisplay( QRect r );
60 
62  bool overRegion( QPoint p );
63 
65  void recenterSelection(QPoint mousePosition);
66 
68  QImage scaledImage;
69 
72 
74  QSize origImageSize;
75 
77  QRect selection;
78 
82 
86  //----------------------
87 signals:
88  //emitted as the user drags the selection around
89  void placementChanged( QRect );
90  //----------------------
91 };
92 //======================
93 
94 #endif //GUI_EDITING_SELECTIONPLACEMENTINTERFACE_H
bool currentlyDragging
dragging the mouse only moves the selection if the mouse button is pressed first over the selected re...
QRect getSelectedRegion()
Returns the selected region in image space.
void recenterSelection(QPoint mousePosition)
util function used to center selection about mouse location
QRect imageToDisplay(QRect r)
convert rectangle from image coordinates to display coordinates
QSize origImageSize
original image dimensions
QImage unselectedScaledImage
Unselected scaled image (desaturated version of scaled image)
A selection region placement interface.
void setSelectedRegion(QRect selection)
Set the select region using image space coordinates.
bool currentMouseShapeIsDrag
current mouse shape.
QImage scaledImage
Scaled image used for display purposes.
bool overRegion(QPoint p)
util function used to determine if mouse is over selected region
SelectionPlacementInterface(QString imageFilename, QWidget *parent=0, const char *name=0)
Creates layout.