1 /* ADG - Automatic Drawing Generation
2 * Copyright (C) 2007,2008,2009 Nicola Fontana <ntd at entidi.it>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #ifndef __ADG_ENTITY_H__
22 #define __ADG_ENTITY_H__
24 #include <adg/adg-context.h>
25 #include <adg/adg-matrix.h>
26 #include <adg/adg-point.h>
27 #include <adg/adg-line-style.h>
28 #include <adg/adg-font-style.h>
29 #include <adg/adg-arrow-style.h>
30 #include <adg/adg-dim-style.h>
35 /* Forward declarations */
36 typedef struct _AdgCanvas AdgCanvas
;
37 typedef struct _AdgContainer AdgContainer
;
40 #define ADG_TYPE_ENTITY (adg_entity_get_type ())
41 #define ADG_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ADG_TYPE_ENTITY, AdgEntity))
42 #define ADG_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ADG_TYPE_ENTITY, AdgEntityClass))
43 #define ADG_IS_ENTITY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ADG_TYPE_ENTITY))
44 #define ADG_IS_ENTITY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ADG_TYPE_ENTITY))
45 #define ADG_ENTITY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ADG_TYPE_ENTITY, AdgEntityClass))
48 typedef struct _AdgEntity AdgEntity
;
49 typedef struct _AdgEntityClass AdgEntityClass
;
54 GInitiallyUnowned parent
;
58 struct _AdgEntityClass
{
60 GInitiallyUnownedClass parent_class
;
64 void (*parent_set
) (AdgEntity
*entity
,
65 AdgContainer
*old_parent
);
66 void (*model_matrix_changed
) (AdgEntity
*entity
,
67 AdgMatrix
*parent_matrix
);
68 void (*paper_matrix_changed
) (AdgEntity
*entity
,
69 AdgMatrix
*parent_matrix
);
70 void (*invalidate
) (AdgEntity
*entity
);
71 void (*render
) (AdgEntity
*entity
,
74 AdgContainer
* (*get_parent
) (AdgEntity
*entity
);
75 void (*set_parent
) (AdgEntity
*entity
,
76 AdgContainer
*parent
);
77 AdgContext
* (*get_context
) (AdgEntity
*entity
);
78 const AdgMatrix
* (*get_model_matrix
) (AdgEntity
*entity
);
79 const AdgMatrix
* (*get_paper_matrix
) (AdgEntity
*entity
);
83 #define ADG_CALLBACK(f) ((AdgCallback) (f))
86 typedef void (*AdgCallback
)(AdgEntity
*entity
, cairo_t
*cr
, gpointer user_data
);
89 GType
adg_entity_get_type (void) G_GNUC_CONST
;
90 AdgCanvas
* adg_entity_get_canvas (AdgEntity
*entity
);
92 AdgContainer
* adg_entity_get_parent (AdgEntity
*entity
);
93 void adg_entity_set_parent (AdgEntity
*entity
,
94 AdgContainer
*parent
);
95 void adg_entity_unparent (AdgEntity
*entity
);
96 void adg_entity_reparent (AdgEntity
*entity
,
97 AdgContainer
*parent
);
98 AdgContext
* adg_entity_get_context (AdgEntity
*entity
);
99 void adg_entity_set_context (AdgEntity
*entity
,
100 AdgContext
*context
);
101 const AdgMatrix
*adg_entity_get_model_matrix (AdgEntity
*entity
);
102 const AdgMatrix
*adg_entity_get_paper_matrix (AdgEntity
*entity
);
103 gboolean
adg_entity_build_paper2model (AdgEntity
*entity
,
105 gboolean
adg_entity_build_model2paper (AdgEntity
*entity
,
107 void adg_entity_scale_to_model (AdgEntity
*entity
,
109 void adg_entity_scale_to_paper (AdgEntity
*entity
,
111 void adg_entity_model_matrix_changed (AdgEntity
*entity
,
112 const AdgMatrix
*parent_matrix
);
113 void adg_entity_paper_matrix_changed (AdgEntity
*entity
,
114 const AdgMatrix
*parent_matrix
);
115 AdgStyle
* adg_entity_get_style (AdgEntity
*entity
,
116 AdgStyleSlot style_slot
);
117 void adg_entity_apply (AdgEntity
*entity
,
118 AdgStyleSlot style_slot
,
120 void adg_entity_point_to_pair (AdgEntity
*entity
,
121 const AdgPoint
*point
,
124 void adg_entity_point_to_model_pair (AdgEntity
*entity
,
125 const AdgPoint
*point
,
127 void adg_entity_point_to_paper_pair (AdgEntity
*entity
,
128 const AdgPoint
*point
,
130 gboolean
adg_entity_model_matrix_applied (AdgEntity
*entity
);
131 gboolean
adg_entity_paper_matrix_applied (AdgEntity
*entity
);
132 gboolean
adg_entity_model_applied (AdgEntity
*entity
);
133 void adg_entity_invalidate (AdgEntity
*entity
);
134 void adg_entity_render (AdgEntity
*entity
,
140 #endif /* __ADG_ENTITY_H__ */