-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoboWindow.rb
76 lines (67 loc) · 1.93 KB
/
RoboWindow.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require './CoreGraphics'
require './Phases/LoadPhase'
class RoboWindow < FXMainWindow
def initialize(app, db)
super(app, "Robo", :width => 800, :height => 600)
@canvas = FXCanvas.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT)
@phase = nil
@db = db
@canvas.connect(SEL_LEFTBUTTONPRESS) do |sender, sel, event|
@canvas.grab
@phase.on_leftbuttonpress event
end
@canvas.connect(SEL_MOTION) do |sender, sel, event|
@phase.on_motion event
end
@canvas.connect(SEL_LEFTBUTTONRELEASE) do |sender, sel, event|
@canvas.ungrab
@phase.on_leftbuttonrelease event
end
end
def draw
ctx = FXDCWindow.new(@canvas)
yield(ctx)
ctx.end
end
def onTimeout(sender, sel, ptr)
@phase.update
@phase.draw
getApp.addTimeout(20, method(:onTimeout))
return 1
end
# Create and show the main window
def create
super
# font = FXFont.new(app,'Arial,100')
# font.create
# txt = db.execute("SElECT value FROM Meta WHERE key='foo'")[0][0]
# img = File.open('test.png', 'rb')
# fximg = FXPNGImage.new(app, img.read, 0, 374, 448)
# fximg.create
# img.close
# window.draw do |ctx|
# ctx.foreground = 'black'
# ctx.font = font
# ctx.drawText(0, window.height, txt)
#
# ctx.drawImage(fximg, 100, 100)
# end
cg = CoreGraphics.new getApp, self
f = FXFont.new(app,'Arial,240')
f.create
cg.register_files(['test'], '.png')
cg.register_animation('fourier', 'png')
cg.load
@phase = LoadPhase.new({
:cg => cg,
:window => self,
:font => f
})
# cg.begin
# cg.pdraw('test').move_animated(:SMOOTH, 300, 200, 0) { |img| img.kill }
# cg.pdraw('test', 1, 0, 100)
# cg.adraw('fourier', 0, 300, 300).move_animated(:LINEAR, 100, 300, 200) { }
getApp.addTimeout(20, method(:onTimeout))
show(PLACEMENT_SCREEN) # Make the main window appear
end
end