require 'fltk' require 'mkmf' if( !defined?(FLTK::HelpView) ) $stderr.print("FLTK should have HelpView widget.\n", "Your FLTK seems to be older than 1.1.x.\n") exit(1) end if( RUBY_PLATFORM =~ /(mingw)|(cygwin)|(mswin)/ ) MYFONT = FLTK::FREE_FONT FLTK.set_font(MYFONT, "MS 明朝") else MYFONT = FLTK::HELVETICA end RUBY = CONFIG["prefix"] + "/bin/" + CONFIG["ruby_install_name"] Dir.chdir(File.dirname($0)) class DemoHelpView < FLTK::HelpView DEMO_FILE = "demo-j.html" def initialize(*args) super(*args) link{|w,uri| case uri when /^ruby:(.+)/i rbfile = $1 Thread.new{ system("#{RUBY} ./#{rbfile}") } load(DEMO_FILE) nil when /^edit:(.+)/i rbfile = $1 Thread.new{ system("#{RUBY} ./editor.rb ./#{rbfile}") } load(DEMO_FILE) nil when "cmd:quit" exit(0) else uri end } load(DEMO_FILE) end end FLTK::Window.new(400,300){|win| help = DemoHelpView.new(0,0,400,280) help.textfont = FLTK::MYFONT FLTK::Pack.new(0,280,400,20){|pack| pack.packtype = FLTK::HORIZONTAL FLTK::Button.new(0,0,50,20,"+1"){ help.textsize += 1 } FLTK::Button.new(0,0,50,20,"-1"){ help.textsize -= 1 } FLTK::Box.new(0,0,250,20) b = FLTK::Button.new(0,0,50,20,"終了"){ exit(0) } b.labelfont = FLTK::MYFONT } win.resizable(win) win.show } FLTK.run()