1 /* 2 * sheet.h 3 * 4 * 5 * Authors: 6 * Richard Hult <rhult@hem.passagen.se> 7 * Ricardo Markiewicz <rmarkie@fi.uba.ar> 8 * Andres de Barbara <adebarbara@fi.uba.ar> 9 * Marc Lorber <lorber.marc@wanadoo.fr> 10 * Guido Trentalancia <guido@trentalancia.com> 11 * 12 * Web page: https://ahoi.io/project/oregano 13 * 14 * Copyright (C) 1999-2001 Richard Hult 15 * Copyright (C) 2003,2004 Ricardo Markiewicz 16 * Copyright (C) 2009-2012 Marc Lorber 17 * Copyright (C) 2017 Guido Trentalancia 18 * 19 * This program is free software; you can redistribute it and/or 20 * modify it under the terms of the GNU General Public License as 21 * published by the Free Software Foundation; either version 2 of the 22 * License, or (at your option) any later version. 23 * 24 * This program is distributed in the hope that it will be useful, 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 * General Public License for more details. 28 * 29 * You should have received a copy of the GNU General Public 30 * License along with this program; if not, write to the 31 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 32 * Boston, MA 02110-1301, USA. 33 */ 34 35 #ifndef __SHEET_H 36 #define __SHEET_H 37 38 #include <goocanvas.h> 39 #include <gtk/gtk.h> 40 41 #include "grid.h" 42 43 #include "item-data.h" 44 45 // typedef to avoid circular dependency 46 typedef struct _SchematicView SchematicView; 47 48 // Allow about 200 pixels for the border of the sheet 49 #define SHEET_BORDER 200 50 51 typedef struct _Sheet Sheet; 52 typedef struct _SheetPriv SheetPriv; 53 typedef struct _SheetClass SheetClass; 54 typedef struct _SheetItem SheetItem; 55 56 #define TYPE_SHEET (sheet_get_type ()) 57 #define SHEET(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_SHEET, Sheet)) 58 #define SHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, TYPE_SHEET, SheetClass)) 59 #define IS_SHEET(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, TYPE_SHEET)) 60 61 typedef enum { 62 SHEET_STATE_NONE, 63 SHEET_STATE_DRAG_START, 64 SHEET_STATE_DRAG, 65 SHEET_STATE_FLOAT_START, 66 SHEET_STATE_FLOAT, 67 SHEET_STATE_WIRE, 68 SHEET_STATE_TEXTBOX_WAIT, 69 SHEET_STATE_TEXTBOX_START, 70 SHEET_STATE_TEXTBOX_CREATING 71 } SheetState; 72 73 struct _Sheet 74 { 75 GooCanvas parent_canvas; 76 SheetState state; 77 GooCanvasGroup *object_group; 78 79 Grid *grid; 80 SheetPriv *priv; 81 }; 82 83 struct _SheetClass 84 { 85 GooCanvasClass parent_class; 86 87 void (*selection_changed)(Sheet *sheet); 88 gint (*button_press)(Sheet *sheet, GdkEventButton *event); 89 void (*context_click)(Sheet *sheet, const char *name, gpointer data); 90 void (*cancel)(Sheet *sheet); 91 }; 92 93 GType sheet_get_type (void); 94 GtkWidget *sheet_new (const gdouble width, const gdouble height); 95 gboolean sheet_replace (SchematicView *sv); 96 void sheet_scroll_pixel (const Sheet *sheet, int dx, int dy); 97 void sheet_get_size_pixels (const Sheet *sheet, guint *width, guint *height); 98 gpointer sheet_get_first_selected_item (const Sheet *sheet); 99 void sheet_zoom_step (Sheet *sheet, const double rate); 100 void sheet_get_zoom (const Sheet *sheet, gdouble *zoom); 101 void sheet_delete_selected_items (const Sheet *sheet); 102 void sheet_rotate_selected_items (const Sheet *sheet); 103 void sheet_rotate_floating_items (const Sheet *sheet); 104 void sheet_reset_floating_items (const Sheet *sheet); 105 void sheet_remove_selected_object (const Sheet *sheet, SheetItem *item); 106 void sheet_prepend_selected_object (Sheet *sheet, SheetItem *item); 107 void sheet_remove_floating_object (const Sheet *sheet, SheetItem *item); 108 void sheet_prepend_floating_object (Sheet *sheet, SheetItem *item); 109 void sheet_connect_part_item_to_floating_group (Sheet *sheet, gpointer *sv); 110 void sheet_show_node_labels (Sheet *sheet, gboolean show); 111 void sheet_add_item (Sheet *sheet, SheetItem *item); 112 void sheet_stop_rubberband (Sheet *sheet, GdkEventButton *event); 113 void sheet_setup_rubberband (Sheet *sheet, GdkEventButton *event); 114 int sheet_event_callback (GtkWidget *widget, GdkEvent *event, Sheet *sheet); 115 void sheet_select_all (Sheet *sheet, gboolean select); 116 void sheet_rotate_selection (Sheet *sheet, gint angle); 117 void sheet_move_selection (Sheet *sheet, gdouble dx, gdouble dy); 118 void sheet_delete_selection (Sheet *sheet); 119 void sheet_release_selected_objects (Sheet *sheet); 120 GList *sheet_get_selection (Sheet *sheet); 121 void sheet_update_parts (Sheet *sheet); 122 void sheet_destroy_sheet_item (SheetItem *item, Sheet *sheet); 123 void sheet_rotate_ghosts (Sheet *sheet); 124 void sheet_flip_selection (Sheet *sheet, IDFlip direction); 125 void sheet_flip_ghosts (Sheet *sheet, IDFlip direction); 126 void sheet_clear_op_values (Sheet *sheet); 127 void sheet_provide_object_properties (Sheet *sheet); 128 void sheet_clear_ghosts (Sheet *sheet); 129 guint sheet_get_selected_objects_length (Sheet *sheet); 130 GList *sheet_get_floating_objects (Sheet *sheet); 131 void sheet_add_ghost_item (Sheet *sheet, ItemData *data); 132 GList *sheet_get_items (const Sheet *sheet); 133 void sheet_stop_create_wire (Sheet *sheet); 134 void sheet_initiate_create_wire (Sheet *sheet); 135 void sheet_connect_node_dots_to_signals (Sheet *sheet); 136 void sheet_remove_item_in_sheet (SheetItem *item, Sheet *sheet); 137 gboolean sheet_get_pointer_pixel (Sheet *sheet, gdouble *x, gdouble *y); 138 gboolean sheet_get_pointer (Sheet *sheet, gdouble *x, gdouble *y); 139 gboolean sheet_get_pointer_snapped (Sheet *sheet, gdouble *x, gdouble *y); 140 gboolean sheet_pointer_grab (Sheet *sheet, GdkEvent *event); 141 void sheet_pointer_ungrab (Sheet *sheet, GdkEvent *event); 142 gboolean sheet_keyboard_grab (Sheet *sheet, GdkEvent *event); 143 void sheet_keyboard_ungrab (Sheet *sheet, GdkEvent *event); 144 gboolean sheet_get_adjustments (const Sheet *sheet, GtkAdjustment **hadj, GtkAdjustment **vadj); 145 #endif 146