~ubuntu-branches/ubuntu/edgy/digikam/edgy-updates

« back to all changes in this revision

Viewing changes to digikam/libs/widgets/imageselectionwidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Achim Bohnet
  • Date: 2005-03-10 02:39:02 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050310023902-023nymfst5mg696c
Tags: 0.7.2-2
* debian/TODO: clean
* digikam manpage: better --detect-camera description

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 * Author: Gilles Caulier <caulier dot gilles at free.fr>
 
3
 * Date  : 2004-12-09
 
4
 * Description : 
 
5
 * 
 
6
 * Copyright 2004 by Gilles Caulier
 
7
 *
 
8
 * This program is free software; you can redistribute it
 
9
 * and/or modify it under the terms of the GNU General
 
10
 * Public License as published by the Free Software Foundation;
 
11
 * either version 2, or (at your option)
 
12
 * any later version.
 
13
 * 
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 * 
 
19
 * ============================================================ */
 
20
 
 
21
#ifndef IMAGESELECTIONWIDGET_H
 
22
#define IMAGESELECTIONWIDGET_H
 
23
 
 
24
// Qt includes.
 
25
 
 
26
#include <qwidget.h>
 
27
#include <qrect.h>
 
28
 
 
29
class QPixmap;
 
30
class QTimer;
 
31
 
 
32
namespace Digikam
 
33
{
 
34
 
 
35
class ImageIface;
 
36
 
 
37
class ImageSelectionWidget : public QWidget
 
38
{
 
39
Q_OBJECT
 
40
 
 
41
public:
 
42
    
 
43
    enum RatioAspect           // Contrained Aspect Ratio list.
 
44
    {
 
45
    RATIOCUSTOM=0,             // Custom aspect ratio.
 
46
    RATIO01X01,                // 1:1
 
47
    RATIO02x03,                // 2:3
 
48
    RATIO03X04,                // 3:4
 
49
    RATIO04X05,                // 4:5
 
50
    RATIO05x07,                // 5:7
 
51
    RATIO07x10,                // 7:10
 
52
    RATIONONE                  // No aspect ratio.
 
53
    };
 
54
 
 
55
    enum Orient  
 
56
    {
 
57
    Landscape = 0,
 
58
    Paysage
 
59
    };
 
60
 
 
61
    ImageSelectionWidget(int width, int height, QWidget *parent=0, 
 
62
                         float aspectRatioValue=1.0, int aspectRatio=RATIO01X01, 
 
63
                         int orient=Landscape, bool ruleThirdLines=false);
 
64
    ~ImageSelectionWidget();
 
65
 
 
66
    void  setCenterSelection(void);
 
67
    void  setSelectionX(int x);
 
68
    void  setSelectionY(int y);
 
69
    void  setSelectionWidth(int w);
 
70
    void  setSelectionHeight(int h);
 
71
    void  setSelectionOrientation(int orient);
 
72
    void  setSelectionAspectRatioType(int aspectRatioType);
 
73
    void  setSelectionAspectRatioValue(float aspectRatioValue);
 
74
    
 
75
    int   getOriginalImageWidth(void);
 
76
    int   getOriginalImageHeight(void);
 
77
    QRect getRegionSelection(void);
 
78
    
 
79
    int   getMinWidthRange(void);
 
80
    int   getMinHeightRange(void);
 
81
    
 
82
    void  resetSelection(void);
 
83
    void  maxAspectSelection(void);
 
84
 
 
85
public slots:
 
86
 
 
87
    void slotRuleThirdLines(bool ruleThirdLines);
 
88
    
 
89
signals:
 
90
 
 
91
    void signalSelectionMoved( QRect rect );     
 
92
    void signalSelectionChanged( QRect rect );   
 
93
    void signalSelectionWidthChanged( int newWidth ); 
 
94
    void signalSelectionHeightChanged( int newHeight ); 
 
95
    
 
96
protected:
 
97
    
 
98
    void paintEvent( QPaintEvent *e );
 
99
    void mousePressEvent ( QMouseEvent * e );
 
100
    void mouseReleaseEvent ( QMouseEvent * e );
 
101
    void mouseMoveEvent ( QMouseEvent * e );
 
102
 
 
103
protected slots:
 
104
 
 
105
    void slotTimerDone(void);
 
106
                
 
107
private:
 
108
 
 
109
    enum ResizingMode
 
110
    {
 
111
    ResizingNone = 0,
 
112
    ResizingTopLeft,
 
113
    ResizingTopRight, 
 
114
    ResizingBottomLeft,   
 
115
    ResizingBottomRight
 
116
    };
 
117
    
 
118
    ImageIface *m_iface;
 
119
    
 
120
    bool        m_ruleThirdLines;
 
121
    
 
122
    uint       *m_data;
 
123
    int         m_w;
 
124
    int         m_h;
 
125
    
 
126
    int         m_xpos;
 
127
    int         m_ypos;
 
128
 
 
129
    QRect       m_rect;                    
 
130
    QRect       m_regionSelection;         // Real size image selection.
 
131
    QRect       m_localRegionSelection;    // Local size selection.
 
132
    
 
133
    // Draggable local region selection corners.
 
134
    QRect       m_localTopLeftCorner;
 
135
    QRect       m_localBottomLeftCorner;
 
136
    QRect       m_localTopRightCorner;
 
137
    QRect       m_localBottomRightCorner;
 
138
    
 
139
    QPixmap    *m_pixmap;
 
140
    
 
141
    QTimer     *m_timerW;
 
142
    QTimer     *m_timerH;
 
143
    
 
144
    int         m_currentAspectRatioType;
 
145
    int         m_currentAspectRatio;
 
146
    int         m_currentResizing;
 
147
    int         m_currentOrientation;
 
148
    
 
149
    float       m_currentAspectRatioValue;
 
150
    
 
151
    // Recalculate the target selection position and emit 'signalSelectionMoved'.
 
152
    void regionSelectionMoved( bool targetDone );
 
153
    
 
154
    void regionSelectionChanged(bool targetDone);
 
155
    void realToLocalRegion(bool updateSizeOnly=false);
 
156
    void localToRealRegion(void);
 
157
    void applyAspectRatio(bool WOrH, bool repaintWidget=true, bool updateChange=true);
 
158
    void updatePixmap(void);
 
159
};
 
160
 
 
161
}  // NameSpace Digikam
 
162
 
 
163
#endif /* IMAGESELECTIONWIDGET_H */