From: Andrea Zagli Date: Sat, 23 Jun 2007 07:50:56 +0000 (+0000) Subject: Continued selection. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=bcb4411082ff6d76b2ecadf1f16936e25d3d8d09;p=reptool%2Fgreptool Continued selection. Managed page header/footer properties. git-svn-id: svn+ssh://saetta.homelinux.org/svn/greptool/trunk@7 76169498-11ee-428b-941f-28d7a79d5cb2 --- diff --git a/data/greptool/glade/greptool.glade b/data/greptool/glade/greptool.glade index 953d95c..375f442 100644 --- a/data/greptool/glade/greptool.glade +++ b/data/greptool/glade/greptool.glade @@ -98,7 +98,6 @@ gtk-cut True True - @@ -107,7 +106,6 @@ gtk-copy True True - @@ -116,7 +114,6 @@ gtk-paste True True - @@ -125,7 +122,6 @@ gtk-delete True True - @@ -149,6 +145,7 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK _All True + @@ -157,6 +154,7 @@ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK _None True + @@ -167,7 +165,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - _Properties + P_roperties True @@ -176,7 +174,7 @@ True - _Page + _Page... True @@ -184,7 +182,7 @@ True - _Report + _Report... True @@ -192,7 +190,7 @@ True - _Object + _Object... True @@ -201,6 +199,20 @@ + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Preferences... + True + + @@ -212,6 +224,14 @@ True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Grid + True + + True @@ -228,9 +248,8 @@ True - _XML + _XML... True - @@ -463,9 +482,15 @@ GDK_WINDOW_TYPE_HINT_DIALOG w_main GRepTool + 0.0.1 Copyright (C) 2007 Andrea Zagli Creates and manages RepTool report's definition files http://reptool.sourceforge.net + GRepTool 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 2 of the License, or (at your option) any later version. + +GRepTool 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 more details. + +You should have received a copy of the GNU General Public License along with Nautilus; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Andrea Zagli <azagli@inwind.it> translator-credits True @@ -510,40 +535,27 @@ 4 3 - - True - 0 - Provider - - - GTK_FILL - - - - - + True - 0 - Connection String + True + 1 + 2 1 2 - GTK_FILL - + True - 0 - SQL - 2 - 3 + 1 + 2 GTK_FILL - + GTK_FILL @@ -566,26 +578,39 @@ - + True + 0 + SQL - 1 - 2 + 2 + 3 GTK_FILL - GTK_FILL + - + True - True + 0 + Connection String - 1 - 2 1 2 + GTK_FILL + + + + + + True + 0 + Provider + + + GTK_FILL @@ -623,27 +648,19 @@ 3 3 - - True - 0 - Height - - - GTK_FILL - - - - - + True True - 1 1 10000 1 10 10 - 1 - 2 + True + 0 + True 1 2 + 1 + 2 + GTK_FILL @@ -661,18 +678,26 @@ - + True True - True - 0 - True + 1 1 10000 1 10 10 + 1 + 2 1 2 - 1 - 2 + + + + + + True + 0 + Height + + GTK_FILL @@ -719,27 +744,19 @@ 3 3 - - True - 0 - Height - - - GTK_FILL - - - - - + True True - 1 1 10000 1 10 10 - 1 - 2 + True + 0 + True 1 2 + 1 + 2 + GTK_FILL @@ -757,18 +774,26 @@ - + True True - True - 0 - True + 1 1 10000 1 10 10 + 1 + 2 1 2 - 1 - 2 + + + + + + True + 0 + Height + + GTK_FILL @@ -842,6 +867,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 3 GRepTool - Page Properties True 300 @@ -872,35 +898,32 @@ 3 3 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Width + A4 +Custom + - 1 - 2 - GTK_FILL - + 1 + 2 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 - Height + Type - 2 - 3 GTK_FILL - + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -910,11 +933,12 @@ 1 2 - 1 + 2 + 3 - + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -924,33 +948,35 @@ 1 2 - 2 - 3 + 1 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 - Type + Height + 2 + 3 GTK_FILL - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - A4 -Custom - + 0 + Width - 1 - 2 + 1 + 2 + GTK_FILL + @@ -993,27 +1019,73 @@ Custom 3 3 - + True + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Top + 0 0 10000 1 10 10 + 2 - GTK_FILL - + 1 + 2 + 3 + 4 - + True + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Right + 0 0 10000 1 10 10 + 2 + 1 + 2 + 2 + 3 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 0 10000 1 10 10 + 2 + + + 1 + 2 1 2 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 0 10000 1 10 10 + 2 + + + 1 + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Left + + + 3 + 4 GTK_FILL @@ -1033,21 +1105,79 @@ Custom - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 0 - Left + Right - 3 - 4 + 1 + 2 GTK_FILL - + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Top + + + GTK_FILL + + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Margins + True + + + label_item + + + + + False + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + GTK_SHADOW_NONE + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + 4 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Height + + + + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -1056,16 +1186,42 @@ Custom 1 - 2 + 4 - + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + On First Page + + + 1 + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + On Last Page + + + 2 + 3 + 1 + 2 + + + + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 0 10000 1 10 10 - 2 + 0 + True 1 @@ -1075,7 +1231,70 @@ Custom - + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + True + + + 3 + 4 + 1 + 2 + + + + + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Header + 0 + True + + + + label_item + + + + + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + GTK_SHADOW_NONE + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + 4 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Height + + + + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -1084,24 +1303,63 @@ Custom 1 - 2 - 2 - 3 + 4 - + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + On First Page + + + 1 + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + On Last Page + + + 2 + 3 + 1 + 2 + + + + True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 0 10000 1 10 10 - 2 + 0 + True 1 2 - 3 - 4 + 1 + 2 + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + True + + + 3 + 4 + 1 + 2 @@ -1109,11 +1367,14 @@ Custom - + True + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Margins - True + Footer + 0 + True + label_item @@ -1121,8 +1382,7 @@ Custom - False - 1 + 3 @@ -1162,7 +1422,7 @@ Custom False - 2 + 4 diff --git a/src/canvas.c b/src/canvas.c index 0923ce4..070e07b 100644 --- a/src/canvas.c +++ b/src/canvas.c @@ -50,6 +50,7 @@ struct _GRptCanvasPrivate GList *report_footer_objects; GList *page_footer_objects; + gboolean in_selection; gdouble sel_x_start; gdouble sel_y_start; @@ -116,6 +117,9 @@ grpt_canvas_class_init (GRptCanvasClass *klass) static void grpt_canvas_init (GRptCanvas *grpt_canvas) { + GRptCanvasPrivate *priv = GRPT_CANVAS_GET_PRIVATE (grpt_canvas); + + priv->in_selection = FALSE; } static void @@ -129,14 +133,10 @@ grpt_canvas_add_object (GRptCanvas *grpt_canvas, RptReportSection section, Tool GRptCanvasItem *item; RptPoint position; - RptSize size; position.x = x; position.y = y; - size.width = width; - size.height = height; - switch (tool) { case TOOL_LINE: @@ -144,15 +144,11 @@ grpt_canvas_add_object (GRptCanvas *grpt_canvas, RptReportSection section, Tool rpt_object = rpt_obj_line_new (get_new_object_name (priv->tool), position); rpt_report_add_object_to_section (priv->rpt_report, rpt_object, RPTREPORT_SECTION_BODY); - g_object_set (G_OBJECT (rpt_object), - "size", &size, - NULL); - item = grpt_canvas_line_new (priv->root, - x, y, - width, height, - RPT_OBJ_LINE (rpt_object), - NULL); + x, y, + width, height, + RPT_OBJ_LINE (rpt_object), + NULL); } break; @@ -162,15 +158,11 @@ grpt_canvas_add_object (GRptCanvas *grpt_canvas, RptReportSection section, Tool rpt_object = rpt_obj_rect_new (get_new_object_name (priv->tool), position); rpt_report_add_object_to_section (priv->rpt_report, rpt_object, RPTREPORT_SECTION_BODY); - g_object_set (G_OBJECT (rpt_object), - "size", &size, - NULL); - item = grpt_canvas_rect_new (priv->root, - x, y, - width, height, - RPT_OBJ_RECT (rpt_object), - NULL); + x, y, + width, height, + RPT_OBJ_RECT (rpt_object), + NULL); } break; @@ -198,16 +190,49 @@ grpt_canvas_on_button_press_event (GtkWidget *widget, { priv->tool = get_current_tool (); - priv->sel_x_start = event->x; - priv->sel_y_start = event->y; - - g_object_set (G_OBJECT (priv->selection), - "x", priv->sel_x_start, - "y", priv->sel_y_start, - "width", 0.0, - "height", 0.0, - "visibility", GOO_CANVAS_ITEM_VISIBLE, - NULL); + if (priv->tool == TOOL_SELECT) + { + /* moving selected items */ + GooCanvasItem *item = goo_canvas_get_item_at (GOO_CANVAS (priv->goo_canvas), + event->x, event->y, + FALSE); + if (item != NULL && item != priv->selection) + { + if (!grpt_canvas_item_is_selected (GRPT_CANVAS_ITEM (item))) + { + grpt_canvas_item_set_selected (GRPT_CANVAS_ITEM (item), TRUE); + } + } + else + { + priv->in_selection = TRUE; + priv->sel_x_start = event->x; + priv->sel_y_start = event->y; + + g_object_set (G_OBJECT (priv->selection), + "x", priv->sel_x_start, + "y", priv->sel_y_start, + "width", 0.0, + "height", 0.0, + "visibility", GOO_CANVAS_ITEM_VISIBLE, + NULL); + } + } + else + { + /* TO DO */ + priv->in_selection = TRUE; + priv->sel_x_start = event->x; + priv->sel_y_start = event->y; + + g_object_set (G_OBJECT (priv->selection), + "x", priv->sel_x_start, + "y", priv->sel_y_start, + "width", 0.0, + "height", 0.0, + "visibility", GOO_CANVAS_ITEM_VISIBLE, + NULL); + } } return FALSE; @@ -254,13 +279,16 @@ grpt_canvas_on_button_release_event (GtkWidget *widget, if (priv->tool != TOOL_SELECT) { - grpt_canvas_add_object ((GRptCanvas *)user_data, RPTREPORT_SECTION_BODY, priv->tool, x, y, width, height); + if (width != 0 || height != 0) + { + grpt_canvas_add_object ((GRptCanvas *)user_data, RPTREPORT_SECTION_BODY, priv->tool, x, y, width, height); + } } else { GooCanvasBounds bound; GList *objects; - GooCanvasItemSimple *item; + GooCanvasItem *item; bound.x1 = x; bound.y1 = y; @@ -276,14 +304,19 @@ grpt_canvas_on_button_release_event (GtkWidget *widget, } while (objects != NULL) { - item = (GooCanvasItemSimple *)objects->data; + item = (GooCanvasItem *)objects->data; - grpt_canvas_item_set_selected (GRPT_CANVAS_ITEM (item), TRUE); + if (item != priv->selection) + { + grpt_canvas_item_set_selected (GRPT_CANVAS_ITEM (item), TRUE); + } objects = g_list_next (objects); } g_list_free (objects); } + + priv->in_selection = FALSE; } return FALSE; @@ -291,8 +324,8 @@ grpt_canvas_on_button_release_event (GtkWidget *widget, static gboolean grpt_canvas_on_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event, - gpointer user_data) + GdkEventMotion *event, + gpointer user_data) { gint x; gint y; @@ -313,42 +346,71 @@ grpt_canvas_on_motion_notify_event (GtkWidget *widget, if (state & GDK_BUTTON1_MASK) { - gdouble width; - gdouble height; - - if (x < priv->sel_x_start) - { - g_object_set (G_OBJECT (priv->selection), - "x", (gdouble)x, - NULL); - width = priv->sel_x_start - x; - } - else - { - g_object_set (G_OBJECT (priv->selection), - "x", priv->sel_x_start, - NULL); - width = x - priv->sel_x_start; - } - if (y < priv->sel_y_start) + if (priv->in_selection) { + gdouble width; + gdouble height; + + if (x < priv->sel_x_start) + { + g_object_set (G_OBJECT (priv->selection), + "x", (gdouble)x, + NULL); + width = priv->sel_x_start - x; + } + else + { + g_object_set (G_OBJECT (priv->selection), + "x", priv->sel_x_start, + NULL); + width = x - priv->sel_x_start; + } + if (y < priv->sel_y_start) + { + g_object_set (G_OBJECT (priv->selection), + "y", (gdouble)y, + NULL); + height = priv->sel_y_start - y; + } + else + { + g_object_set (G_OBJECT (priv->selection), + "y", priv->sel_y_start, + NULL); + height = y - priv->sel_y_start; + } + g_object_set (G_OBJECT (priv->selection), - "y", (gdouble)y, + "width", width, + "height", height, NULL); - height = priv->sel_y_start - y; } else { - g_object_set (G_OBJECT (priv->selection), - "y", priv->sel_y_start, - NULL); - height = y - priv->sel_y_start; - } + /* moving selected items */ + GList *items; + GRptCanvasItem *item; + RptPoint *position; - g_object_set (G_OBJECT (priv->selection), - "width", width, - "height", height, - NULL); + items = grpt_canvas_get_selected_items ((GRptCanvas *)user_data); + if (items != NULL) + { + items = g_list_first (items); + } + while (items != NULL) + { + item = (GRptCanvasItem *)items->data; + + position = grpt_canvas_item_get_position (item); + + position->x += (x - position->x); + position->y += (y - position->y); + + grpt_canvas_item_set_position (item, *position); + + items = g_list_next (items); + } + } } return FALSE; @@ -499,23 +561,23 @@ grpt_canvas_select_section_all (GRptCanvas *grpt_canvas, RptReportSection sectio switch (section) { case RPTREPORT_SECTION_REPORT_HEADER: - objects = g_list_copy (priv->report_header_objects); + objects = priv->report_header_objects; break; case RPTREPORT_SECTION_PAGE_HEADER: - objects = g_list_copy (priv->page_header_objects); + objects = priv->page_header_objects; break; case RPTREPORT_SECTION_BODY: - objects = g_list_copy (priv->body_objects); + objects = priv->body_objects; break; case RPTREPORT_SECTION_REPORT_FOOTER: - objects = g_list_copy (priv->report_footer_objects); + objects = priv->report_footer_objects; break; case RPTREPORT_SECTION_PAGE_FOOTER: - objects = g_list_copy (priv->page_footer_objects); + objects = priv->page_footer_objects; break; } @@ -540,23 +602,23 @@ grpt_canvas_select_section_none (GRptCanvas *grpt_canvas, RptReportSection secti switch (section) { case RPTREPORT_SECTION_REPORT_HEADER: - objects = g_list_copy (priv->report_header_objects); + objects = priv->report_header_objects; break; case RPTREPORT_SECTION_PAGE_HEADER: - objects = g_list_copy (priv->page_header_objects); + objects = priv->page_header_objects; break; case RPTREPORT_SECTION_BODY: - objects = g_list_copy (priv->body_objects); + objects = priv->body_objects; break; case RPTREPORT_SECTION_REPORT_FOOTER: - objects = g_list_copy (priv->report_footer_objects); + objects = priv->report_footer_objects; break; case RPTREPORT_SECTION_PAGE_FOOTER: - objects = g_list_copy (priv->page_footer_objects); + objects = priv->page_footer_objects; break; } @@ -571,6 +633,69 @@ grpt_canvas_select_section_none (GRptCanvas *grpt_canvas, RptReportSection secti } } +GList +*grpt_canvas_get_selected_items (GRptCanvas *grpt_canvas) +{ + GList *ret = NULL; + + ret = g_list_concat (ret, grpt_canvas_get_section_selected_items (grpt_canvas, RPTREPORT_SECTION_REPORT_HEADER)); + ret = g_list_concat (ret, grpt_canvas_get_section_selected_items (grpt_canvas, RPTREPORT_SECTION_PAGE_HEADER)); + ret = g_list_concat (ret, grpt_canvas_get_section_selected_items (grpt_canvas, RPTREPORT_SECTION_BODY)); + ret = g_list_concat (ret, grpt_canvas_get_section_selected_items (grpt_canvas, RPTREPORT_SECTION_REPORT_FOOTER)); + ret = g_list_concat (ret, grpt_canvas_get_section_selected_items (grpt_canvas, RPTREPORT_SECTION_PAGE_FOOTER)); + + return ret; +} + +GList +*grpt_canvas_get_section_selected_items (GRptCanvas *grpt_canvas, + RptReportSection section) +{ + GList *objects = NULL; + GList *ret = NULL; + + GRptCanvasPrivate *priv = GRPT_CANVAS_GET_PRIVATE (grpt_canvas); + + switch (section) + { + case RPTREPORT_SECTION_REPORT_HEADER: + objects = priv->report_header_objects; + break; + + case RPTREPORT_SECTION_PAGE_HEADER: + objects = priv->page_header_objects; + break; + + case RPTREPORT_SECTION_BODY: + objects = priv->body_objects; + break; + + case RPTREPORT_SECTION_REPORT_FOOTER: + objects = priv->report_footer_objects; + break; + + case RPTREPORT_SECTION_PAGE_FOOTER: + objects = priv->page_footer_objects; + break; + } + + if (objects != NULL) + { + objects = g_list_first (objects); + } + while (objects != NULL) + { + if (grpt_canvas_item_is_selected ((GRptCanvasItem *)objects->data)) + { + ret = g_list_append (ret, objects->data); + } + + objects = g_list_next (objects); + } + + return ret; +} + void grpt_canvas_free (GRptCanvas *grpt_canvas) { diff --git a/src/canvas.h b/src/canvas.h index 2548c53..e138cb2 100644 --- a/src/canvas.h +++ b/src/canvas.h @@ -76,6 +76,10 @@ void grpt_canvas_select_section_all (GRptCanvas *grpt_canvas, void grpt_canvas_select_section_none (GRptCanvas *grpt_canvas, RptReportSection section); +GList *grpt_canvas_get_selected_items (GRptCanvas *grpt_canvas); +GList *grpt_canvas_get_section_selected_items (GRptCanvas *grpt_canvas, + RptReportSection section); + void grpt_canvas_free (GRptCanvas *grpt_canvas); diff --git a/src/canvasitem.c b/src/canvasitem.c index f43da85..862f143 100644 --- a/src/canvasitem.c +++ b/src/canvasitem.c @@ -40,6 +40,11 @@ static gboolean grpt_canvas_item_is_item_at (GooCanvasItemSimple *simple, typedef struct _GRptCanvasItemPrivate GRptCanvasItemPrivate; struct _GRptCanvasItemPrivate { + gdouble x; + gdouble y; + gdouble width; + gdouble height; + RptReportSection section; gboolean selected; @@ -91,10 +96,10 @@ grpt_canvas_item_init (GRptCanvasItem *grpt_canvas_item) { GRptCanvasItemPrivate *priv = GRPT_CANVAS_ITEM_GET_PRIVATE (grpt_canvas_item); - grpt_canvas_item->x = 0.0; - grpt_canvas_item->y = 0.0; - grpt_canvas_item->width = 0.0; - grpt_canvas_item->height = 0.0; + priv->x = 0.0; + priv->y = 0.0; + priv->width = 0.0; + priv->height = 0.0; priv->selected = FALSE; } @@ -104,16 +109,17 @@ GooCanvasItem { GooCanvasItem *item; GRptCanvasItem *grpt_canvas_item; + GRptCanvasItemPrivate *priv; + RptPoint position; + RptSize size; + const char *first_property; va_list var_args; item = g_object_new (GRPT_TYPE_CANVAS_ITEM, NULL); grpt_canvas_item = (GRptCanvasItem *)item; - grpt_canvas_item->x = x; - grpt_canvas_item->y = y; - grpt_canvas_item->width = width; - grpt_canvas_item->height = height; + priv = GRPT_CANVAS_ITEM_GET_PRIVATE (grpt_canvas_item); va_start (var_args, height); first_property = va_arg (var_args, char*); @@ -129,9 +135,89 @@ GooCanvasItem g_object_unref (item); } + position.x = x; + position.y = y; + grpt_canvas_item_set_position (grpt_canvas_item, position); + + size.width = width; + size.height = height; + grpt_canvas_item_set_size (grpt_canvas_item, size); + return item; } +RptPoint +*grpt_canvas_item_get_position (GRptCanvasItem *grpt_canvas_item) +{ + RptPoint *position = NULL; + RptObject *rpto; + + rpto = grpt_canvas_item_get_rpt_object (grpt_canvas_item); + + g_object_get (G_OBJECT (rpto), + "position", &position, + NULL); + + return position; +} + +void +grpt_canvas_item_set_position (GRptCanvasItem *grpt_canvas_item, RptPoint position) +{ + GRptCanvasItemPrivate *priv = GRPT_CANVAS_ITEM_GET_PRIVATE (grpt_canvas_item); + + GooCanvasItemSimple *simple = (GooCanvasItemSimple *)grpt_canvas_item; + + RptObject *rpto; + + priv->x = position.x; + priv->y = position.y; + + rpto = grpt_canvas_item_get_rpt_object (grpt_canvas_item); + + g_object_set (G_OBJECT (rpto), + "position", &position, + NULL); + + goo_canvas_item_simple_changed (simple, TRUE); +} + +RptSize +*grpt_canvas_item_get_size (GRptCanvasItem *grpt_canvas_item) +{ + RptSize *size = NULL; + RptObject *rpto; + + rpto = grpt_canvas_item_get_rpt_object (grpt_canvas_item); + + g_object_get (G_OBJECT (rpto), + "size", &size, + NULL); + + return size; +} + +void +grpt_canvas_item_set_size (GRptCanvasItem *grpt_canvas_item, RptSize size) +{ + GRptCanvasItemPrivate *priv = GRPT_CANVAS_ITEM_GET_PRIVATE (grpt_canvas_item); + + RptObject *rpto; + + GooCanvasItemSimple *simple = (GooCanvasItemSimple *)grpt_canvas_item; + + priv->width = size.width; + priv->height = size.height; + + rpto = grpt_canvas_item_get_rpt_object (grpt_canvas_item); + + g_object_set (G_OBJECT (rpto), + "size", &size, + NULL); + + goo_canvas_item_simple_changed (simple, TRUE); +} + RptObject *grpt_canvas_item_get_rpt_object (GRptCanvasItem *grpt_canvas_item) { @@ -174,18 +260,22 @@ grpt_canvas_item_set_selected (GRptCanvasItem *grpt_canvas_item, gboolean select { GRptCanvasItemPrivate *priv = GRPT_CANVAS_ITEM_GET_PRIVATE (grpt_canvas_item); + GooCanvasItemSimple *simple = (GooCanvasItemSimple *)grpt_canvas_item; + priv->selected = selected; + goo_canvas_request_redraw (simple->canvas, &simple->bounds); } static void grpt_canvas_item_update (GooCanvasItemSimple *simple, cairo_t *cr) { GRptCanvasItem *grpt_canvas_item = (GRptCanvasItem *)simple; + GRptCanvasItemPrivate *priv = GRPT_CANVAS_ITEM_GET_PRIVATE (grpt_canvas_item); - simple->bounds.x1 = grpt_canvas_item->x; - simple->bounds.y1 = grpt_canvas_item->y; - simple->bounds.x2 = grpt_canvas_item->x + grpt_canvas_item->width; - simple->bounds.y2 = grpt_canvas_item->y + grpt_canvas_item->height; + simple->bounds.x1 = priv->x; + simple->bounds.y1 = priv->y; + simple->bounds.x2 = priv->x + priv->width; + simple->bounds.y2 = priv->y + priv->height; } static void @@ -210,9 +300,10 @@ static gboolean grpt_canvas_item_is_item_at (GooCanvasItemSimple *simple, gdouble x, gdouble y, cairo_t *cr, gboolean is_pointer_event) { GRptCanvasItem *grpt_canvas_item = (GRptCanvasItem *)simple; + GRptCanvasItemPrivate *priv = GRPT_CANVAS_ITEM_GET_PRIVATE (grpt_canvas_item); - if (x < grpt_canvas_item->x || x > grpt_canvas_item->x + grpt_canvas_item->width - || y < grpt_canvas_item->y || y > grpt_canvas_item->y + grpt_canvas_item->height) + if (x < priv->x || x > priv->x + priv->width + || y < priv->y || y > priv->y + priv->height) { return FALSE; } diff --git a/src/canvasitem.h b/src/canvasitem.h index 7eeeec5..8fb0319 100644 --- a/src/canvasitem.h +++ b/src/canvasitem.h @@ -41,8 +41,6 @@ typedef struct _GRptCanvasItemClass GRptCanvasItemClass; struct _GRptCanvasItem { GooCanvasItemSimple parent; - - gdouble x, y, width, height; }; struct _GRptCanvasItemClass @@ -65,6 +63,12 @@ GooCanvasItem *grpt_canvas_item_new (GooCanvasItem *parent, gdouble height, ...); +RptPoint *grpt_canvas_item_get_position (GRptCanvasItem *grpt_canvas_item); +void grpt_canvas_item_set_position (GRptCanvasItem *grpt_canvas_item, RptPoint position); + +RptSize *grpt_canvas_item_get_size (GRptCanvasItem *grpt_canvas_item); +void grpt_canvas_item_set_size (GRptCanvasItem *grpt_canvas_item, RptSize size); + RptObject *grpt_canvas_item_get_rpt_object (GRptCanvasItem *grpt_canvas_item); RptReportSection grpt_canvas_item_get_section (GRptCanvasItem *grpt_canvas_item); diff --git a/src/canvasline.c b/src/canvasline.c index d8cddb9..e0106a5 100644 --- a/src/canvasline.c +++ b/src/canvasline.c @@ -90,15 +90,15 @@ GRptCanvasItem { GRptCanvasItem *item; GRptCanvasLine *grpt_canvas_line; + + RptPoint position; + RptSize size; + const char *first_property; va_list var_args; GRptCanvasLinePrivate *priv; item = g_object_new (GRPT_TYPE_CANVAS_LINE, NULL); - item->x = x; - item->y = y; - item->width = width; - item->height = height; grpt_canvas_line = (GRptCanvasLine *)item; @@ -119,14 +119,23 @@ GRptCanvasItem g_object_unref (item); } + position.x = x; + position.y = y; + grpt_canvas_item_set_position (item, position); + + size.width = width; + size.height = height; + grpt_canvas_item_set_size (item, size); + return item; } static void grpt_canvas_line_paint (GooCanvasItemSimple *simple, cairo_t *cr, const GooCanvasBounds *bounds) { - RptPoint from_p; - RptPoint to_p; + RptPoint *from_p; + RptPoint *to_p = (RptPoint *)g_new (RptPoint, 1); + RptSize *size; RptRotation *rotation = NULL; RptStroke *stroke = NULL; @@ -136,16 +145,16 @@ grpt_canvas_line_paint (GooCanvasItemSimple *simple, cairo_t *cr, const GooCanva GRptCanvasLinePrivate *priv = GRPT_CANVAS_LINE_GET_PRIVATE (grpt_canvas_line); - from_p.x = grpt_canvas_item->x; - from_p.y = grpt_canvas_item->y; - to_p.x = grpt_canvas_item->x + grpt_canvas_item->width; - to_p.y = grpt_canvas_item->y + grpt_canvas_item->height; - g_object_get (G_OBJECT (priv->rpt_object_line), + "position", &from_p, + "size", &size, "rotation", &rotation, "stroke", &stroke, NULL); + to_p->x = from_p->x + size->width; + to_p->y = from_p->y + size->height; + if (stroke != NULL) { /* TO DO */ @@ -175,8 +184,8 @@ grpt_canvas_line_paint (GooCanvasItemSimple *simple, cairo_t *cr, const GooCanva rpt_print_rotate (rpt_print, from_p, &size, rotation->angle);*/ } - cairo_move_to (cr, from_p.x, from_p.y); - cairo_line_to (cr, to_p.x, to_p.y); + cairo_move_to (cr, from_p->x, from_p->y); + cairo_line_to (cr, to_p->x, to_p->y); cairo_stroke (cr); if (stroke != NULL && stroke->style != NULL) diff --git a/src/canvasrect.c b/src/canvasrect.c index bc07561..a0e4137 100644 --- a/src/canvasrect.c +++ b/src/canvasrect.c @@ -76,8 +76,7 @@ grpt_canvas_rect_class_init (GRptCanvasRectClass *klass) g_type_class_add_private (object_class, sizeof (GRptCanvasRectPrivate)); - simple_class->simple_paint = grpt_canvas_rect_paint; - + canvas_item_class->paint = grpt_canvas_rect_paint; canvas_item_class->get_rpt_object = grpt_canvas_rect_get_rpt_object; } @@ -91,15 +90,15 @@ GRptCanvasItem { GRptCanvasItem *item; GRptCanvasRect *grpt_canvas_rect; + + RptPoint position; + RptSize size; + const char *first_property; va_list var_args; GRptCanvasRectPrivate *priv; item = g_object_new (GRPT_TYPE_CANVAS_RECT, NULL); - item->x = x; - item->y = y; - item->width = width; - item->height = height; grpt_canvas_rect = (GRptCanvasRect *)item; @@ -120,6 +119,14 @@ GRptCanvasItem g_object_unref (item); } + position.x = x; + position.y = y; + grpt_canvas_item_set_position (item, position); + + size.width = width; + size.height = height; + grpt_canvas_item_set_size (item, size); + return item; } diff --git a/src/canvasrect.h b/src/canvasrect.h index e03063a..9feedfd 100644 --- a/src/canvasrect.h +++ b/src/canvasrect.h @@ -52,12 +52,12 @@ struct _GRptCanvasRectClass GType grpt_canvas_rect_get_type (void) G_GNUC_CONST; GRptCanvasItem *grpt_canvas_rect_new (GooCanvasItem *parent, - gdouble x, - gdouble y, - gdouble width, - gdouble height, - RptObjRect *rpt_object_rect, - ...); + gdouble x, + gdouble y, + gdouble width, + gdouble height, + RptObjRect *rpt_object_rect, + ...); G_END_DECLS diff --git a/src/main.c b/src/main.c index c1029b8..68e579e 100644 --- a/src/main.c +++ b/src/main.c @@ -42,8 +42,11 @@ void report_on_canvas_object_removed (GRptCanvas *grpt_canvas, static gchar *report_filename; static RptReport *rpt_report; +static gint text_counter = 0; static gint line_counter = 0; static gint rect_counter = 0; +static gint ellipse_counter = 0; +static gint image_counter = 0; static GtkWidget *w; static GtkWidget *vbox; @@ -285,6 +288,20 @@ on_mnu_file_close_activate (GtkMenuItem *menuitem, gtk_window_set_title (GTK_WINDOW (w), "GRepTool"); } +void +on_mnu_edit_select_all_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + grpt_canvas_select_section_all (grpt_canvas, RPTREPORT_SECTION_BODY, FALSE); +} + +void +on_mnu_edit_select_none_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + grpt_canvas_select_section_none (grpt_canvas, RPTREPORT_SECTION_BODY); +} + void on_mnu_edit_report_properties_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -412,6 +429,10 @@ const gchar switch (tool) { + case TOOL_TEXT: + ret = g_strdup_printf ("text%d", ++text_counter); + break; + case TOOL_LINE: ret = g_strdup_printf ("line%d", ++line_counter); break; @@ -419,6 +440,14 @@ const gchar case TOOL_RECT: ret = g_strdup_printf ("rect%d", ++rect_counter); break; + + case TOOL_ELLIPSE: + ret = g_strdup_printf ("ellipse%d", ++ellipse_counter); + break; + + case TOOL_IMAGE: + ret = g_strdup_printf ("image%d", ++image_counter); + break; } return ret; diff --git a/src/page_properties.c b/src/page_properties.c index 6eb9a59..c227f0f 100644 --- a/src/page_properties.c +++ b/src/page_properties.c @@ -30,9 +30,17 @@ static GtkWidget *spn_margin_top; static GtkWidget *spn_margin_right; static GtkWidget *spn_margin_bottom; static GtkWidget *spn_margin_left; +static GtkWidget *chk_header; +static GtkWidget *spn_header_height; +static GtkWidget *chk_header_first_page; +static GtkWidget *chk_header_last_page; +static GtkWidget *chk_footer; +static GtkWidget *spn_footer_height; +static GtkWidget *chk_footer_first_page; +static GtkWidget *chk_footer_last_page; static void -page_properties_set_size_sesitivity () +page_properties_set_size_sensibility () { gchar *text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (cb_size_type)); gboolean sens = (text != NULL && strcmp (text, "Custom") == 0); @@ -41,6 +49,26 @@ page_properties_set_size_sesitivity () gtk_widget_set_sensitive (spn_width, sens); } +static void +page_properties_set_header_sensibility () +{ + gboolean sens = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_header)); + + gtk_widget_set_sensitive (spn_header_height, sens); + gtk_widget_set_sensitive (chk_header_first_page, sens); + gtk_widget_set_sensitive (chk_header_last_page, sens); +} + +static void +page_properties_set_footer_sensibility () +{ + gboolean sens = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_footer)); + + gtk_widget_set_sensitive (spn_footer_height, sens); + gtk_widget_set_sensitive (chk_footer_first_page, sens); + gtk_widget_set_sensitive (chk_footer_last_page, sens); +} + static void page_properties_load () { @@ -48,6 +76,7 @@ page_properties_load () gdouble right; gdouble bottom; gdouble left; + gdouble height; RptSize *size = rpt_report_get_page_size (rpt_report_); @@ -64,13 +93,49 @@ page_properties_load () gtk_spin_button_set_value (GTK_SPIN_BUTTON (spn_margin_top), right); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spn_margin_top), bottom); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spn_margin_top), left); + + height = rpt_report_get_section_height (rpt_report_, RPTREPORT_SECTION_PAGE_HEADER); + if (height >= 0) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chk_header), TRUE); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (spn_header_height), height); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chk_header_first_page), + rpt_report_get_page_header_first_page (rpt_report_)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chk_header_last_page), + rpt_report_get_page_header_last_page (rpt_report_)); + } + + height = rpt_report_get_section_height (rpt_report_, RPTREPORT_SECTION_PAGE_HEADER); + if (height >= 0) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chk_footer), TRUE); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (spn_footer_height), height); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chk_footer_first_page), + rpt_report_get_page_footer_first_page (rpt_report_)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chk_footer_last_page), + rpt_report_get_page_footer_last_page (rpt_report_)); + } } void page_properties_on_cb_size_type_changed (GtkComboBox *widget, gpointer user_data) { - page_properties_set_size_sesitivity (); + page_properties_set_size_sensibility (); +} + +void +page_properties_on_chk_header_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + page_properties_set_header_sensibility (); +} + +void +page_properties_on_chk_footer_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + page_properties_set_footer_sensibility (); } void @@ -97,6 +162,23 @@ page_properties_on_btn_ok_clicked (GtkButton *button, gtk_spin_button_get_value (GTK_SPIN_BUTTON (spn_margin_bottom)), gtk_spin_button_get_value (GTK_SPIN_BUTTON (spn_margin_left))); + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_header))) + { + rpt_report_set_section_height (rpt_report_, RPTREPORT_SECTION_PAGE_HEADER, + gtk_spin_button_get_value (GTK_SPIN_BUTTON (spn_header_height))); + rpt_report_set_page_header_first_last_page (rpt_report_, + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_header_first_page)), + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_header_last_page))); + } + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_footer))) + { + rpt_report_set_section_height (rpt_report_, RPTREPORT_SECTION_PAGE_HEADER, + gtk_spin_button_get_value (GTK_SPIN_BUTTON (spn_footer_height))); + rpt_report_set_page_header_first_last_page (rpt_report_, + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_footer_first_page)), + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_footer_last_page))); + } + gtk_widget_destroy (w_prop); } @@ -117,8 +199,19 @@ page_properties (RptReport *rpt_report) spn_margin_right = glade_xml_get_widget (gla, "spn_margin_right"); spn_margin_bottom = glade_xml_get_widget (gla, "spn_margin_bottom"); spn_margin_left = glade_xml_get_widget (gla, "spn_margin_left"); + chk_header = glade_xml_get_widget (gla, "chk_header"); + spn_header_height = glade_xml_get_widget (gla, "spn_header_height"); + chk_header_first_page = glade_xml_get_widget (gla, "chk_header_first_page"); + chk_header_last_page = glade_xml_get_widget (gla, "chk_header_last_page"); + chk_footer = glade_xml_get_widget (gla, "chk_footer"); + spn_footer_height = glade_xml_get_widget (gla, "spn_footer_height"); + chk_footer_first_page = glade_xml_get_widget (gla, "chk_footer_first_page"); + chk_footer_last_page = glade_xml_get_widget (gla, "chk_footer_last_page"); + + page_properties_set_size_sensibility (); + page_properties_set_header_sensibility (); + page_properties_set_footer_sensibility (); - page_properties_set_size_sesitivity (); page_properties_load (); gtk_widget_show_all (w_prop);