1 /*
2 SANE EPSON backend
3 Copyright (C) 2001, 2005, 2008 SEIKO EPSON Corporation
4
5 Date Author Reason
6 06/01/2001 N.Sasaki New
7
8 This file is part of the `iscan' program.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 As a special exception, the copyright holders give permission
25 to link the code of this program with the esmod library and
26 distribute linked combinations including the two. You must obey
27 the GNU General Public License in all respects for all of the
28 code used other then esmod.
29 */
30
31 #ifndef ___PISA_VIEW_MANAGER_H
32 #define ___PISA_VIEW_MANAGER_H
33
34 #include "pisa_enums.h"
35
36 #include "pisa_settings.h"
37
38 #include "pisa_scan_manager.h"
39
40 #include "pisa_main_window.h"
41 #include "pisa_preview_window.h"
42 #include "pisa_progress_window.h"
43 #include "pisa_image_controls.h"
44 #include "pisa_gamma_correction.h"
45 #include "pisa_configuration.h"
46 #include "pisa_error.h"
47 #include "pisa_scan_selector.h"
48
49 #include "file-selector.h"
50
51 class view_manager
52 {
53 public:
54
55 // operation
56 static int create_view_manager ( int argc, char * argv [ ] );
57
58 void release_view_manager ( void );
59
60 int main ( void );
61
62 void init ( void );
63 void destroy ( void );
64
65 GtkWidget * create_window ( pisa_window_id id );
66 int close_window ( pisa_window_id id, int destroy_flag );
67 void * get_window_cls ( pisa_window_id id );
68
get_scan_manager(void)69 scan_manager * get_scan_manager ( void ) { return m_scanmanager_cls; }
70
71 void sensitive ( void );
72
73 int is_gimp ( void );
74
75 void start_scan ( void );
76
77 int update_lut (long index = -1);
78 int update_lut (marquee& m);
79
80 bool change_document_source (char option, char film, const imagetype *);
81 void set_device ( char * name );
82 char * get_device_name() const;
83
84 const settings& get_settings (void) const;
85 const marquee& get_marquee (long index = -1) const;
86 marquee& get_marquee (long index = -1);
87
88 void add_marquee (marquee **m);
89 void del_marquee (long index = -1);
90
91 long get_marquee_size () const;
92
93 void set_destination (long destination);
94 void set_resolution (long resolution);
95 void set_image_type (const imagetype *type);
96 void set_unit (long unit);
97 void enable_start_button (bool value);
98 void enable_unsharp_mask (bool value);
99
100 private:
101
102 // operation
103 void open_device ( void );
104 void close_device ( void );
105
106 void load_preference ( void );
107 void save_preference ( void );
108
109 int init_img_info ( pisa_option_type option, pisa_film_type film );
110
111 int init_scan_param (void);
112
113 int do_scan_file (file_selector *fs = 0,
114 bool first_time_around = true);
115 int do_scan_printer (int fd = -1,
116 bool first_time_around = true);
117 int do_scan_gimp (bool first_time_around = true);
118
119 bool scan_file (const char *filename, int *cancel,
120 bool first_time_around = true);
121 bool scan_gimp (int *cancel,
122 bool first_time_around = true);
123 int dialog_reply( const pisa_error& err ) const;
124
125 pisa_file_type get_file_type (const char * filename);
126 int get_temp_filename (char **filename);
127 int check_overwrite( const char *regexp );
128 void regerror( int code, regex_t *regex );
129
130 // attribute
131 settings m_set;
132
133 scan_manager * m_scanmanager_cls;
134
135 main_window * m_main_cls;
136 preview_window * m_prev_cls;
137 image_controls * m_imgctrl_cls;
138 gamma_correction * m_gamma_cls;
139 config_window * m_config_cls;
140 file_selector * m_filsel_cls;
141 scan_selector * m_scansel_cls;
142
143 progress_window *_feedback;
144 };
145
146 extern view_manager * g_view_manager;
147
148 inline const settings&
get_settings(void)149 view_manager::get_settings (void) const
150 {
151 return m_set;
152 }
153
154 inline const marquee&
get_marquee(long index)155 view_manager::get_marquee (long index) const
156 {
157 return m_set.get_marquee (index);
158 }
159
160 inline marquee&
get_marquee(long index)161 view_manager::get_marquee (long index)
162 {
163 return m_set.get_marquee (index);
164 }
165
166 inline long
get_marquee_size(void)167 view_manager::get_marquee_size (void) const
168 {
169 return m_set.get_marquee_size ();
170 }
171
172 inline void
add_marquee(marquee ** m)173 view_manager::add_marquee (marquee **m)
174 {
175 m_set.add_marquee (m);
176 }
177
178 inline void
del_marquee(long index)179 view_manager::del_marquee (long index)
180 {
181 m_set.del_marquee (index);
182 }
183
184 inline void
set_destination(long destination)185 view_manager::set_destination (long destination)
186 {
187 m_set.destination = destination;
188 }
189
190 inline void
set_resolution(long resolution)191 view_manager::set_resolution (long resolution)
192 {
193 m_set.resolution = resolution;
194 }
195
196 inline void
set_image_type(const imagetype * type)197 view_manager::set_image_type (const imagetype *type)
198 {
199 memcpy (&m_set.imgtype, type, sizeof (imagetype));
200 }
201
202 inline void
set_unit(long unit)203 view_manager::set_unit (long unit)
204 {
205 m_set.unit = unit;
206 }
207
208 inline void
enable_start_button(bool value)209 view_manager::enable_start_button (bool value)
210 {
211 m_set.enable_start_button = value;
212 }
213
214 inline void
enable_unsharp_mask(bool value)215 view_manager::enable_unsharp_mask (bool value)
216 {
217 m_set.usm = (value ? 1 : 0);
218 }
219
220
221 #endif // ___PISA_VIEW_MANAGER_H
222
223