summaryrefslogtreecommitdiffstats
path: root/kooka/kookaview.h
blob: 90160cbf33d819cbca45c52f014d917feb985274 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/***************************************************************************
                          kookaview.h  -  Main view
                             -------------------
    begin                : Sun Jan 16 2000
    copyright            : (C) 2000 by Klaas Freitag
    email                : freitag@suse.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *  This file may be distributed and/or modified under the terms of the    *
 *  GNU General Public License version 2 as published by the Free Software *
 *  Foundation and appearing in the file COPYING included in the           *
 *  packaging of this file.                                                *
 *
 *  As a special exception, permission is given to link this program       *
 *  with any version of the KADMOS ocr/icr engine of reRecognition GmbH,   *
 *  Kreuzlingen and distribute the resulting executable without            *
 *  including the source code for KADMOS in the source distribution.       *
 *
 *  As a special exception, permission is given to link this program       *
 *  with any edition of TQt, and distribute the resulting executable,       *
 *  without including the source code for TQt in the source distribution.   *
 *                                                                         *
 ***************************************************************************/
#ifndef KOOKAVIEW_H
#define KOOKAVIEW_H

#include <tqwidget.h>
#include <kopenwith.h>
#include "kookaiface.h"
#include <kdockwidget.h>
#include <tqtabwidget.h>
#include <tqlayout.h>
#include <tqimage.h>
#include <tqsplitter.h>

#include <tdeparts/dockmainwindow.h>
#include <tdeparts/part.h>

// application specific includes
#include "kscandevice.h"
#include "previewer.h"
#include "scanpackager.h"
#include "scanparams.h"
#include "img_canvas.h"

class KDockWidget;
class TQPainter;
class KSANEOCR;
class TDEConfig;
class KPrinter;
class KComboBox;
class TDEAction;
class TDEActionCollection;
class ThumbView;
class KookaImage;
class TQPixmap;
class ocrResEdit;
/**
 * This is the main view class for Kooka.  Most of the non-menu,
 * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
 * here.
 *
 * @short Main view
 * @author Klaas Freitag <freitag@suse.de>
 * @version 0.1
 */
class KookaView : public TQObject
{
    TQ_OBJECT
  
public:
    typedef enum { MirrorVertical, MirrorHorizontal, MirrorBoth } MirrorType;
    typedef enum { StatusTemp, StatusImage } StatusBarIDs;

    /**
     * Default constructor
     */
    KookaView(KParts::DockMainWindow *parent, const TQCString& deviceToUse);

    /**
     * Destructor
     */
    virtual ~KookaView();

    /**
     * Print this view to any medium -- paper or not
     */
    void print( );

    bool ToggleVisibility( int );
    void loadStartupImage( void );
    KDockWidget *mainDockWidget( ) { return m_mainDock; }

    void createDockMenu( TDEActionCollection*, KDockMainWindow *, const char *);

    ScanPackager *gallery() { return packager; }

    // KParts::Part* ocrResultPart() { return m_textEdit; }

    ImageCanvas *getImageViewer() { return img_canvas; }
public slots:
    void slShowPreview()  {  }
    void slShowPackager() {  }
    void slNewPreview( TQImage *, ImgScanInfo * );

    void slSetScanParamsVisible( bool v )
        { if( v ) scan_params->show(); else scan_params->hide(); }
    void slSetTabWVisible( bool v )
        { if( v ) preview_canvas->show(); else preview_canvas->hide(); }

    void doOCR( void );
    void doOCRonSelection( void );

    void slStartPreview() { if( scan_params ) scan_params->slAcquirePreview(); }
    void slStartFinalScan() { if( scan_params ) scan_params->slStartScan(); }

    void slCreateNewImgFromSelection( void );

    void slRotateImage( int );

    void slMirrorImage( MirrorType );

    void slIVScaleToWidth( void )
        { if( img_canvas ) img_canvas->handle_popup(ImageCanvas::ID_FIT_WIDTH );}
    void slIVScaleToHeight( void )
        { if( img_canvas ) img_canvas->handle_popup(ImageCanvas::ID_FIT_HEIGHT );}
    void slIVScaleOriginal( void )
        { if( img_canvas ) img_canvas->handle_popup(ImageCanvas::ID_ORIG_SIZE ); }
    void slIVShowZoomDialog( )
        { if( img_canvas ) img_canvas->handle_popup(ImageCanvas::ID_POP_ZOOM ); }

    void slOpenCurrInGraphApp( void );

    void slSaveOCRResult();

    void slLoadScanParams( );
    void slSaveScanParams( );

    void slOCRResultImage( const TQPixmap& );

    void slShowThumbnails( KFileTreeViewItem *dirKfi = 0, bool forceRedraw=false);
     void slFreshUpThumbView();

    /**
     * slot that show the image viewer
     */
    void slStartLoading( const KURL& url );
    /**
     * starts ocr on the image the parameter is pointing to
     **/
    void startOCR( KookaImage* );

    void  slCloseScanDevice();
    void saveProperties( TDEConfig* );

    /**
     * slot to select the scanner device. Does all the work with selection
     * of scanner, disconnection of the old device and connecting the new.
     */
    bool slSelectDevice(const TQCString& useDevice=TQCString());

    void connectViewerAction( TDEAction *action );
    void connectGalleryAction( TDEAction *action );

    void slScanStart();
    void slScanFinished( KScanStat stat );
    void slAcquireStart();


protected slots:

    void  slShowAImage( KookaImage* );
    void  slUnloadAImage( KookaImage* );

    /**
     * called from the scandevice if a new Image was successfully scanned.
     * Needs to convert the one-page-TQImage to a KookaImage
     */
    void slNewImageScanned(TQImage*, ImgScanInfo*);

    /**
     * called if an viewer image was set to read only or back to read write state.
     */
    void slViewerReadOnly( bool ro );
signals:
    /**
     * Use this signal to change the content of the statusbar
     */
    void signalChangeStatusbar(const TQString& text);

    /**
     * Use this signal to clean up the statusbar
     */
    void signalCleanStatusbar( void );

    /**
     * Use this signal to change the content of the caption
     */
    void signalChangeCaption(const TQString& text);

private:
    TQImage rotateRight( TQImage* );
    TQImage rotateLeft ( TQImage* );
    TQImage rotate180  ( TQImage* );
    TQCString userDeviceSelection( ) const;

    void updateCurrImage( TQImage& ) ;

    ImageCanvas  *img_canvas;
    ThumbView    *m_thumbview;

    Previewer    *preview_canvas;
    ScanPackager *packager;
    ScanParams   *scan_params;

    KScanDevice  *sane;
    KComboBox    *recentFolder;

    TQCString     connectedDevice;

    TQImage       *m_ocrResultImg;
    int          image_pool_id;
    int 	 preview_id;

    KSANEOCR *ocrFabric;

    KDockWidget *m_mainDock;
    KDockWidget *m_dockScanParam;
    KDockWidget *m_dockThumbs;
    KDockWidget *m_dockPackager;
    KDockWidget *m_dockRecent;
    KDockWidget *m_dockPreview;
    KDockWidget *m_dockOCRText;

    TDEMainWindow *m_mainWindow;

    ocrResEdit  *m_ocrResEdit;
};

#endif // KOOKAVIEW_H