diff options
author | David Robillard <d@drobilla.net> | 2014-04-26 16:49:15 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-04-26 16:49:15 +0000 |
commit | 65b14544b89afc3a7d3a7de57e6ef15ca8165bd0 (patch) | |
tree | aff9e8f19197c83df67ff723ea154b7573880cdb /ganv | |
parent | fb3498abb00ed3cf5c5938fcb1bffef163674274 (diff) | |
download | ganv-65b14544b89afc3a7d3a7de57e6ef15ca8165bd0.tar.gz ganv-65b14544b89afc3a7d3a7de57e6ef15ca8165bd0.tar.bz2 ganv-65b14544b89afc3a7d3a7de57e6ef15ca8165bd0.zip |
Clean up Ganv API.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5367 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'ganv')
-rw-r--r-- | ganv/Box.hpp | 5 | ||||
-rw-r--r-- | ganv/Canvas.hpp | 73 | ||||
-rw-r--r-- | ganv/Edge.hpp | 8 | ||||
-rw-r--r-- | ganv/Item.hpp | 19 | ||||
-rw-r--r-- | ganv/Module.hpp | 6 | ||||
-rw-r--r-- | ganv/Node.hpp | 20 | ||||
-rw-r--r-- | ganv/box.h | 2 | ||||
-rw-r--r-- | ganv/canvas.h | 129 | ||||
-rw-r--r-- | ganv/circle.h | 17 | ||||
-rw-r--r-- | ganv/edge.h | 19 | ||||
-rw-r--r-- | ganv/group.h | 10 | ||||
-rw-r--r-- | ganv/item.h | 30 | ||||
-rw-r--r-- | ganv/module.h | 12 | ||||
-rw-r--r-- | ganv/node.h | 49 | ||||
-rw-r--r-- | ganv/port.h | 6 | ||||
-rw-r--r-- | ganv/text.h | 2 | ||||
-rw-r--r-- | ganv/widget.h | 18 | ||||
-rw-r--r-- | ganv/wrap.hpp | 10 |
18 files changed, 210 insertions, 225 deletions
diff --git a/ganv/Box.hpp b/ganv/Box.hpp index 6d75d23..aa88f0e 100644 --- a/ganv/Box.hpp +++ b/ganv/Box.hpp @@ -30,10 +30,15 @@ public: RW_PROPERTY(const char*, label); + METHODRET0(ganv_box, double, get_x1) + METHODRET0(ganv_box, double, get_y1) + METHODRET0(ganv_box, double, get_x2) + METHODRET0(ganv_box, double, get_y2) METHODRET0(ganv_box, double, get_width) METHOD1(ganv_box, set_width, double, width) METHODRET0(ganv_box, double, get_height) METHOD1(ganv_box, set_height, double, height) + METHODRET0(ganv_box, double, get_border_width) GanvBox* gobj() { return GANV_BOX(_gobj); } const GanvBox* gobj() const { return GANV_BOX(_gobj); } diff --git a/ganv/Canvas.hpp b/ganv/Canvas.hpp index 2139e93..88211d4 100644 --- a/ganv/Canvas.hpp +++ b/ganv/Canvas.hpp @@ -34,6 +34,7 @@ GANV_GLIB_WRAP(Canvas) namespace Ganv { class Edge; +class Item; class Node; class Port; @@ -55,42 +56,64 @@ public: Canvas(double width, double height); virtual ~Canvas(); + GanvItem* root() { return ganv_canvas_root(gobj()); } + METHOD0(ganv_canvas, clear); - METHOD0(ganv_canvas, clear_selection); - METHOD0(ganv_canvas, select_all); - METHODRET0(ganv_canvas, double, get_zoom); - METHOD1(ganv_canvas, set_zoom, double, pix_per_unit); - METHOD1(ganv_canvas, set_font_size, double, points); - METHOD0(ganv_canvas, zoom_full); - METHODRET0(ganv_canvas, double, get_font_size) - METHODRET0(ganv_canvas, double, get_default_font_size) - METHOD1(ganv_canvas, export_dot, const char*, filename); - METHOD0(ganv_canvas, arrange); - METHOD2(ganv_canvas, move_contents_to, double, x, double, y); + METHODRET0(ganv_canvas, gboolean, empty) METHOD2(ganv_canvas, resize, double, width, double, height); + METHOD4(ganv_canvas, set_scroll_region, double, x1, double, y1, double, x2, double, y2); + METHOD4(ganv_canvas, get_scroll_region, double*, x1, double*, y1, double*, x2, double*, y2); + METHOD1(ganv_canvas, set_center_scroll_region, gboolean, c); + METHODRET0(ganv_canvas, gboolean, get_center_scroll_region); + METHOD2(ganv_canvas, scroll_to, int, x, int, y); + + void get_scroll_offsets(int& cx, int& cy) const { + ganv_canvas_get_scroll_offsets(gobj(), &cx, &cy); + } + + METHOD1(ganv_canvas, w2c_affine, cairo_matrix_t*, matrix); + METHOD4(ganv_canvas, w2c, double, wx, double, wy, int*, cx, int*, cy); + METHOD4(ganv_canvas, w2c_d, double, wx, double, wy, double*, cx, double*, cy); + METHOD4(ganv_canvas, c2w, int, cx, int, cy, double*, wx, double*, wy); + METHOD4(ganv_canvas, window_to_world, double, winx, double, winy, double*, worldx, double*, worldy); + METHOD4(ganv_canvas, world_to_window, double, worldx, double, worldy, double*, winx, double*, winy); + + Item* get_item_at(double x, double y) const; + Edge* get_edge(Node* tail, Node* head) const; + void remove_edge_between(Node* tail, Node* head); + void remove_edge(Edge* edge); + + METHOD0(ganv_canvas, arrange); + METHOD1(ganv_canvas, export_dot, const char*, filename); + METHODRET0(ganv_canvas, gboolean, supports_sprung_layout); + METHODRET1(ganv_canvas, gboolean, set_sprung_layout, gboolean, sprung_layout); METHOD2(ganv_canvas, for_each_node, GanvNodeFunc, f, void*, data) METHOD2(ganv_canvas, for_each_selected_node, GanvNodeFunc, f, void*, data) METHOD2(ganv_canvas, for_each_edge, GanvEdgeFunc, f, void*, data) - METHOD2(ganv_canvas, for_each_selected_edge, GanvEdgeFunc, f, void*, data) - METHODRET0(ganv_canvas, gboolean, empty) - METHOD2(ganv_canvas, scroll_to, int, x, int, y); - METHOD3(ganv_canvas, for_each_edge_from, const GanvNode*, tail, GanvEdgeFunc, f, void*, data); - METHOD3(ganv_canvas, for_each_edge_to, const GanvNode*, head, GanvEdgeFunc, f, void*, data); - METHOD3(ganv_canvas, for_each_edge_on, const GanvNode*, node, GanvEdgeFunc, f, void*, data); + METHOD2(ganv_canvas, for_each_selected_edge, GanvEdgeFunc, f, void*, data) + METHOD0(ganv_canvas, select_all); + METHOD0(ganv_canvas, clear_selection); + METHODRET0(ganv_canvas, double, get_zoom); + METHOD1(ganv_canvas, set_zoom, double, pix_per_unit); + METHOD0(ganv_canvas, zoom_full); + METHODRET0(ganv_canvas, double, get_default_font_size) + METHODRET0(ganv_canvas, double, get_font_size) + METHOD1(ganv_canvas, set_font_size, double, points); METHOD0(ganv_canvas, get_move_cursor); + METHOD2(ganv_canvas, move_contents_to, double, x, double, y); RW_PROPERTY(gboolean, locked); RW_PROPERTY(double, width) @@ -101,24 +124,8 @@ public: return *Glib::wrap(&_gobj->layout); } - /** Get the edge from @c tail to @c head if one exists. */ - Edge* get_edge(Node* tail, Node* head) const; - - /** Delete the edge from @c tail to @c head. */ - void remove_edge(Node* tail, Node* head); - - void remove_edge(Edge* edge); - - void get_scroll_offsets(int& cx, int& cy) const { - ganv_canvas_get_scroll_offsets(gobj(), &cx, &cy); - } - GQuark wrapper_key(); - GanvItem* root() { - return ganv_canvas_root(gobj()); - } - GanvCanvas* gobj() { return GANV_CANVAS(_gobj); } const GanvCanvas* gobj() const { return GANV_CANVAS(_gobj); } diff --git a/ganv/Edge.hpp b/ganv/Edge.hpp index e220d95..350a617 100644 --- a/ganv/Edge.hpp +++ b/ganv/Edge.hpp @@ -61,14 +61,12 @@ public: {} virtual ~Edge() { - if (_gobj && _gobj->parent) { + if (_gobj && ganv_item_get_parent(_gobj)) { g_object_unref(_gobj); } } - /** Return true iff the handle is within the given rectangle. */ - virtual gboolean is_within(double x1, double y1, - double x2, double y2) const { + gboolean is_within(double x1, double y1, double x2, double y2) const { return ganv_edge_is_within(gobj(), x1, y1, x2, y2); } @@ -81,8 +79,6 @@ public: METHODRETWRAP0(ganv_edge, Node*, get_tail); METHODRETWRAP0(ganv_edge, Node*, get_head); - METHOD1(ganv_edge, tick, double, seconds); - GanvEdge* gobj() { return (GanvEdge*)_gobj; } const GanvEdge* gobj() const { return (GanvEdge*)_gobj; } diff --git a/ganv/Item.hpp b/ganv/Item.hpp index 2ba4de0..fb2667d 100644 --- a/ganv/Item.hpp +++ b/ganv/Item.hpp @@ -27,6 +27,8 @@ #include "ganv/item.h" #include "ganv/wrap.hpp" +GANV_GLIB_WRAP(Item) + namespace Ganv { class Canvas; @@ -39,7 +41,7 @@ public: : _gobj(gobj) { GQuark wrapper_key = g_quark_from_string("ganvmm"); - if (gobj && gobj->parent) { + if (gobj && ganv_item_get_parent(gobj)) { g_object_set_qdata(G_OBJECT(_gobj), wrapper_key, this); g_signal_connect( G_OBJECT(_gobj), "event", G_CALLBACK(on_item_event), this); @@ -53,18 +55,17 @@ public: RW_PROPERTY(double, x) RW_PROPERTY(double, y) + METHOD0(ganv_item, raise); + METHOD0(ganv_item, lower); + METHOD2(ganv_item, move, double, dx, double, dy); METHOD0(ganv_item, show); METHOD0(ganv_item, hide); - METHOD2(ganv_item, move, double, dx, double, dy); - - GanvItem* property_parent() const { - GanvItem* parent; - g_object_get(G_OBJECT(_gobj), "parent", &parent, NULL); - return parent; - } + METHOD2(ganv_item, i2w, double*, x, double*, y); + METHOD2(ganv_item, w2i, double*, x, double*, y); + METHOD0(ganv_item, grab_focus); Canvas* canvas() const { - return Glib::wrap(GANV_CANVAS(_gobj->canvas)); + return Glib::wrap(ganv_item_get_canvas(_gobj)); } GanvItem* gobj() const { return _gobj; } diff --git a/ganv/Module.hpp b/ganv/Module.hpp index 21deb91..ef73621 100644 --- a/ganv/Module.hpp +++ b/ganv/Module.hpp @@ -105,11 +105,7 @@ public: const_iterator back() const { return iterator(const_cast<GanvModule*>(gobj()), num_ports() - 1); } void embed(Gtk::Widget* widget) { - if (widget) { - ganv_module_embed(gobj(), widget->gobj()); - } else { - ganv_module_embed(gobj(), NULL); - } + ganv_module_embed(gobj(), widget ? widget->gobj() : NULL); } Port* get_port(guint index) { diff --git a/ganv/Node.hpp b/ganv/Node.hpp index 9a3e56b..a6f47e8 100644 --- a/ganv/Node.hpp +++ b/ganv/Node.hpp @@ -44,15 +44,20 @@ public: g_object_unref(_gobj); } + RW_PROPERTY(gboolean, can_tail) + RW_PROPERTY(gboolean, can_head) + RW_PROPERTY(gboolean, is_source) + + gboolean is_within(double x1, double y1, double x2, double y2) const { + return ganv_node_is_within(gobj(), x1, y1, x2, y2); + } + RW_PROPERTY(const char*, label) + RW_PROPERTY(double, border_width) RW_PROPERTY(double, dash_length) RW_PROPERTY(double, dash_offset) - RW_PROPERTY(double, border_width) RW_PROPERTY(guint, fill_color) RW_PROPERTY(guint, border_color) - RW_PROPERTY(gboolean, can_tail) - RW_PROPERTY(gboolean, can_head) - RW_PROPERTY(gboolean, is_source) RW_PROPERTY(gboolean, selected) RW_PROPERTY(gboolean, highlighted) RW_PROPERTY(gboolean, draggable) @@ -60,13 +65,6 @@ public: RW_OBJECT_PROPERTY(Node*, partner); - METHOD1(ganv_node, tick, double, seconds); - - virtual gboolean is_within(double x1, double y1, - double x2, double y2) const { - return ganv_node_is_within(gobj(), x1, y1, x2, y2); - } - GanvNode* gobj() { return GANV_NODE(_gobj); } const GanvNode* gobj() const { return GANV_NODE(_gobj); } @@ -50,7 +50,7 @@ struct _GanvBoxClass { double height); /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethods[4]; }; GType ganv_box_get_type(void) G_GNUC_CONST; diff --git a/ganv/canvas.h b/ganv/canvas.h index a3444dc..02219c1 100644 --- a/ganv/canvas.h +++ b/ganv/canvas.h @@ -60,7 +60,7 @@ struct _GanvCanvasClass { GtkLayoutClass parent_class; /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethods[4]; }; GType ganv_canvas_get_type(void) G_GNUC_CONST; @@ -94,6 +94,28 @@ GanvCanvas* ganv_canvas_new(double width, double height); /** + * ganv_canvas_clear: + * Remove all items from the canvas. + */ +void +ganv_canvas_clear(GanvCanvas* canvas); + +/** + * ganv_canvas_empty: + * + * Return value: True if there are no items on the canvas. + */ +gboolean +ganv_canvas_empty(const GanvCanvas* canvas); + +/** + * ganv_canvas_resize: + * Resize the canvas to the given dimensions. + */ +void +ganv_canvas_resize(GanvCanvas* canvas, double width, double height); + +/** * ganv_canvas_root: * @canvas: A canvas. * @@ -158,7 +180,7 @@ ganv_canvas_set_center_scroll_region(GanvCanvas* canvas, * Returns: Whether the scroll region is being centered in the canvas window. */ gboolean -ganv_canvas_get_center_scroll_region(GanvCanvas* canvas); +ganv_canvas_get_center_scroll_region(const GanvCanvas* canvas); /** * ganv_canvas_scroll_to: @@ -187,21 +209,6 @@ void ganv_canvas_get_scroll_offsets(const GanvCanvas* canvas, int* cx, int* cy); /** - * ganv_canvas_get_item_at: - * @canvas: A canvas. - * @x: X position in world coordinates. - * @y: Y position in world coordinates. - * - * Looks for the item that is under the specified position, which must be - * specified in world coordinates. - * - * Returns: (transfer none): The sought item, or NULL if no item is at the - * specified coordinates. - */ -GanvItem* -ganv_canvas_get_item_at(GanvCanvas* canvas, double x, double y); - -/** * ganv_canvas_w2c_affine: * @canvas: A canvas. * @matrix: An affine transformation matrix (return value). @@ -293,11 +300,19 @@ ganv_canvas_world_to_window(GanvCanvas* canvas, double* winy); /** - * ganv_canvas_resize: - * Resize the canvas to the given dimensions. + * ganv_canvas_get_item_at: + * @canvas: A canvas. + * @x: X position in world coordinates. + * @y: Y position in world coordinates. + * + * Looks for the item that is under the specified position, which must be + * specified in world coordinates. + * + * Returns: (transfer none): The sought item, or NULL if no item is at the + * specified coordinates. */ -void -ganv_canvas_resize(GanvCanvas* canvas, double width, double height); +GanvItem* +ganv_canvas_get_item_at(GanvCanvas* canvas, double x, double y); /** * ganv_canvas_get_edge: @@ -311,6 +326,15 @@ ganv_canvas_get_edge(GanvCanvas* canvas, GanvNode* head); /** + * ganv_canvas_remove_edge: + * + * Remove @edge from the canvas. + */ +void +ganv_canvas_remove_edge(GanvCanvas* canvas, + GanvEdge* edge); + +/** * ganv_canvas_remove_edge_between: * * Remove the edge from @tail to @head if one exists. @@ -321,14 +345,6 @@ ganv_canvas_remove_edge_between(GanvCanvas* canvas, GanvNode* head); /** - * ganv_canvas_get_default_font_size: - * - * Get the default font size in points. - */ -double -ganv_canvas_get_default_font_size(const GanvCanvas* canvas); - -/** * ganv_canvas_get_direction: * * Return the direction of signal flow. @@ -345,14 +361,6 @@ void ganv_canvas_set_direction(GanvCanvas* canvas, GanvDirection dir); /** - * ganv_canvas_clear_selection: - * - * Deselect any selected items on the canvas. - */ -void -ganv_canvas_clear_selection(GanvCanvas* canvas); - -/** * ganv_canvas_arrange: * * Automatically arrange the canvas contents. @@ -374,7 +382,7 @@ ganv_canvas_export_dot(GanvCanvas* canvas, const char* filename); * Returns: true iff ganv is compiled with sprung layout support. */ gboolean -ganv_canvas_supports_sprung_layout(GanvCanvas* canvas); +ganv_canvas_supports_sprung_layout(const GanvCanvas* canvas); /** * ganv_canvas_set_sprung_layout: @@ -392,7 +400,7 @@ ganv_canvas_set_sprung_layout(GanvCanvas* canvas, gboolean sprung_layout); * Return true iff the canvas is locked and nodes may not move. */ gboolean -ganv_canvas_get_locked(GanvCanvas* canvas); +ganv_canvas_get_locked(const GanvCanvas* canvas); /** * ganv_canvas_for_each_node: @@ -417,14 +425,6 @@ ganv_canvas_for_each_selected_node(GanvCanvas* canvas, void* data); /** - * ganv_canvas_empty: - * - * Return value: True if there are no items on the canvas. - */ -gboolean -ganv_canvas_empty(const GanvCanvas* canvas); - -/** * ganv_canvas_for_each_edge: * @canvas: The canvas. * @f: (scope call): A function to call on every edge on @canvas. @@ -483,18 +483,19 @@ ganv_canvas_for_each_selected_edge(GanvCanvas* canvas, void* data); /** - * ganv_canvas_clear: - * Remove all items from the canvas. + * ganv_canvas_select_all: + * Select all items on the canvas. */ void -ganv_canvas_clear(GanvCanvas* canvas); +ganv_canvas_select_all(GanvCanvas* canvas); /** - * ganv_canvas_select_all: - * Select all items on the canvas. + * ganv_canvas_clear_selection: + * + * Deselect any selected items on the canvas. */ void -ganv_canvas_select_all(GanvCanvas* canvas); +ganv_canvas_clear_selection(GanvCanvas* canvas); /** * ganv_canvas_get_zoom: @@ -520,6 +521,21 @@ void ganv_canvas_set_zoom(GanvCanvas* canvas, double zoom); /** + * ganv_canvas_zoom_full: + * Zoom so all canvas contents are visible. + */ +void +ganv_canvas_zoom_full(GanvCanvas* canvas); + +/** + * ganv_canvas_get_default_font_size: + * + * Get the default font size in points. + */ +double +ganv_canvas_get_default_font_size(const GanvCanvas* canvas); + +/** * ganv_canvas_get_font_size: * Get the current font size in points. */ @@ -534,13 +550,6 @@ void ganv_canvas_set_font_size(GanvCanvas* canvas, double points); /** - * ganv_canvas_zoom_full: - * Zoom so all canvas contents are visible. - */ -void -ganv_canvas_zoom_full(GanvCanvas* canvas); - -/** * ganv_canvas_get_move_cursor: * Return the cursor to use while dragging canvas objects. */ diff --git a/ganv/circle.h b/ganv/circle.h index 859bb29..bf562b9 100644 --- a/ganv/circle.h +++ b/ganv/circle.h @@ -46,7 +46,7 @@ struct _GanvCircleClass { GanvNodeClass parent_class; /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethods[4]; }; GType ganv_circle_get_type(void) G_GNUC_CONST; @@ -58,6 +58,21 @@ ganv_circle_new(GanvCanvas* canvas, double ganv_circle_get_radius(const GanvCircle* circle); +void +ganv_circle_set_radius(GanvCircle* circle, double radius); + +double +ganv_circle_get_radius_ems(const GanvCircle* circle); + +void +ganv_circle_set_radius_ems(GanvCircle* circle, double radius); + +gboolean +ganv_circle_get_fit_label(const GanvCircle* circle); + +void +ganv_circle_set_fit_label(GanvCircle* circle, gboolean fit_label); + G_END_DECLS #endif /* GANV_CIRCLE_H */ diff --git a/ganv/edge.h b/ganv/edge.h index d5c0c59..c36e0ed 100644 --- a/ganv/edge.h +++ b/ganv/edge.h @@ -41,7 +41,7 @@ struct _GanvEdgeClass { GanvItemClass parent_class; /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethods[4]; }; GType ganv_edge_get_type(void) G_GNUC_CONST; @@ -59,20 +59,23 @@ ganv_edge_is_within(const GanvEdge* edge, double x2, double y2); +gboolean +ganv_edge_get_curved(const GanvEdge* edge); + void -ganv_edge_update_location(GanvEdge* edge); +ganv_edge_set_curved(GanvEdge* edge, gboolean curved); void -ganv_edge_select(GanvEdge* edge); +ganv_edge_set_selected(GanvEdge* edge, gboolean selected); void -ganv_edge_unselect(GanvEdge* edge); +ganv_edge_set_highlighted(GanvEdge* edge, gboolean highlighted); void -ganv_edge_highlight(GanvEdge* edge); +ganv_edge_select(GanvEdge* edge); void -ganv_edge_unhighlight(GanvEdge* edge); +ganv_edge_unselect(GanvEdge* edge); /** * ganv_edge_disconnect: @@ -91,10 +94,6 @@ ganv_edge_disconnect(GanvEdge* edge); void ganv_edge_remove(GanvEdge* edge); -void -ganv_edge_tick(GanvEdge* edge, - double seconds); - /** * ganv_edge_get_tail: * diff --git a/ganv/group.h b/ganv/group.h index 0d77ee6..1979d6f 100644 --- a/ganv/group.h +++ b/ganv/group.h @@ -33,21 +33,19 @@ G_BEGIN_DECLS #define GANV_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GANV_TYPE_GROUP, GanvGroupClass)) typedef struct _GanvGroup GanvGroup; +typedef struct _GanvGroupImpl GanvGroupImpl; typedef struct _GanvGroupClass GanvGroupClass; struct _GanvGroup { - GanvItem item; - - /* Children of the group */ - GList* item_list; - GList* item_list_end; + GanvItem item; + GanvGroupImpl* impl; }; struct _GanvGroupClass { GanvItemClass parent_class; /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethods[4]; }; GType ganv_group_get_type(void) G_GNUC_CONST; diff --git a/ganv/item.h b/ganv/item.h index 83b5f3c..3e57662 100644 --- a/ganv/item.h +++ b/ganv/item.h @@ -28,7 +28,10 @@ G_BEGIN_DECLS +struct _GanvCanvas; + typedef struct _GanvItem GanvItem; +typedef struct _GanvItemImpl GanvItemImpl; typedef struct _GanvItemClass GanvItemClass; /* Object flags for items */ @@ -49,25 +52,8 @@ enum { #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 _GanvCanvas* 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 world coordinates) */ - double x1, y1, x2, y2; - - /* True if parent manages this item (don't call add/remove) */ - gboolean managed; + GtkObject object; + GanvItemImpl* impl; }; struct _GanvItemClass { @@ -136,7 +122,7 @@ struct _GanvItemClass { gboolean (*event)(GanvItem* item, GdkEvent* event); /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethods[4]; }; GType ganv_item_get_type(void) G_GNUC_CONST; @@ -152,6 +138,10 @@ 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); +struct _GanvCanvas* ganv_item_get_canvas(GanvItem* item); + +GanvItem* ganv_item_get_parent(GanvItem* item); + void ganv_item_raise(GanvItem* item); void ganv_item_lower(GanvItem* item); diff --git a/ganv/module.h b/ganv/module.h index 3ee94b5..4eab012 100644 --- a/ganv/module.h +++ b/ganv/module.h @@ -44,7 +44,7 @@ struct _GanvModuleClass { GanvBoxClass parent_class; /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethods[4]; }; GType ganv_module_get_type(void) G_GNUC_CONST; @@ -73,16 +73,10 @@ double ganv_module_get_empty_port_depth(const GanvModule* module); void -ganv_module_set_icon(GanvModule* module, - GdkPixbuf* icon); +ganv_module_embed(GanvModule* module, GtkWidget* widget); void -ganv_module_embed(GanvModule* module, - GtkWidget* widget); - -void -ganv_module_set_direction(GanvModule* module, - GanvDirection direction); +ganv_module_set_direction(GanvModule* module, GanvDirection direction); /** * ganv_module_for_each_port: diff --git a/ganv/node.h b/ganv/node.h index 583d608..2784937 100644 --- a/ganv/node.h +++ b/ganv/node.h @@ -78,7 +78,7 @@ struct _GanvNodeClass { double* dy); /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethods[4]; }; GType ganv_node_get_type(void) G_GNUC_CONST; @@ -119,44 +119,27 @@ ganv_node_is_within(const GanvNode* node, double x2, double y2); -void -ganv_node_tick(GanvNode* self, - double seconds); +const char* ganv_node_get_label(const GanvNode* node); -void -ganv_node_tail_vector(const GanvNode* self, - const GanvNode* head, - double* x1, - double* y1, - double* x2, - double* y2); +double ganv_node_get_border_width(const GanvNode* node); -void -ganv_node_head_vector(const GanvNode* self, - const GanvNode* tail, - double* x1, - double* y1, - double* x2, - double* y2); +void ganv_node_set_border_width(const GanvNode* node, double border_width); -/** - * ganv_node_get_draw_properties: - * - * Get the colours that should currently be used for drawing this node. Note - * these may not be identical to the property values because of highlighting - * and selection. - */ -void -ganv_node_get_draw_properties(const GanvNode* node, - double* dash_length, - double* border_color, - double* fill_color); +double ganv_node_get_dash_length(const GanvNode* node); -const char* ganv_node_get_label(const GanvNode* node); +void ganv_node_set_dash_length(const GanvNode* node, double dash_length); -double ganv_node_get_border_width(const GanvNode* node); +double ganv_node_get_dash_offset(const GanvNode* node); -double ganv_node_get_dash_length(const GanvNode* node); +void ganv_node_set_dash_offset(const GanvNode* node, double dash_offset); + +guint ganv_node_get_fill_color(const GanvNode* node); + +void ganv_node_set_fill_color(const GanvNode* node, guint fill_color); + +guint ganv_node_get_border_color(const GanvNode* node); + +void ganv_node_set_border_color(const GanvNode* node, guint border_color); /** * ganv_node_get_partner: diff --git a/ganv/port.h b/ganv/port.h index a4c43ef..3b04db5 100644 --- a/ganv/port.h +++ b/ganv/port.h @@ -41,7 +41,7 @@ struct _GanvPortClass { GanvBoxClass parent_class; /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethods[4]; }; GType ganv_port_get_type(void) G_GNUC_CONST; @@ -52,10 +52,6 @@ ganv_port_new(GanvModule* module, const char* first_prop_name, ...); void -ganv_port_set_direction(GanvPort* port, - GanvDirection direction); - -void ganv_port_set_value_label(GanvPort* port, const char* str); diff --git a/ganv/text.h b/ganv/text.h index 7429fcc..96a95c0 100644 --- a/ganv/text.h +++ b/ganv/text.h @@ -40,7 +40,7 @@ struct _GanvTextClass { GanvItemClass parent_class; /* Reserved for future expansion */ - gpointer spare_vmethods [4]; + gpointer spare_vmethodsx[4]; }; GType ganv_text_get_type(void) G_GNUC_CONST; diff --git a/ganv/widget.h b/ganv/widget.h index f9134ce..d3d63d1 100644 --- a/ganv/widget.h +++ b/ganv/widget.h @@ -32,24 +32,12 @@ G_BEGIN_DECLS #define GANV_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GANV_TYPE_WIDGET, GanvWidgetClass)) typedef struct _GanvWidget GanvWidget; +typedef struct _GanvWidgetImpl GanvWidgetImpl; typedef struct _GanvWidgetClass GanvWidgetClass; struct _GanvWidget { - GanvItem 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? */ + GanvItem item; + GanvWidgetImpl* impl; }; struct _GanvWidgetClass { diff --git a/ganv/wrap.hpp b/ganv/wrap.hpp index d0cdfa4..f4f2e9c 100644 --- a/ganv/wrap.hpp +++ b/ganv/wrap.hpp @@ -71,6 +71,11 @@ private: \ return prefix##_##name(gobj()); \ } +#define METHODRET1(prefix, ret, name, t1, a1) \ + virtual ret name(t1 a1) { \ + return prefix##_##name(gobj(), a1); \ + } + #define METHODRETWRAP0(prefix, ret, name) \ virtual ret name() const { \ if (gobj()) { \ @@ -90,6 +95,11 @@ private: \ prefix##_##name(gobj(), a1, a2, a3); \ } +#define METHOD4(prefix, name, t1, a1, t2, a2, t3, a3, t4, a4) \ + virtual void name(t1 a1, t2 a2, t3 a3, t4 a4) { \ + prefix##_##name(gobj(), a1, a2, a3, a4); \ + } + #define GANV_GLIB_WRAP(Name) \ namespace Ganv { \ class Name; \ |