tkar 0.63
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/FAQ.rdoc +39 -0
- data/History.txt +175 -0
- data/README.rdoc +153 -0
- data/TODO +67 -0
- data/bin/tkar +104 -0
- data/examples/dial.rb +172 -0
- data/examples/help.gif +0 -0
- data/examples/home.gif +0 -0
- data/examples/mkgrid.rb +58 -0
- data/examples/ps.rb +47 -0
- data/examples/rotate +26 -0
- data/examples/s +3 -0
- data/examples/sample +14 -0
- data/examples/sample.rb +98 -0
- data/examples/sample2 +48 -0
- data/examples/sample3 +57 -0
- data/examples/server.rb +45 -0
- data/examples/tavis.rb +90 -0
- data/install.rb +1015 -0
- data/lib/tkar.rb +109 -0
- data/lib/tkar/argos.rb +214 -0
- data/lib/tkar/canvas.rb +370 -0
- data/lib/tkar/help-window.rb +168 -0
- data/lib/tkar/primitives.rb +376 -0
- data/lib/tkar/stream.rb +284 -0
- data/lib/tkar/timer.rb +174 -0
- data/lib/tkar/tkaroid.rb +95 -0
- data/lib/tkar/version.rb +5 -0
- data/lib/tkar/window.rb +383 -0
- data/protocol.rdoc +539 -0
- data/rakefile +56 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +34 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +292 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/tasks/zentest.rake +36 -0
- metadata +116 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
module Tkar
|
2
|
+
class HelpWindow < TkToplevel
|
3
|
+
def self.show
|
4
|
+
if @help_window
|
5
|
+
@help_window.destroy
|
6
|
+
end
|
7
|
+
@help_window = new
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(*)
|
11
|
+
super
|
12
|
+
|
13
|
+
title("Tkar Help")
|
14
|
+
iconname("tkar help")
|
15
|
+
|
16
|
+
frame = TkFrame.new(self){|frame|
|
17
|
+
pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
|
18
|
+
}
|
19
|
+
|
20
|
+
text = TkText.new(frame){|t|
|
21
|
+
setgrid 'true'
|
22
|
+
width 72
|
23
|
+
height 32
|
24
|
+
wrap 'word'
|
25
|
+
|
26
|
+
TkScrollbar.new(frame) {|s|
|
27
|
+
pack('side'=>'right', 'fill'=>'y')
|
28
|
+
command proc{|*args| t.yview(*args)}
|
29
|
+
t.yscrollcommand proc{|first,last| s.set first,last}
|
30
|
+
}
|
31
|
+
pack('expand'=>'yes', 'fill'=>'both')
|
32
|
+
|
33
|
+
st_fixed = TkTextTag.new(t,
|
34
|
+
'font'=>'-*-Courier--R-Normal--*-120-*-*-*-*-*-*')
|
35
|
+
st_bold = TkTextTag.new(t,
|
36
|
+
'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
|
37
|
+
st_big = TkTextTag.new(t,
|
38
|
+
'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*')
|
39
|
+
st_h1 = st_verybig = TkTextTag.new(t,
|
40
|
+
'font'=>'-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*')
|
41
|
+
st_h2 = TkTextTag.new(t,
|
42
|
+
'font'=>'-*-Helvetica-Bold-R-Normal--*-160-*-*-*-*-*-*')
|
43
|
+
st_small = TkTextTag.new(t,
|
44
|
+
'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*')
|
45
|
+
|
46
|
+
st_color1 = TkTextTag.new(t, 'background'=>'#a0b7ce')
|
47
|
+
st_color2 = TkTextTag.new(t, 'foreground'=>'red')
|
48
|
+
st_raised = TkTextTag.new(t, 'relief'=>'raised', 'borderwidth'=>1)
|
49
|
+
st_sunken = TkTextTag.new(t, 'relief'=>'sunken', 'borderwidth'=>1)
|
50
|
+
|
51
|
+
st_bgstipple = TkTextTag.new(t, 'background'=>'black',
|
52
|
+
'borderwidth'=>0,
|
53
|
+
'bgstipple'=>'gray12')
|
54
|
+
|
55
|
+
st_fgstipple = TkTextTag.new(t, 'fgstipple'=>'gray50')
|
56
|
+
st_underline = TkTextTag.new(t, 'underline'=>'on')
|
57
|
+
st_overstrike = TkTextTag.new(t, 'overstrike'=>'on')
|
58
|
+
st_right = TkTextTag.new(t, 'justify'=>'right')
|
59
|
+
st_center = TkTextTag.new(t, 'justify'=>'center')
|
60
|
+
st_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
|
61
|
+
st_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
|
62
|
+
st_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m',
|
63
|
+
'rmargin'=>'10m')
|
64
|
+
st_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p',
|
65
|
+
'lmargin1'=>'12m', 'lmargin2'=>'6m',
|
66
|
+
'rmargin'=>'10m')
|
67
|
+
|
68
|
+
|
69
|
+
insert('end', "\nTkar Quick Reference", [st_center, st_h1])
|
70
|
+
|
71
|
+
insert('end', "\n\nKey commands", [st_h2])
|
72
|
+
|
73
|
+
insert('end', "\n
|
74
|
+
command effect
|
75
|
+
----------------------------------------------------
|
76
|
+
<right-arrow> scroll right
|
77
|
+
<left-arrow> scroll left
|
78
|
+
<up-arrow> scroll up
|
79
|
+
<down-arrow> scroll down
|
80
|
+
|
81
|
+
<ALT-right-arrow> scroll right one pixel
|
82
|
+
<ALT-left-arrow> scroll left one pixel
|
83
|
+
<ALT-up-arrow> scroll up one pixel
|
84
|
+
<ALT-down-arrow> scroll down one pixel
|
85
|
+
|
86
|
+
<CTRL-up-arrow> zoom out
|
87
|
+
<CTRL-down-arrow> zoom in
|
88
|
+
|
89
|
+
h show help window(*)
|
90
|
+
CTRL-q quit Tkar
|
91
|
+
", st_fixed)
|
92
|
+
|
93
|
+
insert('end', "\n\n(*) The '?' button in the lower right corner also bings up the help window.")
|
94
|
+
|
95
|
+
insert('end', "\n\nMouse commands", [st_h2])
|
96
|
+
|
97
|
+
insert('end', "\n
|
98
|
+
command effect
|
99
|
+
----------------------------------------------------
|
100
|
+
<button-1-drag> drag an object(*)
|
101
|
+
<CTRL-btn-1> select object to follow(**)
|
102
|
+
<button-2-drag> zoom in or out
|
103
|
+
<button-3-drag> scroll
|
104
|
+
<CTRL-btn-3-drag> scroll faster
|
105
|
+
<mouse-wheel> zoom
|
106
|
+
<CTRL-mouse-wheel> zoom faster
|
107
|
+
<hover> highlight all parts of object
|
108
|
+
", st_fixed)
|
109
|
+
|
110
|
+
insert('end', "\n\n(*) If no object is under the mouse, this can be used to scroll the view by moving the mouse outside the visible area.")
|
111
|
+
|
112
|
+
insert('end', "\n\n(**) If no object is under the mouse, this clears the previously selected object to follow (if any) and centers the display at the selected point. If the object selected to be followed is selected a second time, the object is no longer followed.")
|
113
|
+
|
114
|
+
insert('end', "\n\n In addition, some mouse commands cause output to be sent back to the controlling process that can be used to manipulate its own representation of the objects:")
|
115
|
+
|
116
|
+
insert('end', "\n
|
117
|
+
command text sent to master process
|
118
|
+
----------------------------------------------------
|
119
|
+
<click> click <ID>
|
120
|
+
<doubleclick> doubleclick <ID>
|
121
|
+
<button-1-drag> drag <ID> <x> <y>
|
122
|
+
<button-1-drop> drop <ID> <target-ID>
|
123
|
+
", st_fixed)
|
124
|
+
|
125
|
+
insert('end', "\n\nCommand-line usage", [st_h2])
|
126
|
+
insert('end', "\
|
127
|
+
\n\n
|
128
|
+
tkar [-b] [addr] [port]
|
129
|
+
|
130
|
+
Start a tkar animation process. Its inputs and outputs are one of:
|
131
|
+
|
132
|
+
stdin/stdout: this is the default
|
133
|
+
|
134
|
+
TCP socket: if port is given (addr default is 127.0.0.1)
|
135
|
+
|
136
|
+
UNIX socket: if addr only is given
|
137
|
+
|
138
|
+
The -b switch turns on binary protocol mode, otherwise uses ascii.
|
139
|
+
See docs for details.
|
140
|
+
|
141
|
+
Additional switches:
|
142
|
+
|
143
|
+
-h this help
|
144
|
+
|
145
|
+
-c act as client instead of server [socket cases only]
|
146
|
+
|
147
|
+
--local-lib tells bin/tkar to use the lib dir at ./lib
|
148
|
+
", st_fixed)
|
149
|
+
|
150
|
+
insert('end', "\n\nRun tkar with the -h option to get the most up-to-date list of command line options.")
|
151
|
+
|
152
|
+
insert('end', "\n\nAuthor", [st_center, st_h1])
|
153
|
+
insert('end', "\n\nJoel VanderWerf, vjoel@users.sourceforge.net")
|
154
|
+
|
155
|
+
insert('end', "\n\nLicense", [st_center, st_h1])
|
156
|
+
insert('end', "\
|
157
|
+
\n\n
|
158
|
+
Use of Tkar is subject to the Ruby license:
|
159
|
+
http://www.ruby-lang.org/en/LICENSE.txt
|
160
|
+
|
161
|
+
Copyright (c) 2006-2009, Joel VanderWerf
|
162
|
+
")
|
163
|
+
|
164
|
+
state 'disabled'
|
165
|
+
}
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,376 @@
|
|
1
|
+
module Tkar
|
2
|
+
module Primitives
|
3
|
+
module_function
|
4
|
+
|
5
|
+
SHORTCUTS = {
|
6
|
+
"fc" => "fill",
|
7
|
+
"oc" => "outline",
|
8
|
+
"wi" => "width",
|
9
|
+
"da" => "dash",
|
10
|
+
"st" => "stipple",
|
11
|
+
}
|
12
|
+
|
13
|
+
def handle_shortcuts key
|
14
|
+
SHORTCUTS[key] || key
|
15
|
+
end
|
16
|
+
|
17
|
+
@color_str = {}
|
18
|
+
|
19
|
+
def color_str col
|
20
|
+
@color_str[col] ||=
|
21
|
+
begin
|
22
|
+
s = col.to_s(16).rjust(6, "0")
|
23
|
+
"##{s}"
|
24
|
+
rescue
|
25
|
+
col # assume col is a color name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
@dash_val = {}
|
30
|
+
|
31
|
+
def dash_val val
|
32
|
+
@dash_val[val] ||= val.is_a?(Integer) ? val.to_s.split("") : val
|
33
|
+
end
|
34
|
+
|
35
|
+
# handles the following options:
|
36
|
+
#
|
37
|
+
# fill
|
38
|
+
# outline
|
39
|
+
# width
|
40
|
+
# dash
|
41
|
+
# stipple
|
42
|
+
def handle_generic_config(config, params, key_args)
|
43
|
+
fc, oc, wi, da, st =
|
44
|
+
key_args.values_at(*%w{fill outline width dash stipple})
|
45
|
+
if fc
|
46
|
+
## skip if we saw this one before?
|
47
|
+
val = fc[params] rescue fc
|
48
|
+
config[:fill] = color_str(val)
|
49
|
+
end
|
50
|
+
if oc
|
51
|
+
val = oc[params] rescue oc
|
52
|
+
config[:outline] = color_str(val)
|
53
|
+
end
|
54
|
+
if wi
|
55
|
+
config[:width] = wi[params] rescue wi
|
56
|
+
end
|
57
|
+
if da
|
58
|
+
val = da[params] rescue da
|
59
|
+
config[:dash] = dash_val val
|
60
|
+
end
|
61
|
+
if st
|
62
|
+
config[:stipple] = st[params] rescue st
|
63
|
+
## how to use "@filename" to load file once and then use bitmap name?
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# arcX,Y,W,H,key:val...
|
68
|
+
#
|
69
|
+
# (X,Y) is center, W is width, H is height.
|
70
|
+
# This differs from Tk because it's better!
|
71
|
+
# Rotation may look strange if width != height
|
72
|
+
#
|
73
|
+
# extent angle
|
74
|
+
# start angle
|
75
|
+
# style sty (pieslice, chord, or arc)
|
76
|
+
def arc args, key_args
|
77
|
+
extent, start, style = key_args.values_at(*%w{extent start style})
|
78
|
+
|
79
|
+
proc do |tkaroid, cos_r, sin_r|
|
80
|
+
x = tkaroid.x
|
81
|
+
y = tkaroid.y
|
82
|
+
params = tkaroid.params
|
83
|
+
|
84
|
+
cx, cy, width, height = args.map {|arg| arg[params] rescue arg}
|
85
|
+
|
86
|
+
rcx = x + cx * cos_r - cy * sin_r
|
87
|
+
rcy = y + cx * sin_r + cy * cos_r
|
88
|
+
|
89
|
+
coords = [
|
90
|
+
rcx - width, rcy - height,
|
91
|
+
rcx + width, rcy + height ]
|
92
|
+
|
93
|
+
## possible to skip below if no changes?
|
94
|
+
config = {}
|
95
|
+
handle_generic_config(config, params, key_args)
|
96
|
+
|
97
|
+
if extent
|
98
|
+
config[:extent] = extent[params] rescue extent
|
99
|
+
end
|
100
|
+
if start
|
101
|
+
config[:start] = start[params] rescue start
|
102
|
+
config[:start] -= tkaroid.r * RADIANS_TO_DEGREES
|
103
|
+
end
|
104
|
+
if style
|
105
|
+
config[:style] = style[params] rescue style
|
106
|
+
end
|
107
|
+
|
108
|
+
[TkcArc, coords, config]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# lineX1,Y1,X2,Y2...,key:val...
|
113
|
+
#
|
114
|
+
# arrow where (none, first, last, both)
|
115
|
+
# arrowshape shape
|
116
|
+
# capstyle style (butt, projecting, round)
|
117
|
+
# joinstyle style (miter, bevel, round)
|
118
|
+
# smooth smoothMethod (true or false)
|
119
|
+
# splinesteps number
|
120
|
+
def line args, key_args
|
121
|
+
arrow, arrowshape, capstyle, joinstyle, smooth, splinesteps =
|
122
|
+
key_args.values_at(
|
123
|
+
*%w{arrow arrowshape capstyle joinstyle smooth splinesteps})
|
124
|
+
|
125
|
+
proc do |tkaroid, cos_r, sin_r|
|
126
|
+
x = tkaroid.x
|
127
|
+
y = tkaroid.y
|
128
|
+
params = tkaroid.params
|
129
|
+
|
130
|
+
coords = []
|
131
|
+
points = args.map {|arg| arg[params] rescue arg}
|
132
|
+
points.each_slice(2) do |xv, yv|
|
133
|
+
coords << x + xv * cos_r - yv * sin_r
|
134
|
+
coords << y + xv * sin_r + yv * cos_r
|
135
|
+
end
|
136
|
+
|
137
|
+
config = {}
|
138
|
+
handle_generic_config(config, params, key_args)
|
139
|
+
|
140
|
+
if arrow
|
141
|
+
config[:arrow] = arrow[params] rescue arrow
|
142
|
+
end
|
143
|
+
if arrowshape
|
144
|
+
val = arrowshape[params] rescue arrowshape
|
145
|
+
val = val.split("+").map{|s| Integer(s)}
|
146
|
+
config[:arrowshape] = val
|
147
|
+
end
|
148
|
+
if capstyle
|
149
|
+
config[:capstyle] = capstyle[params] rescue capstyle
|
150
|
+
end
|
151
|
+
if joinstyle
|
152
|
+
config[:joinstyle] = joinstyle[params] rescue joinstyle
|
153
|
+
end
|
154
|
+
if smooth
|
155
|
+
config[:smooth] = smooth[params] rescue smooth
|
156
|
+
end
|
157
|
+
if splinesteps
|
158
|
+
config[:splinesteps] = splinesteps[params] rescue splinesteps
|
159
|
+
end
|
160
|
+
|
161
|
+
[TkcLine, coords, config]
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# ovalX1,Y1,X2,Y2,key:val...
|
166
|
+
# standard keys
|
167
|
+
def oval args, key_args
|
168
|
+
proc do |tkaroid, cos_r, sin_r|
|
169
|
+
x = tkaroid.x
|
170
|
+
y = tkaroid.y
|
171
|
+
params = tkaroid.params
|
172
|
+
|
173
|
+
coords = []
|
174
|
+
points = args.map {|arg| arg[params] rescue arg}
|
175
|
+
points.each_slice(2) do |xv, yv|
|
176
|
+
coords << x + xv * cos_r - yv * sin_r
|
177
|
+
coords << y + xv * sin_r + yv * cos_r
|
178
|
+
end
|
179
|
+
|
180
|
+
config = {}
|
181
|
+
handle_generic_config(config, params, key_args)
|
182
|
+
|
183
|
+
[TkcOval, coords, config]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# rectX1,Y1,X2,Y2,key:val...
|
188
|
+
# standard keys
|
189
|
+
def rect args, key_args
|
190
|
+
proc do |tkaroid, cos_r, sin_r|
|
191
|
+
x = tkaroid.x
|
192
|
+
y = tkaroid.y
|
193
|
+
params = tkaroid.params
|
194
|
+
|
195
|
+
coords = []
|
196
|
+
points = args.map {|arg| arg[params] rescue arg}
|
197
|
+
points.each_slice(2) do |xv, yv|
|
198
|
+
coords << x + xv * cos_r - yv * sin_r
|
199
|
+
coords << y + xv * sin_r + yv * cos_r
|
200
|
+
end
|
201
|
+
|
202
|
+
config = {}
|
203
|
+
handle_generic_config(config, params, key_args)
|
204
|
+
|
205
|
+
[TkcRectangle, coords, config]
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# polyX1,Y1,X2,Y2,...key:val...
|
210
|
+
#
|
211
|
+
# joinstyle style (miter, bevel, round)
|
212
|
+
# smooth smoothMethod (true or false)
|
213
|
+
# splinesteps number
|
214
|
+
def poly args, key_args
|
215
|
+
joinstyle, smooth, splinesteps =
|
216
|
+
key_args.values_at(*%w{joinstyle smooth splinesteps})
|
217
|
+
|
218
|
+
proc do |tkaroid, cos_r, sin_r|
|
219
|
+
x = tkaroid.x
|
220
|
+
y = tkaroid.y
|
221
|
+
params = tkaroid.params
|
222
|
+
|
223
|
+
coords = []
|
224
|
+
points = args.map {|arg| arg[params] rescue arg}
|
225
|
+
points.each_slice(2) do |xv, yv|
|
226
|
+
coords << x + xv * cos_r - yv * sin_r
|
227
|
+
coords << y + xv * sin_r + yv * cos_r
|
228
|
+
end
|
229
|
+
|
230
|
+
config = {}
|
231
|
+
handle_generic_config(config, params, key_args)
|
232
|
+
|
233
|
+
if joinstyle
|
234
|
+
config[:joinstyle] = joinstyle[params] rescue joinstyle
|
235
|
+
end
|
236
|
+
if smooth
|
237
|
+
config[:smooth] = smooth[params] rescue smooth
|
238
|
+
end
|
239
|
+
if splinesteps
|
240
|
+
config[:splinesteps] = splinesteps[params] rescue splinesteps
|
241
|
+
end
|
242
|
+
|
243
|
+
[TkcPolygon, coords, config]
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
# textX,Y,key:val...
|
248
|
+
#
|
249
|
+
# anchor anchorPos (center, n, nw, ...)
|
250
|
+
# font fontName
|
251
|
+
# justify how (left, right, or center)
|
252
|
+
# text string (**)
|
253
|
+
# width lineLength
|
254
|
+
#
|
255
|
+
# (**) text with embedded spaces can be specified only via a param command
|
256
|
+
def text args, key_args
|
257
|
+
anchor, font, justify, text =
|
258
|
+
key_args.values_at(*%w{anchor font justify text})
|
259
|
+
# width handled by handle_generic_config
|
260
|
+
|
261
|
+
proc do |tkaroid, cos_r, sin_r|
|
262
|
+
x = tkaroid.x
|
263
|
+
y = tkaroid.y
|
264
|
+
params = tkaroid.params
|
265
|
+
|
266
|
+
xv, yv = args.map {|arg| arg[params] rescue arg}
|
267
|
+
coords = [
|
268
|
+
x + xv * cos_r - yv * sin_r,
|
269
|
+
y + xv * sin_r + yv * cos_r
|
270
|
+
]
|
271
|
+
|
272
|
+
config = {}
|
273
|
+
handle_generic_config(config, params, key_args)
|
274
|
+
|
275
|
+
if anchor
|
276
|
+
config[:anchor] = anchor[params] rescue anchor
|
277
|
+
end
|
278
|
+
if font
|
279
|
+
config[:font] = font[params] rescue font
|
280
|
+
end
|
281
|
+
if justify
|
282
|
+
config[:justify] = justify[params] rescue justify
|
283
|
+
end
|
284
|
+
if text
|
285
|
+
config[:text] = text[params] rescue text
|
286
|
+
end
|
287
|
+
|
288
|
+
[TkcText, coords, config]
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
# imageX,Y,key:val...
|
293
|
+
#
|
294
|
+
# anchor anchorPos (center, n, nw, ...)
|
295
|
+
# image imageFileName
|
296
|
+
#
|
297
|
+
def image args, key_args
|
298
|
+
anchor, image = key_args.values_at(*%w{anchor image})
|
299
|
+
|
300
|
+
proc do |tkaroid, cos_r, sin_r|
|
301
|
+
x = tkaroid.x
|
302
|
+
y = tkaroid.y
|
303
|
+
params = tkaroid.params
|
304
|
+
|
305
|
+
xv, yv = args.map {|arg| arg[params] rescue arg}
|
306
|
+
coords = [
|
307
|
+
x + xv * cos_r - yv * sin_r,
|
308
|
+
y + xv * sin_r + yv * cos_r
|
309
|
+
]
|
310
|
+
|
311
|
+
config = {}
|
312
|
+
if anchor
|
313
|
+
config[:anchor] = anchor[params] rescue anchor
|
314
|
+
end
|
315
|
+
if image
|
316
|
+
config[:image] = get_image(image[params]) rescue get_image(image)
|
317
|
+
end
|
318
|
+
|
319
|
+
[TkcImage, coords, config]
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
def get_image file_name
|
324
|
+
@@images ||= {}
|
325
|
+
@@images[file_name] ||= TkPhotoImage.new(:file => file_name)
|
326
|
+
end
|
327
|
+
|
328
|
+
## bitmap
|
329
|
+
|
330
|
+
# anchor anchorPos
|
331
|
+
# height pixels
|
332
|
+
# width pixels
|
333
|
+
# window pathName
|
334
|
+
## def window args, key_args
|
335
|
+
## x, y = args
|
336
|
+
##
|
337
|
+
## end
|
338
|
+
|
339
|
+
# An embedded window that shows a list of key-value pairs.
|
340
|
+
## def proplist args, key_args
|
341
|
+
## end
|
342
|
+
|
343
|
+
# just a very simple example!
|
344
|
+
def polybox args, key_args
|
345
|
+
dx, dy = args
|
346
|
+
|
347
|
+
# return a proc to make the info needed to instantiate/update
|
348
|
+
proc do |tkaroid, cos_r, sin_r|
|
349
|
+
x = tkaroid.x
|
350
|
+
y = tkaroid.y
|
351
|
+
params = tkaroid.params
|
352
|
+
|
353
|
+
ex = dx[params] rescue dx
|
354
|
+
ey = dy[params] rescue dy
|
355
|
+
|
356
|
+
points =
|
357
|
+
[ [ ex, ey],
|
358
|
+
[ ex, -ey],
|
359
|
+
[-ex, -ey],
|
360
|
+
[-ex, ey] ]
|
361
|
+
|
362
|
+
coords = []
|
363
|
+
points.each do |xv, yv|
|
364
|
+
coords << x + xv * cos_r - yv * sin_r
|
365
|
+
coords << y + xv * sin_r + yv * cos_r
|
366
|
+
end
|
367
|
+
|
368
|
+
## possible to skip below if no changes?
|
369
|
+
config = {}
|
370
|
+
handle_generic_config(config, params, key_args)
|
371
|
+
|
372
|
+
[TkcPolygon, coords, config]
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|