vruby 2004.08.07
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/lib/vr/clipboard.rb +107 -0
- data/lib/vr/compat/rubycompat.rb +18 -0
- data/lib/vr/compat/vrcomctl.rb +12 -0
- data/lib/vr/compat/vrcontrol.rb +50 -0
- data/lib/vr/compat/vrmmedia.rb +24 -0
- data/lib/vr/contrib/inifile.rb +111 -0
- data/lib/vr/contrib/msgboxconst.rb +55 -0
- data/lib/vr/contrib/toolbar.rb +378 -0
- data/lib/vr/contrib/vrctlcolor.rb +110 -0
- data/lib/vr/contrib/vrhotkey.rb +35 -0
- data/lib/vr/contrib/vrlistviewex.rb +71 -0
- data/lib/vr/contrib/vrwincomponent.rb +54 -0
- data/lib/vr/dragdropformat.rb +210 -0
- data/lib/vr/handlers.rd +5 -0
- data/lib/vr/rscutil.rb +170 -0
- data/lib/vr/sysmod.rb +250 -0
- data/lib/vr/vractivex.rb +56 -0
- data/lib/vr/vrclipboard.rb +55 -0
- data/lib/vr/vrcomctl.rb +1779 -0
- data/lib/vr/vrcontrol.rb +1326 -0
- data/lib/vr/vrdde.rb +625 -0
- data/lib/vr/vrddrop.rb +191 -0
- data/lib/vr/vrdialog.rb +403 -0
- data/lib/vr/vrhandler.rb +196 -0
- data/lib/vr/vrlayout.old.rb +209 -0
- data/lib/vr/vrlayout.rb +174 -0
- data/lib/vr/vrlayout2.rb +340 -0
- data/lib/vr/vrmmedia.rb +289 -0
- data/lib/vr/vrolednd.rb +193 -0
- data/lib/vr/vrowndraw.rb +109 -0
- data/lib/vr/vrrichedit.rb +335 -0
- data/lib/vr/vrtimer.rb +150 -0
- data/lib/vr/vrtooltip.rb +274 -0
- data/lib/vr/vrtray.rb +144 -0
- data/lib/vr/vrtvitem.rb +120 -0
- data/lib/vr/vrtwopane.rb +226 -0
- data/lib/vr/vruby.rb +1050 -0
- data/lib/vr/winconst.rb +159 -0
- metadata +86 -0
data/lib/vr/vrlayout2.rb
ADDED
@@ -0,0 +1,340 @@
|
|
1
|
+
###################################
|
2
|
+
#
|
3
|
+
# vrlayout2.rb
|
4
|
+
# Programmed by nyasu <nyasu@osk.3web.ne.jp>
|
5
|
+
# Copyright 2000-2003 Nishikawa,Yasuhiro
|
6
|
+
#
|
7
|
+
# More information at http://www.threeweb.ad.jp/~nyasu/software/vrproject.html
|
8
|
+
# (in Japanese)
|
9
|
+
#
|
10
|
+
###################################
|
11
|
+
|
12
|
+
require 'Win32API'
|
13
|
+
|
14
|
+
class VRLayoutFrame
|
15
|
+
=begin
|
16
|
+
== VRLayoutFrame
|
17
|
+
This is a base class for layout frames.
|
18
|
+
|
19
|
+
=== Methods
|
20
|
+
--- register(*controls)
|
21
|
+
Registers controls for LayoutFrame
|
22
|
+
--- move(x,y,w,h)
|
23
|
+
Resizes the layout frame size.
|
24
|
+
This re-calculate the registered controls coordinates.
|
25
|
+
=end
|
26
|
+
|
27
|
+
def initialize()
|
28
|
+
@_vr_layoutclients=[]
|
29
|
+
@_vr_lx,@_vr_ly,@_vr_lw,@_vr_lh = 0,0,10,10
|
30
|
+
end
|
31
|
+
|
32
|
+
def register(*cntl)
|
33
|
+
@_vr_layoutclients.concat cntl
|
34
|
+
_vr_relayout
|
35
|
+
end
|
36
|
+
|
37
|
+
def move(x,y,w,h)
|
38
|
+
@_vr_lx,@_vr_ly,@_vr_lw,@_vr_lh = x,y,w,h
|
39
|
+
_vr_relayout
|
40
|
+
end
|
41
|
+
|
42
|
+
def _vr_relayout
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
class VRVertLayoutFrame < VRLayoutFrame
|
48
|
+
=begin
|
49
|
+
== VRVertLayoutFrame
|
50
|
+
This is a frame that lays out its controls vertically.
|
51
|
+
Use ((|register|)) and ((|move|)) method of VRLayoutFrame
|
52
|
+
=end
|
53
|
+
|
54
|
+
def _vr_relayout
|
55
|
+
return if @_vr_layoutclients.size==0
|
56
|
+
height = @_vr_lh.to_f / @_vr_layoutclients.size
|
57
|
+
@_vr_layoutclients.each_index do |i|
|
58
|
+
@_vr_layoutclients[i].move @_vr_lx, @_vr_ly+height*i,@_vr_lw,height
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class VRHorizLayoutFrame < VRLayoutFrame
|
64
|
+
=begin
|
65
|
+
== VRHorizLayoutFrame
|
66
|
+
This is a frame that lays out its controls horizontally.
|
67
|
+
Use ((|register|)) and ((|move|)) method of VRLayoutFrame
|
68
|
+
=end
|
69
|
+
def _vr_relayout
|
70
|
+
return if @_vr_layoutclients.size==0
|
71
|
+
width = @_vr_lw.to_f / @_vr_layoutclients.size
|
72
|
+
@_vr_layoutclients.each_index do |i|
|
73
|
+
@_vr_layoutclients[i].move @_vr_lx+width*i, @_vr_ly,width,@_vr_lh
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class VRFullsizeLayoutFrame < VRVertLayoutFrame
|
79
|
+
=begin
|
80
|
+
== VRFullsizeLayoutFrame
|
81
|
+
This is a frame that lays out its one control full-sized.
|
82
|
+
Use ((|register|)) and ((|move|)) method of VRLayoutFrame
|
83
|
+
((|register|)) method can be called once and accept only one control.
|
84
|
+
=end
|
85
|
+
|
86
|
+
def register(re)
|
87
|
+
super
|
88
|
+
def self.register
|
89
|
+
raise "register twice"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class VRGridLayoutFrame <VRLayoutFrame
|
95
|
+
def initialize(xs,ys)
|
96
|
+
super()
|
97
|
+
@_vr_xsize=xs
|
98
|
+
@_vr_ysize=ys
|
99
|
+
@_vr_layoutclients = Array.new
|
100
|
+
end
|
101
|
+
def setDimention(xs,ys)
|
102
|
+
@_vr_xsize=x
|
103
|
+
@_vr_ysize=y
|
104
|
+
end
|
105
|
+
|
106
|
+
def register(cntl,x,y,w,h)
|
107
|
+
@_vr_layoutclients.push [cntl,x,y,w,h]
|
108
|
+
_vr_relayout
|
109
|
+
end
|
110
|
+
|
111
|
+
def _vr_relayout
|
112
|
+
@_vr_layoutclients.each do |c|
|
113
|
+
c[0].move( @_vr_lw/@_vr_xsize * c[1],
|
114
|
+
@_vr_lh/@_vr_ysize * c[2],
|
115
|
+
@_vr_lw/@_vr_xsize * c[3],
|
116
|
+
@_vr_lh/@_vr_ysize * c[4])
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
class VRTwoPaneFrame
|
122
|
+
=begin
|
123
|
+
== VRTwoPaneFrame
|
124
|
+
This is a base class for twopane frames.
|
125
|
+
|
126
|
+
=== Methods
|
127
|
+
--- register(*controls)
|
128
|
+
--- move(x,y,w,h)
|
129
|
+
same as ((<VRLayoutFrame>))
|
130
|
+
--- setup(parent)
|
131
|
+
Call this method to combine the frame to the window.
|
132
|
+
--- window_parent
|
133
|
+
Find the first actual window object from its parent or ancestors.
|
134
|
+
=end
|
135
|
+
SPLITTER_MOVEWINDOW=0
|
136
|
+
SPLITTER_DRAWLINE=1
|
137
|
+
@@_vr_paned_splitter_movingmethod = SPLITTER_DRAWLINE
|
138
|
+
|
139
|
+
def splitter_operation_type
|
140
|
+
@@_vr_paned_splitter_movingmethod
|
141
|
+
end
|
142
|
+
|
143
|
+
def splitter_operation_type=(tp)
|
144
|
+
@@_vr_paned_splitter_movingmethod=tp
|
145
|
+
end
|
146
|
+
|
147
|
+
attr :ratio,1
|
148
|
+
attr :separatorheight,1
|
149
|
+
|
150
|
+
Cursor="Size"
|
151
|
+
|
152
|
+
PatBlt = Win32API.new("gdi32","PatBlt","IIIIII","I")
|
153
|
+
|
154
|
+
module VRTwoPaneFrameUsable
|
155
|
+
attr :_vr_twopaneframes,1
|
156
|
+
|
157
|
+
def _vr_twopaneframesinit
|
158
|
+
return if defined?(@_vr_twopaneframes) # no init twice
|
159
|
+
@_vr_twopaneframes = Array.new
|
160
|
+
@_vr_current_tpframe=nil
|
161
|
+
addHandler(
|
162
|
+
WMsg::WM_LBUTTONUP, "vrsepl2buttonup", MSGTYPE::ARGINTSINTSINT,nil)
|
163
|
+
addHandler(
|
164
|
+
WMsg::WM_LBUTTONDOWN,"vrsepl2buttondown",MSGTYPE::ARGINTSINTSINT,nil)
|
165
|
+
addHandler(
|
166
|
+
WMsg::WM_MOUSEMOVE, "vrsepl2mousemove", MSGTYPE::ARGINTSINTSINT,nil)
|
167
|
+
|
168
|
+
acceptEvents [
|
169
|
+
WMsg::WM_LBUTTONUP,WMsg::WM_LBUTTONDOWN,WMsg::WM_MOUSEMOVE
|
170
|
+
]
|
171
|
+
end
|
172
|
+
|
173
|
+
def self_vrsepl2buttondown(s,x,y)
|
174
|
+
@_vr_twopaneframes.each do |f|
|
175
|
+
if f.hittest(x,y)
|
176
|
+
f.setDragCur
|
177
|
+
f.dragstart
|
178
|
+
@_vr_current_tpframe=f
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def self_vrsepl2buttonup(s,x,y)
|
184
|
+
@_vr_current_tpframe=nil
|
185
|
+
@_vr_twopaneframes.each do |f|
|
186
|
+
f.dragend
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def self_vrsepl2mousemove(s,x,y)
|
191
|
+
@_vr_twopaneframes.each do |f|
|
192
|
+
if f.hittest(x,y)
|
193
|
+
f.setDragCur
|
194
|
+
end
|
195
|
+
end
|
196
|
+
if @_vr_current_tpframe then
|
197
|
+
@_vr_current_tpframe.splitterDragging(x,y)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def window_parent
|
203
|
+
a=self
|
204
|
+
while(! a.is_a?(SWin::Window) ) do
|
205
|
+
a = a.instance_eval("@parent")
|
206
|
+
end
|
207
|
+
return a
|
208
|
+
end
|
209
|
+
|
210
|
+
def initialize(pane1,pane2)
|
211
|
+
@pane1,@pane2 = pane1,pane2
|
212
|
+
@_vr_dragging=false
|
213
|
+
@ratio=0.5
|
214
|
+
@separatorheight=4
|
215
|
+
@_vr_splitter_last=nil
|
216
|
+
end
|
217
|
+
|
218
|
+
def hittest(x,y)
|
219
|
+
return unless @_vr_lxs
|
220
|
+
if (@_vr_lxs < x) and (x < @_vr_lxe) and
|
221
|
+
(@_vr_lys < y) and (y < @_vr_lye)
|
222
|
+
then
|
223
|
+
true
|
224
|
+
else
|
225
|
+
false
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def setDragCur
|
230
|
+
@_vr_app.setCursor @_vr_dragcur if @_vr_app
|
231
|
+
end
|
232
|
+
|
233
|
+
def dragstart
|
234
|
+
@parent.setCapture
|
235
|
+
@_vr_dragging=true
|
236
|
+
end
|
237
|
+
|
238
|
+
def dragend
|
239
|
+
return unless @_vr_dragging
|
240
|
+
@parent.releaseCapture
|
241
|
+
@_vr_dragging=false
|
242
|
+
splitterDragEnd
|
243
|
+
end
|
244
|
+
|
245
|
+
def setup(parent)
|
246
|
+
raise "setup twice" if defined? @parent
|
247
|
+
@parent = parent
|
248
|
+
@_vr_app = parent.instance_eval("@screen.application") # parent.application
|
249
|
+
@_vr_dragcur = eval("@_vr_app::SysCursors::#{self.class::Cursor}()")
|
250
|
+
parent.extend VRTwoPaneFrameUsable
|
251
|
+
parent._vr_twopaneframesinit
|
252
|
+
parent._vr_twopaneframes.push self
|
253
|
+
self
|
254
|
+
end
|
255
|
+
|
256
|
+
def move(x,y,w,h)
|
257
|
+
@_vr_lx,@_vr_ly,@_vr_lw,@_vr_lh = x,y,w,h
|
258
|
+
self._vr_relayout
|
259
|
+
end
|
260
|
+
|
261
|
+
def splitterDragging(x,y) end
|
262
|
+
def splitterDragEnd(x,y) end
|
263
|
+
def _vr_relayout() raise "using base class #{self.class}" end
|
264
|
+
end
|
265
|
+
|
266
|
+
class VRVertTwoPaneFrame < VRTwoPaneFrame
|
267
|
+
Cursor = "SizeNS"
|
268
|
+
def splitterDragEnd
|
269
|
+
@_vr_splitter_last=nil
|
270
|
+
_vr_relayout
|
271
|
+
end
|
272
|
+
def splitterDragging(x,y)
|
273
|
+
return if y<@separatorheight+@_vr_ly or y>@_vr_ly+@_vr_lh-@separatorheight
|
274
|
+
@ratio=(y-@_vr_ly).to_f/@_vr_lh
|
275
|
+
|
276
|
+
case(splitter_operation_type)
|
277
|
+
when SPLITTER_MOVEWINDOW
|
278
|
+
_vr_relayout(y-@_vr_ly)
|
279
|
+
when SPLITTER_DRAWLINE
|
280
|
+
w = window_parent
|
281
|
+
w.dopaint do |hdc|
|
282
|
+
w.setBrush(RGB(0x255,0x255,0x255))
|
283
|
+
if @_vr_splitter_last then
|
284
|
+
VRTwoPaneFrame::PatBlt.call(hdc,*@_vr_splitter_last)
|
285
|
+
end
|
286
|
+
current=[@_vr_lx,y,@_vr_lw,@separatorheight,0x5a0049] # PATINVERT
|
287
|
+
VRTwoPaneFrame::PatBlt.call(hdc,*current)
|
288
|
+
@_vr_splitter_last = current
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def _vr_relayout( ys = (@_vr_lh*@ratio).to_i)
|
294
|
+
sh=(@separatorheight/2).to_i
|
295
|
+
@_vr_lxs,@_vr_lxe = @_vr_lx,@_vr_lx+@_vr_lw
|
296
|
+
@_vr_lys,@_vr_lye = @_vr_ly+ys-sh,@_vr_ly+ys+sh
|
297
|
+
|
298
|
+
@pane1.move @_vr_lx,@_vr_ly, @_vr_lw,ys-sh
|
299
|
+
@pane2.move @_vr_lx,@_vr_lys+@separatorheight, @_vr_lw,@_vr_lh-ys-sh
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
class VRHorizTwoPaneFrame < VRTwoPaneFrame
|
304
|
+
Cursor = "SizeWE"
|
305
|
+
def splitterDragEnd
|
306
|
+
@_vr_splitter_last=nil
|
307
|
+
_vr_relayout
|
308
|
+
end
|
309
|
+
def splitterDragging(x,y)
|
310
|
+
return if x<@separatorheight+@_vr_lx or x>@_vr_lx+@_vr_lw-@separatorheight
|
311
|
+
@ratio=(x-@_vr_lx).to_f/@_vr_lw
|
312
|
+
|
313
|
+
case(splitter_operation_type)
|
314
|
+
when SPLITTER_MOVEWINDOW
|
315
|
+
_vr_relayout(x-@_vr_lx)
|
316
|
+
when SPLITTER_DRAWLINE
|
317
|
+
w = window_parent
|
318
|
+
w.dopaint do |hdc|
|
319
|
+
w.setBrush(RGB(0x255,0x255,0x255))
|
320
|
+
if @_vr_splitter_last then
|
321
|
+
VRTwoPaneFrame::PatBlt.call(hdc,*@_vr_splitter_last)
|
322
|
+
end
|
323
|
+
current=[x,@_vr_ly,@separatorheight,@_vr_lh,0x5a0049] # PATINVERT
|
324
|
+
VRTwoPaneFrame::PatBlt.call(hdc,*current)
|
325
|
+
@_vr_splitter_last = current
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
|
330
|
+
end
|
331
|
+
|
332
|
+
def _vr_relayout( xs = (@_vr_lw*@ratio).to_i)
|
333
|
+
sh=(@separatorheight/2).to_i
|
334
|
+
@_vr_lxs,@_vr_lxe = @_vr_lx+xs-sh,@_vr_lx+xs+sh
|
335
|
+
@_vr_lys,@_vr_lye = @_vr_ly,@_vr_ly+@_vr_lh
|
336
|
+
|
337
|
+
@pane1.move @_vr_lx,@_vr_ly, xs-sh,@_vr_lh
|
338
|
+
@pane2.move @_vr_lxs+@separatorheight,@_vr_ly, @_vr_lw-xs-sh,@_vr_lh
|
339
|
+
end
|
340
|
+
end
|
data/lib/vr/vrmmedia.rb
ADDED
@@ -0,0 +1,289 @@
|
|
1
|
+
###################################
|
2
|
+
#
|
3
|
+
# vrmmedia.rb
|
4
|
+
# Programmed by nyasu <nyasu@osk.3web.ne.jp>
|
5
|
+
# Copyright 1999-2001 Nishikawa,Yasuhiro
|
6
|
+
#
|
7
|
+
# More information at http://www.threeweb.ad.jp/~nyasu/software/vrproject.html
|
8
|
+
# (in Japanese)
|
9
|
+
#
|
10
|
+
#
|
11
|
+
# Good Reference: vfw.h
|
12
|
+
#
|
13
|
+
###################################
|
14
|
+
|
15
|
+
VR_DIR="vr/" unless defined?(::VR_DIR)
|
16
|
+
require VR_DIR+'vrcontrol'
|
17
|
+
require 'Win32API'
|
18
|
+
|
19
|
+
=begin
|
20
|
+
= VisualuRuby(tmp) modules for MCI
|
21
|
+
=end
|
22
|
+
|
23
|
+
|
24
|
+
#if RUBY_VERSION<"1.4.4" then # Quick Hacking..
|
25
|
+
# require 'DLLManager'
|
26
|
+
# DLLManager.load("msvfw32.dll")
|
27
|
+
#end
|
28
|
+
|
29
|
+
MCIWndRegisterClass = Win32API.new("msvfw32","MCIWndRegisterClass",[],"I")
|
30
|
+
MCIWndRegisterClass.call
|
31
|
+
|
32
|
+
|
33
|
+
module VRMediaViewContainer
|
34
|
+
=begin
|
35
|
+
== VRMediaViewContainer
|
36
|
+
This module provides a message handler for MCI messages.
|
37
|
+
VRForm includes this module automatically loading "vrmmedia.rb".
|
38
|
+
=end
|
39
|
+
include VRMessageHandler
|
40
|
+
|
41
|
+
def vrinit
|
42
|
+
super
|
43
|
+
mediaviewcontainerinit
|
44
|
+
end
|
45
|
+
|
46
|
+
def mediaviewcontainerinit
|
47
|
+
addHandler(VRMediaView::MCIWNDM_NOTIFYMODE,
|
48
|
+
"mmnotifies",MSGTYPE::ARGPASS,nil)
|
49
|
+
addHandler(VRMediaView::MCIWNDM_NOTIFYERROR,
|
50
|
+
"mmnotifies",MSGTYPE::ARGPASS,nil)
|
51
|
+
addHandler(VRMediaView::MCIWNDM_NOTIFYSIZE,
|
52
|
+
"mmnotifies",MSGTYPE::ARGPASS,nil)
|
53
|
+
addHandler(VRMediaView::MCIWNDM_NOTIFYMEDIA,
|
54
|
+
"mmnotifies",MSGTYPE::ARGPASS,nil)
|
55
|
+
acceptEvents [ VRMediaView::MCIWNDM_NOTIFYMODE,
|
56
|
+
VRMediaView::MCIWNDM_NOTIFYSIZE,
|
57
|
+
VRMediaView::MCIWNDM_NOTIFYMEDIA,
|
58
|
+
VRMediaView::MCIWNDM_NOTIFYERROR ]
|
59
|
+
|
60
|
+
addNoRelayMessages [ VRMediaView::MCIWNDM_NOTIFYMODE,
|
61
|
+
VRMediaView::MCIWNDM_NOTIFYSIZE,
|
62
|
+
VRMediaView::MCIWNDM_NOTIFYMEDIA,
|
63
|
+
VRMediaView::MCIWNDM_NOTIFYERROR ]
|
64
|
+
end
|
65
|
+
|
66
|
+
def self_mmnotifies(msg)
|
67
|
+
ct=@_vr_mediaviewers_hwnd[msg.wParam]
|
68
|
+
return unless ct
|
69
|
+
messageid=msg.msg
|
70
|
+
|
71
|
+
return unless ct._vr_mmhandlers and ct._vr_mmhandlers[messageid]
|
72
|
+
|
73
|
+
ct._vr_mmhandlers[messageid].each do |shandler|
|
74
|
+
args=msgarg2handlerarg(shandler[1],msg,shandler[2])
|
75
|
+
ct.__send__(shandler[0],*args) if ct.respond_to?(shandler[0])
|
76
|
+
msg.retval = controlmsg_dispatching(ct,shandler[0],*args)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def addControl(*args)
|
81
|
+
@_vr_mediaviewers_hwnd={} unless defined?(@_vr_mediaviewers_hwnd)
|
82
|
+
a=super
|
83
|
+
@_vr_mediaviewers_hwnd[a.hWnd]=a if a.is_a?(VRMediaView)
|
84
|
+
return a
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
module VRContainersSet
|
89
|
+
include VRMediaViewContainer
|
90
|
+
INITIALIZERS.push :mediaviewcontainerinit
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
#####
|
95
|
+
|
96
|
+
module VRMediaViewModeNotifier
|
97
|
+
include VRMediaViewContainer
|
98
|
+
|
99
|
+
=begin
|
100
|
+
== VRMediaViewModeNotifier
|
101
|
+
This module is to use another event handlers for mci.
|
102
|
+
These new handlers are not relayed to parent by VRMessageParentRelayer.
|
103
|
+
(Use setnotifier() as setnotifier("cname1_cname2))
|
104
|
+
|
105
|
+
=== Methods
|
106
|
+
--- setnotifier(cname)
|
107
|
+
This enables ((<VRMediaView>))'s other event handlers such as cname_stopped,
|
108
|
+
cname_playing,cname_paused and cname_open, named after
|
109
|
+
((<VRMediaView>))#modestring.
|
110
|
+
=end
|
111
|
+
|
112
|
+
def setnotifier(cname)
|
113
|
+
instance_eval(
|
114
|
+
"def "+cname+"_modechanged(n)\n" +
|
115
|
+
" fname='#{cname}_'+@#{cname}.modestring(n) \n" +
|
116
|
+
" send fname if respond_to?(fname) \n" +
|
117
|
+
"end\n"
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
class VRMediaView < VRControl
|
124
|
+
=begin
|
125
|
+
== VRMediaView
|
126
|
+
This is a control window to play multimedia files.
|
127
|
+
|
128
|
+
=== Methods
|
129
|
+
--- mediaopen(filename,flag=0)
|
130
|
+
Open mediafile as filename.
|
131
|
+
--- mediaclose
|
132
|
+
Close mediafile.
|
133
|
+
--- mode
|
134
|
+
Return current mode number.
|
135
|
+
--- modestring(n)
|
136
|
+
Return description for mode number #n
|
137
|
+
--- errorstring
|
138
|
+
Return error description
|
139
|
+
--- play
|
140
|
+
--- pause
|
141
|
+
--- stop
|
142
|
+
--- eject
|
143
|
+
--- step(n=1)
|
144
|
+
--- seek(pos)
|
145
|
+
--- seekHome
|
146
|
+
--- seekEnd
|
147
|
+
--- playable?
|
148
|
+
--- ejectable?
|
149
|
+
--- window?
|
150
|
+
--- length
|
151
|
+
--- position
|
152
|
+
--- volume
|
153
|
+
--- volume=(vl)
|
154
|
+
--- speed
|
155
|
+
--- speed=
|
156
|
+
--- zoom
|
157
|
+
--- zoom=
|
158
|
+
|
159
|
+
=== Event Handlers
|
160
|
+
--- ????_onerror()
|
161
|
+
--- ????_modechanged(newmode)
|
162
|
+
--- ????_sizechanged()
|
163
|
+
--- ????_mediachanged(str)
|
164
|
+
=end
|
165
|
+
|
166
|
+
|
167
|
+
attr :_vr_mmhandlers
|
168
|
+
|
169
|
+
MCI_CLOSE = 0x0804
|
170
|
+
MCI_PLAY = 0x0806
|
171
|
+
MCI_SEEK = 0x0807
|
172
|
+
MCI_STOP = 0x0808
|
173
|
+
MCI_PAUSE = 0x0809
|
174
|
+
MCI_STEP = 0x080E
|
175
|
+
|
176
|
+
MCIWNDM_GETPOSITION = (WMsg::WM_USER + 102) # A message
|
177
|
+
MCIWNDM_GETLENGTH = (WMsg::WM_USER + 104)
|
178
|
+
MCIWNDM_GETMODE = (WMsg::WM_USER + 106) # A message
|
179
|
+
MCIWNDM_EJECT = (WMsg::WM_USER + 107)
|
180
|
+
MCIWNDM_SETZOOM = (WMsg::WM_USER + 108)
|
181
|
+
MCIWNDM_GETZOOM = (WMsg::WM_USER + 109)
|
182
|
+
MCIWNDM_SETVOLUME = (WMsg::WM_USER + 110)
|
183
|
+
MCIWNDM_GETVOLUME = (WMsg::WM_USER + 111)
|
184
|
+
MCIWNDM_SETSPEED = (WMsg::WM_USER + 112)
|
185
|
+
MCIWNDM_GETSPEED = (WMsg::WM_USER + 113)
|
186
|
+
|
187
|
+
MCIWNDM_GETERROR = (WMsg::WM_USER + 128) # A message
|
188
|
+
|
189
|
+
MCIWNDM_CAN_PLAY = (WMsg::WM_USER + 144)
|
190
|
+
MCIWNDM_CAN_WINDOW = (WMsg::WM_USER + 145)
|
191
|
+
MCIWNDM_CAN_EJECT = (WMsg::WM_USER + 148)
|
192
|
+
MCIWNDM_CAN_CONFIG = (WMsg::WM_USER + 149)
|
193
|
+
MCIWNDM_SETOWNER = (WMsg::WM_USER + 152)
|
194
|
+
MCIWNDM_OPEN = (WMsg::WM_USER + 153) # A message
|
195
|
+
|
196
|
+
MCIWNDM_NOTIFYMODE = (WMsg::WM_USER + 200) # wparam = hwnd, lparam = mode
|
197
|
+
MCIWNDM_NOTIFYSIZE = (WMsg::WM_USER + 202) # wparam = hwnd
|
198
|
+
MCIWNDM_NOTIFYMEDIA = (WMsg::WM_USER + 203) # wparam = hwnd, lparam = fn
|
199
|
+
MCIWNDM_NOTIFYERROR = (WMsg::WM_USER + 205) # wparam = hwnd, lparam = error
|
200
|
+
|
201
|
+
MCIWNDF_NOPLAYBAR = 0x0002
|
202
|
+
MCIWNDF_NOAUTOSIZEMOVIE = 0x0004
|
203
|
+
MCIWNDF_NOMENU = 0x0008
|
204
|
+
|
205
|
+
MCIWNDF_SIMPLE = 0xe
|
206
|
+
|
207
|
+
WINCLASSINFO = ["MCIWndClass",0x5500 | 0x400 | 0x880 ]
|
208
|
+
#notify:mode,error,size,media
|
209
|
+
|
210
|
+
def addMMHandler(msg,handlername,handlertype,argparsestr)
|
211
|
+
@_vr_mmhandlers={} unless defined? @_vr_mmhandlers
|
212
|
+
@_vr_mmhandlers[msg]=[] unless @_vr_mmhandlers[msg]
|
213
|
+
@_vr_mmhandlers[msg].push [handlername,handlertype,argparsestr]
|
214
|
+
end
|
215
|
+
|
216
|
+
def deleteMMHandler(msg,handlername)
|
217
|
+
return false unless defined?(@_vr_mmhandlers) and @_vr_mmhandlers[msg]
|
218
|
+
@_vr_mmhandlers.delete_if do |shandler|
|
219
|
+
shandler[0] != (PREHANDLERSTR+handlername).intern
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def vrinit
|
224
|
+
super
|
225
|
+
addMMHandler(VRMediaView::MCIWNDM_NOTIFYERROR,"onerror",MSGTYPE::ARGINT,nil)
|
226
|
+
addMMHandler(VRMediaView::MCIWNDM_NOTIFYMODE,"modechanged",MSGTYPE::ARGINT,nil)
|
227
|
+
addMMHandler(VRMediaView::MCIWNDM_NOTIFYSIZE, "sizechanged",MSGTYPE::ARGNONE,nil)
|
228
|
+
addMMHandler(VRMediaView::MCIWNDM_NOTIFYMEDIA,"mediachanged",MSGTYPE::ARGSTRING,nil)
|
229
|
+
end
|
230
|
+
|
231
|
+
def mediaopen(filename,flag=0)
|
232
|
+
sendMessage MCIWNDM_OPEN,flag,filename
|
233
|
+
sendMessage MCIWNDM_SETOWNER,@parent.hWnd,0
|
234
|
+
end
|
235
|
+
|
236
|
+
def play() sendMessage MCI_PLAY,0,0 end
|
237
|
+
def pause() sendMessage MCI_PAUSE,0,0 end
|
238
|
+
def stop() sendMessage MCI_STOP,0,0 end
|
239
|
+
def mediaclose() sendMessage MCI_CLOSE,0,0 end
|
240
|
+
def eject() sendMessage MCI_EJECT,0,0 end
|
241
|
+
def step(n=1) sendMessage MCI_STEP,0,n.to_i end
|
242
|
+
def seek(pos) sendMessage MCI_SEEK,0,pos.to_i end
|
243
|
+
def seekHome() sendMessage MCI_SEEK,0,-1 end
|
244
|
+
def seekEnd() sendMessage MCI_SEEK,0,-2 end
|
245
|
+
|
246
|
+
def playable?() sendMessage(MCIWNDM_CAN_PLAY,0,0)!=0 end
|
247
|
+
def ejectable?() sendMessage(MCIWNDM_CAN_EJECT,0,0)!=0 end
|
248
|
+
def window?() sendMessage(MCIWNDM_CAN_WINDOW,0,0)!=0 end
|
249
|
+
|
250
|
+
def length() sendMessage MCIWNDM_GETLENGTH,0,0 end
|
251
|
+
def position() sendMessage MCI_SEEK,0,0 end
|
252
|
+
|
253
|
+
def volume=(vl) sendMessage MCIWNDM_SETVOLUME,0,vl.to_i end
|
254
|
+
def volume() sendMessage MCIWNDM_GETVOLUME,0,0 end
|
255
|
+
def speed=(sp) sendMessage MCIWNDM_SETSPEED,0,sp.to_i end
|
256
|
+
def speed() sendMessage MCIWNDM_GETSPEED,0,0 end
|
257
|
+
def zoom=(zm) sendMessage MCIWNDM_SETZOOM,0,zm.to_i end
|
258
|
+
def zoom() sendMessage MCIWNDM_GETZOOM,0,0 end
|
259
|
+
|
260
|
+
def mode
|
261
|
+
p="\0 " #32bytes
|
262
|
+
sendMessage MCIWNDM_GETMODE,31,p
|
263
|
+
p
|
264
|
+
end
|
265
|
+
|
266
|
+
def modestring(n)
|
267
|
+
case n
|
268
|
+
when 524; "not_ready"
|
269
|
+
when 525; "stopped"
|
270
|
+
when 526; "playing"
|
271
|
+
when 527; "recording"
|
272
|
+
when 528; "seeking"
|
273
|
+
when 529; "paused"
|
274
|
+
when 530; "open"
|
275
|
+
else; "unknown_mode"
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def errorstring
|
280
|
+
p="\0 "*8 #256bytes
|
281
|
+
sendMessage MCIWNDM_GETERROR,255,p
|
282
|
+
p
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
286
|
+
|
287
|
+
if VR_COMPATIBILITY_LEVEL then
|
288
|
+
require VR_DIR + 'compat/vrmmedia.rb'
|
289
|
+
end
|