summaryrefslogtreecommitdiffstats
path: root/libkscan/previewer.h
blob: 6d9a7b105d23c473eaebdd5cf364a2604abdf150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* This file is part of the KDE Project
   Copyright (C) 2000 Klaas Freitag <freitag@suse.de>

   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.
*/

#ifndef PREVIEWER_H
#define PREVIEWER_H

#include <tqwidget.h>
#include <tqimage.h>
#include <tqrect.h>
#include <tqbuttongroup.h>
#include <tqpoint.h>

#include <kruler.h>
#include <tqmemarray.h>

/**
  *@author Klaas Freitag
  */
class ImageCanvas;
class TQCheckBox;
class TQSlider;
class KScanDevice;
class TQComboBox;
class TQRadioButton;
class TQHBoxLayout;

class Previewer : public QWidget
{
    Q_OBJECT
public:
    Previewer(TQWidget *parent=0, const char *name=0);
    ~Previewer();

    ImageCanvas *getImageCanvas( void ){ return( img_canvas ); }

    /**
     * Static function that returns the image gallery base dir.
     */
    static TQString galleryRoot();
    bool setPreviewImage( const TQImage &image );
    void findSelection();

public slots:
    void newImage( TQImage* );
    void slFormatChange( int id );
    void slOrientChange(int);
    void slSetDisplayUnit( KRuler::MetricStyle unit );
    void setScanSize( int w, int h, KRuler::MetricStyle unit );
    void slCustomChange( void );
    void slNewDimen(TQRect r);
    void slNewScanResolutions( int, int );
    void recalcFileSize( void );
    void slSetAutoSelThresh(int);
    void slSetAutoSelDustsize(int);
    void slSetScannerBgIsWhite(bool b);
    void slConnectScanner( KScanDevice *scan );
protected slots:
    void slScaleToWidth();
    void slScaleToHeight();
    void slAutoSelToggled(bool);
    void slScanBackgroundChanged(int);

signals:
    void newRect( TQRect );
    void noRect( void );
    void setScanWidth(const TQString&);
    void setScanHeight(const TQString&);
    void setSelectionSize( long );

private:
    void checkForScannerBg();

    TQPoint calcPercent( int, int );

    TQHBoxLayout *layout;
    ImageCanvas *img_canvas;
    TQComboBox   *pre_format_combo;
    TQMemArray<TQCString> format_ids;
    TQButtonGroup * bgroup;
    TQRadioButton * rb1;
    TQRadioButton * rb2;
    TQImage       m_previewImage;

    bool imagePiece( TQMemArray<long> src,
                     int& start,
                     int& end );

    int landscape_id, portrait_id;

    double overallWidth, overallHeight;
    KRuler::MetricStyle sizeUnit;
    KRuler::MetricStyle displayUnit;
    bool isCustom;

    int  scanResX, scanResY;
    int  pix_per_byte;
    double selectionWidthMm;
    double selectionHeightMm;

    class PreviewerPrivate;
    PreviewerPrivate *d;
};

#endif