VOID:BOOLEAN
VOID:INT
VOID:INT,INT
+VOID:INT,DOUBLE
VOID:DOUBLE
VOID:DOUBLE,DOUBLE
VOID:STRING
glMergeRecord *record);
+static void draw_object (PrintInfo *pi,
+ glLabelObject *object,
+ glMergeRecord *record);
+
static void draw_text_object (PrintInfo *pi,
glLabelText *object,
glMergeRecord *record);
for (p_obj = label->objects; p_obj != NULL; p_obj = p_obj->next) {
object = (glLabelObject *) p_obj->data;
- if (GL_IS_LABEL_TEXT(object)) {
- draw_text_object (pi, GL_LABEL_TEXT(object), record);
- } else if (GL_IS_LABEL_BOX(object)) {
- draw_box_object (pi, GL_LABEL_BOX(object));
- } else if (GL_IS_LABEL_LINE(object)) {
- draw_line_object (pi, GL_LABEL_LINE(object));
- } else if (GL_IS_LABEL_ELLIPSE(object)) {
- draw_ellipse_object (pi, GL_LABEL_ELLIPSE(object));
- } else if (GL_IS_LABEL_IMAGE(object)) {
- draw_image_object (pi, GL_LABEL_IMAGE(object));
- } else if (GL_IS_LABEL_BARCODE(object)) {
- draw_barcode_object (pi, GL_LABEL_BARCODE(object),
- record);
- }
+ draw_object (pi, object, record);
+ }
+
+ gl_debug (DEBUG_PRINT, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Draw object. */
+/*---------------------------------------------------------------------------*/
+static void
+draw_object (PrintInfo *pi,
+ glLabelObject *object,
+ glMergeRecord *record)
+{
+ gdouble x0, y0, w, h;
+ glLabelObjectFlip flip;
+
+ gl_debug (DEBUG_PRINT, "START");
+
+ gl_label_object_get_position (object, &x0, &y0);
+ gl_label_object_get_size (object, &w, &h);
+ flip = gl_label_object_get_flip (object);
+
+ gnome_print_gsave (pi->pc);
+ gnome_print_translate (pi->pc, x0, y0);
+
+ if ( flip & GL_LABEL_OBJECT_FLIP_HORIZ ) {
+ gnome_print_translate (pi->pc, w, 0.0);
+ gnome_print_scale (pi->pc, -1.0, 1.0);
+ }
+ if ( flip & GL_LABEL_OBJECT_FLIP_VERT ) {
+ gnome_print_translate (pi->pc, 0.0, h);
+ gnome_print_scale (pi->pc, 1.0, -1.0);
+ }
+
+ if (GL_IS_LABEL_TEXT(object)) {
+ draw_text_object (pi, GL_LABEL_TEXT(object), record);
+ } else if (GL_IS_LABEL_BOX(object)) {
+ draw_box_object (pi, GL_LABEL_BOX(object));
+ } else if (GL_IS_LABEL_LINE(object)) {
+ draw_line_object (pi, GL_LABEL_LINE(object));
+ } else if (GL_IS_LABEL_ELLIPSE(object)) {
+ draw_ellipse_object (pi, GL_LABEL_ELLIPSE(object));
+ } else if (GL_IS_LABEL_IMAGE(object)) {
+ draw_image_object (pi, GL_LABEL_IMAGE(object));
+ } else if (GL_IS_LABEL_BARCODE(object)) {
+ draw_barcode_object (pi, GL_LABEL_BARCODE(object),
+ record);
}
+ gnome_print_grestore (pi->pc);
+
gl_debug (DEBUG_PRINT, "END");
}
gchar **line;
gint i;
gdouble x_offset, y_offset, w, object_w, object_h;
- gdouble x, y;
- gdouble x0, y0;
gchar *text;
GList *lines;
gchar *font_family;
gl_debug (DEBUG_PRINT, "START");
- gl_label_object_get_position (GL_LABEL_OBJECT(object), &x0, &y0);
gl_label_object_get_size (GL_LABEL_OBJECT(object), &object_w, &object_h);
lines = gl_label_text_get_lines (object);
gl_label_text_get_props (object,
y_offset = (i + 1) * font_size
+ gnome_font_get_descender (font);
- x = x0 + x_offset;
- y = y0 + y_offset;
- gnome_print_moveto (pi->pc, x, y);
+ gnome_print_moveto (pi->pc, x_offset, y_offset);
gnome_print_gsave (pi->pc);
gnome_print_scale (pi->pc, 1.0, -1.0);
draw_box_object (PrintInfo *pi,
glLabelBox *object)
{
- gdouble x, y, w, h;
+ gdouble w, h;
gdouble line_width;
guint line_color, fill_color;
gl_debug (DEBUG_PRINT, "START");
- gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
line_width = gl_label_box_get_line_width (object);
line_color = gl_label_box_get_line_color (object);
fill_color = gl_label_box_get_fill_color (object);
/* Paint fill color */
- create_rectangle_path (pi->pc, x, y, w, h);
+ create_rectangle_path (pi->pc, 0.0, 0.0, w, h);
gnome_print_setrgbcolor (pi->pc,
GL_COLOR_F_RED (fill_color),
GL_COLOR_F_GREEN (fill_color),
gnome_print_fill (pi->pc);
/* Draw outline */
- create_rectangle_path (pi->pc, x, y, w, h);
+ create_rectangle_path (pi->pc, 0.0, 0.0, w, h);
gnome_print_setrgbcolor (pi->pc,
GL_COLOR_F_RED (line_color),
GL_COLOR_F_GREEN (line_color),
draw_line_object (PrintInfo *pi,
glLabelLine *object)
{
- gdouble x, y, w, h;
+ gdouble w, h;
gdouble line_width;
guint line_color;
gl_debug (DEBUG_PRINT, "START");
- gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
line_width = gl_label_line_get_line_width (object);
line_color = gl_label_line_get_line_color (object);
- gnome_print_moveto (pi->pc, x, y);
- gnome_print_lineto (pi->pc, x + w, y + h);
+ gnome_print_moveto (pi->pc, 0.0, 0.0);
+ gnome_print_lineto (pi->pc, w, h);
gnome_print_setrgbcolor (pi->pc,
GL_COLOR_F_RED (line_color),
GL_COLOR_F_GREEN (line_color),
draw_ellipse_object (PrintInfo *pi,
glLabelEllipse *object)
{
- gdouble x, y, x0, y0, rx, ry, w, h;
+ gdouble x0, y0, rx, ry, w, h;
gdouble line_width;
guint line_color, fill_color;
gl_debug (DEBUG_PRINT, "START");
- gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
line_width = gl_label_ellipse_get_line_width (object);
line_color = gl_label_ellipse_get_line_color (object);
rx = w / 2.0;
ry = h / 2.0;
- x0 = x + rx;
- y0 = y + ry;
+ x0 = rx;
+ y0 = ry;
/* Paint fill color */
create_ellipse_path (pi->pc, x0, y0, rx, ry);
draw_image_object (PrintInfo *pi,
glLabelImage *object)
{
- gdouble x, y, w, h;
+ gdouble w, h;
const GdkPixbuf *pixbuf;
guchar *image_data;
gint image_w, image_h, image_stride;
gl_debug (DEBUG_PRINT, "START");
- gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
pixbuf = gl_label_image_get_pixbuf (object);
image_alpha_flag = gdk_pixbuf_get_has_alpha(pixbuf);
gnome_print_gsave (pi->pc);
- gnome_print_translate (pi->pc, x, y+h);
+ gnome_print_translate (pi->pc, 0.0, h);
gnome_print_scale (pi->pc, w, -h);
if (image_alpha_flag) {
ret = gnome_print_rgbaimage (pi->pc, image_data,
glBarcodeLine *line;
glBarcodeChar *bchar;
GList *li;
- gdouble x, y, y_offset;
+ gdouble y_offset;
GnomeFont *font;
gchar *text, *cstring;
glTextNode *text_node;
gl_debug (DEBUG_PRINT, "START");
- gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
text_node = gl_label_barcode_get_data (object);
gl_label_barcode_get_props (object,
&style, &text_flag, &color, &scale);
GL_COLOR_F_ALPHA (color));
y_offset = 12.0 - gnome_font_get_descender (font);
- gnome_print_moveto (pi->pc, x, y + y_offset);
+ gnome_print_moveto (pi->pc, 0.0, y_offset);
gnome_print_gsave (pi->pc);
gnome_print_scale (pi->pc, 1.0, -1.0);
for (li = gbc->lines; li != NULL; li = li->next) {
line = (glBarcodeLine *) li->data;
- gnome_print_moveto (pi->pc, x + line->x, y + line->y);
- gnome_print_lineto (pi->pc, x + line->x,
- y + line->y + line->length);
+ gnome_print_moveto (pi->pc, line->x, line->y);
+ gnome_print_lineto (pi->pc, line->x, line->y + line->length);
gnome_print_setrgbcolor (pi->pc,
GL_COLOR_F_RED (color),
GL_COLOR_F_GREEN (color),
y_offset =
bchar->y + bchar->fsize -
gnome_font_get_descender (font);
- gnome_print_moveto (pi->pc, x + bchar->x, y + y_offset);
+ gnome_print_moveto (pi->pc, bchar->x, y_offset);
cstring = g_strdup_printf ("%c", bchar->c);
gnome_print_gsave (pi->pc);
}
}
+/*****************************************************************************/
+/* Flip objects horizontally callback. */
+/*****************************************************************************/
+void
+gl_tools_flip_objects_horiz (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname)
+
+{
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_flip_selection_horiz (GL_VIEW(window->view));
+ }
+}
+
+/*****************************************************************************/
+/* Flip objects vertically callback. */
+/*****************************************************************************/
+void
+gl_tools_flip_objects_vert (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname)
+
+{
+ glWindow *window;
+
+ window = GL_WINDOW (user_data);
+
+ if (window->view != NULL) {
+ gl_view_flip_selection_vert (GL_VIEW(window->view));
+ }
+}
+
#include <bonobo/bonobo-ui-component.h>
-extern void gl_tools_arrow (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+G_BEGIN_DECLS
-extern void gl_tools_text (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_arrow (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_box (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_text (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_line (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_box (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_ellipse (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_line (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_image (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_ellipse (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_barcode (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_image (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_zoomin (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_barcode (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_zoomout (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_zoomin (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_zoom1to1 (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_zoomout (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_merge_properties (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_zoom1to1 (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_object_properties (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_merge_properties (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_raise_objects (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_object_properties (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
-extern void gl_tools_lower_objects (BonoboUIComponent *uic,
- gpointer user_data,
- const gchar* verbname);
+void gl_tools_raise_objects (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
+
+void gl_tools_lower_objects (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
+
+void gl_tools_flip_objects_horiz (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
+
+void gl_tools_flip_objects_vert (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname);
+
+G_END_DECLS
#endif
draw_barcode (glViewBarcode *view_barcode)
{
glLabelObject *object;
- GnomeCanvasItem *group, *item;
+ GnomeCanvasItem *item;
glTextNode *text_node;
glBarcodeStyle style;
gboolean text_flag;
digits = gl_text_node_expand (text_node, NULL);
}
- /* get parent item/group to render to. */
- group = gl_view_object_get_group (GL_VIEW_OBJECT(view_barcode));
-
/* remove previous items from group. */
for (li = view_barcode->private->item_list; li!=NULL; li = li->next) {
gl_debug (DEBUG_VIEW, "in loop");
strlen
(cstring));
y_offset = 10.0 - gnome_font_get_descender (font);
- item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
- gl_canvas_hacktext_get_type (),
- "x", 0.0,
- "y", y_offset,
- "glyphlist", glyphlist, NULL);
+ item = gl_view_object_item_new (GL_VIEW_OBJECT(view_barcode),
+ gl_canvas_hacktext_get_type (),
+ "x", 0.0,
+ "y", y_offset,
+ "glyphlist", glyphlist, NULL);
view_barcode->private->item_list =
g_list_prepend (view_barcode->private->item_list, item);
points->coords[2] = line->x;
points->coords[3] = line->y + line->length;
- item =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
- gnome_canvas_line_get_type
- (), "points", points,
- "width_units", line->width,
- "fill_color_rgba", color,
- NULL);
+ item = gl_view_object_item_new (GL_VIEW_OBJECT(view_barcode),
+ gnome_canvas_line_get_type (),
+ "points", points,
+ "width_units", line->width,
+ "fill_color_rgba", color,
+ NULL);
view_barcode->private->item_list =
g_list_prepend (view_barcode->private->item_list, item);
}
1);
y_offset =
bchar->fsize - gnome_font_get_descender (font);
- item =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
- gnome_canvas_hacktext_get_type
- (), "x", bchar->x, "y",
- bchar->y + y_offset,
- "glyphlist", glyphlist,
- NULL);
+ item = gl_view_object_item_new (GL_VIEW_OBJECT(view_barcode),
+ gnome_canvas_hacktext_get_type (),
+ "x", bchar->x,
+ "y", bchar->y + y_offset,
+ "glyphlist", glyphlist,
+ NULL);
view_barcode->private->item_list =
g_list_prepend (view_barcode->private->item_list, item);
glView *view)
{
glViewBox *view_box;
- GnomeCanvasItem *group;
gdouble line_width;
guint line_color, fill_color;
gdouble w, h;
fill_color = gl_label_box_get_fill_color(object);
/* Create analogous canvas item. */
- group = gl_view_object_get_group (GL_VIEW_OBJECT(view_box));
view_box->private->item =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
- gnome_canvas_rect_get_type (),
- "x1", 0.0,
- "y1", 0.0,
- "x2", w + DELTA,
- "y2", h + DELTA,
- "width_units", line_width,
- "outline_color_rgba", line_color,
- "fill_color_rgba", fill_color,
- NULL);
+ gl_view_object_item_new (GL_VIEW_OBJECT(view_box),
+ gnome_canvas_rect_get_type (),
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", w + DELTA,
+ "y2", h + DELTA,
+ "width_units", line_width,
+ "outline_color_rgba", line_color,
+ "fill_color_rgba", fill_color,
+ NULL);
g_signal_connect (G_OBJECT (object), "changed",
G_CALLBACK (update_view_box_cb), view_box);
glView *view)
{
glViewEllipse *view_ellipse;
- GnomeCanvasItem *group;
gdouble line_width;
guint line_color, fill_color;
gdouble w, h;
fill_color = gl_label_ellipse_get_fill_color(object);
/* Create analogous canvas item. */
- group = gl_view_object_get_group (GL_VIEW_OBJECT(view_ellipse));
view_ellipse->private->item =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
- gnome_canvas_ellipse_get_type (),
- "x1", 0.0,
- "y1", 0.0,
- "x2", w + DELTA,
- "y2", h + DELTA,
- "width_units", line_width,
- "outline_color_rgba", line_color,
- "fill_color_rgba", fill_color,
- NULL);
+ gl_view_object_item_new (GL_VIEW_OBJECT(view_ellipse),
+ gnome_canvas_ellipse_get_type (),
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", w + DELTA,
+ "y2", h + DELTA,
+ "width_units", line_width,
+ "outline_color_rgba", line_color,
+ "fill_color_rgba", fill_color,
+ NULL);
g_signal_connect (G_OBJECT (object), "changed",
G_CALLBACK (update_view_ellipse_cb), view_ellipse);
glView *view)
{
glViewImage *view_image;
- GnomeCanvasItem *group;
const GdkPixbuf *pixbuf;
gdouble w, h;
GtkMenu *menu;
pixbuf = gl_label_image_get_pixbuf(object);
/* Create analogous canvas item. */
- group = gl_view_object_get_group (GL_VIEW_OBJECT(view_image));
view_image->private->item =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
- gnome_canvas_pixbuf_get_type (),
- "x", 0.0,
- "y", 0.0,
- "width_set", TRUE,
- "height_set", TRUE,
- "width", w,
- "height", h,
- "pixbuf", pixbuf,
- NULL);
+ gl_view_object_item_new (GL_VIEW_OBJECT(view_image),
+ gnome_canvas_pixbuf_get_type (),
+ "x", 0.0,
+ "y", 0.0,
+ "width_set", TRUE,
+ "height_set", TRUE,
+ "width", w,
+ "height", h,
+ "pixbuf", pixbuf,
+ NULL);
g_signal_connect (G_OBJECT (object), "changed",
G_CALLBACK (update_view_image_cb), view_image);
glView *view)
{
glViewLine *view_line;
- GnomeCanvasItem *group;
gdouble line_width;
guint line_color;
gdouble w, h;
line_color = gl_label_line_get_line_color(object);
/* Create analogous canvas item. */
- group = gl_view_object_get_group (GL_VIEW_OBJECT(view_line));
-
points = gnome_canvas_points_new (2);
points->coords[0] = 0.0;
points->coords[1] = 0.0;
points->coords[2] = w;
points->coords[3] = h;
view_line->private->item =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
- gnome_canvas_line_get_type (),
- "points", points,
- "width_units", line_width,
- "fill_color_rgba", line_color,
- NULL);
+ gl_view_object_item_new (GL_VIEW_OBJECT(view_line),
+ gnome_canvas_line_get_type (),
+ "points", points,
+ "width_units", line_width,
+ "fill_color_rgba", line_color,
+ NULL);
gnome_canvas_points_free (points);
g_signal_connect (G_OBJECT (object), "changed",
#include <glib.h>
#include "view-object.h"
+#include "libart_lgpl/libart.h"
#include "debug.h"
GnomeCanvasItem *group;
GnomeCanvasItem *highlight;
+ gdouble affine[6];
+
GtkWidget *menu;
GtkWidget *property_dialog;
/* Private function prototypes. */
/*========================================================*/
-static void gl_view_object_class_init (glViewObjectClass *klass);
-static void gl_view_object_instance_init (glViewObject *view_object);
-static void gl_view_object_finalize (GObject *object);
+static void gl_view_object_class_init (glViewObjectClass *klass);
+static void gl_view_object_instance_init (glViewObject *view_object);
+static void gl_view_object_finalize (GObject *object);
+
+static GtkMenu *new_menu (glViewObject *view_object);
+
+static void object_moved_cb (glLabelObject *object,
+ gdouble x,
+ gdouble y,
+ glViewObject *view_object);
-static GtkMenu *new_menu (glViewObject *view_object);
+static void raise_object_cb (GtkWidget *widget,
+ glViewObject *view_object);
+
+static void lower_object_cb (GtkWidget *widget,
+ glViewObject *view_object);
+
+static void flip_rotate_object_cb (GtkWidget *widget,
+ glLabelObjectFlip flip,
+ gdouble rotate_degs,
+ glViewObject *view_object);
-static void object_moved_cb (glLabelObject *object,
- gdouble x, gdouble y,
- glViewObject *view_object);
-static void raise_object_cb (GtkWidget * widget, glViewObject *view_object);
-static void lower_object_cb (GtkWidget * widget, glViewObject *view_object);
\f
/*****************************************************************************/
{
GnomeCanvas *canvas;
GnomeCanvasGroup *root;
- gdouble x, y;
+ gdouble x, y, w, h;
+ glLabelObjectFlip flip;
+ gdouble a[6];
gl_debug (DEBUG_VIEW, "START");
view_object->private->object = object;
gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y);
+ gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h);
/* create canvas group to contain items representing object */
canvas = GNOME_CANVAS (view_object->private->view->canvas);
"y", y,
NULL);
+ /* create affine to handle flipping and rotation transformations */
+ art_affine_identity (view_object->private->affine);
+#if 1
+ /* Apply appropriate flipping */
+ flip = gl_label_object_get_flip (object);
+ g_print ("Flip = %d\n", flip);
+ if ( flip & GL_LABEL_OBJECT_FLIP_HORIZ ) {
+ art_affine_translate (a, -w, 0.0);
+ art_affine_multiply (view_object->private->affine,
+ view_object->private->affine, a);
+ art_affine_scale (a, -1.0, 1.0);
+ art_affine_multiply (view_object->private->affine,
+ view_object->private->affine, a);
+ }
+ if ( flip & GL_LABEL_OBJECT_FLIP_VERT ) {
+ art_affine_translate (a, 0.0, -h);
+ art_affine_multiply (view_object->private->affine,
+ view_object->private->affine, a);
+ art_affine_scale (a, 1.0, -1.0);
+ art_affine_multiply (view_object->private->affine,
+ view_object->private->affine, a);
+ }
+#endif
+
/* Create appropriate selection highlight canvas item. */
view_object->private->highlight =
gl_view_highlight_new (view_object, style);
G_CALLBACK (lower_object_cb),
view_object);
+ g_signal_connect (G_OBJECT (object), "flip_rotate",
+ G_CALLBACK (flip_rotate_object_cb),
+ view_object);
+
g_signal_connect (G_OBJECT (view_object->private->group), "event",
G_CALLBACK (gl_view_item_event_handler),
view_object);
return view_object->private->group;
}
+/*****************************************************************************/
+/* Create canvas item for this object. */
+/*****************************************************************************/
+GnomeCanvasItem *
+gl_view_object_item_new (glViewObject *view_object,
+ GType type,
+ const gchar *first_arg_name,
+ ...)
+{
+ GnomeCanvasItem *item;
+ va_list args;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_val_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object), NULL);
+
+ item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(view_object->private->group),
+ type, NULL);
+
+ va_start (args, first_arg_name);
+ gnome_canvas_item_set_valist (item, first_arg_name, args);
+ va_end (args);
+
+ g_print ("Affine = {%f, %f, %f, %f, %f, %f}\n",
+ view_object->private->affine[0],
+ view_object->private->affine[1],
+ view_object->private->affine[2],
+ view_object->private->affine[3],
+ view_object->private->affine[4],
+ view_object->private->affine[5]);
+
+#if 0
+ gnome_canvas_item_affine_absolute (item, view_object->private->affine);
+#endif
+
+ gl_debug (DEBUG_VIEW, "END");
+
+ return item;
+}
+
/*****************************************************************************/
/* Return dialog for controlling/viewing object properties. */
/*****************************************************************************/
{
gl_debug (DEBUG_VIEW, "START");
- g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object));
+ g_return_val_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object), NULL);
gl_debug (DEBUG_VIEW, "END");
{
gl_debug (DEBUG_VIEW, "START");
- g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object));
+ g_return_val_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object), NULL);
gl_debug (DEBUG_VIEW, "END");
/*---------------------------------------------------------------------------*/
static void
object_moved_cb (glLabelObject *object,
- gdouble dx,
- gdouble dy,
- glViewObject *view_object)
+ gdouble dx,
+ gdouble dy,
+ glViewObject *view_object)
{
GnomeCanvasItem *item, *highlight;
/* PRIVATE. raise item to front callback. */
/*---------------------------------------------------------------------------*/
static void
-raise_object_cb (GtkWidget * widget,
+raise_object_cb (GtkWidget *widget,
glViewObject *view_object)
{
glLabelObject *object;
/* PRIVATE. lower item to back callback. */
/*---------------------------------------------------------------------------*/
static void
-lower_object_cb (GtkWidget * widget,
+lower_object_cb (GtkWidget *widget,
glViewObject *view_object)
{
glLabelObject *object;
gl_debug (DEBUG_VIEW, "END");
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Flip/rotate object callback. */
+/*---------------------------------------------------------------------------*/
+static void
+flip_rotate_object_cb (GtkWidget *widget,
+ glLabelObjectFlip flip,
+ gdouble rotate_degs,
+ glViewObject *view_object)
+{
+ glLabelObject *object;
+ gdouble a[6];
+ gdouble w, h;
+ GList *p, *item_list;
+ GnomeCanvasItem *item;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ gl_label_object_get_size (view_object->private->object, &w, &h);
+
+ /* Reset to identity affine */
+ art_affine_identity (view_object->private->affine);
+
+ /* Apply appropriate flipping */
+ if ( flip & GL_LABEL_OBJECT_FLIP_HORIZ ) {
+ art_affine_translate (a, -w, 0.0);
+ art_affine_multiply (view_object->private->affine, view_object->private->affine, a);
+ art_affine_scale (a, -1.0, 1.0);
+ art_affine_multiply (view_object->private->affine,
+ view_object->private->affine, a);
+ }
+ if ( flip & GL_LABEL_OBJECT_FLIP_VERT ) {
+ art_affine_translate (a, 0.0, -h);
+ art_affine_multiply (view_object->private->affine,
+ view_object->private->affine, a);
+ art_affine_scale (a, 1.0, -1.0);
+ art_affine_multiply (view_object->private->affine,
+ view_object->private->affine, a);
+ }
+
+#if 0
+ /* Apply newly constructed affine */
+ item_list = GNOME_CANVAS_GROUP(view_object->private->group)->item_list;
+ for ( p=item_list; p != NULL; p=p->next) {
+ item = GNOME_CANVAS_ITEM(p->data);
+ gnome_canvas_item_affine_absolute (item, view_object->private->affine);
+ }
+#endif
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
/*****************************************************************************/
/* Select object. */
/*****************************************************************************/
GnomeCanvasItem *gl_view_object_get_group (glViewObject *view_object);
+GnomeCanvasItem *gl_view_object_item_new (glViewObject *view_object,
+ GType type,
+ const gchar *first_arg_name,
+ ...);
+
GtkMenu *gl_view_object_get_menu (glViewObject *view_object);
void gl_view_object_update_highlight (glViewObject *view_object);
update_view_text_cb (glLabelObject *object,
glViewText *view_text)
{
- glView *view;
-
gl_debug (DEBUG_VIEW, "START");
- view = gl_view_object_get_view (GL_VIEW_OBJECT(view_text));
-
/* Adjust appearance of analogous canvas item. */
draw_hacktext (view_text);
draw_hacktext (glViewText *view_text)
{
glLabelObject *object;
- GnomeCanvasItem *group, *item;
+ GnomeCanvasItem *item;
GList *lines;
gchar *text;
gchar *font_family;
text = gl_text_node_lines_expand (lines, NULL);
line = g_strsplit (text, "\n", -1);
- /* get parent item/group to render to. */
- group = gl_view_object_get_group (GL_VIEW_OBJECT(view_text));
-
/* remove previous items from group. */
for (li = view_text->private->item_list; li != NULL; li = li->next) {
gl_debug (DEBUG_VIEW, "in loop");
y_offset =
(i + 1) * font_size + gnome_font_get_descender (font);
- item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group),
- gl_canvas_hacktext_get_type (),
- "x", x_offset,
- "y", y_offset,
- "glyphlist", glyphlist, NULL);
+ item = gl_view_object_item_new (GL_VIEW_OBJECT(view_text),
+ gl_canvas_hacktext_get_type (),
+ "x", x_offset,
+ "y", y_offset,
+ "glyphlist", glyphlist, NULL);
view_text->private->item_list =
g_list_prepend (view_text->private->item_list, item);
gl_debug (DEBUG_VIEW, "END");
}
+/*****************************************************************************/
+/* Flip selected objects horizontally. */
+/*****************************************************************************/
+void
+gl_view_flip_selection_horiz (glView *view)
+{
+ GList *p;
+ glViewObject *view_object;
+ glLabelObject *label_object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+ view_object = GL_VIEW_OBJECT (p->data);
+ label_object = gl_view_object_get_object (view_object);
+ gl_label_object_flip_horiz (label_object);
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
+/*****************************************************************************/
+/* Flip selected objects vertically. */
+/*****************************************************************************/
+void
+gl_view_flip_selection_vert (glView *view)
+{
+ GList *p;
+ glViewObject *view_object;
+ glLabelObject *label_object;
+
+ gl_debug (DEBUG_VIEW, "START");
+
+ g_return_if_fail (GL_IS_VIEW (view));
+
+ for (p = view->selected_object_list; p != NULL; p = p->next) {
+ view_object = GL_VIEW_OBJECT (p->data);
+ label_object = gl_view_object_get_object (view_object);
+ gl_label_object_flip_vert (label_object);
+ }
+
+ gl_debug (DEBUG_VIEW, "END");
+}
+
/*****************************************************************************/
/* "Cut" selected items and place in clipboard selections. */
/*****************************************************************************/
G_BEGIN_DECLS
-guint gl_view_get_type (void);
+guint gl_view_get_type (void);
-GtkWidget *gl_view_new (glLabel *label);
+GtkWidget *gl_view_new (glLabel *label);
-void gl_view_raise_fg (glView *view);
+void gl_view_raise_fg (glView *view);
-void gl_view_arrow_mode (glView *view);
+void gl_view_arrow_mode (glView *view);
-void gl_view_object_create_mode (glView *view,
- glLabelObjectType type);
+void gl_view_object_create_mode (glView *view,
+ glLabelObjectType type);
-void gl_view_select_object (glView *view,
- glViewObject *view_object);
+void gl_view_select_object (glView *view,
+ glViewObject *view_object);
-void gl_view_unselect_object (glView *view,
- glViewObject *view_object);
+void gl_view_unselect_object (glView *view,
+ glViewObject *view_object);
-void gl_view_select_all (glView *view);
+void gl_view_select_all (glView *view);
-void gl_view_unselect_all (glView *view);
+void gl_view_unselect_all (glView *view);
-void gl_view_select_region (glView *view,
- gdouble x1,
- gdouble y1,
- gdouble x2,
- gdouble y2);
+void gl_view_select_region (glView *view,
+ gdouble x1,
+ gdouble y1,
+ gdouble x2,
+ gdouble y2);
-gboolean gl_view_is_selection_empty (glView *view);
+gboolean gl_view_is_selection_empty (glView *view);
-gboolean gl_view_is_selection_atomic(glView *view);
+gboolean gl_view_is_selection_atomic (glView *view);
-void gl_view_delete_selection (glView *view);
+void gl_view_delete_selection (glView *view);
-void gl_view_edit_object_props (glView *view);
+void gl_view_edit_object_props (glView *view);
-void gl_view_raise_selection (glView *view);
+void gl_view_raise_selection (glView *view);
-void gl_view_lower_selection (glView *view);
+void gl_view_lower_selection (glView *view);
-void gl_view_cut (glView *view);
+void gl_view_flip_selection_horiz (glView *view);
-void gl_view_copy (glView *view);
+void gl_view_flip_selection_vert (glView *view);
-void gl_view_paste (glView *view);
+void gl_view_cut (glView *view);
+void gl_view_copy (glView *view);
-void gl_view_zoom_in (glView *view);
+void gl_view_paste (glView *view);
-void gl_view_zoom_out (glView *view);
-void gl_view_set_zoom (glView *view,
- gdouble scale);
+void gl_view_zoom_in (glView *view);
-gdouble gl_view_get_zoom (glView *view);
+void gl_view_zoom_out (glView *view);
-gboolean gl_view_is_zoom_max (glView *view);
+void gl_view_set_zoom (glView *view,
+ gdouble scale);
-gboolean gl_view_is_zoom_min (glView *view);
+gdouble gl_view_get_zoom (glView *view);
+gboolean gl_view_is_zoom_max (glView *view);
-int gl_view_item_event_handler (GnomeCanvasItem *item,
- GdkEvent *event,
- glViewObject *view_object);
+gboolean gl_view_is_zoom_min (glView *view);
+
+
+int gl_view_item_event_handler (GnomeCanvasItem *item,
+ GdkEvent *event,
+ glViewObject *view_object);
G_END_DECLS
glLabelObject *object;
gdouble x, y;
gchar *type_string;
+ gchar *flip_string;
gl_debug (DEBUG_XML, "START");
gl_label_object_set_position (object, x, y);
+ flip_string = xmlGetProp (object_node, "flip");
+ if ( g_strcasecmp (flip_string, "None") == 0 ) {
+ gl_label_object_set_flip (object, GL_LABEL_OBJECT_FLIP_NONE);
+ } else if ( g_strcasecmp (flip_string, "Horiz") == 0 ) {
+ gl_label_object_set_flip (object, GL_LABEL_OBJECT_FLIP_HORIZ);
+ } else if ( g_strcasecmp (flip_string, "Vert") == 0 ) {
+ gl_label_object_set_flip (object, GL_LABEL_OBJECT_FLIP_VERT);
+ } else if ( g_strcasecmp (flip_string, "Both") == 0 ) {
+ gl_label_object_set_flip (object, GL_LABEL_OBJECT_FLIP_BOTH);
+ } else {
+ g_warning ("Unknown flip type \"%s\"", flip_string);
+ return;
+ }
+
gl_debug (DEBUG_XML, "END");
}
g_free (string);
xmlSetProp (object_node, "rotate", "0");
- xmlSetProp (object_node, "flip", "None");
+
+ switch (gl_label_object_get_flip (object)) {
+ case GL_LABEL_OBJECT_FLIP_NONE:
+ xmlSetProp (object_node, "flip", "None");
+ break;
+ case GL_LABEL_OBJECT_FLIP_HORIZ:
+ xmlSetProp (object_node, "flip", "Horiz");
+ break;
+ case GL_LABEL_OBJECT_FLIP_VERT:
+ xmlSetProp (object_node, "flip", "Vert");
+ break;
+ case GL_LABEL_OBJECT_FLIP_BOTH:
+ xmlSetProp (object_node, "flip", "Both");
+ break;
+ default:
+ g_assert_not_reached ();
+ }
if ( GL_IS_LABEL_TEXT(object) ) {
xml_create_text_props (object_node, ns, object);