void GfxSquareBrush::drawStyle(GnomeCanvasItem *rb, GdkBitmap *stipple, GdkBitmap *stubble, const guint32 &black, const guint32 &white, const Coord ¤t) { GnomeCanvasPoints *pts = gnome_canvas_points_new(4); pts->coords[0] = current(0) - size; pts->coords[1] = current(1) + size; pts->coords[2] = current(0) - size; pts->coords[3] = current(1) - size; pts->coords[4] = current(0) + size; pts->coords[5] = current(1) - size; pts->coords[6] = current(0) + size; pts->coords[7] = current(1) + size; gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb), gnome_canvas_polygon_get_type(), "points", pts, "outline_color_rgba", black, "width_pixels", 0, "outline_stipple", stipple, NULL); gnome_canvas_item_new(GNOME_CANVAS_GROUP(rb), gnome_canvas_polygon_get_type(), "points", pts, "outline_color_rgba", white, "width_pixels", 0, "outline_stipple", stubble, NULL); }
/* Goes through all known links and checks whether there already exists * a corresponding canvas_link. If not, create it.*/ static gint check_new_link (link_id_t * link_id, link_t * link, GtkWidget * canvas) { canvas_link_t *new_canvas_link; GnomeCanvasGroup *group; GnomeCanvasPoints *points; guint i = 0; if (!g_tree_lookup (canvas_links, link_id)) { group = gnome_canvas_root (GNOME_CANVAS (canvas)); new_canvas_link = g_malloc (sizeof (canvas_link_t)); g_assert(new_canvas_link); new_canvas_link->canvas_link_id = *link_id; /* We set the lines position using groups positions */ points = gnome_canvas_points_new (3); for (; i <= 5; i++) points->coords[i] = 0.0; new_canvas_link->src_item = gnome_canvas_item_new (group, gnome_canvas_polygon_get_type (), "points", points, "fill_color", "tan", NULL); addref_canvas_obj(G_OBJECT (new_canvas_link->src_item)); new_canvas_link->dst_item = gnome_canvas_item_new (group, gnome_canvas_polygon_get_type (), "points", points, "fill_color", "tan", NULL); addref_canvas_obj(G_OBJECT (new_canvas_link->dst_item)); g_tree_insert (canvas_links, &new_canvas_link->canvas_link_id, new_canvas_link); gnome_canvas_item_lower_to_bottom (new_canvas_link->src_item); gnome_canvas_item_lower_to_bottom (new_canvas_link->dst_item); gnome_canvas_points_unref (points); g_signal_connect (G_OBJECT (new_canvas_link->src_item), "event", (GtkSignalFunc) link_item_event, new_canvas_link); g_signal_connect (G_OBJECT (new_canvas_link->dst_item), "event", (GtkSignalFunc) link_item_event, new_canvas_link); } return FALSE; } /* check_new_link */
void start_selectregion(GdkEvent *event) { double pt[2]; reset_selection(); ui.cur_item_type = ITEM_SELECTREGION; ui.selection = g_new(struct Selection, 1); ui.selection->type = ITEM_SELECTREGION; ui.selection->items = NULL; ui.selection->layer = ui.cur_layer; get_pointer_coords(event, pt); ui.selection->bbox.left = ui.selection->bbox.right = pt[0]; ui.selection->bbox.top = ui.selection->bbox.bottom = pt[1]; realloc_cur_path(1); ui.cur_path.num_points = 1; ui.cur_path.coords[0] = ui.cur_path.coords[2] = pt[0]; ui.cur_path.coords[1] = ui.cur_path.coords[3] = pt[1]; ui.selection->canvas_item = gnome_canvas_item_new(ui.cur_layer->group, gnome_canvas_polygon_get_type(), "width-pixels", 1, "outline-color-rgba", 0x000000ff, "fill-color-rgba", 0x80808040, NULL); make_dashed(ui.selection->canvas_item); update_cursor(); }
void ui_common_study_preferences_widgets(GtkWidget * packing_table, gint table_row, GtkWidget ** proi_width_spin, GnomeCanvasItem ** proi_item, #ifdef AMIDE_LIBGNOMECANVAS_AA GtkWidget ** proi_transparency_spin, #else GtkWidget ** pline_style_menu, GtkWidget ** pfill_roi_button, #endif GtkWidget ** playout_button1, GtkWidget ** playout_button2, GtkWidget ** ppanel_layout_button1, GtkWidget ** ppanel_layout_button2, GtkWidget ** ppanel_layout_button3, GtkWidget ** pmaintain_size_button, GtkWidget ** ptarget_size_spin) { GtkWidget * label; GtkObject * adjustment; GtkWidget * roi_canvas; GnomeCanvasPoints * roi_line_points; GtkWidget * image; GtkWidget * hseparator; #ifndef AMIDE_LIBGNOMECANVAS_AA GdkLineStyle i_line_style; #endif /* widgets to change the roi's size */ label = gtk_label_new(_("ROI Width (pixels)")); gtk_table_attach(GTK_TABLE(packing_table), label, 0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(label); adjustment = gtk_adjustment_new(AMITK_PREFERENCES_MIN_ROI_WIDTH, AMITK_PREFERENCES_MIN_ROI_WIDTH, AMITK_PREFERENCES_MAX_ROI_WIDTH,1.0, 1.0, 0.0); *proi_width_spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1.0, 0); gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(*proi_width_spin),FALSE); gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(*proi_width_spin), TRUE); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(*proi_width_spin), TRUE); gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(*proi_width_spin), GTK_UPDATE_ALWAYS); gtk_table_attach(GTK_TABLE(packing_table), *proi_width_spin, 1,2, table_row, table_row+1, GTK_FILL, 0, X_PADDING, Y_PADDING); gtk_widget_show(*proi_width_spin); /* a little canvas indicator thingie to show the user who the new preferences will look */ #ifdef AMIDE_LIBGNOMECANVAS_AA roi_canvas = gnome_canvas_new_aa(); #else roi_canvas = gnome_canvas_new(); #endif gtk_widget_set_size_request(roi_canvas, 100, 100); gnome_canvas_set_scroll_region(GNOME_CANVAS(roi_canvas), 0.0, 0.0, 100.0, 100.0); gtk_table_attach(GTK_TABLE(packing_table), roi_canvas, 2,3,table_row,table_row+2, GTK_FILL, 0, X_PADDING, Y_PADDING); gtk_widget_show(roi_canvas); /* the box */ roi_line_points = gnome_canvas_points_new(5); roi_line_points->coords[0] = 25.0; /* x1 */ roi_line_points->coords[1] = 25.0; /* y1 */ roi_line_points->coords[2] = 75.0; /* x2 */ roi_line_points->coords[3] = 25.0; /* y2 */ roi_line_points->coords[4] = 75.0; /* x3 */ roi_line_points->coords[5] = 75.0; /* y3 */ roi_line_points->coords[6] = 25.0; /* x4 */ roi_line_points->coords[7] = 75.0; /* y4 */ roi_line_points->coords[8] = 25.0; /* x4 */ roi_line_points->coords[9] = 25.0; /* y4 */ *proi_item = gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(roi_canvas)), #ifdef AMIDE_LIBGNOMECANVAS_AA gnome_canvas_polygon_get_type(), #else gnome_canvas_line_get_type(), #endif "points", roi_line_points, NULL); gnome_canvas_points_unref(roi_line_points); table_row++; #ifdef AMIDE_LIBGNOMECANVAS_AA /* widget to change the transparency level */ /* only works for anti-aliased canvases */ /* widgets to change the roi's size */ label = gtk_label_new(_("ROI Transparency")); gtk_table_attach(GTK_TABLE(packing_table), label, 0, 1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(label); *proi_transparency_spin = gtk_spin_button_new_with_range(0.0,1.0,AMITK_PREFERENCES_DEFAULT_CANVAS_ROI_TRANSPARENCY); gtk_spin_button_set_increments(GTK_SPIN_BUTTON(*proi_transparency_spin),0.1,0.1); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(*proi_transparency_spin),FALSE); gtk_table_attach(GTK_TABLE(packing_table), *proi_transparency_spin, 1,2, table_row, table_row+1, GTK_FILL, 0, X_PADDING, Y_PADDING); gtk_widget_show(*proi_transparency_spin); table_row++; #else /* widgets to change the roi's line style */ /* Anti-aliased canvas doesn't yet support this */ /* also need to remove #ifndef for relevant lines in amitk_canvas_object.c and other locations */ label = gtk_label_new(_("ROI Line Style:")); gtk_table_attach(GTK_TABLE(packing_table), label, 0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(label); *pline_style_menu = gtk_combo_box_new_text(); for (i_line_style=0; i_line_style<=GDK_LINE_DOUBLE_DASH; i_line_style++) gtk_combo_box_append_text(GTK_COMBO_BOX(*pline_style_menu), line_style_names[i_line_style]); gtk_widget_set_size_request (*pline_style_menu, 125, -1); gtk_table_attach(GTK_TABLE(packing_table), *pline_style_menu, 1,2, table_row,table_row+1, GTK_FILL, 0, X_PADDING, Y_PADDING); gtk_widget_show(*pline_style_menu); table_row++; /* do we want to fill in isocontour roi's */ label = gtk_label_new(_("Draw Isocontours/Freehands Filled:")); gtk_table_attach(GTK_TABLE(packing_table), label, 0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(label); *pfill_roi_button = gtk_check_button_new(); gtk_table_attach(GTK_TABLE(packing_table), *pfill_roi_button, 1,2, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(*pfill_roi_button); table_row++; #endif hseparator = gtk_hseparator_new(); gtk_table_attach(GTK_TABLE(packing_table), hseparator, 0, 3, table_row, table_row+1, GTK_FILL, 0, X_PADDING, Y_PADDING); table_row++; gtk_widget_show(hseparator); label = gtk_label_new(_("Canvas Layout:")); gtk_table_attach(GTK_TABLE(packing_table), label, 0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(label); /* the radio buttons */ *playout_button1 = gtk_radio_button_new(NULL); image = gtk_image_new_from_stock("amide_icon_layout_linear",GTK_ICON_SIZE_DIALOG); gtk_button_set_image(GTK_BUTTON(*playout_button1), image); gtk_table_attach(GTK_TABLE(packing_table), *playout_button1, 1,2, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); g_object_set_data(G_OBJECT(*playout_button1), "layout", GINT_TO_POINTER(AMITK_LAYOUT_LINEAR)); gtk_widget_show(*playout_button1); *playout_button2 = gtk_radio_button_new(NULL); gtk_radio_button_set_group(GTK_RADIO_BUTTON(*playout_button2), gtk_radio_button_get_group(GTK_RADIO_BUTTON(*playout_button1))); image = gtk_image_new_from_stock("amide_icon_layout_orthogonal",GTK_ICON_SIZE_DIALOG); gtk_button_set_image(GTK_BUTTON(*playout_button2), image); gtk_table_attach(GTK_TABLE(packing_table), *playout_button2, 2,3, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); g_object_set_data(G_OBJECT(*playout_button2), "layout", GINT_TO_POINTER(AMITK_LAYOUT_ORTHOGONAL)); gtk_widget_show(*playout_button2); table_row++; label = gtk_label_new(_("Multiple Canvases Layout:")); gtk_table_attach(GTK_TABLE(packing_table), label, 0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(label); /* the radio buttons */ *ppanel_layout_button1 = gtk_radio_button_new(NULL); image = gtk_image_new_from_stock("amide_icon_panels_mixed", GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_button_set_image(GTK_BUTTON(*ppanel_layout_button1), image); gtk_table_attach(GTK_TABLE(packing_table), *ppanel_layout_button1, 1,2, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); g_object_set_data(G_OBJECT(*ppanel_layout_button1), "panel_layout", GINT_TO_POINTER(AMITK_PANEL_LAYOUT_MIXED)); gtk_widget_show(*ppanel_layout_button1); *ppanel_layout_button2 = gtk_radio_button_new(NULL); gtk_radio_button_set_group(GTK_RADIO_BUTTON(*ppanel_layout_button2), gtk_radio_button_get_group(GTK_RADIO_BUTTON(*ppanel_layout_button1))); image = gtk_image_new_from_stock("amide_icon_panels_linear_x", GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_button_set_image(GTK_BUTTON(*ppanel_layout_button2), image); gtk_table_attach(GTK_TABLE(packing_table), *ppanel_layout_button2, 2,3, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); g_object_set_data(G_OBJECT(*ppanel_layout_button2), "panel_layout", GINT_TO_POINTER(AMITK_PANEL_LAYOUT_LINEAR_X)); gtk_widget_show(*ppanel_layout_button2); *ppanel_layout_button3 = gtk_radio_button_new(NULL); gtk_radio_button_set_group(GTK_RADIO_BUTTON(*ppanel_layout_button3), gtk_radio_button_get_group(GTK_RADIO_BUTTON(*ppanel_layout_button1))); image = gtk_image_new_from_stock("amide_icon_panels_linear_y", GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_button_set_image(GTK_BUTTON(*ppanel_layout_button3), image); gtk_table_attach(GTK_TABLE(packing_table), *ppanel_layout_button3, 3,4, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); g_object_set_data(G_OBJECT(*ppanel_layout_button3), "panel_layout", GINT_TO_POINTER(AMITK_PANEL_LAYOUT_LINEAR_Y)); gtk_widget_show(*ppanel_layout_button3); table_row++; /* do we want the size of the canvas to not resize */ label = gtk_label_new(_("Maintain view size constant:")); gtk_table_attach(GTK_TABLE(packing_table), label, 0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(label); *pmaintain_size_button = gtk_check_button_new(); gtk_table_attach(GTK_TABLE(packing_table), *pmaintain_size_button, 1,2, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(*pmaintain_size_button); table_row++; /* widgets to change the amount of empty space in the center of the target */ label = gtk_label_new(_("Target Empty Area (pixels)")); gtk_table_attach(GTK_TABLE(packing_table), label, 0,1, table_row, table_row+1, 0, 0, X_PADDING, Y_PADDING); gtk_widget_show(label); adjustment = gtk_adjustment_new(AMITK_PREFERENCES_MIN_TARGET_EMPTY_AREA, AMITK_PREFERENCES_MIN_TARGET_EMPTY_AREA, AMITK_PREFERENCES_MAX_TARGET_EMPTY_AREA, 1.0, 1.0, 0.0); *ptarget_size_spin = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1.0, 0); gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(*ptarget_size_spin),FALSE); gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(*ptarget_size_spin), TRUE); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(*ptarget_size_spin), TRUE); gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(*ptarget_size_spin), GTK_UPDATE_ALWAYS); gtk_table_attach(GTK_TABLE(packing_table), *ptarget_size_spin, 1,2, table_row, table_row+1, GTK_FILL, 0, X_PADDING, Y_PADDING); gtk_widget_show(*ptarget_size_spin); return; }
/* so much gayness in here, either I suck or gnome-canvas does; most * likely, we both do */ static void draw_key(PhatKeyboard* self, gint index, gint pos, guint bg, guint hi, guint low, guint pre, guint on, guint shad) { _Key* key = &self->keys[index]; GnomeCanvasPoints* points; gint x1; gint y1; gint x2; gint y2; if (self->orientation == GTK_ORIENTATION_VERTICAL) { x1 = 0; y1 = pos + 1; /* teh gayz0r */ x2 = PHAT_KEYBOARD_KEY_LENGTH - 1; y2 = pos - PHAT_KEYBOARD_KEY_WIDTH + 1; } else { x1 = pos + PHAT_KEYBOARD_KEY_WIDTH - 1; y1 = 0; x2 = pos; y2 = PHAT_KEYBOARD_KEY_LENGTH - 1; } /* key group */ key->group = (GnomeCanvasGroup*) gnome_canvas_item_new(gnome_canvas_root(self->canvas), gnome_canvas_group_get_type(), NULL); g_signal_connect(G_OBJECT(key->group), "event", G_CALLBACK(key_press_cb), (gpointer)key); key->index = index; key->hold = 0; key->keyboard = self; /* draw main key rect */ gnome_canvas_item_new(key->group, gnome_canvas_rect_get_type(), "x1", (gdouble)x1, "y1", (gdouble)y1, "x2", (gdouble)x2, "y2", (gdouble)y2, "fill-color-rgba", bg, NULL); /* draw prelight rect */ key->pre = gnome_canvas_item_new(key->group, gnome_canvas_rect_get_type(), "x1", (gdouble)x1, "y1", (gdouble)y1, "x2", (gdouble)x2, "y2", (gdouble)y2, "fill-color-rgba", pre, NULL); gnome_canvas_item_hide(key->pre); /* draw key highlight */ points = gnome_canvas_points_new(3); if (self->orientation == GTK_ORIENTATION_VERTICAL) { points->coords[0] = x1+1; points->coords[1] = y1; points->coords[2] = x1+1; points->coords[3] = y2+1; points->coords[4] = x2; points->coords[5] = y2+1; } else { points->coords[0] = x1; points->coords[1] = y1+1; points->coords[2] = x2; points->coords[3] = y1+1; points->coords[4] = x2; points->coords[5] = y2; } gnome_canvas_item_new(key->group, gnome_canvas_line_get_type(), "points", points, "width-units", (gdouble)1, "fill-color-rgba", hi, NULL); gnome_canvas_points_unref(points); /* draw key border */ points = gnome_canvas_points_new(4); if (self->orientation == GTK_ORIENTATION_VERTICAL) { points->coords[0] = x1; points->coords[1] = y1; points->coords[2] = x1; points->coords[3] = y2; points->coords[4] = x2; points->coords[5] = y2; points->coords[6] = x2; points->coords[7] = y1; } else { points->coords[0] = x2; points->coords[1] = y1; points->coords[2] = x1; points->coords[3] = y1; points->coords[4] = x1; points->coords[5] = y2; points->coords[6] = x2; points->coords[7] = y2; } gnome_canvas_item_new(key->group, gnome_canvas_line_get_type(), "points", points, "width-units", (gdouble)1, "fill-color-rgba", low, NULL); gnome_canvas_points_unref(points); if (self->orientation == GTK_ORIENTATION_VERTICAL) { /* draw active rect */ key->on = gnome_canvas_item_new(key->group, gnome_canvas_rect_get_type(), "x1", (gdouble)x1+1, "y1", (gdouble)y1, "x2", (gdouble)x2, "y2", (gdouble)y2+1, "fill-color-rgba", on, NULL); } else { /* draw active rect */ key->on = gnome_canvas_item_new(key->group, gnome_canvas_rect_get_type(), "x1", (gdouble)x1, "y1", (gdouble)y1+1, "x2", (gdouble)x2, "y2", (gdouble)y2, "fill-color-rgba", on, NULL); } gnome_canvas_item_hide(key->on); /* draw active shadow */ points = gnome_canvas_points_new(6); if (self->orientation == GTK_ORIENTATION_VERTICAL) { points->coords[0] = x1+1; points->coords[1] = y1; points->coords[2] = x1+1; points->coords[3] = y2+1; points->coords[4] = x2; points->coords[5] = y2+1; points->coords[6] = x2; points->coords[7] = y2 + 3; points->coords[8] = x1 + 3; points->coords[9] = y2 + 3; points->coords[10] = x1 + 3; points->coords[11] = y1; } else { points->coords[0] = x1; points->coords[1] = y1 + 1; points->coords[2] = x2; points->coords[3] = y1 + 1; points->coords[4] = x2; points->coords[5] = y2; points->coords[6] = x2 + 2; points->coords[7] = y2; points->coords[8] = x2 + 2; points->coords[9] = y1 + 3; points->coords[10] = x1; points->coords[11] = y1 + 3; } key->shad = gnome_canvas_item_new(key->group, gnome_canvas_polygon_get_type(), "points", points, "fill-color-rgba", shad, NULL); gnome_canvas_item_hide(key->shad); gnome_canvas_points_unref(points); /* draw label if applicable */ if (self->label && (index % 12) == 0) { gchar* s = g_strdup_printf("%d", index / 12 + 1); if (self->orientation == GTK_ORIENTATION_VERTICAL) { gnome_canvas_item_new(key->group, gnome_canvas_text_get_type(), "text", s, "x", (gdouble)(x2 - 2), "y", (gdouble)(y1 - (PHAT_KEYBOARD_KEY_WIDTH / 2)), "anchor", GTK_ANCHOR_EAST, "fill-color-rgba", (gint)KEY_TEXT_BG, "font", "sans", "size-points", (gdouble)TEXT_POINTS, NULL); } else { gnome_canvas_item_new(key->group, gnome_canvas_text_get_type(), "text", s, "x", (gdouble)(x1 - (PHAT_KEYBOARD_KEY_WIDTH / 2)), "y", (gdouble)(y2 - 2), "anchor", GTK_ANCHOR_SOUTH, "fill-color-rgba", (gint)KEY_TEXT_BG, "font", "sans", "size-points", (gdouble)TEXT_POINTS, "justification", GTK_JUSTIFY_CENTER, NULL); } g_free(s); } }