1 /*
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * This is a plug-in for GIMP.
5  *
6  * Generates images containing vector type drawings.
7  *
8  * Copyright (C) 1997 Andy Thomas  alt@picnic.demon.co.uk
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 3 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, see <https://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef __GFIG_DOBJECT_H__
25 #define __GFIG_DOBJECT_H__
26 
27 #include "gfig-types.h"
28 #include "gfig-style.h"
29 
30 typedef void        (*DobjDrawFunc)   (GfigObject *, cairo_t *);
31 typedef void        (*DobjFunc)       (GfigObject *);
32 typedef GfigObject *(*DobjGenFunc)    (GfigObject *);
33 
34 typedef struct DobjPoints
35 {
36   struct DobjPoints *next;
37   GdkPoint           pnt;
38   gboolean           found_me;
39 } DobjPoints;
40 
41 typedef struct
42 {
43   DobjType      type;       /* the object type for this class */
44   const gchar  *name;
45 
46   /* virtuals */
47   DobjDrawFunc  drawfunc;   /* How do I draw myself */
48   DobjFunc      paintfunc;  /* Draw me on canvas */
49   DobjGenFunc   copyfunc;   /* copy */
50   void         (*update) (GdkPoint   *pnt);
51 } GfigObjectClass;
52 
53 extern GfigObjectClass dobj_class[10];
54 
55 /* The object itself */
56 struct _GfigObject
57 {
58   DobjType         type;       /* What is the type? */
59   GfigObjectClass *class;      /* What class does it belong to? */
60   gint             type_data;  /* Extra data needed by the object */
61   DobjPoints      *points;     /* List of points */
62   Style            style;      /* this object's individual style settings */
63   gint             style_no;   /* style index of this specific object */
64 };
65 
66 /* States of the object */
67 #define GFIG_OK       0x0
68 #define GFIG_MODIFIED 0x1
69 #define GFIG_READONLY 0x2
70 
71 extern GfigObject *obj_creating;
72 extern GfigObject *tmp_line;
73 
74 
75 DobjPoints *new_dobjpoint            (gint        x,
76                                       gint        y);
77 void        do_save_obj              (GfigObject *obj,
78                                       GString    *to);
79 
80 DobjPoints *d_copy_dobjpoints        (DobjPoints *pnts);
81 void        free_one_obj             (GfigObject *obj);
82 void        d_delete_dobjpoints      (DobjPoints *pnts);
83 void        object_update            (GdkPoint   *pnt);
84 GList      *copy_all_objs            (GList      *objs);
85 void        draw_objects             (GList      *objs,
86                                       gboolean    show_single,
87                                       cairo_t    *cr);
88 
89 GfigObject *d_load_object            (gchar      *desc,
90                                       FILE       *fp);
91 
92 GfigObject *d_new_object             (DobjType    type,
93                                       gint        x,
94                                       gint        y);
95 
96 void        d_save_object            (GfigObject *obj,
97                                       GString    *string);
98 
99 void        free_all_objs            (GList      *objs);
100 
101 void        clear_undo               (void);
102 
103 void        new_obj_2edit            (GFigObj    *obj);
104 
105 void        gfig_init_object_classes (void);
106 
107 void        d_pnt_add_line           (GfigObject *obj,
108                                       gint        x,
109                                       gint        y,
110                                       gint        pos);
111 
112 #endif /* __GFIG_DOBJECT_H__ */
113 
114 
115