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_STRUCTS_H
32 #define ___PISA_STRUCTS_H
33 
34 #ifdef HAVE_CONFIG_H
35 #include <config.h>
36 #endif
37 
38 #ifdef HAVE_GTK_GTK_H
39 #include <gtk/gtk.h>
40 #ifndef HAVE_GTK_2
41 #include <gdk_imlib.h>
42 #endif
43 #endif
44 
45 // scanner
46 /*--------------------------------------------------------------*/
47 typedef struct _gamma_struct
48 {
49   unsigned char gamma_r [ 256 ];
50   unsigned char gamma_g [ 256 ];
51   unsigned char gamma_b [ 256 ];
52 } gamma_struct;
53 
54 
55 /*--------------------------------------------------------------*/
56 typedef struct _imagetype
57 {
58   long		id;
59   char		pixeltype;
60   char		bitdepth;
61   char		scanspeed;
62   char		de_screening;
63   char		ae_option;
64   char		dropout;
65   char		monoopt;
66   char		halftone;
67 } imagetype;
68 
69 // ui
70 /*--------------------------------------------------------------*/
71 template <class Type>
72 struct _point
73 {
74   Type	x, y;
75 
_point_point76   _point ( ) { x = y = 0; }
77   _point ( Type u, Type v = 0 ) { x = u, y = v; }
_point_point78   _point ( const _point & pt ) { x = pt.x; y = pt.y; }
79   _point & operator= ( const _point & pt )
80   {
81     if ( & pt != this )
82       {
83 	x = pt.x;
84 	y = pt.y;
85       }
86     return ( * this );
87   }
88 
89   // == operator
90   friend int operator== ( const _point & pt1, const _point & pt2 )
91   {
92     return ( pt1.x == pt2.x && pt1.y == pt2.y );
93   }
94 
95   // - operator
96   friend _point operator- ( const _point & pt1, const _point & pt2 )
97   {
98     return ( _point ( pt1.x - pt2.x, pt1.y - pt2.y ) );
99   }
100 
101   // + operator
102   friend _point operator+ ( const _point & pt1, const _point & pt2 )
103   {
104     return ( _point ( pt1.x + pt2.x, pt1.y + pt2.y ) );
105   }
106 };
107 
108 typedef _point <double>	_pointD;
109 typedef _point <long>	_pointL;
110 
111 /*--------------------------------------------------------------*/
112 template <class Type>
113 struct _rect
114 {
115   Type	top, bottom, right, left;
116 
_rect_rect117   _rect ( ) { top = bottom = right = left = Type ( 0 ); }
_rect_rect118   _rect ( Type _top, Type _bottom, Type _right, Type _left ):
119     top ( _top ), bottom ( _bottom ), right ( _right ), left ( _left ) { }
_rect_rect120   _rect ( const _rect & x )
121   {
122     top = x.top, bottom = x.bottom;
123     right = x.right, left = x.left;
124   }
125   _rect & operator= ( const _rect & x )
126   {
127     if ( & x != this )
128       {
129 	top = x.top, bottom = x.bottom;
130 	right = x.right, left = x.left;
131       }
132     return ( * this );
133   }
134 
135   // == operator
136   friend int operator== ( const _rect & rc1, const _rect & rc2 )
137   {
138     return ( rc1.top == rc2.top && rc1.bottom == rc2.bottom &&
139 	     rc1.right == rc2.right && rc1.left == rc2.left );
140   }
141 
142   // - operator
143   friend _rect operator- ( const _rect & rc1, const _rect & rc2 )
144   {
145     return ( _rect ( rc1.top - rc2.top, rc1.bottom - rc2.bottom,
146 		     rc1.right - rc2.right, rc1.left - rc2.left ) );
147   }
148 
149   // + operator
150   friend _rect operator+ ( const _rect & rc1, const _rect & rc2 )
151   {
152     return ( _rect ( rc1.top + rc2.top, rc1.bottom + rc2.bottom,
153 		     rc1.right + rc2.right, rc1.left + rc2.left ) );
154   }
155 
156   // empty?
is_rect_empty_rect157   friend int is_rect_empty ( const _rect & rc )
158   {
159     return ( rc.top == 0 && rc.bottom == 0 && rc.right == 0 && rc.left == 0 );
160   }
161 };
162 
163 typedef _rect <_point <long> >	_rectPL;
164 typedef _rect <double>		_rectD;
165 typedef _rect <long>		_rectL;
166 
167 
168 #ifdef HAVE_GTK_GTK_H
169 /*--------------------------------------------------------------*/
170 typedef struct _toolbar_items
171 {
172   GtkWidget		* widget;
173   char			** xpm;
174   GtkSignalFunc		* func;
175 } toolbar_items;
176 
177 /*--------------------------------------------------------------*/
178 typedef struct _menu_items
179 {
180   long			id;
181   GtkWidget		* widget;
182   char			name [ 64 ];
183   GtkSignalFunc		* func;
184 } menu_items;
185 
186 
187 /*------------------------------------------------------------*/
188 typedef struct _scale_items
189 {
190   long			id;
191   GtkWidget		* widget;
192   GtkAdjustment		* adjust;
193   GtkSignalFunc		* func;
194   float			val;
195   float			min;
196   float			max;
197   float			step;
198   float			page;
199 } scale_items;
200 #endif
201 
202 typedef struct
203 {
204   unsigned char		* m_img;
205   long			m_width;
206   long			m_height;
207   long			m_rowbytes;
208 } _pisa_image_info;
209 
210 #include <cstddef>
211 
212 class pisa_image_info : public _pisa_image_info
213 {
214 public:
215   size_t m_bits_per_pixel;
216 
pisa_image_info()217   pisa_image_info () : m_bits_per_pixel (24)
218     {
219       m_img = 0;
220       m_width = 0;
221       m_height = 0;
222       m_rowbytes = 0;
223     };
224 };
225 
226 #endif // ___PISA_STRUCTS_H
227 
228