[dia] dia-object: wrap instance vfuncs
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] dia-object: wrap instance vfuncs
- Date: Sun, 15 Sep 2019 09:43:35 +0000 (UTC)
commit 99156e846b1dce92eb07d60d12e01a562a6d9ba9
Author: Zander Brown <zbrown gnome org>
Date: Tue Sep 10 14:41:24 2019 +0100
dia-object: wrap instance vfuncs
This
- Makes object handling code more readable
- Avoids segfault for incomplete object implementations
- Theoretically makes the methods introspectable for better bindings
lib/create.c | 132 ++++++-----
lib/diaimportrenderer.c | 85 +++----
lib/diapathrenderer.c | 58 ++---
lib/diarenderer.c | 192 ++++++++--------
lib/diatransformrenderer.c | 47 ++--
lib/geometry.c | 38 ++--
lib/group.c | 125 +++++-----
lib/group.h | 2 +
lib/layer.c | 2 +-
lib/object.c | 438 ++++++++++++++++++++++++++++++++++++
lib/object.h | 335 ++++++++-------------------
lib/object_defaults.c | 239 +++++++++-----------
lib/propdialogs.c | 8 +-
lib/propobject.c | 113 ++++------
lib/renderer/diacairo-interactive.c | 2 +-
lib/renderer/diacairo-renderer.c | 2 +-
lib/text.c | 182 ++++++++-------
objects/UML/class.h | 30 ++-
18 files changed, 1136 insertions(+), 894 deletions(-)
---
diff --git a/lib/create.c b/lib/create.c
index e7a1575f..913baf2d 100644
--- a/lib/create.c
+++ b/lib/create.c
@@ -100,12 +100,14 @@ create_standard_ellipse(real xpos, real ypos, real width, real height) {
point.x = xpos;
point.y = ypos;
- new_obj = otype->ops->create(&point, otype->default_user_data,
- &h1, &h2);
+ new_obj = otype->ops->create (&point,
+ otype->default_user_data,
+ &h1,
+ &h2);
- props = make_element_props(xpos,ypos,width,height);
- new_obj->ops->set_props(new_obj, props);
- prop_list_free(props);
+ props = make_element_props (xpos, ypos, width, height);
+ dia_object_set_properties (new_obj, props);
+ prop_list_free (props);
return new_obj;
}
@@ -127,12 +129,14 @@ create_standard_box(real xpos, real ypos, real width, real height) {
point.x = xpos;
point.y = ypos;
- new_obj = otype->ops->create(&point, otype->default_user_data,
- &h1, &h2);
+ new_obj = otype->ops->create (&point,
+ otype->default_user_data,
+ &h1,
+ &h2);
- props = make_element_props(xpos,ypos,width,height);
- new_obj->ops->set_props(new_obj, props);
- prop_list_free(props);
+ props = make_element_props (xpos, ypos, width, height);
+ dia_object_set_properties (new_obj, props);
+ prop_list_free (props);
return new_obj;
}
@@ -162,16 +166,18 @@ create_standard_zigzagline(int num_points, const Point *points,
new_obj = otype->ops->create(NULL, &pcd, &h1, &h2);
- props = prop_list_from_descs(create_line_prop_descs,pdtpp_true);
- g_assert(props->len == 2);
+ props = prop_list_from_descs (create_line_prop_descs, pdtpp_true);
+ g_assert (props->len == 2);
- if (start_arrow != NULL)
- ((ArrowProperty *)g_ptr_array_index(props, 0))->arrow_data = *start_arrow;
- if (end_arrow != NULL)
- ((ArrowProperty *)g_ptr_array_index(props, 1))->arrow_data = *end_arrow;
+ if (start_arrow != NULL) {
+ ((ArrowProperty *) g_ptr_array_index (props, 0))->arrow_data = *start_arrow;
+ }
+ if (end_arrow != NULL) {
+ ((ArrowProperty *) g_ptr_array_index (props, 1))->arrow_data = *end_arrow;
+ }
- new_obj->ops->set_props(new_obj, props);
- prop_list_free(props);
+ dia_object_set_properties (new_obj, props);
+ prop_list_free (props);
return new_obj;
}
@@ -198,16 +204,18 @@ create_standard_polyline(int num_points,
new_obj = otype->ops->create(NULL, &pcd, &h1, &h2);
- props = prop_list_from_descs(create_line_prop_descs,pdtpp_true);
- g_assert(props->len == 2);
+ props = prop_list_from_descs (create_line_prop_descs, pdtpp_true);
+ g_assert (props->len == 2);
- if (start_arrow != NULL)
- ((ArrowProperty *)g_ptr_array_index(props, 0))->arrow_data = *start_arrow;
- if (end_arrow != NULL)
- ((ArrowProperty *)g_ptr_array_index(props, 1))->arrow_data = *end_arrow;
+ if (start_arrow != NULL) {
+ ((ArrowProperty *) g_ptr_array_index (props, 0))->arrow_data = *start_arrow;
+ }
+ if (end_arrow != NULL) {
+ ((ArrowProperty *) g_ptr_array_index (props, 1))->arrow_data = *end_arrow;
+ }
- new_obj->ops->set_props(new_obj, props);
- prop_list_free(props);
+ dia_object_set_properties (new_obj, props);
+ prop_list_free (props);
return new_obj;
}
@@ -254,16 +262,18 @@ create_standard_bezierline(int num_points,
new_obj = otype->ops->create(NULL, &bcd, &h1, &h2);
- props = prop_list_from_descs(create_line_prop_descs,pdtpp_true);
- g_assert(props->len == 2);
+ props = prop_list_from_descs (create_line_prop_descs, pdtpp_true);
+ g_assert (props->len == 2);
- if (start_arrow != NULL)
- ((ArrowProperty *)g_ptr_array_index(props, 0))->arrow_data = *start_arrow;
- if (end_arrow != NULL)
- ((ArrowProperty *)g_ptr_array_index(props, 1))->arrow_data = *end_arrow;
+ if (start_arrow != NULL) {
+ ((ArrowProperty *) g_ptr_array_index (props, 0))->arrow_data = *start_arrow;
+ }
+ if (end_arrow != NULL) {
+ ((ArrowProperty *) g_ptr_array_index (props, 1))->arrow_data = *end_arrow;
+ }
- new_obj->ops->set_props(new_obj, props);
- prop_list_free(props);
+ dia_object_set_properties (new_obj, props);
+ prop_list_free (props);
return new_obj;
}
@@ -338,20 +348,24 @@ create_standard_arc(real x1, real y1, real x2, real y2,
p2.y = y2;
- new_obj = otype->ops->create(&p1, otype->default_user_data,
- &h1, &h2);
- new_obj->ops->move_handle(new_obj, h2, &p2, NULL, HANDLE_MOVE_USER_FINAL,0);
- props = prop_list_from_descs(create_arc_prop_descs,pdtpp_true);
- g_assert(props->len == 3);
+ new_obj = otype->ops->create (&p1,
+ otype->default_user_data,
+ &h1,
+ &h2);
+ dia_object_move_handle (new_obj, h2, &p2, NULL, HANDLE_MOVE_USER_FINAL, 0);
+ props = prop_list_from_descs (create_arc_prop_descs, pdtpp_true);
+ g_assert (props->len == 3);
- ((RealProperty *)g_ptr_array_index(props,0))->real_data = distance;
- if (start_arrow != NULL)
- ((ArrowProperty *)g_ptr_array_index(props, 1))->arrow_data = *start_arrow;
- if (end_arrow != NULL)
- ((ArrowProperty *)g_ptr_array_index(props, 2))->arrow_data = *end_arrow;
+ ((RealProperty *) g_ptr_array_index (props, 0))->real_data = distance;
+ if (start_arrow != NULL) {
+ ((ArrowProperty *) g_ptr_array_index (props, 1))->arrow_data = *start_arrow;
+ }
+ if (end_arrow != NULL) {
+ ((ArrowProperty *) g_ptr_array_index (props, 2))->arrow_data = *end_arrow;
+ }
- new_obj->ops->set_props(new_obj, props);
- prop_list_free(props);
+ dia_object_set_properties (new_obj, props);
+ prop_list_free (props);
return new_obj;
}
@@ -378,21 +392,23 @@ create_standard_image(real xpos, real ypos, real width, real height,
point.x = xpos;
point.y = ypos;
- new_obj = otype->ops->create(&point, otype->default_user_data,
- &h1, &h2);
+ new_obj = otype->ops->create (&point,
+ otype->default_user_data,
+ &h1,
+ &h2);
- props = make_element_props(xpos,ypos,width,height);
- new_obj->ops->set_props(new_obj, props);
- prop_list_free(props);
+ props = make_element_props (xpos, ypos, width, height);
+ dia_object_set_properties (new_obj, props);
+ prop_list_free (props);
- props = prop_list_from_descs(create_file_prop_descs,pdtpp_true);
- g_assert(props->len == 1);
- sprop = g_ptr_array_index(props,0);
- g_free(sprop->string_data);
- sprop->string_data = g_strdup(file);
- new_obj->ops->set_props(new_obj, props);
- prop_list_free(props);
+ props = prop_list_from_descs (create_file_prop_descs, pdtpp_true);
+ g_assert (props->len == 1);
+ sprop = g_ptr_array_index (props, 0);
+ g_free (sprop->string_data);
+ sprop->string_data = g_strdup (file);
+ dia_object_set_properties (new_obj, props);
+ prop_list_free (props);
return new_obj;
}
diff --git a/lib/diaimportrenderer.c b/lib/diaimportrenderer.c
index 95648cea..09ac6a37 100644
--- a/lib/diaimportrenderer.c
+++ b/lib/diaimportrenderer.c
@@ -92,27 +92,27 @@ static void draw_rounded_rect (DiaRenderer *renderer,
Point *ul_corner, Point *lr_corner,
Color *fill, Color *stroke, real radius);
-static void draw_line_with_arrows (DiaRenderer *renderer,
- Point *start, Point *end,
+static void draw_line_with_arrows (DiaRenderer *renderer,
+ Point *start, Point *end,
real line_width,
Color *line_color,
Arrow *start_arrow,
Arrow *end_arrow);
-static void draw_arc_with_arrows (DiaRenderer *renderer,
- Point *start,
+static void draw_arc_with_arrows (DiaRenderer *renderer,
+ Point *start,
Point *end,
Point *midpoint,
real line_width,
Color *color,
Arrow *start_arrow,
Arrow *end_arrow);
-static void draw_polyline_with_arrows (DiaRenderer *renderer,
+static void draw_polyline_with_arrows (DiaRenderer *renderer,
Point *points, int num_points,
real line_width,
Color *color,
Arrow *start_arrow,
Arrow *end_arrow);
-static void draw_rounded_polyline_with_arrows (DiaRenderer *renderer,
+static void draw_rounded_polyline_with_arrows (DiaRenderer *renderer,
Point *points, int num_points,
real line_width,
Color *color,
@@ -120,7 +120,7 @@ static void draw_rounded_polyline_with_arrows (DiaRenderer *renderer,
Arrow *end_arrow,
real radius);
-static void draw_bezier_with_arrows (DiaRenderer *renderer,
+static void draw_bezier_with_arrows (DiaRenderer *renderer,
BezPoint *points,
int num_points,
real line_width,
@@ -193,7 +193,7 @@ dia_import_renderer_class_init (DiaImportRendererClass *klass)
renderer_class->draw_polyline_with_arrows = draw_polyline_with_arrows;
renderer_class->draw_rounded_polyline_with_arrows = draw_rounded_polyline_with_arrows;
renderer_class->draw_bezier_with_arrows = draw_bezier_with_arrows;
-
+
/* other */
renderer_class->is_capable_to = is_capable_to;
renderer_class->set_pattern = set_pattern;
@@ -211,42 +211,42 @@ dia_import_renderer_init (DiaImportRenderer *self)
self->objects = NULL;
}
-static void
+static void
begin_render (DiaRenderer *renderer, const Rectangle *update)
{
- g_warning ("%s::begin_render not implemented!",
+ g_warning ("%s::begin_render not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
-static void
+static void
end_render (DiaRenderer *renderer)
{
- g_warning ("%s::end_render not implemented!",
+ g_warning ("%s::end_render not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
-static void
+static void
set_linewidth (DiaRenderer *renderer, real linewidth)
{
DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
self->line_width = linewidth;
}
-static void
+static void
set_linecaps (DiaRenderer *renderer, LineCaps mode)
{
DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
self->line_caps = mode;
}
-static void
+static void
set_linejoin (DiaRenderer *renderer, LineJoin mode)
{
DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
self->line_join = mode;
}
-static void
+static void
set_linestyle (DiaRenderer *renderer, LineStyle mode, real dash_length)
{
DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
@@ -254,7 +254,7 @@ set_linestyle (DiaRenderer *renderer, LineStyle mode, real dash_length)
self->dash_length = dash_length;
}
-static void
+static void
set_fillstyle (DiaRenderer *renderer, FillStyle mode)
{
DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
@@ -290,9 +290,10 @@ _apply_style (DiaImportRenderer *self,
prop_list_add_line_width (props, 0.0);
prop_list_add_line_colour (props, fill);
}
- if (radius > 0.0)
+ if (radius > 0.0) {
prop_list_add_real (props, "corner_radius", radius);
- obj->ops->set_props (obj, props);
+ }
+ dia_object_set_properties (obj, props);
prop_list_free (props);
}
/*!
@@ -309,7 +310,7 @@ _push_object (DiaImportRenderer *self, DiaObject *obj)
* \brief Draw a simple line
* \memberof _DiaImportRenderer
*/
-static void
+static void
draw_line (DiaRenderer *renderer, Point *start, Point *end, Color *color)
{
Point points[2];
@@ -319,7 +320,7 @@ draw_line (DiaRenderer *renderer, Point *start, Point *end, Color *color)
}
static DiaObject *
-_make_arc (Point *center,
+_make_arc (Point *center,
real width, real height,
real angle1, real angle2)
{
@@ -358,8 +359,8 @@ _make_arc (Point *center,
* \brief Draw an arc
* \memberof _DiaImportRenderer
*/
-static void
-draw_arc (DiaRenderer *renderer, Point *center,
+static void
+draw_arc (DiaRenderer *renderer, Point *center,
real width, real height, real angle1, real angle2,
Color *color)
{
@@ -374,7 +375,7 @@ draw_arc (DiaRenderer *renderer, Point *center,
* \brief Stroke and/or fill a rectangle
* \memberof _DiaImportRenderer
*/
-static void
+static void
draw_rect (DiaRenderer *renderer,
Point *ul_corner, Point *lr_corner,
Color *fill, Color *stroke)
@@ -419,9 +420,9 @@ fill_arc (DiaRenderer *renderer, Point *center,
* Creates a hollow _Ellipse object.
* \memberof _DiaImportRenderer
*/
-static void
+static void
draw_ellipse (DiaRenderer *renderer, Point *center,
- real width, real height,
+ real width, real height,
Color *fill, Color *stroke)
{
DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
@@ -436,7 +437,7 @@ draw_ellipse (DiaRenderer *renderer, Point *center,
* Creates a _Text object with the properties given by _DiaImportRenderer::set_font().
* \memberof _DiaImportRenderer
*/
-static void
+static void
draw_string (DiaRenderer *renderer,
const gchar *text, Point *pos, Alignment alignment,
Color *color)
@@ -451,7 +452,7 @@ draw_string (DiaRenderer *renderer,
prop_list_add_enum (props, "text_alignment", alignment);
prop_list_add_text (props, "text", text); /* must be last! */
- object->ops->set_props (object, props);
+ dia_object_set_properties (object, props);
prop_list_free (props);
_push_object (self, object);
@@ -475,7 +476,7 @@ draw_image (DiaRenderer *renderer,
prop_list_add_filename (props, "image_file", dia_image_filename (image));
/* XXX: reset or merge border? */
- object->ops->set_props (object, props);
+ dia_object_set_properties (object, props);
prop_list_free (props);
dia_object_set_pixbuf (object, (GdkPixbuf *)dia_image_pixbuf (image));
@@ -491,7 +492,7 @@ draw_image (DiaRenderer *renderer,
* Creates a _Bezierline object.
* \memberof _DiaImportRenderer
*/
-static void
+static void
draw_bezier (DiaRenderer *renderer,
BezPoint *points, int numpoints,
Color *color)
@@ -528,7 +529,7 @@ draw_beziergon (DiaRenderer *renderer,
* Creates a _Polyline object.
* \memberof _DiaImportRenderer
*/
-static void
+static void
draw_polyline (DiaRenderer *renderer,
Point *points, int num_points,
Color *color)
@@ -536,7 +537,7 @@ draw_polyline (DiaRenderer *renderer,
draw_rounded_polyline (renderer, points, num_points, color, 0.0);
}
-/*!
+/*!
* \brief Create a polyline with optionally rounded corners
* Creates a _Polyline object.
* \memberof DiaImportRenderer
@@ -574,9 +575,9 @@ draw_polygon (DiaRenderer *renderer,
* \memberof _DiaImportRenderer
*/
static void
-draw_rounded_rect (DiaRenderer *renderer,
+draw_rounded_rect (DiaRenderer *renderer,
Point *ul_corner, Point *lr_corner,
- Color *fill, Color *stroke, real radius)
+ Color *fill, Color *stroke, real radius)
{
DiaImportRenderer *self = DIA_IMPORT_RENDERER (renderer);
DiaObject *object = create_standard_box (ul_corner->x, ul_corner->y,
@@ -592,8 +593,8 @@ draw_rounded_rect (DiaRenderer *renderer,
* \memberof _DiaImportRenderer
*/
static void
-draw_line_with_arrows(DiaRenderer *renderer,
- Point *startpoint,
+draw_line_with_arrows(DiaRenderer *renderer,
+ Point *startpoint,
Point *endpoint,
real line_width,
Color *color,
@@ -616,7 +617,7 @@ draw_line_with_arrows(DiaRenderer *renderer,
* \memberof _DiaImportRenderer
*/
static void
-draw_polyline_with_arrows(DiaRenderer *renderer,
+draw_polyline_with_arrows(DiaRenderer *renderer,
Point *points, int num_points,
real line_width,
Color *color,
@@ -635,7 +636,7 @@ draw_polyline_with_arrows(DiaRenderer *renderer,
* \memberof _DiaImportRenderer
*/
static void
-draw_rounded_polyline_with_arrows(DiaRenderer *renderer,
+draw_rounded_polyline_with_arrows(DiaRenderer *renderer,
Point *points, int num_points,
real line_width,
Color *color,
@@ -656,8 +657,8 @@ draw_rounded_polyline_with_arrows(DiaRenderer *renderer,
* \memberof _DiaImportRenderer
*/
static void
-draw_arc_with_arrows (DiaRenderer *renderer,
- Point *startpoint,
+draw_arc_with_arrows (DiaRenderer *renderer,
+ Point *startpoint,
Point *endpoint,
Point *midpoint,
real line_width,
@@ -684,7 +685,7 @@ draw_arc_with_arrows (DiaRenderer *renderer,
* \memberof _DiaImportRenderer
*/
static void
-draw_bezier_with_arrows(DiaRenderer *renderer,
+draw_bezier_with_arrows(DiaRenderer *renderer,
BezPoint *points,
int num_points,
real line_width,
@@ -705,7 +706,7 @@ draw_bezier_with_arrows(DiaRenderer *renderer,
* limitation with this renderer's implementation.
* \memberof _DiaImportRenderer
*/
-static gboolean
+static gboolean
is_capable_to (DiaRenderer *renderer, RenderCapability cap)
{
return TRUE;
diff --git a/lib/diapathrenderer.c b/lib/diapathrenderer.c
index 1a836c0d..1200f36d 100644
--- a/lib/diapathrenderer.c
+++ b/lib/diapathrenderer.c
@@ -78,7 +78,7 @@ _path_renderer_clear (DiaPathRenderer *self)
{
if (self->pathes) {
guint i;
-
+
for (i = 0; i < self->pathes->len; ++i) {
GArray *path = g_ptr_array_index (self->pathes, i);
@@ -188,7 +188,7 @@ begin_render (DiaRenderer *self, const Rectangle *update)
}
/*!
* \brief End of current rendering run
- * Should not be used to clean the accumulated paths
+ * Should not be used to clean the accumulated paths
* \memberof _DiaPathRenderer
*/
static void
@@ -302,8 +302,8 @@ _path_arc_segment (GArray *path,
* \memberof _DiaPathRenderer
*/
static void
-draw_line(DiaRenderer *self,
- Point *start, Point *end,
+draw_line(DiaRenderer *self,
+ Point *start, Point *end,
Color *line_colour)
{
DiaPathRenderer *renderer = DIA_PATH_RENDERER (self);
@@ -314,8 +314,8 @@ draw_line(DiaRenderer *self,
}
static void
-_polyline(DiaRenderer *self,
- Point *points, int num_points,
+_polyline(DiaRenderer *self,
+ Point *points, int num_points,
const Color *fill, const Color *stroke)
{
DiaPathRenderer *renderer = DIA_PATH_RENDERER (self);
@@ -337,8 +337,8 @@ _polyline(DiaRenderer *self,
* \memberof _DiaPathRenderer
*/
static void
-draw_polyline(DiaRenderer *self,
- Point *points, int num_points,
+draw_polyline(DiaRenderer *self,
+ Point *points, int num_points,
Color *line_colour)
{
_polyline (self, points, num_points, NULL, line_colour);
@@ -349,8 +349,8 @@ draw_polyline(DiaRenderer *self,
* \memberof _DiaPathRenderer
*/
static void
-draw_polygon(DiaRenderer *self,
- Point *points, int num_points,
+draw_polygon(DiaRenderer *self,
+ Point *points, int num_points,
Color *fill, Color *stroke)
{
DiaPathRenderer *renderer = DIA_PATH_RENDERER (self);
@@ -370,7 +370,7 @@ draw_polygon(DiaRenderer *self,
* \memberof _DiaPathRenderer
*/
static void
-draw_rect (DiaRenderer *self,
+draw_rect (DiaRenderer *self,
Point *ul_corner, Point *lr_corner,
Color *fill, Color *stroke)
{
@@ -386,7 +386,7 @@ draw_rect (DiaRenderer *self,
/* 0: top-right, clock-wise */
for (i = 0; i < 4; ++i) {
BezPoint bp;
-
+
bp.type = BEZ_LINE_TO;
bp.p1.x = pt.x + (i < 2 ? width : 0);
bp.p1.y = pt.y + (i > 0 && i < 3 ? height : 0);
@@ -444,7 +444,7 @@ path_build_arc (GArray *path,
* \private \memberof _DiaPathRenderer
*/
static void
-_arc (DiaRenderer *self,
+_arc (DiaRenderer *self,
Point *center,
real width, real height,
real angle1, real angle2,
@@ -460,7 +460,7 @@ _arc (DiaRenderer *self,
* \memberof _DiaPathRenderer
*/
static void
-draw_arc (DiaRenderer *self,
+draw_arc (DiaRenderer *self,
Point *center,
real width, real height,
real angle1, real angle2,
@@ -474,7 +474,7 @@ draw_arc (DiaRenderer *self,
* \memberof _DiaPathRenderer
*/
static void
-fill_arc (DiaRenderer *self,
+fill_arc (DiaRenderer *self,
Point *center,
real width, real height,
real angle1, real angle2,
@@ -506,7 +506,7 @@ path_build_ellipse (GArray *path,
pt.y = (i % 2 == 0 ? center->y : (i == 1 ? center->y + h2 : center->y - h2));
bp.type = BEZ_CURVE_TO;
bp.p3 = pt;
-
+
switch (i) {
case 0 : /* going right for p1 */
bp.p1.x = center->x + dx;
@@ -555,7 +555,7 @@ draw_ellipse (DiaRenderer *self,
path_build_ellipse (path, center, width, height);
}
static void
-_bezier (DiaRenderer *self,
+_bezier (DiaRenderer *self,
BezPoint *points, int numpoints,
const Color *fill, const Color *stroke)
{
@@ -578,7 +578,7 @@ _bezier (DiaRenderer *self,
* \memberof _DiaPathRenderer
*/
static void
-draw_bezier (DiaRenderer *self,
+draw_bezier (DiaRenderer *self,
BezPoint *points,
int numpoints,
Color *color)
@@ -591,7 +591,7 @@ draw_bezier (DiaRenderer *self,
* \memberof _DiaPathRenderer
*/
static void
-draw_beziergon (DiaRenderer *self,
+draw_beziergon (DiaRenderer *self,
BezPoint *points,
int numpoints,
Color *fill,
@@ -603,9 +603,9 @@ draw_beziergon (DiaRenderer *self,
* \brief Convert the text object to a scaled path
* \memberof _DiaPathRenderer
*/
-static void
+static void
draw_text (DiaRenderer *self,
- Text *text)
+ Text *text)
{
DiaPathRenderer *renderer = DIA_PATH_RENDERER (self);
GArray *path = _get_current_path (renderer, NULL, &text->color);
@@ -616,7 +616,7 @@ draw_text (DiaRenderer *self,
PolyBBExtras extra = { 0, };
real dx, dy, sx, sy;
guint i;
-
+
polybezier_bbox (&g_array_index (path, BezPoint, n0), path->len - n0, &extra, TRUE, &bz_bb);
text_calc_boundingbox (text, &tx_bb);
sx = (tx_bb.right - tx_bb.left) / (bz_bb.right - bz_bb.left);
@@ -660,7 +660,7 @@ draw_string(DiaRenderer *self,
}
}
-/*!
+/*!
* \brief Render just a cheap emulation ;)
*
* It might be desirable to convert the given pixels to some vector representation.
@@ -695,7 +695,7 @@ draw_image(DiaRenderer *self,
_path_lineto (path, &to);
}
-/*!
+/*!
* \brief Create contour of the rounded rect
*
* This methods needs to be implemented to avoid the default
@@ -705,7 +705,7 @@ draw_image(DiaRenderer *self,
* \memberof _DiaPathRenderer
*/
static void
-draw_rounded_rect (DiaRenderer *self,
+draw_rounded_rect (DiaRenderer *self,
Point *ul_corner, Point *lr_corner,
Color *fill, Color *stroke, real radius)
{
@@ -718,11 +718,11 @@ draw_rounded_rect (DiaRenderer *self,
if (radius > ry)
radius = ry;
if (stroke) /* deliberately ignoring fill for path building */
- DIA_RENDERER_CLASS(dia_path_renderer_parent_class)->draw_rounded_rect(self,
+ DIA_RENDERER_CLASS(dia_path_renderer_parent_class)->draw_rounded_rect(self,
ul_corner, lr_corner,
NULL, stroke, radius);
else
- DIA_RENDERER_CLASS(dia_path_renderer_parent_class)->draw_rounded_rect(self,
+ DIA_RENDERER_CLASS(dia_path_renderer_parent_class)->draw_rounded_rect(self,
ul_corner, lr_corner,
fill, NULL, radius);
/* stroke is set by the piecewise rendering above already */
@@ -798,7 +798,7 @@ create_standard_path_from_object (DiaObject *obj)
renderer = g_object_new (DIA_TYPE_PATH_RENDERER, 0);
pr = DIA_PATH_RENDERER (renderer);
- obj->ops->draw (obj, renderer);
+ dia_object_draw (obj, renderer);
/* messing with internals */
if (!pr->pathes) { /* oops? */
@@ -864,7 +864,7 @@ create_standard_path_from_list (GList *objects,
int i;
_path_renderer_clear (pr);
- obj->ops->draw (obj, renderer);
+ dia_object_draw (obj, renderer);
if (!pr->pathes) /* nothing created? */
continue;
/* get a single path from this rendererer run */
diff --git a/lib/diarenderer.c b/lib/diarenderer.c
index 7ed882ab..a97fd976 100644
--- a/lib/diarenderer.c
+++ b/lib/diarenderer.c
@@ -130,27 +130,27 @@ static real get_text_width (DiaRenderer *renderer,
static void draw_rounded_rect (DiaRenderer *renderer,
Point *ul_corner, Point *lr_corner,
Color *fill, Color *stroke, real radius);
-static void draw_line_with_arrows (DiaRenderer *renderer,
- Point *start, Point *end,
+static void draw_line_with_arrows (DiaRenderer *renderer,
+ Point *start, Point *end,
real line_width,
Color *line_color,
Arrow *start_arrow,
Arrow *end_arrow);
-static void draw_arc_with_arrows (DiaRenderer *renderer,
- Point *start,
+static void draw_arc_with_arrows (DiaRenderer *renderer,
+ Point *start,
Point *end,
Point *midpoint,
real line_width,
Color *color,
Arrow *start_arrow,
Arrow *end_arrow);
-static void draw_polyline_with_arrows (DiaRenderer *renderer,
+static void draw_polyline_with_arrows (DiaRenderer *renderer,
Point *points, int num_points,
real line_width,
Color *color,
Arrow *start_arrow,
Arrow *end_arrow);
-static void draw_rounded_polyline_with_arrows (DiaRenderer *renderer,
+static void draw_rounded_polyline_with_arrows (DiaRenderer *renderer,
Point *points, int num_points,
real line_width,
Color *color,
@@ -158,7 +158,7 @@ static void draw_rounded_polyline_with_arrows (DiaRenderer *renderer,
Arrow *end_arrow,
real radius);
-static void draw_bezier_with_arrows (DiaRenderer *renderer,
+static void draw_bezier_with_arrows (DiaRenderer *renderer,
BezPoint *points,
int num_points,
real line_width,
@@ -196,11 +196,11 @@ dia_renderer_get_type (void)
"DiaRenderer",
&object_info, 0);
}
-
+
return object_type;
}
-/*!
+/*!
* \brief Render all the visible object in the layer
*
* @param renderer explicit this pointer
@@ -250,7 +250,7 @@ draw_layer (DiaRenderer *renderer,
static void
draw_object (DiaRenderer *renderer,
DiaObject *object,
- DiaMatrix *matrix)
+ DiaMatrix *matrix)
{
if (matrix) {
#if 1
@@ -272,7 +272,7 @@ draw_object (DiaRenderer *renderer,
pt[2].y = matrix->yx * bb->right + matrix->yy * bb->bottom + matrix->y0;
pt[3].x = matrix->xx * bb->left + matrix->xy * bb->bottom + matrix->x0;
pt[3].y = matrix->yx * bb->left + matrix->yy * bb->bottom + matrix->y0;
-
+
DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, 0.0);
DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_DOTTED, 1.0);
DIA_RENDERER_GET_CLASS(renderer)->draw_polygon(renderer, pt, 4, NULL, &red);
@@ -280,7 +280,7 @@ draw_object (DiaRenderer *renderer,
DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &pt[1], &pt[3], &red);
#endif
}
- object->ops->draw(object, renderer);
+ dia_object_draw (object, renderer);
}
static void
@@ -353,7 +353,7 @@ dia_renderer_class_init (DiaRendererClass *klass)
renderer_class->draw_polyline_with_arrows = draw_polyline_with_arrows;
renderer_class->draw_rounded_polyline_with_arrows = draw_rounded_polyline_with_arrows;
renderer_class->draw_bezier_with_arrows = draw_bezier_with_arrows;
-
+
/* other */
renderer_class->is_capable_to = is_capable_to;
renderer_class->set_pattern = set_pattern;
@@ -373,10 +373,10 @@ dia_renderer_class_init (DiaRendererClass *klass)
*
* \memberof _DiaRenderer \pure
*/
-static void
+static void
begin_render (DiaRenderer *object, const Rectangle *update)
{
- g_warning ("%s::begin_render not implemented!",
+ g_warning ("%s::begin_render not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (object)));
}
@@ -387,10 +387,10 @@ begin_render (DiaRenderer *object, const Rectangle *update)
*
* \memberof _DiaRenderer \pure
*/
-static void
+static void
end_render (DiaRenderer *object)
{
- g_warning ("%s::end_render not implemented!",
+ g_warning ("%s::end_render not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (object)));
}
@@ -398,10 +398,10 @@ end_render (DiaRenderer *object)
* \brief Change the line width for the strokes to come
* \memberof _DiaRenderer \pure
*/
-static void
+static void
set_linewidth (DiaRenderer *object, real linewidth)
{
- g_warning ("%s::set_line_width not implemented!",
+ g_warning ("%s::set_line_width not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (object)));
}
@@ -409,10 +409,10 @@ set_linewidth (DiaRenderer *object, real linewidth)
* \brief Change the line caps for the strokes to come
* \memberof _DiaRenderer \pure
*/
-static void
+static void
set_linecaps (DiaRenderer *object, LineCaps mode)
{
- g_warning ("%s::set_line_caps not implemented!",
+ g_warning ("%s::set_line_caps not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (object)));
}
@@ -420,10 +420,10 @@ set_linecaps (DiaRenderer *object, LineCaps mode)
* \brief Change the line join mode for the strokes to come
* \memberof _DiaRenderer \pure
*/
-static void
+static void
set_linejoin (DiaRenderer *renderer, LineJoin mode)
{
- g_warning ("%s::set_line_join not implemented!",
+ g_warning ("%s::set_line_join not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
@@ -431,10 +431,10 @@ set_linejoin (DiaRenderer *renderer, LineJoin mode)
* \brief Change line style and dash length for the strokes to come
* \memberof _DiaRenderer \pure
*/
-static void
+static void
set_linestyle (DiaRenderer *renderer, LineStyle mode, real dash_length)
{
- g_warning ("%s::set_line_style not implemented!",
+ g_warning ("%s::set_line_style not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
@@ -446,10 +446,10 @@ set_linestyle (DiaRenderer *renderer, LineStyle mode, real dash_length)
*
* \memberof _DiaRenderer \pure
*/
-static void
+static void
set_fillstyle (DiaRenderer *renderer, FillStyle mode)
{
- g_warning ("%s::set_fill_style not implemented!",
+ g_warning ("%s::set_fill_style not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
@@ -457,10 +457,10 @@ set_fillstyle (DiaRenderer *renderer, FillStyle mode)
* \brief Draw a single line segment
* \memberof _DiaRenderer \pure
*/
-static void
+static void
draw_line (DiaRenderer *renderer, Point *start, Point *end, Color *color)
{
- g_warning ("%s::draw_line not implemented!",
+ g_warning ("%s::draw_line not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
@@ -472,7 +472,7 @@ draw_line (DiaRenderer *renderer, Point *start, Point *end, Color *color)
*
* \memberof _DiaRenderer
*/
-static void
+static void
draw_polygon (DiaRenderer *renderer,
Point *points, int num_points,
Color *fill, Color *stroke)
@@ -487,7 +487,7 @@ draw_polygon (DiaRenderer *renderer,
for (i = 0; i < num_points - 1; i++)
klass->draw_line (renderer, &points[i+0], &points[i+1], color);
/* close it in any case */
- if ( (points[0].x != points[num_points-1].x)
+ if ( (points[0].x != points[num_points-1].x)
|| (points[0].y != points[num_points-1].y))
klass->draw_line (renderer, &points[num_points-1], &points[0], color);
}
@@ -500,7 +500,7 @@ draw_polygon (DiaRenderer *renderer,
*
* \memberof _DiaRenderer \pure
*/
-static void
+static void
draw_arc (DiaRenderer *renderer, Point *center,
real width, real height, real angle1, real angle2,
Color *color)
@@ -513,24 +513,24 @@ draw_arc (DiaRenderer *renderer, Point *center,
* \brief Fill an arc (a pie-chart)
* \memberof _DiaRenderer \pure
*/
-static void
+static void
fill_arc (DiaRenderer *renderer, Point *center,
real width, real height, real angle1, real angle2,
Color *color)
{
- g_warning ("%s::fill_arc not implemented!",
+ g_warning ("%s::fill_arc not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
/*!
* \brief Fill and/or stroke an ellipse
* \memberof _DiaRenderer \pure
*/
-static void
+static void
draw_ellipse (DiaRenderer *renderer, Point *center,
- real width, real height,
+ real width, real height,
Color *fill, Color *stroke)
{
- g_warning ("%s::draw_ellipse not implemented!",
+ g_warning ("%s::draw_ellipse not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
@@ -557,12 +557,12 @@ set_font (DiaRenderer *renderer, DiaFont *font, real height)
* \brief Draw a string
* \memberof _DiaRenderer \pure
*/
-static void
+static void
draw_string (DiaRenderer *renderer,
const gchar *text, Point *pos, Alignment alignment,
Color *color)
{
- g_warning ("%s::draw_string not implemented!",
+ g_warning ("%s::draw_string not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
@@ -590,9 +590,9 @@ draw_image (DiaRenderer *renderer,
*
* \memberof _DiaRenderer
*/
-static void
+static void
draw_text (DiaRenderer *renderer,
- Text *text)
+ Text *text)
{
Point pos;
int i;
@@ -736,14 +736,14 @@ draw_rotated_image (DiaRenderer *renderer,
*
* \memberof _DiaRenderer
*/
-static void
+static void
draw_text_line (DiaRenderer *renderer,
- TextLine *text_line, Point *pos, Alignment alignment, Color *color)
+ TextLine *text_line, Point *pos, Alignment alignment, Color *color)
{
- DIA_RENDERER_GET_CLASS(renderer)->set_font(renderer,
+ DIA_RENDERER_GET_CLASS(renderer)->set_font(renderer,
text_line_get_font(text_line),
text_line_get_height(text_line));
-
+
DIA_RENDERER_GET_CLASS(renderer)->draw_string(renderer,
text_line_get_string(text_line),
pos, alignment,
@@ -774,9 +774,9 @@ bezier_add_point(BezierApprox *bezier,
bezier->points = g_realloc(bezier->points,
bezier->numpoints*sizeof(Point));
}
-
+
bezier->points[bezier->currpoint] = *point;
-
+
bezier->currpoint++;
}
@@ -831,9 +831,9 @@ bezier_add_lines(BezierApprox *bezier,
middle = points[1];
point_add(&middle, &points[2]);
point_scale(&middle, 0.5);
-
+
r[0] = points[0];
-
+
r[1] = points[0];
point_add(&r[1], &points[1]);
point_scale(&r[1], 0.5);
@@ -847,7 +847,7 @@ bezier_add_lines(BezierApprox *bezier,
s[2] = points[2];
point_add(&s[2], &points[3]);
point_scale(&s[2], 0.5);
-
+
s[1] = s[2];
point_add(&s[1], &middle);
point_scale(&s[1], 0.5);
@@ -855,7 +855,7 @@ bezier_add_lines(BezierApprox *bezier,
r[3] = r[2];
point_add(&r[3], &s[1]);
point_scale(&r[3], 0.5);
-
+
s[0] = r[3];
bezier_add_lines(bezier, r);
@@ -872,7 +872,7 @@ bezier_add_curve(BezierApprox *bezier,
(distance_point_point(&points[0], &points[3]) < 0.00001)) {
bezier_add_point(bezier, &points[3]);
}
-
+
bezier_add_lines(bezier, points);
}
@@ -929,7 +929,7 @@ approximate_bezier (BezierApprox *bezier,
*
* \memberof _DiaRenderer
*/
-static void
+static void
draw_bezier (DiaRenderer *renderer,
BezPoint *points, int numpoints,
Color *color)
@@ -964,7 +964,7 @@ draw_bezier (DiaRenderer *renderer,
*
* \memberof _DiaRenderer
*/
-static void
+static void
draw_beziergon (DiaRenderer *renderer,
BezPoint *points, int numpoints,
Color *fill, Color *stroke)
@@ -1032,7 +1032,7 @@ draw_rect (DiaRenderer *renderer,
*
* \memberof _DiaRenderer
*/
-static void
+static void
draw_polyline (DiaRenderer *renderer,
Point *points, int num_points,
Color *color)
@@ -1116,7 +1116,7 @@ draw_rounded_polyline (DiaRenderer *renderer,
/* adjust the radius if it would cause odd rendering */
min_radius = MIN(radius, calculate_min_radius(&p1,&p2,&p4));
arc_it = fillet(&p1,&p2,&p3,&p4, min_radius, &c, &start_angle, &stop_angle);
- /* start with the line drawing to allow joining in backend */
+ /* start with the line drawing to allow joining in backend */
klass->draw_line(renderer, &p1, &p2, color);
if (arc_it)
klass->draw_arc(renderer, &c, min_radius*2, min_radius*2,
@@ -1137,16 +1137,16 @@ draw_rounded_polyline (DiaRenderer *renderer,
*
* \memberof _DiaRenderer
*/
-static void
-draw_rounded_rect (DiaRenderer *renderer,
+static void
+draw_rounded_rect (DiaRenderer *renderer,
Point *ul_corner, Point *lr_corner,
- Color *fill, Color *stroke, real radius)
+ Color *fill, Color *stroke, real radius)
{
DiaRendererClass *renderer_ops = DIA_RENDERER_GET_CLASS (renderer);
/* clip radius per axis to use the full API;) */
real rw = MIN(radius, (lr_corner->x-ul_corner->x)/2);
real rh = MIN(radius, (lr_corner->y-ul_corner->y)/2);
-
+
if (rw < 0.00001 || rh < 0.00001) {
renderer_ops->draw_rect(renderer, ul_corner, lr_corner, fill, stroke);
} else {
@@ -1175,7 +1175,7 @@ draw_rounded_rect (DiaRenderer *renderer,
pts[6].x = brx - rw; pts[6].y = tly; /* left */
pts[7].x = tlx + rw; pts[7].y = tly;
-
+
/* If line_width would be available we could approximate small radius with:
* renderer_ops->draw_polygon (renderer, pts, 8, fill, stroke);
*/
@@ -1215,8 +1215,8 @@ draw_rounded_rect (DiaRenderer *renderer,
* \memberof _DiaRenderer
*/
static void
-draw_line_with_arrows(DiaRenderer *renderer,
- Point *startpoint,
+draw_line_with_arrows(DiaRenderer *renderer,
+ Point *startpoint,
Point *endpoint,
real line_width,
Color *color,
@@ -1231,7 +1231,7 @@ draw_line_with_arrows(DiaRenderer *renderer,
/* Calculate how to more the line to account for arrow heads */
if (start_arrow != NULL && start_arrow->type != ARROW_NONE) {
Point move_arrow, move_line;
- calculate_arrow_point(start_arrow, startpoint, endpoint,
+ calculate_arrow_point(start_arrow, startpoint, endpoint,
&move_arrow, &move_line,
line_width);
start_arrow_head = *startpoint;
@@ -1274,7 +1274,7 @@ draw_line_with_arrows(DiaRenderer *renderer,
* \memberof _DiaRenderer
*/
static void
-draw_polyline_with_arrows(DiaRenderer *renderer,
+draw_polyline_with_arrows(DiaRenderer *renderer,
Point *points, int num_points,
real line_width,
Color *color,
@@ -1292,14 +1292,14 @@ draw_polyline_with_arrows(DiaRenderer *renderer,
if (start_arrow != NULL && start_arrow->type != ARROW_NONE) {
Point move_arrow, move_line;
while (firstline < num_points-1 &&
- distance_point_point(&points[firstline],
+ distance_point_point(&points[firstline],
&points[firstline+1]) < 0.0000001)
firstline++;
if (firstline == num_points-1)
firstline = 0; /* No non-zero lines, it doesn't matter. */
oldstart = points[firstline];
- calculate_arrow_point(start_arrow,
- &points[firstline], &points[firstline+1],
+ calculate_arrow_point(start_arrow,
+ &points[firstline], &points[firstline+1],
&move_arrow, &move_line,
line_width);
start_arrow_head = points[firstline];
@@ -1308,14 +1308,14 @@ draw_polyline_with_arrows(DiaRenderer *renderer,
}
if (end_arrow != NULL && end_arrow->type != ARROW_NONE) {
Point move_arrow, move_line;
- while (lastline > 0 &&
- distance_point_point(&points[lastline-1],
+ while (lastline > 0 &&
+ distance_point_point(&points[lastline-1],
&points[lastline-2]) < 0.0000001)
lastline--;
if (lastline == 0)
firstline = num_points; /* No non-zero lines, it doesn't matter. */
oldend = points[lastline-1];
- calculate_arrow_point(end_arrow, &points[lastline-1],
+ calculate_arrow_point(end_arrow, &points[lastline-1],
&points[lastline-2],
&move_arrow, &move_line,
line_width);
@@ -1326,7 +1326,7 @@ draw_polyline_with_arrows(DiaRenderer *renderer,
/* Don't draw degenerate line segments at end of line */
if (lastline-firstline > 1) /* probably hiding a bug above, but don't try to draw a negative
* number of points at all, fixes bug #148139 */
- DIA_RENDERER_GET_CLASS(renderer)->draw_polyline(renderer, &points[firstline],
+ DIA_RENDERER_GET_CLASS(renderer)->draw_polyline(renderer, &points[firstline],
lastline-firstline, color);
if (start_arrow != NULL && start_arrow->type != ARROW_NONE)
arrow_draw(renderer, start_arrow->type,
@@ -1351,7 +1351,7 @@ draw_polyline_with_arrows(DiaRenderer *renderer,
* \memberof _DiaRenderer
*/
static void
-draw_rounded_polyline_with_arrows(DiaRenderer *renderer,
+draw_rounded_polyline_with_arrows(DiaRenderer *renderer,
Point *points, int num_points,
real line_width,
Color *color,
@@ -1370,14 +1370,14 @@ draw_rounded_polyline_with_arrows(DiaRenderer *renderer,
if (start_arrow != NULL && start_arrow->type != ARROW_NONE) {
Point move_arrow, move_line;
while (firstline < num_points-1 &&
- distance_point_point(&points[firstline],
+ distance_point_point(&points[firstline],
&points[firstline+1]) < 0.0000001)
firstline++;
if (firstline == num_points-1)
firstline = 0; /* No non-zero lines, it doesn't matter. */
oldstart = points[firstline];
- calculate_arrow_point(start_arrow,
- &points[firstline], &points[firstline+1],
+ calculate_arrow_point(start_arrow,
+ &points[firstline], &points[firstline+1],
&move_arrow, &move_line,
line_width);
start_arrow_head = points[firstline];
@@ -1386,14 +1386,14 @@ draw_rounded_polyline_with_arrows(DiaRenderer *renderer,
}
if (end_arrow != NULL && end_arrow->type != ARROW_NONE) {
Point move_arrow, move_line;
- while (lastline > 0 &&
- distance_point_point(&points[lastline-1],
+ while (lastline > 0 &&
+ distance_point_point(&points[lastline-1],
&points[lastline-2]) < 0.0000001)
lastline--;
if (lastline == 0)
firstline = num_points; /* No non-zero lines, it doesn't matter. */
oldend = points[lastline-1];
- calculate_arrow_point(end_arrow, &points[lastline-1],
+ calculate_arrow_point(end_arrow, &points[lastline-1],
&points[lastline-2],
&move_arrow, &move_line,
line_width);
@@ -1492,7 +1492,7 @@ intersection_line_line(Point *cross,
* The renderer should disappear once the debugging is done.
*/
static gboolean
-find_center_point(Point *center, const Point *p1, const Point *p2, const Point *p3)
+find_center_point(Point *center, const Point *p1, const Point *p2, const Point *p3)
{
Point mid1;
Point mid2;
@@ -1531,7 +1531,7 @@ find_center_point(Point *center, const Point *p1, const Point *p2, const Point *
fabs((p1->y + p2->y + p3->y)/3 - p1->y) < 0.0000001) {
return FALSE;
}
-
+
/* Case 2: Two points are on top of each other. Midpoint of
* non-degenerate line is center. */
if (distance_point_point_manhattan(p1, p2) < 0.0000001) {
@@ -1568,8 +1568,8 @@ is_right_hand (const Point *a, const Point *b, const Point *c)
* \memberof _DiaRenderer
*/
static void
-draw_arc_with_arrows (DiaRenderer *renderer,
- Point *startpoint,
+draw_arc_with_arrows (DiaRenderer *renderer,
+ Point *startpoint,
Point *endpoint,
Point *midpoint,
real line_width,
@@ -1618,7 +1618,7 @@ draw_arc_with_arrows (DiaRenderer *renderer,
}
point_add(&start_arrow_end, startpoint);
- calculate_arrow_point(start_arrow, startpoint, &start_arrow_end,
+ calculate_arrow_point(start_arrow, startpoint, &start_arrow_end,
&move_arrow, &move_line,
line_width);
start_arrow_head = *startpoint;
@@ -1651,8 +1651,8 @@ draw_arc_with_arrows (DiaRenderer *renderer,
/* Now we possibly have new start- and endpoint. We must not
* recalculate the center cause the new points lie on the tangential
- * approximation of the original arc arrow lines not on the arc itself.
- * The one thing we need to deal with is calculating the (new) angles
+ * approximation of the original arc arrow lines not on the arc itself.
+ * The one thing we need to deal with is calculating the (new) angles
* and get rid of the arc drawing altogether if got degenerated.
*/
angle1 = -atan2(new_startpoint.y - center.y, new_startpoint.x - center.x)*180.0/G_PI;
@@ -1690,7 +1690,7 @@ draw_arc_with_arrows (DiaRenderer *renderer,
* \memberof _DiaRenderer
*/
static void
-draw_bezier_with_arrows(DiaRenderer *renderer,
+draw_bezier_with_arrows(DiaRenderer *renderer,
BezPoint *points,
int num_points,
real line_width,
@@ -1742,7 +1742,7 @@ draw_bezier_with_arrows(DiaRenderer *renderer,
points[0].p1 = startpoint;
points[num_points-1].p3 = endpoint;
-
+
}
/*! @} */
@@ -1760,7 +1760,7 @@ draw_bezier_with_arrows(DiaRenderer *renderer,
*
* \memberof _DiaRenderer
*/
-static real
+static real
get_text_width (DiaRenderer *renderer,
const gchar *text, int length)
{
@@ -1769,12 +1769,12 @@ get_text_width (DiaRenderer *renderer,
if (renderer->font) {
char *str = g_strndup (text, length);
- ret = dia_font_string_width (str,
+ ret = dia_font_string_width (str,
renderer->font,
renderer->font_height);
g_free (str);
} else {
- g_warning ("%s::get_text_width not implemented (and renderer->font==NULL)!",
+ g_warning ("%s::get_text_width not implemented (and renderer->font==NULL)!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
@@ -1785,7 +1785,7 @@ get_text_width (DiaRenderer *renderer,
* \brief Get drawing width in pixels if any
* \memberof _DiaRenderer \pure
*/
-static int
+static int
get_width_pixels (DiaRenderer *renderer)
{
g_return_val_if_fail (renderer->is_interactive, 0);
@@ -1796,7 +1796,7 @@ get_width_pixels (DiaRenderer *renderer)
* \brief Get drawing height in pixels if any
* \memberof _DiaRenderer \pure
*/
-static int
+static int
get_height_pixels (DiaRenderer *renderer)
{
g_return_val_if_fail (renderer->is_interactive, 0);
@@ -1821,7 +1821,7 @@ get_height_pixels (DiaRenderer *renderer)
*
* \memberof _DiaRenderer
*/
-static gboolean
+static gboolean
is_capable_to (DiaRenderer *renderer, RenderCapability cap)
{
return FALSE;
@@ -1835,7 +1835,7 @@ is_capable_to (DiaRenderer *renderer, RenderCapability cap)
static void
set_pattern (DiaRenderer *renderer, DiaPattern *pat)
{
- g_warning ("%s::set_pattern not implemented!",
+ g_warning ("%s::set_pattern not implemented!",
G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (renderer)));
}
@@ -1944,7 +1944,7 @@ bezier_render_fill_old (DiaRenderer *renderer, BezPoint *pts, int total, Color *
int s2 = 0;
for (i = 1; i < total; ++i) {
if (BEZ_MOVE_TO == pts[i].type) {
- /* check whether the start point of the second outline is within the first outline.
+ /* check whether the start point of the second outline is within the first outline.
* If so it need to be subtracted - currently blanked. */
real dist = distance_bez_shape_point (&pts[s1], n1 > 0 ? n1 : i - s1, 0, &pts[i].p1);
if (s2 > s1) { /* blanking the previous one */
diff --git a/lib/diatransformrenderer.c b/lib/diatransformrenderer.c
index f48a24be..c71c531c 100644
--- a/lib/diatransformrenderer.c
+++ b/lib/diatransformrenderer.c
@@ -30,7 +30,7 @@
* \brief Renderer which does affine transform rendering
*
* The transform renderer does not produce any external output by itself. It
- * directly delegates it's results to the worker renderer.
+ * directly delegates it's results to the worker renderer.
*
* \extends _DiaRenderer
*/
@@ -40,7 +40,7 @@ struct _DiaTransformRenderer
DiaRenderer *worker; /*!< the renderer with real output */
- GQueue *matrices;
+ GQueue *matrices;
};
struct _DiaTransformRendererClass
@@ -193,8 +193,8 @@ set_fillstyle(DiaRenderer *self, FillStyle mode)
* \memberof _DiaTransformRenderer
*/
static void
-draw_line(DiaRenderer *self,
- Point *start, Point *end,
+draw_line(DiaRenderer *self,
+ Point *start, Point *end,
Color *line_colour)
{
Point p1 = *start;
@@ -209,8 +209,8 @@ draw_line(DiaRenderer *self,
DIA_RENDERER_GET_CLASS (renderer->worker)->draw_line (renderer->worker, &p1, &p2, line_colour);
}
static void
-_polyline(DiaRenderer *self,
- Point *points, int num_points,
+_polyline(DiaRenderer *self,
+ Point *points, int num_points,
Color *fill, Color *stroke,
gboolean closed)
{
@@ -234,8 +234,8 @@ _polyline(DiaRenderer *self,
* \memberof _DiaTransformRenderer
*/
static void
-draw_polyline(DiaRenderer *self,
- Point *points, int num_points,
+draw_polyline(DiaRenderer *self,
+ Point *points, int num_points,
Color *stroke)
{
_polyline (self, points, num_points, NULL, stroke, FALSE);
@@ -245,15 +245,15 @@ draw_polyline(DiaRenderer *self,
* \memberof _DiaTransformRenderer
*/
static void
-draw_polygon(DiaRenderer *self,
- Point *points, int num_points,
+draw_polygon(DiaRenderer *self,
+ Point *points, int num_points,
Color *fill, Color *stroke)
{
_polyline (self, points, num_points, fill, stroke, TRUE);
}
/* ToDo: arc and ellipse to be emulated by bezier - in base class? */
static void
-_bezier (DiaRenderer *self,
+_bezier (DiaRenderer *self,
BezPoint *points, int num_points,
Color *fill, Color *stroke,
gboolean closed)
@@ -276,7 +276,7 @@ _bezier (DiaRenderer *self,
g_return_if_fail (fill == NULL && "fill for stroke?");
}
static void
-_arc (DiaRenderer *self,
+_arc (DiaRenderer *self,
Point *center,
real width, real height,
real angle1, real angle2,
@@ -292,7 +292,7 @@ _arc (DiaRenderer *self,
* \memberof _DiaTransformRenderer
*/
static void
-draw_arc (DiaRenderer *self,
+draw_arc (DiaRenderer *self,
Point *center,
real width, real height,
real angle1, real angle2,
@@ -305,7 +305,7 @@ draw_arc (DiaRenderer *self,
* \memberof _DiaTransformRenderer
*/
static void
-fill_arc (DiaRenderer *self,
+fill_arc (DiaRenderer *self,
Point *center,
real width, real height,
real angle1, real angle2,
@@ -318,7 +318,7 @@ fill_arc (DiaRenderer *self,
* \memberof _DiaTransformRenderer
*/
static void
-draw_ellipse (DiaRenderer *self,
+draw_ellipse (DiaRenderer *self,
Point *center,
real width, real height,
Color *fill, Color *stroke)
@@ -333,7 +333,7 @@ draw_ellipse (DiaRenderer *self,
* \memberof _DiaTransformRenderer
*/
static void
-draw_bezier (DiaRenderer *self,
+draw_bezier (DiaRenderer *self,
BezPoint *points,
int numpoints,
Color *color)
@@ -345,7 +345,7 @@ draw_bezier (DiaRenderer *self,
* \memberof _DiaTransformRenderer
*/
static void
-draw_beziergon (DiaRenderer *self,
+draw_beziergon (DiaRenderer *self,
BezPoint *points, /* Last point must be same as first point */
int numpoints,
Color *fill,
@@ -357,9 +357,9 @@ draw_beziergon (DiaRenderer *self,
* \brief Transform the text object while drawing
* \memberof _DiaTransformRenderer
*/
-static void
+static void
draw_text (DiaRenderer *self,
- Text *text)
+ Text *text)
{
DiaTransformRenderer *renderer = DIA_TRANSFORM_RENDERER (self);
DiaMatrix *m = g_queue_peek_tail (renderer->matrices);
@@ -496,12 +496,12 @@ draw_image(DiaRenderer *self,
static void
draw_object (DiaRenderer *self,
DiaObject *object,
- DiaMatrix *matrix)
+ DiaMatrix *matrix)
{
DiaTransformRenderer *renderer = DIA_TRANSFORM_RENDERER (self);
DiaMatrix *m = g_queue_peek_tail (renderer->matrices);
g_return_if_fail (renderer->worker != NULL);
-
+
if (matrix) {
DiaMatrix *m2 = g_new (DiaMatrix, 1);
if (m)
@@ -511,9 +511,10 @@ draw_object (DiaRenderer *self,
g_queue_push_tail (renderer->matrices, m2);
}
/* This will call us again */
- object->ops->draw(object, DIA_RENDERER (renderer));
- if (matrix)
+ dia_object_draw (object, DIA_RENDERER (renderer));
+ if (matrix) {
g_free (g_queue_pop_tail (renderer->matrices));
+ }
}
/*!
diff --git a/lib/geometry.c b/lib/geometry.c
index 624d22b8..6501c5ed 100644
--- a/lib/geometry.c
+++ b/lib/geometry.c
@@ -94,7 +94,7 @@ rectangle_in_rectangle(const Rectangle* outer, const Rectangle *inner)
(inner->top < outer->top) ||
(inner->bottom > outer->bottom))
return FALSE;
-
+
return TRUE;
}
@@ -171,11 +171,11 @@ distance_line_point(const Point *line_start, const Point *line_end,
}
projlen = point_dot(&v1,&v2) / v1_lensq;
-
+
if (projlen<0.0) {
return sqrt(point_dot(&v2,&v2));
}
-
+
if (projlen>1.0) {
Point v3 = *point;
point_sub(&v3,line_end);
@@ -191,7 +191,7 @@ distance_line_point(const Point *line_start, const Point *line_end,
if (perp_dist < 0.0) {
perp_dist = 0.0;
}
-
+
return perp_dist;
}
@@ -239,10 +239,10 @@ distance_polygon_point(const Point *poly, guint npoints, real line_width,
/* if cross is not NULL, it will be incremented for each ray crossing */
static real
-bez_point_distance_and_ray_crosses(const Point *b1,
- const Point *b2, const Point *b3,
+bez_point_distance_and_ray_crosses(const Point *b1,
+ const Point *b2, const Point *b3,
const Point *b4,
- real line_width, const Point *point,
+ real line_width, const Point *point,
guint *cross)
{
static gboolean calculated_coeff = FALSE;
@@ -287,7 +287,7 @@ bez_point_distance_and_ray_crosses(const Point *b1,
}
real
-distance_bez_seg_point(const Point *b1, const BezPoint *b2,
+distance_bez_seg_point(const Point *b1, const BezPoint *b2,
real line_width, const Point *point)
{
if (b2->type == BEZ_CURVE_TO)
@@ -296,7 +296,7 @@ distance_bez_seg_point(const Point *b1, const BezPoint *b2,
else
return distance_line_point(b1, &b2->p1, line_width, point);
}
-
+
real
distance_bez_line_point(const BezPoint *b, guint npoints,
real line_width, const Point *point)
@@ -395,7 +395,7 @@ distance_ellipse_point(const Point *centre, real width, real height,
real line_width, const Point *point)
{
/* A faster intersection method would be to scaled the ellipse and the
- * point to where the ellipse is a circle, intersect with the circle,
+ * point to where the ellipse is a circle, intersect with the circle,
* then scale back.
*/
real w2 = width*width, h2 = height*height;
@@ -616,7 +616,7 @@ fillet(Point *p1, Point *p2, Point *p3, Point *p4,
return TRUE;
}
-int
+int
three_point_circle (const Point *p1, const Point *p2, const Point *p3,
Point* center, real* radius)
{
@@ -649,7 +649,7 @@ three_point_circle (const Point *p1, const Point *p2, const Point *p3,
/* moved this here since it is being reused by rounded polyline code*/
-real
+real
point_cross(Point *p1, Point *p2)
{
return p1->x * p2->y - p2->x * p1->y;
@@ -659,7 +659,7 @@ point_cross(Point *p1, Point *p2)
/* Computes one point between end and objmid which
* touches the edge of the object */
Point
-calculate_object_edge(Point *objmid, Point *end, DiaObject *obj)
+calculate_object_edge(Point *objmid, Point *end, DiaObject *obj)
{
#define MAXITER 25
#ifdef TRACE_DIST
@@ -676,12 +676,12 @@ calculate_object_edge(Point *objmid, Point *end, DiaObject *obj)
mid3 = *end;
/* If the other end is inside the object */
- dist = obj->ops->distance_from(obj, &mid3);
+ dist = dia_object_distance_from (obj, &mid3);
if (dist < 0.001) return mid1;
do {
- dist = obj->ops->distance_from(obj, &mid2);
+ dist = dia_object_distance_from (obj, &mid2);
if (dist < 0.0000001) {
mid1 = mid2;
} else {
@@ -695,7 +695,7 @@ calculate_object_edge(Point *objmid, Point *end, DiaObject *obj)
#endif
i++;
} while (i < MAXITER && (dist < 0.0000001 || dist > 0.001));
-
+
#ifdef TRACE_DIST
if (i == MAXITER) {
for (i = 0; i < MAXITER; i++) {
@@ -713,7 +713,7 @@ calculate_object_edge(Point *objmid, Point *end, DiaObject *obj)
* @param matrix matrix to check
* \extends _DiaMatrix
*/
-gboolean
+gboolean
dia_matrix_is_identity (const DiaMatrix *matrix)
{
const real epsilon = 1e-6;
@@ -788,7 +788,7 @@ dia_matrix_get_angle_and_scales (const DiaMatrix *m,
len1 = sqrt(rxx * rxx + ryx * ryx);
len2 = sqrt(rxy * rxy + ryy * ryy);
no_skew = fabs(len1 - len2) < epsilon;
-
+
angle = atan2(ryx, rxx);
if (a)
*a = angle;
@@ -810,7 +810,7 @@ dia_matrix_get_angle_and_scales (const DiaMatrix *m,
* @param sy vertical scale
* \extends _DiaMatrix
*/
-void
+void
dia_matrix_set_angle_and_scales (DiaMatrix *m,
real a,
real sx,
diff --git a/lib/group.c b/lib/group.c
index 879ce64a..a5097d6c 100644
--- a/lib/group.c
+++ b/lib/group.c
@@ -104,7 +104,7 @@ group_distance_from(Group *group, Point *point)
Point tp = *point;
dist = 100000.0;
-
+
if (group->matrix) {
DiaMatrix mi = *group->matrix;
@@ -117,12 +117,12 @@ group_distance_from(Group *group, Point *point)
list = group->objects;
while (list != NULL) {
obj = (DiaObject *) list->data;
-
- dist = MIN(dist, obj->ops->distance_from(obj, &tp));
- list = g_list_next(list);
+ dist = MIN (dist, dia_object_distance_from (obj, &tp));
+
+ list = g_list_next (list);
}
-
+
return dist;
}
@@ -136,7 +136,7 @@ static void
group_update_handles(Group *group)
{
Rectangle *bb = &group->object.bounding_box;
-
+
group->handles[0].id = HANDLE_RESIZE_NW;
group->handles[0].pos.x = bb->left;
group->handles[0].pos.y = bb->top;
@@ -173,7 +173,7 @@ group_update_handles(Group *group)
/*! \brief Update connection points positions of contained objects
* BEWARE: must only be called _once_ per update run!
*/
-static void
+static void
group_update_connectionpoints(Group *group)
{
#if 0
@@ -223,7 +223,7 @@ group_move_handle(Group *group, Handle *handle, Point *to, ConnectionPoint *cp,
/* before and after width and height */
real w0, h0, w1, h1;
Point fixed;
-
+
assert(handle->id>=HANDLE_RESIZE_NW);
assert(handle->id<=HANDLE_RESIZE_SE);
@@ -318,12 +318,12 @@ group_move(Group *group, Point *to)
delta = *to;
pos = group->object.position;
point_sub(&delta, &pos);
-
- /* We don't need any transformation of delta, because
+
+ /* We don't need any transformation of delta, because
* group_update_data () maintains the relative position.
*/
group_objects_move_delta(group, &delta);
-
+
group_update_data(group);
return NULL;
@@ -344,7 +344,7 @@ group_draw(Group *group, DiaRenderer *renderer)
}
}
-void
+void
group_destroy_shallow(DiaObject *obj)
{
Group *group = (Group *)obj;
@@ -364,7 +364,7 @@ group_destroy_shallow(DiaObject *obj)
g_free(group);
}
-static void
+static void
group_destroy(Group *group)
{
DiaObject *obj = &group->object;
@@ -374,7 +374,7 @@ group_destroy(Group *group)
/* ConnectionPoints in the inner objects have already
been unconnected and freed. */
obj->num_connections = 0;
-
+
prop_desc_list_free_handler_chain((PropDescription *)group->pdesc);
g_free((PropDescription *)group->pdesc);
@@ -382,7 +382,7 @@ group_destroy(Group *group)
object_destroy(obj);
}
-/*! Accessor for visible/usable number of connections for app/
+/*! Accessor for visible/usable number of connections for app/
*
* Should probably become a DiaObject member when more objects need
* such special handling.
@@ -406,19 +406,19 @@ group_copy(Group *group)
DiaObject *listobj;
GList *list;
int num_conn, i;
-
+
obj = &group->object;
-
+
newgroup = g_new0(Group,1);
newobj = &newgroup->object;
object_copy(obj, newobj);
-
+
for (i=0;i<8;i++) {
newobj->handles[i] = &newgroup->handles[i];
newgroup->handles[i] = group->handles[i];
}
-
+
newgroup->matrix = g_memdup(group->matrix, sizeof(DiaMatrix));
newgroup->objects = object_copy_list(group->objects);
@@ -433,7 +433,7 @@ group_copy(Group *group)
/* Make connectionpoints be that of the 'inner' objects: */
newobj->connections[num_conn++] = listobj->connections[i];
}
-
+
list = g_list_next(list);
}
@@ -458,14 +458,14 @@ group_update_data(Group *group)
list = g_list_next(list);
while (list != NULL) {
obj = (DiaObject *) list->data;
-
+
rectangle_union(&group->object.bounding_box, &obj->bounding_box);
-
+
list = g_list_next(list);
}
obj = (DiaObject *) group->objects->data;
-
+
/* Move group by the point of the first object, otherwise a group
with all objects on grid might be moved off grid. */
group->object.position = obj->position;
@@ -539,10 +539,10 @@ group_create(GList *objects)
g_return_val_if_fail (objects != NULL, NULL);
group = g_new0(Group,1);
- obj = &group->object;
+ obj = DIA_OBJECT (group);
obj->type = &group_type;
-
+
obj->ops = &group_ops;
group->objects = objects;
@@ -558,10 +558,10 @@ group_create(GList *objects)
part_obj = (DiaObject *) list->data;
num_conn += dia_object_get_num_connections(part_obj);
-
+
list = g_list_next(list);
}
-
+
object_init(obj, 8, num_conn);
/* Make connectionpoints be that of the 'inner' objects: */
@@ -573,7 +573,7 @@ group_create(GList *objects)
for (i=0;i<dia_object_get_num_connections(part_obj);i++) {
obj->connections[num_conn++] = part_obj->connections[i];
}
-
+
list = g_list_next(list);
}
@@ -598,32 +598,31 @@ group_objects(DiaObject *group)
}
static gboolean
-group_prop_event_deliver(Group *group, Property *prop)
+group_prop_event_deliver (Group *group, Property *prop)
{
GList *tmp;
for (tmp = group->objects; tmp != NULL; tmp = tmp->next) {
DiaObject *obj = tmp->data;
-
- if (obj->ops->describe_props) {
- const PropDescription *pdesc,*plist;
-
- /* I'm sorry. I haven't found a working less ugly solution :( */
- plist = obj->ops->describe_props(obj);
- pdesc = prop_desc_list_find_prop(plist,prop->descr->name);
- if (pdesc && pdesc->event_handler) {
- /* deliver */
- PropEventHandler hdl = prop_desc_find_real_handler(pdesc);
- if (hdl) {
- return hdl(obj,prop);
- } else {
- g_warning("dropped group event on prop %s, "
- "final handler was NULL",prop->descr->name);
- return FALSE;
- }
+ const PropDescription *pdesc,*plist;
+
+ /* I'm sorry. I haven't found a working less ugly solution :( */
+ plist = dia_object_describe_properties (obj);
+ pdesc = prop_desc_list_find_prop (plist, prop->descr->name);
+ if (pdesc && pdesc->event_handler) {
+ /* deliver */
+ PropEventHandler hdl = prop_desc_find_real_handler (pdesc);
+ if (hdl) {
+ return hdl (obj,prop);
+ } else {
+ g_warning ("dropped group event on prop %s, "
+ "final handler was NULL",prop->descr->name);
+ return FALSE;
}
}
}
- g_warning("undelivered group property event for prop %s",prop->descr->name);
+
+ g_warning ("undelivered group property event for prop %s", prop->descr->name);
+
return FALSE;
}
@@ -673,7 +672,7 @@ group_describe_props(Group *group)
/* hijack event delivery */
for (i=0; i < n_other; i++) {
/* Ensure we have no duplicates with our own properties */
- if (group->pdesc[i].event_handler)
+ if (group->pdesc[i].event_handler)
prop_desc_insert_handler((PropDescription *)&group->pdesc[i],
(PropEventHandler)group_prop_event_deliver);
}
@@ -681,7 +680,7 @@ group_describe_props(Group *group)
{
int n_own = G_N_ELEMENTS(_group_props) - 1;
PropDescription *arr = g_new (PropDescription, n_other+n_own+1);
-
+
for (i = 0; i < n_own; ++i)
arr[i] = _group_props[i];
memcpy (&arr[n_own], group->pdesc, (n_other+1) * sizeof(PropDescription));
@@ -725,18 +724,16 @@ group_get_props(Group *group, GPtrArray *props)
g_ptr_array_add(props_list, p);
}
- object_get_props_from_offsets(&group->object, _group_offsets, props_self);
+ object_get_props_from_offsets (&group->object, _group_offsets, props_self);
for (tmp = group->objects; tmp != NULL; tmp = tmp->next) {
DiaObject *obj = tmp->data;
- if (obj->ops->get_props) {
- obj->ops->get_props(obj, props_list);
- }
+ dia_object_get_properties (obj, props_list);
}
- g_ptr_array_free(props_list, TRUE);
- g_ptr_array_free(props_self, TRUE);
+ g_ptr_array_free (props_list, TRUE);
+ g_ptr_array_free (props_self, TRUE);
}
static void
@@ -765,9 +762,7 @@ group_set_props(Group *group, GPtrArray *props)
for (tmp = group->objects; tmp != NULL; tmp = tmp->next) {
DiaObject *obj = tmp->data;
- if (obj->ops->set_props) {
- obj->ops->set_props(obj, props_list);
- }
+ dia_object_set_properties (obj, props_list);
}
g_ptr_array_free(props_list, TRUE);
@@ -814,16 +809,16 @@ group_apply_properties_list(Group *group, GPtrArray *props)
g_ptr_array_add(props_list, p);
}
- for (tmp = group->objects; tmp != NULL; tmp = g_list_next(tmp)) {
- DiaObject *obj = (DiaObject*)tmp->data;
+ for (tmp = group->objects; tmp != NULL; tmp = g_list_next (tmp)) {
+ DiaObject *obj = (DiaObject*) tmp->data;
objchange = NULL;
-
- objchange = obj->ops->apply_properties_list(obj, props_list);
- clist = g_list_append(clist, objchange);
+
+ objchange = dia_object_apply_properties (obj, props_list);
+ clist = g_list_append (clist, objchange);
}
/* finally ourself */
objchange = object_apply_props (&group->object, props_self);
- clist = g_list_append(clist, objchange);
+ clist = g_list_append (clist, objchange);
g_ptr_array_free(props_list, TRUE);
g_ptr_array_free(props_self, TRUE);
@@ -877,7 +872,7 @@ group_prop_change_revert(GroupPropChange *change, DiaObject *obj)
}
}
-static void
+static void
group_prop_change_free(GroupPropChange *change)
{
GList *tmp;
diff --git a/lib/group.h b/lib/group.h
index 90590082..35c43349 100644
--- a/lib/group.h
+++ b/lib/group.h
@@ -23,6 +23,8 @@
G_BEGIN_DECLS
+#define DIA_GROUP(object) ((Group *) object)
+
extern DIAVAR DiaObjectType group_type;
/* Make sure there are no connections from objects to objects
diff --git a/lib/layer.c b/lib/layer.c
index 7dacb2ca..6c6208c1 100644
--- a/lib/layer.c
+++ b/lib/layer.c
@@ -461,7 +461,7 @@ layer_find_closest_object_except(Layer *layer, Point *pos,
obj = (DiaObject *) l->data;
/* Check bounding box here too. Might give speedup. */
- dist = obj->ops->distance_from(obj, pos);
+ dist = dia_object_distance_from (obj, pos);
if (maxdist-dist > 0.00000001) {
for (avoid_tmp = avoid; avoid_tmp != NULL; avoid_tmp = avoid_tmp->next) {
diff --git a/lib/object.c b/lib/object.c
index 55f4ad83..d7b8d5a2 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
+#define _DIA_OBJECT_BUILD 1
#include "object.h"
#include "diagramdata.h" /* for Layer */
#include "message.h"
@@ -1276,3 +1277,440 @@ dia_object_type_get_icon (const DiaObjectType *type)
return pixbuf;
}
+
+/**
+ * dia_object_draw:
+ * @self: The object to draw.
+ * @renderer: The #DiaRenderer object to draw with.
+ *
+ * Function responsible for drawing the object.
+ *
+ * Every drawing must be done through the use of the Renderer, so that we
+ * can render the picture on screen, in an eps file, ...
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+void
+dia_object_draw (DiaObject *self,
+ DiaRenderer *renderer)
+{
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (self->ops->draw != NULL);
+
+ self->ops->draw (self, renderer);
+}
+
+/**
+ * dia_object_distance_from:
+ * @self: The object.
+ * @point: A #Point to give the distance to.
+ *
+ * Calculate the distance between the #DiaObject and the #Point.
+ *
+ * Several functions are provided in geometry.h to facilitate this calculus.
+ *
+ * Returns: The distance from the point to the nearest part of the object.
+ * If the point is inside a closed object, return 0.0.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+double
+dia_object_distance_from (DiaObject *self,
+ Point *point)
+{
+ g_return_val_if_fail (self != NULL, 0.0);
+ g_return_val_if_fail (self->ops->distance_from != NULL, 0.0);
+
+ return self->ops->distance_from (self, point);
+}
+
+
+/**
+ * dia_object_select:
+ * @self: An object that is being selected.
+ * @point: is the point on the screen where the user has clicked
+ * @renderer: is a renderer that has some extra functions
+ * most notably the possibility to get EXACT
+ * measures of strings. Used to place cursors
+ * and other interactive stuff.
+ * (Don't draw to the renderer)
+ *
+ * Activate the selected state of the #DiaObject
+ *
+ * Function called once the object has been selected.
+ * Basically, this function should update the object (position of the
+ * handles,...)
+ * This function should not redraw the object.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+void
+dia_object_select (DiaObject *self,
+ Point *point,
+ DiaRenderer *renderer)
+{
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (self->ops->selectf != NULL);
+
+ self->ops->selectf (self, point, renderer);
+}
+
+/**
+ * dia_object_clone:
+ * @self: An object to make a copy of.
+ *
+ * Copy constructor of #DiaObject.
+ *
+ * This must be an depth-copy (pointers must be duplicated and so on)
+ * as the initial object can be deleted any time.
+ *
+ * Returns: A newly allocated object copied from @self, but without any
+ * connections to other objects.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+DiaObject *
+dia_object_clone (DiaObject *self)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (self->ops->copy != NULL, NULL);
+
+ return self->ops->copy (self);
+}
+
+/**
+ * dia_object_move:
+ * @self: The object being moved.
+ * @to: Where the object is being moved to.
+ * Its exact definition depends on the object. It is the point on the
+ * object that 'snaps' to the grid if that is enabled. (generally it
+ * is the upper left corner)
+ *
+ * Function called to move the entire object.
+ *
+ * Returns: An #ObjectChange with additional undo information, or
+ * (in most cases) %NULL. Undo for moving the object itself is
+ * handled elsewhere.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+ObjectChange *
+dia_object_move (DiaObject *self,
+ Point *to)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (self->ops->move != NULL, NULL);
+
+ return self->ops->move (self, to);
+}
+
+/**
+ * dia_object_move_handle:
+ * @self: The object whose handle is being moved.
+ * @handle: The handle being moved.
+ * @to: The position it has been moved to (corrected for
+ * vertical/horizontal only movement).
+ * @cp: If non-%NULL, the connectionpoint found at this position.
+ * If @a cp is %NULL, there may or may not be a connectionpoint.
+ * @reason: The reason the handle was moved.
+ * - %HANDLE_MOVE_USER means the user is dragging the point.
+ * - %HANDLE_MOVE_USER_FINAL means the user let go of the point.
+ * - %HANDLE_MOVE_CONNECTED means it was moved because something
+ * it was connected to moved.
+ * - %HANDLE_MOVE_CREATE_FINAL: is given for resizing during creation
+ * None of the given reasons is a reason to decline movement, typical
+ * object implementations can safely ignore this parameter.
+ * @modifiers: gives a bitset of modifier keys currently held down
+ * - %MODIFIER_SHIFT is either shift key
+ * - %MODIFIER_ALT is either alt key
+ * - %MODIFIER_CONTROL is either control key
+ * Each has MODIFIER_LEFT_* and MODIFIER_RIGHT_* variants
+ *
+ * Function called to move one of the handles associated with the object.
+ *
+ * Returns: An #ObjectChange with additional undo information, or
+ * (in most cases) %NULL. Undo for moving the handle itself is handled
+ * elsewhere.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+ObjectChange *
+dia_object_move_handle (DiaObject *self,
+ Handle *handle,
+ Point *to,
+ ConnectionPoint *cp,
+ HandleMoveReason reason,
+ ModifierKeys modifiers)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (self->ops->move_handle != NULL, NULL);
+
+ return self->ops->move_handle (self, handle, to, cp, reason, modifiers);
+}
+
+/**
+ * dia_object_get_editor:
+ * @self: An obj that this dialog is being made for.
+ * @is_default: If %TRUE, this dialog is for object defaults, and
+ * the toolbox options should not be shown.
+ *
+ * Function called when the user has double clicked on an DiaObject.
+ *
+ * When this function is called and the dialog already is created,
+ * make sure to update the values in the widgets so that it
+ * accurately describes the current state of the object.
+ * Remember to destroy this dialog when the object is destroyed!
+
+ * Note that if you want to use the same dialog multiple times,
+ * you should ref it first. Just run the following on the widget
+ * when you create it:
+ * g_object_ref_sink(widget);
+ * If you don't do this, the widget will be destroyed when the
+ * properties dialog is closed.
+ *
+ * Returns: A dialog to edit the properties of the object.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+GtkWidget *
+dia_object_get_editor (DiaObject *self,
+ gboolean is_default)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (self->ops->get_properties != NULL, NULL);
+
+ return self->ops->get_properties (self, is_default);
+}
+
+/**
+ * dia_object_apply_editor:
+ * @self: The object whose dialog has had its Apply button clicked.
+ * @editor: The properties dialog being applied.
+ *
+ * Function is called when the user clicks on the "Apply" button.
+ *
+ * The widget parameter is the one created by
+ * the get_properties function.
+ *
+ * Returns: a #Change that can be used for undo/redo, The returned change is
+ * already applied.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+ObjectChange *
+dia_object_apply_editor (DiaObject *self,
+ GtkWidget *editor)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (self->ops->apply_properties_from_dialog != NULL, NULL);
+
+ return self->ops->apply_properties_from_dialog (self, editor);
+}
+
+/**
+ * dia_object_get_menu:
+ * @self: The object that is selected when the object menu is asked for.
+ * @at: Where the user clicked. This can be used to place whatever
+ * the menu point may create, such as new segment corners.
+ *
+ * Return an object-specific menu with toggles etc. properly set.
+ *
+ * Returns: A menu description with values set appropriately for this object.
+ * The description object must not be freed by the caller.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+DiaMenu *
+dia_object_get_menu (DiaObject *self,
+ Point *at)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (self->ops->get_object_menu != NULL, NULL);
+
+ return self->ops->get_object_menu (self, at);
+}
+
+/**
+ * dia_object_describe_properties:
+ * @self: The object whose properties we want described.
+ *
+ * Describe the properties that this object supports.
+ *
+ * Returns: a %NULL-terminated array of property descriptions.
+ * As the const return implies the returned data is not owned by the
+ * caller. If this function returns a dynamically created description,
+ * then DestroyFunc must free the description.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+const PropDescription *
+dia_object_describe_properties (DiaObject *self)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (self->ops->describe_props != NULL, NULL);
+
+ return self->ops->describe_props (self);
+}
+
+/**
+ * dia_object_get_properties:
+ * @self: An object that delivers the values.
+ * @list: (out): A list of #Property objects whose values are to be set based
+ * on the objects internal data. The types for the objects are
+ * also being set as a side-effect.
+ *
+ * Get the actual values of the properties given.
+ *
+ * Note that the props array need not contain all the properties
+ * defined for the object, nor do all the properties in the array need be
+ * defined for the object. All properties in the props array that are
+ * actually set will be set.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+void
+dia_object_get_properties (DiaObject *self,
+ GPtrArray *list)
+{
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (self->ops->get_props != NULL);
+
+ self->ops->get_props (self, list);
+}
+
+/**
+ * dia_object_set_properties:
+ * @self: An object to update values on.
+ * @list: An array of #Property objects whose values are to be set on
+ * the object.
+ *
+ * Set the object to have the values defined in the properties list.
+ *
+ * Note that the props array may contain more or fewer properties than the
+ * object defines, but only and all the ones defined for the object will
+ * be applied to the object.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+void
+dia_object_set_properties (DiaObject *self,
+ GPtrArray *list)
+{
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (self->ops->set_props != NULL);
+
+ self->ops->set_props (self, list);
+}
+
+
+/**
+ * dia_object_apply_properties:
+ * @self: The object to which properties are to be applied
+ * @list: The list of properties that are to be applied
+ *
+ * Function used to apply a list of properties to the object.
+ *
+ * It is typically called by ApplyPropertiesDialogFunc. This
+ * is different from SetPropsFunc since this is used to implement
+ * undo/redo.
+ *
+ * Returns: a #Change for undo/redo
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+ObjectChange *
+dia_object_apply_properties (DiaObject *self,
+ GPtrArray *list)
+{
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (self->ops->apply_properties_list != NULL, NULL);
+
+ return self->ops->apply_properties_list (self, list);
+}
+
+/**
+ * dia_object_edit_text:
+ * @self: The self object
+ * @text: The text entry being edited
+ * @state: The state of the editing, either %TEXT_EDIT_START,
+ * %TEXT_EDIT_INSERT, %TEXT_EDIT_DELETE, or %TEXT_EDIT_END.
+ * @textchange: For %TEXT_EDIT_INSERT, the text about to be inserted.
+ * For %TEXT_EDIT_DELETE, the text about to be deleted.
+ *
+ * Update the text part of an object
+ *
+ * This function, if not null, will be called every time the text is changed
+ * or editing starts or stops.
+ *
+ * Returns: For %TEXT_EDIT_INSERT and %TEXT_EDIT_DELETE, %TRUE this change
+ * will be allowed, %FALSE otherwise. For %TEXT_EDIT_START and %TEXT_EDIT_END,
+ * the return value is ignored.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+gboolean
+dia_object_edit_text (DiaObject *self,
+ Text *text,
+ TextEditState state,
+ gchar *textchange)
+{
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (self->ops->edit_text != NULL, FALSE);
+
+ return self->ops->edit_text (self, text, state, textchange);
+}
+
+/**
+ * dia_object_transform:
+ * @self: Explicit this pointer
+ * @m: The transformation matrix
+ *
+ * Transform the object with the given matrix
+ *
+ * This function - if not null - will apply the transformation matrix to the
+ * object. It should be implemented for every standard object, because it's
+ * main use-case is the support of transformations from SVG.
+ *
+ * Returns: %TRUE if the matrix can be applied to the object, %FALSE otherwise.
+ *
+ * Stability: Stable
+ *
+ * Since: 0.98
+ */
+gboolean
+dia_object_transform (DiaObject *self,
+ const DiaMatrix *m)
+{
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (self->ops->transform != NULL, FALSE);
+
+ return self->ops->transform (self, m);
+}
diff --git a/lib/object.h b/lib/object.h
index af65794c..6f7991e3 100644
--- a/lib/object.h
+++ b/lib/object.h
@@ -171,255 +171,35 @@ typedef void *(*ApplyDefaultsFunc) ();
*/
typedef void (*DestroyFunc) (DiaObject* obj);
+// TODO: Actually check the cast with GType
+#define DIA_OBJECT(object) ((DiaObject *) object)
-/*!
- * \brief Function responsible for drawing the object.
- *
- * Every drawing must be done through the use of the Renderer, so that we
- * can render the picture on screen, in an eps file, ...
- *
- * @param The object to draw.
- * @param The renderer object to draw with.
- *
- * \public \memberof _DiaObject
- */
typedef void (*DrawFunc) (DiaObject* obj, DiaRenderer* ddisp);
-
-
-/*!
- * \brief Calculate the distance between the _DiaObject and the Point.
- *
- * Several functions are provided in geometry.h to facilitate this calculus.
- *
- * @param obj The object.
- * @param point A point to give the distance to.
- * @return The distance from the point to the nearest part of the object.
- * If the point is inside a closed object, return 0.0.
- * \public \memberof _DiaObject
- */
typedef real (*DistanceFunc) (DiaObject* obj, Point* point);
-
-
-/*!
- * \brief Activate the selected state of the _DiaObject
- *
- * Function called once the object has been selected.
- * Basically, this function should update the object (position of the
- * handles,...)
- * This function should not redraw the object.
- *
- * @param obj An object that is being selected.
- * @param clicked_point is the point on the screen where the user has clicked
- * @param interactive_renderer is a renderer that has some extra functions
- * most notably the possibility to get EXACT
- * measures of strings. Used to place cursors
- * and other interactive stuff.
- * (Don't draw to the renderer)
- * \public \memberof _DiaObject
- */
typedef void (*SelectFunc) (DiaObject* obj,
Point* clicked_point,
DiaRenderer* interactive_renderer);
-
-/*!
- * \brief Copy constructor of _DiaObject.
- *
- * This must be an depth-copy (pointers must be duplicated and so on)
- * as the initial object can be deleted any time.
- *
- * @param obj An object to make a copy of.
- * @return A newly allocated object copied from `obj', but without any
- * connections to other objects.
- * \public \memberof _DiaObject
- */
typedef DiaObject* (*CopyFunc) (DiaObject* obj);
-
-/*!
- * \brief Function called to move the entire object.
- *
- * @param obj The object being moved.
- * @param pos Where the object is being moved to.
- * Its exact definition depends on the object. It is the point on the
- * object that 'snaps' to the grid if that is enabled. (generally it
- * is the upper left corner)
- * @return An ObjectChange* with additional undo information, or
- * (in most cases) NULL. Undo for moving the object itself is handled
- * elsewhere.
- * \public \memberof _DiaObject
- */
typedef ObjectChange* (*MoveFunc) (DiaObject* obj, Point * pos);
-
-/*!
- * \brief Function called to move one of the handles associated with the object.
- *
- * @param obj The object whose handle is being moved.
- * @param handle The handle being moved.
- * @param pos The position it has been moved to (corrected for
- * vertical/horizontal only movement).
- * @param cp If non-NULL, the connectionpoint found at this position.
- * If @a cp is NULL, there may or may not be a connectionpoint.
- * @param The reason the handle was moved.
- * - HANDLE_MOVE_USER means the user is dragging the point.
- * - HANDLE_MOVE_USER_FINAL means the user let go of the point.
- * - HANDLE_MOVE_CONNECTED means it was moved because something
- * it was connected to moved.
- * - HANDLE_MOVE_CREATE_FINAL: is given for resizing during creation
- * None of the given reasons is a reason to decline movement, typical
- * object implementations can safely ignore this parameter.
- * @param modifiers gives a bitset of modifier keys currently held down
- * - MODIFIER_SHIFT is either shift key
- * - MODIFIER_ALT is either alt key
- * - MODIFIER_CONTROL is either control key
- * Each has MODIFIER_LEFT_* and MODIFIER_RIGHT_* variants
- * @return An @a ObjectChange* with additional undo information, or
- * (in most cases) NULL. Undo for moving the handle itself is handled
- * elsewhere.
- * \public \memberof _DiaObject
- */
typedef ObjectChange* (*MoveHandleFunc) (DiaObject* obj,
Handle* handle,
Point* pos,
ConnectionPoint* cp,
HandleMoveReason reason,
ModifierKeys modifiers);
-
-/*!
- * \brief Function called when the user has double clicked on an DiaObject.
- *
- * @param obj An obj that this dialog is being made for.
- * @param is_default If true, this dialog is for object defaults, and
- * the toolbox options should not be shown.
- * @return A dialog to edit the properties of the object.
- * When this function is called and the dialog already is created,
- * make sure to update the values in the widgets so that it
- * accurately describes the current state of the object.
- * Remember to destroy this dialog when the object is destroyed!
-
- * Note that if you want to use the same dialog multiple times,
- * you should ref it first. Just run the following on the widget
- * when you create it:
- * g_object_ref_sink(widget);
- * If you don't do this, the widget will be destroyed when the
- * properties dialog is closed.
- * \public \memberof _DiaObject
- */
typedef GtkWidget *(*GetPropertiesFunc) (DiaObject* obj, gboolean is_default);
-
-/*!
- * \brief Function is called when the user clicks on the "Apply" button.
- *
- * The widget parameter is the one created by
- * the get_properties function.
- *
- * @param obj The object whose dialog has had its Apply button clicked.
- * @param widget The properties dialog being applied.
- * @return a Change that can be used for undo/redo.
- * The returned change is already applied.
- * \public \memberof _DiaObject
- */
typedef ObjectChange *(*ApplyPropertiesDialogFunc) (DiaObject* obj, GtkWidget *widget);
-
-/*!
- * \brief Function used to apply a list of properties to the object.
- *
- * It is typically called by ApplyPropertiesDialogFunc. This
- * is different from SetPropsFunc since this is used to implement
- * undo/redo.
- *
- * @param obj The object to which properties are to be applied
- * @param props The list of properties that are to be applied
- * @return a Change for undo/redo
- * \public \memberof _DiaObject
- */
- typedef ObjectChange *(*ApplyPropertiesListFunc) (DiaObject* obj, GPtrArray* props);
-
-/*!
- * \brief Describe the properties that this object supports.
- *
- * @param obj The object whose properties we want described.
- * @return a NULL-terminated array of property descriptions.
- * As the const return implies the returned data is not owned by the
- * caller. If this function returns a dynamically created description,
- * then DestroyFunc must free the description.
- * \public \memberof _DiaObject
- */
+typedef ObjectChange *(*ApplyPropertiesListFunc) (DiaObject* obj, GPtrArray* props);
typedef const PropDescription *(* DescribePropsFunc) (DiaObject *obj);
-
-/*!
- * \brief Get the actual values of the properties given.
- *
- * Note that the props array need not contain all the properties
- * defined for the object, nor do all the properties in the array need be
- * defined for the object. All properties in the props array that are
- * actually set will be set.
- *
- * @param obj An object that delivers the values.
- * @param props A list of Property objects whose values are to be set based
- * on the objects internal data. The types for the objects are
- * also being set as a side-effect.
- * \public \memberof _DiaObject
- */
typedef void (* GetPropsFunc) (DiaObject *obj, GPtrArray *props);
-
-/*!
- * \brief Set the object to have the values defined in the properties list.
- *
- * Note that the props array may contain more or fewer properties than the
- * object defines, but only and all the ones defined for the object will
- * be applied to the object.
- *
- * @param obj An object to update values on.
- * @param props An array of Property objects whose values are to be set on
- * the object.
- * \public \memberof _DiaObject
- */
typedef void (* SetPropsFunc) (DiaObject *obj, GPtrArray *props);
-
-/*!
- * \brief Return an object-specific menu with toggles etc. properly set.
- *
- * @param obj The object that is selected when the object menu is asked for.
- * @param position Where the user clicked. This can be used to place whatever
- * the menu point may create, such as new segment corners.
- * @return A menu description with values set appropriately for this object.
- * The description object must not be freed by the caller.
- * \public \memberof _DiaObject
- */
typedef DiaMenu *(*ObjectMenuFunc) (DiaObject* obj, Point *position);
-
-/*!
- * \brief Update the text part of an object
- *
- * This function, if not null, will be called every time the text is changed
- * or editing starts or stops.
- *
- * @param obj The self object
- * @param text The text entry being edited
- * @param state The state of the editing, either TEXT_EDIT_START,
- * TEXT_EDIT_INSERT, TEXT_EDIT_DELETE, or TEXT_EDIT_END.
- * @param textchange For TEXT_EDIT_INSERT, the text about to be inserted.
- * For TEXT_EDIT_DELETE, the text about to be deleted.
- * @return For TEXT_EDIT_INSERT and TEXT_EDIT_DELETE, TRUE this change
- * will be allowed, FALSE otherwise. For TEXT_EDIT_START and TEXT_EDIT_END,
- * the return value is ignored.
- * \public \memberof _DiaObject
- */
typedef gboolean (*TextEditFunc) (DiaObject *obj, Text *text, TextEditState state, gchar *textchange);
-
-/*!
- * \brief Transform the object with the given matrix
- *
- * This function - if not null - will apply the transformation matrix to the
- * object. It should be implemented for every standard object, because it's
- * main use-case is the support of transformations from SVG.
- *
- * @param obj Explicit this pointer
- * @param m The transformation matrix
- * @returns TRUE if the matrix can be applied to the object, FALSE otherwise.
- * \public \memberof _DiaObject
- */
typedef gboolean (*TransformFunc) (DiaObject *obj, const DiaMatrix *m);
+
+
+
/*************************************
** The functions provided in object.c
*************************************/
@@ -479,25 +259,43 @@ DiaObject *object_copy_using_properties(DiaObject *obj);
*/
struct _ObjectOps {
DestroyFunc destroy;
- DrawFunc draw;
- DistanceFunc distance_from;
- SelectFunc selectf;
- CopyFunc copy;
- MoveFunc move;
- MoveHandleFunc move_handle;
- GetPropertiesFunc get_properties;
- ApplyPropertiesDialogFunc apply_properties_from_dialog;
- ObjectMenuFunc get_object_menu;
-
- DescribePropsFunc describe_props;
- GetPropsFunc get_props;
- SetPropsFunc set_props;
-
- TextEditFunc edit_text;
-
- ApplyPropertiesListFunc apply_properties_list;
- /*! check for NULL before calling */
- TransformFunc transform;
+
+ void (*draw) (DiaObject *obj,
+ DiaRenderer *ddisp);
+ real (*distance_from) (DiaObject *obj,
+ Point *point);
+ void (*selectf) (DiaObject *obj,
+ Point *clicked_point,
+ DiaRenderer *interactive_renderer);
+ DiaObject *(*copy) (DiaObject *obj);
+ ObjectChange *(*move) (DiaObject *obj,
+ Point *pos);
+ ObjectChange *(*move_handle) (DiaObject *obj,
+ Handle *handle,
+ Point *pos,
+ ConnectionPoint *cp,
+ HandleMoveReason reason,
+ ModifierKeys modifiers);
+ GtkWidget *(*get_properties) (DiaObject *obj,
+ gboolean is_default);
+ ObjectChange *(*apply_properties_from_dialog) (DiaObject *obj,
+ GtkWidget *widget);
+ DiaMenu *(*get_object_menu) (DiaObject *obj,
+ Point *position);
+ const PropDescription *(*describe_props) (DiaObject *obj);
+ void (*get_props) (DiaObject *obj,
+ GPtrArray *props);
+ void (*set_props) (DiaObject *obj,
+ GPtrArray *props);
+ gboolean (*edit_text) (DiaObject *obj,
+ Text *text,
+ TextEditState state,
+ gchar *textchange);
+ ObjectChange *(*apply_properties_list) (DiaObject *obj,
+ GPtrArray *props);
+ gboolean (*transform) (DiaObject *obj,
+ const DiaMatrix *m);
+
/*!
Unused places (for extension).
These should be NULL for now. In the future they might be used.
@@ -507,6 +305,12 @@ struct _ObjectOps {
void (*unused[3])(DiaObject *obj,...);
};
+// #ifdef _DIA_OBJECT_BUILD
+# define _DIA_OBJECT_FIELD(type,name) type name
+// #else
+// # define _DIA_OBJECT_FIELD(type,name) type __graphene_private_##name
+// #endif
+
/*!
\brief Base class for all of Dia's objects, i.e. diagram building blocks
@@ -544,7 +348,7 @@ struct _DiaObject {
/*! Array of ConnectionPoint* - indexing fixed by meaning */
ConnectionPoint **connections;
- ObjectOps *ops; /* pointer to the vtable */
+ _DIA_OBJECT_FIELD (ObjectOps *, ops); /* pointer to the vtable */
Layer *parent_layer; /*!< Back-pointer to the owning layer.
This may only be set by functions internal to
@@ -628,6 +432,45 @@ struct _DiaObjectType {
{ "meta", PROP_TYPE_DICT, offsetof(DiaObject, meta) }
+void dia_object_draw (DiaObject *self,
+ DiaRenderer *renderer);
+double dia_object_distance_from (DiaObject *self,
+ Point *point);
+// TODO: Probably shouldn't pass renderer here
+void dia_object_select (DiaObject *self,
+ Point *point,
+ DiaRenderer *renderer);
+// Note: wraps copy
+DiaObject *dia_object_clone (DiaObject *self);
+ObjectChange *dia_object_move (DiaObject *self,
+ Point *to);
+ObjectChange *dia_object_move_handle (DiaObject *self,
+ Handle *handle,
+ Point *to,
+ ConnectionPoint *cp,
+ HandleMoveReason reason,
+ ModifierKeys modifiers);
+// Note: Wraps get_properties
+GtkWidget *dia_object_get_editor (DiaObject *self,
+ gboolean is_default);
+ObjectChange *dia_object_apply_editor (DiaObject *self,
+ GtkWidget *editor);
+DiaMenu *dia_object_get_menu (DiaObject *self,
+ Point *at);
+const PropDescription *dia_object_describe_properties (DiaObject *self);
+void dia_object_get_properties (DiaObject *self,
+ GPtrArray *list);
+void dia_object_set_properties (DiaObject *self,
+ GPtrArray *list);
+ObjectChange *dia_object_apply_properties (DiaObject *self,
+ GPtrArray *list);
+gboolean dia_object_edit_text (DiaObject *self,
+ Text *text,
+ TextEditState state,
+ gchar *textchange);
+gboolean dia_object_transform (DiaObject *self,
+ const DiaMatrix *m);
+
gboolean dia_object_defaults_load (const gchar *filename,
gboolean create_lazy,
DiaContext *ctx);
diff --git a/lib/object_defaults.c b/lib/object_defaults.c
index fd151a83..b2759336 100644
--- a/lib/object_defaults.c
+++ b/lib/object_defaults.c
@@ -2,7 +2,7 @@
* Copyright (C) 1998 Alexander Larsson
*
* object_defaults.c : manage default properties of dia objects
- * The serialization is done with standard object methods in
+ * The serialization is done with standard object methods in
* a diagram compatible format.
*
* Copyright (C) 2002 Hans Breuer
@@ -37,7 +37,7 @@
#include "diacontext.h"
#include "dia_dirs.h"
#include "propinternals.h"
-
+
static GHashTable *defaults_hash = NULL;
static gboolean object_default_create_lazy = FALSE;
@@ -52,7 +52,7 @@ _obj_create (gpointer key,
DiaObject *obj;
Point startpoint = {0.0,0.0};
Handle *handle1,*handle2;
-
+
g_assert (g_hash_table_lookup (ht, name) == NULL);
/* at least 'Group' has no ops */
@@ -74,7 +74,7 @@ _obj_destroy (gpointer val)
{
DiaObject *obj = (DiaObject *)val;
- obj->ops->destroy (obj);
+ object_destroy (obj);
g_free (obj);
}
@@ -84,7 +84,7 @@ _obj_destroy (gpointer val)
* every known type. Otherwise default objects
* are created on demand
* @param ctx The context in which this function is called
- *
+ *
* Create all the default objects.
*/
gboolean
@@ -96,116 +96,101 @@ dia_object_defaults_load (const gchar *filename, gboolean create_lazy, DiaContex
object_default_create_lazy = create_lazy;
- if (!defaults_hash)
- {
- defaults_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
- NULL, _obj_destroy);
+ if (!defaults_hash) {
+ defaults_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+ NULL, _obj_destroy);
- if (!create_lazy)
- object_registry_foreach (_obj_create, defaults_hash);
+ if (!create_lazy) {
+ object_registry_foreach (_obj_create, defaults_hash);
}
+ }
+
-
/* overload properties from file */
- if (!filename)
- {
- gchar *default_filename = dia_config_filename("defaults.dia");
-
- dia_context_set_filename(ctx, default_filename);
- if (g_file_test(default_filename, G_FILE_TEST_EXISTS))
- doc = diaXmlParseFile (default_filename, ctx, FALSE);
- else
- doc = NULL;
- g_free (default_filename);
- }
- else
- {
- dia_context_set_filename (ctx, filename);
- doc = diaXmlParseFile (filename, ctx, FALSE);
+ if (!filename) {
+ gchar *default_filename = dia_config_filename("defaults.dia");
+
+ dia_context_set_filename (ctx, default_filename);
+ if (g_file_test (default_filename, G_FILE_TEST_EXISTS)) {
+ doc = diaXmlParseFile (default_filename, ctx, FALSE);
+ } else {
+ doc = NULL;
}
+ g_free (default_filename);
+ } else {
+ dia_context_set_filename (ctx, filename);
+ doc = diaXmlParseFile (filename, ctx, FALSE);
+ }
- if (!doc)
- return FALSE;
+ if (!doc) {
+ return FALSE;
+ }
- name_space = xmlSearchNs(doc, doc->xmlRootNode, (const xmlChar *)"dia");
- if (xmlStrcmp (doc->xmlRootNode->name, (const xmlChar *)"diagram")
- || (name_space == NULL))
- {
- dia_context_add_message(ctx, _("Error loading defaults '%s'.\n"
- "Not a Dia diagram file."), filename);
- xmlFreeDoc (doc);
- return FALSE;
- }
+ name_space = xmlSearchNs (doc, doc->xmlRootNode, (const xmlChar *) "dia");
+ if (xmlStrcmp (doc->xmlRootNode->name, (const xmlChar *) "diagram")
+ || (name_space == NULL)) {
+ dia_context_add_message (ctx,
+ _("Error loading defaults '%s'.\n"
+ "Not a Dia diagram file."),
+ filename);
+ xmlFreeDoc (doc);
+ return FALSE;
+ }
layer_node = doc->xmlRootNode->xmlChildrenNode;
- while (layer_node)
- {
- if ( !xmlIsBlankNode(layer_node)
- && 0 == xmlStrcmp(layer_node->name, (const xmlChar *)"layer"))
- {
- obj_node = layer_node->xmlChildrenNode;
- while (obj_node)
- {
- if (!xmlIsBlankNode(obj_node)
- && 0 == xmlStrcmp(obj_node->name, (const xmlChar *)"object"))
- {
- char *typestr = (char *) xmlGetProp(obj_node, (const xmlChar *)"type");
- char *version = (char *) xmlGetProp(obj_node, (const xmlChar *)"version");
- if (typestr)
- {
- DiaObject *obj = g_hash_table_lookup (defaults_hash, typestr);
- if (!obj)
- {
- if (!create_lazy)
- g_warning ("Unknown object '%s' while reading '%s'",
- typestr, filename);
- else
- {
- DiaObjectType *type = object_get_type (typestr);
- if (type)
- obj = type->ops->load (
- obj_node,
- version ? atoi(version) : 0,
- ctx);
- if (obj)
- g_hash_table_insert (defaults_hash,
- obj->type->name, obj);
- }
- }
- else
- {
+ while (layer_node) {
+ if ( !xmlIsBlankNode (layer_node)
+ && 0 == xmlStrcmp (layer_node->name, (const xmlChar *) "layer")) {
+ obj_node = layer_node->xmlChildrenNode;
+
+ while (obj_node) {
+ if (!xmlIsBlankNode (obj_node)
+ && 0 == xmlStrcmp (obj_node->name, (const xmlChar *) "object")) {
+ char *typestr = (char *) xmlGetProp(obj_node, (const xmlChar *) "type");
+ char *version = (char *) xmlGetProp(obj_node, (const xmlChar *) "version");
+ if (typestr) {
+ DiaObject *obj = g_hash_table_lookup (defaults_hash, typestr);
+ if (!obj) {
+ if (!create_lazy) {
+ g_warning ("Unknown object '%s' while reading '%s'",
+ typestr, filename);
+ } else {
+ DiaObjectType *type = object_get_type (typestr);
+ if (type) {
+ obj = type->ops->load (obj_node,
+ version ? atoi(version) : 0,
+ ctx);
+ }
+ if (obj) {
+ g_hash_table_insert (defaults_hash,
+ obj->type->name,
+ obj);
+ }
+ }
+ } else {
#if 0 /* lots of complaining about missing attributes */
- object_load_props(obj, obj_node, ctx); /* leaks ?? */
+ object_load_props(obj, obj_node, ctx); /* leaks ?? */
#else
- DiaObject *def_obj;
- def_obj = obj->type->ops->load (
- obj_node,
- version ? atoi(version) : 0,
- ctx);
- if (def_obj->ops->set_props)
- {
- object_copy_props (obj, def_obj, TRUE);
- def_obj->ops->destroy (def_obj);
- }
- else
- {
- /* can't copy props */
- g_hash_table_replace (defaults_hash,
- def_obj->type->name, def_obj);
- }
-#endif
- }
- if (version)
- xmlFree (version);
- xmlFree (typestr);
- }
- }
- obj_node = obj_node->next;
- }
- }
- layer_node = layer_node->next;
+ DiaObject *def_obj;
+ def_obj = obj->type->ops->load (obj_node,
+ version ? atoi(version) : 0,
+ ctx);
+ object_copy_props (obj, def_obj, TRUE);
+ object_destroy (def_obj);
+ #endif
+ }
+ if (version) {
+ xmlFree (version);
+ }
+ xmlFree (typestr);
+ }
+ }
+ obj_node = obj_node->next;
+ }
}
- xmlFreeDoc(doc);
+ layer_node = layer_node->next;
+ }
+ xmlFreeDoc (doc);
return TRUE;
}
@@ -226,14 +211,14 @@ dia_object_default_get (const DiaObjectType *type, gpointer user_data)
{
Point startpoint = {0.0,0.0};
Handle *handle1,*handle2;
-
+
/* at least 'Group' has no ops */
if (!type->ops)
return NULL;
/* the custom objects needs extra_data */
- obj = type->ops->create(&startpoint,
- type->default_user_data,
+ obj = type->ops->create(&startpoint,
+ type->default_user_data,
&handle1,&handle2);
if (obj)
g_hash_table_insert (defaults_hash, obj->type->name, obj);
@@ -242,7 +227,7 @@ dia_object_default_get (const DiaObjectType *type, gpointer user_data)
return obj;
}
-static gboolean
+static gboolean
pdtpp_standard_or_defaults (const PropDescription *pdesc)
{
return ( (pdesc->flags & PROP_FLAG_NO_DEFAULTS) == 0
@@ -275,24 +260,20 @@ dia_object_default_create (const DiaObjectType *type,
/* don't use dia_object_default_get() as it would insert the object into the hashtable (store defaults
without being asked for it) */
def_obj = g_hash_table_lookup (defaults_hash, type->name);
- if (def_obj && def_obj->ops->describe_props)
- {
- /* copy properties to new object, but keep position */
- obj = type->ops->create (startpoint, user_data, handle1, handle2);
- if (obj)
- {
- GPtrArray *props = prop_list_from_descs (
- object_get_prop_descriptions(def_obj), pdtpp_standard_or_defaults);
- def_obj->ops->get_props((DiaObject *)def_obj, props);
- obj->ops->set_props(obj, props);
- obj->ops->move (obj, startpoint);
- prop_list_free(props);
- }
- }
- else
- {
- obj = type->ops->create (startpoint, user_data, handle1, handle2);
+ if (def_obj) {
+ /* copy properties to new object, but keep position */
+ obj = type->ops->create (startpoint, user_data, handle1, handle2);
+ if (obj) {
+ GPtrArray *props = prop_list_from_descs (object_get_prop_descriptions (def_obj),
+ pdtpp_standard_or_defaults);
+ dia_object_get_properties ((DiaObject *) def_obj, props);
+ dia_object_set_properties (obj, props);
+ dia_object_move (obj, startpoint);
+ prop_list_free (props);
}
+ } else {
+ obj = type->ops->create (startpoint, user_data, handle1, handle2);
+ }
return obj;
}
@@ -329,7 +310,7 @@ _obj_store (gpointer key,
gchar *p;
MyLayerInfo *li;
- /* fires if you have messed up the hash keys,
+ /* fires if you have messed up the hash keys,
* e.g. by using non permanent memory */
g_assert (0 == strcmp (obj->type->name, name));
@@ -366,18 +347,18 @@ _obj_store (gpointer key,
xmlSetProp(obj_node, (const xmlChar *)"id", (xmlChar *)buffer);
/* if it looks like intdata store it as well */
- if ( GPOINTER_TO_INT(obj->type->default_user_data) > 0
+ if ( GPOINTER_TO_INT(obj->type->default_user_data) > 0
&& GPOINTER_TO_INT(obj->type->default_user_data) < 0xFF) {
g_snprintf(buffer, 30, "%d", GPOINTER_TO_INT(obj->type->default_user_data));
xmlSetProp(obj_node, (const xmlChar *)"intdata", (xmlChar *)buffer);
}
- obj->ops->move (obj,&(li->pos));
+ dia_object_move (obj, &(li->pos));
/* saving every property of the object */
obj->type->ops->save (obj, obj_node, ri->ctx);
/* arrange following objects below */
- li->pos.y += (obj->bounding_box.bottom - obj->bounding_box.top + 1.0);
+ li->pos.y += (obj->bounding_box.bottom - obj->bounding_box.top + 1.0);
}
/**
@@ -404,7 +385,7 @@ dia_object_defaults_save (const gchar *filename, DiaContext *ctx)
doc->encoding = xmlStrdup((const xmlChar *)"UTF-8");
doc->xmlRootNode = xmlNewDocNode(doc, NULL, (const xmlChar *)"diagram", NULL);
- ni.name_space = xmlNewNs(doc->xmlRootNode,
+ ni.name_space = xmlNewNs(doc->xmlRootNode,
(const xmlChar *)DIA_XML_NAME_SPACE_BASE,
(const xmlChar *)"dia");
xmlSetNs(doc->xmlRootNode, ni.name_space);
diff --git a/lib/propdialogs.c b/lib/propdialogs.c
index f405beab..bcc3f528 100644
--- a/lib/propdialogs.c
+++ b/lib/propdialogs.c
@@ -189,10 +189,10 @@ property_signal_handler(GObject *obj,
prop_get_data_from_widgets(dialog);
for (tmp = list; tmp != NULL; tmp = tmp->next) {
- DiaObject *obj = (DiaObject*)tmp->data;
- obj->ops->set_props(obj,dialog->props);
- prop->event_handler(obj,prop);
- obj->ops->get_props(obj,dialog->props);
+ DiaObject *obj = (DiaObject*) tmp->data;
+ dia_object_set_properties (obj, dialog->props);
+ prop->event_handler (obj, prop);
+ dia_object_get_properties (obj, dialog->props);
}
for (j = 0; j < dialog->prop_widgets->len; j++) {
diff --git a/lib/propobject.c b/lib/propobject.c
index bb4d8fd6..a869414d 100644
--- a/lib/propobject.c
+++ b/lib/propobject.c
@@ -37,30 +37,29 @@
#include "object.h"
const PropDescription *
-object_get_prop_descriptions(const DiaObject *obj) {
+object_get_prop_descriptions (const DiaObject *obj) {
const PropDescription *pdesc;
- if (!obj->ops->describe_props) return NULL;
- pdesc = obj->ops->describe_props((DiaObject *)obj); /* Yes... */
+ pdesc = dia_object_describe_properties ((DiaObject *) obj); /* Yes... */
if (!pdesc) return NULL;
if (pdesc[0].quark != 0) return pdesc;
- prop_desc_list_calculate_quarks((PropDescription *)pdesc); /* Yes again... */
+ prop_desc_list_calculate_quarks ((PropDescription *) pdesc); /* Yes again... */
return pdesc;
}
const PropDescription *
-object_list_get_prop_descriptions(GList *objects, PropMergeOption option)
+object_list_get_prop_descriptions (GList *objects, PropMergeOption option)
{
GList *descs = NULL, *tmp;
const PropDescription *pdesc;
for (tmp = objects; tmp != NULL; tmp = tmp->next) {
DiaObject *obj = tmp->data;
- const PropDescription *desc = object_get_prop_descriptions(obj);
+ const PropDescription *desc = object_get_prop_descriptions (obj);
- if (desc) descs = g_list_append(descs, (gpointer)desc);
+ if (desc) descs = g_list_append (descs, (gpointer)desc);
}
/* use intersection for single object's list because it is more
@@ -112,21 +111,19 @@ struct _ObjectPropChange {
};
static void
-object_prop_change_apply_revert(ObjectPropChange *change, DiaObject *obj)
+object_prop_change_apply_revert (ObjectPropChange *change, DiaObject *obj)
{
GPtrArray *old_props;
- old_props = prop_list_copy_empty(change->saved_props);
+ old_props = prop_list_copy_empty (change->saved_props);
- if (change->obj->ops->get_props)
- change->obj->ops->get_props(change->obj, old_props);
+ dia_object_get_properties (change->obj, old_props);
/* set saved property values */
- if (change->obj->ops->set_props)
- change->obj->ops->set_props(change->obj, change->saved_props);
+ dia_object_set_properties (change->obj, change->saved_props);
/* move old props to saved properties */
- prop_list_free(change->saved_props);
+ prop_list_free (change->saved_props);
change->saved_props = old_props;
}
@@ -137,12 +134,12 @@ object_prop_change_free(ObjectPropChange *change)
}
ObjectChange *
-object_apply_props(DiaObject *obj, GPtrArray *props)
+object_apply_props (DiaObject *obj, GPtrArray *props)
{
ObjectPropChange *change;
GPtrArray *old_props;
- change = g_new0(ObjectPropChange, 1);
+ change = g_new0 (ObjectPropChange, 1);
change->obj_change.apply =
(ObjectChangeApplyFunc) object_prop_change_apply_revert;
@@ -154,18 +151,16 @@ object_apply_props(DiaObject *obj, GPtrArray *props)
change->obj = obj;
/* create new properties structure with current values */
- old_props = prop_list_copy_empty(props);
+ old_props = prop_list_copy_empty (props);
- if (obj->ops->get_props)
- obj->ops->get_props(obj, old_props);
+ dia_object_get_properties (obj, old_props);
/* set saved property values */
- if (obj->ops->set_props)
- obj->ops->set_props(obj, props);
+ dia_object_set_properties (obj, props);
change->saved_props = old_props;
- return (ObjectChange *)change;
+ return (ObjectChange *) change;
}
/*!
@@ -236,17 +231,8 @@ object_apply_props_from_dialog(DiaObject *obj, WIDGET *dialog_widget)
if ((p->experience & PXP_NOTSET) == 0)
g_ptr_array_add(props, p);
}
- /* with an empty list there is no change at all but simply
- * returning NULL is against the contract ...
- */
- if (!obj->ops->apply_properties_list) {
- g_warning("using a fallback function to apply properties;"
- " undo may not work correctly");
- change = object_apply_props(obj, props);
- } else {
- change = obj->ops->apply_properties_list(obj, props);
- }
- g_ptr_array_free(props, TRUE);
+ change = dia_object_apply_properties (obj, props);
+ g_ptr_array_free (props, TRUE);
return change;
}
@@ -267,18 +253,6 @@ objects_comply_with_stdprop(GList *objects)
gboolean
object_complies_with_stdprop(const DiaObject *obj)
{
- if (obj->ops->set_props == NULL) {
- g_warning("No set_props !");
- return FALSE;
- }
- if (obj->ops->get_props == NULL) {
- g_warning("No get_props !");
- return FALSE;
- }
- if (obj->ops->describe_props == NULL) {
- g_warning("No describe_props !");
- return FALSE;
- }
if (object_get_prop_descriptions(obj) == NULL) {
g_warning("No properties !");
return FALSE;
@@ -287,13 +261,13 @@ object_complies_with_stdprop(const DiaObject *obj)
}
void
-object_list_get_props(GList *objects, GPtrArray *props)
+object_list_get_props (GList *objects, GPtrArray *props)
{
GList *tmp = objects;
for (; tmp != NULL; tmp = tmp->next) {
- DiaObject *obj = (DiaObject*)tmp->data;
- obj->ops->get_props(obj,props);
+ DiaObject *obj = (DiaObject*) tmp->data;
+ dia_object_get_properties (obj, props);
}
}
@@ -304,27 +278,24 @@ pdtpp_do_save_no_standard_default (const PropDescription *pdesc)
}
void
-object_copy_props(DiaObject *dest, const DiaObject *src, gboolean is_default)
+object_copy_props (DiaObject *dest, const DiaObject *src, gboolean is_default)
{
GPtrArray *props;
- g_return_if_fail(src != NULL);
- g_return_if_fail(dest != NULL);
- g_return_if_fail(strcmp(src->type->name,dest->type->name)==0);
- g_return_if_fail(src->ops == dest->ops);
- g_return_if_fail(object_complies_with_stdprop(src));
- g_return_if_fail(object_complies_with_stdprop(dest));
+ g_return_if_fail (src != NULL);
+ g_return_if_fail (dest != NULL);
+ g_return_if_fail (g_strcmp0 (src->type->name, dest->type->name) == 0);
+ g_return_if_fail (object_complies_with_stdprop (src));
+ g_return_if_fail (object_complies_with_stdprop (dest));
- props = prop_list_from_descs(object_get_prop_descriptions(src),
- (is_default?pdtpp_do_save_no_standard_default:
- pdtpp_do_save));
+ props = prop_list_from_descs (object_get_prop_descriptions (src),
+ (is_default ? pdtpp_do_save_no_standard_default:
+ pdtpp_do_save));
- src->ops->get_props((DiaObject *)src, props); /* FIXME: really should make
- get_props' first argument
- a (const DiaObject *) */
- dest->ops->set_props(dest, props);
+ dia_object_get_properties ((DiaObject *) src, props);
+ dia_object_set_properties (dest, props);
- prop_list_free(props);
+ prop_list_free (props);
}
void
@@ -343,8 +314,8 @@ object_load_props(DiaObject *obj, ObjectNode obj_node, DiaContext *ctx)
/* context already has the message */
}
- obj->ops->set_props(obj, props);
- prop_list_free(props);
+ dia_object_set_properties (obj, props);
+ prop_list_free (props);
}
void
@@ -359,9 +330,9 @@ object_save_props(DiaObject *obj, ObjectNode obj_node, DiaContext *ctx)
props = prop_list_from_descs(object_get_prop_descriptions(obj),
pdtpp_do_save);
- obj->ops->get_props(obj, props);
- prop_list_save(props,obj_node,ctx);
- prop_list_free(props);
+ dia_object_get_properties (obj, props);
+ prop_list_save (props, obj_node, ctx);
+ prop_list_free (props);
}
Property *
@@ -385,9 +356,9 @@ object_prop_by_name_type(DiaObject *obj, const char *name, const char *type)
plist = g_ptr_array_new();
g_ptr_array_set_size(plist,1);
}
- prop = pdesc->ops->new_prop(pdesc,pdtpp_from_object);
- g_ptr_array_index(plist,0) = prop;
- obj->ops->get_props(obj,plist);
+ prop = pdesc->ops->new_prop (pdesc, pdtpp_from_object);
+ g_ptr_array_index (plist, 0) = prop;
+ dia_object_get_properties (obj, plist);
return prop;
}
}
diff --git a/lib/renderer/diacairo-interactive.c b/lib/renderer/diacairo-interactive.c
index 1f117c82..628d6958 100644
--- a/lib/renderer/diacairo-interactive.c
+++ b/lib/renderer/diacairo-interactive.c
@@ -555,7 +555,7 @@ dia_cairo_interactive_renderer_draw_object_highlighted (DiaRenderer *self,
/* usually this method would need to draw the object twice,
* once with highlight and once without. But due to our
* draw_text_line implementation we only need one run */
- object->ops->draw (object, self);
+ dia_object_draw (object, self);
/* always reset when done with this object */
interactive->highlight_color = NULL;
}
diff --git a/lib/renderer/diacairo-renderer.c b/lib/renderer/diacairo-renderer.c
index 2bcf1dc6..56467fc9 100644
--- a/lib/renderer/diacairo-renderer.c
+++ b/lib/renderer/diacairo-renderer.c
@@ -364,7 +364,7 @@ dia_cairo_renderer_draw_object (DiaRenderer *self,
g_assert (sizeof (cairo_matrix_t) == sizeof (DiaMatrix));
cairo_transform (renderer->cr, (cairo_matrix_t *) matrix);
}
- object->ops->draw (object, DIA_RENDERER (renderer));
+ dia_object_draw (object, DIA_RENDERER (renderer));
if (matrix) {
cairo_set_matrix (renderer->cr, &before);
}
diff --git a/lib/text.c b/lib/text.c
index 3d8684bf..137d0791 100644
--- a/lib/text.c
+++ b/lib/text.c
@@ -34,7 +34,7 @@
#include "attributes.h"
#include "object.h"
-static int text_key_event(Focus *focus,
+static int text_key_event(Focus *focus,
guint keystate, guint keysym,
const gchar *str, int strlen,
ObjectChange **change);
@@ -93,7 +93,7 @@ text_set_line_text(Text *text, int line_no, gchar *line)
}
/** Delete the line, freeing appropriately and moving stuff up.
- * This function circumvents the normal free/alloc cycle of
+ * This function circumvents the normal free/alloc cycle of
* text_set_line_text. */
static void
text_delete_line(Text *text, int line_no)
@@ -109,7 +109,7 @@ text_delete_line(Text *text, int line_no)
}
/** Insert a new (empty) line at line_no.
- * This function circumvents the normal free/alloc cycle of
+ * This function circumvents the normal free/alloc cycle of
* text_set_line_text. */
static void
text_insert_line(Text *text, int line_no)
@@ -186,7 +186,7 @@ calc_width(Text *text)
for (i = 0; i < text->numlines; i++) {
width = MAX(width, text_get_line_width(text, i));
}
-
+
text->max_width = width;
}
@@ -195,12 +195,12 @@ calc_ascent_descent(Text *text)
{
real sig_a = 0.0,sig_d = 0.0;
gint i;
-
+
for ( i = 0; i < text->numlines; i++) {
sig_a += text_line_get_ascent(text->lines[i]);
sig_d += text_line_get_descent(text->lines[i]);
}
-
+
text->ascent = sig_a / (real)text->numlines;
text->descent = sig_d / (real)text->numlines;
}
@@ -236,7 +236,7 @@ set_string(Text *text, const char *string)
s = string;
}
numlines = 1;
- if (s != NULL)
+ if (s != NULL)
while ( (s = g_utf8_strchr(s, -1, '\n')) != NULL ) {
numlines++;
if (*s) {
@@ -273,7 +273,7 @@ set_string(Text *text, const char *string)
if (text->cursor_row >= text->numlines) {
text->cursor_row = text->numlines - 1;
}
-
+
if (text->cursor_pos > text_get_line_strlen(text, text->cursor_row)) {
text->cursor_pos = text_get_line_strlen(text, text->cursor_row);
}
@@ -285,7 +285,7 @@ text_set_string(Text *text, const char *string)
{
if (text->lines != NULL)
free_string(text);
-
+
set_string(text, string);
}
@@ -306,12 +306,12 @@ new_text(const char *string, DiaFont *font, real height,
text->cursor_pos = 0;
text->cursor_row = 0;
-
+
text->focus.obj = NULL;
text->focus.has_focus = FALSE;
text->focus.key_event = text_key_event;
text->focus.text = text;
-
+
set_string(text, string);
calc_ascent_descent(text);
@@ -330,7 +330,7 @@ new_text_default(Point *pos, Color *color, Alignment align)
real font_height;
attributes_get_default_font(&font, &font_height);
- text = new_text("", font, font_height, pos, color, align);
+ text = new_text("", font, font_height, pos, color, align);
dia_font_unref(font);
return text;
}
@@ -344,7 +344,7 @@ text_copy(Text *text)
copy = g_new(Text, 1);
copy->numlines = text->numlines;
copy->lines = g_new(TextLine *, text->numlines);
-
+
copy->font = dia_font_copy(text->font);
copy->height = text->height;
copy->position = text->position;
@@ -364,11 +364,11 @@ text_copy(Text *text)
copy->focus.has_focus = FALSE;
copy->focus.key_event = text_key_event;
copy->focus.text = copy;
-
+
copy->ascent = text->ascent;
copy->descent = text->descent;
copy->max_width = text->max_width;
-
+
return copy;
}
@@ -410,7 +410,7 @@ text_set_font(Text *text, DiaFont *font)
for (i = 0; i < text->numlines; i++) {
text_line_set_font(text->lines[i], font);
}
-
+
calc_width(text);
calc_ascent_descent(text);
}
@@ -454,7 +454,7 @@ text_calc_boundingbox(Text *text, Rectangle *box)
}
box->right = box->left + text->max_width;
-
+
box->top = text->position.y - text->ascent;
#if 0
box->bottom = box->top + text->height*text->numlines + text->descent;
@@ -469,11 +469,11 @@ text_calc_boundingbox(Text *text, Rectangle *box)
box->left -= height/(CURSOR_HEIGHT_RATIO*2);
} else {
/* Half the cursor width. Assume that
- if it isn't at position zero, it might be
+ if it isn't at position zero, it might be
at the last position possible. */
box->right += height/(CURSOR_HEIGHT_RATIO*2);
}
-
+
/* Account for the size of the cursor top and bottom */
box->top -= height/(CURSOR_HEIGHT_RATIO*2);
box->bottom += height/CURSOR_HEIGHT_RATIO;
@@ -485,24 +485,24 @@ text_get_string_copy(const Text *text)
{
int num,i;
char *str;
-
+
num = 0;
for (i=0;i<text->numlines;i++) {
/* This is for allocation, so it should not use g_utf8_strlen() */
- num += strlen(text_get_line(text, i))+1;
+ num += strlen(text_get_line(text, i))+1;
}
str = g_malloc(num);
*str = 0;
-
+
for (i=0;i<text->numlines;i++) {
strcat(str, text_get_line(text, i));
if (i != (text->numlines-1)) {
strcat(str, "\n");
}
}
-
+
return str;
}
@@ -513,7 +513,7 @@ text_distance_from(Text *text, Point *point)
real topy, bottomy;
real left, right;
int line;
-
+
topy = text->position.y - text->ascent;
bottomy = text->position.y + text->descent + text->height*(text->numlines-1);
if (point->y <= topy) {
@@ -564,7 +564,7 @@ text_draw(Text *text, DiaRenderer *renderer)
real str_width_whole;
Point p1, p2;
real height = text->ascent+text->descent;
- curs_y = text->position.y - text->ascent + text->cursor_row*text->height;
+ curs_y = text->position.y - text->ascent + text->cursor_row*text->height;
DIA_RENDERER_GET_CLASS(renderer)->set_font(renderer, text->font, text->height);
@@ -593,7 +593,7 @@ text_draw(Text *text, DiaRenderer *renderer)
p1.y = curs_y;
p2.x = curs_x;
p2.y = curs_y + height;
-
+
DIA_RENDERER_GET_CLASS(renderer)->set_linestyle(renderer, LINESTYLE_SOLID, 0.0);
DIA_RENDERER_GET_CLASS(renderer)->set_linewidth(renderer, height/CURSOR_HEIGHT_RATIO);
DIA_RENDERER_GET_CLASS(renderer)->draw_line(renderer, &p1, &p2, &color_black);
@@ -629,7 +629,7 @@ text_move_cursor(Text *text, CursorMovement mv)
int i;
for (i = 0; i < text->cursor_pos; ++i)
p = g_utf8_next_char (p);
- }
+ }
if (WORD_START == mv && text->cursor_pos < 1) {
if (text->cursor_row) {
text->cursor_row--;
@@ -676,7 +676,7 @@ text_set_cursor(Text *text, Point *clicked_point,
if (clicked_point != NULL) {
top = text->position.y - text->ascent;
-
+
row = (int)floor((clicked_point->y - top) / text->height);
if (row < 0)
@@ -684,7 +684,7 @@ text_set_cursor(Text *text, Point *clicked_point,
if (row >= text->numlines)
row = text->numlines - 1;
-
+
text->cursor_row = row;
text->cursor_pos = 0;
@@ -740,10 +740,10 @@ text_join_lines(Text *text, int first_line)
{
gchar *combined_line;
int len1;
-
+
len1 = text_get_line_strlen(text, first_line);
- combined_line = g_strconcat(text_get_line(text, first_line),
+ combined_line = g_strconcat(text_get_line(text, first_line),
text_get_line(text, first_line + 1), NULL);
text_delete_line(text, first_line);
text_set_line_text(text, first_line, combined_line);
@@ -764,9 +764,9 @@ text_delete_forward(Text *text)
gchar *line;
gchar *utf8_before, *utf8_after;
gchar *str1, *str;
-
+
row = text->cursor_row;
-
+
if (text->cursor_pos >= text_get_line_strlen(text, row)) {
if (row + 1 < text->numlines)
text_join_lines(text, row);
@@ -801,9 +801,9 @@ text_delete_backward(Text *text)
gchar *line;
gchar *utf8_before, *utf8_after;
gchar *str1, *str;
-
+
row = text->cursor_row;
-
+
if (text->cursor_pos <= 0) {
if (row > 0)
text_join_lines(text, row-1);
@@ -838,7 +838,7 @@ text_split_line(Text *text)
real width;
gchar *utf8_before;
gchar *str1, *str2;
-
+
/* Split the lines at cursor_pos */
line = text_get_line(text, text->cursor_row);
text_insert_line(text, text->cursor_row);
@@ -873,7 +873,7 @@ text_insert_char(Text *text, gunichar c)
/* Make a string of the the char */
unilen = g_unichar_to_utf8 (c, ch);
ch[unilen] = 0;
-
+
row = text->cursor_row;
/* Copy the before and after parts with the new char in between */
@@ -919,8 +919,8 @@ text_delete_key_handler(Focus *focus, ObjectChange ** change)
}
static int
-text_key_event(Focus *focus,
- guint keystate, guint keyval,
+text_key_event(Focus *focus,
+ guint keystate, guint keyval,
const gchar *str, int strlen,
ObjectChange **change)
{
@@ -931,7 +931,7 @@ text_key_event(Focus *focus,
gunichar c;
*change = NULL;
-
+
text = focus->text;
switch(keyval) {
@@ -953,7 +953,7 @@ text_key_event(Focus *focus,
if (text->cursor_pos > text_get_line_strlen(text, text->cursor_row))
text->cursor_pos = text_get_line_strlen(text, text->cursor_row);
-
+
break;
case GDK_Left:
case GDK_KP_Left:
@@ -1037,7 +1037,7 @@ text_key_event(Focus *focus,
utf = g_utf8_next_char (utf), strlen--) {
ObjectChange *step;
c = g_utf8_get_char (utf);
-
+
step = text_create_change (text, TYPE_INSERT_CHAR, c,
text->cursor_pos, text->cursor_row,
focus->obj);
@@ -1046,8 +1046,8 @@ text_key_event(Focus *focus,
}
}
break;
- }
-
+ }
+
return return_val;
}
@@ -1069,7 +1069,7 @@ text_delete_all(Text *text, ObjectChange **change, DiaObject *obj)
*change = text_create_change(text, TYPE_DELETE_ALL,
0, text->cursor_pos, text->cursor_row,
obj);
-
+
text_set_string(text, "");
calc_ascent_descent(text);
return TRUE;
@@ -1129,7 +1129,7 @@ data_text(AttributeNode text_attr, DiaContext *ctx)
} else {
font = dia_font_new_from_style(DIA_FONT_SANS,1.0);
}
-
+
attr = composite_find_attribute(text_attr, "pos");
if (attr != NULL)
data_point(attribute_first_data(attr), &pos, ctx);
@@ -1143,7 +1143,7 @@ data_text(AttributeNode text_attr, DiaContext *ctx)
attr = composite_find_attribute(text_attr, "alignment");
if (attr != NULL)
align = data_enum(attribute_first_data(attr), ctx);
-
+
text = new_text(string ? string : "", font, height, &pos, &col, align);
if (font) dia_font_unref(font);
if (string) g_free(string);
@@ -1152,7 +1152,7 @@ data_text(AttributeNode text_attr, DiaContext *ctx)
void
text_get_attributes(Text *text, TextAttributes *attr)
-{
+{
DiaFont *old_font;
old_font = attr->font;
attr->font = dia_font_ref(text->font);
@@ -1176,43 +1176,41 @@ text_set_attributes(Text *text, TextAttributes *attr)
}
static void
-text_change_apply(struct TextObjectChange *change, DiaObject *obj)
+text_change_apply (struct TextObjectChange *change, DiaObject *obj)
{
Text *text = change->text;
- /* remember previous position/size */
- if (change->obj->ops->get_props)
- change->obj->ops->get_props(change->obj, change->props);
+ dia_object_get_properties (change->obj, change->props);
switch (change->type) {
- case TYPE_INSERT_CHAR:
- text->cursor_pos = change->pos;
- text->cursor_row = change->row;
- text_insert_char(text, change->ch);
- break;
- case TYPE_DELETE_BACKWARD:
- text->cursor_pos = change->pos+1;
- text->cursor_row = change->row;
- text_delete_backward(text);
- break;
- case TYPE_DELETE_FORWARD:
- text->cursor_pos = change->pos;
- text->cursor_row = change->row;
- text_delete_forward(text);
- break;
- case TYPE_SPLIT_ROW:
- text->cursor_pos = change->pos;
- text->cursor_row = change->row;
- text_split_line(text);
- break;
- case TYPE_JOIN_ROW:
- text_join_lines(text, change->row);
- break;
- case TYPE_DELETE_ALL:
- set_string(text, "");
- text->cursor_pos = 0;
- text->cursor_row = 0;
- break;
+ case TYPE_INSERT_CHAR:
+ text->cursor_pos = change->pos;
+ text->cursor_row = change->row;
+ text_insert_char (text, change->ch);
+ break;
+ case TYPE_DELETE_BACKWARD:
+ text->cursor_pos = change->pos+1;
+ text->cursor_row = change->row;
+ text_delete_backward (text);
+ break;
+ case TYPE_DELETE_FORWARD:
+ text->cursor_pos = change->pos;
+ text->cursor_row = change->row;
+ text_delete_forward (text);
+ break;
+ case TYPE_SPLIT_ROW:
+ text->cursor_pos = change->pos;
+ text->cursor_row = change->row;
+ text_split_line (text);
+ break;
+ case TYPE_JOIN_ROW:
+ text_join_lines (text, change->row);
+ break;
+ case TYPE_DELETE_ALL:
+ set_string (text, "");
+ text->cursor_pos = 0;
+ text->cursor_row = 0;
+ break;
}
}
@@ -1253,12 +1251,11 @@ text_change_revert(struct TextObjectChange *change, DiaObject *obj)
break;
}
/* restore previous position/size */
- if (change->obj->ops->set_props)
- change->obj->ops->set_props(change->obj, change->props);
+ dia_object_set_properties (change->obj, change->props);
}
static void
-text_change_free(struct TextObjectChange *change)
+text_change_free(struct TextObjectChange *change)
{
g_free(change->str);
prop_list_free(change->props);
@@ -1298,8 +1295,7 @@ text_create_change(Text *text, TextChangeType type,
change->obj = obj;
change->props = make_posision_and_size_prop_list ();
/* remember previous position/size */
- if (change->obj->ops->get_props)
- change->obj->ops->get_props(change->obj, change->props);
+ dia_object_get_properties (change->obj, change->props);
change->obj_change.apply = (ObjectChangeApplyFunc) text_change_apply;
change->obj_change.revert = (ObjectChangeRevertFunc) text_change_revert;
@@ -1317,36 +1313,36 @@ text_create_change(Text *text, TextChangeType type,
return (ObjectChange *)change;
}
-gboolean
+gboolean
apply_textattr_properties(GPtrArray *props,
Text *text, const gchar *textname,
TextAttributes *attrs)
{
- TextProperty *textprop =
+ TextProperty *textprop =
(TextProperty *)find_prop_by_name_and_type(props,textname,PROP_TYPE_TEXT);
- if ((!textprop) ||
+ if ((!textprop) ||
((textprop->common.experience & (PXP_LOADED|PXP_SFO))==0 )) {
/* most likely we're called after the dialog box has been applied */
text_set_attributes(text,attrs);
- return TRUE;
+ return TRUE;
}
return FALSE;
}
-gboolean
+gboolean
apply_textstr_properties(GPtrArray *props,
Text *text, const gchar *textname,
const gchar *str)
{
- TextProperty *textprop =
+ TextProperty *textprop =
(TextProperty *)find_prop_by_name_and_type(props,textname,PROP_TYPE_TEXT);
- if ((!textprop) ||
+ if ((!textprop) ||
((textprop->common.experience & (PXP_LOADED|PXP_SFO))==0 )) {
/* most likely we're called after the dialog box has been applied */
text_set_string(text,str);
- return TRUE;
+ return TRUE;
}
return FALSE;
}
diff --git a/objects/UML/class.h b/objects/UML/class.h
index 46bc07ff..1f92247f 100644
--- a/objects/UML/class.h
+++ b/objects/UML/class.h
@@ -17,9 +17,9 @@
*
* File: class.h
*
- * Purpose: This is the interface file for the class icon and dialog.
+ * Purpose: This is the interface file for the class icon and dialog.
*/
-
+
/** \file objects/UML/class.h Declaration of the 'UML - Class' type */
#ifndef CLASS_H
#define CLASS_H
@@ -30,8 +30,6 @@
#include "uml.h"
-#define DIA_OBJECT(x) (DiaObject*)(x)
-
/** The number of regular connectionpoints on the class (not cps for
* attributes and operands and not the mainpoint). */
#define UMLCLASS_CONNECTIONPOINTS 8
@@ -40,10 +38,10 @@
/** default wrap length for comments */
#define UMLCLASS_COMMENT_LINE_LENGTH 40
-/* The code behind the following preprocessor symbol should stay disabled until
- * the dynamic relocation of connection points (caused by attribute and
- * operation changes) is taken into account. It probably has other issues we are
- * not aware of yet. Some more information maybe available at
+/* The code behind the following preprocessor symbol should stay disabled until
+ * the dynamic relocation of connection points (caused by attribute and
+ * operation changes) is taken into account. It probably has other issues we are
+ * not aware of yet. Some more information maybe available at
* http://bugzilla.gnome.org/show_bug.cgi?id=303301
*
* Enabling 29/7 2005: Not known to cause any problems.
@@ -56,7 +54,7 @@
typedef struct _UMLClass UMLClass;
typedef struct _UMLClassDialog UMLClassDialog;
-/**
+/**
* \brief The most complex object Dia has
*
* What should I say? Don't try this at home :)
@@ -87,13 +85,13 @@ struct _UMLClass {
DiaFont *classname_font;
DiaFont *abstract_classname_font;
DiaFont *comment_font;
-
+
char *name;
char *stereotype; /**< NULL if no stereotype */
char *comment; /**< Comments on the class */
int abstract;
- int suppress_attributes;
- int suppress_operations;
+ int suppress_attributes;
+ int suppress_operations;
int visible_attributes; /**< ie. don't draw strings. */
int visible_operations;
int visible_comments;
@@ -102,7 +100,7 @@ struct _UMLClass {
int wrap_after_char;
int comment_line_length; /**< Maximum line length for comments */
int comment_tagging; /**< bool: if the {documentation = } tag should be used */
-
+
Color line_color;
Color fill_color;
Color text_color;
@@ -120,10 +118,10 @@ struct _UMLClass {
gboolean allow_resizing;
/* Calculated variables: */
-
+
real namebox_height;
char *stereotype_string;
-
+
real attributesbox_height;
real operationsbox_height;
@@ -142,7 +140,7 @@ struct _UMLClass {
* destroyed, and don't do umlclass_calculate_data when it is set.
* This is to avoid a half-way destroyed list being updated.
*/
- gboolean destroyed;
+ gboolean destroyed;
};
void umlclass_dialog_free (UMLClassDialog *dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]