def initialize
super(false, 4)
border_width = 4
show
w = Gtk::Label.new("This demo allows you to edit arrowhead shapes. Drag the little boxes\nto change the shape of the line and its arrowhead. You can see the\narrows at their normal scale on the right hand side of the window.\n")
pack_start(w, false, false, 0)
w.show()
w = Gtk::Alignment.new(0.5, 0.5, 0.0, 0.0)
pack_start(w, true, true, 0)
w.show()
frame = Gtk::Frame.new()
frame.set_shadow_type(Gtk::SHADOW_IN)
w.add(frame)
frame.show()
canvas = Gnome::Canvas.new()
canvas.set_size_request(500, 350)
canvas.set_scroll_region(0, 0, 500, 350)
frame.add(canvas)
canvas.show()
root = canvas.root
@width = DEFAULT_WIDTH
@shape_a = DEFAULT_SHAPE_A
@shape_b = DEFAULT_SHAPE_B
@shape_c = DEFAULT_SHAPE_C
@big_arrow = Gnome::CanvasLine.new(root,
{:points => [[LEFT, MIDDLE], [RIGHT, MIDDLE]],
:fill_color => "mediumseagreen",
:width_pixels => DEFAULT_WIDTH * 20,
:last_arrowhead => true})
@outline = Gnome::CanvasLine.new(root,
{:fill_color => "black",
:width_pixels => 2,
:cap_style => Gdk::GC::CAP_ROUND,
:join_style => Gdk::GC::JOIN_ROUND})
@width_drag_box = create_drag_box(root) do |item, event|
width_event(item, event)
end
@shape_a_drag_box = create_drag_box(root) do |item, event|
shape_a_event(item, event)
end
@shape_b_c_drag_box = create_drag_box(root) do |item, event|
shape_b_c_event(item, event)
end
@width_arrow, @width_text = create_dimension(root, Gtk::ANCHOR_E)
@shape_a_arrow, @shape_a_text = create_dimension(root, Gtk::ANCHOR_N)
@shape_b_arrow, @shape_b_text = create_dimension(root, Gtk::ANCHOR_N)
@shape_c_arrow, @shape_c_text = create_dimension(root, Gtk::ANCHOR_N)
@width_info = create_info(root, LEFT, 260)
@shape_a_info = create_info(root, LEFT, 280)
@shape_b_info = create_info(root, LEFT, 300)
@shape_c_info = create_info(root, LEFT, 320)
Gnome::CanvasLine.new(root,
{:points => [[RIGHT + 50, 0], [RIGHT + 50, 1000]],
:fill_color => "black",
:width_pixels => 2})
@sample_1 = create_sample_arrow(root, RIGHT + 100, 30, RIGHT + 100, MIDDLE - 30)
@sample_2 = create_sample_arrow(root, RIGHT + 70, MIDDLE, RIGHT + 130, MIDDLE)
@sample_3 = create_sample_arrow(root, RIGHT + 70, MIDDLE + 30, RIGHT + 130, MIDDLE + 120)
set_arrow_shape(canvas)
end