mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 00:34:59 +01:00
merge gnomecanvas into ardour tree, so that we can fix our own bugs and not wait for silly gnome release schedules
git-svn-id: svn://localhost/ardour2/branches/3.0@8114 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
a2f870bff9
commit
bb592809f1
37 changed files with 18473 additions and 4 deletions
|
|
@ -16,7 +16,7 @@ fi
|
|||
|
||||
export VAMP_PATH=$libs/vamp-plugins${VAMP_PATH:+:$VAMP_PATH}
|
||||
|
||||
export LD_LIBRARY_PATH=$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/sigc++2:$libs/glibmm2:$libs/gtkmm2/atk:$libs/gtkmm2/pango:$libs/gtkmm2/gdk:$libs/gtkmm2/gtk:$libs/libgnomecanvasmm:$libs/libsndfile:$libs/appleutility:$libs/cairomm:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$libs/audiographer${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
export LD_LIBRARY_PATH=$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/gnomecanvas:$libs/libsndfile:$libs/appleutility:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$libs/audiographer${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||
|
||||
# DYLD_LIBRARY_PATH is for darwin.
|
||||
export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH
|
||||
|
|
|
|||
|
|
@ -242,7 +242,6 @@ def configure(conf):
|
|||
autowaf.check_pkg(conf, 'gthread', uselib_store='GTHREAD', atleast_version='2.10.1')
|
||||
autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK', atleast_version='2.18')
|
||||
autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM', atleast_version='2.18')
|
||||
autowaf.check_pkg(conf, 'libgnomecanvas-2.0', uselib_store='GNOMECANVAS', atleast_version='2.0')
|
||||
autowaf.check_pkg(conf, 'libgnomecanvasmm-2.6', uselib_store='GNOMECANVASMM', atleast_version='2.16')
|
||||
autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
|
||||
|
||||
|
|
@ -278,11 +277,11 @@ def build(bld):
|
|||
else:
|
||||
obj.target = 'ardour-3.0'
|
||||
obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
|
||||
obj.uselib = 'UUID FLAC GLIBMM GTHREAD GTK GNOMECANVAS OGG ALSA CURL DL'
|
||||
obj.uselib = 'UUID FLAC GLIBMM GTHREAD GTK OGG ALSA CURL DL'
|
||||
obj.uselib += ' GTKMM GNOMECANVASMM '
|
||||
obj.uselib += ' AUDIOUNITS OSX GTKOSX '
|
||||
obj.uselib_local = '''libpbd libmidipp libtaglib libardour libardour_cp
|
||||
libgtkmm2ext libtaglib'''
|
||||
libgtkmm2ext libtaglib libgnomecanvas-2'''
|
||||
if sys.platform == 'darwin':
|
||||
obj.uselib_local + ' libappleutility'
|
||||
obj.cflags = ['-DPACKAGE="gtk2_ardour"']
|
||||
|
|
|
|||
84
libs/gnomecanvas/config.h
Normal file
84
libs/gnomecanvas/config.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/* config.h. Generated from config.h.in by configure. */
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* always defined to indicate that i18n is enabled */
|
||||
#define ENABLE_NLS 1
|
||||
|
||||
/* Gettext package */
|
||||
#define GETTEXT_PACKAGE "libgnomecanvas-2.0"
|
||||
|
||||
/* Define the location where the catalogs will be installed */
|
||||
#define GNOMECANVASLOCALEDIR "/usr/share/locale"
|
||||
|
||||
/* Define to 1 if you have the `bind_textdomain_codeset' function. */
|
||||
#define HAVE_BIND_TEXTDOMAIN_CODESET 1
|
||||
|
||||
/* Define to 1 if you have the `dcgettext' function. */
|
||||
#define HAVE_DCGETTEXT 1
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define if the GNU gettext() function is already present or preinstalled. */
|
||||
#define HAVE_GETTEXT 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define if your <locale.h> file defines LC_MESSAGES. */
|
||||
#define HAVE_LC_MESSAGES 1
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "libgnomecanvas"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "http://bugzilla.gnome.org/enter_bug.cgi?product=libgnomecanvas"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "libgnomecanvas"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "libgnomecanvas 2.30.1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "libgnomecanvas"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "2.30.1"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "2.30.1"
|
||||
175
libs/gnomecanvas/libgnomecanvas/gnome-canvas-bpath.c
Normal file
175
libs/gnomecanvas/libgnomecanvas/gnome-canvas-bpath.c
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
/* Bpath item type for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
* Copyright (C) 1998,1999 The Free Software Foundation
|
||||
*
|
||||
* Authors: Federico Mena <federico@nuclecu.unam.mx>
|
||||
* Raph Levien <raph@acm.org>
|
||||
* Lauris Kaplinski <lauris@ximian.com>
|
||||
* Miguel de Icaza <miguel@kernel.org>
|
||||
* Cody Russell <bratsche@gnome.org>
|
||||
* Rusty Conover <rconover@bangtail.net>
|
||||
*/
|
||||
|
||||
/* These includes are set up for standalone compile. If/when this codebase
|
||||
is integrated into libgnomeui, the includes will need to change. */
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "gnome-canvas.h"
|
||||
#include "gnome-canvas-util.h"
|
||||
|
||||
#include "gnome-canvas-bpath.h"
|
||||
#include "gnome-canvas-shape.h"
|
||||
#include "gnome-canvas-shape-private.h"
|
||||
#include "gnome-canvas-path-def.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_BPATH
|
||||
};
|
||||
|
||||
static void gnome_canvas_bpath_class_init (GnomeCanvasBpathClass *class);
|
||||
static void gnome_canvas_bpath_init (GnomeCanvasBpath *bpath);
|
||||
static void gnome_canvas_bpath_destroy (GtkObject *object);
|
||||
static void gnome_canvas_bpath_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gnome_canvas_bpath_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gnome_canvas_bpath_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags);
|
||||
|
||||
|
||||
static GnomeCanvasShapeClass *parent_class;
|
||||
|
||||
GType
|
||||
gnome_canvas_bpath_get_type (void)
|
||||
{
|
||||
static GType bpath_type;
|
||||
|
||||
if (!bpath_type) {
|
||||
const GTypeInfo object_info = {
|
||||
sizeof (GnomeCanvasBpathClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gnome_canvas_bpath_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL, /* class_data */
|
||||
sizeof (GnomeCanvasBpath),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gnome_canvas_bpath_init,
|
||||
NULL /* value_table */
|
||||
};
|
||||
|
||||
bpath_type = g_type_register_static (GNOME_TYPE_CANVAS_SHAPE, "GnomeCanvasBpath",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
return bpath_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_bpath_class_init (GnomeCanvasBpathClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkObjectClass *object_class;
|
||||
GnomeCanvasItemClass *item_class;
|
||||
|
||||
gobject_class = (GObjectClass *) class;
|
||||
object_class = (GtkObjectClass *) class;
|
||||
item_class = (GnomeCanvasItemClass *) class;
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
/* when this gets checked into libgnomeui, change the
|
||||
GTK_TYPE_POINTER to GTK_TYPE_GNOME_CANVAS_BPATH, and add an
|
||||
entry to gnome-boxed.defs */
|
||||
|
||||
gobject_class->set_property = gnome_canvas_bpath_set_property;
|
||||
gobject_class->get_property = gnome_canvas_bpath_get_property;
|
||||
|
||||
object_class->destroy = gnome_canvas_bpath_destroy;
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_BPATH,
|
||||
g_param_spec_boxed ("bpath", NULL, NULL,
|
||||
GNOME_TYPE_CANVAS_PATH_DEF,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
|
||||
item_class->update = gnome_canvas_bpath_update;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_bpath_init (GnomeCanvasBpath *bpath)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_bpath_destroy (GtkObject *object)
|
||||
{
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_bpath_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
GnomeCanvasPathDef *gpp;
|
||||
|
||||
item = GNOME_CANVAS_ITEM (object);
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_BPATH:
|
||||
gpp = (GnomeCanvasPathDef*) g_value_get_boxed (value);
|
||||
|
||||
gnome_canvas_shape_set_path_def (GNOME_CANVAS_SHAPE (object), gpp);
|
||||
|
||||
gnome_canvas_item_request_update (item);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnome_canvas_bpath_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GnomeCanvasShape *shape;
|
||||
|
||||
shape = GNOME_CANVAS_SHAPE(object);
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_BPATH:
|
||||
g_value_set_boxed (value, shape->priv->path);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_bpath_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
|
||||
{
|
||||
if(GNOME_CANVAS_ITEM_CLASS(parent_class)->update) {
|
||||
(* GNOME_CANVAS_ITEM_CLASS(parent_class)->update)(item, affine, clip_path, flags);
|
||||
}
|
||||
}
|
||||
61
libs/gnomecanvas/libgnomecanvas/gnome-canvas-bpath.h
Normal file
61
libs/gnomecanvas/libgnomecanvas/gnome-canvas-bpath.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* Bpath item type for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
* Copyright (C) 1998,1999 The Free Software Foundation
|
||||
*
|
||||
* Authors: Federico Mena <federico@nuclecu.unam.mx>
|
||||
* Raph Levien <raph@acm.org>
|
||||
* Lauris Kaplinski <lauris@ximian.com>
|
||||
* Rusty Conover <rconover@bangtail.net>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_BPATH_H
|
||||
#define GNOME_CANVAS_BPATH_H
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
#include <libgnomecanvas/gnome-canvas-shape.h>
|
||||
#include <libgnomecanvas/gnome-canvas-path-def.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* Bpath item for the canvas.
|
||||
*
|
||||
* The following object arguments are available:
|
||||
*
|
||||
* name type read/write description
|
||||
* ------------------------------------------------------------------------------------------
|
||||
* bpath GnomeCanvasPathDef * RW Pointer to an GnomeCanvasPathDef structure.
|
||||
* This can be created by a call to
|
||||
* gp_path_new() in (gp-path.h).
|
||||
*/
|
||||
|
||||
#define GNOME_TYPE_CANVAS_BPATH (gnome_canvas_bpath_get_type ())
|
||||
#define GNOME_CANVAS_BPATH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_BPATH, GnomeCanvasBpath))
|
||||
#define GNOME_CANVAS_BPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_BPATH, GnomeCanvasBpathClass))
|
||||
#define GNOME_IS_CANVAS_BPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_BPATH))
|
||||
#define GNOME_IS_CANVAS_BPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_BPATH))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasBpath GnomeCanvasBpath;
|
||||
typedef struct _GnomeCanvasBpathPriv GnomeCanvasBpathPriv;
|
||||
typedef struct _GnomeCanvasBpathClass GnomeCanvasBpathClass;
|
||||
|
||||
struct _GnomeCanvasBpath {
|
||||
GnomeCanvasShape item;
|
||||
|
||||
};
|
||||
|
||||
struct _GnomeCanvasBpathClass {
|
||||
GnomeCanvasShapeClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_bpath_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
450
libs/gnomecanvas/libgnomecanvas/gnome-canvas-clipgroup.c
Normal file
450
libs/gnomecanvas/libgnomecanvas/gnome-canvas-clipgroup.c
Normal file
|
|
@ -0,0 +1,450 @@
|
|||
#define GNOME_CANVAS_CLIPGROUP_C
|
||||
|
||||
/* Clipping group for GnomeCanvas
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
* Copyright (C) 1998,1999 The Free Software Foundation
|
||||
*
|
||||
* Author:
|
||||
* Lauris Kaplinski <lauris@ximian.com>
|
||||
*/
|
||||
|
||||
/* These includes are set up for standalone compile. If/when this codebase
|
||||
is integrated into libgnomeui, the includes will need to change. */
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libart_lgpl/art_misc.h>
|
||||
#include <libart_lgpl/art_rect.h>
|
||||
#include <libart_lgpl/art_vpath.h>
|
||||
#include <libart_lgpl/art_bpath.h>
|
||||
#include <libart_lgpl/art_vpath.h>
|
||||
#include <libart_lgpl/art_vpath_bpath.h>
|
||||
#include <libart_lgpl/art_svp.h>
|
||||
#include <libart_lgpl/art_svp_vpath.h>
|
||||
#include <libart_lgpl/art_rect_svp.h>
|
||||
#include <libart_lgpl/art_gray_svp.h>
|
||||
#include <libart_lgpl/art_svp_intersect.h>
|
||||
#include <libart_lgpl/art_svp_ops.h>
|
||||
|
||||
#include "gnome-canvas.h"
|
||||
#include "gnome-canvas-util.h"
|
||||
#include "gnome-canvas-clipgroup.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_PATH,
|
||||
PROP_WIND
|
||||
};
|
||||
|
||||
static void gnome_canvas_clipgroup_class_init (GnomeCanvasClipgroupClass *klass);
|
||||
static void gnome_canvas_clipgroup_init (GnomeCanvasClipgroup *clipgroup);
|
||||
static void gnome_canvas_clipgroup_destroy (GtkObject *object);
|
||||
static void gnome_canvas_clipgroup_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gnome_canvas_clipgroup_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gnome_canvas_clipgroup_update (GnomeCanvasItem *item,
|
||||
double *affine,
|
||||
ArtSVP *clip_path,
|
||||
int flags);
|
||||
|
||||
/*
|
||||
* Generic clipping stuff
|
||||
*
|
||||
* This is somewhat slow and memory-hungry - we add extra
|
||||
* composition, extra SVP render and allocate 65536
|
||||
* bytes for each clip level. It could be done more
|
||||
* efficently per-object basis - but to make clipping
|
||||
* universal, there is no alternative to double
|
||||
* buffering (although it should be done into RGBA
|
||||
* buffer by other method than ::render to make global
|
||||
* opacity possible).
|
||||
* Using art-render could possibly optimize that a bit,
|
||||
* although I am not sure.
|
||||
*/
|
||||
|
||||
#define GCG_BUF_WIDTH 128
|
||||
#define GCG_BUF_HEIGHT 128
|
||||
#define GCG_BUF_PIXELS (GCG_BUF_WIDTH * GCG_BUF_HEIGHT)
|
||||
#define GCG_BUF_SIZE (GCG_BUF_WIDTH * GCG_BUF_HEIGHT * 3)
|
||||
|
||||
#define noSHOW_SHADOW
|
||||
|
||||
static guchar *gcg_buf_new (void);
|
||||
static void gcg_buf_free (guchar *buf);
|
||||
static guchar *gcg_mask_new (void);
|
||||
static void gcg_mask_free (guchar *mask);
|
||||
|
||||
static void gnome_canvas_clipgroup_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf);
|
||||
|
||||
static GnomeCanvasGroupClass *parent_class;
|
||||
|
||||
GType
|
||||
gnome_canvas_clipgroup_get_type (void)
|
||||
{
|
||||
static GType clipgroup_type;
|
||||
|
||||
if (!clipgroup_type) {
|
||||
const GTypeInfo object_info = {
|
||||
sizeof (GnomeCanvasClipgroupClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gnome_canvas_clipgroup_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL, /* class_data */
|
||||
sizeof (GnomeCanvasClipgroup),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gnome_canvas_clipgroup_init,
|
||||
NULL /* value_table */
|
||||
};
|
||||
|
||||
clipgroup_type = g_type_register_static (GNOME_TYPE_CANVAS_GROUP, "GnomeCanvasClipgroup",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
return clipgroup_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_clipgroup_class_init (GnomeCanvasClipgroupClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkObjectClass *object_class;
|
||||
GnomeCanvasItemClass *item_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
item_class = (GnomeCanvasItemClass *) klass;
|
||||
parent_class = g_type_class_ref (GNOME_TYPE_CANVAS_GROUP);
|
||||
|
||||
object_class->destroy = gnome_canvas_clipgroup_destroy;
|
||||
gobject_class->set_property = gnome_canvas_clipgroup_set_property;
|
||||
gobject_class->get_property = gnome_canvas_clipgroup_get_property;
|
||||
item_class->update = gnome_canvas_clipgroup_update;
|
||||
item_class->render = gnome_canvas_clipgroup_render;
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_PATH,
|
||||
g_param_spec_pointer ("path", NULL, NULL,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_WIND,
|
||||
g_param_spec_uint ("wind", NULL, NULL,
|
||||
0, G_MAXUINT, 0,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_clipgroup_init (GnomeCanvasClipgroup *clipgroup)
|
||||
{
|
||||
clipgroup->path = NULL;
|
||||
clipgroup->wind = ART_WIND_RULE_NONZERO; /* default winding rule */
|
||||
clipgroup->svp = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_clipgroup_destroy (GtkObject *object)
|
||||
{
|
||||
GnomeCanvasClipgroup *clipgroup;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_CLIPGROUP (object));
|
||||
|
||||
clipgroup = GNOME_CANVAS_CLIPGROUP (object);
|
||||
|
||||
if (clipgroup->path) {
|
||||
gnome_canvas_path_def_unref (clipgroup->path);
|
||||
clipgroup->path = NULL;
|
||||
}
|
||||
|
||||
if (clipgroup->svp) {
|
||||
art_svp_free (clipgroup->svp);
|
||||
clipgroup->svp = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnome_canvas_clipgroup_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
GnomeCanvasClipgroup *cgroup;
|
||||
GnomeCanvasPathDef *gpp;
|
||||
|
||||
item = GNOME_CANVAS_ITEM (object);
|
||||
cgroup = GNOME_CANVAS_CLIPGROUP (object);
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_PATH:
|
||||
gpp = g_value_get_pointer (value);
|
||||
|
||||
if (cgroup->path) {
|
||||
gnome_canvas_path_def_unref (cgroup->path);
|
||||
cgroup->path = NULL;
|
||||
}
|
||||
if (gpp != NULL) {
|
||||
cgroup->path = gnome_canvas_path_def_closed_parts (gpp);
|
||||
}
|
||||
|
||||
gnome_canvas_item_request_update (item);
|
||||
break;
|
||||
|
||||
case PROP_WIND:
|
||||
cgroup->wind = g_value_get_uint (value);
|
||||
gnome_canvas_item_request_update (item);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_clipgroup_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GnomeCanvasClipgroup * cgroup;
|
||||
|
||||
cgroup = GNOME_CANVAS_CLIPGROUP (object);
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_PATH:
|
||||
g_value_set_pointer (value, cgroup->path);
|
||||
break;
|
||||
|
||||
case PROP_WIND:
|
||||
g_value_set_uint (value, cgroup->wind);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_clipgroup_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
|
||||
{
|
||||
GnomeCanvasClipgroup *clipgroup;
|
||||
ArtSvpWriter *swr;
|
||||
ArtBpath *bp;
|
||||
ArtBpath *bpath;
|
||||
ArtVpath *vpath;
|
||||
ArtSVP *svp, *svp1, *svp2;
|
||||
|
||||
clipgroup = GNOME_CANVAS_CLIPGROUP (item);
|
||||
|
||||
if (clipgroup->svp) {
|
||||
art_svp_free (clipgroup->svp);
|
||||
clipgroup->svp = NULL;
|
||||
}
|
||||
|
||||
if (clipgroup->path) {
|
||||
bp = gnome_canvas_path_def_bpath (clipgroup->path);
|
||||
bpath = art_bpath_affine_transform (bp, affine);
|
||||
|
||||
vpath = art_bez_path_to_vec (bpath, 0.25);
|
||||
art_free (bpath);
|
||||
|
||||
svp1 = art_svp_from_vpath (vpath);
|
||||
art_free (vpath);
|
||||
|
||||
swr = art_svp_writer_rewind_new (clipgroup->wind);
|
||||
art_svp_intersector (svp1, swr);
|
||||
|
||||
svp2 = art_svp_writer_rewind_reap (swr);
|
||||
art_svp_free (svp1);
|
||||
|
||||
if (clip_path != NULL) {
|
||||
svp = art_svp_intersect (svp2, clip_path);
|
||||
art_svp_free (svp2);
|
||||
} else {
|
||||
svp = svp2;
|
||||
}
|
||||
|
||||
clipgroup->svp = svp;
|
||||
}
|
||||
|
||||
if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update)
|
||||
(GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, NULL, flags);
|
||||
|
||||
if (clipgroup->svp) {
|
||||
ArtDRect cbox;
|
||||
art_drect_svp (&cbox, clipgroup->svp);
|
||||
item->x1 = MAX (item->x1, cbox.x0 - 1.0);
|
||||
item->y1 = MAX (item->y1, cbox.y0 - 1.0);
|
||||
item->x2 = MIN (item->x2, cbox.x1 + 1.0);
|
||||
item->y2 = MIN (item->y2, cbox.y1 + 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
/* non-premultiplied composition into RGB */
|
||||
|
||||
#define COMPOSEN11(fc,fa,bc) (((255 - (guint) (fa)) * (guint) (bc) + (guint) (fc) * (guint) (fa) + 127) / 255)
|
||||
|
||||
static void
|
||||
gnome_canvas_clipgroup_render (GnomeCanvasItem *item, GnomeCanvasBuf *buf)
|
||||
{
|
||||
GnomeCanvasClipgroup *cg;
|
||||
GnomeCanvasBuf lbuf;
|
||||
guchar *mask;
|
||||
|
||||
cg = GNOME_CANVAS_CLIPGROUP (item);
|
||||
|
||||
if (cg->svp) {
|
||||
gint bw, bh, sw, sh;
|
||||
gint x, y;
|
||||
|
||||
/* fixme: We could optimize background handling (lauris) */
|
||||
|
||||
if (buf->is_bg) {
|
||||
gnome_canvas_buf_ensure_buf (buf);
|
||||
buf->is_bg = FALSE;
|
||||
buf->is_buf = TRUE;
|
||||
}
|
||||
|
||||
bw = buf->rect.x1 - buf->rect.x0;
|
||||
bh = buf->rect.y1 - buf->rect.y0;
|
||||
if ((bw < 1) || (bh < 1)) return;
|
||||
|
||||
if (bw * bh <= GCG_BUF_PIXELS) {
|
||||
/* We can go with single buffer */
|
||||
sw = bw;
|
||||
sh = bh;
|
||||
} else if (bw <= (GCG_BUF_PIXELS >> 3)) {
|
||||
/* Go with row buffer */
|
||||
sw = bw;
|
||||
sh = GCG_BUF_PIXELS / bw;
|
||||
} else if (bh <= (GCG_BUF_PIXELS >> 3)) {
|
||||
/* Go with column buffer */
|
||||
sw = GCG_BUF_PIXELS / bh;
|
||||
sh = bh;
|
||||
} else {
|
||||
/* Tile buffer */
|
||||
sw = GCG_BUF_WIDTH;
|
||||
sh = GCG_BUF_HEIGHT;
|
||||
}
|
||||
|
||||
/* Set up local buffer */
|
||||
lbuf.buf = gcg_buf_new ();
|
||||
lbuf.bg_color = buf->bg_color;
|
||||
lbuf.is_bg = FALSE;
|
||||
lbuf.is_buf = TRUE;
|
||||
/* Allocate mask */
|
||||
mask = gcg_mask_new ();
|
||||
|
||||
for (y = buf->rect.y0; y < buf->rect.y1; y += sh) {
|
||||
for (x = buf->rect.x0; x < buf->rect.x1; x += sw) {
|
||||
gint r, xx, yy;
|
||||
/* Set up local buffer */
|
||||
lbuf.rect.x0 = x;
|
||||
lbuf.rect.y0 = y;
|
||||
lbuf.rect.x1 = MIN (x + sw, buf->rect.x1);
|
||||
lbuf.rect.y1 = MIN (y + sh, buf->rect.y1);
|
||||
lbuf.buf_rowstride = 3 * (lbuf.rect.x1 - lbuf.rect.x0);
|
||||
/* Copy background */
|
||||
for (r = lbuf.rect.y0; r < lbuf.rect.y1; r++) {
|
||||
memcpy (lbuf.buf + (r - lbuf.rect.y0) * lbuf.buf_rowstride,
|
||||
buf->buf + (r - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3,
|
||||
(lbuf.rect.x1 - lbuf.rect.x0) * 3);
|
||||
}
|
||||
/* Invoke render method */
|
||||
if (((GnomeCanvasItemClass *) parent_class)->render)
|
||||
((GnomeCanvasItemClass *) parent_class)->render (item, &lbuf);
|
||||
/* Render mask */
|
||||
art_gray_svp_aa (cg->svp, lbuf.rect.x0, lbuf.rect.y0, lbuf.rect.x1, lbuf.rect.y1,
|
||||
mask, lbuf.rect.x1 - lbuf.rect.x0);
|
||||
/* Combine */
|
||||
for (yy = lbuf.rect.y0; yy < lbuf.rect.y1; yy++) {
|
||||
guchar *s, *m, *d;
|
||||
s = lbuf.buf + (yy - lbuf.rect.y0) * lbuf.buf_rowstride;
|
||||
m = mask + (yy - lbuf.rect.y0) * (lbuf.rect.x1 - lbuf.rect.x0);
|
||||
d = buf->buf + (yy - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3;
|
||||
for (xx = lbuf.rect.x0; xx < lbuf.rect.x1; xx++) {
|
||||
#ifndef SHOW_SHADOW
|
||||
d[0] = COMPOSEN11 (s[0], m[0], d[0]);
|
||||
d[1] = COMPOSEN11 (s[1], m[0], d[1]);
|
||||
d[2] = COMPOSEN11 (s[2], m[0], d[2]);
|
||||
#else
|
||||
d[0] = COMPOSEN11 (s[0], m[0] | 0x7f, d[0]);
|
||||
d[1] = COMPOSEN11 (s[1], m[0] | 0x7f, d[1]);
|
||||
d[2] = COMPOSEN11 (s[2], m[0] | 0x7f, d[2]);
|
||||
#endif
|
||||
s += 3;
|
||||
m += 1;
|
||||
d += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Free buffers */
|
||||
gcg_mask_free (mask);
|
||||
gcg_buf_free (lbuf.buf);
|
||||
} else {
|
||||
if (((GnomeCanvasItemClass *) parent_class)->render)
|
||||
((GnomeCanvasItemClass *) parent_class)->render (item, buf);
|
||||
}
|
||||
}
|
||||
|
||||
static GSList *gcg_buffers = NULL;
|
||||
static GSList *gcg_masks = NULL;
|
||||
|
||||
static guchar *
|
||||
gcg_buf_new (void)
|
||||
{
|
||||
guchar *buf;
|
||||
|
||||
if (!gcg_buffers) {
|
||||
buf = g_new (guchar, GCG_BUF_SIZE);
|
||||
} else {
|
||||
buf = (guchar *) gcg_buffers->data;
|
||||
gcg_buffers = g_slist_remove (gcg_buffers, buf);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
gcg_buf_free (guchar *buf)
|
||||
{
|
||||
gcg_buffers = g_slist_prepend (gcg_buffers, buf);
|
||||
}
|
||||
|
||||
static guchar *
|
||||
gcg_mask_new (void)
|
||||
{
|
||||
guchar *mask;
|
||||
|
||||
if (!gcg_masks) {
|
||||
mask = g_new (guchar, GCG_BUF_PIXELS);
|
||||
} else {
|
||||
mask = (guchar *) gcg_masks->data;
|
||||
gcg_masks = g_slist_remove (gcg_masks, mask);
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
static void
|
||||
gcg_mask_free (guchar *mask)
|
||||
{
|
||||
gcg_masks = g_slist_prepend (gcg_masks, mask);
|
||||
}
|
||||
58
libs/gnomecanvas/libgnomecanvas/gnome-canvas-clipgroup.h
Normal file
58
libs/gnomecanvas/libgnomecanvas/gnome-canvas-clipgroup.h
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#ifndef GNOME_CANVAS_CLIPGROUP_H
|
||||
#define GNOME_CANVAS_CLIPGROUP_H
|
||||
|
||||
/* Clipping group implementation for GnomeCanvas
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
* TODO: Implement this in libgnomeui, possibly merge with real group
|
||||
*
|
||||
* Copyright (C) 1998,1999 The Free Software Foundation
|
||||
*
|
||||
* Author:
|
||||
* Lauris Kaplinski <lauris@ximian.com>
|
||||
*/
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
#include <libgnomecanvas/gnome-canvas-util.h>
|
||||
|
||||
#include <libart_lgpl/art_bpath.h>
|
||||
#include <libart_lgpl/art_svp_wind.h>
|
||||
#include <libart_lgpl/art_vpath_dash.h>
|
||||
#include <libgnomecanvas/gnome-canvas-path-def.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS_CLIPGROUP (gnome_canvas_clipgroup_get_type ())
|
||||
#define GNOME_CANVAS_CLIPGROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_CLIPGROUP, GnomeCanvasClipgroup))
|
||||
#define GNOME_CANVAS_CLIPGROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_CLIPGROUP, GnomeCanvasClipgroupClass))
|
||||
#define GNOME_IS_CANVAS_CLIPGROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_CLIPGROUP))
|
||||
#define GNOME_IS_CANVAS_CLIPGROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_CLIPGROUP))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasClipgroup GnomeCanvasClipgroup;
|
||||
typedef struct _GnomeCanvasClipgroupClass GnomeCanvasClipgroupClass;
|
||||
|
||||
struct _GnomeCanvasClipgroup {
|
||||
GnomeCanvasGroup group;
|
||||
|
||||
GnomeCanvasPathDef * path;
|
||||
ArtWindRule wind;
|
||||
|
||||
ArtSVP * svp;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasClipgroupClass {
|
||||
GnomeCanvasGroupClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_clipgroup_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
68
libs/gnomecanvas/libgnomecanvas/gnome-canvas-i18n.h
Normal file
68
libs/gnomecanvas/libgnomecanvas/gnome-canvas-i18n.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Handles all of the internationalization configuration options.
|
||||
* Author: Tom Tromey <tromey@creche.cygnus.com>
|
||||
*/
|
||||
|
||||
#ifndef __LIBGNOME_CANVAS_I18N_H__
|
||||
#define __LIBGNOME_CANVAS_I18N_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#if !defined(__LIBGNOME_CANVAS_I18NP_H__)
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# ifdef GNOME_EXPLICIT_TRANSLATION_DOMAIN
|
||||
# undef _
|
||||
# define _(String) dgettext (GNOME_EXPLICIT_TRANSLATION_DOMAIN, String)
|
||||
# else
|
||||
# define _(String) gettext (String)
|
||||
# endif
|
||||
# ifdef gettext_noop
|
||||
# define N_(String) gettext_noop (String)
|
||||
# else
|
||||
# define N_(String) (String)
|
||||
# endif
|
||||
#else
|
||||
/* Stubs that do something close enough. */
|
||||
# define textdomain(String) (String)
|
||||
# define gettext(String) (String)
|
||||
# define dgettext(Domain,Message) (Message)
|
||||
# define dcgettext(Domain,Message,Type) (Message)
|
||||
# define bindtextdomain(Domain,Directory) (Domain)
|
||||
# define _(String) (String)
|
||||
# define N_(String) (String)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __LIBGNOME_CANVAS_I18N_H__ */
|
||||
1423
libs/gnomecanvas/libgnomecanvas/gnome-canvas-line.c
Normal file
1423
libs/gnomecanvas/libgnomecanvas/gnome-canvas-line.c
Normal file
File diff suppressed because it is too large
Load diff
154
libs/gnomecanvas/libgnomecanvas/gnome-canvas-line.h
Normal file
154
libs/gnomecanvas/libgnomecanvas/gnome-canvas-line.h
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
|
||||
/* Line/curve item type for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
*
|
||||
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_LINE_H
|
||||
#define GNOME_CANVAS_LINE_H
|
||||
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* Line item for the canvas. This is a polyline with configurable width, cap/join styles, and arrowheads.
|
||||
* If arrowheads are enabled, then three values are used to specify their shape:
|
||||
*
|
||||
* arrow_shape_a: Distance from tip of arrowhead to the center point.
|
||||
* arrow_shape_b: Distance from tip of arrowhead to trailing point, measured along the shaft.
|
||||
* arrow_shape_c: Distance of trailing point from outside edge of shaft.
|
||||
*
|
||||
* The following object arguments are available:
|
||||
*
|
||||
* name type read/write description
|
||||
* ------------------------------------------------------------------------------------------
|
||||
* points GnomeCanvasPoints* RW Pointer to a GnomeCanvasPoints structure.
|
||||
* This can be created by a call to
|
||||
* gnome_canvas_points_new() (in gnome-canvas-util.h).
|
||||
* X coordinates are in the even indices of the
|
||||
* points->coords array, Y coordinates are in
|
||||
* the odd indices.
|
||||
* fill_color string W X color specification for line
|
||||
* fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor
|
||||
* fill_stipple GdkBitmap* RW Stipple pattern for the line
|
||||
* width_pixels uint R Width of the line in pixels. The line width
|
||||
* will not be scaled when the canvas zoom factor changes.
|
||||
* width_units double R Width of the line in canvas units. The line width
|
||||
* will be scaled when the canvas zoom factor changes.
|
||||
* cap_style GdkCapStyle RW Cap ("endpoint") style for the line.
|
||||
* join_style GdkJoinStyle RW Join ("vertex") style for the line.
|
||||
* line_style GdkLineStyle RW Line dash style
|
||||
* first_arrowhead boolean RW Specifies whether to draw an arrowhead on the
|
||||
* first point of the line.
|
||||
* last_arrowhead boolean RW Specifies whether to draw an arrowhead on the
|
||||
* last point of the line.
|
||||
* smooth boolean RW Specifies whether to smooth the line using
|
||||
* parabolic splines.
|
||||
* spline_steps uint RW Specifies the number of steps to use when rendering curves.
|
||||
* arrow_shape_a double RW First arrow shape specifier.
|
||||
* arrow_shape_b double RW Second arrow shape specifier.
|
||||
* arrow_shape_c double RW Third arrow shape specifier.
|
||||
*/
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS_LINE (gnome_canvas_line_get_type ())
|
||||
#define GNOME_CANVAS_LINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_LINE, GnomeCanvasLine))
|
||||
#define GNOME_CANVAS_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_LINE, GnomeCanvasLineClass))
|
||||
#define GNOME_IS_CANVAS_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_LINE))
|
||||
#define GNOME_IS_CANVAS_LINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_LINE))
|
||||
#define GNOME_CANVAS_LINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_LINE, GnomeCanvasLineClass))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasLine GnomeCanvasLine;
|
||||
typedef struct _GnomeCanvasLineClass GnomeCanvasLineClass;
|
||||
|
||||
struct _GnomeCanvasLine {
|
||||
GnomeCanvasItem item;
|
||||
|
||||
double *coords; /* Array of coordinates for the line's points. X coords are in the
|
||||
* even indices, Y coords are in the odd indices. If the line has
|
||||
* arrowheads then the first and last points have been adjusted to
|
||||
* refer to the necks of the arrowheads rather than their tips. The
|
||||
* actual endpoints are stored in the first_arrow and last_arrow
|
||||
* arrays, if they exist.
|
||||
*/
|
||||
|
||||
double *first_coords; /* Array of points describing polygon for the first arrowhead */
|
||||
double *last_coords; /* Array of points describing polygon for the last arrowhead */
|
||||
|
||||
GdkGC *gc; /* GC for drawing line */
|
||||
|
||||
GdkBitmap *stipple; /* Stipple pattern */
|
||||
|
||||
ArtSVP *fill_svp; /* The SVP for the outline shape */ /*AA*/
|
||||
ArtSVP *first_svp; /* The SVP for the first arrow */ /*AA*/
|
||||
ArtSVP *last_svp; /* The SVP for the last arrow */ /*AA*/
|
||||
|
||||
double width; /* Width of the line */
|
||||
|
||||
double shape_a; /* Distance from tip of arrowhead to center */
|
||||
double shape_b; /* Distance from tip of arrowhead to trailing point, measured along shaft */
|
||||
double shape_c; /* Distance of trailing points from outside edge of shaft */
|
||||
|
||||
GdkCapStyle cap; /* Cap style for line */
|
||||
GdkJoinStyle join; /* Join style for line */
|
||||
GdkLineStyle line_style;/* Style for the line */
|
||||
|
||||
gulong fill_pixel; /* Color for line */
|
||||
|
||||
guint32 fill_rgba; /* RGBA color for outline */ /*AA*/
|
||||
|
||||
int num_points; /* Number of points in the line */
|
||||
guint fill_color; /* Fill color, RGBA */
|
||||
|
||||
int spline_steps; /* Number of steps in each spline segment */
|
||||
|
||||
guint width_pixels : 1; /* Is the width specified in pixels or units? */
|
||||
guint first_arrow : 1; /* Draw first arrowhead? */
|
||||
guint last_arrow : 1; /* Draw last arrowhead? */
|
||||
guint smooth : 1; /* Smooth line (with parabolic splines)? */
|
||||
};
|
||||
|
||||
struct _GnomeCanvasLineClass {
|
||||
GnomeCanvasItemClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_line_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
131
libs/gnomecanvas/libgnomecanvas/gnome-canvas-marshal.c
Normal file
131
libs/gnomecanvas/libgnomecanvas/gnome-canvas-marshal.c
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
|
||||
#define g_marshal_value_peek_char(v) g_value_get_char (v)
|
||||
#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
|
||||
#define g_marshal_value_peek_int(v) g_value_get_int (v)
|
||||
#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
|
||||
#define g_marshal_value_peek_long(v) g_value_get_long (v)
|
||||
#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
|
||||
#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
|
||||
#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
|
||||
#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
|
||||
#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
|
||||
#define g_marshal_value_peek_float(v) g_value_get_float (v)
|
||||
#define g_marshal_value_peek_double(v) g_value_get_double (v)
|
||||
#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
|
||||
#define g_marshal_value_peek_param(v) g_value_get_param (v)
|
||||
#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
|
||||
#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
|
||||
#define g_marshal_value_peek_object(v) g_value_get_object (v)
|
||||
#else /* !G_ENABLE_DEBUG */
|
||||
/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
|
||||
* Do not access GValues directly in your code. Instead, use the
|
||||
* g_value_get_*() functions
|
||||
*/
|
||||
#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
|
||||
#define g_marshal_value_peek_char(v) (v)->data[0].v_int
|
||||
#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
|
||||
#define g_marshal_value_peek_int(v) (v)->data[0].v_int
|
||||
#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
|
||||
#define g_marshal_value_peek_long(v) (v)->data[0].v_long
|
||||
#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
|
||||
#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
|
||||
#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
|
||||
#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
|
||||
#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
|
||||
#define g_marshal_value_peek_float(v) (v)->data[0].v_float
|
||||
#define g_marshal_value_peek_double(v) (v)->data[0].v_double
|
||||
#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
|
||||
#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
|
||||
#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
|
||||
#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
|
||||
#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
|
||||
#endif /* !G_ENABLE_DEBUG */
|
||||
|
||||
|
||||
/* VOID:OBJECT,INT,INT,INT,INT (gnome-canvas-marshal.list:1) */
|
||||
void
|
||||
gnome_canvas_marshal_VOID__OBJECT_INT_INT_INT_INT (GClosure *closure,
|
||||
GValue *return_value G_GNUC_UNUSED,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint G_GNUC_UNUSED,
|
||||
gpointer marshal_data)
|
||||
{
|
||||
typedef void (*GMarshalFunc_VOID__OBJECT_INT_INT_INT_INT) (gpointer data1,
|
||||
gpointer arg_1,
|
||||
gint arg_2,
|
||||
gint arg_3,
|
||||
gint arg_4,
|
||||
gint arg_5,
|
||||
gpointer data2);
|
||||
register GMarshalFunc_VOID__OBJECT_INT_INT_INT_INT callback;
|
||||
register GCClosure *cc = (GCClosure*) closure;
|
||||
register gpointer data1, data2;
|
||||
|
||||
g_return_if_fail (n_param_values == 6);
|
||||
|
||||
if (G_CCLOSURE_SWAP_DATA (closure))
|
||||
{
|
||||
data1 = closure->data;
|
||||
data2 = g_value_peek_pointer (param_values + 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
data1 = g_value_peek_pointer (param_values + 0);
|
||||
data2 = closure->data;
|
||||
}
|
||||
callback = (GMarshalFunc_VOID__OBJECT_INT_INT_INT_INT) (marshal_data ? marshal_data : cc->callback);
|
||||
|
||||
callback (data1,
|
||||
g_marshal_value_peek_object (param_values + 1),
|
||||
g_marshal_value_peek_int (param_values + 2),
|
||||
g_marshal_value_peek_int (param_values + 3),
|
||||
g_marshal_value_peek_int (param_values + 4),
|
||||
g_marshal_value_peek_int (param_values + 5),
|
||||
data2);
|
||||
}
|
||||
|
||||
/* BOOLEAN:BOXED (gnome-canvas-marshal.list:2) */
|
||||
void
|
||||
gnome_canvas_marshal_BOOLEAN__BOXED (GClosure *closure,
|
||||
GValue *return_value G_GNUC_UNUSED,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint G_GNUC_UNUSED,
|
||||
gpointer marshal_data)
|
||||
{
|
||||
typedef gboolean (*GMarshalFunc_BOOLEAN__BOXED) (gpointer data1,
|
||||
gpointer arg_1,
|
||||
gpointer data2);
|
||||
register GMarshalFunc_BOOLEAN__BOXED callback;
|
||||
register GCClosure *cc = (GCClosure*) closure;
|
||||
register gpointer data1, data2;
|
||||
gboolean v_return;
|
||||
|
||||
g_return_if_fail (return_value != NULL);
|
||||
g_return_if_fail (n_param_values == 2);
|
||||
|
||||
if (G_CCLOSURE_SWAP_DATA (closure))
|
||||
{
|
||||
data1 = closure->data;
|
||||
data2 = g_value_peek_pointer (param_values + 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
data1 = g_value_peek_pointer (param_values + 0);
|
||||
data2 = closure->data;
|
||||
}
|
||||
callback = (GMarshalFunc_BOOLEAN__BOXED) (marshal_data ? marshal_data : cc->callback);
|
||||
|
||||
v_return = callback (data1,
|
||||
g_marshal_value_peek_boxed (param_values + 1),
|
||||
data2);
|
||||
|
||||
g_value_set_boolean (return_value, v_return);
|
||||
}
|
||||
|
||||
28
libs/gnomecanvas/libgnomecanvas/gnome-canvas-marshal.h
Normal file
28
libs/gnomecanvas/libgnomecanvas/gnome-canvas-marshal.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
#ifndef __gnome_canvas_marshal_MARSHAL_H__
|
||||
#define __gnome_canvas_marshal_MARSHAL_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* VOID:OBJECT,INT,INT,INT,INT (gnome-canvas-marshal.list:1) */
|
||||
extern void gnome_canvas_marshal_VOID__OBJECT_INT_INT_INT_INT (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
/* BOOLEAN:BOXED (gnome-canvas-marshal.list:2) */
|
||||
extern void gnome_canvas_marshal_BOOLEAN__BOXED (GClosure *closure,
|
||||
GValue *return_value,
|
||||
guint n_param_values,
|
||||
const GValue *param_values,
|
||||
gpointer invocation_hint,
|
||||
gpointer marshal_data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __gnome_canvas_marshal_MARSHAL_H__ */
|
||||
|
||||
1287
libs/gnomecanvas/libgnomecanvas/gnome-canvas-path-def.c
Normal file
1287
libs/gnomecanvas/libgnomecanvas/gnome-canvas-path-def.c
Normal file
File diff suppressed because it is too large
Load diff
96
libs/gnomecanvas/libgnomecanvas/gnome-canvas-path-def.h
Normal file
96
libs/gnomecanvas/libgnomecanvas/gnome-canvas-path-def.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#ifndef GNOME_CANVAS_PATH_DEF_H
|
||||
#define GNOME_CANVAS_PATH_DEF_H
|
||||
|
||||
/*
|
||||
* GnomeCanvasPathDef
|
||||
*
|
||||
* (C) 1999-2000 Lauris Kaplinski <lauris@ximian.com>
|
||||
* Released under LGPL
|
||||
*
|
||||
* This is mostly like GnomeCanvasBpathDef, but with added functionality:
|
||||
* - can be constructed from scratch, from existing bpath of from static bpath
|
||||
* - Path is always terminated with ART_END
|
||||
* - Has closed flag
|
||||
* - has concat, split and copy methods
|
||||
*
|
||||
*/
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <libart_lgpl/art_bpath.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GnomeCanvasPathDef GnomeCanvasPathDef;
|
||||
|
||||
#define GNOME_TYPE_CANVAS_PATH_DEF (gnome_canvas_path_def_get_type ())
|
||||
GType gnome_canvas_path_def_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* Constructors */
|
||||
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_new (void);
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_new_sized (gint length);
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_new_from_bpath (ArtBpath * bpath);
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_new_from_static_bpath (ArtBpath * bpath);
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_new_from_foreign_bpath (ArtBpath * bpath);
|
||||
|
||||
void gnome_canvas_path_def_ref (GnomeCanvasPathDef * path);
|
||||
void gnome_canvas_path_def_finish (GnomeCanvasPathDef * path);
|
||||
void gnome_canvas_path_def_ensure_space (GnomeCanvasPathDef * path, gint space);
|
||||
|
||||
/*
|
||||
* Misc constructors
|
||||
* All these return NEW path, not unrefing old
|
||||
* Also copy and duplicate force bpath to be private (otherwise you
|
||||
* would use ref :)
|
||||
*/
|
||||
|
||||
void gnome_canvas_path_def_copy (GnomeCanvasPathDef * dst, const GnomeCanvasPathDef * src);
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_duplicate (const GnomeCanvasPathDef * path);
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_concat (const GSList * list);
|
||||
GSList * gnome_canvas_path_def_split (const GnomeCanvasPathDef * path);
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_open_parts (const GnomeCanvasPathDef * path);
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_closed_parts (const GnomeCanvasPathDef * path);
|
||||
GnomeCanvasPathDef * gnome_canvas_path_def_close_all (const GnomeCanvasPathDef * path);
|
||||
|
||||
/* Destructor */
|
||||
|
||||
void gnome_canvas_path_def_unref (GnomeCanvasPathDef * path);
|
||||
|
||||
/* Methods */
|
||||
|
||||
/* Sets GnomeCanvasPathDef to zero length */
|
||||
|
||||
void gnome_canvas_path_def_reset (GnomeCanvasPathDef * path);
|
||||
|
||||
/* Drawing methods */
|
||||
|
||||
void gnome_canvas_path_def_moveto (GnomeCanvasPathDef * path, gdouble x, gdouble y);
|
||||
void gnome_canvas_path_def_lineto (GnomeCanvasPathDef * path, gdouble x, gdouble y);
|
||||
|
||||
/* Does not create new ArtBpath, but simply changes last lineto position */
|
||||
|
||||
void gnome_canvas_path_def_lineto_moving (GnomeCanvasPathDef * path, gdouble x, gdouble y);
|
||||
void gnome_canvas_path_def_curveto (GnomeCanvasPathDef * path, gdouble x0, gdouble y0,gdouble x1, gdouble y1, gdouble x2, gdouble y2);
|
||||
void gnome_canvas_path_def_closepath (GnomeCanvasPathDef * path);
|
||||
|
||||
/* Does not draw new line to startpoint, but moves last lineto */
|
||||
|
||||
void gnome_canvas_path_def_closepath_current (GnomeCanvasPathDef * path);
|
||||
|
||||
/* Various methods */
|
||||
|
||||
ArtBpath * gnome_canvas_path_def_bpath (const GnomeCanvasPathDef * path);
|
||||
gint gnome_canvas_path_def_length (const GnomeCanvasPathDef * path);
|
||||
gboolean gnome_canvas_path_def_is_empty (const GnomeCanvasPathDef * path);
|
||||
gboolean gnome_canvas_path_def_has_currentpoint (const GnomeCanvasPathDef * path);
|
||||
void gnome_canvas_path_def_currentpoint (const GnomeCanvasPathDef * path, ArtPoint * p);
|
||||
ArtBpath * gnome_canvas_path_def_last_bpath (const GnomeCanvasPathDef * path);
|
||||
ArtBpath * gnome_canvas_path_def_first_bpath (const GnomeCanvasPathDef * path);
|
||||
gboolean gnome_canvas_path_def_any_open (const GnomeCanvasPathDef * path);
|
||||
gboolean gnome_canvas_path_def_all_open (const GnomeCanvasPathDef * path);
|
||||
gboolean gnome_canvas_path_def_any_closed (const GnomeCanvasPathDef * path);
|
||||
gboolean gnome_canvas_path_def_all_closed (const GnomeCanvasPathDef * path);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
1077
libs/gnomecanvas/libgnomecanvas/gnome-canvas-pixbuf.c
Normal file
1077
libs/gnomecanvas/libgnomecanvas/gnome-canvas-pixbuf.c
Normal file
File diff suppressed because it is too large
Load diff
62
libs/gnomecanvas/libgnomecanvas/gnome-canvas-pixbuf.h
Normal file
62
libs/gnomecanvas/libgnomecanvas/gnome-canvas-pixbuf.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/* GNOME libraries - GdkPixbuf item for the GNOME canvas
|
||||
*
|
||||
* Copyright (C) 1999 The Free Software Foundation
|
||||
*
|
||||
* Author: Federico Mena-Quintero <federico@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_PIXBUF_H
|
||||
#define GNOME_CANVAS_PIXBUF_H
|
||||
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS_PIXBUF (gnome_canvas_pixbuf_get_type ())
|
||||
#define GNOME_CANVAS_PIXBUF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_PIXBUF, GnomeCanvasPixbuf))
|
||||
#define GNOME_CANVAS_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_PIXBUF, GnomeCanvasPixbufClass))
|
||||
#define GNOME_IS_CANVAS_PIXBUF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_PIXBUF))
|
||||
#define GNOME_IS_CANVAS_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_PIXBUF))
|
||||
#define GNOME_CANVAS_PIXBUF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_PIXBUF, GnomeCanvasPixbufClass))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasPixbuf GnomeCanvasPixbuf;
|
||||
typedef struct _GnomeCanvasPixbufClass GnomeCanvasPixbufClass;
|
||||
|
||||
struct _GnomeCanvasPixbuf {
|
||||
GnomeCanvasItem item;
|
||||
|
||||
/* Private data */
|
||||
gpointer priv;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasPixbufClass {
|
||||
GnomeCanvasItemClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gnome_canvas_pixbuf_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
246
libs/gnomecanvas/libgnomecanvas/gnome-canvas-polygon.c
Normal file
246
libs/gnomecanvas/libgnomecanvas/gnome-canvas-polygon.c
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* Polygon item type for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
||||
* Rusty Conover <rconover@bangtail.net>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "libart_lgpl/art_vpath.h"
|
||||
#include "libart_lgpl/art_svp.h"
|
||||
#include "libart_lgpl/art_svp_vpath.h"
|
||||
#include "libart_lgpl/art_svp_vpath_stroke.h"
|
||||
#include "libgnomecanvas.h"
|
||||
|
||||
#include "gnome-canvas-shape.h"
|
||||
|
||||
#define NUM_STATIC_POINTS 256 /* Number of static points to use to avoid allocating arrays */
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_POINTS
|
||||
};
|
||||
|
||||
static void gnome_canvas_polygon_class_init (GnomeCanvasPolygonClass *class);
|
||||
static void gnome_canvas_polygon_init (GnomeCanvasPolygon *poly);
|
||||
static void gnome_canvas_polygon_destroy (GtkObject *object);
|
||||
static void gnome_canvas_polygon_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gnome_canvas_polygon_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gnome_canvas_polygon_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags);
|
||||
|
||||
static GnomeCanvasItemClass *parent_class;
|
||||
|
||||
GType
|
||||
gnome_canvas_polygon_get_type (void)
|
||||
{
|
||||
static GType polygon_type;
|
||||
|
||||
if (!polygon_type) {
|
||||
const GTypeInfo object_info = {
|
||||
sizeof (GnomeCanvasPolygonClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gnome_canvas_polygon_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL, /* class_data */
|
||||
sizeof (GnomeCanvasPolygon),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gnome_canvas_polygon_init,
|
||||
NULL /* value_table */
|
||||
};
|
||||
|
||||
polygon_type = g_type_register_static (GNOME_TYPE_CANVAS_SHAPE, "GnomeCanvasPolygon",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
return polygon_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_polygon_class_init (GnomeCanvasPolygonClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkObjectClass *object_class;
|
||||
GnomeCanvasItemClass *item_class;
|
||||
|
||||
gobject_class = (GObjectClass *) class;
|
||||
object_class = (GtkObjectClass *) class;
|
||||
item_class = (GnomeCanvasItemClass *) class;
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gobject_class->set_property = gnome_canvas_polygon_set_property;
|
||||
gobject_class->get_property = gnome_canvas_polygon_get_property;
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_POINTS,
|
||||
g_param_spec_boxed ("points", NULL, NULL,
|
||||
GNOME_TYPE_CANVAS_POINTS,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
|
||||
object_class->destroy = gnome_canvas_polygon_destroy;
|
||||
|
||||
item_class->update = gnome_canvas_polygon_update;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_polygon_init (GnomeCanvasPolygon *poly)
|
||||
{
|
||||
poly->path_def = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_polygon_destroy (GtkObject *object)
|
||||
{
|
||||
GnomeCanvasPolygon *poly;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_POLYGON (object));
|
||||
|
||||
poly = GNOME_CANVAS_POLYGON (object);
|
||||
|
||||
/* remember, destroy can be run multiple times! */
|
||||
|
||||
if(poly->path_def)
|
||||
gnome_canvas_path_def_unref(poly->path_def);
|
||||
|
||||
poly->path_def = NULL;
|
||||
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
set_points (GnomeCanvasPolygon *poly, GnomeCanvasPoints *points)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
if (poly->path_def)
|
||||
gnome_canvas_path_def_unref(poly->path_def);
|
||||
|
||||
if (!points) {
|
||||
poly->path_def = gnome_canvas_path_def_new();
|
||||
gnome_canvas_shape_set_path_def (GNOME_CANVAS_SHAPE (poly), poly->path_def);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Optomize the path def to the number of points */
|
||||
poly->path_def = gnome_canvas_path_def_new_sized(points->num_points+1);
|
||||
|
||||
#if 0
|
||||
/* No need for explicit duplicate, as closepaths does it for us (Lauris) */
|
||||
/* See if we need to duplicate the first point */
|
||||
duplicate = ((points->coords[0] != points->coords[2 * points->num_points - 2])
|
||||
|| (points->coords[1] != points->coords[2 * points->num_points - 1]));
|
||||
#endif
|
||||
|
||||
|
||||
gnome_canvas_path_def_moveto (poly->path_def, points->coords[0], points->coords[1]);
|
||||
|
||||
for (i = 1; i < points->num_points; i++) {
|
||||
gnome_canvas_path_def_lineto(poly->path_def, points->coords[i * 2], points->coords[(i * 2) + 1]);
|
||||
}
|
||||
|
||||
gnome_canvas_path_def_closepath (poly->path_def);
|
||||
|
||||
gnome_canvas_shape_set_path_def (GNOME_CANVAS_SHAPE (poly), poly->path_def);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnome_canvas_polygon_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
GnomeCanvasPolygon *poly;
|
||||
GnomeCanvasPoints *points;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_POLYGON (object));
|
||||
|
||||
item = GNOME_CANVAS_ITEM (object);
|
||||
poly = GNOME_CANVAS_POLYGON (object);
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_POINTS:
|
||||
points = g_value_get_boxed (value);
|
||||
|
||||
set_points (poly, points);
|
||||
|
||||
gnome_canvas_item_request_update (item);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnome_canvas_polygon_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_POLYGON (object));
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_POINTS:
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnome_canvas_polygon_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
|
||||
{
|
||||
/* Since the path has already been defined just pass the update up. */
|
||||
|
||||
if (parent_class->update)
|
||||
(* parent_class->update) (item, affine, clip_path, flags);
|
||||
}
|
||||
88
libs/gnomecanvas/libgnomecanvas/gnome-canvas-polygon.h
Normal file
88
libs/gnomecanvas/libgnomecanvas/gnome-canvas-polygon.h
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* Polygon item type for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
*
|
||||
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
||||
* Rusty Conover <rconover@bangtail.net>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_POLYGON_H
|
||||
#define GNOME_CANVAS_POLYGON_H
|
||||
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
#include <libgnomecanvas/gnome-canvas-shape.h>
|
||||
#include <libgnomecanvas/gnome-canvas-path-def.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* Polygon item for the canvas. A polygon is a bit different from rectangles and ellipses in that
|
||||
* points inside it will always be considered "inside", even if the fill color is not set. If you
|
||||
* want to have a hollow polygon, use a line item instead.
|
||||
*
|
||||
* The following object arguments are available:
|
||||
*
|
||||
* name type read/write description
|
||||
* ------------------------------------------------------------------------------------------
|
||||
* points GnomeCanvasPoints* RW Pointer to a GnomeCanvasPoints structure.
|
||||
* This can be created by a call to
|
||||
* gnome_canvas_points_new() (in gnome-canvas-util.h).
|
||||
* X coordinates are in the even indices of the
|
||||
* points->coords array, Y coordinates are in
|
||||
* the odd indices.
|
||||
*/
|
||||
|
||||
#define GNOME_TYPE_CANVAS_POLYGON (gnome_canvas_polygon_get_type ())
|
||||
#define GNOME_CANVAS_POLYGON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_POLYGON, GnomeCanvasPolygon))
|
||||
#define GNOME_CANVAS_POLYGON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_POLYGON, GnomeCanvasPolygonClass))
|
||||
#define GNOME_IS_CANVAS_POLYGON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_POLYGON))
|
||||
#define GNOME_IS_CANVAS_POLYGON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_POLYGON))
|
||||
#define GNOME_CANVAS_POLYGON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_POLYGON, GnomeCanvasPolygonClass))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasPolygon GnomeCanvasPolygon;
|
||||
typedef struct _GnomeCanvasPolygonClass GnomeCanvasPolygonClass;
|
||||
|
||||
struct _GnomeCanvasPolygon {
|
||||
GnomeCanvasShape item;
|
||||
|
||||
GnomeCanvasPathDef *path_def;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasPolygonClass {
|
||||
GnomeCanvasShapeClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_polygon_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
#endif
|
||||
431
libs/gnomecanvas/libgnomecanvas/gnome-canvas-rect-ellipse.c
Normal file
431
libs/gnomecanvas/libgnomecanvas/gnome-canvas-rect-ellipse.c
Normal file
|
|
@ -0,0 +1,431 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* Rectangle and ellipse item types for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
*
|
||||
* Authors: Federico Mena <federico@nuclecu.unam.mx>
|
||||
* Rusty Conover <rconover@bangtail.net>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <math.h>
|
||||
#include "gnome-canvas-rect-ellipse.h"
|
||||
#include "gnome-canvas-util.h"
|
||||
#include "gnome-canvas-shape.h"
|
||||
|
||||
|
||||
#include "libart_lgpl/art_vpath.h"
|
||||
#include "libart_lgpl/art_svp.h"
|
||||
#include "libart_lgpl/art_svp_vpath.h"
|
||||
#include "libart_lgpl/art_rgb_svp.h"
|
||||
|
||||
/* Base class for rectangle and ellipse item types */
|
||||
|
||||
#define noVERBOSE
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_X1,
|
||||
PROP_Y1,
|
||||
PROP_X2,
|
||||
PROP_Y2
|
||||
};
|
||||
|
||||
|
||||
static void gnome_canvas_re_class_init (GnomeCanvasREClass *class);
|
||||
static void gnome_canvas_re_init (GnomeCanvasRE *re);
|
||||
static void gnome_canvas_re_destroy (GtkObject *object);
|
||||
static void gnome_canvas_re_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gnome_canvas_re_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gnome_canvas_rect_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags);
|
||||
static void gnome_canvas_ellipse_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags);
|
||||
|
||||
static GnomeCanvasItemClass *re_parent_class;
|
||||
|
||||
|
||||
GType
|
||||
gnome_canvas_re_get_type (void)
|
||||
{
|
||||
static GType re_type;
|
||||
|
||||
if (!re_type) {
|
||||
const GTypeInfo object_info = {
|
||||
sizeof (GnomeCanvasREClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gnome_canvas_re_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL, /* class_data */
|
||||
sizeof (GnomeCanvasRE),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gnome_canvas_re_init,
|
||||
NULL /* value_table */
|
||||
};
|
||||
|
||||
re_type = g_type_register_static (GNOME_TYPE_CANVAS_SHAPE, "GnomeCanvasRE",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
return re_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_re_class_init (GnomeCanvasREClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
gobject_class = (GObjectClass *) class;
|
||||
object_class = (GtkObjectClass *) class;
|
||||
|
||||
re_parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gobject_class->set_property = gnome_canvas_re_set_property;
|
||||
gobject_class->get_property = gnome_canvas_re_get_property;
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_X1,
|
||||
g_param_spec_double ("x1", NULL, NULL,
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_Y1,
|
||||
g_param_spec_double ("y1", NULL, NULL,
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_X2,
|
||||
g_param_spec_double ("x2", NULL, NULL,
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_Y2,
|
||||
g_param_spec_double ("y2", NULL, NULL,
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
|
||||
object_class->destroy = gnome_canvas_re_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_re_init (GnomeCanvasRE *re)
|
||||
{
|
||||
re->x1 = 0.0;
|
||||
re->y1 = 0.0;
|
||||
re->x2 = 0.0;
|
||||
re->y2 = 0.0;
|
||||
re->path_dirty = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_re_destroy (GtkObject *object)
|
||||
{
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_RE (object));
|
||||
|
||||
if (GTK_OBJECT_CLASS (re_parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (re_parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_re_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
GnomeCanvasRE *re;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_RE (object));
|
||||
|
||||
item = GNOME_CANVAS_ITEM (object);
|
||||
re = GNOME_CANVAS_RE (object);
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_X1:
|
||||
re->x1 = g_value_get_double (value);
|
||||
re->path_dirty = 1;
|
||||
gnome_canvas_item_request_update (item);
|
||||
break;
|
||||
|
||||
case PROP_Y1:
|
||||
re->y1 = g_value_get_double (value);
|
||||
re->path_dirty = 1;
|
||||
gnome_canvas_item_request_update (item);
|
||||
break;
|
||||
|
||||
case PROP_X2:
|
||||
re->x2 = g_value_get_double (value);
|
||||
re->path_dirty = 1;
|
||||
gnome_canvas_item_request_update (item);
|
||||
break;
|
||||
|
||||
case PROP_Y2:
|
||||
re->y2 = g_value_get_double (value);
|
||||
re->path_dirty = 1;
|
||||
gnome_canvas_item_request_update (item);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_re_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GnomeCanvasRE *re;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_RE (object));
|
||||
|
||||
re = GNOME_CANVAS_RE (object);
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_X1:
|
||||
g_value_set_double (value, re->x1);
|
||||
break;
|
||||
|
||||
case PROP_Y1:
|
||||
g_value_set_double (value, re->y1);
|
||||
break;
|
||||
|
||||
case PROP_X2:
|
||||
g_value_set_double (value, re->x2);
|
||||
break;
|
||||
|
||||
case PROP_Y2:
|
||||
g_value_set_double (value, re->y2);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Rectangle item */
|
||||
static void gnome_canvas_rect_class_init (GnomeCanvasRectClass *class);
|
||||
|
||||
|
||||
|
||||
GType
|
||||
gnome_canvas_rect_get_type (void)
|
||||
{
|
||||
static GType rect_type;
|
||||
|
||||
if (!rect_type) {
|
||||
const GTypeInfo object_info = {
|
||||
sizeof (GnomeCanvasRectClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gnome_canvas_rect_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL, /* class_data */
|
||||
sizeof (GnomeCanvasRect),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) NULL,
|
||||
NULL /* value_table */
|
||||
};
|
||||
|
||||
rect_type = g_type_register_static (GNOME_TYPE_CANVAS_RE, "GnomeCanvasRect",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
return rect_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_rect_class_init (GnomeCanvasRectClass *class)
|
||||
{
|
||||
GnomeCanvasItemClass *item_class;
|
||||
|
||||
item_class = (GnomeCanvasItemClass *) class;
|
||||
|
||||
item_class->update = gnome_canvas_rect_update;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_rect_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags)
|
||||
{ GnomeCanvasRE *re;
|
||||
|
||||
GnomeCanvasPathDef *path_def;
|
||||
|
||||
re = GNOME_CANVAS_RE(item);
|
||||
|
||||
if (re->path_dirty) {
|
||||
path_def = gnome_canvas_path_def_new ();
|
||||
|
||||
gnome_canvas_path_def_moveto(path_def, re->x1, re->y1);
|
||||
gnome_canvas_path_def_lineto(path_def, re->x2, re->y1);
|
||||
gnome_canvas_path_def_lineto(path_def, re->x2, re->y2);
|
||||
gnome_canvas_path_def_lineto(path_def, re->x1, re->y2);
|
||||
gnome_canvas_path_def_lineto(path_def, re->x1, re->y1);
|
||||
gnome_canvas_path_def_closepath_current(path_def);
|
||||
gnome_canvas_shape_set_path_def (GNOME_CANVAS_SHAPE (item), path_def);
|
||||
gnome_canvas_path_def_unref(path_def);
|
||||
re->path_dirty = 0;
|
||||
}
|
||||
|
||||
if (re_parent_class->update)
|
||||
(* re_parent_class->update) (item, affine, clip_path, flags);
|
||||
}
|
||||
|
||||
/* Ellipse item */
|
||||
|
||||
|
||||
static void gnome_canvas_ellipse_class_init (GnomeCanvasEllipseClass *class);
|
||||
|
||||
|
||||
GType
|
||||
gnome_canvas_ellipse_get_type (void)
|
||||
{
|
||||
static GType ellipse_type;
|
||||
|
||||
if (!ellipse_type) {
|
||||
const GTypeInfo object_info = {
|
||||
sizeof (GnomeCanvasEllipseClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gnome_canvas_ellipse_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL, /* class_data */
|
||||
sizeof (GnomeCanvasEllipse),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) NULL,
|
||||
NULL /* value_table */
|
||||
};
|
||||
|
||||
ellipse_type = g_type_register_static (GNOME_TYPE_CANVAS_RE, "GnomeCanvasEllipse",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
return ellipse_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_ellipse_class_init (GnomeCanvasEllipseClass *class)
|
||||
{
|
||||
GnomeCanvasItemClass *item_class;
|
||||
|
||||
item_class = (GnomeCanvasItemClass *) class;
|
||||
|
||||
item_class->update = gnome_canvas_ellipse_update;
|
||||
}
|
||||
|
||||
#define N_PTS 90
|
||||
|
||||
static void
|
||||
gnome_canvas_ellipse_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags) {
|
||||
GnomeCanvasPathDef *path_def;
|
||||
GnomeCanvasRE *re;
|
||||
|
||||
re = GNOME_CANVAS_RE(item);
|
||||
|
||||
if (re->path_dirty) {
|
||||
gdouble cx, cy, rx, ry;
|
||||
gdouble beta = 0.26521648983954400922; /* 4*(1-cos(pi/8))/(3*sin(pi/8)) */
|
||||
gdouble sincosA = 0.70710678118654752440; /* sin (pi/4), cos (pi/4) */
|
||||
gdouble dx1, dy1, dx2, dy2;
|
||||
gdouble mx, my;
|
||||
|
||||
path_def = gnome_canvas_path_def_new();
|
||||
|
||||
cx = (re->x2 + re->x1) * 0.5;
|
||||
cy = (re->y2 + re->y1) * 0.5;
|
||||
rx = re->x2 - cx;
|
||||
ry = re->y2 - cy;
|
||||
|
||||
dx1 = beta * rx;
|
||||
dy1 = beta * ry;
|
||||
dx2 = beta * rx * sincosA;
|
||||
dy2 = beta * ry * sincosA;
|
||||
mx = rx * sincosA;
|
||||
my = ry * sincosA;
|
||||
|
||||
gnome_canvas_path_def_moveto (path_def, cx + rx, cy);
|
||||
gnome_canvas_path_def_curveto (path_def,
|
||||
cx + rx, cy - dy1,
|
||||
cx + mx + dx2, cy - my + dy2,
|
||||
cx + mx, cy - my);
|
||||
gnome_canvas_path_def_curveto (path_def,
|
||||
cx + mx - dx2, cy - my - dy2,
|
||||
cx + dx1, cy - ry,
|
||||
cx, cy - ry);
|
||||
gnome_canvas_path_def_curveto (path_def,
|
||||
cx - dx1, cy - ry,
|
||||
cx - mx + dx2, cy - my - dy2,
|
||||
cx - mx, cy - my);
|
||||
gnome_canvas_path_def_curveto (path_def,
|
||||
cx - mx - dx2, cy - my + dy2,
|
||||
cx - rx, cy - dy1,
|
||||
cx - rx, cy);
|
||||
|
||||
gnome_canvas_path_def_curveto (path_def,
|
||||
cx - rx, cy + dy1,
|
||||
cx - mx - dx2, cy + my - dy2,
|
||||
cx - mx, cy + my);
|
||||
gnome_canvas_path_def_curveto (path_def,
|
||||
cx - mx + dx2, cy + my + dy2,
|
||||
cx - dx1, cy + ry,
|
||||
cx, cy + ry);
|
||||
gnome_canvas_path_def_curveto (path_def,
|
||||
cx + dx1, cy + ry,
|
||||
cx + mx - dx2, cy + my + dy2,
|
||||
cx + mx, cy + my);
|
||||
gnome_canvas_path_def_curveto (path_def,
|
||||
cx + mx + dx2, cy + my - dy2,
|
||||
cx + rx, cy + dy1,
|
||||
cx + rx, cy);
|
||||
|
||||
gnome_canvas_path_def_closepath_current(path_def);
|
||||
|
||||
gnome_canvas_shape_set_path_def (GNOME_CANVAS_SHAPE (item), path_def);
|
||||
gnome_canvas_path_def_unref(path_def);
|
||||
re->path_dirty = 0;
|
||||
}
|
||||
|
||||
if (re_parent_class->update)
|
||||
(* re_parent_class->update) (item, affine, clip_path, flags);
|
||||
}
|
||||
159
libs/gnomecanvas/libgnomecanvas/gnome-canvas-rect-ellipse.h
Normal file
159
libs/gnomecanvas/libgnomecanvas/gnome-canvas-rect-ellipse.h
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* Rectangle and ellipse item types for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
*
|
||||
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_RECT_ELLIPSE_H
|
||||
#define GNOME_CANVAS_RECT_ELLIPSE_H
|
||||
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas-shape.h>
|
||||
|
||||
#include <libart_lgpl/art_svp.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* Base class for rectangle and ellipse item types. These are defined by their top-left and
|
||||
* bottom-right corners. Rectangles and ellipses share the following arguments:
|
||||
*
|
||||
* name type read/write description
|
||||
* ------------------------------------------------------------------------------------------
|
||||
* x1 double RW Leftmost coordinate of rectangle or ellipse
|
||||
* y1 double RW Topmost coordinate of rectangle or ellipse
|
||||
* x2 double RW Rightmost coordinate of rectangle or ellipse
|
||||
* y2 double RW Bottommost coordinate of rectangle or ellipse
|
||||
* fill_color string W X color specification for fill color,
|
||||
* or NULL pointer for no color (transparent)
|
||||
* fill_color_gdk GdkColor* RW Allocated GdkColor for fill
|
||||
* outline_color string W X color specification for outline color,
|
||||
* or NULL pointer for no color (transparent)
|
||||
* outline_color_gdk GdkColor* RW Allocated GdkColor for outline
|
||||
* fill_stipple GdkBitmap* RW Stipple pattern for fill
|
||||
* outline_stipple GdkBitmap* RW Stipple pattern for outline
|
||||
* width_pixels uint RW Width of the outline in pixels. The outline will
|
||||
* not be scaled when the canvas zoom factor is changed.
|
||||
* width_units double RW Width of the outline in canvas units. The outline
|
||||
* will be scaled when the canvas zoom factor is changed.
|
||||
*/
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS_RE (gnome_canvas_re_get_type ())
|
||||
#define GNOME_CANVAS_RE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_RE, GnomeCanvasRE))
|
||||
#define GNOME_CANVAS_RE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_RE, GnomeCanvasREClass))
|
||||
#define GNOME_IS_CANVAS_RE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_RE))
|
||||
#define GNOME_IS_CANVAS_RE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_RE))
|
||||
#define GNOME_CANVAS_RE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_RE, GnomeCanvasREClass))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasRE GnomeCanvasRE;
|
||||
typedef struct _GnomeCanvasREClass GnomeCanvasREClass;
|
||||
|
||||
struct _GnomeCanvasRE {
|
||||
GnomeCanvasShape item;
|
||||
|
||||
double x1, y1, x2, y2; /* Corners of item */
|
||||
|
||||
unsigned int path_dirty : 1;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasREClass {
|
||||
GnomeCanvasShapeClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_re_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
/* Rectangle item. No configurable or queryable arguments are available (use those in
|
||||
* GnomeCanvasRE).
|
||||
*/
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS_RECT (gnome_canvas_rect_get_type ())
|
||||
#define GNOME_CANVAS_RECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_RECT, GnomeCanvasRect))
|
||||
#define GNOME_CANVAS_RECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_RECT, GnomeCanvasRectClass))
|
||||
#define GNOME_IS_CANVAS_RECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_RECT))
|
||||
#define GNOME_IS_CANVAS_RECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_RECT))
|
||||
#define GNOME_CANVAS_RECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_RECT, GnomeCanvasRectClass))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasRect GnomeCanvasRect;
|
||||
typedef struct _GnomeCanvasRectClass GnomeCanvasRectClass;
|
||||
|
||||
struct _GnomeCanvasRect {
|
||||
GnomeCanvasRE re;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasRectClass {
|
||||
GnomeCanvasREClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_rect_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
/* Ellipse item. No configurable or queryable arguments are available (use those in
|
||||
* GnomeCanvasRE).
|
||||
*/
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS_ELLIPSE (gnome_canvas_ellipse_get_type ())
|
||||
#define GNOME_CANVAS_ELLIPSE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_ELLIPSE, GnomeCanvasEllipse))
|
||||
#define GNOME_CANVAS_ELLIPSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_ELLIPSE, GnomeCanvasEllipseClass))
|
||||
#define GNOME_IS_CANVAS_ELLIPSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_ELLIPSE))
|
||||
#define GNOME_IS_CANVAS_ELLIPSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_ELLIPSE))
|
||||
#define GNOME_CANVAS_ELLIPSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_ELLIPSE, GnomeCanvasEllipseClass))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasEllipse GnomeCanvasEllipse;
|
||||
typedef struct _GnomeCanvasEllipseClass GnomeCanvasEllipseClass;
|
||||
|
||||
struct _GnomeCanvasEllipse {
|
||||
GnomeCanvasRE re;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasEllipseClass {
|
||||
GnomeCanvasREClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_ellipse_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
2202
libs/gnomecanvas/libgnomecanvas/gnome-canvas-rich-text.c
Normal file
2202
libs/gnomecanvas/libgnomecanvas/gnome-canvas-rich-text.c
Normal file
File diff suppressed because it is too large
Load diff
79
libs/gnomecanvas/libgnomecanvas/gnome-canvas-rich-text.h
Normal file
79
libs/gnomecanvas/libgnomecanvas/gnome-canvas-rich-text.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* Editable GnomeCanvas text item based on GtkTextLayout, borrowed heavily
|
||||
* from GtkTextView.
|
||||
*
|
||||
* Copyright (c) 2000 Red Hat, Inc.
|
||||
* Copyright (c) 2001 Joe Shaw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_RICH_TEXT_H
|
||||
#define GNOME_CANVAS_RICH_TEXT_H
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GNOME_TYPE_CANVAS_RICH_TEXT (gnome_canvas_rich_text_get_type ())
|
||||
#define GNOME_CANVAS_RICH_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_RICH_TEXT, GnomeCanvasRichText))
|
||||
#define GNOME_CANVAS_RICH_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_RICH_TEXT, GnomeCanvasRichTextClass))
|
||||
#define GNOME_IS_CANVAS_RICH_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_RICH_TEXT))
|
||||
#define GNOME_IS_CANVAS_RICH_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_RICH_TEXT))
|
||||
#define GNOME_CANVAS_RICH_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_RICH_TEXT, GnomeCanvasRichTextClass))
|
||||
|
||||
typedef struct _GnomeCanvasRichText GnomeCanvasRichText;
|
||||
typedef struct _GnomeCanvasRichTextPrivate GnomeCanvasRichTextPrivate;
|
||||
typedef struct _GnomeCanvasRichTextClass GnomeCanvasRichTextClass;
|
||||
|
||||
struct _GnomeCanvasRichText {
|
||||
GnomeCanvasItem item;
|
||||
|
||||
GnomeCanvasRichTextPrivate *_priv;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasRichTextClass {
|
||||
GnomeCanvasItemClass parent_class;
|
||||
|
||||
void (* tag_changed)(GnomeCanvasRichText *text,
|
||||
GtkTextTag *tag);
|
||||
};
|
||||
|
||||
GType gnome_canvas_rich_text_get_type(void) G_GNUC_CONST;
|
||||
|
||||
void gnome_canvas_rich_text_cut_clipboard(GnomeCanvasRichText *text);
|
||||
|
||||
void gnome_canvas_rich_text_copy_clipboard(GnomeCanvasRichText *text);
|
||||
|
||||
void gnome_canvas_rich_text_paste_clipboard(GnomeCanvasRichText *text);
|
||||
|
||||
void gnome_canvas_rich_text_set_buffer(GnomeCanvasRichText *text,
|
||||
GtkTextBuffer *buffer);
|
||||
|
||||
GtkTextBuffer *gnome_canvas_rich_text_get_buffer(GnomeCanvasRichText *text);
|
||||
void
|
||||
gnome_canvas_rich_text_get_iter_location (GnomeCanvasRichText *text,
|
||||
const GtkTextIter *iter,
|
||||
GdkRectangle *location);
|
||||
void
|
||||
gnome_canvas_rich_text_get_iter_at_location (GnomeCanvasRichText *text,
|
||||
GtkTextIter *iter,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GNOME_CANVAS_RICH_TEXT_H */
|
||||
103
libs/gnomecanvas/libgnomecanvas/gnome-canvas-shape-private.h
Normal file
103
libs/gnomecanvas/libgnomecanvas/gnome-canvas-shape-private.h
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#ifndef GNOME_CANVAS_SHAPE_PRIVATE_H
|
||||
#define GNOME_CANVAS_SHAPE_PRIVATE_H
|
||||
|
||||
/* Bpath item type for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
* Copyright (C) 1998,1999 The Free Software Foundation
|
||||
*
|
||||
* Authors: Federico Mena <federico@nuclecu.unam.mx>
|
||||
* Raph Levien <raph@acm.org>
|
||||
* Lauris Kaplinski <lauris@ariman.ee>
|
||||
*/
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <libart_lgpl/art_vpath.h>
|
||||
#include <libart_lgpl/art_svp.h>
|
||||
#include <libart_lgpl/art_vpath_dash.h>
|
||||
#include <libart_lgpl/art_svp_wind.h>
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas-path-def.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GnomeCanvasShapePrivGdk GnomeCanvasShapePrivGdk;
|
||||
typedef struct _GCBPDrawCtx GCBPDrawCtx;
|
||||
|
||||
/* Per canvas private structure, holding necessary data for rendering
|
||||
* temporary masks, which are needed for drawing multipart bpaths.
|
||||
* As canvas cannot multithread, we can be sure, that masks are used
|
||||
* serially, also one set of masks per canvas is sufficent to guarantee,
|
||||
* that masks are created on needed X server. Masks grow as needed.
|
||||
* Full structure is refcounted in Bpath implementation
|
||||
*/
|
||||
|
||||
struct _GCBPDrawCtx {
|
||||
gint refcount;
|
||||
|
||||
GnomeCanvas * canvas;
|
||||
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
GdkBitmap * mask;
|
||||
GdkBitmap * clip;
|
||||
|
||||
GdkGC * clear_gc;
|
||||
GdkGC * xor_gc;
|
||||
};
|
||||
|
||||
/* Per Bpath private structure, holding Gdk specific data */
|
||||
|
||||
struct _GnomeCanvasShapePrivGdk {
|
||||
gulong fill_pixel; /* Color for fill */
|
||||
gulong outline_pixel; /* Color for outline */
|
||||
|
||||
GdkBitmap *fill_stipple; /* Stipple for fill */
|
||||
GdkBitmap *outline_stipple; /* Stipple for outline */
|
||||
|
||||
GdkGC * fill_gc; /* GC for filling */
|
||||
GdkGC * outline_gc; /* GC for outline */
|
||||
|
||||
gint len_points; /* Size of allocated points array */
|
||||
gint num_points; /* Gdk points in canvas coords */
|
||||
GdkPoint * points; /* Ivariant: closed paths are before open ones */
|
||||
GSList * closed_paths; /* List of lengths */
|
||||
GSList * open_paths; /* List of lengths */
|
||||
|
||||
GCBPDrawCtx * ctx; /* Pointer to per-canvas drawing context */
|
||||
};
|
||||
|
||||
struct _GnomeCanvasShapePriv {
|
||||
GnomeCanvasPathDef * path; /* Our bezier path representation */
|
||||
|
||||
gdouble scale; /* CTM scaling (for pen) */
|
||||
|
||||
guint fill_set : 1; /* Is fill color set? */
|
||||
guint outline_set : 1; /* Is outline color set? */
|
||||
guint width_pixels : 1; /* Is outline width specified in pixels or units? */
|
||||
|
||||
double width; /* Width of outline, in user coords */
|
||||
|
||||
guint32 fill_rgba; /* Fill color, RGBA */
|
||||
guint32 outline_rgba; /* Outline color, RGBA */
|
||||
|
||||
GdkCapStyle cap; /* Cap style for line */
|
||||
GdkJoinStyle join; /* Join style for line */
|
||||
ArtWindRule wind; /* Winding rule */
|
||||
double miterlimit; /* Miter limit */
|
||||
|
||||
ArtVpathDash dash; /* Dashing pattern */
|
||||
|
||||
ArtSVP * fill_svp; /* The SVP for the filled shape */
|
||||
ArtSVP * outline_svp; /* The SVP for the outline shape */
|
||||
|
||||
GnomeCanvasShapePrivGdk * gdk; /* Gdk specific things */
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
1558
libs/gnomecanvas/libgnomecanvas/gnome-canvas-shape.c
Normal file
1558
libs/gnomecanvas/libgnomecanvas/gnome-canvas-shape.c
Normal file
File diff suppressed because it is too large
Load diff
81
libs/gnomecanvas/libgnomecanvas/gnome-canvas-shape.h
Normal file
81
libs/gnomecanvas/libgnomecanvas/gnome-canvas-shape.h
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* Generic bezier shape item for GnomeCanvas
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
* Copyright (C) 1998,1999 The Free Software Foundation
|
||||
*
|
||||
* Authors: Federico Mena <federico@nuclecu.unam.mx>
|
||||
* Raph Levien <raph@acm.org>
|
||||
* Lauris Kaplinski <lauris@ximian.com>
|
||||
* Rusty Conover <rconover@bangtail.net>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_SHAPE_H
|
||||
#define GNOME_CANVAS_SHAPE_H
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
#include <libgnomecanvas/gnome-canvas-path-def.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* Shape item for the canvas.
|
||||
*
|
||||
* The following object arguments are available:
|
||||
*
|
||||
* name type read/write description
|
||||
* ------------------------------------------------------------------------------------------
|
||||
* fill_color string W X color specification for fill color,
|
||||
* or NULL pointer for no color (transparent).
|
||||
* fill_color_gdk GdkColor* RW Allocated GdkColor for fill.
|
||||
* outline_color string W X color specification for outline color,
|
||||
* or NULL pointer for no color (transparent).
|
||||
* outline_color_gdk GdkColor* RW Allocated GdkColor for outline.
|
||||
* fill_stipple GdkBitmap* RW Stipple pattern for fill
|
||||
* outline_stipple GdkBitmap* RW Stipple pattern for outline
|
||||
* width_pixels uint RW Width of the outline in pixels. The outline will
|
||||
* not be scaled when the canvas zoom factor is changed.
|
||||
* width_units double RW Width of the outline in canvas units. The outline
|
||||
* will be scaled when the canvas zoom factor is changed.
|
||||
* cap_style GdkCapStyle RW Cap ("endpoint") style for the bpath.
|
||||
* join_style GdkJoinStyle RW Join ("vertex") style for the bpath.
|
||||
* wind ArtWindRule RW Winding rule for the bpath.
|
||||
* dash ArtVpathDash RW Dashing pattern
|
||||
* miterlimit double RW Minimum angle between segments, where miter join
|
||||
* rule is applied.
|
||||
*/
|
||||
|
||||
#define GNOME_TYPE_CANVAS_SHAPE (gnome_canvas_shape_get_type ())
|
||||
#define GNOME_CANVAS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_SHAPE, GnomeCanvasShape))
|
||||
#define GNOME_CANVAS_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_SHAPE, GnomeCanvasShapeClass))
|
||||
#define GNOME_IS_CANVAS_SHAPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_SHAPE))
|
||||
#define GNOME_IS_CANVAS_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_SHAPE))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasShape GnomeCanvasShape;
|
||||
typedef struct _GnomeCanvasShapePriv GnomeCanvasShapePriv;
|
||||
typedef struct _GnomeCanvasShapeClass GnomeCanvasShapeClass;
|
||||
|
||||
struct _GnomeCanvasShape {
|
||||
GnomeCanvasItem item;
|
||||
|
||||
GnomeCanvasShapePriv *priv; /* Private data */
|
||||
};
|
||||
|
||||
struct _GnomeCanvasShapeClass {
|
||||
GnomeCanvasItemClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* WARNING! These are not usable from modifying shapes from user programs */
|
||||
/* These are meant, to set master shape from subclass ::update method */
|
||||
void gnome_canvas_shape_set_path_def (GnomeCanvasShape *shape, GnomeCanvasPathDef *def);
|
||||
GnomeCanvasPathDef *gnome_canvas_shape_get_path_def (GnomeCanvasShape *shape);
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_shape_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
1740
libs/gnomecanvas/libgnomecanvas/gnome-canvas-text.c
Normal file
1740
libs/gnomecanvas/libgnomecanvas/gnome-canvas-text.c
Normal file
File diff suppressed because it is too large
Load diff
170
libs/gnomecanvas/libgnomecanvas/gnome-canvas-text.h
Normal file
170
libs/gnomecanvas/libgnomecanvas/gnome-canvas-text.h
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* Text item type for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
*
|
||||
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
||||
* Port to Pango co-done by Gergõ Érdi <cactus@cactus.rulez.org>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_TEXT_H
|
||||
#define GNOME_CANVAS_TEXT_H
|
||||
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* Text item for the canvas. Text items are positioned by an anchor point and an anchor direction.
|
||||
*
|
||||
* A clipping rectangle may be specified for the text. The rectangle is anchored at the text's anchor
|
||||
* point, and is specified by clipping width and height parameters. If the clipping rectangle is
|
||||
* enabled, it will clip the text.
|
||||
*
|
||||
* In addition, x and y offset values may be specified. These specify an offset from the anchor
|
||||
* position. If used in conjunction with the clipping rectangle, these could be used to implement
|
||||
* simple scrolling of the text within the clipping rectangle.
|
||||
*
|
||||
* Properties marked with [*] also have _set properties associated
|
||||
* with them, that determine if the specified value should be used
|
||||
* instead of the default (style-defined) values
|
||||
*
|
||||
* The following object arguments are available:
|
||||
*
|
||||
* name type read/write description
|
||||
* ------------------------------------------------------------------------------------------
|
||||
* text string RW The string of the text label
|
||||
* markup string W A Pango markup string for the text label
|
||||
*
|
||||
* x double RW X coordinate of anchor point
|
||||
* y double RW Y coordinate of anchor point
|
||||
*
|
||||
* font string W A string describing the font
|
||||
* font_desc PangoFontDescription* RW Pointer to a PangoFontDescriptor
|
||||
* attributes PangoAttrList* RW Pointer to a Pango attribute list
|
||||
* style PangoStyle RW Pango style of font to use [*]
|
||||
* variant PangoVariant RW Pango variant of font to use [*]
|
||||
* weight int RW Pango weight of font to use [*]
|
||||
* stretch PangoStretch RW Pango stretch of font to use [*]
|
||||
* size int RW Size (in pixels) of font [*]
|
||||
* size_points double RW Size (in points) of font
|
||||
* scale double RW Ratio to scale font [*]
|
||||
*
|
||||
* anchor GtkAnchorType RW Anchor side for the text
|
||||
* justification GtkJustification RW Justification for multiline text
|
||||
* clip_width double RW Width of clip rectangle
|
||||
* clip_height double RW Height of clip rectangle
|
||||
* clip boolean RW Use clipping rectangle?
|
||||
* x_offset double RW Horizontal offset distance from anchor position
|
||||
* y_offset double RW Vertical offset distance from anchor position
|
||||
*
|
||||
* text_width double R Used to query the width of the rendered text
|
||||
* text_height double R Used to query the rendered height of the text
|
||||
*
|
||||
* fill_color string W X color specification for text
|
||||
* fill_color_gdk GdkColor* RW Pointer to an allocated GdkColor
|
||||
* fill_color_rgba guint RW RGBA value used for AA color.
|
||||
* fill_stipple GdkBitmap* RW Stipple pattern for filling the text
|
||||
*/
|
||||
|
||||
#define GNOME_TYPE_CANVAS_TEXT (gnome_canvas_text_get_type ())
|
||||
#define GNOME_CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_TEXT, GnomeCanvasText))
|
||||
#define GNOME_CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_TEXT, GnomeCanvasTextClass))
|
||||
#define GNOME_IS_CANVAS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_TEXT))
|
||||
#define GNOME_IS_CANVAS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_TEXT))
|
||||
#define GNOME_CANVAS_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_TEXT, GnomeCanvasTextClass))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasText GnomeCanvasText;
|
||||
typedef struct _GnomeCanvasTextClass GnomeCanvasTextClass;
|
||||
|
||||
typedef struct _GnomeCanvasTextPrivate GnomeCanvasTextPrivate;
|
||||
|
||||
struct _GnomeCanvasText {
|
||||
GnomeCanvasItem item;
|
||||
|
||||
PangoFontDescription *font_desc; /* Font description for text */
|
||||
PangoAttrList *attr_list; /* Attribute list of the text (caching) */
|
||||
PangoUnderline underline;
|
||||
gboolean strikethrough;
|
||||
int rise;
|
||||
double scale;
|
||||
|
||||
char *text; /* Text to display */
|
||||
GdkBitmap *stipple; /* Stipple for text */
|
||||
GdkGC *gc; /* GC for drawing text */
|
||||
PangoLayout *layout; /* The PangoLayout containing the text */
|
||||
|
||||
gulong pixel; /* Fill color */
|
||||
|
||||
double x, y; /* Position at anchor */
|
||||
|
||||
double clip_width; /* Width of optional clip rectangle */
|
||||
double clip_height; /* Height of optional clip rectangle */
|
||||
|
||||
double xofs, yofs; /* Text offset distance from anchor position */
|
||||
|
||||
double affine[6]; /* The item -> canvas affine */ /*AA*/
|
||||
|
||||
GtkAnchorType anchor; /* Anchor side for text */
|
||||
GtkJustification justification; /* Justification for text */
|
||||
|
||||
int cx, cy; /* Top-left canvas coordinates for text */
|
||||
int clip_cx, clip_cy; /* Top-left canvas coordinates for clip rectangle */
|
||||
int clip_cwidth, clip_cheight; /* Size of clip rectangle in pixels */
|
||||
int max_width; /* Maximum width of text lines */
|
||||
int height; /* Rendered text height in pixels */
|
||||
|
||||
guint32 rgba; /* RGBA color for text */ /*AA*/
|
||||
|
||||
guint clip : 1; /* Use clip rectangle? */
|
||||
|
||||
guint underline_set : 1; /* Apply specified underline style? */
|
||||
guint strike_set : 1; /* Apply specified strikethrough style? */
|
||||
guint rise_set : 1; /* Apply specified ascension/descension? */
|
||||
|
||||
guint scale_set : 1; /* Apply specified font scaling ratio? */
|
||||
|
||||
GnomeCanvasTextPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasTextClass {
|
||||
GnomeCanvasItemClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_text_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
700
libs/gnomecanvas/libgnomecanvas/gnome-canvas-util.c
Normal file
700
libs/gnomecanvas/libgnomecanvas/gnome-canvas-util.c
Normal file
|
|
@ -0,0 +1,700 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* Miscellaneous utility functions for the GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
*
|
||||
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* needed for M_PI_2 under 'gcc -ansi -predantic' on GNU/Linux */
|
||||
#ifndef _BSD_SOURCE
|
||||
# define _BSD_SOURCE 1
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <math.h>
|
||||
#include "gnome-canvas.h"
|
||||
#include "gnome-canvas-util.h"
|
||||
#include <libart_lgpl/art_uta.h>
|
||||
#include <libart_lgpl/art_svp.h>
|
||||
#include <libart_lgpl/art_svp_ops.h>
|
||||
#include <libart_lgpl/art_rgb.h>
|
||||
#include <libart_lgpl/art_rgb_svp.h>
|
||||
#include <libart_lgpl/art_uta_svp.h>
|
||||
#include <libart_lgpl/art_rect_svp.h>
|
||||
|
||||
/**
|
||||
* gnome_canvas_points_new:
|
||||
* @num_points: The number of points to allocate space for in the array.
|
||||
*
|
||||
* Creates a structure that should be used to pass an array of points to
|
||||
* items.
|
||||
*
|
||||
* Return value: A newly-created array of points. It should be filled in
|
||||
* by the user.
|
||||
**/
|
||||
GnomeCanvasPoints *
|
||||
gnome_canvas_points_new (int num_points)
|
||||
{
|
||||
GnomeCanvasPoints *points;
|
||||
|
||||
g_return_val_if_fail (num_points > 1, NULL);
|
||||
|
||||
points = g_new (GnomeCanvasPoints, 1);
|
||||
points->num_points = num_points;
|
||||
points->coords = g_new (double, 2 * num_points);
|
||||
points->ref_count = 1;
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_points_ref:
|
||||
* @points: A canvas points structure.
|
||||
*
|
||||
* Increases the reference count of the specified points structure.
|
||||
*
|
||||
* Return value: The canvas points structure itself.
|
||||
**/
|
||||
GnomeCanvasPoints *
|
||||
gnome_canvas_points_ref (GnomeCanvasPoints *points)
|
||||
{
|
||||
g_return_val_if_fail (points != NULL, NULL);
|
||||
|
||||
points->ref_count += 1;
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_points_free:
|
||||
* @points: A canvas points structure.
|
||||
*
|
||||
* Decreases the reference count of the specified points structure. If it
|
||||
* reaches zero, then the structure is freed.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_points_free (GnomeCanvasPoints *points)
|
||||
{
|
||||
g_return_if_fail (points != NULL);
|
||||
|
||||
points->ref_count -= 1;
|
||||
if (points->ref_count == 0) {
|
||||
g_free (points->coords);
|
||||
g_free (points);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_get_miter_points:
|
||||
* @x1: X coordinate of the first point
|
||||
* @y1: Y coordinate of the first point
|
||||
* @x2: X coordinate of the second (angle) point
|
||||
* @y2: Y coordinate of the second (angle) point
|
||||
* @x3: X coordinate of the third point
|
||||
* @y3: Y coordinate of the third point
|
||||
* @width: Width of the line
|
||||
* @mx1: The X coordinate of the first miter point is returned here.
|
||||
* @my1: The Y coordinate of the first miter point is returned here.
|
||||
* @mx2: The X coordinate of the second miter point is returned here.
|
||||
* @my2: The Y coordinate of the second miter point is returned here.
|
||||
*
|
||||
* Given three points forming an angle, computes the coordinates of the inside
|
||||
* and outside points of the mitered corner formed by a line of a given width at
|
||||
* that angle.
|
||||
*
|
||||
* Return value: FALSE if the angle is less than 11 degrees (this is the same
|
||||
* threshold as X uses. If this occurs, the return points are not modified.
|
||||
* Otherwise, returns TRUE.
|
||||
**/
|
||||
int
|
||||
gnome_canvas_get_miter_points (double x1, double y1, double x2, double y2, double x3, double y3,
|
||||
double width,
|
||||
double *mx1, double *my1, double *mx2, double *my2)
|
||||
{
|
||||
double theta1; /* angle of segment p2-p1 */
|
||||
double theta2; /* angle of segment p2-p3 */
|
||||
double theta; /* angle between line segments */
|
||||
double theta3; /* angle that bisects theta1 and theta2 and points to p1 */
|
||||
double dist; /* distance of miter points from p2 */
|
||||
double dx, dy; /* x and y offsets corresponding to dist */
|
||||
|
||||
#define ELEVEN_DEGREES (11.0 * G_PI / 180.0)
|
||||
|
||||
if (y2 == y1)
|
||||
theta1 = (x2 < x1) ? 0.0 : G_PI;
|
||||
else if (x2 == x1)
|
||||
theta1 = (y2 < y1) ? G_PI_2 : -G_PI_2;
|
||||
else
|
||||
theta1 = atan2 (y1 - y2, x1 - x2);
|
||||
|
||||
if (y3 == y2)
|
||||
theta2 = (x3 > x2) ? 0 : G_PI;
|
||||
else if (x3 == x2)
|
||||
theta2 = (y3 > y2) ? G_PI_2 : -G_PI_2;
|
||||
else
|
||||
theta2 = atan2 (y3 - y2, x3 - x2);
|
||||
|
||||
theta = theta1 - theta2;
|
||||
|
||||
if (theta > G_PI)
|
||||
theta -= 2.0 * G_PI;
|
||||
else if (theta < -G_PI)
|
||||
theta += 2.0 * G_PI;
|
||||
|
||||
if ((theta < ELEVEN_DEGREES) && (theta > -ELEVEN_DEGREES))
|
||||
return FALSE;
|
||||
|
||||
dist = 0.5 * width / sin (0.5 * theta);
|
||||
if (dist < 0.0)
|
||||
dist = -dist;
|
||||
|
||||
theta3 = (theta1 + theta2) / 2.0;
|
||||
if (sin (theta3 - (theta1 + G_PI)) < 0.0)
|
||||
theta3 += G_PI;
|
||||
|
||||
dx = dist * cos (theta3);
|
||||
dy = dist * sin (theta3);
|
||||
|
||||
*mx1 = x2 + dx;
|
||||
*mx2 = x2 - dx;
|
||||
*my1 = y2 + dy;
|
||||
*my2 = y2 - dy;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_get_butt_points:
|
||||
* @x1: X coordinate of first point in the line
|
||||
* @y1: Y cooordinate of first point in the line
|
||||
* @x2: X coordinate of second point (endpoint) of the line
|
||||
* @y2: Y coordinate of second point (endpoint) of the line
|
||||
* @width: Width of the line
|
||||
* @project: Whether the butt points should project out by width/2 distance
|
||||
* @bx1: X coordinate of first butt point is returned here
|
||||
* @by1: Y coordinate of first butt point is returned here
|
||||
* @bx2: X coordinate of second butt point is returned here
|
||||
* @by2: Y coordinate of second butt point is returned here
|
||||
*
|
||||
* Computes the butt points of a line segment.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_get_butt_points (double x1, double y1, double x2, double y2,
|
||||
double width, int project,
|
||||
double *bx1, double *by1, double *bx2, double *by2)
|
||||
{
|
||||
double length;
|
||||
double dx, dy;
|
||||
|
||||
width *= 0.5;
|
||||
dx = x2 - x1;
|
||||
dy = y2 - y1;
|
||||
length = sqrt (dx * dx + dy * dy);
|
||||
|
||||
if (length < GNOME_CANVAS_EPSILON) {
|
||||
*bx1 = *bx2 = x2;
|
||||
*by1 = *by2 = y2;
|
||||
} else {
|
||||
dx = -width * (y2 - y1) / length;
|
||||
dy = width * (x2 - x1) / length;
|
||||
|
||||
*bx1 = x2 + dx;
|
||||
*bx2 = x2 - dx;
|
||||
*by1 = y2 + dy;
|
||||
*by2 = y2 - dy;
|
||||
|
||||
if (project) {
|
||||
*bx1 += dy;
|
||||
*bx2 += dy;
|
||||
*by1 -= dx;
|
||||
*by2 -= dx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_polygon_to_point:
|
||||
* @poly: Vertices of the polygon. X coordinates are in the even indices, and Y
|
||||
* coordinates are in the odd indices
|
||||
* @num_points: Number of points in the polygon
|
||||
* @x: X coordinate of the point
|
||||
* @y: Y coordinate of the point
|
||||
*
|
||||
* Computes the distance between a point and a polygon.
|
||||
*
|
||||
* Return value: The distance from the point to the polygon, or zero if the
|
||||
* point is inside the polygon.
|
||||
**/
|
||||
double
|
||||
gnome_canvas_polygon_to_point (double *poly, int num_points, double x, double y)
|
||||
{
|
||||
double best;
|
||||
int intersections;
|
||||
int i;
|
||||
double *p;
|
||||
double dx, dy;
|
||||
|
||||
/* Iterate through all the edges in the polygon, updating best and intersections.
|
||||
*
|
||||
* When computing intersections, include left X coordinate of line within its range, but not
|
||||
* Y coordinate. Otherwise if the point lies exactly below a vertex we'll count it as two
|
||||
* intersections.
|
||||
*/
|
||||
|
||||
best = 1.0e36;
|
||||
intersections = 0;
|
||||
|
||||
for (i = num_points, p = poly; i > 1; i--, p += 2) {
|
||||
double px, py, dist;
|
||||
|
||||
/* Compute the point on the current edge closest to the point and update the
|
||||
* intersection count. This must be done separately for vertical edges, horizontal
|
||||
* edges, and others.
|
||||
*/
|
||||
|
||||
if (p[2] == p[0]) {
|
||||
/* Vertical edge */
|
||||
|
||||
px = p[0];
|
||||
|
||||
if (p[1] >= p[3]) {
|
||||
py = MIN (p[1], y);
|
||||
py = MAX (py, p[3]);
|
||||
} else {
|
||||
py = MIN (p[3], y);
|
||||
py = MAX (py, p[1]);
|
||||
}
|
||||
} else if (p[3] == p[1]) {
|
||||
/* Horizontal edge */
|
||||
|
||||
py = p[1];
|
||||
|
||||
if (p[0] >= p[2]) {
|
||||
px = MIN (p[0], x);
|
||||
px = MAX (px, p[2]);
|
||||
|
||||
if ((y < py) && (x < p[0]) && (x >= p[2]))
|
||||
intersections++;
|
||||
} else {
|
||||
px = MIN (p[2], x);
|
||||
px = MAX (px, p[0]);
|
||||
|
||||
if ((y < py) && (x < p[2]) && (x >= p[0]))
|
||||
intersections++;
|
||||
}
|
||||
} else {
|
||||
double m1, b1, m2, b2;
|
||||
int lower;
|
||||
|
||||
/* Diagonal edge. Convert the edge to a line equation (y = m1*x + b1), then
|
||||
* compute a line perpendicular to this edge but passing through the point,
|
||||
* (y = m2*x + b2).
|
||||
*/
|
||||
|
||||
m1 = (p[3] - p[1]) / (p[2] - p[0]);
|
||||
b1 = p[1] - m1 * p[0];
|
||||
|
||||
m2 = -1.0 / m1;
|
||||
b2 = y - m2 * x;
|
||||
|
||||
px = (b2 - b1) / (m1 - m2);
|
||||
py = m1 * px + b1;
|
||||
|
||||
if (p[0] > p[2]) {
|
||||
if (px > p[0]) {
|
||||
px = p[0];
|
||||
py = p[1];
|
||||
} else if (px < p[2]) {
|
||||
px = p[2];
|
||||
py = p[3];
|
||||
}
|
||||
} else {
|
||||
if (px > p[2]) {
|
||||
px = p[2];
|
||||
py = p[3];
|
||||
} else if (px < p[0]) {
|
||||
px = p[0];
|
||||
py = p[1];
|
||||
}
|
||||
}
|
||||
|
||||
lower = (m1 * x + b1) > y;
|
||||
|
||||
if (lower && (x >= MIN (p[0], p[2])) && (x < MAX (p[0], p[2])))
|
||||
intersections++;
|
||||
}
|
||||
|
||||
/* Compute the distance to the closest point, and see if that is the best so far */
|
||||
|
||||
dx = x - px;
|
||||
dy = y - py;
|
||||
dist = sqrt (dx * dx + dy * dy);
|
||||
if (dist < best)
|
||||
best = dist;
|
||||
}
|
||||
|
||||
/* We've processed all the points. If the number of intersections is odd, the point is
|
||||
* inside the polygon.
|
||||
*/
|
||||
|
||||
if (intersections & 0x1)
|
||||
return 0.0;
|
||||
else
|
||||
return best;
|
||||
}
|
||||
|
||||
/* Here are some helper functions for aa rendering: */
|
||||
|
||||
/**
|
||||
* gnome_canvas_render_svp:
|
||||
* @buf: the canvas buffer to render over
|
||||
* @svp: the vector path to render
|
||||
* @rgba: the rgba color to render
|
||||
*
|
||||
* Render the svp over the buf.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_render_svp (GnomeCanvasBuf *buf, ArtSVP *svp, guint32 rgba)
|
||||
{
|
||||
guint32 fg_color, bg_color;
|
||||
int alpha;
|
||||
|
||||
if (buf->is_bg) {
|
||||
bg_color = buf->bg_color;
|
||||
alpha = rgba & 0xff;
|
||||
if (alpha == 0xff)
|
||||
fg_color = rgba >> 8;
|
||||
else {
|
||||
/* composite over background color */
|
||||
int bg_r, bg_g, bg_b;
|
||||
int fg_r, fg_g, fg_b;
|
||||
int tmp;
|
||||
|
||||
bg_r = (bg_color >> 16) & 0xff;
|
||||
fg_r = (rgba >> 24) & 0xff;
|
||||
tmp = (fg_r - bg_r) * alpha;
|
||||
fg_r = bg_r + ((tmp + (tmp >> 8) + 0x80) >> 8);
|
||||
|
||||
bg_g = (bg_color >> 8) & 0xff;
|
||||
fg_g = (rgba >> 16) & 0xff;
|
||||
tmp = (fg_g - bg_g) * alpha;
|
||||
fg_g = bg_g + ((tmp + (tmp >> 8) + 0x80) >> 8);
|
||||
|
||||
bg_b = bg_color & 0xff;
|
||||
fg_b = (rgba >> 8) & 0xff;
|
||||
tmp = (fg_b - bg_b) * alpha;
|
||||
fg_b = bg_b + ((tmp + (tmp >> 8) + 0x80) >> 8);
|
||||
|
||||
fg_color = (fg_r << 16) | (fg_g << 8) | fg_b;
|
||||
}
|
||||
art_rgb_svp_aa (svp,
|
||||
buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1,
|
||||
fg_color, bg_color,
|
||||
buf->buf, buf->buf_rowstride,
|
||||
NULL);
|
||||
buf->is_bg = 0;
|
||||
buf->is_buf = 1;
|
||||
} else {
|
||||
art_rgb_svp_alpha (svp,
|
||||
buf->rect.x0, buf->rect.y0, buf->rect.x1, buf->rect.y1,
|
||||
rgba,
|
||||
buf->buf, buf->buf_rowstride,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_update_svp:
|
||||
* @canvas: the canvas containing the svp that needs updating.
|
||||
* @p_svp: a pointer to the existing svp
|
||||
* @new_svp: the new svp
|
||||
*
|
||||
* Sets the svp to the new value, requesting repaint on what's changed. This
|
||||
* function takes responsibility for freeing new_svp.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_update_svp (GnomeCanvas *canvas, ArtSVP **p_svp, ArtSVP *new_svp)
|
||||
{
|
||||
ArtSVP *old_svp;
|
||||
ArtSVP *diff G_GNUC_UNUSED;
|
||||
ArtUta *repaint_uta;
|
||||
|
||||
old_svp = *p_svp;
|
||||
|
||||
if (old_svp != NULL) {
|
||||
ArtDRect bb;
|
||||
art_drect_svp (&bb, old_svp);
|
||||
if ((bb.x1 - bb.x0) * (bb.y1 - bb.y0) > (64 * 64)) {
|
||||
repaint_uta = art_uta_from_svp (old_svp);
|
||||
gnome_canvas_request_redraw_uta (canvas, repaint_uta);
|
||||
} else {
|
||||
ArtIRect ib;
|
||||
art_drect_to_irect (&ib, &bb);
|
||||
gnome_canvas_request_redraw (canvas, ib.x0, ib.y0, ib.x1, ib.y1);
|
||||
}
|
||||
art_svp_free (old_svp);
|
||||
}
|
||||
|
||||
if (new_svp != NULL) {
|
||||
ArtDRect bb;
|
||||
art_drect_svp (&bb, new_svp);
|
||||
if ((bb.x1 - bb.x0) * (bb.y1 - bb.y0) > (64 * 64)) {
|
||||
repaint_uta = art_uta_from_svp (new_svp);
|
||||
gnome_canvas_request_redraw_uta (canvas, repaint_uta);
|
||||
} else {
|
||||
ArtIRect ib;
|
||||
art_drect_to_irect (&ib, &bb);
|
||||
gnome_canvas_request_redraw (canvas, ib.x0, ib.y0, ib.x1, ib.y1);
|
||||
}
|
||||
}
|
||||
|
||||
*p_svp = new_svp;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_update_svp_clip:
|
||||
* @canvas: the canvas containing the svp that needs updating.
|
||||
* @p_svp: a pointer to the existing svp
|
||||
* @new_svp: the new svp
|
||||
* @clip_svp: a clip path, if non-null
|
||||
*
|
||||
* Sets the svp to the new value, clipping if necessary, and requesting repaint
|
||||
* on what's changed. This function takes responsibility for freeing new_svp.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_update_svp_clip (GnomeCanvas *canvas, ArtSVP **p_svp, ArtSVP *new_svp, ArtSVP *clip_svp)
|
||||
{
|
||||
ArtSVP *clipped_svp;
|
||||
|
||||
if (clip_svp != NULL) {
|
||||
clipped_svp = art_svp_intersect (new_svp, clip_svp);
|
||||
art_svp_free (new_svp);
|
||||
} else {
|
||||
clipped_svp = new_svp;
|
||||
}
|
||||
gnome_canvas_update_svp (canvas, p_svp, clipped_svp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_item_reset_bounds:
|
||||
* @item: A canvas item
|
||||
*
|
||||
* Resets the bounding box of a canvas item to an empty rectangle.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_item_reset_bounds (GnomeCanvasItem *item)
|
||||
{
|
||||
item->x1 = 0.0;
|
||||
item->y1 = 0.0;
|
||||
item->x2 = 0.0;
|
||||
item->y2 = 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_item_update_svp:
|
||||
* @item: the canvas item containing the svp that needs updating.
|
||||
* @p_svp: a pointer to the existing svp
|
||||
* @new_svp: the new svp
|
||||
*
|
||||
* Sets the svp to the new value, requesting repaint on what's changed. This
|
||||
* function takes responsibility for freeing new_svp. This routine also adds the
|
||||
* svp's bbox to the item's.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_item_update_svp (GnomeCanvasItem *item, ArtSVP **p_svp, ArtSVP *new_svp)
|
||||
{
|
||||
ArtDRect bbox;
|
||||
|
||||
gnome_canvas_update_svp (item->canvas, p_svp, new_svp);
|
||||
if (new_svp) {
|
||||
bbox.x0 = item->x1;
|
||||
bbox.y0 = item->y1;
|
||||
bbox.x1 = item->x2;
|
||||
bbox.y1 = item->y2;
|
||||
art_drect_svp_union (&bbox, new_svp);
|
||||
item->x1 = bbox.x0;
|
||||
item->y1 = bbox.y0;
|
||||
item->x2 = bbox.x1;
|
||||
item->y2 = bbox.y1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_item_update_svp_clip:
|
||||
* @item: the canvas item containing the svp that needs updating.
|
||||
* @p_svp: a pointer to the existing svp
|
||||
* @new_svp: the new svp
|
||||
* @clip_svp: a clip path, if non-null
|
||||
*
|
||||
* Sets the svp to the new value, clipping if necessary, and requesting repaint
|
||||
* on what's changed. This function takes responsibility for freeing new_svp.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_item_update_svp_clip (GnomeCanvasItem *item, ArtSVP **p_svp, ArtSVP *new_svp,
|
||||
ArtSVP *clip_svp)
|
||||
{
|
||||
ArtSVP *clipped_svp;
|
||||
|
||||
if (clip_svp != NULL) {
|
||||
clipped_svp = art_svp_intersect (new_svp, clip_svp);
|
||||
art_svp_free (new_svp);
|
||||
} else {
|
||||
clipped_svp = new_svp;
|
||||
}
|
||||
|
||||
gnome_canvas_item_update_svp (item, p_svp, clipped_svp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_item_request_redraw_svp
|
||||
* @item: the item containing the svp
|
||||
* @svp: the svp that needs to be redrawn
|
||||
*
|
||||
* Request redraw of the svp if in aa mode, or the entire item in in xlib mode.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_item_request_redraw_svp (GnomeCanvasItem *item, const ArtSVP *svp)
|
||||
{
|
||||
GnomeCanvas *canvas;
|
||||
ArtUta *uta;
|
||||
|
||||
canvas = item->canvas;
|
||||
if (canvas->aa) {
|
||||
if (svp != NULL) {
|
||||
uta = art_uta_from_svp (svp);
|
||||
gnome_canvas_request_redraw_uta (canvas, uta);
|
||||
}
|
||||
} else {
|
||||
gnome_canvas_request_redraw (canvas, item->x1, item->y1, item->x2, item->y2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_update_bbox:
|
||||
* @item: the canvas item needing update
|
||||
* @x1: Left coordinate of the new bounding box
|
||||
* @y1: Top coordinate of the new bounding box
|
||||
* @x2: Right coordinate of the new bounding box
|
||||
* @y2: Bottom coordinate of the new bounding box
|
||||
*
|
||||
* Sets the bbox to the new value, requesting full repaint.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_update_bbox (GnomeCanvasItem *item, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
|
||||
item->x1 = x1;
|
||||
item->y1 = y1;
|
||||
item->x2 = x2;
|
||||
item->y2 = y2;
|
||||
gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_buf_ensure_buf:
|
||||
* @buf: the buf that needs to be represened in RGB format
|
||||
*
|
||||
* Ensure that the buffer is in RGB format, suitable for compositing.
|
||||
**/
|
||||
void
|
||||
gnome_canvas_buf_ensure_buf (GnomeCanvasBuf *buf)
|
||||
{
|
||||
guchar *bufptr;
|
||||
int y;
|
||||
|
||||
if (!buf->is_buf) {
|
||||
bufptr = buf->buf;
|
||||
for (y = buf->rect.y0; y < buf->rect.y1; y++) {
|
||||
art_rgb_fill_run (bufptr,
|
||||
buf->bg_color >> 16,
|
||||
(buf->bg_color >> 8) & 0xff,
|
||||
buf->bg_color & 0xff,
|
||||
buf->rect.x1 - buf->rect.x0);
|
||||
bufptr += buf->buf_rowstride;
|
||||
}
|
||||
buf->is_buf = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_join_gdk_to_art
|
||||
* @gdk_join: a join type, represented in GDK format
|
||||
*
|
||||
* Convert from GDK line join specifier to libart.
|
||||
*
|
||||
* Return value: The line join specifier in libart format.
|
||||
**/
|
||||
ArtPathStrokeJoinType
|
||||
gnome_canvas_join_gdk_to_art (GdkJoinStyle gdk_join)
|
||||
{
|
||||
switch (gdk_join) {
|
||||
case GDK_JOIN_MITER:
|
||||
return ART_PATH_STROKE_JOIN_MITER;
|
||||
|
||||
case GDK_JOIN_ROUND:
|
||||
return ART_PATH_STROKE_JOIN_ROUND;
|
||||
|
||||
case GDK_JOIN_BEVEL:
|
||||
return ART_PATH_STROKE_JOIN_BEVEL;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return ART_PATH_STROKE_JOIN_MITER; /* shut up the compiler */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gnome_canvas_cap_gdk_to_art
|
||||
* @gdk_cap: a cap type, represented in GDK format
|
||||
*
|
||||
* Convert from GDK line cap specifier to libart.
|
||||
*
|
||||
* Return value: The line cap specifier in libart format.
|
||||
**/
|
||||
ArtPathStrokeCapType
|
||||
gnome_canvas_cap_gdk_to_art (GdkCapStyle gdk_cap)
|
||||
{
|
||||
switch (gdk_cap) {
|
||||
case GDK_CAP_BUTT:
|
||||
case GDK_CAP_NOT_LAST:
|
||||
return ART_PATH_STROKE_CAP_BUTT;
|
||||
|
||||
case GDK_CAP_ROUND:
|
||||
return ART_PATH_STROKE_CAP_ROUND;
|
||||
|
||||
case GDK_CAP_PROJECTING:
|
||||
return ART_PATH_STROKE_CAP_SQUARE;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return ART_PATH_STROKE_CAP_BUTT; /* shut up the compiler */
|
||||
}
|
||||
}
|
||||
155
libs/gnomecanvas/libgnomecanvas/gnome-canvas-util.h
Normal file
155
libs/gnomecanvas/libgnomecanvas/gnome-canvas-util.h
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* Miscellaneous utility functions for the GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_UTIL_H
|
||||
#define GNOME_CANVAS_UTIL_H
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
|
||||
#include <libart_lgpl/art_svp.h>
|
||||
#include <libart_lgpl/art_vpath.h>
|
||||
#include <libart_lgpl/art_svp_vpath_stroke.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GnomeCanvasPoints GnomeCanvasPoints;
|
||||
|
||||
/* This structure defines an array of points. X coordinates are stored in the even-numbered
|
||||
* indices, and Y coordinates are stored in the odd-numbered indices. num_points indicates the
|
||||
* number of points, so the array is 2*num_points elements big.
|
||||
*/
|
||||
struct _GnomeCanvasPoints {
|
||||
double *coords;
|
||||
int num_points;
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
|
||||
/* Allocate a new GnomeCanvasPoints structure with enough space for the specified number of points */
|
||||
GnomeCanvasPoints *gnome_canvas_points_new (int num_points);
|
||||
|
||||
/* Increate ref count */
|
||||
GnomeCanvasPoints *gnome_canvas_points_ref (GnomeCanvasPoints *points);
|
||||
#define gnome_canvas_points_unref gnome_canvas_points_free
|
||||
|
||||
/* Decrease ref count and free structure if it has reached zero */
|
||||
void gnome_canvas_points_free (GnomeCanvasPoints *points);
|
||||
|
||||
/* Given three points forming an angle, compute the coordinates of the inside and outside points of
|
||||
* the mitered corner formed by a line of a given width at that angle.
|
||||
*
|
||||
* If the angle is less than 11 degrees, then FALSE is returned and the return points are not
|
||||
* modified. Otherwise, TRUE is returned.
|
||||
*/
|
||||
int gnome_canvas_get_miter_points (double x1, double y1, double x2, double y2, double x3, double y3,
|
||||
double width,
|
||||
double *mx1, double *my1, double *mx2, double *my2);
|
||||
|
||||
/* Compute the butt points of a line segment. If project is FALSE, then the results are as follows:
|
||||
*
|
||||
* -------------------* (bx1, by1)
|
||||
* |
|
||||
* (x1, y1) *------------------* (x2, y2)
|
||||
* |
|
||||
* -------------------* (bx2, by2)
|
||||
*
|
||||
* that is, the line is not projected beyond (x2, y2). If project is TRUE, then the results are as
|
||||
* follows:
|
||||
*
|
||||
* -------------------* (bx1, by1)
|
||||
* (x2, y2) |
|
||||
* (x1, y1) *-------------* |
|
||||
* |
|
||||
* -------------------* (bx2, by2)
|
||||
*/
|
||||
void gnome_canvas_get_butt_points (double x1, double y1, double x2, double y2,
|
||||
double width, int project,
|
||||
double *bx1, double *by1, double *bx2, double *by2);
|
||||
|
||||
/* Calculate the distance from a polygon to a point. The polygon's X coordinates are in the even
|
||||
* indices of the poly array, and the Y coordinates are in the odd indices.
|
||||
*/
|
||||
double gnome_canvas_polygon_to_point (double *poly, int num_points, double x, double y);
|
||||
|
||||
|
||||
/* Render the svp over the buf. */
|
||||
void gnome_canvas_render_svp (GnomeCanvasBuf *buf, ArtSVP *svp, guint32 rgba);
|
||||
|
||||
/* Sets the svp to the new value, requesting repaint on what's changed. This function takes responsibility for
|
||||
* freeing new_svp.
|
||||
*/
|
||||
void gnome_canvas_update_svp (GnomeCanvas *canvas, ArtSVP **p_svp, ArtSVP *new_svp);
|
||||
|
||||
/* Sets the svp to the new value, clipping if necessary, and requesting repaint
|
||||
* on what's changed. This function takes responsibility for freeing new_svp.
|
||||
*/
|
||||
void gnome_canvas_update_svp_clip (GnomeCanvas *canvas, ArtSVP **p_svp, ArtSVP *new_svp,
|
||||
ArtSVP *clip_svp);
|
||||
|
||||
/* Sets the svp to the new value, requesting repaint on what's changed. This
|
||||
* function takes responsibility for freeing new_svp. This routine also adds the
|
||||
* svp's bbox to the item's.
|
||||
*/
|
||||
void gnome_canvas_item_reset_bounds (GnomeCanvasItem *item);
|
||||
|
||||
/* Sets the svp to the new value, requesting repaint on what's changed. This function takes responsibility for
|
||||
* freeing new_svp. This routine also adds the svp's bbox to the item's.
|
||||
*/
|
||||
void gnome_canvas_item_update_svp (GnomeCanvasItem *item, ArtSVP **p_svp, ArtSVP *new_svp);
|
||||
|
||||
/* Sets the svp to the new value, clipping if necessary, and requesting repaint
|
||||
* on what's changed. This function takes responsibility for freeing new_svp.
|
||||
*/
|
||||
void gnome_canvas_item_update_svp_clip (GnomeCanvasItem *item, ArtSVP **p_svp, ArtSVP *new_svp,
|
||||
ArtSVP *clip_svp);
|
||||
|
||||
/* Request redraw of the svp if in aa mode, or the entire item in in xlib
|
||||
* mode.
|
||||
*/
|
||||
void gnome_canvas_item_request_redraw_svp (GnomeCanvasItem *item, const ArtSVP *svp);
|
||||
|
||||
/* Sets the bbox to the new value, requesting full repaint. */
|
||||
void gnome_canvas_update_bbox (GnomeCanvasItem *item, int x1, int y1, int x2, int y2);
|
||||
|
||||
/* Ensure that the buffer is in RGB format, suitable for compositing. */
|
||||
void gnome_canvas_buf_ensure_buf (GnomeCanvasBuf *buf);
|
||||
|
||||
/* Convert from GDK line join specifier to libart. */
|
||||
ArtPathStrokeJoinType gnome_canvas_join_gdk_to_art (GdkJoinStyle gdk_join);
|
||||
|
||||
/* Convert from GDK line cap specifier to libart. */
|
||||
ArtPathStrokeCapType gnome_canvas_cap_gdk_to_art (GdkCapStyle gdk_cap);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
599
libs/gnomecanvas/libgnomecanvas/gnome-canvas-widget.c
Normal file
599
libs/gnomecanvas/libgnomecanvas/gnome-canvas-widget.c
Normal file
|
|
@ -0,0 +1,599 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* Widget item type for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
*
|
||||
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <math.h>
|
||||
#include <gtk/gtksignal.h>
|
||||
#include "gnome-canvas-widget.h"
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_WIDGET,
|
||||
PROP_X,
|
||||
PROP_Y,
|
||||
PROP_WIDTH,
|
||||
PROP_HEIGHT,
|
||||
PROP_ANCHOR,
|
||||
PROP_SIZE_PIXELS
|
||||
};
|
||||
|
||||
|
||||
static void gnome_canvas_widget_class_init (GnomeCanvasWidgetClass *class);
|
||||
static void gnome_canvas_widget_init (GnomeCanvasWidget *witem);
|
||||
static void gnome_canvas_widget_destroy (GtkObject *object);
|
||||
static void gnome_canvas_widget_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gnome_canvas_widget_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gnome_canvas_widget_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags);
|
||||
static double gnome_canvas_widget_point (GnomeCanvasItem *item, double x, double y,
|
||||
int cx, int cy, GnomeCanvasItem **actual_item);
|
||||
static void gnome_canvas_widget_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2);
|
||||
|
||||
static void gnome_canvas_widget_render (GnomeCanvasItem *item,
|
||||
GnomeCanvasBuf *buf);
|
||||
static void gnome_canvas_widget_draw (GnomeCanvasItem *item,
|
||||
GdkDrawable *drawable,
|
||||
int x, int y,
|
||||
int width, int height);
|
||||
|
||||
static GnomeCanvasItemClass *parent_class;
|
||||
|
||||
|
||||
GType
|
||||
gnome_canvas_widget_get_type (void)
|
||||
{
|
||||
static GType widget_type;
|
||||
|
||||
if (!widget_type) {
|
||||
const GTypeInfo object_info = {
|
||||
sizeof (GnomeCanvasWidgetClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gnome_canvas_widget_class_init,
|
||||
(GClassFinalizeFunc) NULL,
|
||||
NULL, /* class_data */
|
||||
sizeof (GnomeCanvasWidget),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gnome_canvas_widget_init,
|
||||
NULL /* value_table */
|
||||
};
|
||||
|
||||
widget_type = g_type_register_static (GNOME_TYPE_CANVAS_ITEM, "GnomeCanvasWidget",
|
||||
&object_info, 0);
|
||||
}
|
||||
|
||||
return widget_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_widget_class_init (GnomeCanvasWidgetClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkObjectClass *object_class;
|
||||
GnomeCanvasItemClass *item_class;
|
||||
|
||||
gobject_class = (GObjectClass *) class;
|
||||
object_class = (GtkObjectClass *) class;
|
||||
item_class = (GnomeCanvasItemClass *) class;
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gobject_class->set_property = gnome_canvas_widget_set_property;
|
||||
gobject_class->get_property = gnome_canvas_widget_get_property;
|
||||
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_WIDGET,
|
||||
g_param_spec_object ("widget", NULL, NULL,
|
||||
GTK_TYPE_WIDGET,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_X,
|
||||
g_param_spec_double ("x", NULL, NULL,
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_Y,
|
||||
g_param_spec_double ("y", NULL, NULL,
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_WIDTH,
|
||||
g_param_spec_double ("width", NULL, NULL,
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_HEIGHT,
|
||||
g_param_spec_double ("height", NULL, NULL,
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_ANCHOR,
|
||||
g_param_spec_enum ("anchor", NULL, NULL,
|
||||
GTK_TYPE_ANCHOR_TYPE,
|
||||
GTK_ANCHOR_NW,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
g_object_class_install_property
|
||||
(gobject_class,
|
||||
PROP_SIZE_PIXELS,
|
||||
g_param_spec_boolean ("size_pixels", NULL, NULL,
|
||||
FALSE,
|
||||
(G_PARAM_READABLE | G_PARAM_WRITABLE)));
|
||||
|
||||
object_class->destroy = gnome_canvas_widget_destroy;
|
||||
|
||||
item_class->update = gnome_canvas_widget_update;
|
||||
item_class->point = gnome_canvas_widget_point;
|
||||
item_class->bounds = gnome_canvas_widget_bounds;
|
||||
item_class->render = gnome_canvas_widget_render;
|
||||
item_class->draw = gnome_canvas_widget_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_widget_init (GnomeCanvasWidget *witem)
|
||||
{
|
||||
witem->x = 0.0;
|
||||
witem->y = 0.0;
|
||||
witem->width = 0.0;
|
||||
witem->height = 0.0;
|
||||
witem->anchor = GTK_ANCHOR_NW;
|
||||
witem->size_pixels = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_widget_destroy (GtkObject *object)
|
||||
{
|
||||
GnomeCanvasWidget *witem;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_WIDGET (object));
|
||||
|
||||
witem = GNOME_CANVAS_WIDGET (object);
|
||||
|
||||
if (witem->widget && !witem->in_destroy) {
|
||||
g_signal_handler_disconnect (witem->widget, witem->destroy_id);
|
||||
gtk_widget_destroy (witem->widget);
|
||||
witem->widget = NULL;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
}
|
||||
|
||||
static void
|
||||
recalc_bounds (GnomeCanvasWidget *witem)
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
double wx, wy;
|
||||
|
||||
item = GNOME_CANVAS_ITEM (witem);
|
||||
|
||||
/* Get world coordinates */
|
||||
|
||||
wx = witem->x;
|
||||
wy = witem->y;
|
||||
gnome_canvas_item_i2w (item, &wx, &wy);
|
||||
|
||||
/* Get canvas pixel coordinates */
|
||||
|
||||
gnome_canvas_w2c (item->canvas, wx, wy, &witem->cx, &witem->cy);
|
||||
|
||||
/* Anchor widget item */
|
||||
|
||||
switch (witem->anchor) {
|
||||
case GTK_ANCHOR_NW:
|
||||
case GTK_ANCHOR_W:
|
||||
case GTK_ANCHOR_SW:
|
||||
break;
|
||||
|
||||
case GTK_ANCHOR_N:
|
||||
case GTK_ANCHOR_CENTER:
|
||||
case GTK_ANCHOR_S:
|
||||
witem->cx -= witem->cwidth / 2;
|
||||
break;
|
||||
|
||||
case GTK_ANCHOR_NE:
|
||||
case GTK_ANCHOR_E:
|
||||
case GTK_ANCHOR_SE:
|
||||
witem->cx -= witem->cwidth;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (witem->anchor) {
|
||||
case GTK_ANCHOR_NW:
|
||||
case GTK_ANCHOR_N:
|
||||
case GTK_ANCHOR_NE:
|
||||
break;
|
||||
|
||||
case GTK_ANCHOR_W:
|
||||
case GTK_ANCHOR_CENTER:
|
||||
case GTK_ANCHOR_E:
|
||||
witem->cy -= witem->cheight / 2;
|
||||
break;
|
||||
|
||||
case GTK_ANCHOR_SW:
|
||||
case GTK_ANCHOR_S:
|
||||
case GTK_ANCHOR_SE:
|
||||
witem->cy -= witem->cheight;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Bounds */
|
||||
|
||||
item->x1 = witem->cx;
|
||||
item->y1 = witem->cy;
|
||||
item->x2 = witem->cx + witem->cwidth;
|
||||
item->y2 = witem->cy + witem->cheight;
|
||||
|
||||
if (witem->widget)
|
||||
gtk_layout_move (GTK_LAYOUT (item->canvas), witem->widget,
|
||||
witem->cx + item->canvas->zoom_xofs,
|
||||
witem->cy + item->canvas->zoom_yofs);
|
||||
}
|
||||
|
||||
static void
|
||||
do_destroy (GtkObject *object, gpointer data)
|
||||
{
|
||||
GnomeCanvasWidget *witem;
|
||||
|
||||
witem = data;
|
||||
|
||||
witem->in_destroy = TRUE;
|
||||
|
||||
gtk_object_destroy (data);
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_widget_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GnomeCanvasItem *item;
|
||||
GnomeCanvasWidget *witem;
|
||||
GObject *obj;
|
||||
int update;
|
||||
int calc_bounds;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_WIDGET (object));
|
||||
|
||||
item = GNOME_CANVAS_ITEM (object);
|
||||
witem = GNOME_CANVAS_WIDGET (object);
|
||||
|
||||
update = FALSE;
|
||||
calc_bounds = FALSE;
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_WIDGET:
|
||||
if (witem->widget) {
|
||||
g_signal_handler_disconnect (witem->widget, witem->destroy_id);
|
||||
gtk_container_remove (GTK_CONTAINER (item->canvas), witem->widget);
|
||||
}
|
||||
|
||||
obj = g_value_get_object (value);
|
||||
if (obj) {
|
||||
witem->widget = GTK_WIDGET (obj);
|
||||
witem->destroy_id = g_signal_connect (obj, "destroy",
|
||||
G_CALLBACK (do_destroy),
|
||||
witem);
|
||||
gtk_layout_put (GTK_LAYOUT (item->canvas), witem->widget,
|
||||
witem->cx + item->canvas->zoom_xofs,
|
||||
witem->cy + item->canvas->zoom_yofs);
|
||||
}
|
||||
|
||||
update = TRUE;
|
||||
break;
|
||||
|
||||
case PROP_X:
|
||||
if (witem->x != g_value_get_double (value))
|
||||
{
|
||||
witem->x = g_value_get_double (value);
|
||||
calc_bounds = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_Y:
|
||||
if (witem->y != g_value_get_double (value))
|
||||
{
|
||||
witem->y = g_value_get_double (value);
|
||||
calc_bounds = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_WIDTH:
|
||||
if (witem->width != fabs (g_value_get_double (value)))
|
||||
{
|
||||
witem->width = fabs (g_value_get_double (value));
|
||||
update = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_HEIGHT:
|
||||
if (witem->height != fabs (g_value_get_double (value)))
|
||||
{
|
||||
witem->height = fabs (g_value_get_double (value));
|
||||
update = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_ANCHOR:
|
||||
if (witem->anchor != g_value_get_enum (value))
|
||||
{
|
||||
witem->anchor = g_value_get_enum (value);
|
||||
update = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_SIZE_PIXELS:
|
||||
if (witem->size_pixels != g_value_get_boolean (value))
|
||||
{
|
||||
witem->size_pixels = g_value_get_boolean (value);
|
||||
update = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
|
||||
if (update)
|
||||
(* GNOME_CANVAS_ITEM_GET_CLASS (item)->update) (item, NULL, NULL, 0);
|
||||
|
||||
if (calc_bounds)
|
||||
recalc_bounds (witem);
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_widget_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GnomeCanvasWidget *witem;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNOME_IS_CANVAS_WIDGET (object));
|
||||
|
||||
witem = GNOME_CANVAS_WIDGET (object);
|
||||
|
||||
switch (param_id) {
|
||||
case PROP_WIDGET:
|
||||
g_value_set_object (value, (GObject *) witem->widget);
|
||||
break;
|
||||
|
||||
case PROP_X:
|
||||
g_value_set_double (value, witem->x);
|
||||
break;
|
||||
|
||||
case PROP_Y:
|
||||
g_value_set_double (value, witem->y);
|
||||
break;
|
||||
|
||||
case PROP_WIDTH:
|
||||
g_value_set_double (value, witem->width);
|
||||
break;
|
||||
|
||||
case PROP_HEIGHT:
|
||||
g_value_set_double (value, witem->height);
|
||||
break;
|
||||
|
||||
case PROP_ANCHOR:
|
||||
g_value_set_enum (value, witem->anchor);
|
||||
break;
|
||||
|
||||
case PROP_SIZE_PIXELS:
|
||||
g_value_set_boolean (value, witem->size_pixels);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_widget_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
|
||||
{
|
||||
GnomeCanvasWidget *witem;
|
||||
|
||||
witem = GNOME_CANVAS_WIDGET (item);
|
||||
|
||||
if (parent_class->update)
|
||||
(* parent_class->update) (item, affine, clip_path, flags);
|
||||
|
||||
if (witem->widget) {
|
||||
if (witem->size_pixels) {
|
||||
witem->cwidth = (int) (witem->width + 0.5);
|
||||
witem->cheight = (int) (witem->height + 0.5);
|
||||
} else {
|
||||
witem->cwidth = (int) (witem->width * item->canvas->pixels_per_unit + 0.5);
|
||||
witem->cheight = (int) (witem->height * item->canvas->pixels_per_unit + 0.5);
|
||||
}
|
||||
|
||||
gtk_widget_set_size_request (witem->widget, witem->cwidth, witem->cheight);
|
||||
} else {
|
||||
witem->cwidth = 0.0;
|
||||
witem->cheight = 0.0;
|
||||
}
|
||||
|
||||
recalc_bounds (witem);
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_widget_render (GnomeCanvasItem *item,
|
||||
GnomeCanvasBuf *buf)
|
||||
{
|
||||
#if 0
|
||||
GnomeCanvasWidget *witem;
|
||||
|
||||
witem = GNOME_CANVAS_WIDGET (item);
|
||||
|
||||
if (witem->widget)
|
||||
gtk_widget_queue_draw (witem->widget);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_widget_draw (GnomeCanvasItem *item,
|
||||
GdkDrawable *drawable,
|
||||
int x, int y,
|
||||
int width, int height)
|
||||
{
|
||||
#if 0
|
||||
GnomeCanvasWidget *witem;
|
||||
|
||||
witem = GNOME_CANVAS_WIDGET (item);
|
||||
|
||||
if (witem->widget)
|
||||
gtk_widget_queue_draw (witem->widget);
|
||||
#endif
|
||||
}
|
||||
|
||||
static double
|
||||
gnome_canvas_widget_point (GnomeCanvasItem *item, double x, double y,
|
||||
int cx, int cy, GnomeCanvasItem **actual_item)
|
||||
{
|
||||
GnomeCanvasWidget *witem;
|
||||
double x1, y1, x2, y2;
|
||||
double dx, dy;
|
||||
|
||||
witem = GNOME_CANVAS_WIDGET (item);
|
||||
|
||||
*actual_item = item;
|
||||
|
||||
gnome_canvas_c2w (item->canvas, witem->cx, witem->cy, &x1, &y1);
|
||||
|
||||
x2 = x1 + (witem->cwidth - 1) / item->canvas->pixels_per_unit;
|
||||
y2 = y1 + (witem->cheight - 1) / item->canvas->pixels_per_unit;
|
||||
|
||||
/* Is point inside widget bounds? */
|
||||
|
||||
if ((x >= x1) && (y >= y1) && (x <= x2) && (y <= y2))
|
||||
return 0.0;
|
||||
|
||||
/* Point is outside widget bounds */
|
||||
|
||||
if (x < x1)
|
||||
dx = x1 - x;
|
||||
else if (x > x2)
|
||||
dx = x - x2;
|
||||
else
|
||||
dx = 0.0;
|
||||
|
||||
if (y < y1)
|
||||
dy = y1 - y;
|
||||
else if (y > y2)
|
||||
dy = y - y2;
|
||||
else
|
||||
dy = 0.0;
|
||||
|
||||
return sqrt (dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
static void
|
||||
gnome_canvas_widget_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
|
||||
{
|
||||
GnomeCanvasWidget *witem;
|
||||
|
||||
witem = GNOME_CANVAS_WIDGET (item);
|
||||
|
||||
*x1 = witem->x;
|
||||
*y1 = witem->y;
|
||||
|
||||
switch (witem->anchor) {
|
||||
case GTK_ANCHOR_NW:
|
||||
case GTK_ANCHOR_W:
|
||||
case GTK_ANCHOR_SW:
|
||||
break;
|
||||
|
||||
case GTK_ANCHOR_N:
|
||||
case GTK_ANCHOR_CENTER:
|
||||
case GTK_ANCHOR_S:
|
||||
*x1 -= witem->width / 2.0;
|
||||
break;
|
||||
|
||||
case GTK_ANCHOR_NE:
|
||||
case GTK_ANCHOR_E:
|
||||
case GTK_ANCHOR_SE:
|
||||
*x1 -= witem->width;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (witem->anchor) {
|
||||
case GTK_ANCHOR_NW:
|
||||
case GTK_ANCHOR_N:
|
||||
case GTK_ANCHOR_NE:
|
||||
break;
|
||||
|
||||
case GTK_ANCHOR_W:
|
||||
case GTK_ANCHOR_CENTER:
|
||||
case GTK_ANCHOR_E:
|
||||
*y1 -= witem->height / 2.0;
|
||||
break;
|
||||
|
||||
case GTK_ANCHOR_SW:
|
||||
case GTK_ANCHOR_S:
|
||||
case GTK_ANCHOR_SE:
|
||||
*y1 -= witem->height;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
*x2 = *x1 + witem->width;
|
||||
*y2 = *y1 + witem->height;
|
||||
}
|
||||
103
libs/gnomecanvas/libgnomecanvas/gnome-canvas-widget.h
Normal file
103
libs/gnomecanvas/libgnomecanvas/gnome-canvas-widget.h
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* Widget item type for GnomeCanvas widget
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is
|
||||
* copyrighted by the Regents of the University of California, Sun Microsystems, and other parties.
|
||||
*
|
||||
*
|
||||
* Author: Federico Mena <federico@nuclecu.unam.mx>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_WIDGET_H
|
||||
#define GNOME_CANVAS_WIDGET_H
|
||||
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* Widget item for canvas. The widget is positioned with respect to an anchor point.
|
||||
* The following object arguments are available:
|
||||
*
|
||||
* name type read/write description
|
||||
* ------------------------------------------------------------------------------------------
|
||||
* widget GtkWidget* RW Pointer to the widget
|
||||
* x double RW X coordinate of anchor point
|
||||
* y double RW Y coordinate of anchor point
|
||||
* width double RW Width of widget (see below)
|
||||
* height double RW Height of widget (see below)
|
||||
* anchor GtkAnchorType RW Anchor side for widget
|
||||
* size_pixels boolean RW Specifies whether the widget size
|
||||
* is specified in pixels or canvas units.
|
||||
* If it is in pixels, then the widget will not
|
||||
* be scaled when the canvas zoom factor changes.
|
||||
* Otherwise, it will be scaled.
|
||||
*/
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS_WIDGET (gnome_canvas_widget_get_type ())
|
||||
#define GNOME_CANVAS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_WIDGET, GnomeCanvasWidget))
|
||||
#define GNOME_CANVAS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_WIDGET, GnomeCanvasWidgetClass))
|
||||
#define GNOME_IS_CANVAS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_WIDGET))
|
||||
#define GNOME_IS_CANVAS_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_WIDGET))
|
||||
#define GNOME_CANVAS_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_WIDGET, GnomeCanvasWidgetClass))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvasWidget GnomeCanvasWidget;
|
||||
typedef struct _GnomeCanvasWidgetClass GnomeCanvasWidgetClass;
|
||||
|
||||
struct _GnomeCanvasWidget {
|
||||
GnomeCanvasItem item;
|
||||
|
||||
GtkWidget *widget; /* The child widget */
|
||||
|
||||
double x, y; /* Position at anchor */
|
||||
double width, height; /* Dimensions of widget */
|
||||
GtkAnchorType anchor; /* Anchor side for widget */
|
||||
|
||||
int cx, cy; /* Top-left canvas coordinates for widget */
|
||||
int cwidth, cheight; /* Size of widget in pixels */
|
||||
|
||||
guint destroy_id; /* Signal connection id for destruction of child widget */
|
||||
|
||||
guint size_pixels : 1; /* Is size specified in (unchanging) pixels or units (get scaled)? */
|
||||
guint in_destroy : 1; /* Is child widget being destroyed? */
|
||||
};
|
||||
|
||||
struct _GnomeCanvasWidgetClass {
|
||||
GnomeCanvasItemClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
/* Standard Gtk function */
|
||||
GType gnome_canvas_widget_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
4109
libs/gnomecanvas/libgnomecanvas/gnome-canvas.c
Normal file
4109
libs/gnomecanvas/libgnomecanvas/gnome-canvas.c
Normal file
File diff suppressed because it is too large
Load diff
635
libs/gnomecanvas/libgnomecanvas/gnome-canvas.h
Normal file
635
libs/gnomecanvas/libgnomecanvas/gnome-canvas.h
Normal file
|
|
@ -0,0 +1,635 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */
|
||||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
/* GnomeCanvas widget - Tk-like canvas widget for Gnome
|
||||
*
|
||||
* GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas
|
||||
* widget. Tk is copyrighted by the Regents of the University of California,
|
||||
* Sun Microsystems, and other parties.
|
||||
*
|
||||
*
|
||||
* Authors: Federico Mena <federico@nuclecu.unam.mx>
|
||||
* Raph Levien <raph@gimp.org>
|
||||
*/
|
||||
|
||||
#ifndef GNOME_CANVAS_H
|
||||
#define GNOME_CANVAS_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdarg.h>
|
||||
#include <libart_lgpl/art_misc.h>
|
||||
#include <libart_lgpl/art_rect.h>
|
||||
#include <libart_lgpl/art_svp.h>
|
||||
#include <libart_lgpl/art_uta.h>
|
||||
#include <libart_lgpl/art_affine.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* "Small" value used by canvas stuff */
|
||||
#define GNOME_CANVAS_EPSILON 1e-10
|
||||
|
||||
|
||||
/* Macros for building colors that fit in a 32-bit integer. The values are in
|
||||
* [0, 255].
|
||||
*/
|
||||
|
||||
#define GNOME_CANVAS_COLOR(r, g, b) ((((unsigned int) (r) & 0xff) << 24) \
|
||||
| (((unsigned int) (g) & 0xff) << 16) \
|
||||
| (((unsigned int) (b) & 0xff) << 8) \
|
||||
| 0xff)
|
||||
|
||||
#define GNOME_CANVAS_COLOR_A(r, g, b, a) ((((unsigned int) (r) & 0xff) << 24) \
|
||||
| (((unsigned int) (g) & 0xff) << 16) \
|
||||
| (((unsigned int) (b) & 0xff) << 8) \
|
||||
| ((unsigned int) (a) & 0xff))
|
||||
|
||||
|
||||
typedef struct _GnomeCanvas GnomeCanvas;
|
||||
typedef struct _GnomeCanvasClass GnomeCanvasClass;
|
||||
typedef struct _GnomeCanvasItem GnomeCanvasItem;
|
||||
typedef struct _GnomeCanvasItemClass GnomeCanvasItemClass;
|
||||
typedef struct _GnomeCanvasGroup GnomeCanvasGroup;
|
||||
typedef struct _GnomeCanvasGroupClass GnomeCanvasGroupClass;
|
||||
|
||||
|
||||
/* GnomeCanvasItem - base item class for canvas items
|
||||
*
|
||||
* All canvas items are derived from GnomeCanvasItem. The only information a
|
||||
* GnomeCanvasItem contains is its parent canvas, its parent canvas item group,
|
||||
* its bounding box in world coordinates, and its current affine transformation.
|
||||
*
|
||||
* Items inside a canvas are organized in a tree of GnomeCanvasItemGroup nodes
|
||||
* and GnomeCanvasItem leaves. Each canvas has a single root group, which can
|
||||
* be obtained with the gnome_canvas_get_root() function.
|
||||
*
|
||||
* The abstract GnomeCanvasItem class does not have any configurable or
|
||||
* queryable attributes.
|
||||
*/
|
||||
|
||||
/* Object flags for items */
|
||||
enum {
|
||||
GNOME_CANVAS_ITEM_REALIZED = 1 << 4,
|
||||
GNOME_CANVAS_ITEM_MAPPED = 1 << 5,
|
||||
GNOME_CANVAS_ITEM_ALWAYS_REDRAW = 1 << 6,
|
||||
GNOME_CANVAS_ITEM_VISIBLE = 1 << 7,
|
||||
GNOME_CANVAS_ITEM_NEED_UPDATE = 1 << 8,
|
||||
GNOME_CANVAS_ITEM_NEED_AFFINE = 1 << 9,
|
||||
GNOME_CANVAS_ITEM_NEED_CLIP = 1 << 10,
|
||||
GNOME_CANVAS_ITEM_NEED_VIS = 1 << 11,
|
||||
GNOME_CANVAS_ITEM_AFFINE_FULL = 1 << 12
|
||||
};
|
||||
|
||||
/* Update flags for items */
|
||||
enum {
|
||||
GNOME_CANVAS_UPDATE_REQUESTED = 1 << 0,
|
||||
GNOME_CANVAS_UPDATE_AFFINE = 1 << 1,
|
||||
GNOME_CANVAS_UPDATE_CLIP = 1 << 2,
|
||||
GNOME_CANVAS_UPDATE_VISIBILITY = 1 << 3,
|
||||
GNOME_CANVAS_UPDATE_IS_VISIBLE = 1 << 4 /* Deprecated. FIXME: remove this */
|
||||
};
|
||||
|
||||
/* Data for rendering in antialiased mode */
|
||||
typedef struct {
|
||||
/* 24-bit RGB buffer for rendering */
|
||||
guchar *buf;
|
||||
|
||||
/* Rectangle describing the rendering area */
|
||||
ArtIRect rect;
|
||||
|
||||
/* Rowstride for the buffer */
|
||||
int buf_rowstride;
|
||||
|
||||
/* Background color, given as 0xrrggbb */
|
||||
guint32 bg_color;
|
||||
|
||||
/* Invariant: at least one of the following flags is true. */
|
||||
|
||||
/* Set when the render rectangle area is the solid color bg_color */
|
||||
unsigned int is_bg : 1;
|
||||
|
||||
/* Set when the render rectangle area is represented by the buf */
|
||||
unsigned int is_buf : 1;
|
||||
} GnomeCanvasBuf;
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS_ITEM (gnome_canvas_item_get_type ())
|
||||
#define GNOME_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_ITEM, GnomeCanvasItem))
|
||||
#define GNOME_CANVAS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_ITEM, GnomeCanvasItemClass))
|
||||
#define GNOME_IS_CANVAS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_ITEM))
|
||||
#define GNOME_IS_CANVAS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_ITEM))
|
||||
#define GNOME_CANVAS_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_ITEM, GnomeCanvasItemClass))
|
||||
|
||||
|
||||
struct _GnomeCanvasItem {
|
||||
GtkObject object;
|
||||
|
||||
/* Parent canvas for this item */
|
||||
GnomeCanvas *canvas;
|
||||
|
||||
/* Parent canvas group for this item (a GnomeCanvasGroup) */
|
||||
GnomeCanvasItem *parent;
|
||||
|
||||
/* If NULL, assumed to be the identity tranform. If flags does not have
|
||||
* AFFINE_FULL, then a two-element array containing a translation. If
|
||||
* flags contains AFFINE_FULL, a six-element array containing an affine
|
||||
* transformation.
|
||||
*/
|
||||
double *xform;
|
||||
|
||||
/* Bounding box for this item (in canvas coordinates) */
|
||||
double x1, y1, x2, y2;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasItemClass {
|
||||
GtkObjectClass parent_class;
|
||||
|
||||
/* Tell the item to update itself. The flags are from the update flags
|
||||
* defined above. The item should update its internal state from its
|
||||
* queued state, and recompute and request its repaint area. The
|
||||
* affine, if used, is a pointer to a 6-element array of doubles. The
|
||||
* update method also recomputes the bounding box of the item.
|
||||
*/
|
||||
void (* update) (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags);
|
||||
|
||||
/* Realize an item -- create GCs, etc. */
|
||||
void (* realize) (GnomeCanvasItem *item);
|
||||
|
||||
/* Unrealize an item */
|
||||
void (* unrealize) (GnomeCanvasItem *item);
|
||||
|
||||
/* Map an item - normally only need by items with their own GdkWindows */
|
||||
void (* map) (GnomeCanvasItem *item);
|
||||
|
||||
/* Unmap an item */
|
||||
void (* unmap) (GnomeCanvasItem *item);
|
||||
|
||||
/* Return the microtile coverage of the item */
|
||||
ArtUta *(* coverage) (GnomeCanvasItem *item);
|
||||
|
||||
/* Draw an item of this type. (x, y) are the upper-left canvas pixel
|
||||
* coordinates of the drawable, a temporary pixmap, where things get
|
||||
* drawn. (width, height) are the dimensions of the drawable.
|
||||
*/
|
||||
void (* draw) (GnomeCanvasItem *item, GdkDrawable *drawable,
|
||||
int x, int y, int width, int height);
|
||||
|
||||
/* Render the item over the buffer given. The buf data structure
|
||||
* contains both a pointer to a packed 24-bit RGB array, and the
|
||||
* coordinates. This method is only used for antialiased canvases.
|
||||
*
|
||||
* TODO: figure out where clip paths fit into the rendering framework.
|
||||
*/
|
||||
void (* render) (GnomeCanvasItem *item, GnomeCanvasBuf *buf);
|
||||
|
||||
/* Calculate the distance from an item to the specified point. It also
|
||||
* returns a canvas item which is the item itself in the case of the
|
||||
* object being an actual leaf item, or a child in case of the object
|
||||
* being a canvas group. (cx, cy) are the canvas pixel coordinates that
|
||||
* correspond to the item-relative coordinates (x, y).
|
||||
*/
|
||||
double (* point) (GnomeCanvasItem *item, double x, double y, int cx, int cy,
|
||||
GnomeCanvasItem **actual_item);
|
||||
|
||||
/* Fetch the item's bounding box (need not be exactly tight). This
|
||||
* should be in item-relative coordinates.
|
||||
*/
|
||||
void (* bounds) (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2);
|
||||
|
||||
/* Signal: an event occurred for an item of this type. The (x, y)
|
||||
* coordinates are in the canvas world coordinate system.
|
||||
*/
|
||||
gboolean (* event) (GnomeCanvasItem *item, GdkEvent *event);
|
||||
|
||||
/* Reserved for future expansion */
|
||||
gpointer spare_vmethods [4];
|
||||
};
|
||||
|
||||
|
||||
GType gnome_canvas_item_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* Create a canvas item using the standard Gtk argument mechanism. The item is
|
||||
* automatically inserted at the top of the specified canvas group. The last
|
||||
* argument must be a NULL pointer.
|
||||
*/
|
||||
GnomeCanvasItem *gnome_canvas_item_new (GnomeCanvasGroup *parent, GType type,
|
||||
const gchar *first_arg_name, ...);
|
||||
|
||||
/* Constructors for use in derived classes and language wrappers */
|
||||
void gnome_canvas_item_construct (GnomeCanvasItem *item, GnomeCanvasGroup *parent,
|
||||
const gchar *first_arg_name, va_list args);
|
||||
|
||||
/* Configure an item using the standard Gtk argument mechanism. The last
|
||||
* argument must be a NULL pointer.
|
||||
*/
|
||||
void gnome_canvas_item_set (GnomeCanvasItem *item, const gchar *first_arg_name, ...);
|
||||
|
||||
/* Used only for language wrappers and the like */
|
||||
void gnome_canvas_item_set_valist (GnomeCanvasItem *item,
|
||||
const gchar *first_arg_name, va_list args);
|
||||
|
||||
/* Move an item by the specified amount */
|
||||
void gnome_canvas_item_move (GnomeCanvasItem *item, double dx, double dy);
|
||||
|
||||
/* Apply a relative affine transformation to the item. */
|
||||
void gnome_canvas_item_affine_relative (GnomeCanvasItem *item, const double affine[6]);
|
||||
|
||||
/* Apply an absolute affine transformation to the item. */
|
||||
void gnome_canvas_item_affine_absolute (GnomeCanvasItem *item, const double affine[6]);
|
||||
|
||||
/* Raise an item in the z-order of its parent group by the specified number of
|
||||
* positions.
|
||||
*/
|
||||
void gnome_canvas_item_raise (GnomeCanvasItem *item, int positions);
|
||||
|
||||
/* Lower an item in the z-order of its parent group by the specified number of
|
||||
* positions.
|
||||
*/
|
||||
void gnome_canvas_item_lower (GnomeCanvasItem *item, int positions);
|
||||
|
||||
/* Raise an item to the top of its parent group's z-order. */
|
||||
void gnome_canvas_item_raise_to_top (GnomeCanvasItem *item);
|
||||
|
||||
/* Lower an item to the bottom of its parent group's z-order */
|
||||
void gnome_canvas_item_lower_to_bottom (GnomeCanvasItem *item);
|
||||
|
||||
/* Show an item (make it visible). If the item is already shown, it has no
|
||||
* effect.
|
||||
*/
|
||||
void gnome_canvas_item_show (GnomeCanvasItem *item);
|
||||
|
||||
/* Hide an item (make it invisible). If the item is already invisible, it has
|
||||
* no effect.
|
||||
*/
|
||||
void gnome_canvas_item_hide (GnomeCanvasItem *item);
|
||||
|
||||
/* Grab the mouse for the specified item. Only the events in event_mask will be
|
||||
* reported. If cursor is non-NULL, it will be used during the duration of the
|
||||
* grab. Time is a proper X event time parameter. Returns the same values as
|
||||
* XGrabPointer().
|
||||
*/
|
||||
int gnome_canvas_item_grab (GnomeCanvasItem *item, unsigned int event_mask,
|
||||
GdkCursor *cursor, guint32 etime);
|
||||
|
||||
/* Ungrabs the mouse -- the specified item must be the same that was passed to
|
||||
* gnome_canvas_item_grab(). Time is a proper X event time parameter.
|
||||
*/
|
||||
void gnome_canvas_item_ungrab (GnomeCanvasItem *item, guint32 etime);
|
||||
|
||||
/* These functions convert from a coordinate system to another. "w" is world
|
||||
* coordinates and "i" is item coordinates.
|
||||
*/
|
||||
void gnome_canvas_item_w2i (GnomeCanvasItem *item, double *x, double *y);
|
||||
void gnome_canvas_item_i2w (GnomeCanvasItem *item, double *x, double *y);
|
||||
|
||||
/* Gets the affine transform that converts from item-relative coordinates to
|
||||
* world coordinates.
|
||||
*/
|
||||
void gnome_canvas_item_i2w_affine (GnomeCanvasItem *item, double affine[6]);
|
||||
|
||||
/* Gets the affine transform that converts from item-relative coordinates to
|
||||
* canvas pixel coordinates.
|
||||
*/
|
||||
void gnome_canvas_item_i2c_affine (GnomeCanvasItem *item, double affine[6]);
|
||||
|
||||
/* Remove the item from its parent group and make the new group its parent. The
|
||||
* item will be put on top of all the items in the new group. The item's
|
||||
* coordinates relative to its new parent to *not* change -- this means that the
|
||||
* item could potentially move on the screen.
|
||||
*
|
||||
* The item and the group must be in the same canvas. An item cannot be
|
||||
* reparented to a group that is the item itself or that is an inferior of the
|
||||
* item.
|
||||
*/
|
||||
void gnome_canvas_item_reparent (GnomeCanvasItem *item, GnomeCanvasGroup *new_group);
|
||||
|
||||
/* Used to send all of the keystroke events to a specific item as well as
|
||||
* GDK_FOCUS_CHANGE events.
|
||||
*/
|
||||
void gnome_canvas_item_grab_focus (GnomeCanvasItem *item);
|
||||
|
||||
/* Fetch the bounding box of the item. The bounding box may not be exactly
|
||||
* tight, but the canvas items will do the best they can. The returned bounding
|
||||
* box is in the coordinate system of the item's parent.
|
||||
*/
|
||||
void gnome_canvas_item_get_bounds (GnomeCanvasItem *item,
|
||||
double *x1, double *y1, double *x2, double *y2);
|
||||
|
||||
/* Request that the update method eventually get called. This should be used
|
||||
* only by item implementations.
|
||||
*/
|
||||
void gnome_canvas_item_request_update (GnomeCanvasItem *item);
|
||||
|
||||
|
||||
/* GnomeCanvasGroup - a group of canvas items
|
||||
*
|
||||
* A group is a node in the hierarchical tree of groups/items inside a canvas.
|
||||
* Groups serve to give a logical structure to the items.
|
||||
*
|
||||
* Consider a circuit editor application that uses the canvas for its schematic
|
||||
* display. Hierarchically, there would be canvas groups that contain all the
|
||||
* components needed for an "adder", for example -- this includes some logic
|
||||
* gates as well as wires. You can move stuff around in a convenient way by
|
||||
* doing a gnome_canvas_item_move() of the hierarchical groups -- to move an
|
||||
* adder, simply move the group that represents the adder.
|
||||
*
|
||||
* The following arguments are available:
|
||||
*
|
||||
* name type read/write description
|
||||
* --------------------------------------------------------------------------------
|
||||
* x double RW X coordinate of group's origin
|
||||
* y double RW Y coordinate of group's origin
|
||||
*/
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS_GROUP (gnome_canvas_group_get_type ())
|
||||
#define GNOME_CANVAS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS_GROUP, GnomeCanvasGroup))
|
||||
#define GNOME_CANVAS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_GROUP, GnomeCanvasGroupClass))
|
||||
#define GNOME_IS_CANVAS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS_GROUP))
|
||||
#define GNOME_IS_CANVAS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_GROUP))
|
||||
#define GNOME_CANVAS_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS_GROUP, GnomeCanvasGroupClass))
|
||||
|
||||
|
||||
struct _GnomeCanvasGroup {
|
||||
GnomeCanvasItem item;
|
||||
|
||||
/* Children of the group */
|
||||
GList *item_list;
|
||||
GList *item_list_end;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasGroupClass {
|
||||
GnomeCanvasItemClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gnome_canvas_group_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
/*** GnomeCanvas ***/
|
||||
|
||||
|
||||
#define GNOME_TYPE_CANVAS (gnome_canvas_get_type ())
|
||||
#define GNOME_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_CANVAS, GnomeCanvas))
|
||||
#define GNOME_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS, GnomeCanvasClass))
|
||||
#define GNOME_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_CANVAS))
|
||||
#define GNOME_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS))
|
||||
#define GNOME_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_CANVAS, GnomeCanvasClass))
|
||||
|
||||
|
||||
struct _GnomeCanvas {
|
||||
GtkLayout layout;
|
||||
|
||||
/* Root canvas group */
|
||||
GnomeCanvasItem *root;
|
||||
|
||||
/* Area that needs redrawing, stored as a microtile array */
|
||||
ArtUta *redraw_area;
|
||||
|
||||
/* The item containing the mouse pointer, or NULL if none */
|
||||
GnomeCanvasItem *current_item;
|
||||
|
||||
/* Item that is about to become current (used to track deletions and such) */
|
||||
GnomeCanvasItem *new_current_item;
|
||||
|
||||
/* Item that holds a pointer grab, or NULL if none */
|
||||
GnomeCanvasItem *grabbed_item;
|
||||
|
||||
/* If non-NULL, the currently focused item */
|
||||
GnomeCanvasItem *focused_item;
|
||||
|
||||
/* GC for temporary draw pixmap */
|
||||
GdkGC *pixmap_gc;
|
||||
|
||||
/* Event on which selection of current item is based */
|
||||
GdkEvent pick_event;
|
||||
|
||||
/* Scrolling region */
|
||||
double scroll_x1, scroll_y1;
|
||||
double scroll_x2, scroll_y2;
|
||||
|
||||
/* Scaling factor to be used for display */
|
||||
double pixels_per_unit;
|
||||
|
||||
/* Idle handler ID */
|
||||
guint idle_id;
|
||||
|
||||
/* Signal handler ID for destruction of the root item */
|
||||
guint root_destroy_id;
|
||||
|
||||
/* Area that is being redrawn. Contains (x1, y1) but not (x2, y2).
|
||||
* Specified in canvas pixel coordinates.
|
||||
*/
|
||||
int redraw_x1, redraw_y1;
|
||||
int redraw_x2, redraw_y2;
|
||||
|
||||
/* Offsets of the temprary drawing pixmap */
|
||||
int draw_xofs, draw_yofs;
|
||||
|
||||
/* Internal pixel offsets when zoomed out */
|
||||
int zoom_xofs, zoom_yofs;
|
||||
|
||||
/* Last known modifier state, for deferred repick when a button is down */
|
||||
int state;
|
||||
|
||||
/* Event mask specified when grabbing an item */
|
||||
guint grabbed_event_mask;
|
||||
|
||||
/* Tolerance distance for picking items */
|
||||
int close_enough;
|
||||
|
||||
/* Whether the canvas should center the scroll region in the middle of
|
||||
* the window if the scroll region is smaller than the window.
|
||||
*/
|
||||
unsigned int center_scroll_region : 1;
|
||||
|
||||
/* Whether items need update at next idle loop iteration */
|
||||
unsigned int need_update : 1;
|
||||
|
||||
/* Whether the canvas needs redrawing at the next idle loop iteration */
|
||||
unsigned int need_redraw : 1;
|
||||
|
||||
/* Whether current item will be repicked at next idle loop iteration */
|
||||
unsigned int need_repick : 1;
|
||||
|
||||
/* For use by internal pick_current_item() function */
|
||||
unsigned int left_grabbed_item : 1;
|
||||
|
||||
/* For use by internal pick_current_item() function */
|
||||
unsigned int in_repick : 1;
|
||||
|
||||
/* Whether the canvas is in antialiased mode or not */
|
||||
unsigned int aa : 1;
|
||||
|
||||
/* Which dither mode to use for antialiased mode drawing */
|
||||
GdkRgbDither dither;
|
||||
};
|
||||
|
||||
struct _GnomeCanvasClass {
|
||||
GtkLayoutClass parent_class;
|
||||
|
||||
/* Draw the background for the area given. This method is only used
|
||||
* for non-antialiased canvases.
|
||||
*/
|
||||
void (* draw_background) (GnomeCanvas *canvas, GdkDrawable *drawable,
|
||||
int x, int y, int width, int height);
|
||||
|
||||
/* Render the background for the buffer given. The buf data structure
|
||||
* contains both a pointer to a packed 24-bit RGB array, and the
|
||||
* coordinates. This method is only used for antialiased canvases.
|
||||
*/
|
||||
void (* render_background) (GnomeCanvas *canvas, GnomeCanvasBuf *buf);
|
||||
|
||||
/* Private Virtual methods for groping the canvas inside bonobo */
|
||||
void (* request_update) (GnomeCanvas *canvas);
|
||||
|
||||
/* Reserved for future expansion */
|
||||
gpointer spare_vmethods [4];
|
||||
};
|
||||
|
||||
|
||||
GType gnome_canvas_get_type (void) G_GNUC_CONST;
|
||||
|
||||
/* Creates a new canvas. You should check that the canvas is created with the
|
||||
* proper visual and colormap. Any visual will do unless you intend to insert
|
||||
* gdk_imlib images into it, in which case you should use the gdk_imlib visual.
|
||||
*
|
||||
* You should call gnome_canvas_set_scroll_region() soon after calling this
|
||||
* function to set the desired scrolling limits for the canvas.
|
||||
*/
|
||||
GtkWidget *gnome_canvas_new (void);
|
||||
|
||||
/* Creates a new antialiased empty canvas. You should push the GdkRgb colormap
|
||||
* and visual for this.
|
||||
*/
|
||||
#ifndef GNOME_EXCLUDE_EXPERIMENTAL
|
||||
GtkWidget *gnome_canvas_new_aa (void);
|
||||
#endif
|
||||
|
||||
/* Returns the root canvas item group of the canvas */
|
||||
GnomeCanvasGroup *gnome_canvas_root (GnomeCanvas *canvas);
|
||||
|
||||
/* Sets the limits of the scrolling region, in world coordinates */
|
||||
void gnome_canvas_set_scroll_region (GnomeCanvas *canvas,
|
||||
double x1, double y1, double x2, double y2);
|
||||
|
||||
/* Gets the limits of the scrolling region, in world coordinates */
|
||||
void gnome_canvas_get_scroll_region (GnomeCanvas *canvas,
|
||||
double *x1, double *y1, double *x2, double *y2);
|
||||
|
||||
/* Whether the canvas centers the scroll region if it is smaller than the window */
|
||||
void gnome_canvas_set_center_scroll_region (GnomeCanvas *canvas, gboolean center_scroll_region);
|
||||
|
||||
/* Returns whether the canvas is set to center the scroll region if it is smaller than the window */
|
||||
gboolean gnome_canvas_get_center_scroll_region (GnomeCanvas *canvas);
|
||||
|
||||
/* Sets the number of pixels that correspond to one unit in world coordinates */
|
||||
void gnome_canvas_set_pixels_per_unit (GnomeCanvas *canvas, double n);
|
||||
|
||||
/* Scrolls the canvas to the specified offsets, given in canvas pixel coordinates */
|
||||
void gnome_canvas_scroll_to (GnomeCanvas *canvas, int cx, int cy);
|
||||
|
||||
/* Returns the scroll offsets of the canvas in canvas pixel coordinates. You
|
||||
* can specify NULL for any of the values, in which case that value will not be
|
||||
* queried.
|
||||
*/
|
||||
void gnome_canvas_get_scroll_offsets (GnomeCanvas *canvas, int *cx, int *cy);
|
||||
|
||||
/* Requests that the canvas be repainted immediately instead of in the idle
|
||||
* loop.
|
||||
*/
|
||||
void gnome_canvas_update_now (GnomeCanvas *canvas);
|
||||
|
||||
/* Returns the item that is at the specified position in world coordinates, or
|
||||
* NULL if no item is there.
|
||||
*/
|
||||
GnomeCanvasItem *gnome_canvas_get_item_at (GnomeCanvas *canvas, double x, double y);
|
||||
|
||||
/* For use only by item type implementations. Request that the canvas eventually
|
||||
* redraw the specified region. The region is specified as a microtile
|
||||
* array. This function takes over responsibility for freeing the uta argument.
|
||||
*/
|
||||
void gnome_canvas_request_redraw_uta (GnomeCanvas *canvas, ArtUta *uta);
|
||||
|
||||
/* For use only by item type implementations. Request that the canvas
|
||||
* eventually redraw the specified region, specified in canvas pixel
|
||||
* coordinates. The region contains (x1, y1) but not (x2, y2).
|
||||
*/
|
||||
void gnome_canvas_request_redraw (GnomeCanvas *canvas, int x1, int y1, int x2, int y2);
|
||||
|
||||
/* Gets the affine transform that converts world coordinates into canvas pixel
|
||||
* coordinates.
|
||||
*/
|
||||
void gnome_canvas_w2c_affine (GnomeCanvas *canvas, double affine[6]);
|
||||
|
||||
/* These functions convert from a coordinate system to another. "w" is world
|
||||
* coordinates, "c" is canvas pixel coordinates (pixel coordinates that are
|
||||
* (0,0) for the upper-left scrolling limit and something else for the
|
||||
* lower-left scrolling limit).
|
||||
*/
|
||||
void gnome_canvas_w2c (GnomeCanvas *canvas, double wx, double wy, int *cx, int *cy);
|
||||
void gnome_canvas_w2c_d (GnomeCanvas *canvas, double wx, double wy, double *cx, double *cy);
|
||||
void gnome_canvas_c2w (GnomeCanvas *canvas, int cx, int cy, double *wx, double *wy);
|
||||
|
||||
/* This function takes in coordinates relative to the GTK_LAYOUT
|
||||
* (canvas)->bin_window and converts them to world coordinates.
|
||||
*/
|
||||
void gnome_canvas_window_to_world (GnomeCanvas *canvas,
|
||||
double winx, double winy, double *worldx, double *worldy);
|
||||
|
||||
/* This is the inverse of gnome_canvas_window_to_world() */
|
||||
void gnome_canvas_world_to_window (GnomeCanvas *canvas,
|
||||
double worldx, double worldy, double *winx, double *winy);
|
||||
|
||||
/* Takes a string specification for a color and allocates it into the specified
|
||||
* GdkColor. If the string is null, then it returns FALSE. Otherwise, it
|
||||
* returns TRUE.
|
||||
*/
|
||||
int gnome_canvas_get_color (GnomeCanvas *canvas, const char *spec, GdkColor *color);
|
||||
|
||||
/* Allocates a color from the RGB value passed into this function. */
|
||||
gulong gnome_canvas_get_color_pixel (GnomeCanvas *canvas,
|
||||
guint rgba);
|
||||
|
||||
|
||||
/* Sets the stipple origin of the specified gc so that it will be aligned with
|
||||
* all the stipples used in the specified canvas. This is intended for use only
|
||||
* by canvas item implementations.
|
||||
*/
|
||||
void gnome_canvas_set_stipple_origin (GnomeCanvas *canvas, GdkGC *gc);
|
||||
|
||||
/* Controls the dithering used when the canvas renders.
|
||||
* Only applicable to antialiased canvases - ignored by non-antialiased canvases.
|
||||
*/
|
||||
void gnome_canvas_set_dither (GnomeCanvas *canvas, GdkRgbDither dither);
|
||||
|
||||
/* Returns the dither mode of an antialiased canvas.
|
||||
* Only applicable to antialiased canvases - ignored by non-antialiased canvases.
|
||||
*/
|
||||
GdkRgbDither gnome_canvas_get_dither (GnomeCanvas *canvas);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
||||
48
libs/gnomecanvas/libgnomecanvas/libgnomecanvas.h
Normal file
48
libs/gnomecanvas/libgnomecanvas/libgnomecanvas.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
|
||||
#ifndef LIBGNOMECANVAS_H
|
||||
#define LIBGNOMECANVAS_H
|
||||
|
||||
#include <libgnomecanvas/gnome-canvas.h>
|
||||
#include <libgnomecanvas/gnome-canvas-line.h>
|
||||
#include <libgnomecanvas/gnome-canvas-text.h>
|
||||
#include <libgnomecanvas/gnome-canvas-rich-text.h>
|
||||
#include <libgnomecanvas/gnome-canvas-polygon.h>
|
||||
#include <libgnomecanvas/gnome-canvas-pixbuf.h>
|
||||
#include <libgnomecanvas/gnome-canvas-widget.h>
|
||||
#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
|
||||
#include <libgnomecanvas/gnome-canvas-bpath.h>
|
||||
#include <libgnomecanvas/gnome-canvas-util.h>
|
||||
#include <libgnomecanvas/gnome-canvas-clipgroup.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GType gnome_canvas_points_get_type (void);
|
||||
#define GNOME_TYPE_CANVAS_POINTS gnome_canvas_points_get_type()
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* LIBGNOMECANVAS_H */
|
||||
43
libs/gnomecanvas/libgnomecanvas/libgnomecanvastypes.c
Normal file
43
libs/gnomecanvas/libgnomecanvas/libgnomecanvastypes.c
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (C) 1999, 2000 Red Hat, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This file is part of the Gnome Library.
|
||||
*
|
||||
* The Gnome Library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* The Gnome Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with the Gnome Library; see the file COPYING.LIB. If not,
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
/*
|
||||
@NOTATION@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include <libgnomecanvas/libgnomecanvas.h>
|
||||
|
||||
GType
|
||||
gnome_canvas_points_get_type (void)
|
||||
{
|
||||
static GType type_canvas_points = 0;
|
||||
|
||||
if (!type_canvas_points)
|
||||
type_canvas_points = g_boxed_type_register_static
|
||||
("GnomeCanvasPoints",
|
||||
(GBoxedCopyFunc) gnome_canvas_points_ref,
|
||||
(GBoxedFreeFunc) gnome_canvas_points_unref);
|
||||
|
||||
return type_canvas_points;
|
||||
}
|
||||
66
libs/gnomecanvas/wscript
Normal file
66
libs/gnomecanvas/wscript
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env python
|
||||
import autowaf
|
||||
import os
|
||||
|
||||
# Version of this package (even if built as a child)
|
||||
MAJOR = '2'
|
||||
MINOR = '30'
|
||||
MICRO = '1'
|
||||
LIBGNOMECANVAS_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
|
||||
|
||||
# Library version (UNIX style major, minor, micro)
|
||||
# major increment <=> incompatible changes
|
||||
# minor increment <=> compatible changes (additions)
|
||||
# micro increment <=> no interface changes
|
||||
LIBGNOMECANVAS_LIB_VERSION = '0.0.0'
|
||||
|
||||
# Variables for 'waf dist'
|
||||
APPNAME = 'libgnomecanvas'
|
||||
VERSION = LIBGNOMECANVAS_VERSION
|
||||
|
||||
# Mandatory variables
|
||||
srcdir = '.'
|
||||
blddir = 'build'
|
||||
|
||||
path_prefix = 'libs/gnomecanvas/'
|
||||
|
||||
libgnomecanvas_sources = [
|
||||
'libgnomecanvas/gnome-canvas-bpath.c',
|
||||
'libgnomecanvas/gnome-canvas.c',
|
||||
'libgnomecanvas/gnome-canvas-clipgroup.c',
|
||||
'libgnomecanvas/gnome-canvas-line.c',
|
||||
'libgnomecanvas/gnome-canvas-path-def.c',
|
||||
'libgnomecanvas/gnome-canvas-pixbuf.c',
|
||||
'libgnomecanvas/gnome-canvas-polygon.c',
|
||||
'libgnomecanvas/gnome-canvas-rect-ellipse.c',
|
||||
'libgnomecanvas/gnome-canvas-rich-text.c',
|
||||
'libgnomecanvas/gnome-canvas-shape.c',
|
||||
'libgnomecanvas/gnome-canvas-text.c',
|
||||
'libgnomecanvas/gnome-canvas-util.c',
|
||||
'libgnomecanvas/gnome-canvas-widget.c',
|
||||
'libgnomecanvas/libgnomecanvastypes.c'
|
||||
]
|
||||
|
||||
def set_options(opt):
|
||||
autowaf.set_options(opt)
|
||||
|
||||
def configure(conf):
|
||||
autowaf.configure(conf)
|
||||
conf.check_tool('compiler_cc')
|
||||
autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK', atleast_version='2.18')
|
||||
autowaf.check_pkg(conf, 'libart-2.0', uselib_store='LIBART', atleast_version='2.3')
|
||||
|
||||
def build(bld):
|
||||
# Library
|
||||
obj = bld.new_task_gen('cc', 'shlib')
|
||||
obj.source = libgnomecanvas_sources
|
||||
obj.includes = ['.']
|
||||
obj.name = 'libgnomecanvas-2'
|
||||
obj.target = 'gnomecanvas-2'
|
||||
obj.uselib = 'GLIB GTK LIBART'
|
||||
obj.vnum = LIBGNOMECANVAS_LIB_VERSION
|
||||
obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
|
||||
|
||||
def shutdown():
|
||||
autowaf.shutdown()
|
||||
|
||||
1
wscript
1
wscript
|
|
@ -29,6 +29,7 @@ children = [
|
|||
'libs/gtkmm2ext',
|
||||
'libs/clearlooks-newer',
|
||||
'libs/audiographer',
|
||||
'libs/gnomecanvas',
|
||||
'gtk2_ardour'
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue