Newer
Older
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
77
78
79
80
81
82
#
# Splashscreen component, contributed by David Naseby.
#
require 'fox16/colors'
module Fox
#
# The FXSplashScreen window...
#
class FXSplashScreen < FXDialogBox
#
# Return an initialized FXSplashScreen instance.
#
# ==== Parameters:
#
# +owner+:: Owner window for this dialog box [FXWindow]
# +title+:: Title string for this dialog box [String]
# +text+:: Message text for this dialog box [String]
# +action+:: The action
#
def initialize( owner, title, text, action )
# Initialize the base class first
super(owner, title)
# Store the action block
@action = action
# Construct the window contents
FXVerticalFrame.new( self ) do |frame|
text.each_line do |line|
FXLabel.new( frame, line.strip )
end
FXLabel.new( frame, "Click OK to continue (this may take a few moments)...." )
@status = FXLabel.new( frame, " " )
@accept = FXButton.new( frame, "&OK", nil, self, ID_ACCEPT,
FRAME_RAISED|FRAME_THICK|LAYOUT_RIGHT|LAYOUT_CENTER_Y)
@accept.enabled = false
end
end
def execute(placement = PLACEMENT_OWNER)
Thread.new do
sleep 1
@action.call method( :update_status )
update_status "Completed"
@accept.enabled = true
end
super
end
def update_status(msg)
@status.text = msg
end
end
end
if $0 == __FILE__
class FakeSite # :nodoc:
def open( &status )
yield ">>>>> Opening Site" if block_given?
sleep 5
yield "site open" if block_given?
end
end
fake_site = FakeSite.new
include Fox
FXApp.new( "Test SplashScreen" ) do |theApp|
FXMainWindow.new( theApp, "Hello" ) do |mainWin|
FXButton.new( mainWin, "Show Splash" ).connect( SEL_COMMAND ) do
lv = FXSplashScreen.new( mainWin, "Opening Site", "Welcome to Sitebuilder!\nOpening the site.\n", lambda{ |proc| fake_site.open( &proc ) } )
lv.execute
end
mainWin.show
end
theApp.create
theApp.run
end
end