def draw_curve(item, x, y)
root = item.parent
case @current_state
when STATE_INIT
@current_points = [] if @current_points.nil?
@current_points[0] = x
@current_points[1] = y
when STATE_FIRST_PRESS
@current_points[2] = x
@current_points[3] = y
path_def = Gnome::CanvasPathDef.new()
path_def.moveto(@current_points[0], @current_points[1])
path_def.lineto(@current_points[2], @current_points[3])
unless @current_item.nil?
@current_item.set({:bpath => path_def})
else
@current_item = Gnome::CanvasBpath.new(root,
{:bpath => path_def,
:outline_color => "blue",
:width_pixels => 5,
:cap_style => Gdk::GC::CAP_ROUND})
@current_item.signal_connect("event") do |item, event|
item_event(item, event)
end
end
when STATE_FIRST_RELEASE
@current_points[4] = x
@current_points[5] = y
path_def = Gnome::CanvasPathDef.new()
path_def.moveto(@current_points[0], @current_points[1])
path_def.curveto(@current_points[4], @current_points[5],
@current_points[4], @current_points[5],
@current_points[2], @current_points[3])
@current_item.set({:bpath => path_def})
when STATE_SECOND_PRESS
@current_points[6] = x;
@current_points[7] = y;
path_def = Gnome::CanvasPathDef.new();
path_def.moveto(@current_points[0], @current_points[1])
path_def.curveto(@current_points[4], @current_points[5],
@current_points[6], @current_points[7],
@current_points[2], @current_points[3])
@current_item.set({:bpath => path_def})
@current_item = nil
else
raise "not reached here"
end
end