newt 0.9.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.rdoc +30 -1
- data/examples/test-e.rb +112 -0
- data/examples/test-j.rb +112 -0
- data/examples/test_method/Button.rb +21 -0
- data/examples/test_method/Checkbox.rb +33 -0
- data/examples/test_method/CheckboxTree.rb +28 -0
- data/examples/test_method/CheckboxTreeMulti.rb +26 -0
- data/examples/test_method/CompactButton.rb +21 -0
- data/examples/test_method/Entry.rb +66 -0
- data/examples/test_method/Form.rb +23 -0
- data/examples/test_method/Form_ExitStruct.rb +36 -0
- data/examples/test_method/HelpCallback.rb +48 -0
- data/examples/test_method/Label.rb +26 -0
- data/examples/test_method/Listbox.rb +33 -0
- data/examples/test_method/Newt_FLAG_SCROLL.rb +20 -0
- data/examples/test_method/Newt_cursor.rb +30 -0
- data/examples/test_method/RadioButton.rb +25 -0
- data/examples/test_method/ReflowText.rb +15 -0
- data/examples/test_method/Scale.rb +27 -0
- data/examples/test_method/Screen_bell.rb +10 -0
- data/examples/test_method/Screen_cls.rb +11 -0
- data/examples/test_method/Screen_draw_roottext.rb +15 -0
- data/examples/test_method/Screen_init.rb +10 -0
- data/examples/test_method/Screen_pop_helpline.rb +15 -0
- data/examples/test_method/Screen_push_helpline.rb +13 -0
- data/examples/test_method/Screen_redraw_helpline.rb +15 -0
- data/examples/test_method/Screen_set_colors.rb +32 -0
- data/examples/test_method/Screen_size.rb +15 -0
- data/examples/test_method/Screen_win_menu.rb +15 -0
- data/examples/test_method/SuspendCallback.rb +33 -0
- data/examples/test_method/Textbox.rb +27 -0
- data/examples/test_method/TextboxReflowed.rb +20 -0
- data/examples/test_method/Widget_callback.rb +76 -0
- data/examples/test_method/memory.rb +21 -0
- data/examples/testgrid-e.rb +78 -0
- data/examples/testgrid-j.rb +80 -0
- data/examples/testtree-e.rb +53 -0
- data/examples/testtree-j.rb +53 -0
- data/ext/ruby_newt/extconf.rb +5 -4
- data/ext/ruby_newt/ruby_newt.c +1297 -537
- data/lib/version.rb +1 -1
- metadata +49 -13
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'newt'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Newt::Screen.new
|
7
|
+
Newt::Screen.centered_window(45, 10, 'Cursor Test')
|
8
|
+
|
9
|
+
l = Newt::Listbox.new(5, 1, 5)
|
10
|
+
1.upto(3) do |i|
|
11
|
+
l.append("item #{i}", i)
|
12
|
+
end
|
13
|
+
|
14
|
+
b1 = Newt::Button.new(2, 5, 'Cursor On')
|
15
|
+
b2 = Newt::Button.new(17, 5, 'Cursor Off')
|
16
|
+
b3 = Newt::Button.new(33, 5, 'Exit')
|
17
|
+
|
18
|
+
f = Newt::Form.new
|
19
|
+
f.add(l, b1, b2, b3)
|
20
|
+
|
21
|
+
loop do
|
22
|
+
case f.run
|
23
|
+
when b1 then Newt::Screen.cursor_on
|
24
|
+
when b2 then Newt::Screen.cursor_off
|
25
|
+
else break
|
26
|
+
end
|
27
|
+
end
|
28
|
+
ensure
|
29
|
+
Newt::Screen.finish
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
begin
|
7
|
+
Newt::Screen.new
|
8
|
+
Newt::Screen.centered_window(20, 8, 'RadioButton')
|
9
|
+
|
10
|
+
rb1 = Newt::RadioButton.new(1, 1, 'Button1', 1)
|
11
|
+
rb2 = Newt::RadioButton.new(1, 2, 'Button2', 0, rb1)
|
12
|
+
|
13
|
+
b = Newt::Button.new(6, 4, 'Exit')
|
14
|
+
|
15
|
+
f = Newt::Form.new
|
16
|
+
f.add(rb1, rb2, b)
|
17
|
+
|
18
|
+
f.run
|
19
|
+
current = rb1.get_current
|
20
|
+
ensure
|
21
|
+
Newt::Screen.finish
|
22
|
+
end
|
23
|
+
|
24
|
+
puts "selected: #{current}"
|
25
|
+
puts "current == rb1?: #{current == rb1}"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
text, width, height = Newt.reflow_text('This is a quite a bit of text. It is 40 ' \
|
7
|
+
'columns long, so some wrapping should be ' \
|
8
|
+
'done. Did you know that the quick, brown ' \
|
9
|
+
"fox jumped over the lazy dog?\n\n" \
|
10
|
+
"In other news, it's pretty important that we " \
|
11
|
+
'can properly force a line break.', 40, 5, 5)
|
12
|
+
|
13
|
+
p text
|
14
|
+
p width
|
15
|
+
p height
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
begin
|
7
|
+
SCALE_EMPTY = Newt::COLORSET_CUSTOM 1
|
8
|
+
SCALE_FULL = Newt::COLORSET_CUSTOM 2
|
9
|
+
|
10
|
+
Newt::Screen.new
|
11
|
+
Newt::Screen.set_color(SCALE_EMPTY, 'yellow', 'cyan')
|
12
|
+
Newt::Screen.set_color(SCALE_FULL, 'black', 'red')
|
13
|
+
Newt::Screen.centered_window(20, 8, 'Scale')
|
14
|
+
|
15
|
+
s = Newt::Scale.new(1, 1, 18, 100)
|
16
|
+
s.set(50)
|
17
|
+
s.set_colors(SCALE_EMPTY, SCALE_FULL)
|
18
|
+
|
19
|
+
b = Newt::Button.new(6, 4, 'Exit')
|
20
|
+
|
21
|
+
f = Newt::Form.new
|
22
|
+
f.add(s, b)
|
23
|
+
|
24
|
+
f.run
|
25
|
+
ensure
|
26
|
+
Newt::Screen.finish
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
begin
|
7
|
+
Newt::Screen.new
|
8
|
+
|
9
|
+
Newt::Screen.push_helpline('Hit Key!!')
|
10
|
+
Newt::Screen.wait_for_key
|
11
|
+
Newt::Screen.pop_helpline
|
12
|
+
Newt::Screen.wait_for_key
|
13
|
+
ensure
|
14
|
+
Newt::Screen.finish
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
begin
|
7
|
+
Newt::Screen.new
|
8
|
+
|
9
|
+
Newt::Screen.push_helpline('Hit Key!!')
|
10
|
+
Newt::Screen.wait_for_key
|
11
|
+
Newt::Screen.redraw_helpline
|
12
|
+
Newt::Screen.wait_for_key
|
13
|
+
ensure
|
14
|
+
Newt::Screen.finish
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
COLORS = {
|
7
|
+
borderFg: 'yellow', borderBg: 'cyan',
|
8
|
+
windowFg: 'black', windowBg: 'cyan',
|
9
|
+
titleFg: 'black', titleBg: 'cyan',
|
10
|
+
listboxFg: 'black', listboxBg: 'cyan',
|
11
|
+
actListboxFg: 'black', actListboxBg: 'red',
|
12
|
+
buttonFg: 'white', buttonBg: 'blue'
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
begin
|
16
|
+
Newt::Screen.new
|
17
|
+
Newt::Screen.set_colors(COLORS)
|
18
|
+
|
19
|
+
l1 = Newt::Listbox.new(1, 1, 10, Newt::FLAG_SCROLL)
|
20
|
+
1.upto(20) do |i|
|
21
|
+
l1.append("item #{i}", i)
|
22
|
+
end
|
23
|
+
|
24
|
+
b = Newt::Button.new(1, 12, 'Exit')
|
25
|
+
|
26
|
+
f = Newt::Form.new
|
27
|
+
f.add(l1, b)
|
28
|
+
|
29
|
+
f.run
|
30
|
+
ensure
|
31
|
+
Newt::Screen.finish
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# rubocop:disable Style/GlobalVars
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'newt'
|
6
|
+
|
7
|
+
$suspend_called = false
|
8
|
+
$callback_data = nil
|
9
|
+
|
10
|
+
def global_callback(data)
|
11
|
+
$suspend_called = true
|
12
|
+
$callback_data = data
|
13
|
+
end
|
14
|
+
|
15
|
+
begin
|
16
|
+
Newt::Screen.new
|
17
|
+
Newt::Screen.suspend_callback(:global_callback, 'Hello World!')
|
18
|
+
Newt::Screen.centered_window(20, 8, 'Suspend Callback')
|
19
|
+
|
20
|
+
l = Newt::Label.new(6, 1, 'Press ^Z')
|
21
|
+
b = Newt::Button.new(6, 3, 'Exit')
|
22
|
+
|
23
|
+
f = Newt::Form.new
|
24
|
+
f.add(l, b)
|
25
|
+
|
26
|
+
f.run
|
27
|
+
ensure
|
28
|
+
Newt::Screen.finish
|
29
|
+
end
|
30
|
+
|
31
|
+
puts "suspend_called: #{$suspend_called}"
|
32
|
+
puts "callback_data: #{$callback_data}"
|
33
|
+
# rubocop:enable Style/GlobalVars
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
begin
|
7
|
+
TEXTBOX_NORMAL = Newt::COLORSET_CUSTOM 1
|
8
|
+
TEXTBOX_ACTIVE = Newt::COLORSET_CUSTOM 2
|
9
|
+
|
10
|
+
Newt::Screen.new
|
11
|
+
Newt::Screen.set_color(TEXTBOX_NORMAL, 'black', 'red')
|
12
|
+
Newt::Screen.set_color(TEXTBOX_ACTIVE, 'white', 'red')
|
13
|
+
Newt::Screen.centered_window(20, 10, 'Textbox')
|
14
|
+
|
15
|
+
t = Newt::Textbox.new(1, 1, 18, 3, Newt::FLAG_WRAP)
|
16
|
+
t.set_colors(TEXTBOX_NORMAL, TEXTBOX_ACTIVE)
|
17
|
+
t.set_text("Line1\nLine2\nLine3")
|
18
|
+
t.set_height(20)
|
19
|
+
|
20
|
+
b = Newt::Button.new(6, 6, 'Exit')
|
21
|
+
f = Newt::Form.new
|
22
|
+
f.add(t, b)
|
23
|
+
|
24
|
+
f.run
|
25
|
+
ensure
|
26
|
+
Newt::Screen.finish
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
begin
|
7
|
+
Newt::Screen.new
|
8
|
+
Newt::Screen.centered_window(20, 10, 'TextboxReflowed')
|
9
|
+
|
10
|
+
text = "Line1 Line1 Line1 Line1 Line1 Line1 Line1 Line1 \nLine2"
|
11
|
+
t = Newt::TextboxReflowed.new(1, 1, text, 18, 0, 0, 0)
|
12
|
+
|
13
|
+
b = Newt::Button.new(6, 6, 'Exit')
|
14
|
+
f = Newt::Form.new
|
15
|
+
f.add(t, b)
|
16
|
+
|
17
|
+
f.run
|
18
|
+
ensure
|
19
|
+
Newt::Screen.finish
|
20
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# rubocop:disable Style/GlobalVars
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'newt'
|
6
|
+
|
7
|
+
$cb1_called = false
|
8
|
+
$cb1_widget = nil
|
9
|
+
$cb1_data = nil
|
10
|
+
|
11
|
+
$cb2_called = false
|
12
|
+
$cb2_widget = nil
|
13
|
+
$cb2_data = nil
|
14
|
+
|
15
|
+
$cb3_called = false
|
16
|
+
$cb3_widget = nil
|
17
|
+
$cb3_data = nil
|
18
|
+
|
19
|
+
def callme(w, data)
|
20
|
+
$cb1_called = true
|
21
|
+
$cb1_widget = w
|
22
|
+
$cb1_data = data
|
23
|
+
end
|
24
|
+
|
25
|
+
class Receiver
|
26
|
+
attr_reader :cb
|
27
|
+
def initialize
|
28
|
+
@cb = Newt::Checkbox.new(1, 12, 'Checkbox3')
|
29
|
+
@cb.callback(:callme, 'Hello Receiver!')
|
30
|
+
end
|
31
|
+
|
32
|
+
def callme(w, data)
|
33
|
+
$cb3_called = true
|
34
|
+
$cb3_widget = w
|
35
|
+
$cb3_data = data
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
begin
|
40
|
+
Newt::Screen.new
|
41
|
+
|
42
|
+
cb1 = Newt::Checkbox.new(1, 10, 'Checkbox1')
|
43
|
+
cb1.callback(:callme, 'Hello World!')
|
44
|
+
|
45
|
+
cb2 = Newt::Checkbox.new(1, 11, 'Checkbox2')
|
46
|
+
cb2.callback(proc { |w, data|
|
47
|
+
$cb2_called = true
|
48
|
+
$cb2_widget = w
|
49
|
+
$cb2_data = data
|
50
|
+
}, 'Hello Proc!')
|
51
|
+
|
52
|
+
cb_receiver = Receiver.new
|
53
|
+
b = Newt::Button.new(1, 14, 'Exit')
|
54
|
+
|
55
|
+
f = Newt::Form.new
|
56
|
+
f.add(cb1, cb2, cb_receiver.cb, b)
|
57
|
+
|
58
|
+
f.run
|
59
|
+
ensure
|
60
|
+
Newt::Screen.finish
|
61
|
+
end
|
62
|
+
|
63
|
+
puts "$cb1_called: #{$cb1_called}"
|
64
|
+
puts "$cb1_widget: #{$cb1_widget}"
|
65
|
+
puts "$cb1_data: #{$cb1_data}"
|
66
|
+
puts
|
67
|
+
|
68
|
+
puts "$cb2_called: #{$cb2_called}"
|
69
|
+
puts "$cb2_widget: #{$cb2_widget}"
|
70
|
+
puts "$cb2_data: #{$cb2_data}"
|
71
|
+
puts
|
72
|
+
|
73
|
+
puts "$cb3_called: #{$cb3_called}"
|
74
|
+
puts "$cb3_widget: #{$cb3_widget}"
|
75
|
+
puts "$cb3_data: #{$cb3_data}"
|
76
|
+
# rubocop:enable Style/GlobalVars
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'newt'
|
4
|
+
|
5
|
+
def cleanup
|
6
|
+
Newt::Screen.finish
|
7
|
+
end
|
8
|
+
|
9
|
+
Newt::Screen.new
|
10
|
+
Signal.trap('INT') { cleanup }
|
11
|
+
|
12
|
+
10.times do
|
13
|
+
f = Newt::Form.new
|
14
|
+
b1 = Newt::Button.new(3, 1, 'Exit')
|
15
|
+
b2 = Newt::Button.new(18, 1, 'Update')
|
16
|
+
f.add(b1, b2)
|
17
|
+
Newt::Screen.refresh
|
18
|
+
GC.start
|
19
|
+
end
|
20
|
+
|
21
|
+
cleanup
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
menu_contents = %w[One Two Three Four Five]
|
7
|
+
auto_entries = ['An entry', 'Another entry', 'Third entry', 'Fourth entry']
|
8
|
+
|
9
|
+
Newt::Screen.new
|
10
|
+
|
11
|
+
b1 = Newt::Checkbox.new(-1, -1, 'An pretty long checkbox for testing', ' ', nil)
|
12
|
+
b2 = Newt::Button.new(-1, -1, 'Another Button')
|
13
|
+
b3 = Newt::Button.new(-1, -1, 'But, but')
|
14
|
+
b4 = Newt::Button.new(-1, -1, 'But what?')
|
15
|
+
|
16
|
+
f = Newt::Form.new
|
17
|
+
|
18
|
+
grid = Newt::Grid.new(2, 2)
|
19
|
+
grid.set_field(0, 0, Newt::GRID_COMPONENT, b1, 0, 0, 0, 0,
|
20
|
+
Newt::ANCHOR_RIGHT, 0)
|
21
|
+
grid.set_field(0, 1, Newt::GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0)
|
22
|
+
grid.set_field(1, 0, Newt::GRID_COMPONENT, b3, 0, 0, 0, 0, 0, 0)
|
23
|
+
grid.set_field(1, 1, Newt::GRID_COMPONENT, b4, 0, 0, 0, 0, 0, 0)
|
24
|
+
|
25
|
+
f.add(b1, b2, b3, b4)
|
26
|
+
grid.wrapped_window('first window')
|
27
|
+
f.run
|
28
|
+
|
29
|
+
Newt::Screen.pop_window
|
30
|
+
|
31
|
+
flowed_text, text_width, text_height = Newt.reflow_text('This is a quite a bit of text. It is 40 ' \
|
32
|
+
'columns long, so some wrapping should be ' \
|
33
|
+
'done. Did you know that the quick, brown ' \
|
34
|
+
"fox jumped over the lazy dog?\n\n" \
|
35
|
+
"In other news, it's pretty important that we " \
|
36
|
+
'can properly force a line break.', 40, 5, 5)
|
37
|
+
|
38
|
+
t = Newt::Textbox.new(-1, -1, text_width, text_height, Newt::FLAG_WRAP)
|
39
|
+
t.set_text(flowed_text)
|
40
|
+
|
41
|
+
b1 = Newt::Button.new(-1, -1, 'Okay')
|
42
|
+
b2 = Newt::Button.new(-1, -1, 'Cancel')
|
43
|
+
|
44
|
+
grid = Newt::Grid.new(1, 2)
|
45
|
+
subgrid = Newt::Grid.new(2, 1)
|
46
|
+
|
47
|
+
subgrid.set_field(0, 0, Newt::GRID_COMPONENT, b1, 0, 0, 0, 0, 0, 0)
|
48
|
+
subgrid.set_field(1, 0, Newt::GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0)
|
49
|
+
|
50
|
+
grid.set_field(0, 0, Newt::GRID_COMPONENT, t, 0, 0, 0, 1, 0, 0)
|
51
|
+
grid.set_field(0, 1, Newt::GRID_SUBGRID, subgrid, 0, 0, 0, 0, 0,
|
52
|
+
Newt::GRID_FLAG_GROWX)
|
53
|
+
grid.wrapped_window('another example')
|
54
|
+
|
55
|
+
f = Newt::Form.new
|
56
|
+
f.add(b1, t, b2)
|
57
|
+
f.run
|
58
|
+
|
59
|
+
Newt::Screen.pop_window
|
60
|
+
|
61
|
+
Newt::Screen.win_message('Simple', 'Ok', 'This is a simple message window')
|
62
|
+
result = Newt::Screen.win_choice('Simple', 'Ok', 'Cancel', 'This is a simple choice window')
|
63
|
+
|
64
|
+
text_width = Newt::Screen.win_menu('Test Menu', 'This is a sample invovation of the ' \
|
65
|
+
'newtWinMenu() call. It may or may not have a scrollbar, ' \
|
66
|
+
'depending on the need for one.',
|
67
|
+
50, 5, 5, 3, menu_contents, 'Ok', 'Cancel')
|
68
|
+
|
69
|
+
v = Newt::Screen.win_entries('Text newtWinEntries()', 'This is a sample invovation of ' \
|
70
|
+
'newtWinEntries() call. It lets you get a lot of input ' \
|
71
|
+
'quite easily.',
|
72
|
+
50, 5, 5, 20, auto_entries, 'Ok', 'Cancel')
|
73
|
+
|
74
|
+
Newt::Screen.finish
|
75
|
+
|
76
|
+
printf "item = %d\n", text_width
|
77
|
+
p v
|
78
|
+
p result
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
menu_contents = ['°ì', 'Æó', '»°', '»Í', '¸Þ']
|
7
|
+
auto_entries = ['¥¨¥ó¥È¥ê', 'Ê̤Υ¨¥ó¥È¥ê', '»°ÈÖÌܤΥ¨¥ó¥È¥ê', '»ÍÈÖÌܤΥ¨¥ó¥È¥ê']
|
8
|
+
|
9
|
+
Newt::Screen.new
|
10
|
+
|
11
|
+
b1 = Newt::Checkbox.new(-1, -1, '¥Æ¥¹¥È¤Î¤¿¤á¤Î¤«¤Ê¤êŤ¤¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹', ' ', nil)
|
12
|
+
b2 = Newt::Button.new(-1, -1, 'Ê̤Υܥ¿¥ó')
|
13
|
+
b3 = Newt::Button.new(-1, -1, '¤·¤«¤·¡¢¤·¤«¤·')
|
14
|
+
b4 = Newt::Button.new(-1, -1, '¤·¤«¤·²¿¤À¤í¤¦¡©')
|
15
|
+
|
16
|
+
f = Newt::Form.new
|
17
|
+
|
18
|
+
grid = Newt::Grid.new(2, 2)
|
19
|
+
grid.set_field(0, 0, Newt::GRID_COMPONENT, b1, 0, 0, 0, 0,
|
20
|
+
Newt::ANCHOR_RIGHT, 0)
|
21
|
+
grid.set_field(0, 1, Newt::GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0)
|
22
|
+
grid.set_field(1, 0, Newt::GRID_COMPONENT, b3, 0, 0, 0, 0, 0, 0)
|
23
|
+
grid.set_field(1, 1, Newt::GRID_COMPONENT, b4, 0, 0, 0, 0, 0, 0)
|
24
|
+
|
25
|
+
f.add(b1, b2, b3, b4)
|
26
|
+
grid.wrapped_window('°ìÈÖÌܤΥ¦¥£¥ó¥É¥¦')
|
27
|
+
f.run
|
28
|
+
|
29
|
+
# f.destroy
|
30
|
+
Newt::Screen.pop_window
|
31
|
+
|
32
|
+
flowed_text, text_width, text_height = Newt.reflow_text('¤³¤ì¤Ï¤«¤Ê¤ê¥Æ¥¥¹¥È¤é¤·¤¤¤â¤Î¤Ç¤¹¡£40¥«¥é¥à' \
|
33
|
+
'¤ÎŤµ¤Ç¡¢¥é¥Ã¥Ô¥ó¥°¤¬¹Ô¤ï¤ì¤Þ¤¹¡£' \
|
34
|
+
'ÁÇÁᤤ¡¢Ã㿧¤Î¸Ñ¤¬¤Î¤í¤Þ¤Ê¸¤¤òÈô¤Ó' \
|
35
|
+
"±Û¤¨¤¿¤Î¤òÃΤäƤ뤫¤¤?\n\n" \
|
36
|
+
'¾¤Ë¤ªÃΤ餻¤¹¤ë¤³¤È¤È¤·¤Æ¡¢Å¬Åö¤Ë²þ¹Ô¤ò¤¹¤ë' \
|
37
|
+
'¤³¤È¤¬½ÅÍפǤ¹¡£', 40, 5, 5)
|
38
|
+
|
39
|
+
t = Newt::Textbox.new(-1, -1, text_width, text_height, Newt::FLAG_WRAP)
|
40
|
+
t.set_text(flowed_text)
|
41
|
+
|
42
|
+
b1 = Newt::Button.new(-1, -1, 'λ²ò')
|
43
|
+
b2 = Newt::Button.new(-1, -1, '¥¥ã¥ó¥»¥ë')
|
44
|
+
|
45
|
+
grid = Newt::Grid.new(1, 2)
|
46
|
+
subgrid = Newt::Grid.new(2, 1)
|
47
|
+
|
48
|
+
subgrid.set_field(0, 0, Newt::GRID_COMPONENT, b1, 0, 0, 0, 0, 0, 0)
|
49
|
+
subgrid.set_field(1, 0, Newt::GRID_COMPONENT, b2, 0, 0, 0, 0, 0, 0)
|
50
|
+
|
51
|
+
grid.set_field(0, 0, Newt::GRID_COMPONENT, t, 0, 0, 0, 1, 0, 0)
|
52
|
+
grid.set_field(0, 1, Newt::GRID_SUBGRID, subgrid, 0, 0, 0, 0, 0,
|
53
|
+
Newt::GRID_FLAG_GROWX)
|
54
|
+
grid.wrapped_window('Ê̤ÎÎã')
|
55
|
+
|
56
|
+
f = Newt::Form.new
|
57
|
+
f.add(b1, t, b2)
|
58
|
+
f.run
|
59
|
+
|
60
|
+
Newt::Screen.pop_window
|
61
|
+
# f.destroy
|
62
|
+
|
63
|
+
Newt::Screen.win_message('¥·¥ó¥×¥ë', 'λ²ò', '¤³¤ì¤Ï¥·¥ó¥×¥ë¤Ê¥á¥Ã¥»¡¼¥¸¥¦¥£¥ó¥É¥¦¤Ç¤¹')
|
64
|
+
result = Newt::Screen.win_choice('¥·¥ó¥×¥ë', 'λ²ò', '¥¥ã¥ó¥»¥ë', '¤³¤ì¤Ï¥·¥ó¥×¥ë¤ÊÁªÂò¥¦¥£¥ó¥É¥¦¤Ç¤¹')
|
65
|
+
|
66
|
+
text_width = Newt::Screen.win_menu('¥Æ¥¹¥È¥á¥Ë¥å¡¼', '¤³¤ì¤Ï newtWinMenu() ¥³¡¼¥ë¤Î¥µ¥ó¥×¥ë' \
|
67
|
+
'¤Ç¤¹¡£ ¥¹¥¯¥í¡¼¥ë¥Ð¡¼¤ÏɬÍפ˱þ¤¸¤Æ¤Ä¤¤¤¿¤ê¡¢ ' \
|
68
|
+
'¤Ä¤«¤Ê¤«¤Ã¤¿¤ê¤·¤Þ¤¹¡£',
|
69
|
+
50, 5, 5, 3, menu_contents, 'λ²ò', '¥¥ã¥ó¥»¥ë')
|
70
|
+
|
71
|
+
v = Newt::Screen.win_entries('¥Æ¥¥¹¥È newtWinEntries()', '¤³¤ì¤Ï newtWinEntries()' \
|
72
|
+
'¥³¡¼¥ë¤Î¥µ¥ó¥×¥ë¤Ç¤¹¡£¤¿¤¤¤Ø¤ó´Êñ¤Ë¤¿¤¯¤µ¤ó¤ÎÆþÎϤò' \
|
73
|
+
'°·¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£',
|
74
|
+
50, 5, 5, 20, auto_entries, 'λ²ò', '¥¥ã¥ó¥»¥ë')
|
75
|
+
|
76
|
+
Newt::Screen.finish
|
77
|
+
|
78
|
+
printf "item = %d\n", text_width
|
79
|
+
p v
|
80
|
+
p result
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'newt'
|
5
|
+
|
6
|
+
Newt::Screen.new
|
7
|
+
|
8
|
+
checktree = Newt::CheckboxTreeMulti.new(-1, -1, 10, ' ab', Newt::FLAG_SCROLL)
|
9
|
+
checktree.add('Numbers', 2, 0, Newt::ARG_APPEND)
|
10
|
+
checktree.add('Really really long thing', 3, 0, Newt::ARG_APPEND)
|
11
|
+
checktree.add('number 5', 5, Newt::FLAG_SELECTED, Newt::ARG_APPEND)
|
12
|
+
checktree.add('number 6', 6, 0, Newt::ARG_APPEND)
|
13
|
+
checktree.add('number 7', 7, Newt::FLAG_SELECTED, Newt::ARG_APPEND)
|
14
|
+
checktree.add('number 8', 8, 0, Newt::ARG_APPEND)
|
15
|
+
checktree.add('number 9', 9, 0, Newt::ARG_APPEND)
|
16
|
+
checktree.add('number 10', 10, Newt::FLAG_SELECTED, Newt::ARG_APPEND)
|
17
|
+
checktree.add('number 11', 11, 0, Newt::ARG_APPEND)
|
18
|
+
checktree.add('number 12', 12, Newt::FLAG_SELECTED, Newt::ARG_APPEND)
|
19
|
+
|
20
|
+
checktree.add('Colors', 1, 0, 0)
|
21
|
+
checktree.add('Red', 100, 0, 0, Newt::ARG_APPEND)
|
22
|
+
checktree.add('White', 101, 0, 0, Newt::ARG_APPEND)
|
23
|
+
checktree.add('Blue', 102, 0, 0, Newt::ARG_APPEND)
|
24
|
+
|
25
|
+
checktree.add('number 4', 4, 0, 3)
|
26
|
+
|
27
|
+
checktree.add('Single digit', 200, 0, 1, Newt::ARG_APPEND)
|
28
|
+
checktree.add('One', 201, 0, 1, 0, Newt::ARG_APPEND)
|
29
|
+
checktree.add('Two', 202, 0, 1, 0, Newt::ARG_APPEND)
|
30
|
+
checktree.add('Three', 203, 0, 1, 0, Newt::ARG_APPEND)
|
31
|
+
checktree.add('Four', 204, 0, 1, 0, Newt::ARG_APPEND)
|
32
|
+
|
33
|
+
checktree.add('Double digit', 300, 0, 1, Newt::ARG_APPEND)
|
34
|
+
checktree.add('Ten', 210, 0, 1, 1, Newt::ARG_APPEND)
|
35
|
+
checktree.add('Eleven', 211, 0, 1, 1, Newt::ARG_APPEND)
|
36
|
+
checktree.add('Twelve', 212, 0, 1, 1, Newt::ARG_APPEND)
|
37
|
+
checktree.add('Thirteen', 213, 0, 1, 1, Newt::ARG_APPEND)
|
38
|
+
|
39
|
+
button = Newt::Button.new(-1, -1, 'Exit')
|
40
|
+
|
41
|
+
grid = Newt::Grid.new(1, 2)
|
42
|
+
grid.set_field(0, 0, Newt::GRID_COMPONENT, checktree, 0, 0, 0, 1,
|
43
|
+
Newt::ANCHOR_RIGHT, 0)
|
44
|
+
grid.set_field(0, 1, Newt::GRID_COMPONENT, button, 0, 0, 0, 0, 0, 0)
|
45
|
+
|
46
|
+
grid.wrapped_window('Checkbox Tree Test')
|
47
|
+
|
48
|
+
form = Newt::Form.new
|
49
|
+
form.add(checktree, button)
|
50
|
+
|
51
|
+
form.run
|
52
|
+
|
53
|
+
Newt::Screen.finish
|