rubydx 0.0.1alpha.1 → 0.0.1alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/docs/MessageBox.md +2 -2
- data/lib/rubydx/version.rb +1 -1
- data/lib/rubydx/windows_api/message_box.rb +126 -3
- data/spec/rubydx/windows_api/message_box_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmFiNDZhZmM1Yzg3ZTIyYjRlN2RjYWE3YzM5YWExY2Q0OWY5Yzg3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzQ5YWNhMzg5MWYzMGMwNjhjZDEyZGQ5Mjk1NWY4MGZjMTZlYWIyZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODI5ZjI1MjIxNTg4N2Q1Y2NmOWE3NjQ3N2FlYzJhYmI1ZWUwM2ZkMjhiYmFl
|
10
|
+
OGExYTM0OWUzOWZiZWUzYTdmYjYwMWRlOTRjZTRiN2FmMmFhMDkzMDFjNDRl
|
11
|
+
ZDcwY2ViNmFjNjJiMGFkN2Q1N2NjZjc5MDUxMDVkOGE3NDE4NGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTQ0ZjJiMDQzZDBkM2FhNmRhYjAyMGVmZjBjYmYyMWIxZjI4NDc5ZjkzMDY2
|
14
|
+
YTA2YmMyNjM0ODIxMzgwNTE0MTMxMTQ2MWFiODI1Mjg0MGM4MmRjYzhkNzU2
|
15
|
+
YmZiN2Y3NzEwYWNhMWVjYzAxYWQxN2VjNjY2MDA3NWU2Zjg3NGI=
|
data/docs/MessageBox.md
CHANGED
@@ -4,7 +4,7 @@ MessageBox
|
|
4
4
|
Call for
|
5
5
|
|
6
6
|
```ruby
|
7
|
-
def message_box(text, caption = nil, window = nil,
|
7
|
+
def message_box(text, caption = nil, window = nil, styles = [])
|
8
8
|
```
|
9
9
|
|
10
10
|
Exapmple Uses:
|
@@ -16,7 +16,7 @@ Rubydx::WindowsApi.message_box "Hi"
|
|
16
16
|
more Example
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
Rubydx::WindowsApi.message_box("This is Test Message!!", "Nice caption?", nil,
|
19
|
+
Rubydx::WindowsApi.message_box("This is Test Message!!", "Nice caption?", nil, [:yes, :no])
|
20
20
|
```
|
21
21
|
|
22
22
|
More API Details.
|
data/lib/rubydx/version.rb
CHANGED
@@ -1,12 +1,58 @@
|
|
1
1
|
module Rubydx
|
2
2
|
class WindowsApi
|
3
3
|
module MessageBox
|
4
|
-
|
5
|
-
|
4
|
+
#
|
5
|
+
# = Call for MessageBox() Win32 API.
|
6
|
+
#
|
7
|
+
# Exapmple Uses:
|
8
|
+
#
|
9
|
+
# Rubydx::WindowsApi.message_box "Hi"
|
10
|
+
#
|
11
|
+
# more Example
|
12
|
+
#
|
13
|
+
# Rubydx::WindowsApi.message_box("This is Test Message!!", "Nice caption?", nil, 0x40)
|
14
|
+
#
|
15
|
+
# Native API Reference (MSDN) for
|
16
|
+
#
|
17
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx
|
18
|
+
#
|
19
|
+
# [text]
|
20
|
+
# Dialog Message (Detail for lpText)
|
21
|
+
#
|
22
|
+
# [caption]
|
23
|
+
# Dialog Title (Detail for lpCaption)
|
24
|
+
#
|
25
|
+
# [window]
|
26
|
+
# <em><b>currently not Implemented</b></em>, Window class.
|
27
|
+
# not Specified in parent window free dialog.
|
28
|
+
#
|
29
|
+
# [options]
|
30
|
+
# <b>Style Options.</b> specifiable many in Array and by symbols.
|
31
|
+
#
|
32
|
+
# - +:cancel+: show <b>Cancel</b> Button.
|
33
|
+
# - +:yes+: show <b>Yes</b> and <b>No</b> Button.
|
34
|
+
# - +:abort+: <b>Abort</b>, <b>Retry</b>, <b>Ignore</b> Buttons Dialog.
|
35
|
+
# - +:retry+: <b>Retry</b>, <b>Cancel</b> Buttons Dialog.
|
36
|
+
# - +:continue+: <b>Cancel</b>, <b>Retry</b>, <b>Continue</b> Buttons Dialog.
|
37
|
+
#
|
38
|
+
# And dialog Icon type for
|
39
|
+
#
|
40
|
+
# - +:icon_information+: or +:information+: are <b>Information</b> <tt>(!)</tt>(Blue color) Icon type.
|
41
|
+
# - +:icon_question+: or +:question+: or +:ask+: are <b>Question</b> <tt>(?)</tt>(Blue color) Icon type.
|
42
|
+
# - +:icon_exclamation+: or +:icon_warning+: or +:exclamation+: or +:warning+: are <b>Warning</b> <tt>(i)</tt>(Yellow color) Icon type.
|
43
|
+
# - +:icon_hand+: or +:icon_stop+: or +:icon_error+: or +:hand+: or +:stop+: or +:error+: are <b>Error</b> <tt>(X)</tt>(Red color) Icon type.
|
44
|
+
#
|
45
|
+
# [Returned Value]
|
46
|
+
# For selected Button to Symbol. Are any of
|
47
|
+
# +:ok+, +:cancel+, +:abort+, +:retry+, +:ignore+, +:yes+, +:no+, +:try_again+, +:continue+.
|
48
|
+
#
|
49
|
+
def message_box(text, caption = nil, window = nil, options = [])
|
6
50
|
hwnd = ( window ? window.handle : 0 )
|
7
51
|
|
8
52
|
func = Win32API.new(LIB, FUNCNAME, PARAMS, RET)
|
9
|
-
func.call(hwnd, text, caption,
|
53
|
+
ret = func.call(hwnd, text, caption, options_to_value(options))
|
54
|
+
|
55
|
+
ret_to_symbol(ret)
|
10
56
|
end
|
11
57
|
|
12
58
|
private
|
@@ -14,6 +60,83 @@ module Rubydx
|
|
14
60
|
FUNCNAME = "MessageBox"
|
15
61
|
PARAMS = %w(p p p i)
|
16
62
|
RET = "i"
|
63
|
+
|
64
|
+
def options_to_value(options)
|
65
|
+
value = buttons_value(options)
|
66
|
+
value |= icon_value(options)
|
67
|
+
value
|
68
|
+
end
|
69
|
+
|
70
|
+
def icon_value(styles)
|
71
|
+
return 0x30 if (styles.include? :icon_exclamation) ||
|
72
|
+
(styles.include? :icon_warning) ||
|
73
|
+
(styles.include? :exclamation) ||
|
74
|
+
(styles.include? :warning) ||
|
75
|
+
(styles.include? :warn)
|
76
|
+
return 0x40 if (styles.include? :icon_information) ||
|
77
|
+
(styles.include? :icon_asterisk) ||
|
78
|
+
(styles.include? :information)
|
79
|
+
return 0x20 if (styles.include? :icon_question) ||
|
80
|
+
(styles.include? :question) ||
|
81
|
+
(styles.include? :ask)
|
82
|
+
return 0x10 if (styles.include? :icon_stop) ||
|
83
|
+
(styles.include? :stop) ||
|
84
|
+
(styles.include? :icon_error) ||
|
85
|
+
(styles.include? :error) ||
|
86
|
+
(styles.include? :icon_hand) ||
|
87
|
+
(styles.include? :hand)
|
88
|
+
end
|
89
|
+
|
90
|
+
def buttons_value(styles)
|
91
|
+
if styles.include? :yes
|
92
|
+
if styles.include? :cancel
|
93
|
+
0x03
|
94
|
+
else
|
95
|
+
0x04
|
96
|
+
end
|
97
|
+
elsif styles.include? :cancel
|
98
|
+
0x01
|
99
|
+
elsif styles.include? :abort
|
100
|
+
0x02
|
101
|
+
elsif styles.include? :retry
|
102
|
+
0x05
|
103
|
+
elsif styles.include? :continue
|
104
|
+
0x06
|
105
|
+
else
|
106
|
+
0
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def ret_to_symbol(ret)
|
111
|
+
case ret
|
112
|
+
|
113
|
+
when 0 then
|
114
|
+
:failed_function
|
115
|
+
|
116
|
+
when 1 then
|
117
|
+
:ok
|
118
|
+
when 2 then
|
119
|
+
:cancel
|
120
|
+
when 3 then
|
121
|
+
:abort
|
122
|
+
when 4 then
|
123
|
+
:retry
|
124
|
+
when 5 then
|
125
|
+
:ignore
|
126
|
+
when 6 then
|
127
|
+
:yes
|
128
|
+
when 7 then
|
129
|
+
:no
|
130
|
+
|
131
|
+
when 10 then
|
132
|
+
:try_again
|
133
|
+
when 11 then
|
134
|
+
:continue
|
135
|
+
|
136
|
+
else
|
137
|
+
:unknown
|
138
|
+
end
|
139
|
+
end
|
17
140
|
end
|
18
141
|
end
|
19
142
|
end
|
@@ -4,11 +4,11 @@ describe Rubydx::WindowsApi::MessageBox do
|
|
4
4
|
subject do
|
5
5
|
|
6
6
|
Rubydx::WindowsApi.message_box(
|
7
|
-
"This
|
8
|
-
"
|
7
|
+
"This dialog shown expected?",
|
8
|
+
"RSpec",
|
9
9
|
nil,
|
10
|
-
|
10
|
+
[:yes, :no, :cancel, :icon_question]
|
11
11
|
)
|
12
12
|
end
|
13
|
-
it { should eq
|
13
|
+
it { should eq :yes }
|
14
14
|
end
|