1 /* view_area.h - headers for standard view area
2  *
3  * Copyright (C) 2003, 2007 Patrice St-Gelais
4  *         patrstg@users.sourceforge.net
5  *         www.oricom.ca/patrice.st-gelais
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 
22 #ifndef _VIEW_AREA
23 #define _VIEW_AREA 1
24 
25 #include <gtk/gtk.h>
26 
27 typedef struct {
28 //	Simple struct for a view / preview area
29 	GtkWidget *area;
30 	GtkWidget *viewport; // used only if the area is scrollable, for rescaling
31 	gint width;
32 	gint height;
33 	unsigned char *buf8;
34 //	The function used in the area callbacks, for recalculating the image
35 //	"buf8" is the output, it is normally equal to this->buf8
36 //	"width" and "height" are this->width and this->height
37 	void (*calc_buf) (gpointer external_data, unsigned char *buf8, gint width, gint height);
38 //	Embedded data, to apply on calc_buf
39 	gpointer external_data;
40 	gboolean if_rgb; // TRUE if buf8 is a RGB buffer
41 } view_struct;
42 
43 view_struct *view_struct_new (
44 	gint width,
45 	gint height,
46 	void (*calc_buf) (gpointer, unsigned char *, gint, gint),
47 	gpointer external_data);
48 view_struct *view_struct_new_with_rgb (
49 	gint width,
50 	gint height,
51 	void (*calc_buf) (gpointer, unsigned char *, gint, gint),
52 	gpointer external_data,
53 	gboolean if_rgb);
54 void view_struct_free (view_struct * vs);
55 void draw_area (view_struct *vs);
56 void draw_area_callb (GtkWidget *wdg, gpointer view_struct_ptr);
57 void resize_area (view_struct *vs, gint new_width, gint new_height);
58 
59 #endif // VIEW_AREA
60 
61