arcadia 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/README +69 -77
  2. data/arcadia.rb +1097 -770
  3. data/base/a-commons.rb +480 -0
  4. data/base/a-contracts.rb +207 -322
  5. data/base/{a-utils.rb → a-tkcommons.rb} +933 -993
  6. data/conf/arcadia.conf +130 -203
  7. data/conf/arcadia.res.rb +1332 -1325
  8. data/ext/ae-action-dispatcher/ae-action-dispatcher.conf +6 -0
  9. data/ext/ae-action-dispatcher/ae-action-dispatcher.rb +22 -0
  10. data/ext/ae-complete-code/ae-complete-code.conf +2 -2
  11. data/ext/ae-complete-code/ae-complete-code.rb +82 -80
  12. data/ext/ae-doc-code/ae-doc-code.conf +2 -2
  13. data/ext/ae-doc-code/ae-doc-code.rb +114 -111
  14. data/ext/ae-editor/ae-editor.conf +110 -105
  15. data/ext/ae-editor/ae-editor.rb +2501 -2287
  16. data/ext/ae-editor/langs/conf.lang +15 -0
  17. data/ext/ae-editor/langs/lang.lang.bind +1 -0
  18. data/ext/ae-editor/langs/rb.lang +67 -0
  19. data/ext/ae-editor/langs/rbw.lang.bind +1 -0
  20. data/ext/ae-event-log/ae-event-log.rb +45 -52
  21. data/ext/ae-file-history/ae-file-history.conf +4 -4
  22. data/ext/ae-file-history/ae-file-history.rb +298 -286
  23. data/ext/ae-flag/ae-flag.conf +6 -6
  24. data/ext/ae-flag/ae-flag.rb +12 -12
  25. data/ext/ae-inspector/ae-inspector.conf +3 -3
  26. data/ext/ae-inspector/ae-inspector.rb +2 -2
  27. data/ext/ae-output-event/ae-output-event.conf +15 -15
  28. data/ext/ae-output/ae-output.conf +5 -3
  29. data/ext/ae-output/ae-output.rb +62 -33
  30. data/ext/ae-palette/ae-palette.conf +3 -3
  31. data/ext/ae-palette/ae-palette.rb +265 -306
  32. data/ext/ae-rad/ae-rad-inspector.rb +1534 -0
  33. data/{base/a-libs.rb → ext/ae-rad/ae-rad-libs.rb} +1118 -846
  34. data/ext/ae-rad/ae-rad-palette.rb +273 -0
  35. data/ext/ae-rad/ae-rad.conf +71 -0
  36. data/ext/ae-rad/ae-rad.rb +56 -0
  37. data/{lib → ext/ae-rad/lib}/tk/al-tk.rb +21 -110
  38. data/{lib → ext/ae-rad/lib}/tk/al-tk.res.rb +0 -0
  39. data/{lib → ext/ae-rad/lib}/tk/al-tkarcadia.rb +26 -26
  40. data/{lib → ext/ae-rad/lib}/tk/al-tkcustom.rb +70 -70
  41. data/{lib → ext/ae-rad/lib}/tkext/al-bwidget.rb +194 -194
  42. data/{lib → ext/ae-rad/lib}/tkext/al-iwidgets.rb +25 -25
  43. data/{lib → ext/ae-rad/lib}/tkext/al-tile.rb +173 -173
  44. data/{lib → ext/ae-rad/lib}/tkext/al-tktable.rb +0 -0
  45. data/ext/ae-ruby-debug/ae-ruby-debug.conf +7 -4
  46. data/ext/ae-ruby-debug/ae-ruby-debug.rb +278 -142
  47. data/ext/ae-search-in-files/ae-search-in-files.conf +15 -0
  48. data/ext/ae-search-in-files/ae-search-in-files.rb +284 -0
  49. data/ext/ae-shell/ae-shell.rb +88 -8
  50. data/ext/ae-shell/sh.rb +7 -0
  51. metadata +93 -79
  52. data/base/a-contracts-work.rb +0 -219
  53. data/base/a-ext.rb +0 -280
  54. data/ext/ae-debug/ae-debug.conf +0 -7
  55. data/ext/ae-debug/ae-debug.rb +0 -601
  56. data/ext/ae-debug/debug1.57.rb +0 -998
