wet-winobj 0.1-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/src/wet-winobj.rb +41 -0
- data/src/wet/constants/process.rb +10 -0
- data/src/wet/constants/testconstants.rb +1 -0
- data/src/wet/constants/winconstants.rb +73 -0
- data/src/wet/constants/wincontrolconst.rb +60 -0
- data/src/wet/exceptions/CompileExceptions.rb +31 -0
- data/src/wet/exceptions/RuntimeExceptions.rb +20 -0
- data/src/wet/utils/ArrayUtils.rb +52 -0
- data/src/wet/utils/CompileUtils.rb +43 -0
- data/src/wet/utils/FileUtils.rb +75 -0
- data/src/wet/utils/TextUtils.rb +63 -0
- data/src/wet/winobjects/AppWindow.rb +144 -0
- data/src/wet/winobjects/WinButton.rb +101 -0
- data/src/wet/winobjects/WinCheckbox.rb +84 -0
- data/src/wet/winobjects/WinComboBox.rb +70 -0
- data/src/wet/winobjects/WinDialog.rb +112 -0
- data/src/wet/winobjects/WinEdit.rb +125 -0
- data/src/wet/winobjects/WinLabel.rb +112 -0
- data/src/wet/winobjects/WinObjects.rb +35 -0
- data/src/wet/winobjects/WinRadio.rb +75 -0
- data/src/wet/winobjects/WinUtils.rb +231 -0
- data/src/wet/winobjects/Window.rb +537 -0
- data/tests/README +5 -0
- data/tests/TestAppWindow.rb +96 -0
- data/tests/TestButtonsWindow.rb +71 -0
- data/tests/TestCheckbox.rb +113 -0
- data/tests/TestCombo.rb +53 -0
- data/tests/TestDialog.rb +111 -0
- data/tests/TestLabel.rb +79 -0
- data/tests/TestRadio.rb +82 -0
- data/tests/TestWebEdit.rb +100 -0
- data/tests/wet-winobj-tests.rb +325 -0
- metadata +75 -0
data/tests/TestLabel.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'wet-winobj-tests.rb'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
class TestLabel < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
if !$is_init
|
8
|
+
$common_wxw = ControlWindow.new()
|
9
|
+
$common_wxw.create("Label Tester")
|
10
|
+
$st_panel = StaticPanel.new($common_wxw.get_frame)
|
11
|
+
#st_panel = StatusPanel.new($common_wxw.get_frame)
|
12
|
+
$common_wxw.show()
|
13
|
+
$hwnd = $common_wxw.hwnd
|
14
|
+
$is_init = true
|
15
|
+
end
|
16
|
+
#$common_wxw.main_loop
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_get_by_text()
|
20
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => "S&le")
|
21
|
+
assert_equal(lbl1.hwnd, $st_panel.hwnd('lbl1'))
|
22
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => "Second")
|
23
|
+
assert_equal(lbl1.hwnd, $st_panel.hwnd('lbl2'))
|
24
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => "Third")
|
25
|
+
assert_equal(lbl1.hwnd, $st_panel.hwnd('lbl3'))
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_get_by_text_regex()
|
29
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => /^S\&/)
|
30
|
+
assert_equal(lbl1.hwnd, $st_panel.hwnd('lbl1'))
|
31
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => /nd$/)
|
32
|
+
assert_equal(lbl1.hwnd, $st_panel.hwnd('lbl2'))
|
33
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => /T.*d/)
|
34
|
+
assert_equal(lbl1.hwnd, $st_panel.hwnd('lbl3'))
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_get_text()
|
38
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => /^S\&/)
|
39
|
+
assert_equal(lbl1.text, "S&le")
|
40
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => /nd$/)
|
41
|
+
assert_equal(lbl1.text, "Second")
|
42
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => /T.*d/)
|
43
|
+
assert_equal(lbl1.text, "Third")
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_get_display_text()
|
47
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => /^S\&/)
|
48
|
+
assert_equal(lbl1.display_text, "S&le")
|
49
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => /nd$/)
|
50
|
+
assert_equal(lbl1.display_text, "Second")
|
51
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => /T.*d/)
|
52
|
+
assert_equal(lbl1.display_text, "Third")
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_get_labelled()
|
56
|
+
#As of now you have to find the label only by first finding the parent as
|
57
|
+
#Wet object
|
58
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => "S&le")
|
59
|
+
ctl1 = lbl1.labelled_control
|
60
|
+
assert_equal($st_panel.hwnd('txt1'), ctl1.hwnd)
|
61
|
+
|
62
|
+
# Last label
|
63
|
+
lbl2 = AppWindow.new($hwnd).win_label("text" => "Third")
|
64
|
+
ctl2 = lbl2.labelled_control
|
65
|
+
assert_equal($st_panel.hwnd('cmb1'), ctl2.hwnd)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_get_labelled_negative_static_next()
|
69
|
+
lbl1 = AppWindow.new($hwnd).win_label("text" => "Second")
|
70
|
+
ctl1 = lbl1.labelled_control
|
71
|
+
#assert_nil(ctl1)
|
72
|
+
assert(false, "Get labelled control is not very smart yet!")
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_get_labelled_negative_control_in_another_container()
|
76
|
+
assert(false, "Get labelled control is not very smart yet!")
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
data/tests/TestRadio.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'wet-winobj-tests.rb'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
class TestRadio < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
if !$is_init
|
8
|
+
$common_wxw = ControlWindow.new()
|
9
|
+
$common_wxw.create("Radio Tester")
|
10
|
+
$radio_panel1 = RadioPanel.new($common_wxw.get_frame)
|
11
|
+
$common_wxw.show()
|
12
|
+
$hwnd = $common_wxw.hwnd
|
13
|
+
$is_init = true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_get_by_text()
|
18
|
+
wtr = Window.new($hwnd).win_radio("text" => "First value")
|
19
|
+
assert_equal(wtr.hwnd, $radio_panel1.hwnd('b1'))
|
20
|
+
wtr = Window.new($hwnd).win_radio("text" => "Third value")
|
21
|
+
assert_equal(wtr.hwnd, $radio_panel1.hwnd('b3'))
|
22
|
+
wtr = Window.new($hwnd).win_radio("text" => "Fourth values")
|
23
|
+
assert_equal(wtr.hwnd, $radio_panel1.hwnd('b4'))
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_get_by_text_regex()
|
27
|
+
wtr = Window.new($hwnd).win_radio("text" => /^Fir/)
|
28
|
+
assert_equal(wtr.hwnd, $radio_panel1.hwnd('b1'))
|
29
|
+
wtr = Window.new($hwnd).win_radio("text" => /Th.*va.*e/)
|
30
|
+
assert_equal(wtr.hwnd, $radio_panel1.hwnd('b3'))
|
31
|
+
wtr = Window.new($hwnd).win_radio("text" => /s$/)
|
32
|
+
assert_equal(wtr.hwnd, $radio_panel1.hwnd('b4'))
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_get_text()
|
36
|
+
wtr = Window.new($hwnd).win_radio("text" => /^Fir/)
|
37
|
+
assert_equal(wtr.text, 'First value')
|
38
|
+
wtr = Window.new($hwnd).win_radio("text" => /Th.*va.*e/)
|
39
|
+
assert_equal(wtr.text, 'Third value')
|
40
|
+
wtr = Window.new($hwnd).win_radio("text" => /s$/)
|
41
|
+
assert_equal(wtr.text, 'Fourth values')
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_set()
|
45
|
+
b1 = WinRadio.new($radio_panel1.hwnd('b2'))
|
46
|
+
Thread.new() {Thread.pass; $common_wxw.main_loop}
|
47
|
+
sleep 1
|
48
|
+
b1.set()
|
49
|
+
assert($radio_panel1.is_set('b2'))
|
50
|
+
assert(!$radio_panel1.is_set('b1'))
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_set_different_group()
|
54
|
+
b1 = WinRadio.new($radio_panel1.hwnd('b2'))
|
55
|
+
b2 = WinRadio.new($radio_panel1.hwnd('b4'))
|
56
|
+
Thread.new() {Thread.pass; $common_wxw.main_loop}
|
57
|
+
sleep 1
|
58
|
+
b1.set()
|
59
|
+
b2.set()
|
60
|
+
assert($radio_panel1.is_set('b4'))
|
61
|
+
assert(!$radio_panel1.is_set('b3'))
|
62
|
+
#Verify that setting a radio in one group has no effect on other groups
|
63
|
+
assert($radio_panel1.is_set('b2'))
|
64
|
+
assert(!$radio_panel1.is_set('b1'))
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_is_set()
|
68
|
+
b1 = WinRadio.new($radio_panel1.hwnd('b2'))
|
69
|
+
b2 = WinRadio.new($radio_panel1.hwnd('b1'))
|
70
|
+
Thread.new() {Thread.pass; $common_wxw.main_loop}
|
71
|
+
sleep 1
|
72
|
+
b1.set()
|
73
|
+
assert(b1.is_set())
|
74
|
+
assert(!b2.is_set())
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def teardown()
|
79
|
+
$common_wxw.exit_main_loop
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'wet-winobj-tests.rb'
|
2
|
+
require 'timeout'
|
3
|
+
|
4
|
+
class TestWebEdit < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
if !$is_init
|
8
|
+
$common_wxw = ControlWindow.new()
|
9
|
+
$common_wxw.create("Edit Tester")
|
10
|
+
$tx_panel = EditPanel.new($common_wxw.get_frame)
|
11
|
+
$common_wxw.show()
|
12
|
+
$hwnd = $common_wxw.hwnd
|
13
|
+
$is_init = true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_get_by_label()
|
18
|
+
txt1 = Window.new($hwnd).win_edit("label" => "Tex&t1")
|
19
|
+
assert_equal(txt1.hwnd, $tx_panel.hwnd('txt1'))
|
20
|
+
|
21
|
+
txt2 = Window.new($hwnd).win_edit("label" => "Se&cond Text")
|
22
|
+
assert_equal(txt2.hwnd, $tx_panel.hwnd('txt2'))
|
23
|
+
|
24
|
+
txt3 = Window.new($hwnd).win_edit("label" => "Thir&d")
|
25
|
+
assert_equal(txt3.hwnd, $tx_panel.hwnd('txt3'))
|
26
|
+
|
27
|
+
txt4 = Window.new($hwnd).win_edit("label" => "Fourth te&xt")
|
28
|
+
assert_equal(txt4.hwnd, $tx_panel.hwnd('txt4'))
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_get_by_label_regex()
|
32
|
+
txt1 = Window.new($hwnd).win_edit("label" => /^Te/)
|
33
|
+
assert_equal(txt1.hwnd, $tx_panel.hwnd('txt1'))
|
34
|
+
|
35
|
+
txt2 = Window.new($hwnd).win_edit("label" => /ext$/)
|
36
|
+
assert_equal(txt2.hwnd, $tx_panel.hwnd('txt2'))
|
37
|
+
|
38
|
+
txt3 = Window.new($hwnd).win_edit("label" => /.*&d.*/)
|
39
|
+
assert_equal(txt3.hwnd, $tx_panel.hwnd('txt3'))
|
40
|
+
|
41
|
+
txt4 = Window.new($hwnd).win_edit("label" => /F.*xt/)
|
42
|
+
assert_equal(txt4.hwnd, $tx_panel.hwnd('txt4'))
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_is_password()
|
46
|
+
txt1 = Window.new($hwnd).win_edit("label" => "Tex&t1")
|
47
|
+
assert(!txt1.is_password)
|
48
|
+
|
49
|
+
txt3 = Window.new($hwnd).win_edit("label" => "Thir&d")
|
50
|
+
assert(txt3.is_password)
|
51
|
+
|
52
|
+
txt4 = Window.new($hwnd).win_edit("label" => "Fourth te&xt")
|
53
|
+
assert(!txt4.is_password)
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_is_readonly()
|
57
|
+
txt1 = Window.new($hwnd).win_edit("label" => "Tex&t1")
|
58
|
+
assert(!txt1.is_readonly)
|
59
|
+
|
60
|
+
txt3 = Window.new($hwnd).win_edit("label" => "Thir&d")
|
61
|
+
assert(!txt3.is_readonly)
|
62
|
+
|
63
|
+
txt4 = Window.new($hwnd).win_edit("label" => "Fourth te&xt")
|
64
|
+
assert(txt4.is_readonly)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_set()
|
68
|
+
txt1 = Window.new($hwnd).win_edit("label" => "Tex&t1")
|
69
|
+
txt1.set("new text")
|
70
|
+
assert_equal($tx_panel.get_text('txt1'), "new text")
|
71
|
+
|
72
|
+
txt2 = Window.new($hwnd).win_edit("label" => "Thir&d")
|
73
|
+
txt2.set("password text")
|
74
|
+
assert_equal($tx_panel.get_text('txt3'), "password text")
|
75
|
+
|
76
|
+
assert_equal($tx_panel.get_text('txt4'), "readonly")
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_get()
|
80
|
+
txt1 = Window.new($hwnd).win_edit("label" => "Tex&t1")
|
81
|
+
assert_equal(txt1.text, "abcdef")
|
82
|
+
|
83
|
+
txt2 = Window.new($hwnd).win_edit("label" => "Se&cond Text")
|
84
|
+
assert_equal(txt2.text, "")
|
85
|
+
|
86
|
+
txt3 = Window.new($hwnd).win_edit("label" => "Thir&d")
|
87
|
+
assert_equal(txt3.text, "1234")
|
88
|
+
|
89
|
+
txt4 = Window.new($hwnd).win_edit("label" => "Fourth te&xt")
|
90
|
+
assert_equal(txt4.text, "readonly")
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def teardown()
|
95
|
+
$tx_panel.set_text('txt1', "abcdef")
|
96
|
+
$tx_panel.set_text('txt2', "")
|
97
|
+
$tx_panel.set_text('txt3', "1234")
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,325 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'wxruby'
|
3
|
+
require 'wet-winobj'
|
4
|
+
include Wx
|
5
|
+
include Wet::Winobjects
|
6
|
+
|
7
|
+
WET_WIN_WIDTH = 640
|
8
|
+
WET_WIN_HEIGHT = 480
|
9
|
+
|
10
|
+
WET_B1 = 21
|
11
|
+
WET_B2 = 22
|
12
|
+
WET_B3 = 23
|
13
|
+
WET_B4 = 24
|
14
|
+
|
15
|
+
WET_CB1 = 31
|
16
|
+
WET_CB2 = 32
|
17
|
+
WET_CB3 = 33
|
18
|
+
|
19
|
+
WET_RB1 = 41
|
20
|
+
WET_RB2 = 42
|
21
|
+
WET_RB3 = 43
|
22
|
+
WET_RB4 = 44
|
23
|
+
|
24
|
+
WET_ST1 = 51
|
25
|
+
WET_ST2 = 52
|
26
|
+
WET_ST3 = 53
|
27
|
+
WET_ST4 = 54
|
28
|
+
|
29
|
+
WET_ST_T1 = 1051
|
30
|
+
WET_ST_T2 = 1052
|
31
|
+
WET_ST_T3 = 1053
|
32
|
+
WET_ST_T4 = 1054
|
33
|
+
WET_ST_CM1 = 1151
|
34
|
+
WET_ST_CM2 = 1152
|
35
|
+
WET_ST_CM3 = 1153
|
36
|
+
WET_ST_CM4 = 1154
|
37
|
+
|
38
|
+
WET_TX1 = 61
|
39
|
+
WET_TX2 = 62
|
40
|
+
WET_TX3 = 63
|
41
|
+
WET_TX4 = 64
|
42
|
+
WET_TX_LBL1 = 1061
|
43
|
+
WET_TX_LBL2 = 1062
|
44
|
+
WET_TX_LBL3 = 1063
|
45
|
+
WET_TX_LBL4 = 1064
|
46
|
+
|
47
|
+
WET_CMB1 = 71
|
48
|
+
WET_CMB2 = 72
|
49
|
+
WET_CMB3 = 73
|
50
|
+
WET_CMB4 = 74
|
51
|
+
WET_CMB_LBL1 = 1071
|
52
|
+
WET_CMB_LBL2 = 1072
|
53
|
+
WET_CMB_LBL3 = 1073
|
54
|
+
WET_CMB_LBL4 = 1074
|
55
|
+
|
56
|
+
WET_RBOX1 = 1041
|
57
|
+
WET_RBOX2 = 1042
|
58
|
+
|
59
|
+
|
60
|
+
class WetWxWindow < App
|
61
|
+
|
62
|
+
def show(title, style = DEFAULT_FRAME_STYLE)
|
63
|
+
@frame = Frame.new(nil, -1, title, DEFAULT_POSITION, Size.new(WET_WIN_WIDTH, WET_WIN_HEIGHT), style)
|
64
|
+
@frame.show
|
65
|
+
end
|
66
|
+
|
67
|
+
def hwnd
|
68
|
+
return @frame.get_handle
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
class ControlWindow < App
|
74
|
+
|
75
|
+
def create(title)
|
76
|
+
@frame = Frame.new(nil, -1, title, DEFAULT_POSITION, Size.new(WET_WIN_WIDTH, WET_WIN_HEIGHT))
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_frame()
|
80
|
+
return @frame
|
81
|
+
end
|
82
|
+
|
83
|
+
def show()
|
84
|
+
@frame.show
|
85
|
+
end
|
86
|
+
|
87
|
+
def hwnd
|
88
|
+
return @frame.get_handle
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
class WetRadioButton < RadioButton
|
94
|
+
def initialize(par, id, label, pos)
|
95
|
+
super(par, id, label, pos)
|
96
|
+
evt_radiobutton(id) {|event| on_cb(event)}
|
97
|
+
@par = par
|
98
|
+
end
|
99
|
+
|
100
|
+
def on_cb(event)
|
101
|
+
puts "clicked...#{event.get_id}"
|
102
|
+
event.methods.each do |m|
|
103
|
+
puts m
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class RadioPanel < Panel
|
110
|
+
def initialize(parent, y=20)
|
111
|
+
super(parent)
|
112
|
+
box1 = RadioBox.new(self, WET_RBOX1, "", Point.new(0, 5), Size.new(200, 50), [], RA_HORIZONTAL)
|
113
|
+
|
114
|
+
@b1 = WetRadioButton.new(box1, WET_RB1, "First value", Point.new(10, y))
|
115
|
+
@b2 = WetRadioButton.new(box1, WET_RB2, "Second value", Point.new(100, y))
|
116
|
+
|
117
|
+
box2 = RadioBox.new(self, WET_RBOX2, "", Point.new(240, 5), Size.new(200, 50), [], RA_HORIZONTAL)
|
118
|
+
@b3 = WetRadioButton.new(box2, WET_RB3, "Third value", Point.new(10, y))
|
119
|
+
@b4 = WetRadioButton.new(box2, WET_RB4, "Fourth values", Point.new(100, y))
|
120
|
+
|
121
|
+
@s = StatusPanel.new(self)
|
122
|
+
end
|
123
|
+
|
124
|
+
def set_status(text)
|
125
|
+
@s.set_value(text)
|
126
|
+
end
|
127
|
+
|
128
|
+
def hwnd(btn)
|
129
|
+
return eval("@#{btn}.get_handle()")
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_status()
|
133
|
+
return @s.get_value()
|
134
|
+
end
|
135
|
+
|
136
|
+
def set(btn)
|
137
|
+
eval("@#{btn}.set_value(true)")
|
138
|
+
end
|
139
|
+
|
140
|
+
def is_set(btn)
|
141
|
+
return eval("@#{btn}.get_value()")
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
class WetCheckBox < CheckBox
|
148
|
+
def initialize(par, id, label, pos)
|
149
|
+
super(par, id, label, pos)
|
150
|
+
evt_checkbox(id) {|event| on_cb(event)}
|
151
|
+
@par = par
|
152
|
+
end
|
153
|
+
|
154
|
+
def on_cb(event)
|
155
|
+
puts "clicked...#{event.is_checked}"
|
156
|
+
@par.set_status(event.get_id.to_s)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class CBPanel < Panel
|
161
|
+
def initialize(parent)
|
162
|
+
super(parent)
|
163
|
+
@b1 = WetCheckBox.new(self, WET_CB1, "Is Ok", Point.new(10, 20))
|
164
|
+
@b2 = WetCheckBox.new(self, WET_CB2, "Pass?", Point.new(100, 20))
|
165
|
+
@b3 = WetCheckBox.new(self, WET_CB3, "Are you s&ure?", Point.new(200, 20))
|
166
|
+
@s = StatusPanel.new(self)
|
167
|
+
end
|
168
|
+
|
169
|
+
def set_status(text)
|
170
|
+
@s.set_value(text)
|
171
|
+
end
|
172
|
+
|
173
|
+
def hwnd(btn)
|
174
|
+
return eval("@#{btn}.get_handle()")
|
175
|
+
end
|
176
|
+
|
177
|
+
def get_status()
|
178
|
+
return @s.get_value()
|
179
|
+
end
|
180
|
+
|
181
|
+
def set_value(btn, val)
|
182
|
+
eval("@#{btn}.set_value(#{val})")
|
183
|
+
end
|
184
|
+
|
185
|
+
def is_checked(btn)
|
186
|
+
return eval("@#{btn}.is_checked()")
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
class WetButton < Button
|
192
|
+
|
193
|
+
def initialize(par, id, label, pos)
|
194
|
+
super(par, id, label, pos)
|
195
|
+
evt_button(id) {|event| onClick(event)}
|
196
|
+
@par = par
|
197
|
+
end
|
198
|
+
|
199
|
+
def onClick(event)
|
200
|
+
puts "clicked...#{event.get_id}"
|
201
|
+
@par.set_status(event.get_id.to_s)
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
class ButtonPanel < Panel
|
207
|
+
|
208
|
+
def initialize(parent)
|
209
|
+
super(parent)
|
210
|
+
@b1 = WetButton.new(self, WET_B1, "OK", Point.new(10, 20))
|
211
|
+
@b2 = WetButton.new(self, WET_B2, "Cancel", Point.new(100, 20))
|
212
|
+
@b3 = WetButton.new(self, WET_B3, "In the middle", Point.new(200, 20))
|
213
|
+
@b4 = WetButton.new(self, WET_B4, "c&onfused", Point.new(300, 20))
|
214
|
+
@s = StatusPanel.new(self)
|
215
|
+
end
|
216
|
+
|
217
|
+
def set_status(text)
|
218
|
+
@s.set_value(text)
|
219
|
+
end
|
220
|
+
|
221
|
+
def hwnd(btn)
|
222
|
+
return eval("@#{btn}.get_handle()")
|
223
|
+
end
|
224
|
+
|
225
|
+
def get_status()
|
226
|
+
return @s.get_value()
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
class StaticPanel < Panel
|
232
|
+
def initialize(parent)
|
233
|
+
y = 20
|
234
|
+
super(parent, 600, Point.new(0, y), Size.new(WET_WIN_WIDTH-20, 50), STATIC_BORDER )
|
235
|
+
@lbl1 = StaticText.new(self, WET_ST1, "S&le", Point.new(5, 10))
|
236
|
+
@txt1 = TextCtrl.new(self, WET_ST_T1, "", Point.new(60, 10), Size.new(500, 20) )
|
237
|
+
y = 40
|
238
|
+
@lbl2 = StaticText.new(self, WET_ST2, "Second", Point.new(5, y))
|
239
|
+
@lbl3 = StaticText.new(self, WET_ST3, "Third", Point.new(100, y))
|
240
|
+
|
241
|
+
@cmb1 = ComboBox.new(self, WET_ST_CM3, "", Point.new(160, y), Size.new(200, 20))
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
def hwnd(btn)
|
246
|
+
return eval("@#{btn}.get_handle()")
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
class EditPanel < Panel
|
251
|
+
def initialize(parent)
|
252
|
+
super(parent)
|
253
|
+
@lbl1 = StaticText.new(self, WET_TX_LBL1, "Tex&t1", Point.new(10, 20), Size.new(50, 20))
|
254
|
+
@txt1 = TextCtrl.new(self, WET_TX1, "abcdef", Point.new(70, 20), Size.new(100, 20) )
|
255
|
+
@lbl2 = StaticText.new(self, WET_TX_LBL2, "Se&cond Text", Point.new(200, 20))
|
256
|
+
@txt2 = TextCtrl.new(self, WET_TX2, "", Point.new(300, 20), Size.new(100, 20) )
|
257
|
+
@lbl3 = StaticText.new(self, WET_TX_LBL3, "Thir&d", Point.new(10, 50))
|
258
|
+
@txt3 = TextCtrl.new(self, WET_TX3, "1234", Point.new(70, 50), DEFAULT_SIZE, TE_PASSWORD)
|
259
|
+
@lbl4 = StaticText.new(self, WET_TX_LBL4, "Fourth te&xt", Point.new(10, 80))
|
260
|
+
@txt4 = TextCtrl.new(self, WET_TX4, "readonly", Point.new(70, 80), DEFAULT_SIZE , TE_READONLY)
|
261
|
+
end
|
262
|
+
|
263
|
+
def hwnd(btn)
|
264
|
+
return eval("@#{btn}.get_handle()")
|
265
|
+
end
|
266
|
+
|
267
|
+
def get_text(txt)
|
268
|
+
return eval("@#{txt}.get_value()")
|
269
|
+
end
|
270
|
+
|
271
|
+
def set_text(txt, val)
|
272
|
+
return eval("@#{txt}.set_value(val)")
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
class ComboPanel < Panel
|
278
|
+
def initialize(parent)
|
279
|
+
super(parent)
|
280
|
+
@lbl1 = StaticText.new(self, WET_CMB_LBL1, "Tex&t1", Point.new(10, 20), Size.new(50, 20))
|
281
|
+
@cmb1 = ComboBox.new(self, WET_CMB1, "abcdef", Point.new(70, 20), Size.new(100, 20) )
|
282
|
+
@lbl2 = StaticText.new(self, WET_CMB_LBL2, "Se&cond Text", Point.new(200, 20))
|
283
|
+
@cmb2 = ComboBox.new(self, WET_CMB2, "", Point.new(300, 20), Size.new(100, 20) )
|
284
|
+
@lbl3 = StaticText.new(self, WET_CMB_LBL3, "Thir&d", Point.new(10, 50))
|
285
|
+
@cmb3 = ComboBox.new(self, WET_CMB3, "1234", Point.new(70, 50))
|
286
|
+
@lbl4 = StaticText.new(self, WET_CMB_LBL4, "Cho&ice box", Point.new(200, 50))
|
287
|
+
@cmb4 = Choice.new(self, WET_CMB4, Point.new(300, 50), Size.new(100, 20) , \
|
288
|
+
["one", "two", "three", "four"])
|
289
|
+
end
|
290
|
+
|
291
|
+
def hwnd(btn)
|
292
|
+
return eval("@#{btn}.get_handle()")
|
293
|
+
end
|
294
|
+
|
295
|
+
def get_value(cmb)
|
296
|
+
return eval("@#{cmb}.get_value()")
|
297
|
+
end
|
298
|
+
|
299
|
+
def set_value(cmb, val)
|
300
|
+
return eval("@#{cmb}.set_value(val)")
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
class StatusPanel < Panel
|
305
|
+
|
306
|
+
def initialize(parent)
|
307
|
+
y = 60
|
308
|
+
super(parent, 600, Point.new(0, y), Size.new(WET_WIN_WIDTH-20, 50), STATIC_BORDER )
|
309
|
+
@s1 = StaticText.new(self, 601, "S&tatus", Point.new(5, 10))
|
310
|
+
@t1 = TextCtrl.new(self, 602, "", Point.new(60, 10), Size.new(500, 20) )
|
311
|
+
end
|
312
|
+
|
313
|
+
def set_value(text)
|
314
|
+
@t1.set_value(text)
|
315
|
+
end
|
316
|
+
|
317
|
+
def get_value()
|
318
|
+
@t1.get_value()
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|
322
|
+
|
323
|
+
class CheckPanel < Panel
|
324
|
+
|
325
|
+
end
|