diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-12 23:08:32 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-12 23:08:32 +0000 |
commit | ed6ce8b43b6f25df1d4809ac799de4dd1c85c1f3 (patch) | |
tree | 09bc05d679d0f224a29fee44d10beea321bdc0b5 /ext/tk/lib/tkextlib/tcllib/diagrams.rb | |
parent | e13fb8029b87943ab8af2211226b7c9347d3976d (diff) |
* ext/tk/extconf.rb: New strategy for searching Tcl/Tk libraries.
* ext/tk/*: Support new features of Tcl/Tk8.6b1 and minor bug fixes.
( [KNOWN BUG] Ruby/Tk on Ruby 1.9 will not work on Cygwin. )
* ext/tk/*: Unify sources between Ruby 1.8 & 1.9.
Improve default_widget_set handling.
* ext/tk/*: Multi-TkInterpreter (multi-tk.rb) works on Ruby 1.8 & 1.9.
( [KNOWN BUG] On Ruby 1.8, join to a long term Thread on Tk
callbacks may freeze. On Ruby 1.9, cannot create a second
master interpreter (creating slaves are OK); supported master
interpreter is the default master interpreter only. )
* ext/tk/lib/tkextlib/*: Update supported versions of Tk extensions.
Tcllib 1.8/Tklib 0.4.1 ==> Tcllib 1.11.1/Tklib 0.5
BWidgets 1.7 ==> BWidgets 1.8
TkTable 2.9 ==> TkTable 2.10
TkTreeCtrl 2005-12-02 ==> TkTreeCtrl 2.2.9
Tile 0.8.0/8.5.1 ==> Tile 0.8.3/8.6b1
IncrTcl 2005-02-14 ==> IncrTcl 2008-12-15
TclX 2005-02-07 ==> TclX 2008-12-15
Trofs 0.4.3 ==> Trofs 0.4.4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib/tcllib/diagrams.rb')
-rw-r--r-- | ext/tk/lib/tkextlib/tcllib/diagrams.rb | 224 |
1 files changed, 224 insertions, 0 deletions
diff --git a/ext/tk/lib/tkextlib/tcllib/diagrams.rb b/ext/tk/lib/tkextlib/tcllib/diagrams.rb new file mode 100644 index 0000000000..d24ba9d232 --- /dev/null +++ b/ext/tk/lib/tkextlib/tcllib/diagrams.rb @@ -0,0 +1,224 @@ +# +# tkextlib/tcllib/diagrams.rb +# by Hidetoshi NAGAI ([email protected]) +# +# * Part of tcllib extension +# * Draw diagrams +# + +require 'tk' +require 'tkextlib/tcllib.rb' + +# TkPackage.require('Diagrams', '0.3') +TkPackage.require('Diagrams') + +module Tk::Tcllib + module Diagrams + PACKAGE_NAME = 'Diagrams'.freeze + def self.package_name + PACKAGE_NAME + end + + def self.package_version + begin + TkPackage.require('Diagrams') + rescue + '' + end + end + end +end + +class << Tk::Tcllib::Diagrams + include TkCore + + def drawin(canvas) + tk_call('::Diagrams::drawin', canvas) + canvas + end + alias draw_in drawin + + def saveps(filename) + tk_call('::Diagrams::saveps', filename) + filename + end + alias save_ps saveps + + def direction(dir) + tk_call('::Diagrams::direction', dir) + dir + end + + def currentpos(pos) + list(tk_call('::Diagrams::currentpos', pos)) + end + alias current_pos currentpos + alias currentpos= currentpos + alias current_pos= currentpos + + def getpos(anchor, obj) + list(tk_call('::Diagrams::getpos', anchor, obj)) + end + alias get_pos getpos + + def position(x, y) + list(tk_call('::Diagrams::position', x, y)) + end + + def box(text, width=nil, height=nil) + if width || height + width = '' unless width + height = '' unless height + list(tk_call('::Diagrams::box', text, width, height)) + else + list(tk_call('::Diagrams::box', text)) + end + end + + def plaintext(text, width=nil, height=nil) + if width || height + width = '' unless width + height = '' unless height + list(tk_call('::Diagrams::plaintext', text, width, height)) + else + list(tk_call('::Diagrams::plaintext', text)) + end + end + + def circle(text, radius=nil) + if radius + list(tk_call('::Diagrams::circle', text, radius)) + else + list(tk_call('::Diagrams::circle', text)) + end + end + + def slanted(text, width=nil, height=nil, angle=nil) + if width || height || angle + width = '' unless width + height = '' unless height + if angle + list(tk_call('::Diagrams::slanted', text, width, height, angle)) + else + list(tk_call('::Diagrams::slanted', text, width, height)) + end + else + list(tk_call('::Diagrams::slanted', text)) + end + end + + def diamond(text, width=nil, height=nil) + if width || height + width = '' unless width + height = '' unless height + list(tk_call('::Diagrams::diamond', text, width, height)) + else + list(tk_call('::Diagrams::diamond', text)) + end + end + + def drum(text, width=nil, height=nil) + if width || height + width = '' unless width + height = '' unless height + list(tk_call('::Diagrams::drum', text, width, height)) + else + list(tk_call('::Diagrams::drum', text)) + end + end + + def arrow(text=nil, length=nil, head=nil) + if length || head + text = '' unless text + length = '' unless length + list(tk_call('::Diagrams::arrow', text, length, head)) + else + if text + list(tk_call('::Diagrams::arrow', text)) + else + list(tk_call('::Diagrams::arrow')) + end + end + end + + def line(*args) + ary = [] + args.each{|arg| + if arg.kind_of?(Array) && arg.length == 2 # [length, angle] + ary.concat arg + else # ["POSITION", x, y] or length or angle + ary << arg + end + } + list(tk_call('::Diagrams::line', *ary)) + end + + def bracket(dir, dist, from_pos, to_pos) + list(tk_call('::Diagrams::bracket', dir, dist, from_pos, to_pos)) + end + + def attach(anchor=None) + tk_call('::Diagrams::attach', anchor) + end + + def color(name=None) + tk_call('::Diagrams::color', name) + end + + def fillcolor(name=None) + tk_call('::Diagrams::fillcolor', name) + end + + def textcolor(name=None) + tk_call('::Diagrams::textcolor', name) + end + + def usegap(mode=None) + bool(tk_call('::Diagrams::usegap', mode)) + end + alias use_gap usegap + + def xgap(val=None) + number(tk_call('::Diagrams::xgap', val)) + end + + def ygap(val=None) + number(tk_call('::Diagrams::ygap', val)) + end + + def textfont(fnt=None) + tk_call('::Diagrams::textfont', fnt) + end + + def linewidth(pixels=None) + number(tk_call('::Diagrams::linewidth', pixels)) + end + + def linestyle(style=None) + tk_call('::Diagrams::linestyle', style) + end + + def pushstate + tk_call('::Diagrams::pushstate') + end + alias push_state pushstate + + def popstate + tk_call('::Diagrams::popstate') + end + alias pop_state popstate + + def computepos + list(tk_call('::Diagrams::computepos')) + end + alias compute_pos computepos + + def boxcoords(x1, y1, x2, y2) + list(tk_call('::Diagrams::boxcoords', x1, y1, x2, y2)) + end + + def moveobject(obj) + list(tk_call('::Diagrams::moveobject', obj)) + end + alias move_object moveobject +end |