exerb 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/ChangeLog.ja.rd +305 -0
  4. data/README.en.txt +12 -0
  5. data/README.ja.html +143 -0
  6. data/README.ja.txt +6 -0
  7. data/README.md +50 -0
  8. data/Rakefile +205 -0
  9. data/bin/exerb +185 -0
  10. data/bin/mkexy +47 -0
  11. data/doc/LGPL +513 -0
  12. data/doc/class.ja.html +92 -0
  13. data/doc/command.ja.html +109 -0
  14. data/doc/core.ja.html +72 -0
  15. data/doc/example.ja.html +89 -0
  16. data/doc/faq.ja.html +59 -0
  17. data/doc/inside.ja.rd +404 -0
  18. data/doc/license.ja.html +62 -0
  19. data/doc/logo.gif +0 -0
  20. data/doc/misc.ja.html +72 -0
  21. data/doc/navi.gif +0 -0
  22. data/doc/recipe.ja.html +317 -0
  23. data/doc/style.css +187 -0
  24. data/doc/tutorial.ja.html +182 -0
  25. data/example/Makefile +54 -0
  26. data/example/cat_n.rb +14 -0
  27. data/example/exception.rb +9 -0
  28. data/example/ext/Win32API.so +0 -0
  29. data/example/ext/swin.so +0 -0
  30. data/example/msgbox.rb +14 -0
  31. data/example/rubytk.rb +22 -0
  32. data/example/runtime.ico +0 -0
  33. data/example/runtime.rb +19 -0
  34. data/example/vr/clipboard.rb +106 -0
  35. data/example/vr/compat/rubycompat.rb +18 -0
  36. data/example/vr/compat/vrcomctl.rb +12 -0
  37. data/example/vr/compat/vrcontrol.rb +50 -0
  38. data/example/vr/compat/vrmmedia.rb +24 -0
  39. data/example/vr/contrib/inifile.rb +116 -0
  40. data/example/vr/contrib/msgboxconst.rb +55 -0
  41. data/example/vr/contrib/toolbar.rb +371 -0
  42. data/example/vr/contrib/vrctlcolor.rb +110 -0
  43. data/example/vr/contrib/vrhotkey.rb +35 -0
  44. data/example/vr/contrib/vrlistviewex.rb +71 -0
  45. data/example/vr/contrib/vrstdscrollbar.rb +414 -0
  46. data/example/vr/contrib/vrwincomponent.rb +54 -0
  47. data/example/vr/dragdropformat.rb +209 -0
  48. data/example/vr/rscutil.rb +168 -0
  49. data/example/vr/sysmod.rb +249 -0
  50. data/example/vr/vractivex.rb +56 -0
  51. data/example/vr/vrclipboard.rb +53 -0
  52. data/example/vr/vrcomctl.rb +1819 -0
  53. data/example/vr/vrcontrol.rb +1374 -0
  54. data/example/vr/vrdde.rb +623 -0
  55. data/example/vr/vrddrop.rb +190 -0
  56. data/example/vr/vrdialog.rb +406 -0
  57. data/example/vr/vrhandler.rb +195 -0
  58. data/example/vr/vrlayout.old.rb +209 -0
  59. data/example/vr/vrlayout.rb +173 -0
  60. data/example/vr/vrlayout2.rb +340 -0
  61. data/example/vr/vrmargin.rb +141 -0
  62. data/example/vr/vrmgdlayout.rb +381 -0
  63. data/example/vr/vrmmedia.rb +287 -0
  64. data/example/vr/vrolednd.rb +192 -0
  65. data/example/vr/vrowndraw.rb +108 -0
  66. data/example/vr/vrrichedit.rb +366 -0
  67. data/example/vr/vrtimer.rb +148 -0
  68. data/example/vr/vrtooltip.rb +273 -0
  69. data/example/vr/vrtray.rb +143 -0
  70. data/example/vr/vrtvitem.rb +118 -0
  71. data/example/vr/vrtwopane.rb +223 -0
  72. data/example/vr/vruby.rb +1051 -0
  73. data/example/vr/winconst.rb +158 -0
  74. data/example/vruby.rb +38 -0
  75. data/exerb.gemspec +26 -0
  76. data/extconf.rb +7 -0
  77. data/lib/exerb/archive.rb +143 -0
  78. data/lib/exerb/config.rb +51 -0
  79. data/lib/exerb/error.rb +15 -0
  80. data/lib/exerb/executable.rb +68 -0
  81. data/lib/exerb/file_table.rb +189 -0
  82. data/lib/exerb/mkexy.rb +81 -0
  83. data/lib/exerb/name_table.rb +120 -0
  84. data/lib/exerb/recipe.rb +465 -0
  85. data/lib/exerb/resource.rb +190 -0
  86. data/lib/exerb/resource/base.rb +29 -0
  87. data/lib/exerb/resource/binary.rb +31 -0
  88. data/lib/exerb/resource/dialog.rb +30 -0
  89. data/lib/exerb/resource/group_icon.rb +85 -0
  90. data/lib/exerb/resource/icon.rb +52 -0
  91. data/lib/exerb/resource/version_info.rb +155 -0
  92. data/lib/exerb/resource_library.rb +120 -0
  93. data/lib/exerb/utility.rb +95 -0
  94. data/lib/exerb/utility2.rb +122 -0
  95. data/lib/exerb/version.rb +13 -0
  96. data/lib/exerb/win32/const/resource.rb +51 -0
  97. data/lib/exerb/win32/icon_file.rb +78 -0
  98. data/lib/exerb/win32/pe_file.rb +59 -0
  99. data/lib/exerb/win32/resource_directory.rb +105 -0
  100. data/lib/exerb/win32/resource_directory_root.rb +67 -0
  101. data/lib/exerb/win32/resource_entry.rb +98 -0
  102. data/lib/exerb/win32/struct/base.rb +43 -0
  103. data/lib/exerb/win32/struct/icon_dir_entry.rb +83 -0
  104. data/lib/exerb/win32/struct/icon_header.rb +43 -0
  105. data/lib/exerb/win32/struct/icon_res_entry.rb +48 -0
  106. data/lib/exerb/win32/struct/image_dos_header.rb +73 -0
  107. data/lib/exerb/win32/struct/image_file_header.rb +47 -0
  108. data/lib/exerb/win32/struct/image_nt_headers32.rb +53 -0
  109. data/lib/exerb/win32/struct/image_optional_header32.rb +107 -0
  110. data/lib/exerb/win32/struct/image_resource_data_entry.rb +45 -0
  111. data/lib/exerb/win32/struct/image_resource_directory.rb +47 -0
  112. data/lib/exerb/win32/struct/image_resource_directory_entry.rb +72 -0
  113. data/lib/exerb/win32/struct/image_section_header.rb +53 -0
  114. data/lib/exerb/win32/struct/version_info_block.rb +75 -0
  115. data/lib/exerb/win32/struct/vs_fixed_file_info.rb +62 -0
  116. data/src/exerb/cui.c +48 -0
  117. data/src/exerb/default.rb +1 -0
  118. data/src/exerb/exerb.c +877 -0
  119. data/src/exerb/exerb.h +92 -0
  120. data/src/exerb/gui.c +176 -0
  121. data/src/exerb/module.c +138 -0
  122. data/src/exerb/module.h +7 -0
  123. data/src/exerb/patch.c +27 -0
  124. data/src/exerb/resource.h +22 -0
  125. data/src/exerb/resource.rc +121 -0
  126. data/src/exerb/ruby.ico +0 -0
  127. data/src/exerb/utility.c +263 -0
  128. data/src/exerb/utility.h +33 -0
  129. data/test/alltests.rb +16 -0
  130. data/test/test-argv.rb +26 -0
  131. data/test/test-argv/test-argv.rb +9 -0
  132. data/test/test-argv/test-argv.ret +1 -0
  133. data/test/test-dollarzero.rb +26 -0
  134. data/test/test-dollarzero/test-dollarzero.rb +10 -0
  135. data/test/test-dollarzero/test-dollarzero.ret +2 -0
  136. data/test/test-dot.rb +26 -0
  137. data/test/test-dot/dot.dot.dot.rb +9 -0
  138. data/test/test-dot/dot.dot.rb +9 -0
  139. data/test/test-dot/test-dot.rb +13 -0
  140. data/test/test-dot/test-dot.ret +5 -0
  141. data/test/test-exitcode.rb +28 -0
  142. data/test/test-exitcode/test-exitcode.rb +9 -0
  143. data/test/test-kcode.rb +43 -0
  144. data/test/test-kcode/euc.rb +10 -0
  145. data/test/test-kcode/euc.ret +2 -0
  146. data/test/test-kcode/none.rb +10 -0
  147. data/test/test-kcode/none.ret +2 -0
  148. data/test/test-kcode/sjis.rb +10 -0
  149. data/test/test-kcode/sjis.ret +2 -0
  150. data/test/test-kcode/utf8.rb +10 -0
  151. data/test/test-kcode/utf8.ret +2 -0
  152. data/test/test-loadpath.rb +24 -0
  153. data/test/test-loadpath/test-loadpath.rb +9 -0
  154. data/test/test-nest.rb +18 -0
  155. data/test/test-nest/foo.rb +1 -0
  156. data/test/test-nest/foo/bar.rb +2 -0
  157. data/test/test-nest/foo/foo.rb +1 -0
  158. data/test/test-nest/test-nest.rb +1 -0
  159. data/test/test-nest/test-nest.ret +1 -0
  160. data/test/test-preload.rb +24 -0
  161. data/test/test-preload/test-preload.rb +9 -0
  162. data/test/test-regexp.rb +26 -0
  163. data/test/test-regexp/test-regexp.rb +23 -0
  164. data/test/test-regexp/test-regexp.ret +13 -0
  165. data/test/test-require1.rb +26 -0
  166. data/test/test-require1/require1.rb +9 -0
  167. data/test/test-require1/require2.rb +9 -0
  168. data/test/test-require1/require3.rb +9 -0
  169. data/test/test-require1/require4.rb +9 -0
  170. data/test/test-require1/require5.rb +9 -0
  171. data/test/test-require1/require6.rb +9 -0
  172. data/test/test-require1/test-require1.rb +41 -0
  173. data/test/test-require1/test-require1.ret +27 -0
  174. data/test/test-socket.rb +26 -0
  175. data/test/test-socket/test-socket.rb +7 -0
  176. data/test/test-socket/test-socket.ret +1 -0
  177. data/test/testcase.rb +66 -0
  178. data/vendor/mkexports.rb +167 -0
  179. metadata +352 -0
