arcadia 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ name=shell
2
+ active=yes
3
+ require=ext/ae-shell/ae-shell
4
+ class=Shell
5
+
6
+
7
+ #:::::::::::::::: output ::::::::::::::::::::::<begin>
8
+ ruby=ruby1.8
9
+ i386-freebsd6:ruby=ruby
10
+ i386-mswin32:ruby=ruby
11
+ #:::::::::::::::: output ::::::::::::::::::::::<end>
@@ -0,0 +1,54 @@
1
+ #
2
+ # ae-shell.rb - Arcadia Ruby ide
3
+ # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
+ #
5
+
6
+ require "tk"
7
+ require "base/a-utils"
8
+
9
+ class Shell < ArcadiaExt
10
+
11
+ def build
12
+ #@ae_msg_contract = @arcadia.retrieve_contract(self, MsgContract)
13
+ @run_threads = Array.new
14
+ end
15
+
16
+ def run_last
17
+ run($arcadia['pers']['run.file.last'])
18
+ end
19
+
20
+ def run_current
21
+ current_editor = $arcadia['editor'].raised
22
+ run(current_editor.file) if current_editor
23
+ end
24
+
25
+ def stop
26
+ @run_threads.each{|t|
27
+ if t.alive?
28
+ t.kill
29
+ end
30
+ }
31
+ debug_quit if @adw
32
+ end
33
+
34
+
35
+ def run(_filename=nil)
36
+ if _filename
37
+ begin
38
+ $arcadia['pers']['run.file.last']=_filename
39
+ @run_threads << Thread.new{
40
+ @cmd = open("|"+$arcadia['conf']['shell.ruby']+" "+_filename+" 2>&1","r"){
41
+ |f|
42
+ MsgContract.instance.out_debug(self, f.read)
43
+ #@ae_msg_contract.out_debug(f.read)
44
+ }
45
+ }
46
+ rescue Exception => e
47
+ MsgContract.instance.out_debug(self, e)
48
+ #@ae_msg_contract.out_debug(e)
49
+ #@main_frame.text.insert('end', "---> "+e )
50
+ end
51
+ end
52
+ end
53
+
54
+ end
data/lib/tk/al-tk.rb ADDED
@@ -0,0 +1,3078 @@
1
+ #
2
+ # al-tk.rb - Arcadia Ruby ide
3
+ # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
+ #
5
+
6
+ require 'tk'
7
+ require 'base/a-libs'
8
+ require "base/a-ext"
9
+ require "lib/tk/al-tk.res"
10
+
11
+ TkAllPhotoImage = TkPhotoImage
12
+
13
+ class AGTkObjRect
14
+ attr_reader :r, :start_x, :start_y, :motion, :x0, :y0, :w0, :h0
15
+ attr_writer :r, :start_x, :start_y, :motion
16
+ def initialize(_parent, _x0, _y0, _w0 , _h0, _side , _cursor, _bind = true )
17
+ if _bind
18
+ _bc = 'white'
19
+ else
20
+ _bc = 'red'
21
+ end
22
+ @r = TkLabel.new(_parent){
23
+ background _bc
24
+ highlightbackground 'black'
25
+ relief 'groove'
26
+ place('x' => _x0 , 'y' => _y0, 'width' => _w0, 'height' => _h0)
27
+ }
28
+ @motion = false
29
+ @side = _side
30
+ @x0 = _x0
31
+ @y0 = _y0
32
+ @w0 = _w0
33
+ @h0 = _h0
34
+ @start_x = _x0
35
+ @start_y = _y0
36
+ @cursor = _cursor
37
+ if _bind
38
+ @r.bind("Enter", proc{|x, y| do_enter(x, y)}, "%x %y")
39
+ @r.bind("ButtonPress-1", proc{|e| do_press(e.x, e.y)})
40
+ @r.bind("B1-Motion", proc{|x, y| do_motion(x,y)},"%x %y")
41
+ end
42
+ end
43
+
44
+ def do_enter(x, y)
45
+ @oldcursor = @r.cget('cursor')
46
+ @r.configure('cursor'=> @cursor)
47
+ end
48
+
49
+ def do_leave
50
+ @r.configure('cursor'=>@oldcursor)
51
+ end
52
+
53
+ def do_press(x, y)
54
+ @start_x = x
55
+ @start_y = y
56
+ end
57
+
58
+ def do_motion( x, y)
59
+ @motion = true
60
+ move(x - @start_x, y - @start_y)
61
+ end
62
+
63
+ def move(_x,_y)
64
+ case @side
65
+ when 'both'
66
+ @x0 = @x0 + _x
67
+ @y0 = @y0 + _y
68
+ @r.place('x' => @x0, 'y' => @y0)
69
+ when 'x'
70
+ @x0 = @x0 + _x
71
+ @r.place('x' => @x0)
72
+ when 'y'
73
+ @y0 = @y0 + _y
74
+ @r.place('y' => @y0)
75
+ end
76
+ end
77
+
78
+ end
79
+
80
+ class AGTkSimpleManager
81
+
82
+ def initialize(_agobj, _active)
83
+ @agobj = _agobj
84
+ @active = _active
85
+ add_bind
86
+ # @byb = true
87
+ end
88
+
89
+ def add_bind
90
+ @agobj.obj.bind_append("ButtonPress-1", proc{object_inspector_select})
91
+ end
92
+
93
+ # def bypass_bind
94
+ # @byb = true
95
+ # end
96
+
97
+ def object_inspector_select
98
+ @agobj.select
99
+ #@agobj.object_inspector.select(@agobj, false) if !defined? @agobj.object_inspector.active_object or @agobj.object_inspector.active_object != @agobj
100
+ AGTkLManager.deactivate_all
101
+ end
102
+
103
+ end
104
+
105
+ class AGTkPlaceManager
106
+
107
+ def initialize(_agobj, _active=false)
108
+ #Tk.messageBox('message'=>_active.to_s)
109
+ unless defined? _agobj.ag_parent
110
+ break
111
+ end
112
+ @agobj = _agobj
113
+ if !defined? @@place_managers
114
+ @@place_managers = Array.new
115
+ end
116
+ if @agobj.ag_parent != nil
117
+ @top = @agobj.ag_parent
118
+ while @top.l_manager.simple_manager == nil
119
+ @top = @top.ag_parent
120
+ end
121
+ end
122
+ initx0x3
123
+ flash
124
+ obj_bind
125
+ activate if _active
126
+ object_inspector_select if _active
127
+ @active = _active
128
+ @last_layout = @agobj.props['layout_man']['manager']['get'].call
129
+ @@place_managers << self
130
+ @cursor = 'fleur'
131
+ end
132
+
133
+ def obj_bind
134
+ if (@agobj.ag_parent != nil)
135
+ @agobj.obj.bind_append("ButtonPress-1", proc{|e| do_press_obj(e.x, e.y);@agobj.obj.callback_break})
136
+ @agobj.obj.bind_append("ButtonRelease-1", proc{|e| do_release_obj(e.x, e.y)})
137
+ @agobj.obj.bind("B1-Motion", proc{|x, y| do_mov_obj(x,y)},"%x %y")
138
+ @agobj.obj.bind("Control-ButtonPress-1", proc{
139
+ if active?
140
+ deactivate
141
+ else
142
+ activate(false)
143
+ end
144
+ #do_bypass_parent_bind
145
+ })
146
+ @agobj.obj.bind("Control-ButtonRelease-1", proc{})
147
+ if @agobj.obj.configure('cursor') != nil
148
+ @agobj.obj.bind_append("Enter", proc{|x, y| do_enter_obj(x, y)}, "%x %y" )
149
+ @agobj.obj.bind_append("Leave", proc{do_leave_obj})
150
+ end
151
+ end
152
+ end
153
+
154
+ def do_release_obj(x,y)
155
+ @agobj.update_property(@agobj, 'place', 'x', @x0)
156
+ @agobj.update_property(@agobj, 'place', 'y', @y0)
157
+ end
158
+
159
+ def do_enter_obj(x, y)
160
+ @oldcursor = @agobj.obj.cget('cursor')
161
+ @agobj.obj.configure('cursor'=> @cursor)
162
+ end
163
+
164
+ def do_leave_obj
165
+ @agobj.obj.configure('cursor'=>@oldcursor)
166
+ end
167
+
168
+ def do_mov_obj(x,y)
169
+ x00 = @x0
170
+ y00 = @y0
171
+ @x0 = @x0 + x - @start_x
172
+ @y0 = @y0 + y - @start_y
173
+ @agobj.obj.place('x'=>@x0, 'y'=>@y0)
174
+ @x3 = @x3 + @x0 - x00
175
+ @y3 = @y3 + @y0 - y00
176
+ move_other_obj(@x0 - x00,@y0 - y00)
177
+ end
178
+
179
+ def do_mov_obj_delta(_delta_x=1, _delta_y=1)
180
+ x00 = @x0
181
+ y00 = @y0
182
+ @x0 = @x0 + _delta_x
183
+ #@agobj.update_property('place', 'x', @x0)
184
+ @y0 = @y0 + _delta_y
185
+ #@agobj.update_property('place', 'y', @y0)
186
+ @agobj.obj.place('x'=>@x0, 'y'=>@y0)
187
+ @x3 = @x3 + @x0 - x00
188
+ @y3 = @y3 + @y0 - y00
189
+ end
190
+
191
+ def do_mov_obj_delta_dim(_delta_width=1, _delta_height=1)
192
+ _width = @x3 - @x0 + _delta_width
193
+ _height = @y3 - @y0 + _delta_height
194
+ #@agobj.update_property('place', 'width', _width)
195
+ #@agobj.update_property('place', 'height', _height)
196
+ @agobj.obj.place('width'=>_width, 'height'=>_height)
197
+ @x3 = @x0 + _width
198
+ @y3 = @y0 + _height
199
+ end
200
+
201
+ def object_inspector_select
202
+ @agobj.select
203
+ #@agobj.object_inspector.select(@agobj, false) if !defined? @agobj.object_inspector.active_object or @agobj.object_inspector.active_object != @agobj
204
+ end
205
+
206
+ def do_press_obj(x, y)
207
+ @start_x = x
208
+ @start_y = y
209
+ object_inspector_select
210
+ end
211
+
212
+ def getx0x3
213
+ @agobj.props['place']['x']['value'] = @agobj.props['place']['x']['get'].call.to_i
214
+ @agobj.props['place']['y']['value'] = @agobj.props['place']['y']['get'].call.to_i
215
+ @agobj.props['place']['width']['value'] = @agobj.props['place']['width']['get'].call.to_i
216
+ @agobj.props['place']['height']['value'] = @agobj.props['place']['height']['get'].call.to_i
217
+ @x0 = @agobj.props['place']['x']['value']
218
+ @y0 = @agobj.props['place']['y']['value']
219
+ @x3 = @x0 + @agobj.props['place']['width']['value']
220
+ @y3 = @y0 + @agobj.props['place']['height']['value']
221
+ end
222
+
223
+ def initx0x3(_prop = nil, _value = nil)
224
+ case _prop
225
+ when 'x'
226
+ _x = @x0
227
+ @x0 = _value.to_i
228
+ @x3 = @x3 + @x0 - _x
229
+ when 'y'
230
+ _y = @y0
231
+ @y0 = _value.to_i
232
+ @y3 = @y3 + @y0 - _y
233
+ when 'width'
234
+ @x3 = @x0 + _value.to_i
235
+ when 'height'
236
+ @y3 = @y0 + _value.to_i
237
+ when nil, 'text'
238
+ getx0x3
239
+ end
240
+ @start_x = @x0 if defined? @x0
241
+ @start_y = @y0 if defined? @y0
242
+ end
243
+
244
+ def move_other_obj(x,y)
245
+ @@place_managers.each do |value|
246
+ if (value != self)&&(value.active?)
247
+ value.do_mov_obj_delta(x,y)
248
+ end
249
+ end
250
+ end
251
+
252
+ def deactivate
253
+ self.free_rect
254
+ @active = false
255
+ end
256
+
257
+ def refresh_active
258
+ @@place_managers.each do |value|
259
+ if value.active?
260
+ value.refresh
261
+ end
262
+ end
263
+ end
264
+
265
+ def refresh
266
+ getx0x3
267
+ activate(false)
268
+ end
269
+
270
+
271
+ def activate(free=true)
272
+ if free
273
+ @@place_managers.each do |value|
274
+ value.deactivate
275
+ end
276
+ else
277
+ self.free_rect
278
+ end
279
+ _layout = @agobj.props['layout_man']['manager']['get'].call
280
+ _bind = _layout == 'place'
281
+ if _bind && @last_layout != 'place'
282
+ @agobj.obj.place('x'=> @ox0,'y'=> @oy0)
283
+ end
284
+ create_rect(_bind)
285
+ @last_layout = _layout
286
+ @active = true
287
+ end
288
+
289
+ def active?
290
+ return @active
291
+ end
292
+
293
+ def create_rect(_bind = true)
294
+ _L = 6
295
+ _mx = 0
296
+ _my = 0
297
+
298
+ # r1 r14 r4
299
+ # r12 r34
300
+ # r2 r23 r3
301
+
302
+ _x0_RectLeft = @x0 - _L - _mx
303
+ _x3_RectLeft = @x3 + _mx
304
+ _x14_RectLeft = (@x3 + @x0)/2 - _L/2
305
+ _y0_RectLeft = @y0 - _L - _my
306
+ _y3_RectLeft = @y3 + _my
307
+ _y12_RectLeft = (@y3 + @y0 - _L)/2
308
+
309
+ @r1 = AGTkObjRect.new(@agobj.ag_parent.obj, _x0_RectLeft, _y0_RectLeft, _L, _L,'both',
310
+ 'top_left_corner',_bind)
311
+ @r12 = AGTkObjRect.new(@agobj.ag_parent.obj, _x0_RectLeft, _y12_RectLeft, _L, _L,
312
+ 'x', 'sb_h_double_arrow',_bind)
313
+ @r2 = AGTkObjRect.new(@agobj.ag_parent.obj, _x0_RectLeft, _y3_RectLeft, _L, _L,'both', 'bottom_left_corner',_bind)
314
+ @r3 = AGTkObjRect.new(@agobj.ag_parent.obj,_x3_RectLeft, _y3_RectLeft, _L, _L,'both','bottom_right_corner',_bind)
315
+ @r34 = AGTkObjRect.new(@agobj.ag_parent.obj, _x3_RectLeft, _y12_RectLeft, _L, _L, 'x', 'sb_h_double_arrow',_bind)
316
+ @r4 = AGTkObjRect.new(@agobj.ag_parent.obj,_x3_RectLeft, _y0_RectLeft, _L, _L,'both', 'top_right_corner',_bind)
317
+ @r14 = AGTkObjRect.new(@agobj.ag_parent.obj, _x14_RectLeft, _y0_RectLeft, _L, _L,'y', 'sb_v_double_arrow',_bind)
318
+ @r23 = AGTkObjRect.new(@agobj.ag_parent.obj, _x14_RectLeft, _y3_RectLeft, _L, _L,'y', 'sb_v_double_arrow',_bind)
319
+ if _bind
320
+ @r1.r.bind("ButtonRelease-1", proc{do_Release(@r1)})
321
+ @r1.r.bind_append("B1-Motion",proc{geomvar(@r1)})
322
+ @r12.r.bind("ButtonRelease-1", proc{do_Release(@r12)})
323
+ @r12.r.bind_append("B1-Motion",proc{geomvar(@r12)})
324
+ @r2.r.bind("ButtonRelease-1", proc{do_Release(@r2)})
325
+ @r2.r.bind_append("B1-Motion",proc{geomvar(@r2)})
326
+ @r3.r.bind("ButtonRelease-1", proc{do_Release(@r3)})
327
+ @r3.r.bind_append("B1-Motion",proc{geomvar(@r3)})
328
+ @r34.r.bind("ButtonRelease-1", proc{do_Release(@r34)})
329
+ @r34.r.bind_append("B1-Motion",proc{geomvar(@r34)})
330
+ @r4.r.bind("ButtonRelease-1", proc{do_Release(@r4)})
331
+ @r4.r.bind_append("B1-Motion",proc{geomvar(@r4)})
332
+ @r14.r.bind("ButtonRelease-1", proc{do_Release(@r14)})
333
+ @r14.r.bind_append("B1-Motion",proc{geomvar(@r14)})
334
+ @r23.r.bind("ButtonRelease-1", proc{do_Release(@r23)})
335
+ @r23.r.bind_append("B1-Motion",proc{geomvar(@r23)})
336
+
337
+ @r1.r.bind_append("ButtonPress-1", proc{@r1.r.callback_break})
338
+ @r12.r.bind_append("ButtonPress-1", proc{@r12.r.callback_break})
339
+ @r2.r.bind_append("ButtonPress-1", proc{@r2.r..callback_break})
340
+ @r3.r.bind_append("ButtonPress-1", proc{@r3.r.callback_break})
341
+ @r34.r.bind_append("ButtonPress-1", proc{@r34.r.callback_break})
342
+ @r4.r.bind_append("ButtonPress-1", proc{@r4.r.callback_break})
343
+ @r14.r.bind_append("ButtonPress-1", proc{@r14.r.callback_break})
344
+ @r23.r.bind_append("ButtonPress-1", proc{@r23.r.callback_break})
345
+ end
346
+ flash
347
+ end
348
+
349
+ def flash
350
+ @ox0 = @x0
351
+ @ox3 = @x3
352
+ @oy0 = @y0
353
+ @oy3 = @y3
354
+ end
355
+
356
+ def free_rect
357
+ if defined? @r1
358
+ @r1.r.destroy
359
+ end
360
+ if defined? @r2
361
+ @r2.r.destroy
362
+ end
363
+ if defined? @r3
364
+ @r3.r.destroy
365
+ end
366
+ if defined? @r4
367
+ @r4.r.destroy
368
+ end
369
+ if defined? @r14
370
+ @r14.r.destroy
371
+ end
372
+ if defined? @r23
373
+ @r23.r.destroy
374
+ end
375
+ if defined? @r12
376
+ @r12.r.destroy
377
+ end
378
+ if defined? @r34
379
+ @r34.r.destroy
380
+ end
381
+ end
382
+
383
+ def do_start(_r)
384
+ case _r
385
+ when @r3
386
+ @r4.start_x = _r.start_x
387
+ @r2.start_y = _r.start_y
388
+ end
389
+ end
390
+
391
+ def resize_rect(_x0,_y0, _x3,_y3, _r)
392
+ # r1 r14 r4
393
+ # r12 r34
394
+ # r2 r23 r3
395
+ if defined? _r
396
+ if _r != @r1
397
+ @r1.r.place('x' =>_x0 - @r1.w0 , 'y' => _y0 - @r1.h0)
398
+ end
399
+ if _r != @r2
400
+ @r2.r.place('x' =>_x0 - @r2.w0, 'y' => _y3)
401
+ end
402
+ if _r != @r3
403
+ @r3.r.place('x' =>_x3, 'y' => _y3)
404
+ end
405
+ if _r != @r4
406
+ @r4.r.place('x' =>_x3, 'y' => _y0 - @r4.h0)
407
+ end
408
+ if _r != @r14
409
+ @r14.r.place('x' => (_x3 +_x0 - @r14.w0)/2, 'y' => _y0 - @r14.h0)
410
+ end
411
+ if _r != @r23
412
+ @r23.r.place('x' => (_x3 +_x0 - @r23.w0)/2, 'y' => _y3)
413
+ end
414
+ if _r != @r12
415
+ @r12.r.place('x' => _x0 - @r12.w0, 'y' => (_y3 + _y0 - @r12.w0)/2)
416
+ end
417
+ if _r != @r34
418
+ @r34.r.place('x' => _x3 , 'y' => (_y3 + _y0 - @r34.w0)/2)
419
+ end
420
+ end
421
+ end
422
+
423
+ def border
424
+ @l1.delete if defined? @l1
425
+ @l1 = TkcLine.new(@agobj.ag_parent.canvas, @ox0, @oy0, @ox3,@oy0, @ox3,@oy3, @ox0 , @oy3, @ox0, @oy0){
426
+ fill 'red'
427
+ width 0.2
428
+ }
429
+ end
430
+
431
+ def geomvar(_r)
432
+ # r1 r14 r4
433
+ # r12 r34
434
+ # r2 r23 r3
435
+ case _r
436
+ when @r1
437
+ w = @ox3 - @r1.x0 - @r1.w0
438
+ h = @oy3 - @r1.y0 - @r1.h0
439
+ @ox0 = @ox3 - w
440
+ @oy0 = @oy3 - h
441
+ when @r12
442
+ w = @ox3 - @r12.x0 - @r12.w0
443
+ @ox0 = @ox3 - w
444
+ when @r2
445
+ w = @ox3 - @r2.x0 - @r2.w0
446
+ h = @r2.y0 - @oy0
447
+ @ox0 = @ox3 - w
448
+ @oy3 = @oy0 + h
449
+ when @r23
450
+ h = @r23.y0 - @oy0
451
+ @oy3 = @oy0 + h
452
+ when @r3
453
+ w = @r3.x0 - @ox0
454
+ h = @r3.y0 - @oy0
455
+ @ox3 = @ox0 + w
456
+ @oy3 = @oy0 + h
457
+ when @r34
458
+ w = @r34.x0 - @ox0
459
+ @ox3 = @ox0 + w
460
+ when @r4
461
+ w = @r4.x0 - @ox0
462
+ h = @oy3 - @r4.y0 - @r4.h0
463
+ @oy0 = @oy3 - h
464
+ @ox3 = @ox0 + w
465
+ when @r14
466
+ h = @oy3 - @r14.y0 - @r14.h0
467
+ @oy0 = @oy3 - h
468
+ end
469
+ resize_rect(@ox0, @oy0 , @ox3, @oy3, _r)
470
+ end
471
+
472
+ def do_Release(_r)
473
+ # r1 r14 r4
474
+ # r12 r34
475
+ # r2 r23 r3
476
+ if _r.motion
477
+ case _r
478
+ when @r1
479
+ w = @ox3 - @ox0
480
+ h = @oy3 - @oy0
481
+ @agobj.update_property(@agobj, 'place', 'x', @ox0) if @ox0 != @x0
482
+ @agobj.update_property(@agobj, 'place', 'y', @oy0) if @oy0 != @y0
483
+ @agobj.update_property(@agobj, 'place', 'width', w) if w != @x3 - @x0
484
+ @agobj.update_property(@agobj, 'place', 'height', h) if h != @y3 - @y0
485
+ when @r12
486
+ w = @ox3 - @ox0
487
+ @agobj.update_property(@agobj, 'place', 'x', @ox0) if @ox0 != @x0
488
+ @agobj.update_property(@agobj, 'place', 'width', w) if w != @x3 - @x0
489
+ when @r2
490
+ w = @ox3 - @ox0
491
+ h = @oy3 - @oy0
492
+ @agobj.update_property(@agobj, 'place', 'x', @ox0) if @ox0 != @x0
493
+ @agobj.update_property(@agobj, 'place', 'width', w) if w != @x3 - @x0
494
+ @agobj.update_property(@agobj, 'place', 'height', h) if h != @y3 - @y0
495
+ when @r23
496
+ h = @oy3 - @oy0
497
+ @agobj.update_property(@agobj, 'place', 'height', h) if h != @y3 - @y0
498
+ when @r3
499
+ w = @ox3 - @ox0
500
+ h = @oy3 - @oy0
501
+ @agobj.update_property(@agobj, 'place', 'width', w) if w != @x3 - @x0
502
+ @agobj.update_property(@agobj, 'place', 'height', h) if h != @y3 - @y0
503
+ when @r34
504
+ w = @ox3 - @ox0
505
+ @agobj.update_property(@agobj, 'place', 'width', w) if w != @x3 - @x0
506
+ when @r4
507
+ w = @ox3 - @ox0
508
+ h = @oy3 - @oy0
509
+
510
+ @agobj.update_property(@agobj, 'place', 'y', @oy0) if @oy0 != @y0
511
+ @agobj.update_property(@agobj, 'place', 'width', w) if w != @x3 - @x0
512
+ @agobj.update_property(@agobj, 'place', 'height', h) if h != @y3 - @y0
513
+ when @r14
514
+ h = @oy3 - @oy0
515
+ @agobj.update_property(@agobj, 'place', 'y', @oy0) if @oy0 != @y0
516
+ @agobj.update_property(@agobj, 'place', 'height', h) if h != @y3 - @y0
517
+
518
+ end
519
+ @x0 = @ox0
520
+ @y0 = @oy0
521
+ @x3 = @ox3
522
+ @y3 = @oy3
523
+ @l1.delete if defined? @l1
524
+ _r.motion = false
525
+ end
526
+ end
527
+
528
+ def move_rect(x,y)
529
+ @r1.move(x,y) if defined? @r1
530
+ @r2.move(x,y) if defined? @r2
531
+ @r3.move(x,y) if defined? @r3
532
+ @r4.move(x,y) if defined? @r4
533
+ @r14.move(x,y) if defined? @r14
534
+ @ox0 = @agobj.x0
535
+ @ox3 = @agobj.x3
536
+ @oy0 = @agobj.y0
537
+ @oy3 = @agobj.y3
538
+ end
539
+
540
+ end
541
+
542
+ class AGTkObjPackRect
543
+ attr :r
544
+
545
+ def initialize(_parent,_w0 , _h0, _anchor)
546
+ @r = TkLabel.new(_parent){
547
+ text 'p'
548
+ font 'courier 8'
549
+ highlightbackground 'black'
550
+ background 'yellow'
551
+ relief 'groove'
552
+ pack('ipadx'=>0,'ipady'=>0, 'anchor' => _anchor)
553
+ }
554
+ end
555
+
556
+ end
557
+
558
+ class AGTkPackManager
559
+
560
+ def initialize(_agobj, _active)
561
+ unless defined? _agobj.ag_parent
562
+ break
563
+ end
564
+ @agobj = _agobj
565
+ if !defined? @@packs_managers
566
+ @@packs_managers = Array.new
567
+ end
568
+ activate if _active
569
+ @@packs_managers << self
570
+ end
571
+
572
+ def deactivate
573
+ self.free_rect
574
+ end
575
+
576
+ def activate
577
+ @@packs_managers.each do |value|
578
+ value.free_rect
579
+ end
580
+ create_rect
581
+ end
582
+
583
+ def create_rect
584
+ # r1 r14 r4
585
+ # r12 r34
586
+ # r2 r23 r3
587
+ TkPack::propagate(@agobj.obj, false)
588
+ @r1 = AGTkObjPackRect.new(@agobj.obj, 3, 3, 'nw')
589
+ end
590
+
591
+ def free_rect
592
+ if defined? @r1
593
+ @r1.r.destroy
594
+ end
595
+ end
596
+
597
+ end
598
+
599
+ class AGTkGridManager
600
+
601
+ def initialize(_agobj, _active)
602
+ unless defined? _agobj.ag_parent
603
+ break
604
+ end
605
+ @agobj = _agobj
606
+ if !defined? @@grids_managers
607
+ @@grids_managers = Array.new
608
+ end
609
+ activate if _active
610
+ @@grids_managers << self
611
+ end
612
+
613
+ def deactivate
614
+ end
615
+
616
+ def activate
617
+ end
618
+
619
+ end
620
+
621
+
622
+ class AGTkLManager
623
+ attr_reader :place_manager
624
+ attr_reader :simple_manager
625
+
626
+ def initialize(_agobj, _activate)
627
+ unless defined? _agobj.ag_parent
628
+ break
629
+ end
630
+ @@place_managers = Array.new if !defined? @@place_managers
631
+ @@pack_managers = Array.new if !defined? @@pack_managers
632
+ @@grid_managers = Array.new if !defined? @@grid_managers
633
+ @agobj = _agobj
634
+ @agobj.obj.bind_append("ButtonPress-1", proc{switch_manager(_activate)})
635
+ set_manager(_agobj.props['layout_man']['manager']['get'].call, _activate)
636
+ @active = _activate
637
+ end
638
+
639
+ def active?
640
+ return @active||@place_manager.active?
641
+ end
642
+
643
+ def switch_manager(_activate=true)
644
+ _req_manager = @agobj.props['layout_man']['manager']['get'].call
645
+ if @manager != _req_manager
646
+ set_manager(_req_manager, _activate)
647
+ end
648
+ end
649
+
650
+ def set_manager(_name, _activate)
651
+ case _name
652
+ when 'place'
653
+ if !defined? @place_manager
654
+ @place_manager = AGTkPlaceManager.new(@agobj,_activate)
655
+ @@last = @place_manager
656
+ @@place_managers << @place_manager
657
+ end
658
+ if defined? @pack_manager
659
+ @pack_manager.free_rect
660
+ end
661
+ when 'pack'
662
+ if !defined? @pack_manager
663
+ @pack_manager = AGTkPackManager.new(@agobj,_activate) if !defined? @pack_manager
664
+ @@last = @pack_manager
665
+ @@pack_managers << @pack_manager
666
+ end
667
+ if defined? @place_manager
668
+ @place_manager.free_rect
669
+ end
670
+ when 'grid'
671
+ if !defined? @grid_manager
672
+ @grid_manager = AGTkGridManager.new(@agobj,_activate) if !defined? @grid_manager
673
+ @@last = @grid_manager
674
+ @@grid_managers << @grid_manager
675
+ end
676
+ else
677
+ @simple_manager = AGTkSimpleManager.new(@agobj,_activate)
678
+ end
679
+ @manager = _name
680
+ @active = _activate
681
+ end
682
+
683
+ def activate(free=true)
684
+ #Tk.messageBox('message'=>'activate')
685
+ if !defined?(@manager)
686
+ set_manager(@agobj.props['layout_man']['manager']['get'].call, true)
687
+ end
688
+ case @manager
689
+ when 'place'
690
+ @place_manager.activate(free) if defined? @place_manager
691
+ @@last = @place_manager if defined? @place_manager
692
+ when 'pack'
693
+ @pack_manager.activate if defined? @pack_manager
694
+ @@last = @place_manager if defined? @pack_manager
695
+ else
696
+ AGTkLManager.deactivate_all
697
+ @@last = nil
698
+ end
699
+ @active = true
700
+ #@agobj.obj.callback_break
701
+ end
702
+
703
+ def refresh
704
+ case @manager
705
+ when 'place'
706
+ @place_manager.refresh
707
+ end
708
+ end
709
+
710
+ def deactivate_last
711
+ @@last.deactivate if @@last
712
+ end
713
+
714
+ def AGTkLManager.deactivate_all
715
+ @@place_managers.each{|value| value.deactivate}
716
+ @@pack_managers.each{|value| value.deactivate}
717
+ @@grid_managers.each{|value| value.deactivate}
718
+ @active = false
719
+ end
720
+
721
+ def deactivate
722
+ case @manager
723
+ when 'place'
724
+ @place_manager.deactivate if defined? @place_manager
725
+ when 'pack'
726
+ @pack_manager.deactivate if defined? @pack_manager
727
+ end
728
+ @active = false
729
+ end
730
+
731
+ def util_bind
732
+ @agobj.obj.bind_append("Control-KeyPress"){|e|
733
+ _deltax = 0
734
+ _deltay = 0
735
+ case e.keysym
736
+ when 'Left'
737
+ _deltax = -1
738
+ _deltay = 0
739
+ when 'Right'
740
+ _deltax = 1
741
+ _deltay = 0
742
+ when 'Up'
743
+ _deltax = 0
744
+ _deltay = -1
745
+ when 'Down'
746
+ _deltax = 0
747
+ _deltay = 1
748
+ end
749
+ if (_deltax != 0) || (_deltay != 0)
750
+ active_object = AG.active
751
+ active_object.l_manager.place_manager.do_mov_obj_delta(_deltax,_deltay)
752
+ active_object.l_manager.place_manager.move_other_obj(_deltax, _deltay)
753
+ active_object.l_manager.place_manager.refresh_active
754
+ end
755
+ }
756
+ @agobj.obj.bind_append("Shift-KeyPress"){|e|
757
+ active_object = AG.active
758
+ case e.keysym
759
+ when 'Left'
760
+ active_object.l_manager.place_manager.do_mov_obj_delta_dim(-1,0)
761
+ active_object.l_manager.activate
762
+ when 'Right'
763
+ active_object.l_manager.place_manager.do_mov_obj_delta_dim(1,0)
764
+ active_object.l_manager.activate
765
+ when 'Up'
766
+ active_object.l_manager.place_manager.do_mov_obj_delta_dim(0,-1)
767
+ active_object.l_manager.activate
768
+ when 'Down'
769
+ active_object.l_manager.place_manager.do_mov_obj_delta_dim(0,1)
770
+ active_object.l_manager.activate
771
+ end
772
+ }
773
+ end
774
+
775
+ end
776
+
777
+ class AGTkRenderer < AGRenderer
778
+
779
+ def class_hinner_begin(_ind=0)
780
+ return super(_ind), render_family(_ind+1,TkWinfo.manager(@agobj.obj)), "\n"
781
+ end
782
+
783
+ def class_end(_ind=0)
784
+ result = super(_ind)
785
+ if @agobj.contains_events
786
+ result = result,"\n", class_controller(_ind)
787
+ end
788
+ return result
789
+ end
790
+
791
+ def class_controller(_ind=0)
792
+ return class_controller_begin(_ind), class_controller_hinner_begin(_ind), class_controller_hinner_end(_ind), class_controller_end(_ind)
793
+ end
794
+
795
+ def class_controller_begin(_ind=0)
796
+ code = "\n","\t"*_ind,'class ', @agobj.getInstanceClass, 'C', "\n"
797
+ code = code, "\t"*(_ind+1),"attr_reader :",@agobj.i_name," :md\n"
798
+ code = code, "\t"*(_ind+1),"def initialize(_md)\n"
799
+ code = code, "\t"*(_ind+2),"@",@agobj.i_name,"=",@agobj.getInstanceClass,".new\n"
800
+ code = code, "\t"*(_ind+2),"@md=_md\n"
801
+ code = code, "\t"*(_ind+2),"self.binding\n"
802
+ code = code, "\t"*(_ind+1),"end\n"
803
+ end
804
+
805
+ def class_controller_hinner_begin(_ind=0)
806
+ code = code, "\t"*(_ind+1),"def binding\n"
807
+ code = code, "\t"*(_ind+2),recursive_binding(@agobj,2),"\n"
808
+ end
809
+
810
+ def recursive_binding(_agobj,_ind=0)
811
+ _code = ''
812
+ _agobj.props_def['bind']['path'] = '@',_agobj.get_path_i_name,'.'
813
+ if _agobj.has_events
814
+ for i in 0.._agobj.persistent['events'].length - 1
815
+ _agobj.persistent['prog']=i
816
+ if _agobj.persistent['procs'] == nil || (_agobj.persistent['procs'][i] == nil || _agobj.persistent['procs'][i].length == 0)
817
+ _agobj.persistent['procs'] = Array.new if _agobj.persistent['procs'] == nil
818
+ _agobj.persistent['procs'][i]= "@md.on_",_agobj.i_name,'_',_agobj.persistent['events'][i]
819
+ end
820
+ _code = _code, _agobj.renderer.render_family(_ind,'bind')
821
+ end
822
+ _code = _code,"\n"
823
+ end
824
+ _agobj.sons.each{|son|
825
+ _code = _code, recursive_binding(son,_ind),"\n"
826
+ }
827
+ return _code
828
+ end
829
+
830
+ def class_controller_hinner_end(_ind=0)
831
+ code = code, " end\n"
832
+ end
833
+
834
+ def class_controller_end(_ind=0)
835
+ code = code, "end\n"
836
+ end
837
+
838
+ end
839
+
840
+ class AGTkSniffer < AGSniffer
841
+ end
842
+
843
+ class AGTkCompositeSniffer < AGTkSniffer
844
+
845
+ def find_sons
846
+ super
847
+ @sons.concat(TkWinfo.children(@obj))
848
+ end
849
+
850
+ end
851
+
852
+ class AGINTk < AG
853
+ attr_reader :graphic_obj
854
+
855
+ def initialize(_ag_parent = nil, _object = nil)
856
+ super(_ag_parent, _object)
857
+ object_inspector_select
858
+ end
859
+
860
+ def new_object
861
+ super
862
+ new_graphic_rappresentation
863
+ end
864
+
865
+ def update(_event, _agobj)
866
+ case _event
867
+ when 'SELECT'
868
+ if _agobj == self
869
+ @graphic_obj.configure('relief'=> 'ridge')
870
+ else
871
+ @graphic_obj.configure('relief'=> 'flat')
872
+ end
873
+ end
874
+ end
875
+
876
+ def new_graphic_rappresentation
877
+ @graphic_obj = TkLabel.new(@ag_parent.obj){
878
+ background '#fab4b9'
879
+ background '#fab4b9'
880
+ foreground '#a30c17'
881
+ text 'obj'
882
+ }
883
+ if (defined? @ag_parent.where_x)&&(defined? @ag_parent.where_y)
884
+ @graphic_obj.place('x'=>@ag_parent.where_x,'y'=>@ag_parent.where_y)
885
+ end
886
+ AGTkObjPlace.new(@graphic_obj)
887
+ @graphic_obj.bind_append("ButtonPress-1", proc{object_inspector_select; @graphic_obj.callback_break })
888
+ end
889
+
890
+ def object_inspector_select
891
+ AGTkLManager.deactivate_all
892
+ self.select
893
+ self.activate
894
+ #@object_inspector.select(self, true) if !defined? @object_inspector.active_object or @object_inspector.active_object != self
895
+ end
896
+
897
+ end
898
+
899
+ class AGTk < AG
900
+ attr_reader :canvas, :x0, :y0, :x3, :y3, :l_manager
901
+ attr_writer :x0, :y0, :x3, :y3
902
+
903
+ def initialize(_ag_parent = nil, _object = nil)
904
+ super(_ag_parent, _object)
905
+
906
+ if (defined? @obj)
907
+ if @ag_parent != nil
908
+ ppress = proc{
909
+ @l_manager.deactivate_last
910
+ }
911
+ prelease = proc{
912
+ @l_manager.activate
913
+ }
914
+ @obj.bind_append("ButtonPress-1", ppress)
915
+ @obj.bind_append("ButtonRelease-1", prelease)
916
+ @parent = TkWinfo.parent(@obj)
917
+ end
918
+ @l_manager = AGTkLManager.new(self, _object == nil)
919
+ end
920
+ popup
921
+ build_sons if _object != nil
922
+ end
923
+
924
+ def properties
925
+ super
926
+ publish('winfo','name'=>'path','get'=> proc{@obj.path}, 'def'=> 'nodef')
927
+ publish('winfo','name'=>'id','get'=> proc{TkWinfo.id(@obj)}, 'def'=> 'nodef')
928
+ publish('winfo','name'=>'parent','get'=> proc{TkWinfo.parent(@obj)}, 'def'=> 'nodef')
929
+
930
+ end
931
+
932
+ def update_property(_sender, _family,_name,_value)
933
+ super
934
+ if _sender != self && ['x','y','width','height'].include?(_name)
935
+ @l_manager.refresh
936
+ end
937
+
938
+ end
939
+
940
+
941
+ def popup_items(_popup_menu)
942
+ _popup_menu.insert('end',
943
+ :command,
944
+ :label=>@obj.class.to_s,
945
+ :background => 'white',
946
+ :hidemargin => false
947
+ )
948
+
949
+ _popup_menu.insert('end',
950
+ :command,
951
+ :label=>'Delete',
952
+ :hidemargin => false,
953
+ :command=> proc{self.delete}
954
+ )
955
+ end
956
+
957
+ def popup
958
+ if @obj
959
+ _parent = nil
960
+ if @ag_parent != nil
961
+ _parent = @ag_parent.obj
962
+ end
963
+ @obj.bind("Button-3", proc{|x,y|
964
+ popup_menu = TkMenu.new(
965
+ :parent=>_parent,
966
+ :tearoff=>0,
967
+ :relief=>'groove',
968
+ :title => @obj.class.to_s
969
+ )
970
+ popup_items(popup_menu)
971
+ _x = TkWinfo.pointerx(@obj)
972
+ _y = TkWinfo.pointery(@obj)
973
+ popup_menu.popup(_x,_y)
974
+ @obj.callback_break
975
+ },
976
+ "%x %y")
977
+ end
978
+ end
979
+
980
+ def active_move_tab
981
+ @obj.bind("Enter",
982
+ proc{@canvas_of_move = TkCanvas.new(@obj)
983
+ _lx = 30
984
+ _ly = 43
985
+ _x = (@x3 - @x0)/2 - _lx/2
986
+ _y = (@y3 - @y0)/2 - _ly/2
987
+ TkcImage.new(@canvas_of_move, _lx/2, _ly/2){
988
+ image TkAllPhotoImage.new('file' => 'skull.bmp')
989
+ }
990
+ @canvas_of_move.configure('cursor'=>'draft_small')
991
+ @canvas_of_move.place('x' => _x ,
992
+ 'y' => _y,
993
+ 'width' => _lx,
994
+ 'height' => _ly
995
+ )
996
+ @canvas_of_move.bind("1", proc{|e| do_press(e.x, e.y)})
997
+ @canvas_of_move.bind("B1-Motion", proc{|x, y| do_movobj(x,y)},"%x %y")
998
+ @canvas_of_move.bind_append("ButtonPress-1", proc{@l_manager.deactivate_last})
999
+ @canvas_of_move.bind_append("ButtonPress-1", proc{|e| do_press(e.x, e.y)})
1000
+ @canvas_of_move.bind("ButtonRelease-1", proc{ @l_manager.activate })
1001
+ }
1002
+ )
1003
+ @obj.bind("Leave", proc{@canvas_of_move.destroy})
1004
+ @obj.bind("Motion", proc{|x, y| @canvas_of_move.place('x' =>x - 5, 'y' => y - 5)},"%x %y")
1005
+ end
1006
+
1007
+ def new_object
1008
+ if self.class.class_wrapped
1009
+ if @ag_parent
1010
+ @obj = self.class.class_wrapped.new(@ag_parent.obj)
1011
+ else
1012
+ @obj = self.class.class_wrapped.new
1013
+ end
1014
+ end
1015
+ end
1016
+
1017
+ def AGTk.class_wrapped
1018
+ nil
1019
+ end
1020
+
1021
+ def AGTk.class_renderer
1022
+ AGTkRenderer
1023
+ end
1024
+
1025
+ def AGTk.class_sniffer
1026
+ AGTkSniffer
1027
+ end
1028
+
1029
+ def has_events
1030
+ result = defined?(@persistent) && @persistent['events'] != nil
1031
+ end
1032
+
1033
+ def contains_events
1034
+ result = has_events
1035
+ self.sons.each{|son|
1036
+ result = result || son.contains_events
1037
+ }
1038
+ return result
1039
+ end
1040
+
1041
+ # def retrive_values
1042
+ # @props['layout_man']['manager']['value'] = @props['layout_man']['manager']['get'].call
1043
+ # end
1044
+
1045
+ def delete
1046
+ @l_manager.deactivate if defined? @l_manager
1047
+ super()
1048
+ end
1049
+
1050
+ def getFileName
1051
+ __FILE__
1052
+ end
1053
+
1054
+ def updatep(_family, prop, value, _call_from_inspector=false)
1055
+ if _call_from_inspector && ['place','pack','grid','layout_man'].include?(_family)
1056
+ @l_manager.deactivate
1057
+ end
1058
+ super(_family, prop,value, _call_from_inspector)
1059
+ if _call_from_inspector && _family == 'place'
1060
+ @l_manager.place_manager.initx0x3
1061
+ end
1062
+ if _call_from_inspector && ['place','pack','grid','layout_man'].include?(_family)
1063
+ @l_manager.activate
1064
+ end
1065
+ Tk.update
1066
+ end
1067
+
1068
+ def activate
1069
+ super
1070
+ @l_manager.activate if defined? @l_manager
1071
+ self
1072
+ end
1073
+
1074
+ end
1075
+
1076
+ class QTkScrollbar < TkScrollbar
1077
+
1078
+ def initialize(parent=nil, keys=nil,&b)
1079
+ @strin = ''
1080
+ if keys
1081
+ @strin = keys.to_s
1082
+ end
1083
+ if block_given?
1084
+ @strin = @strin + b.to_s
1085
+ end
1086
+ super
1087
+ ArcadiaLibs.copy_wrapper_of_class_to_class(TkScrollbar, QTkScrollbar)
1088
+ end
1089
+
1090
+ def class
1091
+ TkScrollbar
1092
+ end
1093
+
1094
+ def wrapline(_str)
1095
+ if _str
1096
+ m = /@\(eval\)\:([0123456789]*)/.match(_str)
1097
+ if m && m[1]
1098
+ return m[1].to_i
1099
+ else
1100
+ -1
1101
+ end
1102
+ else
1103
+ -1
1104
+ end
1105
+ end
1106
+
1107
+ def block(_i, _str)
1108
+ _nline = 0
1109
+ _strwrk = ''
1110
+ _str.each{|line|
1111
+ _nline = _nline + 1
1112
+ if _nline >= _i
1113
+ _strwrk = _strwrk + line
1114
+ end
1115
+ }
1116
+
1117
+ m = /\{(.*)\}/m.match(_strwrk)
1118
+ if m && m[1]
1119
+ return m[1]
1120
+ else
1121
+ ' ma! '
1122
+ end
1123
+
1124
+ end
1125
+
1126
+ def command_script
1127
+ block(wrapline(@strin), $arcadia['code'])
1128
+ end
1129
+
1130
+ end
1131
+
1132
+
1133
+ module WrapBind
1134
+
1135
+ def wbind_mini()
1136
+ p self
1137
+ end
1138
+
1139
+ def wbind_append(context, cmd=Proc.new, args=nil)
1140
+ self.bind_append(context, cmd)
1141
+ end
1142
+
1143
+ def wbind(context, cmd=Proc.new, args=nil)
1144
+ self.bind(context, cmd)
1145
+ end
1146
+
1147
+ def procstr(path)
1148
+ parts = path.split('@')
1149
+ file,srow = parts[1].split(':')
1150
+ srow.sub!('>','')
1151
+ row = srow.to_i
1152
+ lines = IO.readlines(file)
1153
+ line = lines[row - 1]
1154
+ i1 = line.index('proc{') + 5
1155
+ result = line[i1..line.length - 1]
1156
+ i2 = nil
1157
+ while i2 == nil
1158
+ i2 = result.index('}')
1159
+ if i2
1160
+ i2 = i2 + i1 - 1
1161
+ result = line[i1..i2]
1162
+ else
1163
+ row = row + 1
1164
+ result = result + lines[row - 1]
1165
+ end
1166
+ end
1167
+ return result
1168
+ end
1169
+
1170
+ end
1171
+
1172
+ include WrapBind
1173
+
1174
+ class Revparsel
1175
+
1176
+ def initialize(_code, _filename=nil)
1177
+ _code.gsub!('TkScrollbar','QTkScrollbar')
1178
+ _code.gsub!('bind(','wbind(')
1179
+ $arcadia.publish('code',_code)
1180
+ @filename = _filename
1181
+ _re_string = ''
1182
+ ['TkToplevel','TkRoot','TkToplevelLayer'].each{|top|
1183
+ if _re_string.length > 0
1184
+ _re_string = _re_string+'|'
1185
+ end
1186
+ _re_string = _re_string+'class\s*[A-Za-z0-9_]*\s*<\s*'+top
1187
+ }
1188
+ m = Regexp::new(_re_string).match(_code)
1189
+ if m
1190
+ _c,_class_name,_c,_class = m[0].split
1191
+ _obj_name = _class_name.sub(/^./) { $&.downcase}
1192
+ cod = _code + "\n@"+ _obj_name + "="+ _class_name+".new\n"
1193
+ cod = cod + '@ag'+ _obj_name + "="+'AG'+ _class+".new(nil,@"+_obj_name+"){\n"
1194
+ cod = cod + "|_self|\n"
1195
+ cod = cod + " _self.i_name='"+_obj_name+"' \n"
1196
+ cod = cod + " _self.i_ag='"+'ag'+_obj_name+"' \n"
1197
+ cod = cod + '}'+"\n"
1198
+ eval(cod)
1199
+ end
1200
+ end
1201
+
1202
+ def eval_obj(_obj_name, _ag_obj_name)
1203
+ _obj_name_base = _obj_name.delete('@')
1204
+ cod = " @istancev = "+ _obj_name +".instance_variables\n"
1205
+ eval(cod)
1206
+ cod = " @tkv = TkWinfo.children("+_obj_name+")\n"
1207
+ eval(cod)
1208
+ if @tkv.length > 0
1209
+ array_eval = "["
1210
+ l=0
1211
+ @istancev.each{|i|
1212
+ array_eval = array_eval + "," if l>0
1213
+ array_eval = array_eval +i+'.object_id'
1214
+ l=l+1
1215
+ }
1216
+ array_eval = array_eval +"]"
1217
+ @tkv.each{|k|
1218
+ $k=k
1219
+ _name = '@j'+$k.object_id.abs.to_s
1220
+ cod = "if !"+ array_eval
1221
+ cod = cod+".include?("+$k.object_id.to_s+")"+"\n"
1222
+ cod = cod + _name +'=$k'
1223
+ cod = cod + "\nelse\n" + '$k=nil'
1224
+ cod = cod+"\nend\n"
1225
+ eval(_obj_name+'.instance_eval{|k| '+cod+'}')
1226
+ if $k
1227
+ @istancev << _name
1228
+ end
1229
+ }
1230
+ end
1231
+ if @istancev.length > 0
1232
+ cod = " class << "+_obj_name+"\n"
1233
+ @istancev.each{|i|
1234
+ i.delete!('@')
1235
+ cod = cod + " attr_reader :"+i+"\n"
1236
+ }
1237
+ cod = cod +"end\n"
1238
+ eval(cod)
1239
+ cod = ''
1240
+ @istancev.each{|v|
1241
+ v.delete!('@')
1242
+ path_obj = _obj_name+'.'+ v
1243
+ eval('@gong = '+ path_obj)
1244
+ _agclass=ArcadiaLibs.wrapper_class(@gong.class)
1245
+ if _agclass
1246
+ cod = "@ag"+v+"="+_agclass+".new("+ _ag_obj_name +","+path_obj+"){|_self|\n"
1247
+ cod = cod + " _self.i_name = '"+v+"'\n"
1248
+ cod = cod + " _self.i_ag = 'ag"+v+"'\n"
1249
+ cod = cod + "}\n"
1250
+ eval(cod)
1251
+ eval_obj(path_obj, "@ag"+v)
1252
+ end
1253
+ }
1254
+ end
1255
+ end
1256
+ end
1257
+
1258
+ module Visible
1259
+ def hide object = self
1260
+ object.withdraw
1261
+ end
1262
+ def show object = self
1263
+ object.takefocus(1)
1264
+ object.deiconify
1265
+ end
1266
+ end
1267
+
1268
+ class TkToplevelLayer < TkToplevel
1269
+ include Visible
1270
+ def initialize()
1271
+ super
1272
+ takefocus 1
1273
+ withdraw
1274
+ protocol( "WM_DELETE_WINDOW", proc{self.hide})
1275
+ end
1276
+ end
1277
+
1278
+ class TkFrameLayer < TkFrame
1279
+ include Visible
1280
+ def initialize()
1281
+ super
1282
+ takefocus 1
1283
+ withdraw
1284
+ end
1285
+ end
1286
+
1287
+ class TkToplevelRoot < TkToplevel
1288
+
1289
+ def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
1290
+ super
1291
+ ArcadiaLibs.copy_wrapper_of_class_to_class(TkToplevel, TkToplevelRoot)
1292
+ end
1293
+
1294
+ end
1295
+
1296
+ class ParsifalTk
1297
+ include TkComm
1298
+
1299
+ def initialize(_code=nil, _filename=nil, _language='ruby')
1300
+ @filename = _filename;
1301
+ @code = _code
1302
+ if (@filename)&&(File.exist?(@filename))
1303
+ @code =''
1304
+ IO.foreach(@filename) { |line| @code += line };
1305
+ end
1306
+ @root = TkWinfo.widget(Tk.tk_call('winfo', 'id', '.'))
1307
+ @top_level_banned = Array.new
1308
+ TkWinfo.children(@root).each{|_c|
1309
+ if _c.kind_of?(TkToplevel)
1310
+ @top_level_banned << _c
1311
+ print "\n"+Tk.tk_call('wm', 'title', _c)
1312
+ end
1313
+ }
1314
+
1315
+ case _language
1316
+ when 'ruby'
1317
+ if !@code.gsub!('TkRoot','TkToplevelRoot')
1318
+ eval('@preudo_root=TkToplevelRoot.new')
1319
+ @code.gsub!('.new(nil','.new(@preudo_root')
1320
+ end
1321
+ @code.gsub!('Tk.mainloop','')
1322
+ eval(@code)
1323
+ when 'tcl'
1324
+ Tk.tk_call( "eval", @code)
1325
+ end
1326
+ tk_tree
1327
+ end
1328
+
1329
+ def tk_tree
1330
+ if defined?(@sons_of)
1331
+ return @sons_of
1332
+ else
1333
+ begin
1334
+ @sons_of = dynasty_of(@root)
1335
+ end
1336
+ ag_wrap_dynasty_of(@root)
1337
+ end
1338
+ end
1339
+
1340
+ def names_dynasty_of(_root, _names=Hash.new)
1341
+ if _root == @root
1342
+ iv = self.instance_variables
1343
+ else
1344
+ iv = _root.instance_variables
1345
+ end
1346
+ if @sons_of[_root]
1347
+ @sons_of[_root].each{|tkobj|
1348
+ iv.each{|i|
1349
+ eval("@bingo = "+i+"==tkobj")
1350
+ if @bingo
1351
+ _names[tkobj]=i.delete!('@')
1352
+ break
1353
+ end
1354
+ }
1355
+ names_dynasty_of(tkobj, _names)
1356
+ }
1357
+ end
1358
+ return _names
1359
+ end
1360
+
1361
+ def name(_obj)
1362
+ if !defined?(@names)
1363
+ @names = names_dynasty_of(@root)
1364
+ end
1365
+ _name = @names[_obj]
1366
+ if !_name&&(_obj!=@root)
1367
+ _name = 'j'+_obj.id.to_s
1368
+ end
1369
+ return _name
1370
+ end
1371
+
1372
+ def ag_wrap_dynasty_of(_root, _rootname=name(_root))
1373
+ if _rootname
1374
+ _rootname = '@ag'+_rootname
1375
+ end
1376
+ if @sons_of[_root]
1377
+ @sons_of[_root].each{|_son|
1378
+ print "\nwrappo -->"+_son.to_s
1379
+ ag_create(_son, name(_son), _rootname, @filename)
1380
+ ag_wrap_dynasty_of(_son)
1381
+ }
1382
+ end
1383
+ end
1384
+
1385
+ def ag_create(_obj, _obj_name=nil, _ag_parent_name=nil, _filename=nil)
1386
+ if !_ag_parent_name
1387
+ _ag_parent_name='nil'
1388
+ end
1389
+ @filename = _filename
1390
+ if !_obj_name
1391
+ _obj_name = 'j'+_obj.id.to_s
1392
+ end
1393
+ _agclass=ArcadiaLibs.wrapper_class(_obj.class)
1394
+ if _agclass
1395
+ cod = '@'+_obj_name+"=_obj\n"
1396
+ if @filename && _obj.kind_of?(TkToplevel)
1397
+ cod = cod + '@ag'+ _obj_name + "="+ _agclass+".new("+_ag_parent_name+", _obj"+",nil,'"+_filename+"'){\n"
1398
+ else
1399
+ cod = cod + '@ag'+ _obj_name + "="+ _agclass+".new("+_ag_parent_name+", _obj"+",nil){\n"
1400
+ end
1401
+ cod = cod + "|_self|\n"
1402
+ cod = cod + " _self.i_name='"+_obj_name+"'\n"
1403
+ cod = cod + " _self.i_ag='"+'ag'+_obj_name+"'\n"
1404
+ cod = cod + '}'
1405
+ eval(cod)
1406
+ end
1407
+ end
1408
+
1409
+ def dynasty_of(_root, sons_of = Hash.new)
1410
+ _childrens = TkWinfo.children(_root)
1411
+ if (_childrens != nil)&&(_childrens.length > 0)
1412
+ sons_of[_root] = _childrens
1413
+ sons_of[_root].delete_if {
1414
+ |_s|
1415
+ @top_level_banned.include?(_s)||
1416
+ ((_root.kind_of?(TkRoot))&&(!_s.kind_of?(TkToplevel)))
1417
+ }
1418
+ sons_of[_root].each{|son|
1419
+ dynasty_of(son, sons_of)
1420
+ }
1421
+ end
1422
+ return sons_of
1423
+ end
1424
+
1425
+ end
1426
+
1427
+ class AGTkObjPlace
1428
+ attr_reader :obj, :r, :start_x, :start_y, :motion, :x0, :y0, :w0, :h0, :width,:height,:relwidth,:relheight
1429
+ attr_writer :r, :start_x, :start_y, :motion,:width,:height,:relwidth,:relheight
1430
+
1431
+ def initialize(_obj=nil , _side='both' , _cursor=nil, _bind = true )
1432
+ if !_obj
1433
+ break
1434
+ end
1435
+ @obj = _obj
1436
+ if !_cursor
1437
+ case _side
1438
+ when 'x'
1439
+ _cursor = 'sb_h_double_arrow'
1440
+ when 'y'
1441
+ _cursor = 'sb_v_double_arrow'
1442
+ when 'both'
1443
+ _cursor = 'draft_small'
1444
+ end
1445
+ end
1446
+ @motion = false
1447
+ @side = _side
1448
+ @x0 = TkPlace.info(@obj)['x']
1449
+ @y0 = TkPlace.info(@obj)['y']
1450
+ if TkWinfo.mapped?(@obj)
1451
+ @w0=TkWinfo.width(@obj)
1452
+ @h0=TkWinfo.height(@obj)
1453
+ else
1454
+ @w0=TkWinfo.reqwidth(@obj)
1455
+ @h0=TkWinfo.reqheight(@obj)
1456
+ end
1457
+ @start_x = @x0
1458
+ @start_y = @y0
1459
+ @cursor = _cursor
1460
+ if _bind
1461
+ @obj.bind_append("Enter", proc{|x, y| do_enter(x, y)}, "%x %y")
1462
+ @obj.bind_append("ButtonPress-1", proc{|e| do_press(e.x, e.y)})
1463
+ @obj.bind_append("B1-Motion", proc{|x, y| do_motion(x,y)},"%x %y")
1464
+ end
1465
+ end
1466
+
1467
+ def w
1468
+ if TkWinfo.mapped?(@obj)
1469
+ @w0= TkWinfo.width(@obj)
1470
+ else
1471
+ @w0= TkWinfo.reqwidth(@obj)
1472
+ end
1473
+ end
1474
+
1475
+ def h
1476
+ if TkWinfo.mapped?(@obj)
1477
+ @h0= TkWinfo.height(@obj)
1478
+ else
1479
+ @h0= TkWinfo.reqheight(@obj)
1480
+ end
1481
+ end
1482
+
1483
+ def do_enter(x, y)
1484
+ @oldcursor = @obj.cget('cursor')
1485
+ @obj.configure('cursor'=> @cursor)
1486
+ end
1487
+
1488
+ def do_leave
1489
+ @obj.configure('cursor'=>@oldcursor)
1490
+ end
1491
+
1492
+ def do_press(x, y)
1493
+ @start_x = x
1494
+ @start_y = y
1495
+ end
1496
+
1497
+ def do_motion( _x, _y)
1498
+ @motion = true
1499
+ move(_x - @start_x, _y - @start_y)
1500
+ end
1501
+
1502
+ def move(_x,_y)
1503
+ case @side
1504
+ when 'both'
1505
+ @x0 = @x0 + _x if (@x0 + _x) >= 0
1506
+ @y0 = @y0 + _y
1507
+ @obj.place('x' => @x0, 'y' => @y0, 'width' => @width, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
1508
+ when 'x'
1509
+ @x0 = @x0 + _x if (@x0 + _x) >= 0
1510
+ @obj.place('x' => @x0, 'width' => @width, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
1511
+ when 'y'
1512
+ @y0 = @y0 + _y
1513
+ @obj.place('y' => @y0, 'width' => @width, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
1514
+ end
1515
+ end
1516
+
1517
+ def amove(_x,_y)
1518
+ move(_x - @x0 , _y - @y0)
1519
+ end
1520
+
1521
+ def go(_w, _h)
1522
+ case @side
1523
+ when 'x'
1524
+ @w0 = _w
1525
+ @obj.place('width' => @w0, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
1526
+ when 'y'
1527
+ @h0 = _h
1528
+ @obj.place('height' => @h0, 'width' => @width, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
1529
+ end
1530
+ end
1531
+
1532
+ end
1533
+
1534
+ class AGTkFramePlaceManager
1535
+ attr_reader :main_frame
1536
+
1537
+ def initialize(_main_frame = nil)
1538
+ @main_frame = _main_frame
1539
+ @frames = Hash.new
1540
+ @frames_seq = Array.new
1541
+
1542
+ @frames_left = Hash.new
1543
+ @frames_right = Hash.new
1544
+ @frames_top = Hash.new
1545
+ @frames_bottom = Hash.new
1546
+
1547
+ @Info = Struct.new("Info", :obj, :splitter, :side, :objp, :visible)
1548
+ @motion = false
1549
+ @nx= 0
1550
+ yield(self) if block_given?
1551
+ end
1552
+
1553
+ def add(_name, _frame=TkFrame.new(@main_frame), _ndim=-1, _splitter=false, _side='x' )
1554
+ if _frame == nil
1555
+ _frame=TkFrame.new(@main_frame)
1556
+ end
1557
+ case _side
1558
+ when 'x'
1559
+ @frames_right.each_value{|value|
1560
+ value << _name
1561
+ }
1562
+ if @frames_right[_name]==nil
1563
+ @frames_right[_name] = Array.new
1564
+ end
1565
+ when 'y'
1566
+ @frames_bottom.each_value{|value|
1567
+ value << _name
1568
+ }
1569
+ end
1570
+ case _side
1571
+ when 'x'
1572
+ @frames_left[_name]= Array.new
1573
+ @frames_seq.each{|item|
1574
+ @frames_left[_name] << item
1575
+ }
1576
+ (_ndim>0)?(_rw=0):_rw=1
1577
+ _frame.place(
1578
+ 'relwidth' => _rw,
1579
+ 'relx' => 0,
1580
+ 'x' => @nx,
1581
+ 'y' => '0',
1582
+ 'relheight' => '1',
1583
+ 'rely' => 0,
1584
+ 'height' => 1,
1585
+ 'bordermode' => 'inside',
1586
+ 'width' => _ndim
1587
+ )
1588
+ if _splitter
1589
+ _xbutton = TkButton.new(@main_frame){
1590
+ text '<'
1591
+ overrelief 'ridge'
1592
+ relief 'groove'
1593
+ }
1594
+ _xbutton.place(
1595
+ 'x' => @nx - 20,
1596
+ 'y' => 0,
1597
+ 'height' => 20,
1598
+ 'bordermode' => 'outside',
1599
+ 'width' => 20
1600
+ )
1601
+ _xbutton.bind_append(
1602
+ "ButtonPress-1",
1603
+ proc{
1604
+ @frames[@frames_left[_name][0]].objp.obj.unplace
1605
+ @frames[_name].objp.amove(1,0)
1606
+ do_resize(_name)
1607
+ _xbutton.place('x'=>0)
1608
+ _xbutton.raise
1609
+ if _xbutton.cget('text') == '<'
1610
+ _xbutton.configure('text'=>'>')
1611
+ else
1612
+ _xbutton.configure('text'=>'<')
1613
+ end
1614
+ }
1615
+ )
1616
+ if @motion
1617
+ _frame.bind_append(
1618
+ "B1-Motion",
1619
+ proc{do_resize(_name)}
1620
+ )
1621
+ else
1622
+ _frame.bind_append(
1623
+ "B1-Motion",
1624
+ proc{_frame.raise}
1625
+ )
1626
+ end
1627
+ _frame.bind_append(
1628
+ "ButtonRelease-1",
1629
+ proc{do_resize(_name)}
1630
+ )
1631
+ end
1632
+
1633
+ @nx = @nx + _ndim if _ndim > 0
1634
+
1635
+ when 'y'
1636
+ @frames_top[_name]= Array.new
1637
+ @frames_bottom[_name]= Array.new
1638
+ @frames_seq.each{|item|
1639
+ @frames_top[_name] << item
1640
+ }
1641
+ end
1642
+ @frames[_name] = @Info.new(
1643
+ _frame,
1644
+ _splitter,
1645
+ _side,
1646
+ AGTkObjPlace.new(_frame, _side),
1647
+ true
1648
+ )
1649
+ @frames_seq << _name
1650
+ return _frame
1651
+ end
1652
+
1653
+ def do_resize (_name_splitter)
1654
+ case @frames[_name_splitter].side
1655
+ when 'x'
1656
+ _x = @frames[_name_splitter].objp.x0
1657
+ if (_x > 0)&&(@frames_left.length > 0)
1658
+ _w = @frames[_name_splitter].objp.w
1659
+ _index = @frames_left[_name_splitter].length - 1
1660
+ if (@frames_left.length == 1)||(_x > @frames[@frames_left[_name_splitter][_index]].objp.x0)
1661
+ @frames[@frames_left[_name_splitter][_index]].objp.go(_x,0)
1662
+ end
1663
+ _gap = _w
1664
+ @frames_right[_name_splitter].each{|i|
1665
+ @frames[i].objp.amove(_x + _gap,0)
1666
+ _gap = _gap + @frames[i].objp.w
1667
+ }
1668
+ end
1669
+ when 'y'
1670
+ end
1671
+ end
1672
+
1673
+ def [](_name)
1674
+ @frames[_name].obj
1675
+ end
1676
+
1677
+ def frame(_name)
1678
+ @frames[_name].obj
1679
+ end
1680
+
1681
+ def hide(_name)
1682
+ _w = @frames[_name].objp.w
1683
+ @frames[_name].obj.unplace
1684
+ @frames[_name].visible = false
1685
+ @frames_right[_name].each{|i|
1686
+ @frames[i].objp.move(-_w,0) if @frames[i].visible
1687
+ }
1688
+ end
1689
+ def show(_name)
1690
+ _x = @frames[_name].objp.x0
1691
+ _w = @frames[_name].objp.w0
1692
+ @frames[_name].obj.place(
1693
+ 'x' => _x,
1694
+ 'relheight' => '1',
1695
+ 'width' => _w
1696
+ )
1697
+ @frames[_name].visible = true
1698
+ _x = _x + _w
1699
+ @frames_right[_name].each{|i|
1700
+ if @frames[i].visible
1701
+ @frames[i].obj.place('x' =>_x)
1702
+ _x = _x + @frames[i].objp.w
1703
+ end
1704
+ }
1705
+ end
1706
+
1707
+ end
1708
+
1709
+ module TkType
1710
+ TkagRelief = EnumType.new('flat','groove','raised','ridge','sunken')
1711
+ TkagJustify = EnumType.new('left','center','right')
1712
+ TkagOrient = EnumType.new('vertical','horizontal')
1713
+ TkagAnchor = EnumType.new('n', 'ne', 'e','se', 's', 'sw', 'w', 'nw','center')
1714
+ TkagBool = EnumType.new(true,false)
1715
+ TkagState = EnumType.new('normal', 'active', 'disabled')
1716
+ TkagFile = ProcType.new(proc{value = Tk.getOpenFile})
1717
+ TkagCompound = EnumType.new('none' ,'bottom', 'center', 'left', 'none', 'right', 'top')
1718
+ if RUBY_PLATFORM.include?('win32')
1719
+ TkagColor = EnumProcType.new(proc{value = Tk.chooseColor},
1720
+ 'SystemActiveBorder',
1721
+ 'SystemActiveCaption',
1722
+ 'SystemAppWorkspace',
1723
+ 'SystemBackground',
1724
+ 'SystemButtonFace',
1725
+ 'SystemButtonHighlight',
1726
+ 'SystemButtonShadow',
1727
+ 'SystemButtonText',
1728
+ 'SystemCaptionText',
1729
+ 'SystemDisabledText',
1730
+ 'SystemHighlight',
1731
+ 'SystemHighlightText',
1732
+ 'SystemInactiveBorder',
1733
+ 'SystemInactiveCaption',
1734
+ 'SystemInactiveCaptionText',
1735
+ 'SystemMenu',
1736
+ 'SystemMenuText',
1737
+ 'SystemScrollbar',
1738
+ 'SystemWindow',
1739
+ 'SystemWindowFrame',
1740
+ 'SystemWindowText'
1741
+ )
1742
+ else
1743
+ TkagColor = ProcType.new(proc{value = Tk.chooseColor})
1744
+ end
1745
+ TkagFont = ProcType.new(proc{value = $arcadia['action.get.font'].call})
1746
+ TkagCursor = EnumType.new('X_cursor', 'hand2','left_ptr')
1747
+
1748
+ end
1749
+
1750
+ module TkProperties
1751
+
1752
+ def TkProperties.property(_name, _obj)
1753
+ {'name'=>_name,
1754
+ 'get'=> proc{_obj.cget(_name)},
1755
+ 'set'=> proc{|value| _obj.configure(_name=>value)}
1756
+ }
1757
+ end
1758
+
1759
+ def TkProperties.generic_color(_name, _obj)
1760
+ {'name'=>_name,
1761
+ 'get'=> proc{_obj.cget(_name)},
1762
+ 'set'=> proc{|value| _obj.configure(_name=>value)},
1763
+ 'def'=> '',
1764
+ 'type'=> TkType::TkagColor
1765
+ }
1766
+ end
1767
+
1768
+
1769
+ def TkProperties.background(_obj)
1770
+ {'name'=>'background',
1771
+ 'get'=> proc{_obj.cget('background')},
1772
+ 'set'=> proc{|background| _obj.configure('background'=>background)},
1773
+ 'def'=> '',
1774
+ 'type'=> TkType::TkagColor
1775
+ }
1776
+ end
1777
+
1778
+ def TkProperties.highlightbackground(_obj)
1779
+ {'name'=>'highlightbackground',
1780
+ 'get'=> proc{_obj.cget('highlightbackground')},
1781
+ 'set'=> proc{|background| _obj.configure('highlightbackground'=>background)},
1782
+ 'def'=> '',
1783
+ 'type'=> TkType::TkagColor
1784
+ }
1785
+ end
1786
+
1787
+ def TkProperties.width(_obj)
1788
+ {'name'=>'width',
1789
+ 'get'=> proc{_obj.cget('width')},
1790
+ 'set'=> proc{|t| _obj.configure('width'=>t)},
1791
+ 'def'=> ""
1792
+ }
1793
+ end
1794
+
1795
+ def TkProperties.height(_obj)
1796
+ {'name'=>'height',
1797
+ 'get'=> proc{_obj.cget('height')},
1798
+ 'set'=> proc{|t| _obj.configure('height'=>t)},
1799
+ 'def'=> ""
1800
+ }
1801
+ end
1802
+
1803
+
1804
+ def TkProperties.highlightcolor(_obj)
1805
+ {'name'=>'highlightcolor',
1806
+ 'get'=> proc{_obj.cget('highlightcolor')},
1807
+ 'set'=> proc{|background| _obj.configure('highlightcolor'=>background)},
1808
+ 'def'=> '',
1809
+ 'type'=> TkType::TkagColor
1810
+ }
1811
+ end
1812
+
1813
+ def TkProperties.highlightthickness(_obj)
1814
+ {'name'=>'highlightthickness',
1815
+ 'get'=> proc{_obj.cget('highlightthickness')},
1816
+ 'set'=> proc{|x| _obj.configure('highlightthickness'=>x)},
1817
+ 'def'=> ''
1818
+ }
1819
+ end
1820
+
1821
+ def TkProperties.foreground(_obj)
1822
+ {'name'=>'foreground',
1823
+ 'get'=> proc{_obj.cget('foreground')},
1824
+ 'set'=> proc{|foreground| _obj.configure('foreground'=>foreground)},
1825
+ 'def'=> '',
1826
+ 'type'=> TkType::TkagColor
1827
+ }
1828
+ end
1829
+
1830
+ def TkProperties.disabledforeground(_obj)
1831
+ {'name'=>'disabledforeground',
1832
+ 'get'=> proc{_obj.cget('disabledforeground')},
1833
+ 'set'=> proc{|foreground| _obj.configure('disabledforeground'=>foreground)},
1834
+ 'def'=> '',
1835
+ 'type'=> TkType::TkagColor
1836
+ }
1837
+ end
1838
+
1839
+ def TkProperties.activebackground(_obj)
1840
+ {'name'=>'activebackground',
1841
+ 'get'=> proc{_obj.cget('activebackground')},
1842
+ 'set'=> proc{|activebackground| _obj.configure('activebackground'=>activebackground)},
1843
+ 'def'=> '',
1844
+ 'type'=> TkType::TkagColor
1845
+ }
1846
+ end
1847
+
1848
+ def TkProperties.activeforeground(_obj)
1849
+ {'name'=>'activeforeground',
1850
+ 'get'=> proc{_obj.cget('activeforeground')},
1851
+ 'set'=> proc{|activeforeground| _obj.configure('activeforeground'=>activeforeground)},
1852
+ 'def'=> '',
1853
+ 'type'=> TkType::TkagColor
1854
+ }
1855
+ end
1856
+
1857
+ def TkProperties.disabledforeground(_obj)
1858
+ {'name'=>'disabledforeground',
1859
+ 'get'=> proc{_obj.cget('disabledforeground')},
1860
+ 'set'=> proc{|disabledforeground| _obj.configure('disabledforeground'=>disabledforeground)},
1861
+ 'def'=> '',
1862
+ 'type'=> TkType::TkagColor
1863
+ }
1864
+ end
1865
+
1866
+ def TkProperties.relief(_obj)
1867
+ {'name'=>'relief',
1868
+ 'get'=> proc{_obj.cget('relief')},
1869
+ 'set'=> proc{|r| _obj.configure('relief'=>r)},
1870
+ 'def'=> "",
1871
+ 'type'=> TkType::TkagRelief
1872
+ }
1873
+ end
1874
+
1875
+
1876
+ def TkProperties.overrelief(_obj)
1877
+ {'name'=>'overrelief',
1878
+ #'default'=> 'ridge',
1879
+ 'get'=> proc{_obj.cget('overrelief')},
1880
+ 'set'=> proc{|r| _obj.configure('overrelief'=>r)},
1881
+ 'def'=> "",
1882
+ 'type'=> TkType::TkagRelief
1883
+ }
1884
+ end
1885
+
1886
+ def TkProperties.command(_obj)
1887
+ {'name'=>'command',
1888
+ 'get'=> proc{eval('@c = _obj.command_script'); @c},
1889
+ 'set'=> proc{|r| _obj.configure('command'=>r)},
1890
+ 'def'=> ""
1891
+ }
1892
+ end
1893
+
1894
+ def TkProperties.xscrollcommand(_obj)
1895
+ {'name'=>'xscrollcommand',
1896
+ 'get'=> proc{_obj.cget('xscrollcommand')},
1897
+ 'set'=> proc{|r| _obj.configure('xscrollcommand'=>r)},
1898
+ 'def'=> ""
1899
+ }
1900
+ end
1901
+
1902
+ def TkProperties.yscrollcommand(_obj)
1903
+ {'name'=>'yscrollcommand',
1904
+ 'get'=> proc{_obj.cget('yscrollcommand')},
1905
+ 'set'=> proc{|r| _obj.configure('yscrollcommand'=>r)},
1906
+ 'def'=> ""
1907
+ }
1908
+ end
1909
+
1910
+
1911
+
1912
+ def TkProperties.compound(_obj)
1913
+ {'name'=>'compound',
1914
+ 'get'=> proc{_obj.cget('compound')},
1915
+ 'set'=> proc{|compound| _obj.configure('compound'=>compound)},
1916
+ 'def'=> '',
1917
+ 'type'=> TkType::TkagCompound
1918
+ }
1919
+ end
1920
+
1921
+ def TkProperties.font(_obj)
1922
+ {'name'=>'font',
1923
+ 'get'=> proc{font = _obj.cget('font')
1924
+ if font.kind_of?(TkFont)
1925
+ keys = Hash.new
1926
+ font.configinfo.each{|key,value| keys[key]=value }
1927
+ keys['family']+"\s"+keys['size'].to_s+"\s"+keys['weight'].to_s
1928
+ else
1929
+ nil
1930
+ end
1931
+ },
1932
+ 'set'=> proc{|f| _obj.configure('font'=>f)},
1933
+ 'def'=> "",
1934
+ 'type'=> TkType::TkagFont
1935
+ }
1936
+ end
1937
+
1938
+ def TkProperties.state(_obj)
1939
+ {'name'=>'state',
1940
+ 'get'=> proc{_obj.cget('state')},
1941
+ 'set'=> proc{|s| _obj.configure('state'=>s)},
1942
+ 'def'=> "",
1943
+ 'type'=> TkType::TkagState
1944
+ }
1945
+ end
1946
+
1947
+ def TkProperties.wraplength(_obj)
1948
+ {'name'=>'wraplength',
1949
+ 'get'=> proc{_obj.cget('wraplength')},
1950
+ 'set'=> proc{|w| _obj.configure('wraplength'=>w)},
1951
+ 'def'=> ""
1952
+ }
1953
+ end
1954
+
1955
+ def TkProperties.image(_obj)
1956
+ {'name'=>'image',
1957
+ 'get'=> proc{_ret = _obj.cget('image')
1958
+ if ! _ret.kind_of?(String)
1959
+ _ret = _ret.cget('file')
1960
+ end
1961
+ _ret
1962
+ },
1963
+ 'set'=> proc{|j| _obj.configure('image'=>TkAllPhotoImage.new('file' => j))},
1964
+ 'def'=> proc{|x|
1965
+ if x.to_s.length > 2
1966
+ "image TkPhotoImage.new('file' => #{x})"
1967
+ else
1968
+ ""
1969
+ end
1970
+ },
1971
+ 'type'=> TkType::TkagFile
1972
+ }
1973
+ end
1974
+
1975
+ def TkProperties.bitmap(_obj)
1976
+ {'name'=>'bitmap',
1977
+ 'get'=> proc{_obj.cget('bitmap')},
1978
+ 'set'=> proc{|j| _obj.configure('bitmap'=>TkAllPhotoImage.new('file' => j))},
1979
+ 'def'=> proc{|x|
1980
+ if x.to_s.length > 2
1981
+ "bitmap TkAllPhotoImage.new('file' => #{x})"
1982
+ else
1983
+ ""
1984
+ end
1985
+ },
1986
+ 'type'=> TkType::TkagFile
1987
+ }
1988
+ end
1989
+
1990
+
1991
+ def TkProperties.borderwidth(_obj)
1992
+ {'name'=>'borderwidth',
1993
+ #'default'=> 2,
1994
+ 'get'=> proc{_obj.cget('borderwidth')},
1995
+ 'set'=> proc{|b| _obj.configure('borderwidth'=>b)},
1996
+ 'def'=> ""
1997
+ }
1998
+ end
1999
+
2000
+ def TkProperties.border(_obj)
2001
+ {'name'=>'border',
2002
+ 'default'=> 0,
2003
+ 'get'=> proc{_obj.cget('border')},
2004
+ 'set'=> proc{|b| _obj.configure('border'=>b)},
2005
+ 'def'=> ""
2006
+ }
2007
+ end
2008
+
2009
+
2010
+ def TkProperties.padx(_obj)
2011
+ {'name'=>'padx',
2012
+ #'default'=> 0,
2013
+ 'get'=> proc{_obj.cget('padx')},
2014
+ 'set'=> proc{|b| _obj.configure('padx'=>b)},
2015
+ 'def'=> ""
2016
+ }
2017
+ end
2018
+
2019
+ def TkProperties.pady(_obj)
2020
+ {'name'=>'pady',
2021
+ #'default'=> 0,
2022
+ 'get'=> proc{_obj.cget('pady')},
2023
+ 'set'=> proc{|b| _obj.configure('pady'=>b)},
2024
+ 'def'=> ""
2025
+ }
2026
+ end
2027
+
2028
+
2029
+ def TkProperties.orient(_obj)
2030
+ {'name'=>'orient',
2031
+ 'get'=> proc{_obj.cget('orient')},
2032
+ 'set'=> proc{|o| _obj.configure('orient'=>o)},
2033
+ 'def'=> "",
2034
+ 'type'=> TkType::TkagOrient
2035
+ }
2036
+ end
2037
+
2038
+ def TkProperties.anchor(_obj)
2039
+ {'name'=>'anchor',
2040
+ 'get'=> proc{_obj.cget('anchor')},
2041
+ 'set'=> proc{|a| _obj.configure('anchor'=>a)},
2042
+ 'def'=> "",
2043
+ 'type'=> TkType::TkagAnchor
2044
+ }
2045
+ end
2046
+
2047
+ def TkProperties.labelanchor(_obj)
2048
+ {'name'=>'labelanchor',
2049
+ 'get'=> proc{_obj.cget('labelanchor')},
2050
+ 'set'=> proc{|a| _obj.configure('labelanchor'=>a)},
2051
+ 'def'=> "",
2052
+ 'type'=> TkType::TkagAnchor
2053
+ }
2054
+ end
2055
+
2056
+ def TkProperties.cursor(_obj)
2057
+ {'name'=>'cursor',
2058
+ 'get'=> proc{_obj.cget('cursor')},
2059
+ 'set'=> proc{|o| _obj.configure('cursor'=>o)},
2060
+ 'def'=> "",
2061
+ 'type'=> TkType::TkagCursor
2062
+ }
2063
+ end
2064
+
2065
+ def TkProperties.justify(_obj)
2066
+ {'name'=>'justify',
2067
+ 'get'=> proc{_obj.cget('justify')},
2068
+ 'set'=> proc{|j| _obj.configure('justify'=>j)},
2069
+ 'def'=> "",
2070
+ 'type'=> TkType::TkagJustify
2071
+ }
2072
+ end
2073
+
2074
+ def TkProperties.takefocus(_obj)
2075
+ {'name'=>'takefocus',
2076
+ 'get'=> proc{_obj.cget('takefocus')},
2077
+ 'set'=> proc{|j| _obj.configure('takefocus'=>j)},
2078
+ 'def'=> "",
2079
+ 'type'=> EnumType.new(0,1)
2080
+ }
2081
+ end
2082
+
2083
+ def TkProperties.class(_obj)
2084
+ {'name'=>'class',
2085
+ 'get'=> proc{_obj.cget('class')},
2086
+ 'set'=> proc{|r| _obj.configure('class'=>r)},
2087
+ 'def'=> ""
2088
+ }
2089
+ end
2090
+
2091
+ def TkProperties.colormap(_obj)
2092
+ {'name'=>'colormap',
2093
+ 'get'=> proc{_obj.cget('colormap')},
2094
+ 'set'=> proc{|r| _obj.configure('colormap'=>r)},
2095
+ 'def'=> "",
2096
+ 'type'=> EnumType.new('new','')
2097
+ }
2098
+ end
2099
+
2100
+ def TkProperties.container(_obj)
2101
+ {'name'=>'container',
2102
+ 'get'=> proc{_obj.cget('container')},
2103
+ 'set'=> proc{|r| _obj.configure('container'=>r)},
2104
+ 'def'=> "",
2105
+ 'type'=> TkType::TkagBool
2106
+ }
2107
+ end
2108
+
2109
+ def TkProperties.text(_obj)
2110
+ {'name'=>'text',
2111
+ 'start'=> '<...>',
2112
+ 'get'=> proc{_obj.cget('text')},
2113
+ 'set'=> proc{|t| _obj.configure('text'=>t)},
2114
+ 'def'=> ""
2115
+ }
2116
+ end
2117
+ def TkProperties.labelwidget(_obj)
2118
+ {'name'=>'labelwidget',
2119
+ 'get'=> proc{_obj.cget('labelwidget')},
2120
+ 'set'=> proc{|t| _obj.configure('labelwidget'=>t)},
2121
+ 'def'=> ""
2122
+ }
2123
+ end
2124
+
2125
+ # def TkProperties.path(_obj)
2126
+ # {'name'=>'path',
2127
+ # 'get'=> proc{_obj.path},
2128
+ # 'def'=> 'nodef'
2129
+ # }
2130
+ # end
2131
+
2132
+ end
2133
+
2134
+
2135
+
2136
+ class AGTkLayoutManaged < AGTk
2137
+ def start_properties
2138
+ if (defined? @ag_parent.where_x)&&(defined? @ag_parent.where_y)
2139
+ @props['place']['x']['start'] = @ag_parent.where_x
2140
+ @props['place']['y']['start'] = @ag_parent.where_y
2141
+ end
2142
+ super()
2143
+ end
2144
+
2145
+
2146
+ def properties
2147
+ super
2148
+ # +-----------------------------------+
2149
+ # | common properties |
2150
+ # +-----------------------------------+
2151
+ _self = self
2152
+
2153
+ publish('layout_man','name'=>'manager',
2154
+ 'default'=> 'place',
2155
+ 'get'=> proc{TkWinfo.manager(@obj)},
2156
+ 'set'=> proc{|l|
2157
+ _old_manager = @props['layout_man']['manager']['value']
2158
+ @props['layout_man']['manager']['value'] = l
2159
+ if ['pack','place','grid'].include?(l)
2160
+ if _old_manager != l
2161
+ eval('@obj.'+@renderer.render_family(0,l,nil,true).to_s.strip)
2162
+ WrapperContract.instance.property_updated(
2163
+ WrapperContract::TWrapperObj.new(self,
2164
+ 'wrapper'=>self,
2165
+ 'property_name'=> 'manager',
2166
+ 'property_family'=>'layout_man',
2167
+ 'property_old_value'=>_old_manager,
2168
+ 'property_new_value'=>l
2169
+ )
2170
+ )
2171
+
2172
+ end
2173
+ end
2174
+ if _old_manager != @props['layout_man']['manager']['value']
2175
+ self.l_manager.switch_manager if self.l_manager != nil
2176
+ end
2177
+
2178
+ },
2179
+ 'def'=> proc{""},
2180
+ 'type'=> EnumType.new('place','pack','grid')
2181
+ )
2182
+ # +-----------------------------------+
2183
+ # | place |
2184
+ # +-----------------------------------+
2185
+ publish_def('place',
2186
+ 'before'=>'place(',
2187
+ 'sep'=>',',
2188
+ 'after'=>')'
2189
+ )
2190
+ publish('place','name'=>'x',
2191
+ 'get'=> proc{TkPlace.info(@obj)['x'] if TkWinfo.manager(@obj)=='place'},
2192
+ 'set'=> proc{|x| @obj.place('x'=>x); @props['place']['x']['value'] = x },
2193
+ 'def'=> proc{|x| "'x'=>#{x}"},
2194
+ 'default'=> 10
2195
+ )
2196
+ publish('place','name'=>'y',
2197
+ 'get'=> proc{TkPlace.info(@obj)['y'] if TkWinfo.manager(@obj)=='place'},
2198
+ 'set'=> proc{|y| @obj.place('y'=>y);@props['place']['y']['value'] = y},
2199
+ 'def'=> proc{|x| "'y'=>#{x}"},
2200
+ 'default'=> 10
2201
+ )
2202
+ publish('place','name'=>'width',
2203
+ 'get'=> proc{if TkWinfo.mapped?(@obj)
2204
+ TkWinfo.width(@obj) if TkWinfo.manager(@obj)=='place'
2205
+ else
2206
+ TkWinfo.reqwidth(@obj) if TkWinfo.manager(@obj)=='place'
2207
+ end
2208
+ },
2209
+ 'set'=> proc{|w| @obj.place('width'=>w)},
2210
+ 'def'=> proc{|x| "'width'=>#{x}"}
2211
+ )
2212
+
2213
+ publish('place','name'=>'height',
2214
+ 'get'=> proc{if TkWinfo.mapped?(@obj)
2215
+ TkWinfo.height(@obj) if TkWinfo.manager(@obj)=='place'
2216
+ else
2217
+ TkWinfo.reqheight(@obj) if TkWinfo.manager(@obj)=='place'
2218
+ end
2219
+ },
2220
+ 'set'=> proc{|h| @obj.place('height'=>h);@props['place']['height']['value'] = h},
2221
+ 'def'=> proc{|x| "'height'=> #{x}"}
2222
+ )
2223
+
2224
+ publish('place','name'=>'relx',
2225
+ 'get'=> proc{TkPlace.info(@obj)['relx'] if TkWinfo.manager(@obj)=='place'},
2226
+ 'set'=> proc{|x| @obj.place('relx'=>x);@props['place']['relx']['value'] = x},
2227
+ 'def'=> proc{|x| "'relx'=> #{x}"},
2228
+ 'value'=> 0,
2229
+ 'default'=> 0
2230
+ )
2231
+
2232
+ publish('place','name'=>'rely',
2233
+ 'get'=> proc{TkPlace.info(@obj)['rely'] if TkWinfo.manager(@obj)=='place'},
2234
+ 'set'=> proc{|x| @obj.place('rely'=>x);@props['place']['rely']['value'] = x},
2235
+ 'def'=> proc{|x| "'rely'=> #{x}"},
2236
+ 'value'=> 0,
2237
+ 'default'=> 0
2238
+ )
2239
+
2240
+ publish('place','name'=>'relheight',
2241
+ 'get'=> proc{TkPlace.info(@obj)['relheight'] if TkWinfo.manager(@obj)=='place'},
2242
+ 'set'=> proc{|x| @obj.place('relheight'=>x);@props['place']['relheight']['value'] = x},
2243
+ 'def'=> proc{|x| "'relheight'=> #{x}"},
2244
+ 'value'=> 0,
2245
+ 'default'=> ''
2246
+ )
2247
+
2248
+ publish('place','name'=>'relwidth',
2249
+ 'get'=> proc{TkPlace.info(@obj)['relwidth'] if TkWinfo.manager(@obj)=='place'},
2250
+ 'set'=> proc{|x| @obj.place('relwidth'=>x);@props['place']['relwidth']['value'] = x},
2251
+ 'def'=> proc{|x| "'relwidth'=> #{x}"},
2252
+ 'value'=> 0,
2253
+ 'default'=> ''
2254
+ )
2255
+
2256
+ publish('place','name'=>'bordermode',
2257
+ 'get'=> proc{TkPlace.info(@obj)['bordermode'] if TkWinfo.manager(@obj)=='place'},
2258
+ 'set'=> proc{|x| @obj.place('bordermode'=>x);@props['place']['bordermode']['value'] = x},
2259
+ 'def'=> proc{|x| "'bordermode'=> #{x}"},
2260
+ 'default'=> 'inside',
2261
+ 'type'=> EnumType.new('inside','outside','ignore')
2262
+ )
2263
+ # +-----------------------------------+
2264
+ # | pack |
2265
+ # +-----------------------------------+
2266
+
2267
+ publish_def('pack',
2268
+ 'before'=>'pack(',
2269
+ 'sep'=>',',
2270
+ 'after'=>')',
2271
+ 'default'=>proc{|name,x| "'#{name}'=> #{x}"}
2272
+ )
2273
+
2274
+ publish('pack','name'=>'anchor',
2275
+ 'get'=> proc{TkPack.info(@obj)['anchor'] if TkWinfo.manager(@obj)=='pack'},
2276
+ 'set'=> proc{|a| @obj.pack('anchor'=>a)},
2277
+ 'def'=> proc{|x| "'anchor'=> #{x}"},
2278
+ 'type'=> TkType::TkagAnchor
2279
+ )
2280
+
2281
+ publish('pack','name'=>'fill',
2282
+ 'get'=> proc{TkPack.info(@obj)['fill'] if TkWinfo.manager(@obj)=='pack'},
2283
+ 'set'=> proc{|a| @obj.pack('fill'=>a)},
2284
+ 'def'=> proc{|x| "'fill'=> #{x}"},
2285
+ 'type'=> EnumType.new('none','x','y','both')
2286
+ )
2287
+
2288
+ publish('pack','name'=>'ipadx',
2289
+ 'get'=> proc{TkPack.info(@obj)['ipadx'] if TkWinfo.manager(@obj)=='pack'},
2290
+ 'set'=> proc{|x| @obj.pack('ipadx'=>x)},
2291
+ 'def'=> proc{|x| "'ipadx'=> #{x}"}
2292
+ )
2293
+
2294
+ publish('pack','name'=>'ipady',
2295
+ 'get'=> proc{TkPack.info(@obj)['ipady'] if TkWinfo.manager(@obj)=='pack'},
2296
+ 'set'=> proc{|x| @obj.pack('ipady'=>x)},
2297
+ 'def'=> proc{|x| "'ipady'=> #{x}"}
2298
+ )
2299
+
2300
+ publish('pack','name'=>'expand',
2301
+ 'get'=> proc{TkPack.info(@obj)['expand'] if TkWinfo.manager(@obj)=='pack'},
2302
+ 'set'=> proc{|x| @obj.pack('expand'=>x)},
2303
+ 'def'=> '',
2304
+ 'type'=> EnumType.new('yes','no')
2305
+ )
2306
+
2307
+ publish('pack','name'=>'side',
2308
+ 'get'=> proc{TkPack.info(@obj)['side'] if TkWinfo.manager(@obj)=='pack'},
2309
+ 'set'=> proc{|x| @obj.pack('side'=>x)},
2310
+ 'def'=> '',
2311
+ 'type'=> EnumType.new('left', 'right', 'top','bottom')
2312
+ )
2313
+
2314
+ publish('pack','name'=>'padx',
2315
+ 'get'=> proc{TkPack.info(@obj)['padx'] if TkWinfo.manager(@obj)=='pack'},
2316
+ 'set'=> proc{|x| @obj.pack('padx'=>x)},
2317
+ 'def'=> ''
2318
+ )
2319
+
2320
+ publish('pack','name'=>'pady',
2321
+ 'get'=> proc{TkPack.info(@obj)['pady'] if TkWinfo.manager(@obj)=='pack'},
2322
+ 'set'=> proc{|y| @obj.pack('padx'=>y)},
2323
+ 'def'=> ''
2324
+ )
2325
+ # +-----------------------------------+
2326
+ # | grid |
2327
+ # +-----------------------------------+
2328
+
2329
+ publish_def('grid',
2330
+ 'before'=>'grid(',
2331
+ 'sep'=>',',
2332
+ 'after'=>')'
2333
+ )
2334
+
2335
+ publish('grid','name'=>'column',
2336
+ 'get'=> proc{TkGrid.info(@obj)['column'] if TkWinfo.manager(@obj)=='grid'},
2337
+ 'set'=> proc{|y| @obj.grid('column'=>y)},
2338
+ 'def'=> ''
2339
+ )
2340
+
2341
+ publish('grid','name'=>'row',
2342
+ 'get'=> proc{TkGrid.info(@obj)['row'] if TkWinfo.manager(@obj)=='grid'},
2343
+ 'set'=> proc{|y| @obj.grid('row'=>y)},
2344
+ 'def'=> ''
2345
+ )
2346
+
2347
+ publish('grid','name'=>'columnspan',
2348
+ 'get'=> proc{TkGrid.info(@obj)['columnspan'] if TkWinfo.manager(@obj)=='grid'},
2349
+ 'set'=> proc{|y| @obj.grid('columnspan'=>y)},
2350
+ 'def'=> ''
2351
+ )
2352
+
2353
+ publish('grid','name'=>'rowspan',
2354
+ 'get'=> proc{TkGrid.info(@obj)['rowspan'] if TkWinfo.manager(@obj)=='grid'},
2355
+ 'set'=> proc{|y| @obj.grid('rowspan'=>y)},
2356
+ 'def'=> ''
2357
+ )
2358
+
2359
+ publish('grid','name'=>'padx',
2360
+ 'get'=> proc{TkGrid.info(@obj)['padx'] if TkWinfo.manager(@obj)=='grid'},
2361
+ 'set'=> proc{|y| @obj.grid('padx'=>y)},
2362
+ 'def'=> ''
2363
+ )
2364
+
2365
+ publish('grid','name'=>'pady',
2366
+ 'get'=> proc{TkGrid.info(@obj)['pady'] if TkWinfo.manager(@obj)=='grid'},
2367
+ 'set'=> proc{|y| @obj.grid('pady'=>y)},
2368
+ 'def'=> ''
2369
+ )
2370
+
2371
+ publish('grid','name'=>'ipadx',
2372
+ 'get'=> proc{TkGrid.info(@obj)['ipadx'] if TkWinfo.manager(@obj)=='grid'},
2373
+ 'set'=> proc{|y| @obj.grid('ipadx'=>y)},
2374
+ 'def'=> ''
2375
+ )
2376
+
2377
+ publish('grid','name'=>'ipady',
2378
+ 'get'=> proc{TkGrid.info(@obj)['ipady'] if TkWinfo.manager(@obj)=='grid'},
2379
+ 'set'=> proc{|y| @obj.grid('ipady'=>y)},
2380
+ 'def'=> ''
2381
+ )
2382
+
2383
+ publish('grid','name'=>'in',
2384
+ 'get'=> proc{TkGrid.info(@obj)['in'] if TkWinfo.manager(@obj)=='grid'},
2385
+ 'set'=> proc{|y| @obj.grid('in'=>y)},
2386
+ 'def'=> ''
2387
+ )
2388
+
2389
+ # +-----------------------------------+
2390
+ # | binding |
2391
+ # +-----------------------------------+
2392
+
2393
+ @persistent_proc = proc{|url,value|
2394
+ if @persistent['prog'] == nil
2395
+ @persistent['prog'] = 0
2396
+ end
2397
+ if @persistent[url] == nil
2398
+ @persistent[url] = Array.new
2399
+ end
2400
+ @persistent[url][@persistent['prog']]=value
2401
+ }
2402
+
2403
+ publish('bind','name'=>'event',
2404
+ 'get'=>proc{@persistent['events'][@persistent['prog']] if @persistent['events'] != nil},
2405
+ 'set'=>proc{|v| @persistent_proc.call('events',v)},
2406
+ 'def'=>proc{|x| "#{x}"}
2407
+ )
2408
+
2409
+ publish('bind','name'=>'handler',
2410
+ 'get'=>proc{@persistent['procs'][@persistent['prog']] if @persistent['procs'] != nil},
2411
+ 'set'=>proc{|v| @persistent_proc.call('procs',v)},
2412
+ 'def'=>proc{|x| "proc{#{x}}"},
2413
+ 'def_string'=>false
2414
+ )
2415
+
2416
+ publish_def('bind',
2417
+ 'path'=>'',
2418
+ 'before'=>'bind(',
2419
+ 'after'=>')',
2420
+ 'sep'=>',',
2421
+ 'default'=>proc{|name,x| "#{x}"}
2422
+ )
2423
+ end
2424
+
2425
+ end
2426
+ #-----------------------------------------------------------------
2427
+
2428
+ class AGTkBase < AGTkLayoutManaged
2429
+ def properties
2430
+ super
2431
+ publish('property',TkProperties::background(@obj))
2432
+ end
2433
+ end
2434
+
2435
+ class AGTkBaseContainer < AGTkLayoutManaged
2436
+ attr_reader :where_x, :where_y
2437
+ def initialize(_ag_parent, _object = nil)
2438
+ super(_ag_parent, _object)
2439
+ p1 = proc{|e|
2440
+ @where_x = e.x
2441
+ @where_y = e.y
2442
+ #$arcadia.objects('objic').activate(@object_inspector) if @object_inspector != $arcadia.objects('objic').active
2443
+ _tobj = PaletteContract::TPaletteObj.new(self)
2444
+ _tobj.parent = self
2445
+ PaletteContract.instance.make_selected(_tobj)
2446
+ #Arcadia.instance.retrieve_contract(self, PaletteActionContract).make_selected(PaletteActionContract::TObj.new(self))
2447
+ #$arcadia.objects('palette').give_me_obj(self)
2448
+ #@obj.callback_break
2449
+ }
2450
+ @obj.bind_append("ButtonRelease-1", p1)
2451
+
2452
+ end
2453
+ def properties
2454
+ super
2455
+ publish('property',TkProperties::background(@obj))
2456
+ end
2457
+ end
2458
+
2459
+ class AGTkContainer < AGTkBaseContainer
2460
+ def AGTkContainer.class_sniffer
2461
+ AGTkCompositeSniffer
2462
+ end
2463
+ end
2464
+
2465
+
2466
+ class AGTkToplevel < AGTkContainer
2467
+
2468
+ def initialize(_ag_parent=nil, _object = nil)
2469
+ super(_ag_parent, _object)
2470
+
2471
+ @l_manager.util_bind
2472
+ end
2473
+
2474
+ def AGTkToplevel.class_wrapped
2475
+ TkToplevel
2476
+ end
2477
+
2478
+ def form2code
2479
+ tobj = EditorContract::TEditorObj.new(self)
2480
+ tobj.title = @i_name
2481
+ tobj.text = @renderer.class_code.to_s
2482
+ EditorContract.instance.open_text(tobj)
2483
+ #Arcadia.instance.retrieve_contract(self, EditorActionContract).open_text(tobj)
2484
+ self.delete
2485
+ end
2486
+
2487
+ def keep_me
2488
+ $arcadia['buffers.code.in_memory'][@i_name]=@renderer.class_code.to_s
2489
+ self.delete
2490
+ end
2491
+
2492
+ def popup_items(_popup_menu)
2493
+ super(_popup_menu)
2494
+ _popup_menu.insert('end',
2495
+ :command,
2496
+ :label=>'View as code',
2497
+ :hidemargin => false,
2498
+ :command=> proc{form2code}
2499
+ )
2500
+ end
2501
+
2502
+
2503
+
2504
+ def on_close_query
2505
+ ans = Tk.messageBox('icon' => 'question', 'type' => 'yesnocancel',
2506
+ 'title' => 'Exit', 'parent' => @obj,
2507
+ 'message' => "Do you want shift to code view?")
2508
+
2509
+ if ans =='yes'
2510
+ form2code
2511
+ elsif ans =='no'
2512
+ keep_me
2513
+ end
2514
+ end
2515
+
2516
+ def set_obj_exit_protocol
2517
+ @obj.protocol( "WM_DELETE_WINDOW", proc{on_close_query})
2518
+ end
2519
+
2520
+ def new_object
2521
+ super
2522
+ set_obj_exit_protocol
2523
+ end
2524
+
2525
+
2526
+ def passed_object(_obj)
2527
+ super(_obj)
2528
+ set_obj_exit_protocol
2529
+ end
2530
+
2531
+ def rewind_by_property(_name, _val)
2532
+ msg = "To modify "+_name+" must create new Toplevel: do you want to procede ?"
2533
+ if Tk.messageBox('icon' => 'warning', 'type' => 'okcancel',
2534
+ 'title' => '(Arcadia) '+_name, 'message' => msg) == 'cancel'
2535
+ return
2536
+ end
2537
+ _rewind_code = @renderer.class_code(2,_name=> _val).to_s
2538
+ begin
2539
+ Revparsel.new(_rewind_code)
2540
+ #$arcadia.objects('objic').del(@object_inspector)
2541
+ rescue => exc
2542
+ _editor = $arcadia.objects('editor').open_tab(@i_name)
2543
+ _editor.text_insert('end', _rewind_code)
2544
+ raise
2545
+ end
2546
+ end
2547
+
2548
+ def properties
2549
+ super
2550
+ publish_mod('layout_man','name'=>'manager',
2551
+ 'default'=> 'none',
2552
+ 'get'=> proc{'none'},
2553
+ 'set'=> proc{},
2554
+ 'def'=> proc{""},
2555
+ 'type'=> ''
2556
+ )
2557
+ publish_del('place')
2558
+ publish_del('pack')
2559
+ publish_del('property','state')
2560
+ publish('property','name'=>'geometry',
2561
+ 'get'=> proc{ TkWinfo.geometry(@obj)},
2562
+ 'set'=> proc{|g| Tk.tk_call('wm', 'geometry', @obj, g )},
2563
+ 'def'=> proc{|x| "Tk.tk_call('wm', 'geometry', self, #{x} )"},
2564
+ 'start'=> '245x180+300+230'
2565
+ )
2566
+ publish('property','name'=>'icon',
2567
+ 'get'=> proc{Tk.tk_call('wm', 'iconbitmap', @obj, nil)},
2568
+ 'set'=> proc{|i| Tk.tk_call('wm', 'iconbitmap', @obj, i )},
2569
+ 'def'=> proc{|x| "Tk.tk_call('wm', 'iconbitmap', self, #{x} )"},
2570
+ 'type'=> TkType::TkagFile
2571
+ )
2572
+ publish('property','name'=>'title',
2573
+ 'get'=> proc{ Tk.tk_call('wm', 'title', @obj)},
2574
+ 'set'=> proc{|t| Tk.tk_call('wm', 'title', @obj, t )},
2575
+ 'def'=> proc{|x| "Tk.tk_call('wm', 'title', self, #{x} )"},
2576
+ 'start'=>'...hello'
2577
+ )
2578
+ publish('property',TkProperties::container(@obj))
2579
+ publish('property',TkProperties::borderwidth(@obj))
2580
+ publish('property',TkProperties::cursor(@obj))
2581
+ publish('property',TkProperties::highlightbackground(@obj))
2582
+ publish('property',TkProperties::highlightcolor(@obj))
2583
+ publish('property',TkProperties::highlightthickness(@obj))
2584
+ publish('property',TkProperties::relief(@obj))
2585
+ publish('property',TkProperties::takefocus(@obj))
2586
+ publish('property',TkProperties::padx(@obj))
2587
+ publish('property',TkProperties::pady(@obj))
2588
+ publish('property',TkProperties::height(@obj))
2589
+ publish('property',TkProperties::width(@obj))
2590
+ publish('property','name'=>'class',
2591
+ 'get'=> proc{@obj.cget('class')},
2592
+ 'set'=> proc{ |r| rewind_by_property('class',r) },
2593
+ 'kind'=>'on-create'
2594
+ )
2595
+ publish('property','name'=>'colormap',
2596
+ 'get'=> proc{@obj.cget('colormap')},
2597
+ 'set'=> proc{|t| @obj.configure('colormap'=>t)},
2598
+ 'def'=> ""
2599
+ )
2600
+
2601
+ publish('property','name'=>'menu',
2602
+ 'get'=> proc{@obj.cget('menu')},
2603
+ 'set'=> proc{|t| @obj.configure('menu'=>t)},
2604
+ 'def'=> ""
2605
+ )
2606
+
2607
+ publish('property','name'=>'screen',
2608
+ 'get'=> proc{@obj.cget('screen')},
2609
+ 'set'=> proc{|t| rewind_by_property('screen',t) },
2610
+ 'def'=> "",
2611
+ 'kind'=>'on-create'
2612
+ )
2613
+
2614
+ publish('property','name'=>'use',
2615
+ 'get'=> proc{@obj.cget('use')},
2616
+ 'set'=> proc{ |r| rewind_by_property('use',r) },
2617
+ 'kind'=>'on-create'
2618
+ )
2619
+
2620
+ publish('property','name'=>'visual',
2621
+ 'get'=> proc{@obj.cget('visual')},
2622
+ 'set'=> proc{|r| rewind_by_property('visual',r) },
2623
+ 'def'=> "",
2624
+ 'kind'=>'on-create',
2625
+ 'type'=> EnumType.new('','best', 'directcolor', 'grayscale','greyscale',
2626
+ 'pseudocolor', 'staticcolor', 'staticgray', 'staticgrey', 'truecolor', 'default')
2627
+ )
2628
+
2629
+ publish('winfo','name'=>'server','get'=> proc{TkWinfo.server(@obj)}, 'def'=> 'nodef')
2630
+ publish('winfo','name'=>'screen','get'=> proc{TkWinfo.screen(@obj)}, 'def'=> 'nodef')
2631
+
2632
+ end
2633
+
2634
+ def get_implementation_new #overloaded
2635
+ result = '@',@i_name,' = ', getInstanceClass ,".new\n"
2636
+ result = result,'@', @i_ag," = ",self.class, '.new(nil,','@',@i_name,", $arcadia.objects('objic').create(",
2637
+ "self,'", $arcadia.objects('objic').active.filename,"'))"
2638
+ end
2639
+ end
2640
+
2641
+ class AGTkRoot < AGTkToplevel
2642
+
2643
+ def AGTkRoot.class_wrapped
2644
+ TkRoot
2645
+ end
2646
+
2647
+ def new_object
2648
+ AGTkToplevel.new_object
2649
+ end
2650
+
2651
+ end
2652
+
2653
+ class AGTkFrame < AGTkContainer
2654
+
2655
+ def AGTkFrame.class_wrapped
2656
+ TkFrame
2657
+ end
2658
+
2659
+ def properties
2660
+ super
2661
+ publish('property',TkProperties::borderwidth(@obj))
2662
+ publish('property',TkProperties::cursor(@obj))
2663
+ publish('property',TkProperties::highlightbackground(@obj))
2664
+ publish('property',TkProperties::highlightcolor(@obj))
2665
+ publish('property',TkProperties::highlightthickness(@obj))
2666
+ publish('property',TkProperties::relief(@obj))
2667
+ publish('property',TkProperties::takefocus(@obj))
2668
+ publish('property',TkProperties::class(@obj))
2669
+ publish('property',TkProperties::colormap(@obj))
2670
+ publish('property',TkProperties::padx(@obj))
2671
+ publish('property',TkProperties::pady(@obj))
2672
+ publish('property',TkProperties::container(@obj))
2673
+ publish('property',TkProperties::border(@obj))
2674
+ publish('property',TkProperties::height(@obj))
2675
+ publish('property',TkProperties::width(@obj))
2676
+ publish_mod('place','name'=>'width', 'default'=> 200)
2677
+ publish('property','name'=>'visual',
2678
+ 'get'=> proc{@obj.cget('visual')},
2679
+ 'set'=> proc{|r| rewind_by_property('visual',r) },
2680
+ 'def'=> "",
2681
+ 'kind'=>'on-create',
2682
+ 'type'=> EnumType.new('','best', 'directcolor', 'grayscale','greyscale',
2683
+ 'pseudocolor', 'staticcolor', 'staticgray', 'staticgrey', 'truecolor', 'default')
2684
+ )
2685
+ end
2686
+
2687
+ def rewind_by_property(_name, _val)
2688
+ msg = "To modify "+_name+" must create new Toplevel: do you want to procede ?"
2689
+ if Tk.messageBox('icon' => 'warning', 'type' => 'okcancel',
2690
+ 'title' => '(Arcadia) '+_name, 'message' => msg) == 'cancel'
2691
+ return
2692
+ end
2693
+ _rewind_code = @renderer.class_code(2,_name=> _val).to_s
2694
+ begin
2695
+ Tk.messageBox('message'=>_rewind_code)
2696
+ #@object_inspector.delete(self)
2697
+ #Revparsel.new(_rewind_code)
2698
+
2699
+ rescue => exc
2700
+ _editor = $arcadia.objects('editor').open_tab(@i_name)
2701
+ _editor.text_insert('end', _rewind_code)
2702
+ raise
2703
+ end
2704
+ end
2705
+
2706
+ end
2707
+
2708
+ class AGTkLabelFrame < AGTkFrame
2709
+ def AGTkLabelFrame.class_wrapped
2710
+ TkLabelFrame
2711
+ end
2712
+
2713
+ def properties
2714
+ super
2715
+ publish('property',TkProperties::text(@obj))
2716
+ publish('property',TkProperties::labelanchor(@obj))
2717
+ publish('property',TkProperties::labelwidget(@obj))
2718
+ end
2719
+ end
2720
+
2721
+
2722
+ class AGTkLabel < AGTkContainer
2723
+ def AGTkLabel.class_wrapped
2724
+ TkLabel
2725
+ end
2726
+
2727
+ def properties
2728
+ super
2729
+ publish('property',TkProperties::relief(@obj))
2730
+ publish('property',TkProperties::wraplength(@obj))
2731
+ publish('property',TkProperties::borderwidth(@obj))
2732
+ publish('property',TkProperties::activebackground(@obj))
2733
+ publish('property',TkProperties::activeforeground(@obj))
2734
+ publish('property',TkProperties::anchor(@obj))
2735
+ publish('property',TkProperties::background(@obj))
2736
+ publish('property',TkProperties::bitmap(@obj))
2737
+ publish('property',TkProperties::compound(@obj))
2738
+ publish('property',TkProperties::borderwidth(@obj))
2739
+ publish('property',TkProperties::cursor(@obj))
2740
+ publish('property',TkProperties::disabledforeground(@obj))
2741
+ publish('property',TkProperties::font(@obj))
2742
+ publish('property',TkProperties::foreground(@obj))
2743
+ publish('property',TkProperties::highlightbackground(@obj))
2744
+ publish('property',TkProperties::highlightcolor(@obj))
2745
+ publish('property',TkProperties::highlightthickness(@obj))
2746
+ publish('property',TkProperties::image(@obj))
2747
+ publish('property',TkProperties::justify(@obj))
2748
+ publish('property',TkProperties::padx(@obj))
2749
+ publish('property',TkProperties::pady(@obj))
2750
+ publish('property',TkProperties::takefocus(@obj))
2751
+ publish('property',TkProperties::text(@obj))
2752
+ publish('property',TkProperties::property('textvariable', @obj))
2753
+ publish('property',TkProperties::property('underline', @obj))
2754
+ publish('property',TkProperties::property('wraplength', @obj))
2755
+ publish('property',TkProperties::height(@obj))
2756
+ publish('property',TkProperties::state(@obj))
2757
+ publish('property',TkProperties::width(@obj))
2758
+
2759
+ end
2760
+
2761
+ end
2762
+
2763
+ class AGTkButton < AGTkBase
2764
+
2765
+ def AGTkButton.class_wrapped
2766
+ TkButton
2767
+ end
2768
+
2769
+ def properties
2770
+ super()
2771
+ publish('property',TkProperties::relief(@obj))
2772
+ publish('property',TkProperties::overrelief(@obj))
2773
+ publish('property',TkProperties::foreground(@obj))
2774
+ publish('property',TkProperties::compound(@obj))
2775
+ publish('property',TkProperties::image(@obj))
2776
+ publish('property',TkProperties::font(@obj))
2777
+ publish('property',TkProperties::anchor(@obj))
2778
+ publish('property',TkProperties::padx(@obj))
2779
+ publish('property',TkProperties::pady(@obj))
2780
+ publish('property',TkProperties::activebackground(@obj))
2781
+ publish('property',TkProperties::text(@obj))
2782
+ publish('property',TkProperties::activeforeground(@obj))
2783
+ publish('property',TkProperties::borderwidth(@obj))
2784
+ publish('property','name'=>'justify',
2785
+ 'get'=> proc{@obj.cget('justify')},
2786
+ 'set'=> proc{|j| @obj.configure('justify'=>j)},
2787
+ 'def'=> "",
2788
+ 'type'=> TkType::TkagJustify
2789
+ )
2790
+ publish('property','name'=>'default',
2791
+ 'get'=> proc{@obj.cget('default')},
2792
+ 'set'=> proc{|j| @obj.configure('default'=>j)},
2793
+ 'def'=> "",
2794
+ 'type'=> TkType::TkagState
2795
+ )
2796
+ end
2797
+ end
2798
+
2799
+ class AGTkCheckButton < AGTkBase
2800
+ def AGTkCheckButton.class_wrapped
2801
+ TkCheckButton
2802
+ end
2803
+
2804
+ def properties
2805
+ super()
2806
+ publish('property','name'=>'relief',
2807
+ 'get'=> proc{@obj.cget('relief')},
2808
+ 'set'=> proc{|r| @obj.configure('relief'=>r)},
2809
+ 'def'=> "",
2810
+ 'type'=> TkType::TkagRelief
2811
+ )
2812
+
2813
+ publish('property','name'=>'text',
2814
+ 'default'=> @i_name,
2815
+ 'get'=> proc{@obj.cget('text')},
2816
+ 'set'=> proc{|t| @obj.configure('text'=>t)},
2817
+ 'def'=> ""
2818
+ )
2819
+ publish('property','name'=>'justify',
2820
+ 'get'=> proc{@obj.cget('justify')},
2821
+ 'set'=> proc{|j| @obj.configure('justify'=>j)},
2822
+ 'def'=> "",
2823
+ 'type'=> TkType::TkagJustify
2824
+ )
2825
+ end
2826
+ end
2827
+
2828
+
2829
+ class AGTkListbox < AGTkBase
2830
+ def AGTkListbox.class_wrapped
2831
+ TkListbox
2832
+ end
2833
+
2834
+ def properties
2835
+ super()
2836
+ publish('property','name'=>'relief',
2837
+ 'get'=> proc{@obj.cget('relief')},
2838
+ 'set'=> proc{|r| @obj.configure('relief'=>r)},
2839
+ 'def'=> "",
2840
+ 'type'=> TkType::TkagRelief
2841
+ )
2842
+ end
2843
+ end
2844
+
2845
+
2846
+ class AGTkEntry < AGTkBase
2847
+
2848
+ def AGTkEntry.class_wrapped
2849
+ TkEntry
2850
+ end
2851
+
2852
+ def properties
2853
+ super()
2854
+ publish('property','name'=>'relief',
2855
+ 'get'=> proc{@obj.cget('relief')},
2856
+ 'set'=> proc{|r| @obj.configure('relief'=>r)},
2857
+ 'def'=> "",
2858
+ 'type'=> TkType::TkagRelief
2859
+ )
2860
+ publish('property','name'=>'text',
2861
+ 'default'=> @i_name,
2862
+ 'get'=> proc{@obj.cget('text')},
2863
+ 'set'=> proc{|t| @obj.configure('text'=>t)},
2864
+ 'def'=> ""
2865
+ )
2866
+ publish('property','name'=>'justify',
2867
+ 'get'=> proc{@obj.cget('justify')},
2868
+ 'set'=> proc{|j| @obj.configure('justify'=>j)},
2869
+ 'def'=> "",
2870
+ 'type'=> TkType::TkagJustify
2871
+ )
2872
+ publish('property','name'=>'value',
2873
+ 'default'=> '',
2874
+ 'get'=> proc{@obj.value},
2875
+ 'set'=> proc{|t| @obj.value=t},
2876
+ 'def'=> proc{|x| "self.value=#{x}"}
2877
+ )
2878
+ end
2879
+ end
2880
+
2881
+ class AGTkText < AGTkContainer
2882
+
2883
+ def AGTkText.class_wrapped
2884
+ TkText
2885
+ end
2886
+
2887
+ def properties
2888
+ super()
2889
+ publish('property','name'=>'relief',
2890
+ 'get'=> proc{@obj.cget('relief')},
2891
+ 'set'=> proc{|r| @obj.configure('relief'=>r)},
2892
+ 'def'=> "",
2893
+ 'type'=> TkType::TkagRelief
2894
+ )
2895
+
2896
+ publish('property','name'=>'exportselection',
2897
+ 'get'=> proc{@obj.cget('exportselection')},
2898
+ 'set'=> proc{|r| @obj.configure('exportselection'=>r)},
2899
+ 'def'=> "",
2900
+ 'type'=> TkType::TkagBool
2901
+ )
2902
+
2903
+ publish('property','name'=>'setgrid',
2904
+ 'get'=> proc{@obj.cget('setgrid')},
2905
+ 'set'=> proc{|r| @obj.configure('setgrid'=>r)},
2906
+ 'def'=> "",
2907
+ 'type'=> TkType::TkagBool
2908
+ )
2909
+
2910
+ publish('property','name'=>'autoseparators',
2911
+ 'get'=> proc{@obj.cget('autoseparators')},
2912
+ 'set'=> proc{|r| @obj.configure('autoseparators'=>r)},
2913
+ 'def'=> "",
2914
+ 'type'=> TkType::TkagBool
2915
+ )
2916
+
2917
+ publish('property','name'=>'undo',
2918
+ 'get'=> proc{@obj.cget('undo')},
2919
+ 'set'=> proc{|r| @obj.configure('undo'=>r)},
2920
+ 'def'=> "",
2921
+ 'type'=> TkType::TkagBool
2922
+ )
2923
+
2924
+
2925
+ publish_mod('place','name'=>'width','default'=> 100)
2926
+ publish('property',TkProperties::yscrollcommand(@obj))
2927
+ publish('property',TkProperties::xscrollcommand(@obj))
2928
+
2929
+ # publish('property',TkProperties::container(@obj))
2930
+ publish('property',TkProperties::borderwidth(@obj))
2931
+ publish('property',TkProperties::cursor(@obj))
2932
+ publish('property',TkProperties::font(@obj))
2933
+ publish('property',TkProperties::foreground(@obj))
2934
+ publish('property',TkProperties::highlightbackground(@obj))
2935
+ publish('property',TkProperties::highlightcolor(@obj))
2936
+ publish('property',TkProperties::highlightthickness(@obj))
2937
+
2938
+ publish('property',TkProperties::generic_color('insertbackground', @obj))
2939
+ publish('property',TkProperties::generic_color('selectbackground', @obj))
2940
+ publish('property',TkProperties::generic_color('selectforeground', @obj))
2941
+
2942
+ publish('property',TkProperties::property('insertborderwidth', @obj))
2943
+ publish('property',TkProperties::property('insertofftime', @obj))
2944
+ publish('property',TkProperties::property('insertontime', @obj))
2945
+ publish('property',TkProperties::property('insertwidth', @obj))
2946
+ publish('property',TkProperties::property('selectborderwidth', @obj))
2947
+ publish('property',TkProperties::property('maxundo', @obj))
2948
+ publish('property',TkProperties::property('spacing1', @obj))
2949
+ publish('property',TkProperties::property('spacing2', @obj))
2950
+ publish('property',TkProperties::property('spacing3', @obj))
2951
+ publish('property',TkProperties::property('tabs', @obj))
2952
+
2953
+ publish('property',TkProperties::relief(@obj))
2954
+ publish('property',TkProperties::takefocus(@obj))
2955
+ publish('property',TkProperties::padx(@obj))
2956
+ publish('property',TkProperties::pady(@obj))
2957
+ publish('property',TkProperties::height(@obj))
2958
+ publish('property',TkProperties::width(@obj))
2959
+ publish('property',TkProperties::state(@obj))
2960
+
2961
+ publish('property','name'=>'wrap',
2962
+ 'get'=> proc{@obj.cget('wrap')},
2963
+ 'set'=> proc{|r| @obj.configure('wrap'=>r)},
2964
+ 'def'=> "",
2965
+ 'type'=> EnumType.new('none', 'char', 'word')
2966
+ )
2967
+
2968
+
2969
+ end
2970
+ end
2971
+
2972
+ class AGTkScrollbar < AGTkBase
2973
+
2974
+ def AGTkScrollbar.class_wrapped
2975
+ TkScrollbar
2976
+ end
2977
+
2978
+ def properties
2979
+ super()
2980
+ publish('property','name'=>'relief',
2981
+ 'get'=> proc{@obj.cget('relief')},
2982
+ 'set'=> proc{|r| @obj.configure('relief'=>r)},
2983
+ 'def'=> "",
2984
+ 'type'=> TkType::TkagRelief
2985
+ )
2986
+ publish('property','name'=>'orient',
2987
+ 'get'=> proc{@obj.cget('orient')},
2988
+ 'set'=> proc{|o| @obj.configure('orient'=>o)},
2989
+ 'def'=> "",
2990
+ 'type'=> TkType::TkagOrient
2991
+ )
2992
+ end
2993
+ end
2994
+
2995
+ class AGTkMenuButton < AGTkButton
2996
+
2997
+ def new_object
2998
+ @obj = TkMenuButton.new(@ag_parent.obj)
2999
+ end
3000
+
3001
+ def AGTkMenuButton.class_wrapped
3002
+ TkMenuButton
3003
+ end
3004
+
3005
+ def properties
3006
+ super()
3007
+ end
3008
+
3009
+ end
3010
+
3011
+
3012
+ class AGTkMenu < AG
3013
+
3014
+ def new_object
3015
+ if @ag_parent.obj.class == TkMenubar
3016
+ @obj=@ag_parent.obj.add_menu(['asdasd',0])
3017
+ $arcadia.outln(@obj.to_s)
3018
+ end
3019
+ end
3020
+
3021
+ def AGTkMenu.class_wrapped
3022
+ TkMenu
3023
+ end
3024
+
3025
+ def properties
3026
+ super()
3027
+ end
3028
+
3029
+ end
3030
+
3031
+ class AGTkMenubar < AGTkContainer
3032
+
3033
+ def new_object
3034
+ @obj = TkMenubar.new(@ag_parent.obj)
3035
+ end
3036
+
3037
+ def AGTkMenubar.class_wrapped
3038
+ TkMenubar
3039
+ end
3040
+
3041
+ def properties
3042
+ super()
3043
+ end
3044
+
3045
+ end
3046
+
3047
+ class AGTkScale < AGTkBase
3048
+ def AGTkScale.class_wrapped
3049
+ TkScale
3050
+ end
3051
+
3052
+ def properties
3053
+ super
3054
+ publish('property',TkProperties::activebackground(@obj))
3055
+ publish('property',TkProperties::borderwidth(@obj))
3056
+ publish('property',TkProperties::relief(@obj))
3057
+ publish('property',TkProperties::orient(@obj))
3058
+ end
3059
+ end
3060
+
3061
+ class ArcadiaLibTk < ArcadiaLib
3062
+ def register_classes
3063
+ self.add_class(AGTkToplevel,true)
3064
+ self.add_class(AGTkFrame)
3065
+ self.add_class(AGTkLabelFrame)
3066
+ self.add_class(AGTkText)
3067
+ self.add_class(AGTkLabel)
3068
+ self.add_class(AGTkButton)
3069
+ self.add_class(AGTkCheckButton)
3070
+ self.add_class(AGTkListbox)
3071
+ self.add_class(AGTkEntry)
3072
+ self.add_class(AGTkScrollbar)
3073
+ self.add_class(AGTkScale)
3074
+ self.add_class(AGTkMenubar)
3075
+ self.add_class(AGTkMenu)
3076
+ self.add_class(AGTkMenuButton)
3077
+ end
3078
+ end