2
# tkextlib/tcllib/diagrams.rb
3
# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
5
# * Part of tcllib extension
10
require 'tkextlib/tcllib.rb'
12
# TkPackage.require('Diagrams', '0.3')
13
TkPackage.require('Diagrams')
17
PACKAGE_NAME = 'Diagrams'.freeze
22
def self.package_version
24
TkPackage.require('Diagrams')
32
class << Tk::Tcllib::Diagrams
36
tk_call('::Diagrams::drawin', canvas)
42
tk_call('::Diagrams::saveps', filename)
48
tk_call('::Diagrams::direction', dir)
53
list(tk_call('::Diagrams::currentpos', pos))
55
alias current_pos currentpos
56
alias currentpos= currentpos
57
alias current_pos= currentpos
59
def getpos(anchor, obj)
60
list(tk_call('::Diagrams::getpos', anchor, obj))
65
list(tk_call('::Diagrams::position', x, y))
68
def box(text, width=nil, height=nil)
70
width = '' unless width
71
height = '' unless height
72
list(tk_call('::Diagrams::box', text, width, height))
74
list(tk_call('::Diagrams::box', text))
78
def plaintext(text, width=nil, height=nil)
80
width = '' unless width
81
height = '' unless height
82
list(tk_call('::Diagrams::plaintext', text, width, height))
84
list(tk_call('::Diagrams::plaintext', text))
88
def circle(text, radius=nil)
90
list(tk_call('::Diagrams::circle', text, radius))
92
list(tk_call('::Diagrams::circle', text))
96
def slanted(text, width=nil, height=nil, angle=nil)
97
if width || height || angle
98
width = '' unless width
99
height = '' unless height
101
list(tk_call('::Diagrams::slanted', text, width, height, angle))
103
list(tk_call('::Diagrams::slanted', text, width, height))
106
list(tk_call('::Diagrams::slanted', text))
110
def diamond(text, width=nil, height=nil)
112
width = '' unless width
113
height = '' unless height
114
list(tk_call('::Diagrams::diamond', text, width, height))
116
list(tk_call('::Diagrams::diamond', text))
120
def drum(text, width=nil, height=nil)
122
width = '' unless width
123
height = '' unless height
124
list(tk_call('::Diagrams::drum', text, width, height))
126
list(tk_call('::Diagrams::drum', text))
130
def arrow(text=nil, length=nil, head=nil)
132
text = '' unless text
133
length = '' unless length
134
list(tk_call('::Diagrams::arrow', text, length, head))
137
list(tk_call('::Diagrams::arrow', text))
139
list(tk_call('::Diagrams::arrow'))
147
if arg.kind_of?(Array) && arg.length == 2 # [length, angle]
149
else # ["POSITION", x, y] or length or angle
153
list(tk_call('::Diagrams::line', *ary))
156
def bracket(dir, dist, from_pos, to_pos)
157
list(tk_call('::Diagrams::bracket', dir, dist, from_pos, to_pos))
160
def attach(anchor=None)
161
tk_call('::Diagrams::attach', anchor)
165
tk_call('::Diagrams::color', name)
168
def fillcolor(name=None)
169
tk_call('::Diagrams::fillcolor', name)
172
def textcolor(name=None)
173
tk_call('::Diagrams::textcolor', name)
176
def usegap(mode=None)
177
bool(tk_call('::Diagrams::usegap', mode))
182
number(tk_call('::Diagrams::xgap', val))
186
number(tk_call('::Diagrams::ygap', val))
189
def textfont(fnt=None)
190
tk_call('::Diagrams::textfont', fnt)
193
def linewidth(pixels=None)
194
number(tk_call('::Diagrams::linewidth', pixels))
197
def linestyle(style=None)
198
tk_call('::Diagrams::linestyle', style)
202
tk_call('::Diagrams::pushstate')
204
alias push_state pushstate
207
tk_call('::Diagrams::popstate')
209
alias pop_state popstate
212
list(tk_call('::Diagrams::computepos'))
214
alias compute_pos computepos
216
def boxcoords(x1, y1, x2, y2)
217
list(tk_call('::Diagrams::boxcoords', x1, y1, x2, y2))
221
list(tk_call('::Diagrams::moveobject', obj))
223
alias move_object moveobject