require 'tkmove4' require 'tkdrawcom.rb' c = TkCanvas.new(nil, 'width'=>600, 'height'=>400, 'bg'=>'white') a = TkdArea.new( c ) r = TkdRectangle.new( c ) o = TkdOval.new( c ) l = TkdLine.new( c ) ls = TkdLines.new( c ) b = TkdBezier.new( c ) p = TkdPolygon.new( c ) bp = TkdBPolygon.new( c ) m = TkMove.new( c ) cp = TkdCopy.new( c ) cf = TkdConfigure.new( c ) cd = TkdCoords.new( c ) d = TkdDelete.new( c ) g = TkdGroup.new( c ) cl = TkdColor.new( c ) cnt = TkdControl.new( c ) size = TkdSize.new( c ) r90 = TkdRotate90.new( c ) rot = TkdRotate.new( c ) mirr = TkdMirror.new( c ) menu_spec = [ [ ['File',0], ['Exit', proc{ exit }] ], [ ['Item', 0], ['Rectangle', proc{ cnt.remove_control; a.delete; m.unbind; r.bind }], ['Oval', proc{ cnt.remove_control; a.delete; m.unbind; o.bind }], '---', ['Line', proc{ cnt.remove_control; a.delete; m.unbind; l.bind }], ['Lines', proc{ cnt.remove_control; a.delete; m.unbind; ls.bind }], ['Bezier', proc{ cnt.remove_control; a.delete; m.unbind; b.bind }], ['Polygone', proc{ cnt.remove_control; a.delete; m.unbind; p.bind }], ['BPolygone', proc{ cnt.remove_control; a.delete; m.unbind; bp.bind }] ], [ ['Edit', 0], ['Move', proc{ cnt.remove_control; a.delete; m.unbind; m.bind }], ['Copy', proc{ cnt.remove_control; a.delete; m.unbind; cp.bind }], '---', ['Control', proc { cnt.remove_control; a.delete; m.unbind; cnt.bind }], '---', ['Color', proc{ cnt.remove_control; a.delete; m.unbind; cl.bind }], ['Configure', proc{ cnt.remove_control; a.delete; m.unbind; cf.bind }], ['Coords', proc{ cnt.remove_control; a.delete; m.unbind; cd.bind }], '---', ['Delete', proc{ cnt.remove_control; a.delete; m.unbind; d.bind }] ], [ ['Group', 0], ['Area select', proc{ cnt.remove_control; a.delete; m.unbind; a.bind }], ['Make group', proc{ cnt.remove_control; a.delete; m.unbind; g.make_group( a.get_coord ) }], ['Break up group', proc{ cnt.remove_control; a.delete; m.unbind; g.bind }] ], [ ['Size', 0], ['Enlarge', proc{ cnt.remove_control; a.delete; m.unbind; size.bind(1.2) }], ['Reduce', proc{ cnt.remove_control; a.delete; m.unbind; size.bind(0.83333) }], ['Rotate90', proc{ cnt.remove_control; a.delete; m.unbind; r90.bind }], ['Mirror', proc{ cnt.remove_control; a.delete; m.unbind; mirr.bind }], ['Rotate', proc{ cnt.remove_control; a.delete; m.unbind; rot.bind }] ] ] mb = TkMenubar.new(nil, menu_spec, 'tearoff'=>false).pack('fill'=>'x', 'side'=>'top') $curs = '' mb.bind('Enter', proc{ root = TkRoot.new; $curs = root.cursor; root.cursor('left_ptr') }) mb.bind('Leave', proc{ TkRoot.new.cursor( $curs ) }) c.pack Tk.mainloop