@@ -0,0 +1,190 @@
1
+ ###################################
2
+ #
3
+ # vrddrop.rb
4
+ # Programmed by nyasu <nyasu@osk.3web.ne.jp>
5
+ # Copyright 1999-2005 Nishikawa,Yasuhiro
6
+ #
7
+ # More information at http://vruby.sourceforge.net/index.html
8
+ #
9
+ ###################################
10
+
11
+ VR_DIR="vr/" unless defined?(::VR_DIR)
12
+ require VR_DIR+'vruby'
13
+ require VR_DIR+'sysmod'
14
+ require VR_DIR+'dragdropformat'
15
+ require 'Win32API'
16
+
17
+
18
+ module VRDropFileTarget
19
+ =begin
20
+ == VRDropFileTarget
21
+ This module prepares the feature that accepts file dropping.
22
+
23
+ === Event handler(s)
24
+ --- self_dropfiles(files)
25
+ Argument ((|files|)) is the array of dropped filenames.
26
+ =end
27
+
28
+ include VRMessageHandler
29
+
30
+ DragAcceptFiles = Win32API.new("shell32","DragAcceptFiles",["I","I"],"")
31
+ DragFinish = Win32API.new("shell32","DragFinish",["I"],"")
32
+
33
+ def filedropinit
34
+ addHandler(WMsg::WM_DROPFILES,"vrdropfiles",MSGTYPE::ARGWINT,nil)
35
+ addEvent WMsg::WM_DROPFILES
36
+ addNoRelayMessages [WMsg::WM_DROPFILES]
37
+ DragAcceptFiles.call(self.hWnd,1)
38
+ end
39
+
40
+ def vrinit
41
+ super
42
+ filedropinit
43
+ end
44
+
45
+ def self_vrdropfiles(handle)
46
+ r = DragDropFiles.get(handle).files
47
+ DragFinish.call(handle)
48
+ selfmsg_dispatching("dropfiles",r)
49
+ # self_dropfiles(r) if self.respond_to?("self_dropfiles")
50
+ end
51
+ end
52
+
53
+
54
+ module VRDragDropSource
55
+ =begin
56
+ == VRDragDropSource
57
+ This module is a base module for dragdrop source. Note that this module uses
58
+ message posting to realize drag and drop instead of using OLE Drag&Drop.
59
+ To use this module, see VRDragFileSource module.
60
+ This module needs a callback function createDropItem, which is called
61
+ when the user releases a mouse button to drop.
62
+
63
+ === Methods
64
+ --- dragDetect()
65
+ Determines by the user's input whether the user is doing dragging or not.
66
+ --- dragStart()
67
+ Starts dragging.
68
+ --- createDropItem()
69
+ This is a callback method to calculate the dropping item. This needs to
70
+ return three values message,wParam and lParam to send to the dropped window.
71
+ The dropped window will receive the message by Windows messaging service.
72
+
73
+ === Attributes
74
+ --- dropToplevel
75
+ While this is true, the message is sent to the toplevel window under the
76
+ cursor, and in the other case the message is sent to the window just
77
+ under the cursor.
78
+
79
+ =end
80
+
81
+ include VRMessageHandler
82
+
83
+ DragDetect = Win32API.new("user32","DragDetect","IP","I")
84
+ GetCursorPos = Win32API.new("user32","GetCursorPos","P","I")
85
+ WindowFromPoint = Win32API.new("user32","WindowFromPoint","II","I")
86
+ GetParent=Win32API.new("user32","GetParent","I","I")
87
+
88
+ def dragdropsourceinit
89
+ @_vr_dragging=false
90
+ @_vr_droptotoplevel=true;
91
+ @_vr_pointbuffer=[0,0].pack("II")
92
+ unless @_vr_dragging_cursor then
93
+ @_vr_dragging_cursor=@screen.application::SysCursors.Cross
94
+ end
95
+ addHandler(WMsg::WM_LBUTTONUP,"_vrdsrclbuttonup",MSGTYPE::ARGINTINT,nil)
96
+ acceptEvents [WMsg::WM_LBUTTONUP]
97
+ end
98
+
99
+ def vrinit
100
+ super
101
+ dragdropsourceinit
102
+ end
103
+
104
+ def dropToplevel() @_vr_droptotoplevel; end
105
+ def dropToplevel=(f) @_vr_droptotoplevel=f;end
106
+
107
+ def dragDetect
108
+ DragDetect.call(self.hWnd,@_vr_pointbuffer)!=0
109
+ end
110
+
111
+ def dragStart()
112
+ GetCursorPos.call(@_vr_pointbuffer)
113
+ if DragDetect.call(self.hWnd,@_vr_pointbuffer)!=0 then
114
+ @_vr_dragging=true
115
+ @screen.application.setCursor @_vr_dragging_cursor
116
+ setCapture
117
+ end
118
+ end
119
+
120
+ def createDropItem()
121
+ # msg,wParam,lParam
122
+ return nil,nil,nil
123
+ end
124
+
125
+ def self__vrdsrclbuttonup(shift,xy)
126
+ if @_vr_dragging then
127
+ @screen.application.setCursor @screen.application::SysCursors.Arrow
128
+ GetCursorPos.call(@_vr_pointbuffer)
129
+ handle=WindowFromPoint.call(*@_vr_pointbuffer.unpack("II"))
130
+ releaseCapture
131
+
132
+ if @_vr_droptotoplevel then
133
+ while handle!=0 do # search the top level window
134
+ droptarget=handle; handle=GetParent.call(handle)
135
+ end
136
+ else
137
+ droptarget=handle;
138
+ end
139
+
140
+ msg,wParam,lParam = self.createDropItem
141
+ SMSG::postMessage droptarget,msg,wParam,lParam
142
+ end
143
+ @_vr_dragging=false
144
+ end
145
+ end
146
+
147
+ module VRDragFileSource
148
+ include VRDragDropSource
149
+ =begin
150
+ == VRDragFileSource
151
+ This module prepares the feature to start dragging files.
152
+ This is the result of quick-hacking. Are you so kind that teach me
153
+ the structure of "internal structure describing the dropped files?"
154
+
155
+ === Event handler(s)
156
+ --- dragStart(files)
157
+ Starts file dragging with ((|files|)) that is an Array including
158
+ the filenames to be dragged.
159
+ =end
160
+
161
+ def dragStart(paths)
162
+ @_vr_dragpaths=paths
163
+ super()
164
+ end
165
+
166
+ def createDropItem
167
+ hDrop = DragDropFiles.set(@_vr_dragpaths).handle
168
+ return WMsg::WM_DROPFILES, hDrop, 0
169
+ end
170
+ end
171
+
172
+ =begin VRDragFileSource sample
173
+ require 'vr/vrcontrol'
174
+ require 'vr/vrhandler'
175
+ require 'vr/vrddrop'
176
+
177
+ class MyForm < VRForm
178
+ include VRDragFileSource
179
+ include VRMouseFeasible
180
+
181
+ def self_lbuttondown(shift,x,y)
182
+ if dragDetect then
183
+ dragStart ['c:\autoexec.bat','c:\config.sys']
184
+ end
185
+ end
186
+ end
187
+
188
+ VRLocalScreen.start(MyForm)
189
+ =end
190
+
@@ -0,0 +1,406 @@
1
+ ###################################
2
+ #
3
+ # vrdialog.rb
4
+ # Programmed by nyasu <nyasu@osk.3web.ne.jp>
5
+ # Copyright 1999-2005 Nishikawa,Yasuhiro
6
+ #
7
+ # More information at http://vruby.sourceforge.net/index.html
8
+ #
9
+ ###################################
10
+
11
+ =begin
12
+ = VisualuRuby(tmp) Dialog boxes
13
+ =end
14
+
15
+
16
+ VR_DIR="vr/" unless defined?(::VR_DIR)
17
+ require VR_DIR+'vruby'
18
+ require VR_DIR+'vrcontrol'
19
+
20
+ class VRDialogTemplate
21
+ =begin
22
+ == VRDialogTemplate
23
+ Create Dialog template string for the argument of
24
+ DialogBoxIndirectParam() Win32API.
25
+
26
+ === Attributes
27
+ ((|style|)),((|exstyle|)),((|caption|)),((|fontsize|)),((|fontname|)) are
28
+ read/write accessible.
29
+ ((|x|)),((|y|)),((|w|)),((|h|)) are read-only and access these attributes
30
+ with 'move' method.
31
+
32
+ === Methods
33
+ --- move(x,y,w,h)
34
+ Sets the dialog dimension and position. The position is relative from
35
+ parent window.
36
+ --- addDlgControl(ctype,caption,x,y,w,h,style=0)
37
+ Adds a control on the dialog. ((|ctype|)) is the control-class such as
38
+ VRButton.
39
+ --- to_template
40
+ Create a dialog template string and return it.
41
+ =end
42
+
43
+ attr_accessor :style
44
+ attr_accessor :exstyle
45
+ attr_reader :x
46
+ attr_reader :y
47
+ attr_reader :w
48
+ attr_reader :h
49
+ attr_accessor :caption
50
+ attr_accessor :fontsize
51
+ attr_accessor :fontname
52
+
53
+ require 'Win32API'
54
+ MultiByteToWideChar =
55
+ Win32API.new("kernel32","MultiByteToWideChar",["I","I","P","I","P","I"],"I")
56
+
57
+ private
58
+ def padding_dwordAlignment(str)
59
+ a=str.length
60
+ c = ( (a+3)&0xfffc ) - a # Don't use String whose length is over 0xfffc :)
61
+ str << " "*c
62
+ end
63
+
64
+ def mb2wc(str)
65
+ r=" "*(str.length*2)
66
+ l=MultiByteToWideChar.call(0,0,str,str.length,r,r.length)
67
+ r[0,l*2]
68
+ end
69
+
70
+ def class2param(cls)
71
+ if cls == VRButton then
72
+ [0xffff,0x80].pack("SS")
73
+ elsif cls == VREdit || cls == VRText
74
+ [0xffff,0x81].pack("SS")
75
+ elsif cls == VRStatic
76
+ [0xffff,0x82].pack("SS")
77
+ elsif cls == VRListbox
78
+ [0xffff,0x83].pack("SS")
79
+ elsif cls == VRScrollbar
80
+ [0xffff,0x84].pack("SS")
81
+ elsif cls == VRCombobox
82
+ [0xffff,0x85].pack("SS")
83
+ else
84
+ mb2wc(cls.Controltype[0]+"\0")
85
+ end
86
+ end
87
+
88
+ def tmplateinit
89
+ @_vr_dcontrols={}; @_vr_cid=0;
90
+ @style = 0x90c800c0
91
+ @exstyle=0
92
+ self.move 100,100,200,100
93
+ @caption=""
94
+ @fontname="system"
95
+ @fontsize=10
96
+ end
97
+
98
+ def initialize
99
+ tmplateinit
100
+ end
101
+
102
+ public
103
+ def move(x,y,w,h)
104
+ @x,@y,@w,@h = x,y,w,h
105
+ end
106
+
107
+ def addDlgControl(ctype,caption,x,y,w,h,style=0)
108
+ newid = @_vr_cid + $VRCONTROL_STARTID*2
109
+ @_vr_dcontrols[newid] =
110
+ [ctype,"",caption,x,y,w,h,
111
+ ctype.Controltype[1] | style | 0x50000000] #WS_VISIBLECHILD
112
+ @_vr_cid+=1
113
+ return newid
114
+ end
115
+
116
+
117
+ def to_template
118
+ tmp =
119
+ [
120
+ @style,@exstyle,@_vr_dcontrols.size,@x,@y,@w,@h,0,0
121
+ ] .pack("LISSSSSSS") + mb2wc(@caption+"\0")
122
+
123
+ if (@style & 0x40)>0 then # DS_SETFONT
124
+ tmp << [@fontsize].pack("S") << mb2wc(@fontname+"\0")
125
+ end
126
+ padding_dwordAlignment(tmp)
127
+
128
+ @_vr_dcontrols.each do |iid,val|
129
+ tmp << [val[7],0,val[3,4],iid].flatten.pack("IISSSSS")
130
+ tmp << class2param(val[0])
131
+ tmp << mb2wc(val[2]+"\0") << [0].pack("S")
132
+ padding_dwordAlignment(tmp)
133
+ end
134
+ return tmp
135
+ end
136
+ end
137
+
138
+
139
+ module WMsg
140
+ WM_INITDIALOG = 0x110
141
+ end
142
+
143
+ class VRDialogComponent < SWin::Dialog
144
+ =begin
145
+ == VRDialogComponent
146
+ This class represents modal/modeless dialogs.
147
+ --- setButtonAs(button,dlgbuttonid)
148
+ Set the button as dialog's functional button like IDOK, IDCANCEL and so on.
149
+ ((|button|)) must be a VRButton and dlgbuttonid must be between IDOK and IDHELP
150
+ --- centering
151
+ set the dialog at the center of the parent window.
152
+ =end
153
+
154
+ include VRParent
155
+
156
+ IDOK = 1
157
+ IDCANCEL = 2
158
+ IDABORT = 3
159
+ IDRETRY = 4
160
+ IDIGNORE = 5
161
+ IDYES = 6
162
+ IDNO = 7
163
+ IDCLOSE = 8
164
+ IDHELP = DLGMAX_ID = 9
165
+
166
+ attr :options,1 #hash
167
+
168
+ def vrinit
169
+ extend VRWinComponent::VRInitBlocker
170
+ end
171
+
172
+ def setscreen(scr)
173
+ @screen=scr
174
+ end
175
+ def create(*arg)
176
+ self.open(*arg)
177
+ end
178
+
179
+ def setButtonAs(control, newid) #contributed by Katonbo-san.
180
+ if newid > DLGMAX_ID then
181
+ raise "id[#{newid}] is too big"
182
+ end
183
+ id = control.etc
184
+ @controls[newid] = @controls[id]
185
+ # control.etc = newid
186
+ # @controls.delete(id)
187
+ end
188
+
189
+ def centering(target = @parent) #contributed by Yuya-san./modified by nyasu.
190
+ unless target.is_a?(SWin::Window) then
191
+ target = @screen
192
+ end
193
+ x0,y0,w0,h0 = self.windowrect
194
+ if target == @screen then
195
+ x1=target.x; y1=target.y; w1=target.w; h1=target.h
196
+ else
197
+ x1,y1,w1,h1 = target.windowrect
198
+ end
199
+ x = x1 + w1 / 2 - w0 / 2
200
+ y = y1 + h1 / 2 - h0 / 2
201
+ self.move(x, y, w0, h0)
202
+ end
203
+
204
+ def initialize(*arg)
205
+ @options={}
206
+ end
207
+
208
+ def self.new(screen,template) # obsolete
209
+ r=screen.factory.newdialog(template.to_template,self)
210
+ r.parentinit(screen)
211
+ r.options={}
212
+ r.addEvent WMsg::WM_INITDIALOG
213
+ r.addEvent WMsg::WM_COMMAND
214
+ return r
215
+ end
216
+
217
+ def self.new2(screen) # obsolete
218
+ template = VRDialogTemplate.new
219
+ opt={}
220
+ yield(opt,template)
221
+ r=self.new(screen,template)
222
+ r.options=opt if opt.is_a?(Hash)
223
+ return r
224
+ end
225
+
226
+ module VRInitDialogHandler
227
+ def vrinit
228
+ if self.kind_of?(VRMessageHandler) then
229
+ addHandler WMsg::WM_INITDIALOG,"initdialog",MSGTYPE::ARGINTINT,nil
230
+ end
231
+ super
232
+ end
233
+
234
+ def msghandler(msg)
235
+ if msg.msg==WMsg::WM_INITDIALOG then
236
+ self.vrinit
237
+ self.construct if self.respond_to?(:construct)
238
+ self.self_created if self.respond_to?(:self_created)
239
+ end
240
+ super
241
+ end
242
+ end
243
+
244
+ def open(parent=@parent,modal=true)
245
+ @parent=parent
246
+ super parent,modal
247
+ end
248
+ end
249
+
250
+
251
+ class VRModalDialog <VRDialogComponent
252
+ =begin
253
+ == VRModalDialog
254
+ This class represents a modal dialog.
255
+ When a modal dialog opens, the sequence is blocked until the dialog is closed.
256
+ (Process about the dialog is advancing.)
257
+ VRModalDialog#open method returns the value which is the argument
258
+ at VRModalDialog#close(value). <- SWin::Dialog#close
259
+
260
+ === Attributes
261
+ Hash of ((|options|)) set values as 'options["cancelbutton"]=canbtn'
262
+
263
+ === Methods
264
+ --- close(value)
265
+ See SWin::Dialog#close
266
+ =end
267
+
268
+ include VRParent
269
+
270
+ end
271
+
272
+ class VRModelessDialog <VRDialogComponent
273
+ =begin
274
+ == VRModelessDialog
275
+ This class represents a modeless dialog.
276
+ VRModelessDialog dialog is resemble like VRForm except at creating.
277
+ The modeless dialogs have advantages enabling TAB_STOP control focusing.
278
+
279
+ === Attributes
280
+ Hash of ((|options|)) set values as 'options["cancelbutton"]=canbtn'
281
+
282
+ === Methods
283
+ --- open(parent=@parent)
284
+ See SWin::Dialog#open.
285
+ --- close(value)
286
+ See SWin::Dialog#close
287
+ =end
288
+
289
+ include VRParent
290
+
291
+ def open(parent=@parent,ignored_modal=false)
292
+ super parent,false
293
+ end
294
+ end
295
+
296
+
297
+
298
+ class VRScreen
299
+ =begin
300
+ == VRScreen
301
+ A method is added to VRScreen by loading this file.
302
+
303
+ === Method
304
+ --- openModalDialog(parent,style=nil,mod=VRDialogComponent,template=PlaneDialogTemplate,options={})
305
+ Creates and opens a modal dialog box.
306
+ This method is blocked until the dialog box closed.
307
+ GUI definition can be specified by ((|template|)) or mod#construct.
308
+ When mod==nil, then this method use VRDialogComponent instead of nil.
309
+ The return value is dialog's return value set by SWin::Dialog#close.
310
+ ((|options|)) specifies the focused control, ok button, cancel button, etc.
311
+ --- openModelessDialog(parent,style=nil,mod=VRDialogComponent,template=PlaneDialogTemplate,options={})
312
+ Creates and opens a modeless dialog box.
313
+ GUI definition can be specified by ((|template|)) or mod#construct.
314
+ When mod==nil, then this method use VRDialogComponent instead of nil.
315
+ The return value is false and this method returns immediately.(non-blocking)
316
+ ((|options|)) specifies the focused control, ok button, cancel button, etc.
317
+ (see VRInputbox)
318
+
319
+ --- newdialog(parent,style=nil,mod=VRDialogComponent,template=PlaneDialogTemplate,options={})
320
+ Creates a dialogbox whose parent is ((|parent|)), and returns it.
321
+ To open that dialogbox, call "open" method.
322
+ This method is called by openModalDialog() and openModelessDialog() .
323
+ ((|mod|)) may be a module or a class which is a descendant of
324
+ VRDialogComponent.
325
+ =end
326
+
327
+ PlaneDialogTemplate = VRDialogTemplate.new.to_template
328
+
329
+ def newdialog(parent,style=nil,mod=VRDialogComponent,*template_arg)
330
+ template,options = *template_arg
331
+ template = PlaneDialogTemplate unless template
332
+ options = {} unless options
333
+ if mod.is_a?(Class) and mod.ancestors.index(VRDialogComponent) then
334
+ frm=@factory.newdialog(template,mod)
335
+ elsif mod.is_a?(Class) then
336
+ raise "#{mod.class} is not a descendant of VRDialogComponent"
337
+ elsif mod.is_a?(Module) then
338
+ frm=@factory.newdialog(template,VRDialogComponent)
339
+ frm.extend VRParent
340
+ frm.extend mod
341
+ else
342
+ raise ArgumentError,"a Class/Module of VRDialogComponent required"
343
+ end
344
+ frm.parentinit(self)
345
+ frm.addEvent WMsg::WM_INITDIALOG
346
+ frm.extend(VRStdControlContainer)
347
+ frm.style=style if style
348
+ frm.extend(VRDialogComponent::VRInitDialogHandler)
349
+ frm.options.update(options)
350
+ frm.instance_eval("@parent=parent")
351
+ frm
352
+ end
353
+
354
+ def openModalDialog(parent,style=nil,mod=VRModalDialog,*template_arg)
355
+ mod = VRModalDialog unless mod
356
+ frm = newdialog(parent,style,mod,*template_arg)
357
+ a = frm.open(parent,true)
358
+ end
359
+
360
+ def openModelessDialog(parent,style=nil,mod=VRModelessDialog,*template_arg)
361
+ mod = VRModelessDialog unless mod
362
+ frm = newdialog(parent,style,mod,*template_arg)
363
+ frm.open parent,false
364
+ @_vr_box.push frm
365
+ frm
366
+ end
367
+
368
+ alias modalform :openModalDialog
369
+ alias modelessform :openModelessDialog
370
+ end
371
+
372
+ module VRInputboxDialog
373
+ =begin
374
+ == VRInputboxDialog
375
+ Abstract module of Inputbox.
376
+ Ok button, Cancel button and input area are have to be added by addDlgControl.
377
+ After creating them, set the options "okbutton","cancelbutton","target" and
378
+ "default".
379
+ =end
380
+
381
+ include VRParent
382
+ include VRStdControlContainer
383
+
384
+ def vrinit
385
+ super
386
+ target = @options["target"]
387
+ end
388
+
389
+ def msghandler(msg)
390
+ if msg.msg == WMsg::WM_INITDIALOG then
391
+ self.setItemTextOf(@options["target"],@options["default"].to_s)
392
+ end
393
+
394
+ if msg.msg == WMsg::WM_COMMAND then
395
+ if msg.wParam==@options["okbutton"] then
396
+ close self.getItemTextOf(@options["target"])
397
+ elsif msg.wParam==@options["cancelbutton"] then
398
+ close false
399
+ end
400
+ end
401
+ end
402
+ end
403
+
404
+ class VRInputbox < VRDialogComponent
405
+ include VRInputboxDialog
406
+ end