@@ -1,993 +1,933 @@
1
- #
2
- # a-utils.rb - Arcadia Ruby ide
3
- # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
- #
5
-
6
- require 'lib/tk/al-tk'
7
-
8
- class AGTkSplittedFrames < TkFrame
9
- def initialize(parent=nil, length=10, keys=nil)
10
- super(parent, keys)
11
- @parent = parent
12
- @slen = 5
13
- relief 'groove'
14
- end
15
-
16
- def maximize(_frame)
17
- p = TkWinfo.parent(@parent)
18
- if p.kind_of?(AGTkSplittedFrames)
19
- p.maximize(@parent)
20
- end
21
- end
22
-
23
- def minimize(_frame)
24
- p = TkWinfo.parent(@parent)
25
- if p.kind_of?(AGTkSplittedFrames)
26
- p.minimize(@parent)
27
- end
28
- end
29
-
30
- end
31
-
32
-
33
- class AGTkVSplittedFrames < AGTkSplittedFrames
34
- attr_reader :left_frame, :right_frame
35
- def initialize(parent=nil, width=10, keys=nil)
36
- super(parent, width, keys)
37
-
38
- self.pack(:expand=>true, :fill=>:both)
39
- @left_frame = TkFrame.new(self){
40
- relief 'flat'
41
- }
42
- x = width
43
- @left_frame.place(
44
- 'relx' => 0,
45
- 'x' => 0,
46
- 'y' => '0',
47
- 'relheight' => '1',
48
- 'rely' => 0,
49
- 'bordermode' => 'inside',
50
- 'width' => x
51
- )
52
- @left_frame_obj = AGTkObjPlace.new(@left_frame, 'x', nil, false)
53
- @left_frame_obj.width = x
54
- @left_frame_obj.height = 0
55
- @left_frame_obj.relwidth = 0
56
- @left_frame_obj.relheight = 1
57
-
58
- @splitter_frame = TkFrame.new(self){
59
- relief 'raised'
60
- border 1
61
- }
62
-
63
- @splitter_frame.place(
64
- 'relx' => 0,
65
- 'x' => x,
66
- 'y' => '0',
67
- 'relheight' => '1',
68
- 'rely' => 0,
69
- 'bordermode' => 'inside',
70
- 'width' => @slen
71
- )
72
- @splitter_frame.bind_append(
73
- "ButtonRelease-1",
74
- proc{do_resize}
75
- )
76
- _self = self
77
- @b_left = TkButton.new{
78
- image TkPhotoImage.new('dat'=>LEFT_SIDE_GIF)
79
- }
80
-
81
- @b_right = TkButton.new{
82
- image TkPhotoImage.new('dat'=>RIGHT_SIDE_GIF)
83
- }
84
- @proc_unplace = proc{
85
- @b_left.unplace
86
- @b_right.unplace
87
- }
88
- @splitter_frame.bind_append(
89
- "B1-Motion",
90
- proc{@splitter_frame.raise;@proc_unplace.call}
91
- )
92
- @@last_b_left = nil
93
- @@last_b_right = nil
94
- @b_left.bind_append('ButtonPress-1',proc{_self.hide_left;@proc_unplace.call})
95
- @b_right.bind_append('ButtonPress-1',proc{_self.hide_right;@proc_unplace.call})
96
- @proc_place = proc{|x,y|
97
- if !TkWinfo.mapped?(@b_left)
98
- _x = TkWinfo.pointerx(self) - 10
99
- _y = TkWinfo.pointery(self) - 20
100
- if @@last_b_left != nil
101
- @@last_b_left.unplace
102
- @@last_b_right.unplace
103
- end
104
- @b_left.place('x'=>_x,'y'=>_y,'border'=>'outside')
105
- @b_right.place('x'=>_x,'y'=>_y+25,'border'=>'outside')
106
- @b_left.raise
107
- @b_right.raise
108
- @@last_b_left = @b_left
109
- @@last_b_right = @b_right
110
- if @thread_unplace
111
- @thread_unplace.kill
112
- end
113
- @thread_unplace= Thread.new {
114
- sleep(5)
115
- @proc_unplace.call
116
- kill
117
- }
118
- end
119
- }
120
-
121
- @splitter_frame.bind_append(
122
- 'ButtonPress-1',
123
- proc{|x,y|
124
- @thread_place= Thread.new {
125
- @proc_place.call(x,y)
126
- }
127
- }, "%x %y")
128
-
129
- @splitter_frame.bind_append(
130
- "Enter",
131
- proc{
132
- @color_save = @splitter_frame.background
133
- @splitter_frame.background('#9aa6a7')}
134
- )
135
- @splitter_frame.bind_append(
136
- "Leave",
137
- proc{
138
- @splitter_frame.background(@color_save)
139
- }
140
- )
141
- @splitter_frame_obj = AGTkObjPlace.new(@splitter_frame, 'x')
142
- @splitter_frame_obj.width = @slen
143
- @splitter_frame_obj.height = 0
144
- @splitter_frame_obj.relwidth = 0
145
- @splitter_frame_obj.relheight = 1
146
- x = x + @slen
147
- @right_frame = TkFrame.new(self){
148
- relief 'flat'
149
- }
150
- @right_frame.place(
151
- 'relwidth' => 1,
152
- 'relx' => 0,
153
- 'x' => x,
154
- 'y' => 0,
155
- 'width' => -x,
156
- 'relheight' => 1,
157
- 'rely' => 0,
158
- 'bordermode' => 'inside'
159
- )
160
- @right_frame_obj = AGTkObjPlace.new(@right_frame, 'x', nil, false)
161
- @right_frame_obj.width = -x
162
- @right_frame_obj.height = 0
163
- @right_frame_obj.relwidth = 1
164
- @right_frame_obj.relheight = 1
165
- @state = 'middle'
166
- yield(self) if block_given?
167
- end
168
-
169
- def get_main_x
170
- if TkWinfo.manager(@parent)=='place'
171
- return TkPlace.info(@parent)['x'] / 2
172
- else
173
- return 20
174
- end
175
- end
176
-
177
- def do_resize
178
- _x = @splitter_frame_obj.x0
179
- _w = @splitter_frame_obj.w
180
- @left_frame_obj.width = _x
181
- @left_frame_obj.go(_x,0)
182
- @right_frame_obj.width = - _x - _w
183
- @right_frame_obj.amove(_x + _w,0)
184
- end
185
-
186
- def hide_left
187
- if (@state=='left')
188
- _w = @last
189
- @state = 'middle'
190
- @left_frame_obj.width = _w
191
- @left_frame_obj.go(_w,0)
192
- else
193
- _w = 0
194
- @state = 'right'
195
- @last = @left_frame_obj.w
196
- end
197
- @left_frame_obj.amove(0,0)
198
- @splitter_frame_obj.amove(_w,0)
199
- @right_frame_obj.width = - _w - @slen
200
- @right_frame_obj.amove(_w + @slen,0)
201
- end
202
-
203
- def hide_right
204
- if (@state=='right')
205
- _w = @last
206
- @state = 'middle'
207
- else
208
- _w = @right_frame_obj.w + @left_frame_obj.w #+ @slen
209
- @state = 'left'
210
- @last = @left_frame_obj.w
211
- end
212
- @right_frame_obj.width = - _w - @slen
213
- @right_frame_obj.amove(_w + @slen,0)
214
- @splitter_frame_obj.amove(_w,0)
215
- @left_frame_obj.width = _w
216
- @left_frame_obj.go(_w,0)
217
- end
218
-
219
- def maximize(_frame)
220
- super(_frame)
221
- case _frame
222
- when left_frame
223
- hide_right
224
- when right_frame
225
- hide_left
226
- end
227
- Tk.update
228
- end
229
-
230
- def minimize(_frame)
231
- super(_frame)
232
- case _frame
233
- when left_frame
234
- hide_left
235
- when right_frame
236
- hide_right
237
- end
238
- Tk.update
239
- end
240
-
241
- def hide(_name)
242
- end
243
-
244
- def show(_name)
245
- end
246
-
247
- end
248
-
249
- class AGTkOSplittedFrames < AGTkSplittedFrames
250
- attr_reader :top_frame, :bottom_frame
251
- def initialize(parent=nil, height=10, perc=false,keys=nil)
252
- super(parent, height, keys)
253
- self.place(
254
- 'relwidth' => 1,
255
- 'relx' => 0,
256
- 'x' => 0,
257
- 'y' => 0,
258
- 'relheight' => 1,
259
- 'rely' => 0,
260
- 'bordermode' => 'inside'
261
- )
262
- @top_frame = TkFrame.new(self){
263
- relief 'flat'
264
- }
265
- if perc
266
- p_height = TkWinfo.screenheight(self)
267
- y = (p_height/100*height).to_i
268
- else
269
- y = height
270
- end
271
- @top_frame.place(
272
- 'relwidth' => '1',
273
- 'bordermode' => 'inside',
274
- 'height' => y
275
- )
276
- @top_frame_obj = AGTkObjPlace.new(@top_frame, 'y', nil, false)
277
- @top_frame_obj.width = 0
278
- @top_frame_obj.height = y
279
- @top_frame_obj.relwidth = 1
280
- @top_frame_obj.relheight = 0
281
- @splitter_frame = TkFrame.new(self){
282
- relief 'groove'
283
- border 1
284
- }
285
- @splitter_frame.place(
286
- 'relx' => 0,
287
- 'x' => 0,
288
- 'y' => y,
289
- 'relwidth' => '1',
290
- 'rely' => 0,
291
- 'bordermode' => 'inside',
292
- 'height' => @slen
293
- )
294
- @splitter_frame.bind_append(
295
- "B1-Motion",
296
- proc{@splitter_frame.raise}
297
- )
298
- @splitter_frame.bind_append(
299
- "ButtonRelease-1",
300
- proc{do_resize}
301
- )
302
- @splitter_frame_obj = AGTkObjPlace.new(@splitter_frame, 'y')
303
- @splitter_frame_obj.width = 0
304
- @splitter_frame_obj.height = @slen
305
- @splitter_frame_obj.relwidth = 1
306
- @splitter_frame_obj.relheight = 0
307
- y = y + @slen
308
- @bottom_frame = TkFrame.new(self){
309
- relief 'flat'
310
- }
311
- @bottom_frame.place(
312
- 'relwidth' => 1,
313
- 'relx' => 0,
314
- 'x' => 0,
315
- 'y' => y,
316
- 'height' => -y,
317
- 'relheight' => 1,
318
- 'rely' => 0,
319
- 'bordermode' => 'inside'
320
- )
321
- @bottom_frame_obj = AGTkObjPlace.new(@bottom_frame, 'y', nil, false)
322
- @bottom_frame_obj.width = 0
323
- @bottom_frame_obj.height = -y
324
- @bottom_frame_obj.relwidth = 1
325
- @bottom_frame_obj.relheight = 1
326
- _xbutton = TkButton.new(@splitter_frame){
327
- background '#4966d7'
328
- overrelief 'raised'
329
- relief 'flat'
330
- }
331
- _xbutton.place(
332
- 'x' => 0,
333
- 'y' => 0,
334
- 'relheight' => 1,
335
- 'bordermode' => 'outside',
336
- 'width' => 20
337
- )
338
- _xbutton.bind_append(
339
- "ButtonPress-1",
340
- proc{hide_top}
341
- )
342
- _ybutton = TkButton.new(@splitter_frame){
343
- background '#118124'
344
- overrelief 'raised'
345
- relief 'flat'
346
- }
347
- _ybutton.place(
348
- 'x' => 21,
349
- 'y' => 0,
350
- 'bordermode' => 'outside',
351
- 'width' => 20,
352
- 'relheight' => 1
353
- )
354
- _ybutton.bind_append(
355
- "ButtonPress-1",
356
- proc{hide_bottom}
357
- )
358
- @state = 'middle'
359
- yield(self) if block_given?
360
- end
361
-
362
- def hide_top
363
- if (@state=='top')
364
- _h = @last
365
- @state = 'middle'
366
- @top_frame_obj.height = _h
367
- @top_frame_obj.go(0,_h)
368
- elsif (@state=='bottom')
369
- return
370
- else
371
- _h = 0
372
- @state = 'bottom'
373
- @last = @top_frame_obj.h
374
- end
375
- @top_frame_obj.amove(0,0)
376
- @splitter_frame_obj.amove(0, _h)
377
- @bottom_frame_obj.height = - _h - @slen
378
- @bottom_frame_obj.amove(0,_h + @slen)
379
- end
380
-
381
- def hide_bottom
382
- if (@state=='bottom')
383
- _h = @last
384
- @state = 'middle'
385
- elsif (@state == 'top')
386
- return
387
- else
388
- _h = @bottom_frame_obj.h + @top_frame_obj.h #+ @slen
389
- @state = 'top'
390
- @last = @top_frame_obj.h #+ @slen
391
- end
392
- @bottom_frame_obj.height = - _h - @slen
393
- @bottom_frame_obj.amove(0,_h + @slen)
394
- @splitter_frame_obj.amove(0,_h)
395
- @top_frame_obj.height = _h
396
- @top_frame_obj.go(0,_h)
397
- end
398
-
399
-
400
- def maximize(_frame)
401
- super(_frame)
402
- case _frame
403
- when top_frame
404
- hide_bottom
405
- when bottom_frame
406
- hide_top
407
- end
408
- Tk.update
409
- end
410
-
411
- def minimize(_frame)
412
- super(_frame)
413
- case _frame
414
- when top_frame
415
- hide_top
416
- when bottom_frame
417
- hide_bottom
418
- end
419
- Tk.update
420
- end
421
-
422
-
423
- def get_main_y
424
- return 40
425
- end
426
-
427
- def do_resize
428
- _y = @splitter_frame_obj.y0
429
- _h = @splitter_frame_obj.h
430
- @top_frame_obj.height = _y
431
- @top_frame_obj.go(0,_y)
432
- @bottom_frame_obj.height = -_y-_h
433
- @bottom_frame_obj.amove(0,_y + _h)
434
- #end
435
- end
436
-
437
- def hide(_name)
438
- end
439
-
440
- def show(_name)
441
- end
442
-
443
- end
444
-
445
- class TkBaseTitledFrame < TkFrame
446
- attr_reader :frame
447
- attr_reader :top
448
-
449
- def initialize(parent=nil, *args)
450
- super(parent, *args)
451
- @parent = parent
452
- @title_height = 18
453
- @top = TkFrame.new(self){
454
- background '#303b50'
455
- #foreground 'white'
456
- #anchor 'w'
457
- }.place('x'=>0, 'y'=>0,'height'=>@title_height, 'relwidth'=>1)
458
- #.pack('fill'=> 'x','ipady'=> @title_height, 'side'=>'top')
459
-
460
-
461
- @frame = create_frame
462
-
463
-
464
-
465
- @button_frame=TkFrame.new(@top){
466
- #background '#303b50'
467
- }.pack('side'=> 'right','anchor'=> 'w')
468
-
469
- self.head_buttons
470
- end
471
-
472
- def create_frame
473
- return TkFrame.new(self).place('x'=>0, 'y'=>@title_height,'height'=>-@title_height,'relheight'=>1, 'relwidth'=>1)
474
- #pack('fill'=>'both','expand'=> 1, 'anchor'=>'center')
475
- #
476
- end
477
-
478
- def add_button(_label,_proc=nil,_image=nil, _side= 'right')
479
- TkButton.new(@button_frame){
480
- text _label if _label
481
- image TkPhotoImage.new('dat' => _image) if _image
482
- relief 'flat'
483
- font 'helvetica 8 bold'
484
- #borderwidth 0
485
- #background '#303b50'
486
- #background '#8080ff'
487
- pack('side'=> _side,'anchor'=> 'e')
488
- bind('1',_proc) if _proc
489
- }
490
- end
491
-
492
- def head_buttons
493
- @bmaxmin = add_button('[ ]',proc{resize}, W_MAX_GIF)
494
- end
495
-
496
- end
497
-
498
-
499
-
500
- class TkTitledFrame < TkBaseTitledFrame
501
- attr_reader :frame
502
- attr_reader :top
503
-
504
- def initialize(parent=nil, title='...', img=nil , keys=nil)
505
- super(parent, keys)
506
- @state = 'normal'
507
- @title_label =TkLabel.new(@top){
508
- text title+' :: '
509
- anchor 'w'
510
- font $arcadia['conf']['all.frame.title.font']
511
- background '#303b50'
512
- foreground '#e8e651'
513
- compound 'left'
514
- image TkAllPhotoImage.new('file' => img) if img
515
- pack('side'=> 'left','anchor'=> 'e')
516
- }
517
- @top_label =TkLabel.new(@top){
518
- anchor 'w'
519
- font $arcadia['conf']['all.frame.title.font.italic']
520
- background '#303b50'
521
- foreground '#FFFFFF'
522
- compound 'left'
523
- pack('side'=> 'left','anchor'=> 'e')
524
- }
525
-
526
- @ap = Array.new
527
- @apx = Array.new
528
- @apy = Array.new
529
- @apw = Array.new
530
- @aph = Array.new
531
- end
532
-
533
- def top_text(_text)
534
- @top_label.text(_text)
535
- end
536
-
537
- def title(_text)
538
- @title_label.text(_text+'::')
539
- end
540
-
541
-
542
- def add_sep(_width=0,_background =@top.background)
543
- TkLabel.new(@top){||
544
- text ''
545
- background _background
546
- pack('side'=> 'right','anchor'=> 'e', 'ipadx'=>_width)
547
- }
548
- end
549
-
550
-
551
- def head_buttons
552
- @bmaxmin = add_button('[ ]',proc{resize}, W_MAX_GIF)
553
- #@bmaxmin = add_button('[ ]',proc{resize}, EXPAND_GIF)
554
- end
555
-
556
- def resize
557
- p = TkWinfo.parent(@parent)
558
- if @state == 'normal'
559
- if p.kind_of?(AGTkSplittedFrames)
560
- p.maximize(@parent)
561
- @bmaxmin.image(TkPhotoImage.new('dat' => W_NORM_GIF))
562
- end
563
- @state = 'maximize'
564
- else
565
- if p.kind_of?(AGTkSplittedFrames)
566
- p.minimize(@parent)
567
- @bmaxmin.image(TkPhotoImage.new('dat' =>W_MAX_GIF))
568
- end
569
- @state = 'normal'
570
- end
571
- self.raise
572
- end
573
-
574
- def maximize
575
- if @state == 'normal'
576
- p = TkWinfo.parent(self)
577
- while (p != nil) && (TkWinfo.manager(p)=='place')
578
- Tk.messageBox('message'=>p.to_s)
579
- @ap << p
580
- @apx << TkPlace.info(p)['x']
581
- @apy << TkPlace.info(p)['y']
582
- @apw << TkPlace.info(p)['width']
583
- @aph << TkPlace.info(p)['height']
584
- p.place('x'=>0, 'y'=>0,'relheight'=>1, 'relwidth'=>1)
585
- p.raise
586
- p = TkWinfo.parent(p)
587
- end
588
- @state = 'maximize'
589
- self.raise
590
- else
591
- @ap.each_index{|i|
592
- @ap[i].place('x'=>@apx[i], 'y'=>@apy[i],'width'=>@apw[i], 'height'=>@aph[i],'relheight'=>1, 'relwidth'=>1)
593
- @ap[i].raise
594
- }
595
- self.raise
596
- @ap.clear
597
- @apx.clear
598
- @apy.clear
599
- @state = 'normal'
600
- end
601
- end
602
- end
603
-
604
- class TkTitledScrollFrame < TkTitledFrame
605
-
606
- def create_frame
607
- return Tk::ScrollFrame.new(self,:scrollbarwidth=>10, :width=>300, :height=>200).place('x'=>0, 'y'=>@title_height,'height'=>-@title_height,'relheight'=>1, 'relwidth'=>1)
608
- end
609
-
610
- end
611
-
612
-
613
-
614
- class Application
615
- ApplicationParams = Struct.new( "ApplicationParams",
616
- :name,
617
- :version,
618
- :config_file,
619
- :persistent_file
620
- )
621
-
622
- def initialize(_ap=ApplicationParams.new)
623
- @@instance = self
624
- eval('$'+_ap.name+'=self')
625
- publish('applicationParams', _ap)
626
- publish(_ap.name,self)
627
- @first_run = false
628
- init_config
629
- yield(self) if block_given?
630
- end
631
-
632
- def Application.instance
633
- @@instance
634
- end
635
-
636
- def init_config
637
- self['applicationParams'].persistent_file = File.join(local_dir, self['applicationParams'].name+'.pers')
638
- if !File.exists?(self['applicationParams'].persistent_file)
639
- File.new(self['applicationParams'].persistent_file, File::CREAT).close
640
- end
641
- publish('conf', config_file2hash(self['applicationParams'].config_file)) if self['applicationParams'].config_file
642
- publish('pers', config_file2hash(self['applicationParams'].persistent_file)) if self['applicationParams'].persistent_file
643
- end
644
-
645
- def prepare
646
- end
647
-
648
- def publish(_name, _obj)
649
- @objs = Hash.new if !defined?(@objs)
650
- @objs[_name] = _obj
651
- end
652
-
653
- # this method load arcadia.conf from local directory for personalizations
654
- def load_local_config(_create_if_not_exist=true)
655
- local_file_config = File.join(local_dir,File.basename(self['applicationParams'].config_file))
656
- if FileTest.exist?(local_file_config)
657
- self['conf'].update(self.config_file2hash(local_file_config))
658
- elsif _create_if_not_exist
659
- if FileTest.writable?(local_dir)
660
- f = File.new(local_file_config, "w")
661
- begin
662
- if f
663
- p = self['conf']
664
- if p
665
- p.keys.sort.each{|key|
666
- f.syswrite('#'+key+'='+self['conf'][key]+"\n")
667
- }
668
- end
669
- end
670
- ensure
671
- f.close unless f.nil?
672
- end
673
- else
674
- msg = "Locad dir "+'"'+local_dir+'"'+" must be writable!"
675
- Tk.messageBox('icon' => 'error', 'type' => 'ok',
676
- 'title' => '(Arcadia)',
677
- 'message' => msg)
678
- exit
679
-
680
- end
681
- end
682
- end
683
-
684
- def local_dir
685
- _local_dir = File.join(ENV["HOME"],'.'+self['applicationParams'].name) if ENV["HOME"]
686
- if _local_dir && !File.exist?(_local_dir)
687
- if FileTest.exist?(ENV["HOME"])
688
- Dir.mkdir(_local_dir)
689
- @first_run = true
690
- else
691
- msg = "Locad dir "+'"'+ENV["HOME"]+'"'+" must be writable!"
692
- Tk.messageBox('icon' => 'error', 'type' => 'ok',
693
- 'title' => '(Arcadia)',
694
- 'message' => msg)
695
- exit
696
- end
697
- end
698
- return _local_dir
699
- end
700
-
701
- def load_config(_config_file)
702
- if _config_file && FileTest::exist?(_config_file)
703
- f = File::open(_config_file,'r')
704
- begin
705
- _lines = f.readlines
706
- _lines.each{|_line|
707
- _strip_line = _line.strip
708
- if (_strip_line.length > 0)&&(_strip_line[0,1]!='#')
709
- var_plat = _line.split('::')
710
- if var_plat.length > 1
711
- if (RUBY_PLATFORM.include?(var_plat[0]))
712
- #if (var_plat[0] == RUBY_PLATFORM)
713
- _line = var_plat[1]
714
- else
715
- _line = ''
716
- end
717
- end
718
- var = _line.split('=')
719
- if var.length > 1
720
- self['conf'][var[0].strip]=var[1].strip
721
- end
722
- end
723
- }
724
- ensure
725
- f.close unless f.nil?
726
- end
727
- end
728
- end
729
-
730
- def config_file2hash(_config_file)
731
- r_hash = Hash.new
732
- if _config_file && FileTest::exist?(_config_file)
733
- f = File::open(_config_file,'r')
734
- begin
735
- _lines = f.readlines
736
- _lines.each{|_line|
737
- _strip_line = _line.strip
738
- if (_strip_line.length > 0)&&(_strip_line[0,1]!='#')
739
- var_plat = _line.split('::')
740
- if var_plat.length > 1
741
- if (RUBY_PLATFORM.include?(var_plat[0]))
742
- #if (var_plat[0] == RUBY_PLATFORM)
743
- _line = var_plat[1]
744
- else
745
- _line = ''
746
- end
747
- end
748
- var = _line.split('=')
749
- if var.length > 1
750
- r_hash[var[0].strip]=var[1].strip
751
- end
752
- end
753
- }
754
- ensure
755
- f.close unless f.nil?
756
- end
757
- return r_hash
758
- end
759
- end
760
-
761
-
762
- def load_persist(_persist_file)
763
- if _persist_file && !FileTest::exist?(_persist_file)
764
- Dir.mkdir(File.dirname(_persist_file)) unless File.exists?(File.dirname(_persist_file))
765
- File.new(_persist_file, File::CREAT)
766
- end
767
-
768
- if _persist_file && FileTest::exist?(_persist_file)
769
- f = File::open(_persist_file,'r')
770
- begin
771
- _lines = f.readlines
772
- _lines.each{|_line|
773
- _strip_line = _line.strip
774
- if (_strip_line.length > 0)&&(_strip_line[0,1]!='#')
775
- var = _line.split('=')
776
- if var.length > 1
777
- self['pers'][var[0].strip]=var[1].strip
778
- end
779
- end
780
- }
781
- ensure
782
- f.close unless f.nil?
783
- end
784
- end
785
- end
786
-
787
- def write_persist
788
- if FileTest::exist?(self['applicationParams'].persistent_file)
789
- f = File.new(self['applicationParams'].persistent_file, "w")
790
- begin
791
- if f
792
- p = self['pers']
793
- if p
794
- p.each{|key,value|
795
- f.syswrite(key+'='+value+"\n")
796
- }
797
- end
798
- end
799
- ensure
800
- f.close unless f.nil?
801
- end
802
- end
803
- end
804
-
805
- def create(_name, _class)
806
- register(_name,_class.new)
807
- end
808
-
809
- def objects(_name)
810
- return @objs[_name]
811
- end
812
-
813
- def [](_name)
814
- if @objs[_name]
815
- return @objs[_name]
816
- else
817
- raise RuntimeError, "resurce '"+_name+"' unavabled ", caller
818
- end
819
- end
820
-
821
- def run
822
- end
823
- end
824
-
825
- class TkApplication < Application
826
- def run
827
- Tk.mainloop
828
- end
829
- end
830
-
831
- module TkMovable
832
- def start_moving(_moving_obj=self, _moved_obj=self)
833
- @x0 = 0
834
- @y0 = 0
835
- @moving_obj = _moving_obj
836
- @moved_obj = _moved_obj
837
- @moving_obj.bind_append("B1-Motion", proc{|x, y| moving_do_move_obj(x,y)},"%x %y")
838
- @moving_obj.bind_append("ButtonPress-1", proc{|e| moving_do_press(e.x, e.y)})
839
- end
840
-
841
- def stop_moving
842
- @moving_obj.bind_remove("B1-Motion")
843
- @moving_obj.bind_remove("ButtonPress-1")
844
- end
845
-
846
- def moving_do_press(_x, _y)
847
- @x0 = _x
848
- @y0 = _y
849
- end
850
-
851
- def moving_do_move_obj(_x, _y)
852
- _x = TkPlace.info(@moved_obj)['x'] + _x - @x0
853
- _y = TkPlace.info(@moved_obj)['y'] + _y - @y0
854
- @moved_obj.place('x'=>_x, 'y'=>_y)
855
- end
856
-
857
- end
858
-
859
- module TkResizabled
860
- MIN_WIDTH = 50
861
- MIN_HEIGHT = 50
862
- def start_resizing(_moving_obj=self, _moved_obj=self)
863
- @x0 = 0
864
- @y0 = 0
865
- @moving_obj = _moving_obj
866
- @moved_obj = _moved_obj
867
- @moving_obj.bind_append("B1-Motion", proc{|x, y| resizing_do_move_obj(x,y)},"%x %y")
868
- @moving_obj.bind_append("ButtonPress-1", proc{|e| resizing_do_press(e.x, e.y)})
869
- end
870
-
871
- def stop_resizing
872
- @moving_obj.bind_remove("B1-Motion")
873
- @moving_obj.bind_remove("ButtonPress-1")
874
- end
875
-
876
- def resizing_do_press(_x, _y)
877
- @x0 = _x
878
- @y0 = _y
879
- end
880
-
881
- def resizing_do_move_obj(_x, _y)
882
- _width0 = TkPlace.info(@moved_obj)['width']
883
- _height0 = TkPlace.info(@moved_obj)['height']
884
- _width = _width0 + _x - @x0
885
- _height = _height0 + _y -@y0
886
- _width = MIN_WIDTH if _width < MIN_WIDTH
887
- _height = MIN_HEIGHT if _height < MIN_HEIGHT
888
- @moved_obj.place('width'=>_width, 'height'=>_height)
889
- end
890
-
891
- end
892
-
893
-
894
- class TkFloatTitledFrame < TkBaseTitledFrame
895
- include TkMovable
896
- include TkResizabled
897
- def initialize(parent=nil, *args)
898
- super(parent)
899
- frame.place('height'=>-32)
900
- borderwidth 2
901
- relief 'groove'
902
-
903
- @top_label = TkLabel.new(@top){
904
- background '#303b50'
905
- foreground 'white'
906
- anchor 'w'
907
- }.pack('fill'=>'x', 'side'=>'top')
908
- #.place('x'=>0, 'y'=>0,'relheight'=>1, 'relwidth'=>1 ,'width'=>-20)
909
-
910
- @resizing_label=TkLabel.new(self){
911
- #background '#303b50'
912
- text '-'
913
- image TkPhotoImage.new('dat'=>EXPAND_LIGHT_GIF)
914
- }.pack('side'=> 'right','anchor'=> 's')
915
-
916
-
917
- start_moving(@top_label, self)
918
- start_resizing(@resizing_label, self)
919
- end
920
-
921
- def title(_text)
922
- @top_label.text(_text)
923
- end
924
-
925
-
926
- def on_close=(_proc)
927
- add_button('X', _proc, TAB_CLOSE_GIF)
928
- end
929
-
930
- def hide
931
- @manager = TkWinfo.manager(self)
932
- if @manager == 'place'
933
- @x_place = TkPlace.info(self)['x']
934
- @y_place = TkPlace.info(self)['y']
935
- @width_place = TkPlace.info(self)['width']
936
- @height_place = TkPlace.info(self)['height']
937
- self.unplace
938
- end
939
- end
940
-
941
- def show
942
- if @manager == 'place'
943
- self.place('x'=>@x_place, 'y'=>@y_place, 'width'=>@width_place, 'height'=>@height_place)
944
- end
945
- end
946
-
947
- def head_buttons
948
- end
949
-
950
- end
951
-
952
- class TkProgressframe < TkFloatTitledFrame
953
- def initialize(parent=nil, _max=100, *args)
954
- super(parent)
955
- @max = _max
956
- @progress = TkVariable.new
957
- @progress.value = -1
958
- Tk::BWidget::ProgressBar.new(self, :width=>150, :height=>10,
959
- :background=>'red',
960
- :foreground=>'blue',
961
- :variable=>@progress,
962
- :borderwidth=>0,
963
- :relief=>'flat',
964
- :maximum=>_max).place('width' => '150','x' => 25,'y' => 30,'height' => 15)
965
-
966
- @buttons_frame = TkFrame.new(self).pack('fill'=>'x', 'side'=>'bottom')
967
-
968
- @b_cancel = TkButton.new(@buttons_frame){|_b_go|
969
- default 'disabled'
970
- text 'Cancel'
971
- overrelief 'raised'
972
- justify 'center'
973
- pack('side'=>'top','ipadx'=>5, 'padx'=>5)
974
- }
975
-
976
- place('x'=>100,'y'=>100,'height'=> 120,'width'=> 200)
977
- end
978
-
979
- def quit
980
- #self.destroy
981
- end
982
-
983
- def progress(_incr=1)
984
- @progress.numeric += _incr
985
- end
986
-
987
- def on_cancel=(_proc)
988
- @b_cancel.bind_append('1', _proc)
989
- end
990
-
991
-
992
- end
993
-
1
+ #
2
+ # a-tkcommons.rb - Arcadia Ruby ide
3
+ # by Antonio Galeone <antonio-galeone@rubyforge.org>
4
+ #
5
+
6
+ require "base/a-commons"
7
+
8
+ class TkApplication < Application
9
+ def run
10
+ Tk.mainloop
11
+ end
12
+ end
13
+
14
+ module TkMovable
15
+ def start_moving(_moving_obj=self, _moved_obj=self)
16
+ @x0 = 0
17
+ @y0 = 0
18
+ @moving_obj = _moving_obj
19
+ @moved_obj = _moved_obj
20
+ @moving_obj.bind_append("B1-Motion", proc{|x, y| moving_do_move_obj(x,y)},"%x %y")
21
+ @moving_obj.bind_append("ButtonPress-1", proc{|e| moving_do_press(e.x, e.y)})
22
+ end
23
+
24
+ def stop_moving
25
+ @moving_obj.bind_remove("B1-Motion")
26
+ @moving_obj.bind_remove("ButtonPress-1")
27
+ end
28
+
29
+ def moving_do_press(_x, _y)
30
+ @x0 = _x
31
+ @y0 = _y
32
+ end
33
+
34
+ def moving_do_move_obj(_x, _y)
35
+ _x = TkPlace.info(@moved_obj)['x'] + _x - @x0
36
+ _y = TkPlace.info(@moved_obj)['y'] + _y - @y0
37
+ @moved_obj.place('x'=>_x, 'y'=>_y)
38
+ end
39
+
40
+ end
41
+
42
+ module TkResizable
43
+ MIN_WIDTH = 50
44
+ MIN_HEIGHT = 50
45
+ def start_resizing(_moving_obj=self, _moved_obj=self)
46
+ @x0 = 0
47
+ @y0 = 0
48
+ @moving_obj = _moving_obj
49
+ @moved_obj = _moved_obj
50
+ @moving_obj.bind_append("B1-Motion", proc{|x, y| resizing_do_move_obj(x,y)},"%x %y")
51
+ @moving_obj.bind_append("ButtonPress-1", proc{|e| resizing_do_press(e.x, e.y)})
52
+ end
53
+
54
+ def stop_resizing
55
+ @moving_obj.bind_remove("B1-Motion")
56
+ @moving_obj.bind_remove("ButtonPress-1")
57
+ end
58
+
59
+ def resizing_do_press(_x, _y)
60
+ @x0 = _x
61
+ @y0 = _y
62
+ end
63
+
64
+ def resizing_do_move_obj(_x, _y)
65
+ _width0 = TkPlace.info(@moved_obj)['width']
66
+ _height0 = TkPlace.info(@moved_obj)['height']
67
+ _width = _width0 + _x - @x0
68
+ _height = _height0 + _y -@y0
69
+ _width = MIN_WIDTH if _width < MIN_WIDTH
70
+ _height = MIN_HEIGHT if _height < MIN_HEIGHT
71
+ @moved_obj.place('width'=>_width, 'height'=>_height)
72
+ end
73
+
74
+ end
75
+
76
+
77
+ class AGTkObjPlace
78
+ attr_reader :obj, :r, :start_x, :start_y, :motion, :x0, :y0, :w0, :h0, :width,:height,:relwidth,:relheight
79
+ attr_writer :r, :start_x, :start_y, :motion,:width,:height,:relwidth,:relheight
80
+
81
+ def initialize(_obj=nil , _side='both' , _cursor=nil, _bind = true )
82
+ if !_obj
83
+ break
84
+ end
85
+ @obj = _obj
86
+ if !_cursor
87
+ case _side
88
+ when 'x'
89
+ _cursor = 'sb_h_double_arrow'
90
+ when 'y'
91
+ _cursor = 'sb_v_double_arrow'
92
+ when 'both'
93
+ _cursor = 'draft_small'
94
+ end
95
+ end
96
+ @motion = false
97
+ @side = _side
98
+ @x0 = TkPlace.info(@obj)['x']
99
+ @y0 = TkPlace.info(@obj)['y']
100
+ if TkWinfo.mapped?(@obj)
101
+ @w0=TkWinfo.width(@obj)
102
+ @h0=TkWinfo.height(@obj)
103
+ else
104
+ @w0=TkWinfo.reqwidth(@obj)
105
+ @h0=TkWinfo.reqheight(@obj)
106
+ end
107
+ @start_x = @x0
108
+ @start_y = @y0
109
+ @cursor = _cursor
110
+ if _bind
111
+ @obj.bind_append("Enter", proc{|x, y| do_enter(x, y)}, "%x %y")
112
+ @obj.bind_append("ButtonPress-1", proc{|e| do_press(e.x, e.y)})
113
+ @obj.bind_append("B1-Motion", proc{|x, y| do_motion(x,y)},"%x %y")
114
+ end
115
+ end
116
+
117
+ def w
118
+ if TkWinfo.mapped?(@obj)
119
+ @w0= TkWinfo.width(@obj)
120
+ else
121
+ @w0= TkWinfo.reqwidth(@obj)
122
+ end
123
+ end
124
+
125
+ def h
126
+ if TkWinfo.mapped?(@obj)
127
+ @h0= TkWinfo.height(@obj)
128
+ else
129
+ @h0= TkWinfo.reqheight(@obj)
130
+ end
131
+ end
132
+
133
+ def do_enter(x, y)
134
+ @oldcursor = @obj.cget('cursor')
135
+ @obj.configure('cursor'=> @cursor)
136
+ end
137
+
138
+ def do_leave
139
+ @obj.configure('cursor'=>@oldcursor)
140
+ end
141
+
142
+ def do_press(x, y)
143
+ @start_x = x
144
+ @start_y = y
145
+ end
146
+
147
+ def do_motion( _x, _y)
148
+ @motion = true
149
+ move(_x - @start_x, _y - @start_y)
150
+ end
151
+
152
+ def move(_x,_y)
153
+ case @side
154
+ when 'both'
155
+ @x0 = @x0 + _x if (@x0 + _x) >= 0
156
+ @y0 = @y0 + _y
157
+ @obj.place('x' => @x0, 'y' => @y0, 'width' => @width, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
158
+ when 'x'
159
+ @x0 = @x0 + _x if (@x0 + _x) >= 0
160
+ @obj.place('x' => @x0, 'width' => @width, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
161
+ when 'y'
162
+ @y0 = @y0 + _y
163
+ @obj.place('y' => @y0, 'width' => @width, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
164
+ end
165
+ end
166
+
167
+ def amove(_x,_y)
168
+ move(_x - @x0 , _y - @y0)
169
+ end
170
+
171
+ def go(_w, _h)
172
+ case @side
173
+ when 'x'
174
+ @w0 = _w
175
+ @obj.place('width' => @w0, 'height'=>@height, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
176
+ when 'y'
177
+ @h0 = _h
178
+ @obj.place('height' => @h0, 'width' => @width, 'relwidth'=>@relwidth, 'relheight'=>@relheight)
179
+ end
180
+ end
181
+
182
+ end
183
+
184
+
185
+ class AGTkSplittedFrames < TkFrame
186
+ def initialize(parent=nil, length=10, keys=nil)
187
+ super(parent, keys)
188
+ @parent = parent
189
+ @slen = 5
190
+ relief 'groove'
191
+ end
192
+
193
+ def maximize(_frame)
194
+ p = TkWinfo.parent(@parent)
195
+ if p.kind_of?(AGTkSplittedFrames)
196
+ p.maximize(@parent)
197
+ end
198
+ end
199
+
200
+ def minimize(_frame)
201
+ p = TkWinfo.parent(@parent)
202
+ if p.kind_of?(AGTkSplittedFrames)
203
+ p.minimize(@parent)
204
+ end
205
+ end
206
+
207
+ end
208
+
209
+
210
+ class AGTkVSplittedFrames < AGTkSplittedFrames
211
+ attr_reader :left_frame, :right_frame, :splitter_frame
212
+ def initialize(parent=nil, width=10, keys=nil)
213
+ super(parent, width, keys)
214
+
215
+ self.pack(:expand=>true, :fill=>:both)
216
+ @left_frame = TkFrame.new(self){
217
+ relief 'flat'
218
+ }
219
+ x = width
220
+ @left_frame.place(
221
+ 'relx' => 0,
222
+ 'x' => 0,
223
+ 'y' => '0',
224
+ 'relheight' => '1',
225
+ 'rely' => 0,
226
+ 'bordermode' => 'inside',
227
+ 'width' => x
228
+ )
229
+ @left_frame_obj = AGTkObjPlace.new(@left_frame, 'x', nil, false)
230
+ @left_frame_obj.width = x
231
+ @left_frame_obj.height = 0
232
+ @left_frame_obj.relwidth = 0
233
+ @left_frame_obj.relheight = 1
234
+
235
+ @splitter_frame = TkFrame.new(self){
236
+ relief 'raised'
237
+ border 1
238
+ }
239
+
240
+ @splitter_frame.place(
241
+ 'relx' => 0,
242
+ 'x' => x,
243
+ 'y' => '0',
244
+ 'relheight' => '1',
245
+ 'rely' => 0,
246
+ 'bordermode' => 'inside',
247
+ 'width' => @slen
248
+ )
249
+ @splitter_frame.bind_append(
250
+ "ButtonRelease-1",
251
+ proc{do_resize}
252
+ )
253
+ _self = self
254
+ @b_left = TkButton.new{
255
+ image TkPhotoImage.new('dat'=>LEFT_SIDE_GIF)
256
+ }
257
+
258
+ @b_right = TkButton.new{
259
+ image TkPhotoImage.new('dat'=>RIGHT_SIDE_GIF)
260
+ }
261
+ @proc_unplace = proc{
262
+ @b_left.unplace
263
+ @b_right.unplace
264
+ }
265
+ @splitter_frame.bind_append(
266
+ "B1-Motion",
267
+ proc{@splitter_frame.raise;@proc_unplace.call}
268
+ )
269
+ @@last_b_left = nil
270
+ @@last_b_right = nil
271
+ @b_left.bind_append('ButtonPress-1',proc{_self.hide_left;@proc_unplace.call})
272
+ @b_right.bind_append('ButtonPress-1',proc{_self.hide_right;@proc_unplace.call})
273
+ @proc_place = proc{|x,y|
274
+ if !TkWinfo.mapped?(@b_left)
275
+ _x = TkWinfo.pointerx(self) - 10
276
+ _y = TkWinfo.pointery(self) - 20
277
+ if @@last_b_left != nil
278
+ @@last_b_left.unplace
279
+ @@last_b_right.unplace
280
+ end
281
+ @b_left.place('x'=>_x,'y'=>_y,'border'=>'outside')
282
+ @b_right.place('x'=>_x,'y'=>_y+25,'border'=>'outside')
283
+ @b_left.raise
284
+ @b_right.raise
285
+ @@last_b_left = @b_left
286
+ @@last_b_right = @b_right
287
+ if @thread_unplace
288
+ @thread_unplace.kill
289
+ end
290
+ @thread_unplace= Thread.new {
291
+ sleep(5)
292
+ @proc_unplace.call
293
+ kill
294
+ }
295
+ end
296
+ }
297
+
298
+ @splitter_frame.bind_append(
299
+ 'ButtonPress-1',
300
+ proc{|x,y|
301
+ @thread_place= Thread.new {
302
+ @proc_place.call(x,y)
303
+ }
304
+ }, "%x %y")
305
+
306
+ @splitter_frame.bind_append(
307
+ "Enter",
308
+ proc{
309
+ @color_save = @splitter_frame.background
310
+ @splitter_frame.background('#9aa6a7')}
311
+ )
312
+ @splitter_frame.bind_append(
313
+ "Leave",
314
+ proc{
315
+ @splitter_frame.background(@color_save)
316
+ }
317
+ )
318
+ @splitter_frame_obj = AGTkObjPlace.new(@splitter_frame, 'x')
319
+ @splitter_frame_obj.width = @slen
320
+ @splitter_frame_obj.height = 0
321
+ @splitter_frame_obj.relwidth = 0
322
+ @splitter_frame_obj.relheight = 1
323
+ x = x + @slen
324
+ @right_frame = TkFrame.new(self){
325
+ relief 'flat'
326
+ }
327
+ @right_frame.place(
328
+ 'relwidth' => 1,
329
+ 'relx' => 0,
330
+ 'x' => x,
331
+ 'y' => 0,
332
+ 'width' => -x,
333
+ 'relheight' => 1,
334
+ 'rely' => 0,
335
+ 'bordermode' => 'inside'
336
+ )
337
+ @right_frame_obj = AGTkObjPlace.new(@right_frame, 'x', nil, false)
338
+ @right_frame_obj.width = -x
339
+ @right_frame_obj.height = 0
340
+ @right_frame_obj.relwidth = 1
341
+ @right_frame_obj.relheight = 1
342
+ @state = 'middle'
343
+ yield(self) if block_given?
344
+ end
345
+
346
+ def get_main_x
347
+ if TkWinfo.manager(@parent)=='place'
348
+ return TkPlace.info(@parent)['x'] / 2
349
+ else
350
+ return 20
351
+ end
352
+ end
353
+
354
+ def do_resize
355
+ _x = @splitter_frame_obj.x0
356
+ _w = @splitter_frame_obj.w
357
+ @left_frame_obj.width = _x
358
+ @left_frame_obj.go(_x,0)
359
+ @right_frame_obj.width = - _x - _w
360
+ @right_frame_obj.amove(_x + _w,0)
361
+ end
362
+
363
+ def hide_left
364
+ if (@state=='left')
365
+ _w = @last
366
+ @state = 'middle'
367
+ @left_frame_obj.width = _w
368
+ @left_frame_obj.go(_w,0)
369
+ else
370
+ _w = 0
371
+ @state = 'right'
372
+ @last = @left_frame_obj.w
373
+ end
374
+ @left_frame_obj.amove(0,0)
375
+ @splitter_frame_obj.amove(_w,0)
376
+ @right_frame_obj.width = - _w - @slen
377
+ @right_frame_obj.amove(_w + @slen,0)
378
+ end
379
+
380
+ def hide_right
381
+ if (@state=='right')
382
+ _w = @last
383
+ @state = 'middle'
384
+ else
385
+ _w = @right_frame_obj.w + @left_frame_obj.w #+ @slen
386
+ @state = 'left'
387
+ @last = @left_frame_obj.w
388
+ end
389
+ @right_frame_obj.width = - _w - @slen
390
+ @right_frame_obj.amove(_w + @slen,0)
391
+ @splitter_frame_obj.amove(_w,0)
392
+ @left_frame_obj.width = _w
393
+ @left_frame_obj.go(_w,0)
394
+ end
395
+
396
+ def maximize(_frame)
397
+ super(_frame)
398
+ case _frame
399
+ when left_frame
400
+ hide_right
401
+ when right_frame
402
+ hide_left
403
+ end
404
+ Tk.update
405
+ end
406
+
407
+ def minimize(_frame)
408
+ super(_frame)
409
+ case _frame
410
+ when left_frame
411
+ hide_left
412
+ when right_frame
413
+ hide_right
414
+ end
415
+ Tk.update
416
+ end
417
+
418
+ def hide(_name)
419
+ end
420
+
421
+ def show(_name)
422
+ end
423
+
424
+ end
425
+
426
+ class AGTkOSplittedFrames < AGTkSplittedFrames
427
+ attr_reader :top_frame, :bottom_frame
428
+ def initialize(parent=nil, height=10, perc=false,keys=nil)
429
+ super(parent, height, keys)
430
+ self.place(
431
+ 'relwidth' => 1,
432
+ 'relx' => 0,
433
+ 'x' => 0,
434
+ 'y' => 0,
435
+ 'relheight' => 1,
436
+ 'rely' => 0,
437
+ 'bordermode' => 'inside'
438
+ )
439
+ @top_frame = TkFrame.new(self){
440
+ relief 'flat'
441
+ }
442
+ if perc
443
+ p_height = TkWinfo.screenheight(self)
444
+ y = (p_height/100*height).to_i
445
+ else
446
+ y = height
447
+ end
448
+ @top_frame.place(
449
+ 'relwidth' => '1',
450
+ 'bordermode' => 'inside',
451
+ 'height' => y
452
+ )
453
+ @top_frame_obj = AGTkObjPlace.new(@top_frame, 'y', nil, false)
454
+ @top_frame_obj.width = 0
455
+ @top_frame_obj.height = y
456
+ @top_frame_obj.relwidth = 1
457
+ @top_frame_obj.relheight = 0
458
+ @splitter_frame = TkFrame.new(self){
459
+ relief 'groove'
460
+ border 1
461
+ }
462
+ @splitter_frame.place(
463
+ 'relx' => 0,
464
+ 'x' => 0,
465
+ 'y' => y,
466
+ 'relwidth' => '1',
467
+ 'rely' => 0,
468
+ 'bordermode' => 'inside',
469
+ 'height' => @slen
470
+ )
471
+ @splitter_frame.bind_append(
472
+ "B1-Motion",
473
+ proc{@splitter_frame.raise}
474
+ )
475
+ @splitter_frame.bind_append(
476
+ "ButtonRelease-1",
477
+ proc{do_resize}
478
+ )
479
+ @splitter_frame_obj = AGTkObjPlace.new(@splitter_frame, 'y')
480
+ @splitter_frame_obj.width = 0
481
+ @splitter_frame_obj.height = @slen
482
+ @splitter_frame_obj.relwidth = 1
483
+ @splitter_frame_obj.relheight = 0
484
+ y = y + @slen
485
+ @bottom_frame = TkFrame.new(self){
486
+ relief 'flat'
487
+ }
488
+ @bottom_frame.place(
489
+ 'relwidth' => 1,
490
+ 'relx' => 0,
491
+ 'x' => 0,
492
+ 'y' => y,
493
+ 'height' => -y,
494
+ 'relheight' => 1,
495
+ 'rely' => 0,
496
+ 'bordermode' => 'inside'
497
+ )
498
+ @bottom_frame_obj = AGTkObjPlace.new(@bottom_frame, 'y', nil, false)
499
+ @bottom_frame_obj.width = 0
500
+ @bottom_frame_obj.height = -y
501
+ @bottom_frame_obj.relwidth = 1
502
+ @bottom_frame_obj.relheight = 1
503
+ _xbutton = TkButton.new(@splitter_frame){
504
+ background '#4966d7'
505
+ overrelief 'raised'
506
+ relief 'flat'
507
+ }
508
+ _xbutton.place(
509
+ 'x' => 0,
510
+ 'y' => 0,
511
+ 'relheight' => 1,
512
+ 'bordermode' => 'outside',
513
+ 'width' => 20
514
+ )
515
+ _xbutton.bind_append(
516
+ "ButtonPress-1",
517
+ proc{hide_top}
518
+ )
519
+ _ybutton = TkButton.new(@splitter_frame){
520
+ background '#118124'
521
+ overrelief 'raised'
522
+ relief 'flat'
523
+ }
524
+ _ybutton.place(
525
+ 'x' => 21,
526
+ 'y' => 0,
527
+ 'bordermode' => 'outside',
528
+ 'width' => 20,
529
+ 'relheight' => 1
530
+ )
531
+ _ybutton.bind_append(
532
+ "ButtonPress-1",
533
+ proc{hide_bottom}
534
+ )
535
+ @state = 'middle'
536
+ yield(self) if block_given?
537
+ end
538
+
539
+ def hide_top
540
+ if (@state=='top')
541
+ _h = @last
542
+ @state = 'middle'
543
+ @top_frame_obj.height = _h
544
+ @top_frame_obj.go(0,_h)
545
+ elsif (@state=='bottom')
546
+ return
547
+ else
548
+ _h = 0
549
+ @state = 'bottom'
550
+ @last = @top_frame_obj.h
551
+ end
552
+ @top_frame_obj.amove(0,0)
553
+ @splitter_frame_obj.amove(0, _h)
554
+ @bottom_frame_obj.height = - _h - @slen
555
+ @bottom_frame_obj.amove(0,_h + @slen)
556
+ end
557
+
558
+ def hide_bottom
559
+ if (@state=='bottom')
560
+ _h = @last
561
+ @state = 'middle'
562
+ elsif (@state == 'top')
563
+ return
564
+ else
565
+ _h = @bottom_frame_obj.h + @top_frame_obj.h #+ @slen
566
+ @state = 'top'
567
+ @last = @top_frame_obj.h #+ @slen
568
+ end
569
+ @bottom_frame_obj.height = - _h - @slen
570
+ @bottom_frame_obj.amove(0,_h + @slen)
571
+ @splitter_frame_obj.amove(0,_h)
572
+ @top_frame_obj.height = _h
573
+ @top_frame_obj.go(0,_h)
574
+ end
575
+
576
+
577
+ def maximize(_frame)
578
+ super(_frame)
579
+ case _frame
580
+ when top_frame
581
+ hide_bottom
582
+ when bottom_frame
583
+ hide_top
584
+ end
585
+ Tk.update
586
+ end
587
+
588
+ def minimize(_frame)
589
+ super(_frame)
590
+ case _frame
591
+ when top_frame
592
+ hide_top
593
+ when bottom_frame
594
+ hide_bottom
595
+ end
596
+ Tk.update
597
+ end
598
+
599
+
600
+ def get_main_y
601
+ return 40
602
+ end
603
+
604
+ def do_resize
605
+ _y = @splitter_frame_obj.y0
606
+ _h = @splitter_frame_obj.h
607
+ @top_frame_obj.height = _y
608
+ @top_frame_obj.go(0,_y)
609
+ @bottom_frame_obj.height = -_y-_h
610
+ @bottom_frame_obj.amove(0,_y + _h)
611
+ #end
612
+ end
613
+
614
+ def hide(_name)
615
+ end
616
+
617
+ def show(_name)
618
+ end
619
+
620
+ end
621
+
622
+ class TkBaseTitledFrame < TkFrame
623
+ attr_reader :frame
624
+ attr_reader :top
625
+
626
+ def initialize(parent=nil, *args)
627
+ super(parent, *args)
628
+ @parent = parent
629
+ @title_height = 18
630
+ @top = TkFrame.new(self){
631
+ background '#303b50'
632
+ #foreground 'white'
633
+ #anchor 'w'
634
+ }.place('x'=>0, 'y'=>0,'height'=>@title_height, 'relwidth'=>1)
635
+ #.pack('fill'=> 'x','ipady'=> @title_height, 'side'=>'top')
636
+
637
+
638
+ @frame = create_frame
639
+
640
+
641
+
642
+ @button_frame=TkFrame.new(@top){
643
+ #background '#303b50'
644
+ }.pack('side'=> 'right','anchor'=> 'w')
645
+
646
+ self.head_buttons
647
+ end
648
+
649
+ def create_frame
650
+ return TkFrame.new(self).place('x'=>0, 'y'=>@title_height,'height'=>-@title_height,'relheight'=>1, 'relwidth'=>1)
651
+ #pack('fill'=>'both','expand'=> 1, 'anchor'=>'center')
652
+ #
653
+ end
654
+
655
+ def add_button(_label,_proc=nil,_image=nil, _side= 'right')
656
+ TkButton.new(@button_frame){
657
+ text _label if _label
658
+ image TkPhotoImage.new('dat' => _image) if _image
659
+ relief 'flat'
660
+ font 'helvetica 8 bold'
661
+ #borderwidth 0
662
+ #background '#303b50'
663
+ #background '#8080ff'
664
+ pack('side'=> _side,'anchor'=> 'e')
665
+ bind('1',_proc) if _proc
666
+ }
667
+ end
668
+
669
+ def head_buttons
670
+ @bmaxmin = add_button('[ ]',proc{resize}, W_MAX_GIF)
671
+ end
672
+
673
+ end
674
+
675
+
676
+
677
+ class TkTitledFrame < TkBaseTitledFrame
678
+ attr_reader :frame
679
+ attr_reader :top
680
+
681
+ def initialize(parent=nil, title='...', img=nil , keys=nil)
682
+ super(parent, keys)
683
+ @state = 'normal'
684
+ @title_label =TkLabel.new(@top){
685
+ text title+' :: '
686
+ anchor 'w'
687
+ font $arcadia['conf']['all.frame.title.font']
688
+ background '#303b50'
689
+ foreground '#e8e651'
690
+ compound 'left'
691
+ image TkAllPhotoImage.new('file' => img) if img
692
+ pack('side'=> 'left','anchor'=> 'e')
693
+ }
694
+ @top_label =TkLabel.new(@top){
695
+ anchor 'w'
696
+ font $arcadia['conf']['all.frame.title.font.italic']
697
+ background '#303b50'
698
+ foreground '#FFFFFF'
699
+ compound 'left'
700
+ pack('side'=> 'left','anchor'=> 'e')
701
+ }
702
+
703
+ @ap = Array.new
704
+ @apx = Array.new
705
+ @apy = Array.new
706
+ @apw = Array.new
707
+ @aph = Array.new
708
+ end
709
+
710
+ def top_text(_text)
711
+ @top_label.text(_text)
712
+ end
713
+
714
+ def title(_text)
715
+ @title_label.text(_text+'::')
716
+ end
717
+
718
+
719
+ def add_sep(_width=0,_background =@top.background)
720
+ TkLabel.new(@top){||
721
+ text ''
722
+ background _background
723
+ pack('side'=> 'right','anchor'=> 'e', 'ipadx'=>_width)
724
+ }
725
+ end
726
+
727
+
728
+ def head_buttons
729
+ @bmaxmin = add_button('[ ]',proc{resize}, W_MAX_GIF)
730
+ #@bmaxmin = add_button('[ ]',proc{resize}, EXPAND_GIF)
731
+ end
732
+
733
+ def resize
734
+ p = TkWinfo.parent(@parent)
735
+ if @state == 'normal'
736
+ if p.kind_of?(AGTkSplittedFrames)
737
+ p.maximize(@parent)
738
+ @bmaxmin.image(TkPhotoImage.new('dat' => W_NORM_GIF))
739
+ end
740
+ @state = 'maximize'
741
+ else
742
+ if p.kind_of?(AGTkSplittedFrames)
743
+ p.minimize(@parent)
744
+ @bmaxmin.image(TkPhotoImage.new('dat' =>W_MAX_GIF))
745
+ end
746
+ @state = 'normal'
747
+ end
748
+ self.raise
749
+ end
750
+
751
+ def maximize
752
+ if @state == 'normal'
753
+ p = TkWinfo.parent(self)
754
+ while (p != nil) && (TkWinfo.manager(p)=='place')
755
+ Tk.messageBox('message'=>p.to_s)
756
+ @ap << p
757
+ @apx << TkPlace.info(p)['x']
758
+ @apy << TkPlace.info(p)['y']
759
+ @apw << TkPlace.info(p)['width']
760
+ @aph << TkPlace.info(p)['height']
761
+ p.place('x'=>0, 'y'=>0,'relheight'=>1, 'relwidth'=>1)
762
+ p.raise
763
+ p = TkWinfo.parent(p)
764
+ end
765
+ @state = 'maximize'
766
+ self.raise
767
+ else
768
+ @ap.each_index{|i|
769
+ @ap[i].place('x'=>@apx[i], 'y'=>@apy[i],'width'=>@apw[i], 'height'=>@aph[i],'relheight'=>1, 'relwidth'=>1)
770
+ @ap[i].raise
771
+ }
772
+ self.raise
773
+ @ap.clear
774
+ @apx.clear
775
+ @apy.clear
776
+ @state = 'normal'
777
+ end
778
+ end
779
+ end
780
+
781
+ class TkTitledScrollFrame < TkTitledFrame
782
+
783
+ def create_frame
784
+ return Tk::ScrollFrame.new(self,:scrollbarwidth=>10, :width=>300, :height=>200).place('x'=>0, 'y'=>@title_height,'height'=>-@title_height,'relheight'=>1, 'relwidth'=>1)
785
+ end
786
+
787
+ end
788
+
789
+ class TkFloatTitledFrame < TkBaseTitledFrame
790
+ include TkMovable
791
+ include TkResizable
792
+ def initialize(parent=nil, *args)
793
+ super(parent)
794
+ frame.place('height'=>-32)
795
+ borderwidth 2
796
+ relief 'groove'
797
+
798
+ @top_label = TkLabel.new(@top){
799
+ background '#303b50'
800
+ foreground 'white'
801
+ anchor 'w'
802
+ }.pack('fill'=>'x', 'side'=>'top')
803
+ #.place('x'=>0, 'y'=>0,'relheight'=>1, 'relwidth'=>1 ,'width'=>-20)
804
+
805
+ @resizing_label=TkLabel.new(self){
806
+ #background '#303b50'
807
+ text '-'
808
+ image TkPhotoImage.new('dat'=>EXPAND_LIGHT_GIF)
809
+ }.pack('side'=> 'right','anchor'=> 's')
810
+ start_moving(@top_label, self)
811
+ start_moving(frame, self)
812
+ start_resizing(@resizing_label, self)
813
+ @grabbed = false
814
+ end
815
+
816
+ def title(_text)
817
+ @top_label.text(_text)
818
+ end
819
+
820
+ def on_close=(_proc)
821
+ add_button('X', _proc, TAB_CLOSE_GIF)
822
+ end
823
+
824
+ def hide
825
+ @manager = TkWinfo.manager(self)
826
+ if @manager == 'place'
827
+ @x_place = TkPlace.info(self)['x']
828
+ @y_place = TkPlace.info(self)['y']
829
+ @width_place = TkPlace.info(self)['width']
830
+ @height_place = TkPlace.info(self)['height']
831
+ self.unplace
832
+ end
833
+
834
+ if @grabbed
835
+ self.grab("release")
836
+ @grabbed = false
837
+ end
838
+ self
839
+ end
840
+
841
+ def show
842
+ if @manager == 'place'
843
+ self.place('x'=>@x_place, 'y'=>@y_place, 'width'=>@width_place, 'height'=>@height_place)
844
+ end
845
+ end
846
+
847
+ def show_grabbed
848
+ show
849
+ @grabbed = true
850
+ self.grab("set")
851
+ end
852
+
853
+ # def show_modal
854
+ # # not implemented
855
+ # end
856
+
857
+ def head_buttons
858
+ end
859
+
860
+ end
861
+
862
+ class TkProgressframe < TkFloatTitledFrame
863
+ def initialize(parent=nil, _max=100, *args)
864
+ super(parent)
865
+ @max = _max
866
+ @progress = TkVariable.new
867
+ @progress.value = -1
868
+ Tk::BWidget::ProgressBar.new(self, :width=>150, :height=>10,
869
+ :background=>'red',
870
+ :foreground=>'blue',
871
+ :variable=>@progress,
872
+ :borderwidth=>0,
873
+ :relief=>'flat',
874
+ :maximum=>_max).place('width' => '150','x' => 25,'y' => 30,'height' => 15)
875
+
876
+ @buttons_frame = TkFrame.new(self).pack('fill'=>'x', 'side'=>'bottom')
877
+
878
+ @b_cancel = TkButton.new(@buttons_frame){|_b_go|
879
+ default 'disabled'
880
+ text 'Cancel'
881
+ overrelief 'raised'
882
+ justify 'center'
883
+ pack('side'=>'top','ipadx'=>5, 'padx'=>5)
884
+ }
885
+
886
+ place('x'=>100,'y'=>100,'height'=> 120,'width'=> 200)
887
+ end
888
+
889
+ def quit
890
+ #self.destroy
891
+ end
892
+
893
+ def progress(_incr=1)
894
+ @progress.numeric += _incr
895
+ end
896
+
897
+ def on_cancel=(_proc)
898
+ @b_cancel.bind_append('1', _proc)
899
+ end
900
+ end
901
+
902
+ class TkBuffersChoiseView < TkToplevel
903
+
904
+ def initialize
905
+ super
906
+ Tk.tk_call('wm', 'title', self, '...hello' )
907
+ Tk.tk_call('wm', 'geometry', self, '150x217+339+198' )
908
+ @lb = TkListbox.new(self){
909
+ background '#fedbd7'
910
+ relief 'groove'
911
+ place('relwidth' => '1','relx' => 0,'x' => '0','y' => '0','relheight' => '1','rely' => 0,'height' => '0','bordermode' => 'inside','width' => '0')
912
+ }
913
+ end
914
+
915
+ end
916
+
917
+ class TkBuffersChoise < TkBuffersChoiseView
918
+
919
+ def initialize
920
+ super
921
+ @lb.value= $arcadia['buffers.code.in_memory'].keys
922
+ @lb.bind("Double-ButtonPress-1",proc{
923
+ _sel = @lb.get('active')
924
+ Revparsel.new($arcadia['buffers.code.in_memory'][_sel])
925
+ @lb.delete('active')
926
+ $arcadia['buffers.code.in_memory'].delete(_sel)
927
+ destroy
928
+ })
929
+ raise
930
+ end
931
+
932
+ end
933
+