1 /* $Id: selection.h,v 1.2 2004/03/13 03:32:27 meffie Exp $
2 *
3 * GNU Paint
4 * Copyright 2000-2003, 2007 Li-Cheng (Andy) Tai
5 *
6 * Authors: Li-Cheng (Andy) Tai <atai@gnu.org>
7 * Michael A. Meffie III <meffiem@neo.rr.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 3
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be
15 * useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17 * PURPOSE. See the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #ifndef __SELECTION_H__
24 #define __SELECTION_H__
25
26 #include <gtk/gtk.h>
27
28 typedef struct _gpaint_point_array gpaint_point_array;
29 typedef struct _gpaint_selection gpaint_selection;
30 typedef struct _gpaint_point gpaint_point;
31
32
33 /* Simple point structure. Like a GdkPoint, but with an extra
34 * field to signify if the point has been defined. */
35 struct _gpaint_point
36 {
37 gboolean defined;
38 gint x;
39 gint y;
40 };
41
set_point(gpaint_point * p,gint x,gint y)42 inline static void set_point(gpaint_point *p, gint x, gint y)
43 {
44 p->defined = TRUE;
45 p->x = x;
46 p->y = y;
47 }
48
clear_point(gpaint_point * p)49 inline static void clear_point(gpaint_point *p)
50 {
51 p->defined = FALSE;
52 }
53
is_point_defined(gpaint_point * p)54 inline static gboolean is_point_defined(gpaint_point *p)
55 {
56 return p->defined;
57 }
58
59
60 gpaint_point_array * point_array_new();
61 void point_array_delete(gpaint_point_array *pa);
62 int point_array_size(gpaint_point_array *pa);
63 GdkPoint* point_array_data(gpaint_point_array *pa);
64 void point_array_set(gpaint_point_array *pa, int index, int x, int y);
65 void point_array_append(gpaint_point_array *pa, int x, int y);
66 void point_array_remove_all(gpaint_point_array *pa);
67 void point_array_copy(gpaint_point_array *dst, gpaint_point_array *src);
68 void point_array_bounding_rectangle(gpaint_point_array *pa, GdkRectangle *rp);
69
70
71 gpaint_selection * selection_new(GtkDrawingArea *drawing_area);
72 void selection_delete(gpaint_selection *selection);
73 void selection_size(gpaint_selection *selection, int width, int height);
74 gpaint_point_array* selection_points(gpaint_selection *selection);
75 int selection_num_points(gpaint_selection *selection);
76 GdkPoint* selection_data(gpaint_selection *selection);
77 void selection_set_rectangle(gpaint_selection *selection, GdkRectangle rect);
78 void selection_set_points(gpaint_selection *selection, gpaint_point_array *points);
79 void selection_add_point(gpaint_selection *selection, int x, int y);
80 void selection_change_last(gpaint_selection *selection, int x, int y);
81 void selection_remove_points(gpaint_selection *selection);
82 void selection_close_loop(gpaint_selection *selection);
83 void selection_move(gpaint_selection *selection, int x, int y);
84 void selection_clear_flash(gpaint_selection *selection);
85 void selection_draw_flash(gpaint_selection *selection);
86 void selection_enable_flash(gpaint_selection *selection);
87 void selection_disable_flash(gpaint_selection *selection);
88
89 #endif
90