summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-01-11 19:44:32 +0000
committerDavid Robillard <d@drobilla.net>2014-01-11 19:44:32 +0000
commitefa3c517693b8eae29082c1a57fb7677bdc548e4 (patch)
treeb6d7e6c20a0184de29398e8996063be1ffab5c2b
parentd1b3daf3a187794d7a6b452080d317046a014a15 (diff)
downloadganv-efa3c517693b8eae29082c1a57fb7677bdc548e4.tar.gz
ganv-efa3c517693b8eae29082c1a57fb7677bdc548e4.tar.bz2
ganv-efa3c517693b8eae29082c1a57fb7677bdc548e4.zip
Separate item.h.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5299 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ganv/Edge.hpp1
-rw-r--r--ganv/Item.hpp4
-rw-r--r--ganv/Node.hpp1
-rw-r--r--ganv/Port.hpp1
-rw-r--r--ganv/canvas-base.h194
-rw-r--r--ganv/edge.h2
-rw-r--r--ganv/group.h2
-rw-r--r--ganv/item.h210
-rw-r--r--ganv/node.h2
-rw-r--r--ganv/text.h2
-rw-r--r--ganv/widget.h2
11 files changed, 219 insertions, 202 deletions
diff --git a/ganv/Edge.hpp b/ganv/Edge.hpp
index aa8e7d1..e220d95 100644
--- a/ganv/Edge.hpp
+++ b/ganv/Edge.hpp
@@ -20,7 +20,6 @@
#include <gdk/gdkevents.h>
-#include "ganv/canvas-base.h"
#include "ganv/Canvas.hpp"
#include "ganv/Item.hpp"
#include "ganv/Node.hpp"
diff --git a/ganv/Item.hpp b/ganv/Item.hpp
index e404369..2ba4de0 100644
--- a/ganv/Item.hpp
+++ b/ganv/Item.hpp
@@ -23,9 +23,9 @@
#include <sigc++/signal.h>
#include <sigc++/trackable.h>
-#include "ganv/canvas-base.h"
-#include "ganv/wrap.hpp"
#include "ganv/Canvas.hpp"
+#include "ganv/item.h"
+#include "ganv/wrap.hpp"
namespace Ganv {
diff --git a/ganv/Node.hpp b/ganv/Node.hpp
index af5e691..9a3e56b 100644
--- a/ganv/Node.hpp
+++ b/ganv/Node.hpp
@@ -19,7 +19,6 @@
#include <glib.h>
#include <assert.h>
-#include "ganv/canvas-base.h"
#include "ganv/node.h"
#include "ganv/Item.hpp"
diff --git a/ganv/Port.hpp b/ganv/Port.hpp
index 980ddb0..648fbc3 100644
--- a/ganv/Port.hpp
+++ b/ganv/Port.hpp
@@ -22,7 +22,6 @@
#include <gdkmm/types.h>
-#include "ganv/canvas-base.h"
#include "ganv/Box.hpp"
#include "ganv/port.h"
diff --git a/ganv/canvas-base.h b/ganv/canvas-base.h
index 6f5f16e..63633b0 100644
--- a/ganv/canvas-base.h
+++ b/ganv/canvas-base.h
@@ -26,6 +26,8 @@
#include <cairo.h>
#include <gtk/gtk.h>
+#include "ganv/item.h"
+
G_BEGIN_DECLS
/* "Small" value used by canvas stuff */
@@ -33,32 +35,6 @@ G_BEGIN_DECLS
typedef struct _GanvCanvasBase GanvCanvasBase;
typedef struct _GanvCanvasBaseClass GanvCanvasBaseClass;
-typedef struct _GanvItem GanvItem;
-typedef struct _GanvItemClass GanvItemClass;
-
-/* GanvItem - base item class for canvas items
- *
- * All canvas items are derived from GanvItem. The only information a GanvItem
- * contains is its parent canvas, its parent canvas item, its bounding box in
- * world coordinates, and its current affine transformation.
- *
- * Items inside a canvas are organized in a tree, where leaves are items
- * without any children. Each canvas has a single root item, which can be
- * obtained with the ganv_canvas_base_get_root() function.
- *
- * The abstract GanvItem class does not have any configurable or
- * queryable attributes.
- */
-
-/* Object flags for items */
-enum {
- GANV_ITEM_REALIZED = 1 << 1,
- GANV_ITEM_MAPPED = 1 << 2,
- GANV_ITEM_ALWAYS_REDRAW = 1 << 3,
- GANV_ITEM_VISIBLE = 1 << 4,
- GANV_ITEM_NEED_UPDATE = 1 << 5,
- GANV_ITEM_NEED_VIS = 1 << 6,
-};
/* Update flags for items */
enum {
@@ -67,172 +43,6 @@ enum {
GANV_CANVAS_BASE_UPDATE_VISIBILITY = 1 << 2,
};
-#define GANV_TYPE_ITEM (ganv_item_get_type())
-#define GANV_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GANV_TYPE_ITEM, GanvItem))
-#define GANV_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GANV_TYPE_ITEM, GanvItemClass))
-#define GANV_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GANV_TYPE_ITEM))
-#define GANV_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GANV_TYPE_ITEM))
-#define GANV_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GANV_TYPE_ITEM, GanvItemClass))
-
-struct _GanvItem {
- GtkObject object;
-
- /* Parent canvas for this item */
- GanvCanvasBase* canvas;
-
- /* Parent for this item */
- GanvItem* parent;
-
- /* Layer (z order), higher values are on top */
- guint layer;
-
- /* Position in parent-relative coordinates. */
- double x, y;
-
- /* Bounding box for this item (in canvas coordinates) */
- double x1, y1, x2, y2;
-
- /* True if parent manages this item (don't call add/remove) */
- gboolean managed;
-};
-
-struct _GanvItemClass {
- GtkObjectClass parent_class;
-
- /* Add a child to this item (optional) */
- void (* add)(GanvItem* item, GanvItem* child);
-
- /* Remove a child from this item (optional) */
- void (* remove)(GanvItem* item, GanvItem* child);
-
- /* 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 update
- * method also recomputes the bounding box of the item.
- */
- void (* update)(GanvItem* item, int flags);
-
- /* Realize an item -- create GCs, etc. */
- void (* realize)(GanvItem* item);
-
- /* Unrealize an item */
- void (* unrealize)(GanvItem* item);
-
- /* Map an item - normally only need by items with their own GdkWindows */
- void (* map)(GanvItem* item);
-
- /* Unmap an item */
- void (* unmap)(GanvItem* 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)(GanvItem* item, cairo_t* cr,
- int x, int y, int width, int height);
-
- /* Calculate the distance from an item to the specified point. It also
- * returns a canvas item which is actual item the point is within, which
- * may not be equal to @item if @item has children. (cx, cy) are the
- * canvas pixel coordinates that correspond to the item-relative
- * coordinates (x, y).
- */
- double (* point)(GanvItem* item, double x, double y, int cx, int cy,
- GanvItem** actual_item);
-
- /* Fetch the item's bounding box (need not be exactly tight). This
- * should be in item-relative coordinates.
- */
- void (* bounds)(GanvItem* 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)(GanvItem* item, GdkEvent* event);
-
- /* Reserved for future expansion */
- gpointer spare_vmethods [4];
-};
-
-GType ganv_item_get_type(void) G_GNUC_CONST;
-
-/* Create a canvas item using the standard Gtk argument mechanism. The item
- * automatically added to @parent. The last argument must be a NULL pointer.
- */
-GanvItem* ganv_item_new(GanvItem* parent, GType type,
- const gchar* first_arg_name, ...);
-
-/* Constructors for use in derived classes and language wrappers */
-void ganv_item_construct(GanvItem* item, GanvItem* 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 ganv_item_set(GanvItem* item, const gchar* first_arg_name, ...);
-
-/* Used only for language wrappers and the like */
-void ganv_item_set_valist(GanvItem* item,
- const gchar* first_arg_name, va_list args);
-
-void ganv_item_raise(GanvItem* item);
-
-void ganv_item_lower(GanvItem* item);
-
-/* Move an item by the specified amount */
-void ganv_item_move(GanvItem* item, double dx, double dy);
-
-/* Show an item (make it visible). If the item is already shown, it has no
- * effect.
- */
-void ganv_item_show(GanvItem* item);
-
-/* Hide an item (make it invisible). If the item is already invisible, it has
- * no effect.
- */
-void ganv_item_hide(GanvItem* 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 ganv_item_grab(GanvItem* item, unsigned int event_mask,
- GdkCursor* cursor, guint32 etime);
-
-/* Ungrabs the mouse -- the specified item must be the same that was passed to
- * ganv_item_grab(). Time is a proper X event time parameter.
- */
-void ganv_item_ungrab(GanvItem* item, guint32 etime);
-
-/* Convert from item coordinates to world coordinates.
- */
-void ganv_item_i2w(GanvItem* item, double* x, double* y);
-
-/* Convert from world coordinates to item coordinates.
- */
-void ganv_item_w2i(GanvItem* item, double* x, double* y);
-
-/* Used to send all of the keystroke events to a specific item as well as
- * GDK_FOCUS_CHANGE events.
- */
-void ganv_item_grab_focus(GanvItem* 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 item relative coordinates.
- */
-void ganv_item_get_bounds(GanvItem* 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 ganv_item_request_update(GanvItem* item);
-
-/*** GanvCanvasBase ***/
-
#define GANV_TYPE_CANVAS_BASE (ganv_canvas_base_get_type())
#define GANV_CANVAS_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GANV_TYPE_CANVAS_BASE, GanvCanvasBase))
#define GANV_CANVAS_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GANV_TYPE_CANVAS_BASE, GanvCanvasBaseClass))
diff --git a/ganv/edge.h b/ganv/edge.h
index 4c2248a..b5c6fb0 100644
--- a/ganv/edge.h
+++ b/ganv/edge.h
@@ -16,7 +16,7 @@
#ifndef GANV_EDGE_H
#define GANV_EDGE_H
-#include "ganv/canvas-base.h"
+#include "ganv/item.h"
#include "ganv/node.h"
#include "ganv/types.h"
diff --git a/ganv/group.h b/ganv/group.h
index 02ccf8c..4bde530 100644
--- a/ganv/group.h
+++ b/ganv/group.h
@@ -16,7 +16,7 @@
#ifndef GANV_GROUP_H
#define GANV_GROUP_H
-#include "ganv/canvas-base.h"
+#include "ganv/item.h"
/* Based on GnomeCanvasGroup, by Federico Mena <federico@nuclecu.unam.mx>
* and Raph Levien <raph@gimp.org>
diff --git a/ganv/item.h b/ganv/item.h
new file mode 100644
index 0000000..a9a8fee
--- /dev/null
+++ b/ganv/item.h
@@ -0,0 +1,210 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2014 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or any later version.
+ *
+ * Ganv 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 General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Based on GnomeCanvas, by Federico Mena <federico@nuclecu.unam.mx>
+ * and Raph Levien <raph@gimp.org>
+ * Copyright 1997-2000 Free Software Foundation
+ */
+
+#ifndef GANV_ITEM_H
+#define GANV_ITEM_H
+
+#include <stdarg.h>
+
+#include <cairo.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GanvItem: Base class for all canvas items.
+ *
+ * All canvas items are derived from GanvItem. The only information a GanvItem
+ * contains is its parent canvas, its parent canvas item, its bounding box in
+ * world coordinates, and its current affine transformation.
+ *
+ * Items inside a canvas are organized in a tree, where leaves are items
+ * without any children. Each canvas has a single root item, which can be
+ * obtained with the ganv_canvas_base_get_root() function.
+ *
+ * The abstract GanvItem class does not have any configurable or queryable
+ * attributes.
+ */
+
+typedef struct _GanvItem GanvItem;
+typedef struct _GanvItemClass GanvItemClass;
+
+/* Object flags for items */
+enum {
+ GANV_ITEM_REALIZED = 1 << 1,
+ GANV_ITEM_MAPPED = 1 << 2,
+ GANV_ITEM_ALWAYS_REDRAW = 1 << 3,
+ GANV_ITEM_VISIBLE = 1 << 4,
+ GANV_ITEM_NEED_UPDATE = 1 << 5,
+ GANV_ITEM_NEED_VIS = 1 << 6,
+};
+
+#define GANV_TYPE_ITEM (ganv_item_get_type())
+#define GANV_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GANV_TYPE_ITEM, GanvItem))
+#define GANV_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GANV_TYPE_ITEM, GanvItemClass))
+#define GANV_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GANV_TYPE_ITEM))
+#define GANV_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GANV_TYPE_ITEM))
+#define GANV_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GANV_TYPE_ITEM, GanvItemClass))
+
+struct _GanvItem {
+ GtkObject object;
+
+ /* Parent canvas for this item */
+ struct _GanvCanvasBase* canvas;
+
+ /* Parent for this item */
+ GanvItem* parent;
+
+ /* Layer (z order), higher values are on top */
+ guint layer;
+
+ /* Position in parent-relative coordinates. */
+ double x, y;
+
+ /* Bounding box for this item (in canvas coordinates) */
+ double x1, y1, x2, y2;
+
+ /* True if parent manages this item (don't call add/remove) */
+ gboolean managed;
+};
+
+struct _GanvItemClass {
+ GtkObjectClass parent_class;
+
+ /**
+ * Add a child to this item (optional).
+ */
+ void (* add)(GanvItem* item, GanvItem* child);
+
+ /**
+ * Remove a child from this item (optional).
+ */
+ void (* remove)(GanvItem* item, GanvItem* child);
+
+ /**
+ * 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 update method also recomputes the
+ * bounding box of the item.
+ */
+ void (* update)(GanvItem* item, int flags);
+
+ /**
+ * Realize an item (create GCs, etc.).
+ */
+ void (* realize)(GanvItem* item);
+
+ /**
+ * Unrealize an item.
+ */
+ void (* unrealize)(GanvItem* item);
+
+ /**
+ * Map an item - normally only need by items with their own GdkWindows.
+ */
+ void (* map)(GanvItem* item);
+
+ /**
+ * Unmap an item
+ */
+ void (* unmap)(GanvItem* item);
+
+ /**
+ * Draw an item of this type.
+ *
+ * (x, y) are the upper-left canvas pixel coordinates of the drawable.
+ * (width, height) are the dimensions of the drawable.
+ */
+ void (* draw)(GanvItem* item, cairo_t* cr,
+ int x, int y, int width, int height);
+
+ /**
+ * Calculate the distance from an item to the specified point.
+ *
+ * It also returns a canvas item which is actual item the point is within,
+ * which may not be equal to @item if @item has children. (cx, cy) are the
+ * canvas pixel coordinates that correspond to the item-relative
+ * coordinates (x, y).
+ */
+ double (* point)(GanvItem* item, double x, double y, int cx, int cy,
+ GanvItem** actual_item);
+
+ /**
+ * Fetch the item's bounding box (need not be exactly tight).
+ *
+ * This should be in item-relative coordinates.
+ */
+ void (* bounds)(GanvItem* 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)(GanvItem* item, GdkEvent* event);
+
+ /* Reserved for future expansion */
+ gpointer spare_vmethods [4];
+};
+
+GType ganv_item_get_type(void) G_GNUC_CONST;
+
+GanvItem* ganv_item_new(GanvItem* parent, GType type,
+ const gchar* first_arg_name, ...);
+
+void ganv_item_construct(GanvItem* item, GanvItem* parent,
+ const gchar* first_arg_name, va_list args);
+
+void ganv_item_set(GanvItem* item, const gchar* first_arg_name, ...);
+
+void ganv_item_set_valist(GanvItem* item,
+ const gchar* first_arg_name, va_list args);
+
+void ganv_item_raise(GanvItem* item);
+
+void ganv_item_lower(GanvItem* item);
+
+void ganv_item_move(GanvItem* item, double dx, double dy);
+
+void ganv_item_show(GanvItem* item);
+
+void ganv_item_hide(GanvItem* item);
+
+int ganv_item_grab(GanvItem* item, unsigned int event_mask,
+ GdkCursor* cursor, guint32 etime);
+
+void ganv_item_ungrab(GanvItem* item, guint32 etime);
+
+void ganv_item_i2w(GanvItem* item, double* x, double* y);
+
+void ganv_item_w2i(GanvItem* item, double* x, double* y);
+
+void ganv_item_grab_focus(GanvItem* item);
+
+void ganv_item_get_bounds(GanvItem* item,
+ double* x1, double* y1, double* x2, double* y2);
+
+void ganv_item_request_update(GanvItem* item);
+
+G_END_DECLS
+
+#endif /* GANV_ITEM_H */
diff --git a/ganv/node.h b/ganv/node.h
index 6823086..db50d1c 100644
--- a/ganv/node.h
+++ b/ganv/node.h
@@ -16,7 +16,7 @@
#ifndef GANV_NODE_H
#define GANV_NODE_H
-#include "ganv/canvas-base.h"
+#include "ganv/item.h"
#include "ganv/types.h"
#include "ganv/text.h"
diff --git a/ganv/text.h b/ganv/text.h
index 192104f..11394b5 100644
--- a/ganv/text.h
+++ b/ganv/text.h
@@ -16,7 +16,7 @@
#ifndef GANV_TEXT_H
#define GANV_TEXT_H
-#include "ganv/canvas-base.h"
+#include "ganv/item.h"
G_BEGIN_DECLS
diff --git a/ganv/widget.h b/ganv/widget.h
index a097770..c5064d2 100644
--- a/ganv/widget.h
+++ b/ganv/widget.h
@@ -20,7 +20,7 @@
#ifndef GANV_WIDGET_H
#define GANV_WIDGET_H
-#include "ganv/canvas-base.h"
+#include "ganv/item.h"
G_BEGIN_DECLS