arcadia 0.1.2.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +9 -9
- data/arcadia.rb +770 -770
- data/base/a-contracts-work.rb +219 -0
- data/base/a-contracts.rb +322 -307
- data/base/a-utils.rb +993 -993
- data/conf/arcadia.conf +203 -203
- data/conf/arcadia.res.rb +1325 -1285
- data/ext/ae-complete-code/ae-complete-code.rb +80 -80
- data/ext/ae-doc-code/ae-doc-code.rb +288 -289
- data/ext/ae-editor/ae-editor.conf +105 -101
- data/ext/ae-editor/ae-editor.rb +2287 -2229
- data/ext/ae-event-log/ae-event-log.conf +5 -5
- data/ext/ae-file-history/ae-file-history.rb +2 -2
- data/ext/ae-flag/ae-flag.conf +6 -0
- data/ext/ae-flag/ae-flag.rb +12 -0
- data/ext/ae-inspector/ae-inspector.conf +7 -7
- data/ext/ae-output-event/ae-output-event.conf +15 -15
- data/ext/ae-palette/ae-palette.conf +7 -7
- data/ext/ae-ruby-debug/ae-ruby-debug.conf +20 -0
- data/ext/ae-ruby-debug/ae-ruby-debug.rb +1329 -0
- data/ext/ae-shell/ae-shell.conf +11 -11
- data/ext/ae-shell/ae-shell.rb +50 -51
- metadata +28 -5
- data/ext/ae-shell/ae-shell.rb~~ +0 -49
data/base/a-utils.rb
CHANGED
@@ -1,993 +1,993 @@
|
|
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-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
|
+
|