exerb 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/ChangeLog.ja.rd +305 -0
- data/README.en.txt +12 -0
- data/README.ja.html +143 -0
- data/README.ja.txt +6 -0
- data/README.md +50 -0
- data/Rakefile +205 -0
- data/bin/exerb +185 -0
- data/bin/mkexy +47 -0
- data/doc/LGPL +513 -0
- data/doc/class.ja.html +92 -0
- data/doc/command.ja.html +109 -0
- data/doc/core.ja.html +72 -0
- data/doc/example.ja.html +89 -0
- data/doc/faq.ja.html +59 -0
- data/doc/inside.ja.rd +404 -0
- data/doc/license.ja.html +62 -0
- data/doc/logo.gif +0 -0
- data/doc/misc.ja.html +72 -0
- data/doc/navi.gif +0 -0
- data/doc/recipe.ja.html +317 -0
- data/doc/style.css +187 -0
- data/doc/tutorial.ja.html +182 -0
- data/example/Makefile +54 -0
- data/example/cat_n.rb +14 -0
- data/example/exception.rb +9 -0
- data/example/ext/Win32API.so +0 -0
- data/example/ext/swin.so +0 -0
- data/example/msgbox.rb +14 -0
- data/example/rubytk.rb +22 -0
- data/example/runtime.ico +0 -0
- data/example/runtime.rb +19 -0
- data/example/vr/clipboard.rb +106 -0
- data/example/vr/compat/rubycompat.rb +18 -0
- data/example/vr/compat/vrcomctl.rb +12 -0
- data/example/vr/compat/vrcontrol.rb +50 -0
- data/example/vr/compat/vrmmedia.rb +24 -0
- data/example/vr/contrib/inifile.rb +116 -0
- data/example/vr/contrib/msgboxconst.rb +55 -0
- data/example/vr/contrib/toolbar.rb +371 -0
- data/example/vr/contrib/vrctlcolor.rb +110 -0
- data/example/vr/contrib/vrhotkey.rb +35 -0
- data/example/vr/contrib/vrlistviewex.rb +71 -0
- data/example/vr/contrib/vrstdscrollbar.rb +414 -0
- data/example/vr/contrib/vrwincomponent.rb +54 -0
- data/example/vr/dragdropformat.rb +209 -0
- data/example/vr/rscutil.rb +168 -0
- data/example/vr/sysmod.rb +249 -0
- data/example/vr/vractivex.rb +56 -0
- data/example/vr/vrclipboard.rb +53 -0
- data/example/vr/vrcomctl.rb +1819 -0
- data/example/vr/vrcontrol.rb +1374 -0
- data/example/vr/vrdde.rb +623 -0
- data/example/vr/vrddrop.rb +190 -0
- data/example/vr/vrdialog.rb +406 -0
- data/example/vr/vrhandler.rb +195 -0
- data/example/vr/vrlayout.old.rb +209 -0
- data/example/vr/vrlayout.rb +173 -0
- data/example/vr/vrlayout2.rb +340 -0
- data/example/vr/vrmargin.rb +141 -0
- data/example/vr/vrmgdlayout.rb +381 -0
- data/example/vr/vrmmedia.rb +287 -0
- data/example/vr/vrolednd.rb +192 -0
- data/example/vr/vrowndraw.rb +108 -0
- data/example/vr/vrrichedit.rb +366 -0
- data/example/vr/vrtimer.rb +148 -0
- data/example/vr/vrtooltip.rb +273 -0
- data/example/vr/vrtray.rb +143 -0
- data/example/vr/vrtvitem.rb +118 -0
- data/example/vr/vrtwopane.rb +223 -0
- data/example/vr/vruby.rb +1051 -0
- data/example/vr/winconst.rb +158 -0
- data/example/vruby.rb +38 -0
- data/exerb.gemspec +26 -0
- data/extconf.rb +7 -0
- data/lib/exerb/archive.rb +143 -0
- data/lib/exerb/config.rb +51 -0
- data/lib/exerb/error.rb +15 -0
- data/lib/exerb/executable.rb +68 -0
- data/lib/exerb/file_table.rb +189 -0
- data/lib/exerb/mkexy.rb +81 -0
- data/lib/exerb/name_table.rb +120 -0
- data/lib/exerb/recipe.rb +465 -0
- data/lib/exerb/resource.rb +190 -0
- data/lib/exerb/resource/base.rb +29 -0
- data/lib/exerb/resource/binary.rb +31 -0
- data/lib/exerb/resource/dialog.rb +30 -0
- data/lib/exerb/resource/group_icon.rb +85 -0
- data/lib/exerb/resource/icon.rb +52 -0
- data/lib/exerb/resource/version_info.rb +155 -0
- data/lib/exerb/resource_library.rb +120 -0
- data/lib/exerb/utility.rb +95 -0
- data/lib/exerb/utility2.rb +122 -0
- data/lib/exerb/version.rb +13 -0
- data/lib/exerb/win32/const/resource.rb +51 -0
- data/lib/exerb/win32/icon_file.rb +78 -0
- data/lib/exerb/win32/pe_file.rb +59 -0
- data/lib/exerb/win32/resource_directory.rb +105 -0
- data/lib/exerb/win32/resource_directory_root.rb +67 -0
- data/lib/exerb/win32/resource_entry.rb +98 -0
- data/lib/exerb/win32/struct/base.rb +43 -0
- data/lib/exerb/win32/struct/icon_dir_entry.rb +83 -0
- data/lib/exerb/win32/struct/icon_header.rb +43 -0
- data/lib/exerb/win32/struct/icon_res_entry.rb +48 -0
- data/lib/exerb/win32/struct/image_dos_header.rb +73 -0
- data/lib/exerb/win32/struct/image_file_header.rb +47 -0
- data/lib/exerb/win32/struct/image_nt_headers32.rb +53 -0
- data/lib/exerb/win32/struct/image_optional_header32.rb +107 -0
- data/lib/exerb/win32/struct/image_resource_data_entry.rb +45 -0
- data/lib/exerb/win32/struct/image_resource_directory.rb +47 -0
- data/lib/exerb/win32/struct/image_resource_directory_entry.rb +72 -0
- data/lib/exerb/win32/struct/image_section_header.rb +53 -0
- data/lib/exerb/win32/struct/version_info_block.rb +75 -0
- data/lib/exerb/win32/struct/vs_fixed_file_info.rb +62 -0
- data/src/exerb/cui.c +48 -0
- data/src/exerb/default.rb +1 -0
- data/src/exerb/exerb.c +877 -0
- data/src/exerb/exerb.h +92 -0
- data/src/exerb/gui.c +176 -0
- data/src/exerb/module.c +138 -0
- data/src/exerb/module.h +7 -0
- data/src/exerb/patch.c +27 -0
- data/src/exerb/resource.h +22 -0
- data/src/exerb/resource.rc +121 -0
- data/src/exerb/ruby.ico +0 -0
- data/src/exerb/utility.c +263 -0
- data/src/exerb/utility.h +33 -0
- data/test/alltests.rb +16 -0
- data/test/test-argv.rb +26 -0
- data/test/test-argv/test-argv.rb +9 -0
- data/test/test-argv/test-argv.ret +1 -0
- data/test/test-dollarzero.rb +26 -0
- data/test/test-dollarzero/test-dollarzero.rb +10 -0
- data/test/test-dollarzero/test-dollarzero.ret +2 -0
- data/test/test-dot.rb +26 -0
- data/test/test-dot/dot.dot.dot.rb +9 -0
- data/test/test-dot/dot.dot.rb +9 -0
- data/test/test-dot/test-dot.rb +13 -0
- data/test/test-dot/test-dot.ret +5 -0
- data/test/test-exitcode.rb +28 -0
- data/test/test-exitcode/test-exitcode.rb +9 -0
- data/test/test-kcode.rb +43 -0
- data/test/test-kcode/euc.rb +10 -0
- data/test/test-kcode/euc.ret +2 -0
- data/test/test-kcode/none.rb +10 -0
- data/test/test-kcode/none.ret +2 -0
- data/test/test-kcode/sjis.rb +10 -0
- data/test/test-kcode/sjis.ret +2 -0
- data/test/test-kcode/utf8.rb +10 -0
- data/test/test-kcode/utf8.ret +2 -0
- data/test/test-loadpath.rb +24 -0
- data/test/test-loadpath/test-loadpath.rb +9 -0
- data/test/test-nest.rb +18 -0
- data/test/test-nest/foo.rb +1 -0
- data/test/test-nest/foo/bar.rb +2 -0
- data/test/test-nest/foo/foo.rb +1 -0
- data/test/test-nest/test-nest.rb +1 -0
- data/test/test-nest/test-nest.ret +1 -0
- data/test/test-preload.rb +24 -0
- data/test/test-preload/test-preload.rb +9 -0
- data/test/test-regexp.rb +26 -0
- data/test/test-regexp/test-regexp.rb +23 -0
- data/test/test-regexp/test-regexp.ret +13 -0
- data/test/test-require1.rb +26 -0
- data/test/test-require1/require1.rb +9 -0
- data/test/test-require1/require2.rb +9 -0
- data/test/test-require1/require3.rb +9 -0
- data/test/test-require1/require4.rb +9 -0
- data/test/test-require1/require5.rb +9 -0
- data/test/test-require1/require6.rb +9 -0
- data/test/test-require1/test-require1.rb +41 -0
- data/test/test-require1/test-require1.ret +27 -0
- data/test/test-socket.rb +26 -0
- data/test/test-socket/test-socket.rb +7 -0
- data/test/test-socket/test-socket.ret +1 -0
- data/test/testcase.rb +66 -0
- data/vendor/mkexports.rb +167 -0
- metadata +352 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
###################################
|
2
|
+
#
|
3
|
+
# vractivex.rb
|
4
|
+
# Programmed by nyasu <nyasu@osk.3web.ne.jp>
|
5
|
+
# Copyright 2003-2005 Nishikawa,Yasuhiro
|
6
|
+
#
|
7
|
+
# More information at http://vruby.sourceforge.net/index.html
|
8
|
+
#
|
9
|
+
###################################
|
10
|
+
|
11
|
+
require 'vr/vruby'
|
12
|
+
require 'Win32API'
|
13
|
+
require 'win32ole'
|
14
|
+
|
15
|
+
class VRActiveXControl < VRControl
|
16
|
+
AtlAxWinInit=Win32API.new("atl.dll","AtlAxWinInit","","I")
|
17
|
+
AtlAxWinInit.call
|
18
|
+
|
19
|
+
WINCLASSINFO=["AtlAxWin",0]
|
20
|
+
ACTIVEXCINFO=["",""] # PROGID,EVENTSINK
|
21
|
+
|
22
|
+
alias :progId :caption
|
23
|
+
alias :progId= :caption=
|
24
|
+
def caption() "" end
|
25
|
+
def caption=(arg) arg end
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
self.progId = self.class::ACTIVEXCINFO[0]
|
29
|
+
class <<self
|
30
|
+
undef_method :progId=
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def vrinit
|
35
|
+
super
|
36
|
+
@_vr_win32ole = self.get_oleinterface
|
37
|
+
if self.class::ACTIVEXCINFO[1] then
|
38
|
+
@_vr_win32ole_event =
|
39
|
+
WIN32OLE_EVENT.new(@_vr_win32ole,self.class::ACTIVEXCINFO[1])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def ole_interface() @_vr_win32ole; end
|
44
|
+
def ole_events() @_vr_win32ole_event; end
|
45
|
+
|
46
|
+
def add_oleeventhandler(evname,handlername=evname.downcase)
|
47
|
+
ole_events.on_event(evname) do |*args|
|
48
|
+
@parent.controlmsg_dispatching(self,handlername,*args)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def _invoke(*args) @_vr_win32ole._invoke(*args) end
|
53
|
+
def _setproperty(*args) @_vr_win32ole._setproperty(*args) end
|
54
|
+
def _getproperty(*args) @_vr_win32ole._getproperty(*args) end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
###################################
|
2
|
+
#
|
3
|
+
# vrclipboard.rb
|
4
|
+
# Programmed by nyasu <nyasu@osk.3web.ne.jp>
|
5
|
+
# Copyright 2000-2005 Nishikawa,Yasuhiro
|
6
|
+
#
|
7
|
+
# More information at http://vruby.sourceforge.net/index.html
|
8
|
+
#
|
9
|
+
#
|
10
|
+
###################################
|
11
|
+
|
12
|
+
VR_DIR="vr/" unless defined?(::VR_DIR)
|
13
|
+
require VR_DIR+'vruby'
|
14
|
+
|
15
|
+
module VRClipboardObserver
|
16
|
+
=begin
|
17
|
+
== VRClipboardObserver
|
18
|
+
module for clipboard observing.
|
19
|
+
|
20
|
+
=== Handlers
|
21
|
+
--- self_drawclipboard
|
22
|
+
Fired when clipboard is changed.
|
23
|
+
=end
|
24
|
+
|
25
|
+
include VRMessageHandler
|
26
|
+
|
27
|
+
SetClipboardViewer = Win32API.new('user32','SetClipboardViewer','L','L')
|
28
|
+
ChangeClipboardChain = Win32API.new('user32','ChangeClipboardChain','LL','I')
|
29
|
+
WM_CHANGECBCHAIN = 781
|
30
|
+
WM_DRAWCLIPBOARD = 776
|
31
|
+
|
32
|
+
def clipboardobserverinit
|
33
|
+
@cbchainnext = SetClipboardViewer.call(self.hWnd)
|
34
|
+
addHandler WM_DRAWCLIPBOARD,"drawclipboard",MSGTYPE::ARGNONE,nil
|
35
|
+
addHandler WM_CHANGECBCHAIN,"vrchangecbchain",MSGTYPE::ARGINTINT,nil
|
36
|
+
addHandler WMsg::WM_DESTROY,"vrcbdestroy",MSGTYPE::ARGNONE,nil
|
37
|
+
acceptEvents [WM_DRAWCLIPBOARD,WM_CHANGECBCHAIN,WMsg::WM_DESTROY]
|
38
|
+
end
|
39
|
+
|
40
|
+
def vrinit
|
41
|
+
super
|
42
|
+
clipboardobserverinit
|
43
|
+
end
|
44
|
+
|
45
|
+
def self_vrchangecbchain(hwndremove,hwndnext)
|
46
|
+
@cbchainnext=hwndnext if hwndremove == @cbchainnext
|
47
|
+
end
|
48
|
+
|
49
|
+
def self_vrcbdestroy
|
50
|
+
ChangeClipboardChain.call self.hWnd,@cbchainnext
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,1819 @@
|
|
1
|
+
###################################
|
2
|
+
#
|
3
|
+
# vrcomctl.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
|
+
|
14
|
+
=begin
|
15
|
+
= VisualuRuby(tmp) Common Controls.
|
16
|
+
This file prepares classes of common controls, panels and menu modules.
|
17
|
+
|
18
|
+
<<< handlers.rd
|
19
|
+
|
20
|
+
=end
|
21
|
+
|
22
|
+
require 'Win32API'
|
23
|
+
|
24
|
+
begin
|
25
|
+
Win32API.new("comctl32","InitCommonControlsEx","P","").call [8,0x400].pack("LL")
|
26
|
+
VR_OLDCOMCTL=false
|
27
|
+
rescue
|
28
|
+
# puts "comctl too old to use rebar and so on"
|
29
|
+
VR_OLDCOMCTL=true
|
30
|
+
end
|
31
|
+
|
32
|
+
module WMsg
|
33
|
+
NFR_ANSI=1
|
34
|
+
NFR_UNICODE=2
|
35
|
+
NF_QUERY=3
|
36
|
+
NF_REQUERY=4
|
37
|
+
WM_NOTIFYFORMAT=85
|
38
|
+
end
|
39
|
+
|
40
|
+
module WStyle
|
41
|
+
CCS_TOP = 0x00000001
|
42
|
+
CCS_NOMOVEY = 0x00000002
|
43
|
+
CCS_BOTTOM = 0x00000003
|
44
|
+
CCS_NORESIZE = 0x00000004
|
45
|
+
end
|
46
|
+
|
47
|
+
module WStruct
|
48
|
+
NMHDR="UUU"
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
##################
|
53
|
+
#
|
54
|
+
# The following control windows send WM_NOTIFY message to their parent
|
55
|
+
# This definition is for handling them.
|
56
|
+
#
|
57
|
+
|
58
|
+
module VRComCtlContainer
|
59
|
+
=begin
|
60
|
+
== VRComCtlContainer
|
61
|
+
This module provides a message handler for WM_NOTIFY, which calls
|
62
|
+
defined method in a parent window.
|
63
|
+
VRForm includes this module automatically loading "vrcomctl.rb".
|
64
|
+
=end
|
65
|
+
|
66
|
+
include VRMessageHandler
|
67
|
+
|
68
|
+
def comctlcontainerinit
|
69
|
+
addHandler(WMsg::WM_NOTIFY,"wmnotify", MSGTYPE::ARGPASS, nil)
|
70
|
+
addHandler(WMsg::WM_NOTIFYFORMAT,"wmnotifyformat",MSGTYPE::ARGINTINT,nil)
|
71
|
+
addEvent WMsg::WM_NOTIFY
|
72
|
+
addEvent WMsg::WM_NOTIFYFORMAT
|
73
|
+
|
74
|
+
addNoRelayMessages [WMsg::WM_NOTIFY,WMsg::WM_NOTIFYFORMAT]
|
75
|
+
end
|
76
|
+
|
77
|
+
def vrinit
|
78
|
+
super
|
79
|
+
comctlcontainerinit
|
80
|
+
end
|
81
|
+
|
82
|
+
def self_wmnotifyformat(parent,command)
|
83
|
+
SKIP_DEFAULTHANDLER[1]
|
84
|
+
end
|
85
|
+
|
86
|
+
def self_wmnotify(msg)
|
87
|
+
|
88
|
+
orig_arg= @screen.application.cstruct2array(msg.lParam,WStruct::NMHDR)
|
89
|
+
|
90
|
+
id=msg.wParam
|
91
|
+
ct=@controls[id] # Activated Control
|
92
|
+
if !ct then return end # Ignore message passed through childwin
|
93
|
+
|
94
|
+
return unless ct.is_a?(VRNotifyControl) and # Added by yukimi_sake
|
95
|
+
ct._vr_ntfyhandlers and ct._vr_ntfyhandlers[orig_arg[2]]
|
96
|
+
ct._vr_ntfyhandlers[orig_arg[2]].each do |shandler|
|
97
|
+
args=msgarg2handlerarg(shandler[1],msg,shandler[2])
|
98
|
+
if args.size>0 and ct.respond_to?("_vr_notifyarg") then
|
99
|
+
necessary_arg=ct._vr_notifyarg[orig_arg[2]]
|
100
|
+
if necessary_arg then
|
101
|
+
n=necessary_arg.size-1
|
102
|
+
0.upto(n) do |idx|
|
103
|
+
args[idx+3]=nil if necessary_arg[idx,1]=='F'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
args=args[3..-1].compact
|
107
|
+
end
|
108
|
+
|
109
|
+
ct.__send__(shandler[0],*args) if ct.respond_to?(shandler[0])
|
110
|
+
msg.retval = controlmsg_dispatching(ct,shandler[0],*args)
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
module VRContainersSet
|
117
|
+
include VRComCtlContainer
|
118
|
+
INITIALIZERS.push :comctlcontainerinit
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
####################################
|
123
|
+
#
|
124
|
+
# Argument Utilities for Common Controls
|
125
|
+
#
|
126
|
+
|
127
|
+
class VRNotifyControl < VRControl
|
128
|
+
=begin
|
129
|
+
== VRNotifyControl
|
130
|
+
All common controls have these event handlers.
|
131
|
+
=== Event handlers
|
132
|
+
--- ????_clicked
|
133
|
+
fired when the control is clicked with left button.
|
134
|
+
--- ????_hitreturn
|
135
|
+
fired when the control has the input focus and the user press ((*ENTER*)) key.
|
136
|
+
--- ????_dblclicked
|
137
|
+
fired when the control is double-clicked with left button.
|
138
|
+
--- ????_rclicked
|
139
|
+
fired when the control is clicked with right button.
|
140
|
+
--- ????_rdblclicked
|
141
|
+
fired when the control is double-clicked with rightbutton.
|
142
|
+
--- ????_gotfocus
|
143
|
+
fired when the control has got the input focus
|
144
|
+
--- ????_lostfocus
|
145
|
+
fired when the control has lost the input focus
|
146
|
+
=end
|
147
|
+
|
148
|
+
attr :_vr_notifyarg
|
149
|
+
|
150
|
+
def _vr_ntfyhandlers
|
151
|
+
unless defined?(@_vr_ntfyhandlers)
|
152
|
+
@_vr_ntfyhandlers={}
|
153
|
+
else
|
154
|
+
@_vr_ntfyhandlers
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
def notifycontrolinit
|
160
|
+
@_vr_notifyarg={}
|
161
|
+
addNotifyHandler(0xfffffffe,"clicked",MSGTYPE::ARGNONE,nil)
|
162
|
+
addNotifyHandler(0xfffffffd,"dblclicked",MSGTYPE::ARGNONE,nil)
|
163
|
+
addNotifyHandler(0xfffffffc,"hitreturn",MSGTYPE::ARGNONE,nil)
|
164
|
+
addNotifyHandler(0xfffffffb,"rclicked",MSGTYPE::ARGNONE,nil)
|
165
|
+
addNotifyHandler(0xfffffffa,"rdblclicked",MSGTYPE::ARGNONE,nil)
|
166
|
+
addNotifyHandler(0xfffffff9,"gotfocus",MSGTYPE::ARGNONE,nil)
|
167
|
+
addNotifyHandler(0xfffffff8,"lostfocus",MSGTYPE::ARGNONE,nil)
|
168
|
+
end
|
169
|
+
def vrinit
|
170
|
+
super
|
171
|
+
notifycontrolinit
|
172
|
+
end
|
173
|
+
|
174
|
+
def addFilterArg(msg,filter) # filter as str : 'T'=true, 'F'=false
|
175
|
+
@_vr_notifyarg[msg]=filter
|
176
|
+
end
|
177
|
+
def deleteFilterArg(msg)
|
178
|
+
@_vr_notifyarg[msg]=nil
|
179
|
+
end
|
180
|
+
|
181
|
+
def addNotifyHandler(msg,handlername,handlertype,argparsestr)
|
182
|
+
@_vr_ntfyhandlers={} unless defined?(@_vr_ntfyhandlers)
|
183
|
+
@_vr_ntfyhandlers[msg]=[] unless @_vr_ntfyhandlers[msg]
|
184
|
+
@_vr_ntfyhandlers[msg].push [handlername,handlertype,argparsestr]
|
185
|
+
end
|
186
|
+
|
187
|
+
def deleteNotifyHandler(msg,handlername)
|
188
|
+
return false unless @_vr_ntfyhandlers and @_vr_ntfyhandlers[msg]
|
189
|
+
@_vr_ntfyhandlers.delete_if do |shandler|
|
190
|
+
shandler[0] != (PREHANDLERSTR+handlername).intern
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
|
196
|
+
###################################
|
197
|
+
# Common Controls
|
198
|
+
#
|
199
|
+
|
200
|
+
# Listview
|
201
|
+
|
202
|
+
module WMsg
|
203
|
+
LVM_GETBKCOLOR = 0x1000 #GETBKCOLOR, LVM_FIRST
|
204
|
+
LVM_SETBKCOLOR = 0x1001
|
205
|
+
|
206
|
+
LVM_SETIMAGELIST = 0x1003
|
207
|
+
LVM_GETITEMCOUNT = 0x1004
|
208
|
+
LVM_GETITEM = 0x1005 #GETITEMA
|
209
|
+
LVM_SETITEM = 0x1006 #SETITEMA
|
210
|
+
LVM_INSERTITEM = 0x1007 #INSERTITEMA
|
211
|
+
LVM_DELETEITEM = 0x1008
|
212
|
+
LVM_DELETEALLITEM = 0x1009
|
213
|
+
|
214
|
+
LVM_GETNEXTITEM = 0x1000 + 12
|
215
|
+
LVM_GETITEMRECT = 0x1000 + 14
|
216
|
+
LVM_HITTEST = 0x1000 + 18
|
217
|
+
LVM_ENSUREVISIBLE = 0x1000 + 19
|
218
|
+
|
219
|
+
LVM_GETCOLUMN = 0x1000+25 #GETCOLUMNA
|
220
|
+
LVM_SETCOLUMN = 0x1000+26 #SETCOLUMNA
|
221
|
+
LVM_INSERTCOLUMN = 0x1000+27 #INSERTCOLUMNA
|
222
|
+
LVM_DELETECOLUMN = 0x1000+28 #DELETECOLUMNA
|
223
|
+
LVM_GETCOLUMNWIDTH= 0x1000+29
|
224
|
+
LVM_SETCOLUMNWIDTH= 0x1000+30
|
225
|
+
|
226
|
+
LVM_SETITEMSTATE = 0x1000+43
|
227
|
+
LVM_GETITEMSTATE = 0x1000+44
|
228
|
+
LVM_GETITEMTEXT = 0x1000+45 #GETITEMTEXTA
|
229
|
+
LVM_SETITEMTEXT = 0x1000+46 #SETITEMTEXTA
|
230
|
+
LVM_SORTITEMS = 0x1000+48
|
231
|
+
LVM_GETSELECTED = 0x1000+50 #LVM_GETSELECTEDCOUNT
|
232
|
+
LVM_SETEXTENDEDLISTVIEWSTYLE = 0x1000 + 54
|
233
|
+
LVM_GETEXTENDEDLISTVIEWSTYLE = 0x1000 + 55
|
234
|
+
LVM_SUBITEMHITTEST= 0x1000+57
|
235
|
+
|
236
|
+
LVN_ITEMCHANGING = 0xffffffff-99
|
237
|
+
LVN_ITEMCHANGED = LVN_ITEMCHANGING-1
|
238
|
+
LVN_INSERTITEM = LVN_ITEMCHANGING-2
|
239
|
+
LVN_DELETEITEM = LVN_ITEMCHANGING-3
|
240
|
+
LVN_COLUMNCLICK = LVN_ITEMCHANGING-8
|
241
|
+
LVN_BEGINDRAG = LVN_ITEMCHANGING-9
|
242
|
+
LVN_BEGINRDRAG = LVN_ITEMCHANGING-11
|
243
|
+
end
|
244
|
+
module WStyle
|
245
|
+
LVS_ICON = 0x0000
|
246
|
+
LVS_REPORT = 0x0001
|
247
|
+
LVS_SMALLICON = 0x0002
|
248
|
+
LVS_LIST = 0x0003
|
249
|
+
LVS_SINGLESEL = 4
|
250
|
+
LVS_SHOWSELALWAYS = 8
|
251
|
+
end
|
252
|
+
module WExStyle
|
253
|
+
LVS_EX_FULLROWSELECT=32
|
254
|
+
LVS_EX_GRIDLINES=1
|
255
|
+
end
|
256
|
+
|
257
|
+
module WConst
|
258
|
+
LVIS_FOCUSED = 0x0001
|
259
|
+
LVIS_SELECTED = 0x0002
|
260
|
+
LVIS_CUT = 0x0004
|
261
|
+
LVIS_DROPHILITED = 0x0008
|
262
|
+
end
|
263
|
+
module WStruct
|
264
|
+
LVITEM = "UIIUUPIIL"
|
265
|
+
LVCOLUMN = "UIIPIIII"
|
266
|
+
LVFIND = "UPLPU"
|
267
|
+
LVHITTEST = "IIUI"
|
268
|
+
NM_LISTVIEW= NMHDR+"IIUUULLL" #INT item,subitem,UINT nst,ost,chg,POINT,LParam
|
269
|
+
end
|
270
|
+
|
271
|
+
class VRListview < VRNotifyControl
|
272
|
+
=begin
|
273
|
+
== VRListview
|
274
|
+
Listview.
|
275
|
+
Some features has not implemented yet.
|
276
|
+
=== Method
|
277
|
+
--- setViewMode(mode)
|
278
|
+
((|mode|)) as viewmode. 0 for ICON, 1 for REPORT, 2 for SMALLICON and
|
279
|
+
3 for LIST
|
280
|
+
--- getViewMode
|
281
|
+
Returns the view mode.
|
282
|
+
--- iconview
|
283
|
+
Sets the view mode for Icon view.
|
284
|
+
--- reportview
|
285
|
+
Sets the view mode for Report view.
|
286
|
+
--- smalliconview
|
287
|
+
Sets the view mode for Small icon view.
|
288
|
+
--- listview
|
289
|
+
Sets the view mode for listing view.
|
290
|
+
--- setBkColor(color)
|
291
|
+
--- bkcolor=(color)
|
292
|
+
Sets the background color.
|
293
|
+
--- lvexstyle
|
294
|
+
--- lvexstyle=(style)
|
295
|
+
Gets/Sets Listview extended style.
|
296
|
+
If you need style mask, use setListviewExStyle()
|
297
|
+
--- setListviewExStyle(style,mask=0xffffffff)
|
298
|
+
Sets Listview extended style using style mask.
|
299
|
+
|
300
|
+
--- insertColumn(column,text,width=50,format=0,textsize=title.size)
|
301
|
+
Inserts a new column specified by ((|text|)), ((|width|)) and ((|format|))
|
302
|
+
into the index of ((|column|)), which is started from 0.
|
303
|
+
((|format|)) means 0 for left-padded, 1 for right-padded, 2 for centred.
|
304
|
+
--- deleteColumn(column)
|
305
|
+
Deletes the column at the index of ((|column|))
|
306
|
+
--- clearColumns
|
307
|
+
Deletes all columns.
|
308
|
+
--- countColumns
|
309
|
+
Counts the number of columns.
|
310
|
+
--- addColumn(text,width=50,format=0,textsize=title.size)
|
311
|
+
Adds a new column after the last column.
|
312
|
+
--- setImagelist(imagelist,itype=0)
|
313
|
+
Set ((|imagelist|)) for displaying icons of items. ((|imagelist|)) must be
|
314
|
+
a kind of SWin::Imagelist. ((|itype|)) specifies the type of Imagelist.
|
315
|
+
itype : 0 for normal icon, 1 for small icon (,2 for state icon).
|
316
|
+
--- setItemIconOf(hitem,img)
|
317
|
+
Sets image ids in a imagelist of the item.
|
318
|
+
The imagelist is set by ((<setImagelist>)) method.
|
319
|
+
--- getItemIconOf(hitem)
|
320
|
+
Returns images id of the item.
|
321
|
+
--- getColumnWidthOf(column)
|
322
|
+
Returns the width of the column whose index is ((|column|)).
|
323
|
+
--- setColumnWidthOf(column,width)
|
324
|
+
Sets the width of the column.
|
325
|
+
--- getColumnTextOf(column)
|
326
|
+
Returns the text of the column whose index is ((|column|)).
|
327
|
+
--- setColumnTextOf(column,text)
|
328
|
+
Sets the text of the column.
|
329
|
+
--- getColumnFormatOf(column)
|
330
|
+
Returns the format of the column whose index is ((|column|)).
|
331
|
+
(see ((<insertColumn>)) about format)
|
332
|
+
--- setColumnFormatOf(column,format)
|
333
|
+
Sets the format of the column.
|
334
|
+
--- insertItem(index,texts,lparam=0,textsize=128)
|
335
|
+
Inserts a new item into the index of ((|index|)).((|texts|)) is an array of
|
336
|
+
String which means [item_text, subitem_text, subitem2_text,...].
|
337
|
+
((|lparam|)) is a 32bit value concerned with the item.
|
338
|
+
((|textsize|)) is the limit length of the item texts.
|
339
|
+
--- addItem(texts,lparam=0,textsize=128)
|
340
|
+
Adds a new item after the last item.
|
341
|
+
--- insertMultiItems(index,multitexts)
|
342
|
+
Inserts new items into the index of ((|index|)).
|
343
|
+
((|multitexts|)) is an array which is the arguments of ((<insertItem>))
|
344
|
+
excluding ((|index|))
|
345
|
+
--- deleteItem(idx)
|
346
|
+
Deletes an item at the index of ((|idx|)).
|
347
|
+
--- clearItems
|
348
|
+
Deletes all items.
|
349
|
+
--- countItems
|
350
|
+
Counts the items.
|
351
|
+
--- hittest(x,y)
|
352
|
+
Inspect the item index which is at the co-ordinate(((|x|)),((|y|)))
|
353
|
+
--- hittest2(x,y)
|
354
|
+
Returns the item information which is at the co-ordinate(((|x|)),((|y|))).
|
355
|
+
The information is the array [x,y,part,index,subitem]
|
356
|
+
--- getItemRect(idx)
|
357
|
+
Returns an co-ordinates array of integers [left,top,right,bottom]
|
358
|
+
--- getItemStateOf(idx)
|
359
|
+
Returns the item state at the index of ((|idx|)).
|
360
|
+
The state is 1 for forcused, 2 for selected, 3 for cut and 4 fordrophilited.
|
361
|
+
--- setItemStateOf(idx,state)
|
362
|
+
Sets the item state.
|
363
|
+
--- selectItem(idx,flag)
|
364
|
+
Change selected state of the item at the index of ((|idx|)).
|
365
|
+
If ((|flag|)) is true, the item is selected and if it's false the item is
|
366
|
+
un-selected.
|
367
|
+
--- getNextItem(start,flags)
|
368
|
+
Searches for an item described by ((|start|)) and ((|flags|)).
|
369
|
+
((|flags|)) is
|
370
|
+
* 1 : focused item after ((|start|))
|
371
|
+
* 2 : selected item after ((|start|))
|
372
|
+
* 4 : cut item after ((|start|))
|
373
|
+
* 8 : drophilited item after ((|start|))
|
374
|
+
* 0x100 : item above ((|start|))
|
375
|
+
* 0x200 : item below ((|start|))
|
376
|
+
* 0x400 : left item from ((|start|))
|
377
|
+
* 0x800 : right item from ((|start|))
|
378
|
+
--- focusedItem
|
379
|
+
Returns index of the focused item.
|
380
|
+
--- getItemTextOf(idx,subitem=0,textsize=128)
|
381
|
+
Retrieves the sub-text of the item (index ((|idx|)) ).
|
382
|
+
((|subitem|)) specifies the subitem number.
|
383
|
+
--- setItemTextOf(idx,subitem,text,textsize=text.size)
|
384
|
+
Sets the sub-text of the item.
|
385
|
+
--- getItemLParamOf(idx)
|
386
|
+
Gets the lParam of the item.
|
387
|
+
--- setItemLParamOf(idx,lparam)
|
388
|
+
Sets the lParam of the item.
|
389
|
+
--- selected?(idx)
|
390
|
+
Returns true if the item is selected.
|
391
|
+
--- focused?(idx)
|
392
|
+
Returns true if the item is focused.
|
393
|
+
--- eachSelectedItems
|
394
|
+
Yields each selected item index.
|
395
|
+
--- countSelectedItems()
|
396
|
+
Counts the selected items.
|
397
|
+
--- ensureVisible(i,partial=true)
|
398
|
+
Ensures the item(idx) is visible by scrolling.
|
399
|
+
|
400
|
+
=== Event handlers
|
401
|
+
--- ????_itemchanged(idx,state)
|
402
|
+
fired when the item state is changed. This also means that this is fired after changing selected items.
|
403
|
+
((|idx|)) is the index of the item and ((|state|)) is the new state.
|
404
|
+
--- ????_itemchanging(idx,state)
|
405
|
+
fired when the item state is changing.
|
406
|
+
--- ????_columnclick(subitem)
|
407
|
+
fired when the column is clicked. ((|subitem|)) is the column index.
|
408
|
+
--- ????_begindrag
|
409
|
+
--- ????_beginrdrag
|
410
|
+
=end
|
411
|
+
|
412
|
+
public
|
413
|
+
WINCLASSINFO = ["SysListView32",WStyle::LVS_REPORT,0x200]
|
414
|
+
|
415
|
+
def listviewinit
|
416
|
+
addNotifyHandler(WMsg::LVN_ITEMCHANGED,"itemchanged",
|
417
|
+
MSGTYPE::ARGSTRUCT,WStruct::NM_LISTVIEW)
|
418
|
+
addFilterArg WMsg::LVN_ITEMCHANGED,"TFFTFFFF"
|
419
|
+
|
420
|
+
addNotifyHandler(WMsg::LVN_ITEMCHANGING,"itemchanging",
|
421
|
+
MSGTYPE::ARGSTRUCT,WStruct::NM_LISTVIEW)
|
422
|
+
addFilterArg WMsg::LVN_ITEMCHANGING,"TFFTFFFF"
|
423
|
+
|
424
|
+
addNotifyHandler(WMsg::LVN_COLUMNCLICK,"columnclick",
|
425
|
+
MSGTYPE::ARGSTRUCT,WStruct::NM_LISTVIEW)
|
426
|
+
addFilterArg WMsg::LVN_COLUMNCLICK,"FTFFFFFF"
|
427
|
+
|
428
|
+
addNotifyHandler(WMsg::LVN_BEGINDRAG,"begindrag",
|
429
|
+
MSGTYPE::ARGNONE,nil)
|
430
|
+
|
431
|
+
addNotifyHandler(WMsg::LVN_BEGINRDRAG,"beginrdrag",
|
432
|
+
MSGTYPE::ARGNONE,nil)
|
433
|
+
end
|
434
|
+
def vrinit
|
435
|
+
super
|
436
|
+
listviewinit
|
437
|
+
end
|
438
|
+
|
439
|
+
def setViewMode(mode)
|
440
|
+
self.style = (self.style & 0xfffffff8) + (mode&3)
|
441
|
+
end
|
442
|
+
def getViewMode
|
443
|
+
self.style & 0xfffffff8
|
444
|
+
end
|
445
|
+
def iconview() setViewMode(0) end
|
446
|
+
def reportview() setViewMode(1) end
|
447
|
+
def smalliconview() setViewMode(2) end
|
448
|
+
def listview() setViewMode(3) end
|
449
|
+
|
450
|
+
|
451
|
+
def setBkColor(color)
|
452
|
+
sendMessage WMsg::LVM_SETBKCOLOR,0,color.to_i
|
453
|
+
end
|
454
|
+
|
455
|
+
def bkcolor=(color)
|
456
|
+
setBkColor(color)
|
457
|
+
end
|
458
|
+
|
459
|
+
def setListviewExStyle(sty,mask=0xffffffff)
|
460
|
+
sendMessage WMsg::LVM_SETEXTENDEDLISTVIEWSTYLE,mask,sty
|
461
|
+
end
|
462
|
+
def lvexstyle=(sty)
|
463
|
+
setListviewExStyle(sty)
|
464
|
+
end
|
465
|
+
def lvexstyle
|
466
|
+
sendMessage WMsg::LVM_GETEXTENDEDLISTVIEWSTYLE,0,0
|
467
|
+
end
|
468
|
+
|
469
|
+
def insertColumn(column,title,width=50,style=0,textsize=title.size)
|
470
|
+
lv=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
|
471
|
+
0xf,style.to_i,width.to_i,title.to_s,textsize,column,0,0)
|
472
|
+
sendMessage WMsg::LVM_INSERTCOLUMN,column.to_i,lv
|
473
|
+
end
|
474
|
+
|
475
|
+
def deleteColumn(column)
|
476
|
+
sendMessage(WMsg::LVM_DELETECOLUMN,column.to_i,0)
|
477
|
+
end
|
478
|
+
def clearColumns
|
479
|
+
while sendMessage(WMsg::LVM_DELETECOLUMN,0,0)!=0 do; end
|
480
|
+
end
|
481
|
+
|
482
|
+
def countColumns
|
483
|
+
r=0
|
484
|
+
while getColumnTextOf(r) do r+=1; end
|
485
|
+
r
|
486
|
+
end
|
487
|
+
|
488
|
+
def addColumn(*args)
|
489
|
+
insertColumn(30000,*args) #30000 as a big number. I believe this is enough.
|
490
|
+
end
|
491
|
+
|
492
|
+
def getColumnWidthOf(column)
|
493
|
+
sendMessage(WMsg::LVM_GETCOLUMNWIDTH,column.to_i,0)
|
494
|
+
end
|
495
|
+
|
496
|
+
def setColumnWidthOf(column,width)
|
497
|
+
sendMessage(WMsg::LVM_SETCOLUMNWIDTH,column.to_i,width.to_i)
|
498
|
+
end
|
499
|
+
|
500
|
+
def setColumnTextOf(column,text)
|
501
|
+
p=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
|
502
|
+
4,0,0,text,text.size,0)
|
503
|
+
sendMessage WMsg::LVM_SETCOLUMN,column.to_i,p
|
504
|
+
end
|
505
|
+
def setColumnFormatOf(column,format)
|
506
|
+
p=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
|
507
|
+
1,format,0,"",0,0)
|
508
|
+
sendMessage WMsg::LVM_SETCOLUMN,column.to_i,p
|
509
|
+
end
|
510
|
+
def getColumnTextOf(column)
|
511
|
+
p=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
|
512
|
+
4,0,0,"\0"*128,128,0)
|
513
|
+
rv=sendMessage WMsg::LVM_GETCOLUMN,column.to_i,p
|
514
|
+
r=@screen.application.unpack(p,WStruct::LVCOLUMN)[3]
|
515
|
+
if rv!=0 then
|
516
|
+
@screen.application.pointer2string(r)
|
517
|
+
else
|
518
|
+
nil
|
519
|
+
end
|
520
|
+
end
|
521
|
+
def getColumnFormatOf(column)
|
522
|
+
p=@screen.application.arg2cstructStr(WStruct::LVCOLUMN,
|
523
|
+
1,0,0,"",0,0)
|
524
|
+
rv=sendMessage WMsg::LVM_GETCOLUMN,column.to_i,p
|
525
|
+
if rv!=0 then
|
526
|
+
@screen.application.unpack(p,WStruct::LVCOLUMN)[1]
|
527
|
+
else
|
528
|
+
nil
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
def insertItem(index,texts,lparam=0,textsize=128)
|
533
|
+
lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
|
534
|
+
0xf,index,0,0,0,texts[0].to_s,textsize,0,lparam)
|
535
|
+
item=sendMessage(WMsg::LVM_INSERTITEM,0,lvitem)
|
536
|
+
|
537
|
+
1.upto(texts.size-1) do |subitem|
|
538
|
+
setItemTextOf(item,subitem,texts[subitem],textsize)
|
539
|
+
end
|
540
|
+
item
|
541
|
+
end
|
542
|
+
|
543
|
+
def addItem(*args)
|
544
|
+
insertItem(30000,*args)
|
545
|
+
end
|
546
|
+
|
547
|
+
def insertMultiItems(index,multitexts,textsize=128)
|
548
|
+
n=multitexts.size
|
549
|
+
0.upto(n-1) do |i|
|
550
|
+
insertItem(index+i,*multitexts[i])
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
554
|
+
def deleteItem(idx)
|
555
|
+
sendMessage WMsg::LVM_DELETEITEM,idx.to_i,0
|
556
|
+
end
|
557
|
+
def clearItems
|
558
|
+
sendMessage WMsg::LVM_DELETEALLITEM,0,0
|
559
|
+
end
|
560
|
+
def countItems
|
561
|
+
sendMessage WMsg::LVM_GETITEMCOUNT,0,0
|
562
|
+
end
|
563
|
+
def hittest(x,y)
|
564
|
+
lvhit=@screen.application.arg2cstructStr(WStruct::LVHITTEST,
|
565
|
+
x.to_i,y.to_i,0,0)
|
566
|
+
sendMessage WMsg::LVM_HITTEST,0,lvhit
|
567
|
+
@screen.application.unpack(lvhit,WStruct::LVHITTEST)[3]
|
568
|
+
end
|
569
|
+
def hittest2(x,y)
|
570
|
+
lvhit=@screen.application.arg2cstructStr(WStruct::LVHITTEST,
|
571
|
+
x.to_i,y.to_i,0,0)
|
572
|
+
sendMessage WMsg::LVM_SUBITEMHITTEST,0,lvhit
|
573
|
+
@screen.application.unpack(lvhit,WStruct::LVHITTEST)
|
574
|
+
end
|
575
|
+
|
576
|
+
def getNextItem(start,flag)
|
577
|
+
r=sendMessage WMsg::LVM_GETNEXTITEM,start,MAKELPARAM(flag,0)
|
578
|
+
case(r)
|
579
|
+
when -1
|
580
|
+
0
|
581
|
+
when 0
|
582
|
+
nil
|
583
|
+
else
|
584
|
+
r
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
def focusedItem
|
589
|
+
getNextItem(0,1)
|
590
|
+
end
|
591
|
+
|
592
|
+
def setImagelist(imagelist,itype=0)
|
593
|
+
raise "not Imagelist" unless imagelist.is_a?(SWin::Imagelist)
|
594
|
+
self.properties["imagelist"]=imagelist
|
595
|
+
sendMessage WMsg::LVM_SETIMAGELIST,itype,imagelist.himagelist
|
596
|
+
end
|
597
|
+
|
598
|
+
def setItemIconOf(idx,imageid)
|
599
|
+
lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
|
600
|
+
2,idx,0,0,0xffff,"",0,imageid.to_i,0) # 2=LVIF_IMAGE
|
601
|
+
sendMessage WMsg::LVM_SETITEM,idx.to_i,lvitem
|
602
|
+
end
|
603
|
+
def getItemIconOf(idx)
|
604
|
+
lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
|
605
|
+
0x2,idx,0,0,0,"",0,0,0)
|
606
|
+
sendMessage( WMsg::LVM_GETITEM,0,lvitem )
|
607
|
+
@screen.application.unpack(lvitem,WStruct::LVITEM)[7]
|
608
|
+
end
|
609
|
+
|
610
|
+
def setItemStateOf(idx,state)
|
611
|
+
lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
|
612
|
+
0,0,0,state,0xffff,"",0,0,0)
|
613
|
+
sendMessage WMsg::LVM_SETITEMSTATE,idx.to_i,lvitem
|
614
|
+
end
|
615
|
+
def getItemStateOf(idx)
|
616
|
+
sendMessage WMsg::LVM_GETITEMSTATE,idx.to_i,0xffff
|
617
|
+
end
|
618
|
+
def selectItem(idx,flag)
|
619
|
+
if flag then
|
620
|
+
s = getItemStateOf(idx) | WConst::LVIS_SELECTED
|
621
|
+
else
|
622
|
+
s = getItemStateOf(idx) & (~ WConst::LVIS_SELECTED)
|
623
|
+
end
|
624
|
+
setItemStateOf(idx,s)
|
625
|
+
end
|
626
|
+
|
627
|
+
def setItemTextOf(idx,subitem,text,textsize=text.size)
|
628
|
+
lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
|
629
|
+
0,0,subitem,0,0,text.to_s,textsize,0,0)
|
630
|
+
sendMessage WMsg::LVM_SETITEMTEXT,idx.to_i,lvitem
|
631
|
+
end
|
632
|
+
def getItemTextOf(idx,subitem=0,textsize=128)
|
633
|
+
app=@screen.application
|
634
|
+
lvitem=app.arg2cstructStr(WStruct::LVITEM,
|
635
|
+
0,0,subitem,0,0,"\0"*textsize,textsize,0,0)
|
636
|
+
sendMessage( WMsg::LVM_GETITEMTEXT,idx,lvitem )
|
637
|
+
app.pointer2string(app.unpack(lvitem,WStruct::LVITEM)[5])
|
638
|
+
end
|
639
|
+
|
640
|
+
def setItemLParamOf(idx,lparam)
|
641
|
+
lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
|
642
|
+
0x4,idx,0,0,0,"",0,0,lparam.to_i)
|
643
|
+
sendMessage WMsg::LVM_SETITEM,0,lvitem
|
644
|
+
end
|
645
|
+
def getItemLParamOf(idx)
|
646
|
+
lvitem=@screen.application.arg2cstructStr(WStruct::LVITEM,
|
647
|
+
0x4,idx,0,0,0,"",0,0,0)
|
648
|
+
sendMessage( WMsg::LVM_GETITEM,0,lvitem )
|
649
|
+
@screen.application.unpack(lvitem,WStruct::LVITEM)[8]
|
650
|
+
end
|
651
|
+
|
652
|
+
def selected?(idx) (getItemStateOf(idx)&1)>0 end
|
653
|
+
def focused?(idx) (getItemStateOf(idx)&2)>0 end
|
654
|
+
|
655
|
+
def eachSelectedItems
|
656
|
+
n=countItems
|
657
|
+
0.upto(n-1) do |i|
|
658
|
+
if (getItemStateOf(i)&WConst::LVIS_SELECTED)>0 then
|
659
|
+
yield i
|
660
|
+
end
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
def countSelectedItems()
|
665
|
+
sendMessage WMsg::LVM_GETSELECTED,0,0
|
666
|
+
end
|
667
|
+
|
668
|
+
def getItemRect(item,code=0)
|
669
|
+
prc = [code,0,0,0].pack("iiii")
|
670
|
+
sendMessage WMsg::LVM_GETITEMRECT,item,prc
|
671
|
+
prc.unpack("iiii")
|
672
|
+
end
|
673
|
+
|
674
|
+
def ensureVisible(i,partial=true)
|
675
|
+
flag = if partial then 1 else 0 end
|
676
|
+
sendMessage WMsg::LVM_ENSUREVISIBLE,i.to_i,flag
|
677
|
+
end
|
678
|
+
|
679
|
+
end
|
680
|
+
|
681
|
+
|
682
|
+
#Treeview
|
683
|
+
module WMsg
|
684
|
+
TVM_INSERTITEM = 0x1100 #INSERTITEMA
|
685
|
+
TVM_DELETEITEM = 0x1100+1
|
686
|
+
TVM_GETCOUNT = 0x1100+5
|
687
|
+
TVM_SETIMAGELIST = 0x1100+9
|
688
|
+
TVM_GETNEXTITEM = 0x1100+10
|
689
|
+
TVM_SELECTITEM = 0x1100+11
|
690
|
+
TVM_GETINDENT = 0x1100+6
|
691
|
+
TVM_SETINDENT = 0x1100+7
|
692
|
+
TVM_GETITEM = 0x1100+12 #GETITEMA
|
693
|
+
TVM_SETITEM = 0x1100+13 #SETITEMA
|
694
|
+
TVM_HITTEST = 0x1100+17
|
695
|
+
TVM_SORTCHILDREN = 0x1100+19
|
696
|
+
|
697
|
+
TVN_START = 0xffffffff-399
|
698
|
+
TVN_SELCHANGED = TVN_START-2 #SELCHANGEDA
|
699
|
+
TVN_ITEMEXPANDED = TVN_START-6 #ITEMEXPANDEDA
|
700
|
+
TVN_BEGINDRAG = TVN_START-7 #BEGINDRAGA
|
701
|
+
TVN_BEGINRDRAG = TVN_START-8 #BEGINRDRAGA
|
702
|
+
TVN_DELETEITEM = TVN_START-9 #DELETEITEMA
|
703
|
+
TVN_KEYDOWN = TVN_START-12
|
704
|
+
end
|
705
|
+
module WStyle
|
706
|
+
TVS_DEFAULT = 0xf
|
707
|
+
end
|
708
|
+
|
709
|
+
module WConst
|
710
|
+
TVI_ROOT = 0xffff0000
|
711
|
+
TVI_FIRST = 0xffff0001
|
712
|
+
TVI_LAST = 0xffff0002
|
713
|
+
TVI_SORT = 0xffff0003
|
714
|
+
|
715
|
+
TVGN_ROOT = 0x0000
|
716
|
+
TVGN_NEXT = 0x0001
|
717
|
+
TVGN_PARENT = 0x0003
|
718
|
+
TVGN_CHILD = 0x0004
|
719
|
+
TVGN_CARET = 0x0009
|
720
|
+
end
|
721
|
+
module WStruct
|
722
|
+
TVITEM="UUUUPIIIIL"
|
723
|
+
TREEINSERTITEM="UU"+TVITEM
|
724
|
+
TVHITTEST = LVHITTEST
|
725
|
+
NM_TREEVIEW= NMHDR+"U"+TVITEM+TVITEM+"LL" #UINT action,TV_ITEM old, new,POINT
|
726
|
+
end
|
727
|
+
|
728
|
+
|
729
|
+
class VRTreeview < VRNotifyControl
|
730
|
+
=begin
|
731
|
+
== VRTreeview
|
732
|
+
Treeview.
|
733
|
+
|
734
|
+
=== Methods
|
735
|
+
((|hitem|)) is an Integer value identifying treeview item.
|
736
|
+
|
737
|
+
--- insertItem(hparent,hafter,text,lparam=0,textsize=text.size)
|
738
|
+
Inserts a new item below ((|hparent|)) and after ((|hafter|)), the text is
|
739
|
+
((|text|)) and lparam=((|lparam|)).
|
740
|
+
--- insertMultiItems(hparent,hafter,items)
|
741
|
+
Inserts new items below ((|hparent|)) and after ((|hafter|)).
|
742
|
+
((|items|)) is a structured array of item array.
|
743
|
+
[text,lparam, child item array as optional].
|
744
|
+
--- addItem(hparent,text,lparam=0,textsize=text.size)
|
745
|
+
Adds a new item below ((|hparent|)) at the last.
|
746
|
+
--- addMultiItems(hparent,items)
|
747
|
+
Same as insertMultiItems( ((|hparent|)),last,((|items|)) )
|
748
|
+
--- deleteItem(hitem)
|
749
|
+
Deletes the item.
|
750
|
+
--- clearItems
|
751
|
+
Deletes all items.
|
752
|
+
--- countItems
|
753
|
+
Counts items.
|
754
|
+
--- selectItem(hitem)
|
755
|
+
Selects the item.
|
756
|
+
--- indent
|
757
|
+
Returns the indent width.
|
758
|
+
--- indent=
|
759
|
+
Sets the indent width.
|
760
|
+
--- hittest(x,y)
|
761
|
+
Inspect the item index which is at the co-ordinate(((|x|)),((|y|)))
|
762
|
+
--- hittest2(x,y)
|
763
|
+
Returns the item information which is at the co-ordinate(((|x|)),((|y|))).
|
764
|
+
The information is the array [x,y,part,index,subitem]
|
765
|
+
--- getNextItem(hitem,code)
|
766
|
+
Searches for an item described by ((|start|)) and ((|code|)).
|
767
|
+
((|code|)) is the series of TVGN_???? in commctrl.h
|
768
|
+
--- topItem
|
769
|
+
The top item in the listview. (not the visible top item)
|
770
|
+
--- root
|
771
|
+
The virtual root item which is not visible and touched.
|
772
|
+
--- last
|
773
|
+
The last item in the listview (not the visible last item)
|
774
|
+
--- selectedItem()
|
775
|
+
Returns the selected item. aliased as selected
|
776
|
+
--- getParentOf(hitem)
|
777
|
+
Returns the parent item of ((|hitem|)).
|
778
|
+
--- getChildOf(hitem)
|
779
|
+
Returns the first child item of ((|hitem|)).
|
780
|
+
--- getNextSiblingOf(hitem)
|
781
|
+
Returns the next sibling item of ((|hitem|)).
|
782
|
+
--- setImagelist(imagelist)
|
783
|
+
Set ((|imagelist|)) for displaying icons of items. ((|imagelist|)) must be
|
784
|
+
a kind of SWin::Imagelist.
|
785
|
+
--- setItemIconOf(hitem,img,simg)
|
786
|
+
Sets image ids of the item. ((|img|)) for normal state image and ((|simg|))
|
787
|
+
for selected state image. Both of them are Integers of id in ImageList and
|
788
|
+
((|img|)) and ((|simg|)) can be ignored by setting nil instead of integer.
|
789
|
+
The imagelist is set by ((<setImagelist>)) method.
|
790
|
+
--- getItemIconOf(hitem)
|
791
|
+
Returns images id of the item.
|
792
|
+
--- setItemLParamOf(hitem,lparam)
|
793
|
+
Sets lparam of the item.
|
794
|
+
--- getItemLParamOf(hitem)
|
795
|
+
Returns lparam of the item.
|
796
|
+
--- setItemTextOf(hitem,text)
|
797
|
+
Sets text of the item.
|
798
|
+
--- getItemTextOf(hitem,textsize=128)
|
799
|
+
Returns text of the item.
|
800
|
+
--- setItemStateOf(hitem,state)
|
801
|
+
Sets state of the item.
|
802
|
+
* 1 : focused
|
803
|
+
* 2 : selected
|
804
|
+
* 4 : cut
|
805
|
+
* 8 : drophilited
|
806
|
+
*16 : bold
|
807
|
+
*32 : expanded
|
808
|
+
--- getItemStateOf(hitem)
|
809
|
+
Returns state of the item.
|
810
|
+
|
811
|
+
=== Event handlers
|
812
|
+
--- ????_selchanged(hitem,lparam)
|
813
|
+
fired when selected item is changed to ((|hitem|))
|
814
|
+
whose lparam is ((|lparam|)).
|
815
|
+
--- ????_itemexpanded(hitem,state,lparam)
|
816
|
+
fired when the ((|hitem|)) item is expanded or closed.
|
817
|
+
--- ????_deleteitem(hitem,lparam)
|
818
|
+
fired when the item is deleted.
|
819
|
+
--- ????_begindrag(hitem,state,lparam)
|
820
|
+
--- ????_beginrdrag(hitem,state,lparam)
|
821
|
+
=end
|
822
|
+
|
823
|
+
private
|
824
|
+
def nilnull(r) if r==0 then nil else r end end
|
825
|
+
|
826
|
+
public
|
827
|
+
WINCLASSINFO = ["SysTreeView32",WStyle::TVS_DEFAULT,0x200]
|
828
|
+
|
829
|
+
def treeviewinit
|
830
|
+
# "F FFFFFFFFFF FTFFFFFFFT FF"
|
831
|
+
addNotifyHandler(WMsg::TVN_SELCHANGED,"selchanged",
|
832
|
+
MSGTYPE::ARGSTRUCT,WStruct::NM_TREEVIEW)
|
833
|
+
addFilterArg WMsg::TVN_SELCHANGED,"FFFFFFFFFFFFTFFFFFFFTFF" #hitem,lparam
|
834
|
+
addNotifyHandler(WMsg::TVN_ITEMEXPANDED,"itemexpanded",
|
835
|
+
MSGTYPE::ARGSTRUCT,WStruct::NM_TREEVIEW)
|
836
|
+
addFilterArg WMsg::TVN_ITEMEXPANDED,"FFFFFFFFFFFFTTFFFFFFTFF" #hitem,state,lparam
|
837
|
+
addNotifyHandler(WMsg::TVN_DELETEITEM,"deleteitem",
|
838
|
+
MSGTYPE::ARGSTRUCT,WStruct::NM_TREEVIEW)
|
839
|
+
addFilterArg WMsg::TVN_DELETEITEM,"FFTFFFFFFFTFFFFFFFFFFFF" #hitem,lparam
|
840
|
+
addNotifyHandler(WMsg::TVN_BEGINDRAG,"begindrag",
|
841
|
+
MSGTYPE::ARGSTRUCT,WStruct::NM_TREEVIEW)
|
842
|
+
addFilterArg WMsg::TVN_BEGINDRAG,"FFFFFFFFFFFFTTFFFFFFTFF" #hitem,state,lparam
|
843
|
+
addNotifyHandler(WMsg::TVN_BEGINRDRAG,"beginrdrag",
|
844
|
+
MSGTYPE::ARGSTRUCT,WStruct::NM_TREEVIEW)
|
845
|
+
addFilterArg WMsg::TVN_BEGINRDRAG,"FFFFFFFFFFFFTTFFFFFFTFF" #hitem,state,lparam
|
846
|
+
end
|
847
|
+
|
848
|
+
def vrinit
|
849
|
+
super
|
850
|
+
treeviewinit
|
851
|
+
end
|
852
|
+
|
853
|
+
def insertItem(hparent,hafter,text,lparam=0,textsize=text.size)
|
854
|
+
ti=@screen.application.arg2cstructStr(WStruct::TREEINSERTITEM,hparent,hafter,
|
855
|
+
0x0f,0,0,0,text.to_s,textsize,0,0,0,lparam)
|
856
|
+
sendMessage WMsg::TVM_INSERTITEM,0,ti
|
857
|
+
end
|
858
|
+
|
859
|
+
def addItem(hparent,*args)
|
860
|
+
insertItem(hparent, WConst::TVI_LAST,*args)
|
861
|
+
end
|
862
|
+
|
863
|
+
def insertMultiItems(hparent,hafter,multitext)
|
864
|
+
ha = if hafter then hafter else WConst::TVI_LAST end
|
865
|
+
|
866
|
+
multitext.each do |item|
|
867
|
+
if item.is_a?(Array)
|
868
|
+
item[1] = 0 unless item[1]
|
869
|
+
h=insertItem(hparent,ha,item[0],item[1])
|
870
|
+
if item.size>2 and item[2].is_a?(Array) then
|
871
|
+
insertMultiItems(h,WConst::TVI_LAST,item[2])
|
872
|
+
end
|
873
|
+
ha=h
|
874
|
+
else
|
875
|
+
raise ArgumentError,"Arg2 illegal"
|
876
|
+
end
|
877
|
+
end
|
878
|
+
end
|
879
|
+
def addMultiItems(hparent,*args)
|
880
|
+
insertMultiItems(hparent, WConst::TVI_LAST,*args)
|
881
|
+
end
|
882
|
+
|
883
|
+
def deleteItem(htreei)
|
884
|
+
sendMessage WMsg::TVM_DELETEITEM,0,htreei
|
885
|
+
end
|
886
|
+
def clearItems
|
887
|
+
deleteItem(WConst::TVGN_ROOT)
|
888
|
+
end
|
889
|
+
def countItems
|
890
|
+
sendMessage WMsg::TVM_GETCOUNT,0,0
|
891
|
+
end
|
892
|
+
def selectItem(hitem)
|
893
|
+
sendMessage WMsg::TVM_SELECTITEM,9,hitem
|
894
|
+
end
|
895
|
+
|
896
|
+
def indent
|
897
|
+
sendMessage WMsg::TVM::TVM_GETINDENT,0,0
|
898
|
+
end
|
899
|
+
def indent=(idt)
|
900
|
+
sendMessage WMsg::TVM::TVM_SETINDENT,idt.to_i,0
|
901
|
+
end
|
902
|
+
|
903
|
+
def hittest(x,y)
|
904
|
+
tvhit=@screen.application.arg2cstructStr(WStruct::TVHITTEST,
|
905
|
+
x.to_i,y.to_i,0,0)
|
906
|
+
sendMessage WMsg::TVM_HITTEST,0,tvhit
|
907
|
+
@screen.application.unpack(tvhit,WStruct::TVHITTEST)[3]
|
908
|
+
end
|
909
|
+
def hittest2(x,y)
|
910
|
+
tvhit=@screen.application.arg2cstructStr(WStruct::TVHITTEST,
|
911
|
+
x.to_i,y.to_i,0,0)
|
912
|
+
sendMessage WMsg::TVM_HITTEST,0,tvhit
|
913
|
+
@screen.application.unpack(tvhit,WStruct::TVHITTEST)
|
914
|
+
end
|
915
|
+
|
916
|
+
def getNextItem(hitem,code)
|
917
|
+
sendMessage WMsg::TVM_GETNEXTITEM,code,hitem
|
918
|
+
end
|
919
|
+
def topItem() getNextItem(0,WConst::TVGN_ROOT) end
|
920
|
+
def root() WConst::TVI_ROOT end
|
921
|
+
def last() WCONST::TVI_LAST end
|
922
|
+
|
923
|
+
def selectedItem() nilnull(getNextItem(0,WConst::TVGN_CARET)) end
|
924
|
+
alias selected :selectedItem
|
925
|
+
def getParentOf(hitem) nilnull(getNextItem(hitem,WConst::TVGN_PARENT))end
|
926
|
+
def getChildOf(hitem) nilnull(getNextItem(hitem,WConst::TVGN_CHILD)) end
|
927
|
+
def getNextSiblingOf(hitem) nilnull(getNextItem(hitem,WConst::TVGN_NEXT)) end
|
928
|
+
|
929
|
+
def setImagelist(imagelist,itype=0)
|
930
|
+
raise "not Imagelist" unless imagelist.is_a?(SWin::Imagelist)
|
931
|
+
self.properties["imagelist"]=imagelist
|
932
|
+
sendMessage WMsg::TVM_SETIMAGELIST,itype,imagelist.himagelist
|
933
|
+
end
|
934
|
+
|
935
|
+
def setItemIconOf(hitem,img,simg=nil)
|
936
|
+
# TVIF_IMAGE=2, TVIF_SELECTEDIMAGE=0x20
|
937
|
+
mask=0; image=0; simage=0
|
938
|
+
if img then mask |= 2; image = img end
|
939
|
+
if simg then mask |= 0x20; simage = simg end
|
940
|
+
|
941
|
+
tvitem=@screen.application.arg2cstructStr(WStruct::TVITEM,
|
942
|
+
mask,hitem.to_i,0,0,"",0,image,simage,0,0)
|
943
|
+
sendMessage WMsg::TVM_SETITEM,0,tvitem
|
944
|
+
end
|
945
|
+
def getItemIconOf(hitem)
|
946
|
+
tvitem=@screen.application.arg2cstructStr(WStruct::TVITEM,
|
947
|
+
0x22,hitem.to_i,0,0,"",0,0,0,0,0)
|
948
|
+
sendMessage WMsg::TVM_GETITEM,0,tvitem
|
949
|
+
@screen.application.unpack(tvitem,WStruct::TVITEM)[6..7]
|
950
|
+
end
|
951
|
+
|
952
|
+
def setItemLParamOf(hitem,lparam)
|
953
|
+
tvitem=@screen.application.arg2cstructStr(WStruct::TVITEM,
|
954
|
+
4,hitem.to_i,0,0,"",0,0,0,0,lparam.to_i) # 4=TVIF_PARAM
|
955
|
+
sendMessage WMsg::TVM_SETITEM,0,tvitem
|
956
|
+
end
|
957
|
+
def getItemLParamOf(hitem)
|
958
|
+
tvitem=@screen.application.arg2cstructStr(WStruct::TVITEM,
|
959
|
+
4,hitem.to_i,0,0,"",0,0,0,0,0) # 4=TVIF_PARAM
|
960
|
+
sendMessage WMsg::TVM_GETITEM,0,tvitem
|
961
|
+
@screen.application.unpack(tvitem,WStruct::TVITEM)[9]
|
962
|
+
end
|
963
|
+
def setItemTextOf(hitem,text)
|
964
|
+
tvitem=@screen.application.arg2cstructStr(WStruct::TVITEM,
|
965
|
+
1,hitem.to_i,0,0,text.to_s,text.size,0,0,0,0) # 1=TVIF_TEXT
|
966
|
+
sendMessage WMsg::TVM_SETITEM,0,tvitem
|
967
|
+
end
|
968
|
+
def getItemTextOf(hitem,textsize=128)
|
969
|
+
app=@screen.application
|
970
|
+
tvitem=app.arg2cstructStr(WStruct::TVITEM,
|
971
|
+
1,hitem.to_i,0,0,"\0"*textsize,textsize,0,0,0,0) # 1=TVIF_TEXT
|
972
|
+
sendMessage WMsg::TVM_GETITEM,0,tvitem
|
973
|
+
app.pointer2string(app.unpack(tvitem,WStruct::TVITEM)[4])
|
974
|
+
end
|
975
|
+
def setItemStateOf(hitem,state)
|
976
|
+
tvitem=@screen.application.arg2cstructStr(WStruct::TVITEM,
|
977
|
+
8,hitem.to_i,state.to_i,0x00ff,"",0,0,0,0,0) # 8=TVIF_STATE
|
978
|
+
sendMessage WMsg::TVM_SETITEM,0,tvitem
|
979
|
+
end
|
980
|
+
def getItemStateOf(hitem)
|
981
|
+
tvitem=@screen.application.arg2cstructStr(WStruct::TVITEM,
|
982
|
+
8,hitem.to_i,0,0x00ff,"",0,0,0,0,0) # 8=TVIF_STATE
|
983
|
+
sendMessage WMsg::TVM_GETITEM,0,tvitem
|
984
|
+
@screen.application.unpack(tvitem,WStruct::TVITEM)[2]
|
985
|
+
end
|
986
|
+
end
|
987
|
+
|
988
|
+
# Progressbar
|
989
|
+
module WMsg
|
990
|
+
PBM_SETRANGE = WM_USER+1
|
991
|
+
PBM_SETPOS = WM_USER+2
|
992
|
+
PBM_DELTAPOS = WM_USER+3
|
993
|
+
PBM_SETSTEP = WM_USER+4
|
994
|
+
PBM_STEPIT = WM_USER+5
|
995
|
+
end
|
996
|
+
module WStyle
|
997
|
+
PBS_SMOOTH = 1 # ?
|
998
|
+
end
|
999
|
+
|
1000
|
+
class VRProgressbar < VRNotifyControl
|
1001
|
+
=begin
|
1002
|
+
== VRProgressbar
|
1003
|
+
Progressbar.
|
1004
|
+
=== Methods
|
1005
|
+
--- setRange(minr,maxr)
|
1006
|
+
Sets the range from ((|minr|)) to ((|maxr|)).
|
1007
|
+
--- position
|
1008
|
+
Returns the current position.
|
1009
|
+
--- position=(pos)
|
1010
|
+
Sets the current position.
|
1011
|
+
--- stepwidth=(st)
|
1012
|
+
Sets the step width for ((<step>)).
|
1013
|
+
--- step
|
1014
|
+
Steps one step in position.
|
1015
|
+
--- advance(n=1)
|
1016
|
+
Steps multi steps in position.
|
1017
|
+
=end
|
1018
|
+
|
1019
|
+
WINCLASSINFO = ["msctls_progress32",0]
|
1020
|
+
|
1021
|
+
attr :stepwidth # oops!
|
1022
|
+
attr :minrange # oops!
|
1023
|
+
attr :maxrange # ooooo.....
|
1024
|
+
|
1025
|
+
def progressbarinit
|
1026
|
+
@stepwidth=10
|
1027
|
+
@minrange=0
|
1028
|
+
@maxrange=100
|
1029
|
+
end
|
1030
|
+
def vrinit
|
1031
|
+
super
|
1032
|
+
progressbarinit
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
def setRange(minr,maxr)
|
1036
|
+
@minrange=minr
|
1037
|
+
@maxrange=maxr
|
1038
|
+
sendMessage WMsg::PBM_SETRANGE,0,MAKELPARAM(minr,maxr)
|
1039
|
+
end
|
1040
|
+
def position=(pos)
|
1041
|
+
sendMessage WMsg::PBM_SETPOS,pos.to_i,0
|
1042
|
+
end
|
1043
|
+
def position
|
1044
|
+
raise StandardError,"not implemented"
|
1045
|
+
end
|
1046
|
+
def advance(n=1)
|
1047
|
+
sendMessage WMsg::PBM_DELTAPOS,n.to_i,0
|
1048
|
+
end
|
1049
|
+
def stepwidth=(st)
|
1050
|
+
@stepwidth=st
|
1051
|
+
sendMessage WMsg::PBM_SETSTEP,st.to_i,0
|
1052
|
+
end
|
1053
|
+
def step
|
1054
|
+
sendMessage WMsg::PBM_STEPIT,0,0
|
1055
|
+
end
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
|
1059
|
+
# Trackbar
|
1060
|
+
module WMsg
|
1061
|
+
TBM_GETPOS = WM_USER + 0
|
1062
|
+
TBM_SETPOS = WM_USER + 1
|
1063
|
+
TBM_GETRANGEMIN = WM_USER + 2
|
1064
|
+
TBM_GETRANGEMAX = WM_USER + 8
|
1065
|
+
TBM_SETRANGEMIN = WM_USER + 7
|
1066
|
+
TBM_SETRANGEMAX = WM_USER + 8
|
1067
|
+
TBM_SETSEL = WM_USER + 10
|
1068
|
+
TBM_SETSELSTART = WM_USER + 11
|
1069
|
+
TBM_SETSELEND = WM_USER + 12
|
1070
|
+
TBM_GETSELSTART = WM_USER + 17
|
1071
|
+
TBM_GETSELEND = WM_USER + 18
|
1072
|
+
TBM_CLEARSEL = WM_USER + 19
|
1073
|
+
TBM_SETPAGESIZE = WM_USER + 21
|
1074
|
+
TBM_GETPAGESIZE = WM_USER + 22
|
1075
|
+
TBM_SETLINESIZE = WM_USER + 23
|
1076
|
+
TBM_GETLINESIZE = WM_USER + 24
|
1077
|
+
end
|
1078
|
+
module WStyle
|
1079
|
+
TBS_AUTOTICS = 0x001
|
1080
|
+
TBS_VERT = 0x002
|
1081
|
+
TBS_HORZ = 0x000
|
1082
|
+
TBS_LEFT = 0x004
|
1083
|
+
TBS_BOTH = 0x008
|
1084
|
+
TBS_ENABLESEL= 0x020 #ENABELSELRANGE
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
class VRTrackbar < VRNotifyControl
|
1088
|
+
=begin
|
1089
|
+
== VRTrackbar
|
1090
|
+
Trackbar.
|
1091
|
+
=== Methods
|
1092
|
+
--- position
|
1093
|
+
Returns the position.
|
1094
|
+
--- position=(pos)
|
1095
|
+
Sets the position.
|
1096
|
+
--- linesize
|
1097
|
+
Returns the number of positions moved on by arrow keys.
|
1098
|
+
--- linesize=(s)
|
1099
|
+
Sets the number of positions mvoed on by arrow keys.
|
1100
|
+
--- pagesize
|
1101
|
+
Returns the number of positions moved on by [page up]/[pagedown] keys.
|
1102
|
+
--- pagesize=(p)
|
1103
|
+
Sets the number of positions moved on by [page up]/[pagedown] keys.
|
1104
|
+
--- rangeMin
|
1105
|
+
Returns minimum value of the trackbar.
|
1106
|
+
--- rangeMin=(m)
|
1107
|
+
Sets minimum value of the trackbar.
|
1108
|
+
--- rangeMax
|
1109
|
+
Returns maximum value of the trackbar.
|
1110
|
+
--- rangeMax=(m)
|
1111
|
+
Sets maximum value of the trackbar.
|
1112
|
+
--- selStart
|
1113
|
+
Returns the selection start of the trackbar.
|
1114
|
+
--- selStart=(m)
|
1115
|
+
Sets the selection start of the trackbar.
|
1116
|
+
--- selEnd
|
1117
|
+
Returns the selection end of the trackbar.
|
1118
|
+
--- selEnd=(m)
|
1119
|
+
Sets the selection end of the trackbar.
|
1120
|
+
--- clearSel
|
1121
|
+
Clears the selection.
|
1122
|
+
=end
|
1123
|
+
|
1124
|
+
WINCLASSINFO = ["msctls_trackbar32",0]
|
1125
|
+
|
1126
|
+
def vrinit
|
1127
|
+
super
|
1128
|
+
end
|
1129
|
+
|
1130
|
+
def position
|
1131
|
+
sendMessage WMsg::TBM_GETPOS,0,0
|
1132
|
+
end
|
1133
|
+
def position=(pos)
|
1134
|
+
sendMessage WMsg::TBM_SETPOS,1,pos.to_i
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
def linesize
|
1138
|
+
sendMessage WMsg::TBM_GETLINESIZE,0,0
|
1139
|
+
end
|
1140
|
+
def linesize=(s)
|
1141
|
+
sendMessage WMsg::TBM_SETLINESIZE,0,s.to_i
|
1142
|
+
end
|
1143
|
+
def pagesize
|
1144
|
+
sendMessage WMsg::TBM_GETPAGESIZE,0,0
|
1145
|
+
end
|
1146
|
+
def pagesize=(s)
|
1147
|
+
sendMessage WMsg::TBM_SETPAGESIZE,0,s.to_i
|
1148
|
+
end
|
1149
|
+
|
1150
|
+
def rangeMin
|
1151
|
+
sendMessage WMsg::TBM_GETRANGEMIN,0,0
|
1152
|
+
end
|
1153
|
+
def rangeMin=(m)
|
1154
|
+
sendMessage WMsg::TBM_SETRANGEMIN,1,m.to_i
|
1155
|
+
end
|
1156
|
+
def rangeMax
|
1157
|
+
sendMessage WMsg::TBM_GETRANGEMAX,0,0
|
1158
|
+
end
|
1159
|
+
def rangeMax=(m)
|
1160
|
+
sendMessage WMsg::TBM_SETRANGEMAX,1,m.to_i
|
1161
|
+
end
|
1162
|
+
def selStart
|
1163
|
+
sendMessage WMsg::TBM_GETSELSTART,0,0
|
1164
|
+
end
|
1165
|
+
def selStart=(m)
|
1166
|
+
sendMessage WMsg::TBM_SETSELSTART,1,m.to_i
|
1167
|
+
end
|
1168
|
+
def selEnd
|
1169
|
+
sendMessage WMsg::TBM_GETSELEND,0,0
|
1170
|
+
end
|
1171
|
+
def clearSel
|
1172
|
+
sendMessage WMsg::TBM_CLEARSEL,1,0
|
1173
|
+
end
|
1174
|
+
end
|
1175
|
+
|
1176
|
+
# updown control
|
1177
|
+
module WMsg
|
1178
|
+
UDM_SETRANGE = WM_USER+101
|
1179
|
+
UDM_GETRANGE = WM_USER+102
|
1180
|
+
UDM_SETPOS = WM_USER+103
|
1181
|
+
UDM_GETPOS = WM_USER+104
|
1182
|
+
UDM_SETBUDDY = WM_USER+105
|
1183
|
+
UDM_GETBUDDY = WM_USER+106
|
1184
|
+
UDM_SETACCEL = WM_USER+107
|
1185
|
+
UDM_GETACCEL = WM_USER+108
|
1186
|
+
UDM_SETBASE = WM_USER+109
|
1187
|
+
UDM_GETBASE = WM_USER+110
|
1188
|
+
|
1189
|
+
UDN_DELTAPOS = 0x100000000-722
|
1190
|
+
end
|
1191
|
+
module WStyle
|
1192
|
+
UDS_ALIGNRIGHT = 0x04
|
1193
|
+
UDS_ALIGNLEFT = 0x08
|
1194
|
+
UDS_HORZ = 0x40
|
1195
|
+
|
1196
|
+
# Thanks to Katonbo-san
|
1197
|
+
UDS_SETBUDDYINT = 0x0002
|
1198
|
+
UDS_AUTOBUDDY = 0x0010
|
1199
|
+
UDS_ARROWKEYS = 0x0020
|
1200
|
+
UDS_NOTHOUSANDS = 0x0080
|
1201
|
+
|
1202
|
+
UDS_INTBUDDYRIGHT = UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ALIGNRIGHT
|
1203
|
+
end
|
1204
|
+
|
1205
|
+
module WStruct
|
1206
|
+
NM_UPDOWN = NMHDR+"UU"
|
1207
|
+
end
|
1208
|
+
class VRUpdown < VRNotifyControl
|
1209
|
+
=begin
|
1210
|
+
== VRUpdown
|
1211
|
+
Updown control.
|
1212
|
+
===Methods
|
1213
|
+
--- setRange(minr,maxr)
|
1214
|
+
Sets the range from ((|minr|)) to ((|maxr|)).
|
1215
|
+
--- getRange
|
1216
|
+
Returns the range as an array [minr,maxr]
|
1217
|
+
--- position
|
1218
|
+
Returns current position.
|
1219
|
+
--- position=
|
1220
|
+
Sets current position.
|
1221
|
+
--- base
|
1222
|
+
Radix.
|
1223
|
+
--- base=(b)
|
1224
|
+
Sets the radix that is 10 or 16.
|
1225
|
+
=== Event handlers
|
1226
|
+
--- ????_changed(pos)
|
1227
|
+
Fired when the position is changing from ((|pos|)).
|
1228
|
+
Note that ((|pos|)) is a previous value. To obtain the current value,
|
1229
|
+
use buddy control which is a (edit) control made directry before
|
1230
|
+
the updown control(using VREdit#changed or its parent handler).
|
1231
|
+
=end
|
1232
|
+
WINCLASSINFO = ["msctls_updown32",0]
|
1233
|
+
|
1234
|
+
def updowninit
|
1235
|
+
addNotifyHandler(WMsg::UDN_DELTAPOS,"deltapos",
|
1236
|
+
MSGTYPE::ARGSTRUCT,WStruct::NM_UPDOWN)
|
1237
|
+
addFilterArg WMsg::UDN_DELTAPOS,"TF"
|
1238
|
+
end
|
1239
|
+
def vrinit
|
1240
|
+
super
|
1241
|
+
updowninit
|
1242
|
+
end
|
1243
|
+
|
1244
|
+
def setRange(minr,maxr)
|
1245
|
+
sendMessage WMsg::UDM_SETRANGE,0,MAKELPARAM(maxr,minr)
|
1246
|
+
end
|
1247
|
+
def getRange
|
1248
|
+
r=sendMessage WMsg::UDM_GETRANGE,0,0
|
1249
|
+
return HIWORD(r),LOWORD(r)
|
1250
|
+
end
|
1251
|
+
|
1252
|
+
def position=(p)
|
1253
|
+
sendMessage WMsg::UDM_SETPOS,0,MAKELPARAM(p.to_i,0)
|
1254
|
+
end
|
1255
|
+
def position
|
1256
|
+
sendMessage WMsg::UDM_GETPOS,0,0
|
1257
|
+
end
|
1258
|
+
|
1259
|
+
def base=(b)
|
1260
|
+
sendMessage WMsg::UDM_SETBASE,b.to_i,0
|
1261
|
+
end
|
1262
|
+
def base
|
1263
|
+
sendMessage WMsg::UDM_GETBASE,0,0
|
1264
|
+
end
|
1265
|
+
end
|
1266
|
+
|
1267
|
+
# Statusbar
|
1268
|
+
|
1269
|
+
module WMsg
|
1270
|
+
SB_SETTEXT = WM_USER+1 #SETTEXT
|
1271
|
+
SB_GETTEXT = WM_USER+2 #GETTEXT
|
1272
|
+
SB_GETTEXTLENGTH = WM_USER+3 #GETTEXTLENGTH
|
1273
|
+
SB_SETPARTS = WM_USER+4
|
1274
|
+
SB_GETPARTS = WM_USER+6
|
1275
|
+
SB_SETMINHEIGHT = WM_USER+8
|
1276
|
+
SB_GETRECT = WM_USER+10
|
1277
|
+
end
|
1278
|
+
module WConst
|
1279
|
+
SBT_OWNERDRAW =0x1000
|
1280
|
+
SBT_NOBORDERS =0x0100
|
1281
|
+
SBT_POPOUT =0x0200
|
1282
|
+
SBT_RTLREADING =0x0400
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
class VRStatusbar < VRNotifyControl
|
1286
|
+
=begin
|
1287
|
+
== VRStatusbar
|
1288
|
+
Statusbar.
|
1289
|
+
=== Methods
|
1290
|
+
--- setparts(p,width=[-1])
|
1291
|
+
Devides the statusbar into ((|p|)) parts with the widths specified by
|
1292
|
+
((|width|)) which is an Integer array. If the width is -1, the right edge
|
1293
|
+
of the part is to be at the right edge of the statusbar.
|
1294
|
+
--- parts
|
1295
|
+
Returns the number of parts.
|
1296
|
+
--- getTextOf(idx)
|
1297
|
+
Returns the text of the parts.
|
1298
|
+
--- setTextOf(idx,text,style=0)
|
1299
|
+
Sets the text of the parts whose index is ((|idx|)) to ((|text|))
|
1300
|
+
--- getRectOf(idx)
|
1301
|
+
Returns the position and size of the parts as an array [x,y,w,h].
|
1302
|
+
--- minheight=(minh)
|
1303
|
+
Sets the minimum height of the statusbar.
|
1304
|
+
=end
|
1305
|
+
|
1306
|
+
WINCLASSINFO = ["msctls_statusbar32",0]
|
1307
|
+
|
1308
|
+
def getTextOf(idx)
|
1309
|
+
len = 1+LOWORD(sendMessage(WMsg::SB_GETTEXTLENGTH,idx,0))
|
1310
|
+
r="\0"*len
|
1311
|
+
sendMessage WMsg::SB_GETTEXT,idx,r
|
1312
|
+
r
|
1313
|
+
end
|
1314
|
+
def setTextOf(idx,text,style=0)
|
1315
|
+
sendMessage WMsg::SB_SETTEXT,(idx|(style&0xff00)),text.to_s
|
1316
|
+
end
|
1317
|
+
def parts
|
1318
|
+
sendMessage WMsg::SB_GETPARTS,0,0
|
1319
|
+
end
|
1320
|
+
def setparts(p,widths=[-1])
|
1321
|
+
if widths then
|
1322
|
+
raise(ArgumentError,"width illegal") unless widths.is_a?(Array)
|
1323
|
+
end
|
1324
|
+
r=@screen.application.arg2cstructStr("I"*p,*widths)
|
1325
|
+
sendMessage WMsg::SB_SETPARTS,p.to_i,r
|
1326
|
+
end
|
1327
|
+
def getRectOf(idx)
|
1328
|
+
r=@screen.application.arg2cstructStr("UUUU",0,0,0,0)
|
1329
|
+
sendMessage WMsg::SB_GETRECT,idx.to_i,r
|
1330
|
+
@screen.application.cstruct2array(r,"UUUU")
|
1331
|
+
end
|
1332
|
+
def minheight=(h)
|
1333
|
+
sendMessage WMsg::SB_SETMINHEIGHT,h.to_i,0
|
1334
|
+
end
|
1335
|
+
end
|
1336
|
+
|
1337
|
+
module VRStatusbarDockable
|
1338
|
+
=begin
|
1339
|
+
== VRStatusbarDockable
|
1340
|
+
This is a module to be added into VRForm for a statusbar that follows form resizing.
|
1341
|
+
|
1342
|
+
=== Method
|
1343
|
+
--- addStatusbar(caption='',height=10,control=VRStatusbar)
|
1344
|
+
Adds a statusbar on a form. If you have another statusbar control, you may
|
1345
|
+
set it for ((|control|)).
|
1346
|
+
=end
|
1347
|
+
|
1348
|
+
def statusbardockableinit
|
1349
|
+
addHandler WMsg::WM_SIZE, "vr_statusbardock", MSGTYPE::ARGLINTINT,nil
|
1350
|
+
acceptEvents [WMsg::WM_SIZE]
|
1351
|
+
end
|
1352
|
+
|
1353
|
+
def vrinit
|
1354
|
+
super
|
1355
|
+
statusbardockableinit
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
def addStatusbar(caption="",height=10,control=VRStatusbar)
|
1359
|
+
@_vr_statusbar=addControl control,"statusbar",caption,10,10,10,height
|
1360
|
+
if self.visible? then
|
1361
|
+
a=self.clientrect
|
1362
|
+
sendMessage WMsg::WM_SIZE,0,MAKELPARAM(a[2]-a[0],a[3]-a[1])
|
1363
|
+
end
|
1364
|
+
@statusbar = @_vr_statusbar
|
1365
|
+
end
|
1366
|
+
|
1367
|
+
def self_vr_statusbardock(w,h)
|
1368
|
+
if defined?(@_vr_statusbar) then
|
1369
|
+
s=@_vr_statusbar
|
1370
|
+
s.move 0, self.h - s.h, self.w, self.h - s.h
|
1371
|
+
end
|
1372
|
+
end
|
1373
|
+
|
1374
|
+
end
|
1375
|
+
|
1376
|
+
|
1377
|
+
#Tabcontrol
|
1378
|
+
|
1379
|
+
module WMsg
|
1380
|
+
TCM_FIRST=0x1300
|
1381
|
+
TCM_GETIMAGELIST = (TCM_FIRST + 2)
|
1382
|
+
TCM_SETIMAGELIST = (TCM_FIRST + 3)
|
1383
|
+
TCM_GETITEMCOUNT = (TCM_FIRST + 4)
|
1384
|
+
TCM_GETITEM = (TCM_FIRST + 5)
|
1385
|
+
TCM_SETITEM = (TCM_FIRST + 6)
|
1386
|
+
TCM_INSERTITEM = (TCM_FIRST + 7)
|
1387
|
+
TCM_DELETEITEM = (TCM_FIRST + 8)
|
1388
|
+
TCM_DELETEALLITEMS = (TCM_FIRST + 9)
|
1389
|
+
TCM_GETITEMRECT = (TCM_FIRST + 10)
|
1390
|
+
TCM_GETCURSEL = (TCM_FIRST + 11)
|
1391
|
+
TCM_SETCURSEL = (TCM_FIRST + 12)
|
1392
|
+
TCM_ADJUSTRECT = (TCM_FIRST + 40)
|
1393
|
+
TCM_SETITEMSIZE = (TCM_FIRST + 41)
|
1394
|
+
TCM_GETCURFOCUS = (TCM_FIRST + 47)
|
1395
|
+
TCM_SETCURFOCUS = (TCM_FIRST + 48)
|
1396
|
+
|
1397
|
+
TCN_FIRST = 0xffffffff-549
|
1398
|
+
TCN_SELCHANGE = (TCN_FIRST - 1)
|
1399
|
+
end
|
1400
|
+
|
1401
|
+
module WStyle
|
1402
|
+
TCS_BOTTOM = 0x0002
|
1403
|
+
TCS_RIGHT = 0x0002
|
1404
|
+
TCS_MULTISELECT = 0x0004
|
1405
|
+
TCS_FLATBUTTONS = 0x0008
|
1406
|
+
|
1407
|
+
TCS_FORCEICONLEFT = 0x0010
|
1408
|
+
TCS_FORCELABELLEFT = 0x0020
|
1409
|
+
TCS_HOTTRACK = 0x0040
|
1410
|
+
TCS_VERTICAL = 0x0080
|
1411
|
+
TCS_TABS = 0x0000
|
1412
|
+
TCS_BUTTONS = 0x0100
|
1413
|
+
TCS_SINGLELINE = 0x0000
|
1414
|
+
TCS_MULTILINE = 0x0200
|
1415
|
+
TCS_RIGHTJUSTIFY = 0x0000
|
1416
|
+
TCS_FIXEDWIDTH = 0x0400
|
1417
|
+
TCS_RAGGEDRIGHT = 0x0800
|
1418
|
+
TCS_FOCUSONBUTTONDOWN= 0x1000
|
1419
|
+
TCS_OWNERDRAWFIXED = 0x2000
|
1420
|
+
TCS_TOOLTIPS = 0x4000
|
1421
|
+
TCS_FOCUSNEVER = 0x8000
|
1422
|
+
end
|
1423
|
+
|
1424
|
+
module WStruct
|
1425
|
+
TC_ITEM = "UUUPUUU" # Mask,rsrv1,rsrv2,Text,TextMax,iImage,lParam
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
class VRTabControl < VRNotifyControl
|
1429
|
+
=begin
|
1430
|
+
== VRTabControl
|
1431
|
+
Tabs.
|
1432
|
+
This class doesn't have a function to show/hide controls according to
|
1433
|
+
the selected tab. For that function ((<VRTabbedPanel>)) class is provided below.
|
1434
|
+
=== Methods
|
1435
|
+
--- insertTab(index,text,textmax=text.size,lparam=0)
|
1436
|
+
Inserts a new tab named ((|text|)) with ((|lparam|)) at ((|index|))-th.
|
1437
|
+
((|index|)) is ordinal number for tabs.
|
1438
|
+
--- clearTabs
|
1439
|
+
Deletes all tabs.
|
1440
|
+
--- deleteTab(idx)
|
1441
|
+
Deletes a tab at ((|index|))
|
1442
|
+
--- countTabs
|
1443
|
+
Counts tabs in the control.
|
1444
|
+
--- selectedTab
|
1445
|
+
Returns the selected tab's index.
|
1446
|
+
--- selectTab(idx)
|
1447
|
+
Selects the tab at ((|idx|))
|
1448
|
+
--- setImagelist(imagelist)
|
1449
|
+
Sets an imagelist for the tabs.
|
1450
|
+
--- setTabSize(width,height)
|
1451
|
+
Sets each tab size.
|
1452
|
+
--- getTabRect(i)
|
1453
|
+
Returns the client area of the tab at ((|idx|)) as an array of [x,y,w,h].
|
1454
|
+
--- adjustRect(x,y,w,h,flag=false)
|
1455
|
+
Adjusts a rectangle coodinates for tabcontrol's clientarea which is
|
1456
|
+
excluded tab buttons area. ((|flag|)) means the direction of adjusting.
|
1457
|
+
adjustRect(0,0,10,10,false) returns a leftsided rectangle below the
|
1458
|
+
tab buttons.
|
1459
|
+
--- getTabTextOf(idx)
|
1460
|
+
Gets a title text of tab at ((|idx|)).
|
1461
|
+
--- setTabTextOf(idx,text)
|
1462
|
+
Sets a title text of tab at ((|idx|)) as ((|text|)).
|
1463
|
+
--- getTabImageOf(idx)
|
1464
|
+
Gets a image id in the imagelist for tab at((|idx|)).
|
1465
|
+
--- setTabImageOf(idx,image)
|
1466
|
+
Sets a image id into ((|image|)) in the imagelist for tab at((|idx|)).
|
1467
|
+
--- getTabLParamOf(idx)
|
1468
|
+
Gets lparam value of tab at((|idx|)).
|
1469
|
+
--- setTabLParamOf(idx,lparam)
|
1470
|
+
Sets lparam value of tab at((|idx|)) as ((|lparam|)).
|
1471
|
+
|
1472
|
+
=== Event Handlers
|
1473
|
+
--- ????_selchanged
|
1474
|
+
Fired when the selected tab changed. To get current tab id, use selectedTab
|
1475
|
+
method.
|
1476
|
+
=end
|
1477
|
+
|
1478
|
+
include VRParent
|
1479
|
+
|
1480
|
+
WINCLASSINFO = ["SysTabControl32",0] #TCS_TAB
|
1481
|
+
|
1482
|
+
def tabcontrolinit
|
1483
|
+
addNotifyHandler WMsg::TCN_SELCHANGE,"selchanged",MSGTYPE::ARGNONE,nil
|
1484
|
+
end
|
1485
|
+
|
1486
|
+
def vrinit
|
1487
|
+
super
|
1488
|
+
tabcontrolinit
|
1489
|
+
end
|
1490
|
+
|
1491
|
+
def clearTabs
|
1492
|
+
sendMessage WMsg::TCM_DELETEALLITEMS,0,0
|
1493
|
+
end
|
1494
|
+
|
1495
|
+
def deleteTab(i)
|
1496
|
+
sendMessage WMsg::TCM_DELETEITEM,i,0
|
1497
|
+
end
|
1498
|
+
|
1499
|
+
def selectedTab
|
1500
|
+
sendMessage WMsg::TCM_GETCURSEL,0,0
|
1501
|
+
end
|
1502
|
+
|
1503
|
+
def countTabs
|
1504
|
+
sendMessage WMsg::TCM_GETITEMCOUNT,0,0
|
1505
|
+
end
|
1506
|
+
|
1507
|
+
def insertTab(idx,text,textmax=text.size,lparam=0)
|
1508
|
+
tb=@screen.application.arg2cstructStr(WStruct::TC_ITEM,
|
1509
|
+
0x9,0,0,text,textmax,0,lparam)
|
1510
|
+
# Mask,rsrv1,rsrv2,Text,TextMax,iImage,lParam
|
1511
|
+
sendMessage WMsg::TCM_INSERTITEM,idx.to_i,tb
|
1512
|
+
end
|
1513
|
+
|
1514
|
+
def selectTab(i)
|
1515
|
+
sendMessage WMsg::TCM_SETCURSEL,i,0
|
1516
|
+
end
|
1517
|
+
|
1518
|
+
def setImagelist(imagelist)
|
1519
|
+
raise "not Imagelist" unless imagelist.is_a?(SWin::Imagelist)
|
1520
|
+
sendMessage WMsg::TCM_SETIMAGELIST,0,imagelist.himagelist
|
1521
|
+
end
|
1522
|
+
|
1523
|
+
def setTabSize(width,height)
|
1524
|
+
sendMessage WMsg::TCM_SETITEMSIZE,0,MAKELPARAM(width,height)
|
1525
|
+
end
|
1526
|
+
|
1527
|
+
def getTabRect(i)
|
1528
|
+
rect="\0"*16
|
1529
|
+
sendMessage WMsg::TCM_GETITEMRECT,i.to_i,rect
|
1530
|
+
return @screen.application.unpack(rect,"UUUU")
|
1531
|
+
end
|
1532
|
+
|
1533
|
+
def adjustRect(x,y,w,h,flag=false)
|
1534
|
+
f = if flag then 1 else 0 end
|
1535
|
+
rect=@screen.application.arg2cstructStr("UUUU",x,y,w,h)
|
1536
|
+
sendMessage WMsg::TCM_ADJUSTRECT,f,rect
|
1537
|
+
return @screen.application.unpack(rect,"UUUU")
|
1538
|
+
end
|
1539
|
+
|
1540
|
+
# tab's properties = text,image,lparam
|
1541
|
+
|
1542
|
+
def getTabTextOf(idx)
|
1543
|
+
tb=@screen.application.arg2cstructStr(WStruct::TC_ITEM,
|
1544
|
+
0x1,0,0,"\0"*128,128,0,0)
|
1545
|
+
rv=sendMessage WMsg::TCM_GETITEM,idx.to_i,tb
|
1546
|
+
if rv!=0 then
|
1547
|
+
r=@screen.application.unpack(tb,WStruct::TC_ITEM)[3]
|
1548
|
+
@screen.application.pointer2string(r)
|
1549
|
+
else
|
1550
|
+
nil
|
1551
|
+
end
|
1552
|
+
end
|
1553
|
+
def getTabImageOf(idx)
|
1554
|
+
tb=@screen.application.arg2cstructStr(WStruct::TC_ITEM,
|
1555
|
+
0x2,0,0," \0",1,0,0)
|
1556
|
+
rv=sendMessage WMsg::TCM_GETITEM,idx.to_i,tb
|
1557
|
+
r=@screen.application.unpack(tb,WStruct::TC_ITEM)[5]
|
1558
|
+
end
|
1559
|
+
def getTabLParamOf(idx)
|
1560
|
+
tb=@screen.application.arg2cstructStr(WStruct::TC_ITEM,
|
1561
|
+
0x8,0,0," \0",1,0,0)
|
1562
|
+
rv=sendMessage WMsg::TCM_GETITEM,idx.to_i,tb
|
1563
|
+
r=@screen.application.unpack(tb,WStruct::TC_ITEM)[6]
|
1564
|
+
end
|
1565
|
+
|
1566
|
+
def setTabTextOf(idx,text)
|
1567
|
+
tb=@screen.application.arg2cstructStr(WStruct::TC_ITEM,
|
1568
|
+
0x1,0,0,text,text.length,0,0)
|
1569
|
+
sendMessage WMsg::TCM_SETITEM,idx.to_i,tb
|
1570
|
+
self.refresh
|
1571
|
+
end
|
1572
|
+
def setTabImageOf(idx,iImage)
|
1573
|
+
tb=@screen.application.arg2cstructStr(WStruct::TC_ITEM,
|
1574
|
+
0x2,0,0," \0",1,iImage,0)
|
1575
|
+
sendMessage WMsg::TCM_SETITEM,idx.to_i,tb
|
1576
|
+
self.refresh
|
1577
|
+
end
|
1578
|
+
def setTabLParamOf(idx,lparam)
|
1579
|
+
tb=@screen.application.arg2cstructStr(WStruct::TC_ITEM,
|
1580
|
+
0x8,0,0," \0",1,0,lparam)
|
1581
|
+
sendMessage WMsg::TCM_SETITEM,idx.to_i,tb
|
1582
|
+
end
|
1583
|
+
end
|
1584
|
+
|
1585
|
+
class VRTabbedPanel < VRTabControl
|
1586
|
+
=begin
|
1587
|
+
== VRTabbedPanel
|
1588
|
+
This is a class utilizing VRTabControl.
|
1589
|
+
On this control, each tab has a VRPanel and be shown/hidden automatically
|
1590
|
+
according to the selected tab.
|
1591
|
+
|
1592
|
+
=== Class method
|
1593
|
+
--- auto_panelresize(flag)
|
1594
|
+
Resize panels on the tabs automatically when this control resized.
|
1595
|
+
=== Methods
|
1596
|
+
--- setupPanels(arg-1,arg-2,arg-3,....)
|
1597
|
+
Creates tabs each titled ((|arg-n|)) if args are String.
|
1598
|
+
When ((|arg-n|)) is array of ((|[title, contorl-class, control-name]|)),
|
1599
|
+
Creates control and relates with the tab.
|
1600
|
+
Use like follows.
|
1601
|
+
class Panel1 < VRPanel
|
1602
|
+
include VRContainersSet
|
1603
|
+
...
|
1604
|
+
end
|
1605
|
+
class Panel2 < VRPanel
|
1606
|
+
...
|
1607
|
+
end
|
1608
|
+
...
|
1609
|
+
setupPanels(["tab-1",Panel1,"panel1"],["tab-2",Panel2,"panel2"])
|
1610
|
+
--- send_parent2(idx,controlname,eventname)
|
1611
|
+
Sets to send to its parent an event of control named ((|controlname|))
|
1612
|
+
on the panel at ((|idx|)).
|
1613
|
+
=== Attribute(s)
|
1614
|
+
--- panels
|
1615
|
+
An array that contains panels for each tab.
|
1616
|
+
panels[i] means a panel concerned with the tab at ((|i|)).
|
1617
|
+
=== Event Handlers
|
1618
|
+
Same as ((<VRTabControl>)).
|
1619
|
+
VRTabbedPanel#selchanged is already defined, so you need to call super when you
|
1620
|
+
override this method.
|
1621
|
+
=end
|
1622
|
+
attr :panels
|
1623
|
+
include VRMessageHandler
|
1624
|
+
include VRParent
|
1625
|
+
|
1626
|
+
@@_auto_tabpanelresize = nil
|
1627
|
+
|
1628
|
+
def self.auto_panelresize(flag)
|
1629
|
+
@@_auto_tabpanelresize = flag
|
1630
|
+
end
|
1631
|
+
|
1632
|
+
def vrinit
|
1633
|
+
super
|
1634
|
+
if @@_auto_tabpanelresize
|
1635
|
+
addHandler(WMsg::WM_SIZE, "_vr_tabpanelresize", MSGTYPE::ARGLINTINT,nil)
|
1636
|
+
acceptEvents [WMsg::WM_SIZE]
|
1637
|
+
end
|
1638
|
+
end
|
1639
|
+
|
1640
|
+
def setupPanels(*args)
|
1641
|
+
@panels=Array.new(args.size)
|
1642
|
+
0.upto(args.size-1) do |i|
|
1643
|
+
if args[i].is_a? Array
|
1644
|
+
insertTab i,args[i][0]
|
1645
|
+
c = args[i][1] ? args[i][1] : VRPanel
|
1646
|
+
s = args[i][2] ? args[i][2] : "panel#{i}"
|
1647
|
+
x,y,w,h = adjustRect(0,0,self.w,self.h,false)
|
1648
|
+
@panels[i] = addControl(c,s,s,x,y,w-x,h-y)
|
1649
|
+
else
|
1650
|
+
insertTab i,args[i]
|
1651
|
+
x,y,w,h = adjustRect(0,0,self.w,self.h,false)
|
1652
|
+
@panels[i] = addControl(VRPanel,"panel#{i}","panel#{i}",x,y,w-x,h-y)
|
1653
|
+
@panels[i].extend VRContainersSet
|
1654
|
+
@panels[i].containers_init
|
1655
|
+
end
|
1656
|
+
@panels[i].show 0
|
1657
|
+
end
|
1658
|
+
|
1659
|
+
@_vr_prevpanel=0
|
1660
|
+
selectTab 0
|
1661
|
+
end
|
1662
|
+
|
1663
|
+
def send_parent2(i,name,method)
|
1664
|
+
@panels[i].send_parent(name,method)
|
1665
|
+
send_parent "panel#{i}","#{name}_#{method}"
|
1666
|
+
end
|
1667
|
+
|
1668
|
+
def selectTab(i)
|
1669
|
+
super
|
1670
|
+
selchanged
|
1671
|
+
end
|
1672
|
+
|
1673
|
+
def selchanged
|
1674
|
+
raise "assigned no panels" if @panels.size<1
|
1675
|
+
@panels[@_vr_prevpanel].show(0)
|
1676
|
+
t=selectedTab
|
1677
|
+
@panels[t].show
|
1678
|
+
@_vr_prevpanel=t
|
1679
|
+
@panels[t].refresh
|
1680
|
+
end
|
1681
|
+
|
1682
|
+
def self__vr_tabpanelresize(w,h)
|
1683
|
+
x,y,w,h = adjustRect(0,0,self.w,self.h,false)
|
1684
|
+
@panels.each{|i| i.move(x,y,w-x,h-y)}
|
1685
|
+
end
|
1686
|
+
end
|
1687
|
+
|
1688
|
+
unless VR_OLDCOMCTL then
|
1689
|
+
|
1690
|
+
|
1691
|
+
module WMsg
|
1692
|
+
RB_INSERTBAND = WM_USER + 1
|
1693
|
+
RB_DELETEBAND = WM_USER + 2
|
1694
|
+
RB_GETBARINFO = WM_USER + 3
|
1695
|
+
RB_SETBARINFO = WM_USER + 4
|
1696
|
+
RB_GETBANDCOUNT = WM_USER + 12
|
1697
|
+
RB_GETROWCOUNT = WM_USER + 13
|
1698
|
+
RB_GETROWHEIGHT = WM_USER + 14
|
1699
|
+
RB_SETBKCOLOR = WM_USER + 19
|
1700
|
+
RB_GETBKCOLOR = WM_USER + 20
|
1701
|
+
RB_SETTEXTCOLOR = WM_USER + 21
|
1702
|
+
RB_GETTEXTCOLOR = WM_USER + 22
|
1703
|
+
RB_SIZETORECT = WM_USER + 23
|
1704
|
+
RB_GETBARHEIGHT = WM_USER + 27
|
1705
|
+
RB_GETBANDINFO = WM_USER + 29
|
1706
|
+
RB_SHOWBAND = WM_USER + 35
|
1707
|
+
RB_SETPALETTE = WM_USER + 37
|
1708
|
+
RB_GETPALETTE = WM_USER + 38
|
1709
|
+
RB_MOVEBAND = WM_USER + 39
|
1710
|
+
|
1711
|
+
RBN_LAYOUTCHANGED = 0x100000000-831-2
|
1712
|
+
end
|
1713
|
+
|
1714
|
+
|
1715
|
+
module WConst
|
1716
|
+
RBBIM_STYLE = 0x00000001
|
1717
|
+
RBBIM_COLORS = 0x00000002
|
1718
|
+
RBBIM_TEXT = 0x00000004
|
1719
|
+
RBBIM_IMAGE = 0x00000008
|
1720
|
+
RBBIM_CHILD = 0x00000010
|
1721
|
+
RBBIM_CHILDSIZE = 0x00000020
|
1722
|
+
RBBIM_SIZE = 0x00000040
|
1723
|
+
RBBIM_BACKGROUND = 0x00000080
|
1724
|
+
end
|
1725
|
+
|
1726
|
+
class VRRebar < VRNotifyControl
|
1727
|
+
=begin
|
1728
|
+
== VRRebar
|
1729
|
+
Rebar control.
|
1730
|
+
If comctl32.dll on your system is too old, this is not available.
|
1731
|
+
=== Methods
|
1732
|
+
--- insertband(cntl,txt,minx=30,miny=cnt.h+2,band=-1)
|
1733
|
+
Creates a new band and set the control on it.
|
1734
|
+
((|txt|)) is the caption of the band and minx/miny is the minimum size of
|
1735
|
+
the band.
|
1736
|
+
The control is created by rebar's addControl() but its event handling is on
|
1737
|
+
the parent window.
|
1738
|
+
--- bkColor=(c)
|
1739
|
+
--- bkColor
|
1740
|
+
Sets/Gets background color of rebar.
|
1741
|
+
--- textColor=(c)
|
1742
|
+
--- textColor
|
1743
|
+
Sets/Gets band caption color.
|
1744
|
+
--- relayout(x=self.x, y=self.y, w=self.w, h=self.h)
|
1745
|
+
rearranges rebar's bands in the specified rectangle.
|
1746
|
+
=end
|
1747
|
+
|
1748
|
+
WINCLASSINFO = ["ReBarWindow32",0]
|
1749
|
+
|
1750
|
+
def rebarinit
|
1751
|
+
sendMessage WMsg::RB_SETBARINFO,0,[12,0,0].pack("LLL")
|
1752
|
+
addNotifyHandler WMsg::RBN_LAYOUTCHANGED,"layoutchanged",MSGTYPE::ARGNONE,nil
|
1753
|
+
end
|
1754
|
+
|
1755
|
+
def vrinit
|
1756
|
+
super
|
1757
|
+
rebarinit
|
1758
|
+
end
|
1759
|
+
|
1760
|
+
def insertband(cnt,txt,minx=30,miny=cnt.h+2,band=-1)
|
1761
|
+
size = 4*14
|
1762
|
+
mask= WConst::RBBIM_TEXT | WConst::RBBIM_STYLE | WConst::RBBIM_CHILD | WConst::RBBIM_CHILDSIZE | WConst::RBBIM_SIZE
|
1763
|
+
style= 4 #RBBS_CHILDEDGE
|
1764
|
+
frcolor= 0
|
1765
|
+
bkcolor= 0
|
1766
|
+
text= txt
|
1767
|
+
cch= 0
|
1768
|
+
image= 0
|
1769
|
+
hwndChild= cnt.hWnd
|
1770
|
+
cxmin= minx
|
1771
|
+
cymin= miny
|
1772
|
+
cx= 100
|
1773
|
+
bkBmp= 0
|
1774
|
+
wid= 0
|
1775
|
+
tis = [size,mask,style,frcolor,bkcolor,text,cch,image,hwndChild,cxmin,cymin,cx,bkBmp,wid].pack("LLLLLP#{text.length}LLLLLLLL")
|
1776
|
+
sendMessage WMsg::RB_INSERTBAND,band,tis
|
1777
|
+
end
|
1778
|
+
|
1779
|
+
def h
|
1780
|
+
sendMessage WMsg::RB_GETBARHEIGHT,0,0
|
1781
|
+
end
|
1782
|
+
|
1783
|
+
def bkColor
|
1784
|
+
sendMessage WMsg::RB_GETBKCOLOR,0,0
|
1785
|
+
end
|
1786
|
+
def bkColor=(c)
|
1787
|
+
sendMessage WMsg::RB_SETBKCOLOR,0,c
|
1788
|
+
end
|
1789
|
+
|
1790
|
+
def textColor
|
1791
|
+
sendMessage WMsg::RB_GETTEXTCOLOR,0,0
|
1792
|
+
end
|
1793
|
+
def textColor=(c)
|
1794
|
+
sendMessage WMsg::RB_SETTEXTCOLOR,0,c
|
1795
|
+
end
|
1796
|
+
|
1797
|
+
def relayout(x=self.x,y=self.y,w=self.w,h=self.h)
|
1798
|
+
sendMessage WMsg::RB_SIZETORECT,0,[x,y,w,h].pack("LLLL")
|
1799
|
+
end
|
1800
|
+
|
1801
|
+
include VRParent
|
1802
|
+
def newControlID
|
1803
|
+
@parent.newControlID
|
1804
|
+
end
|
1805
|
+
def registerControl(*arg)
|
1806
|
+
@parent.registerControl(*arg)
|
1807
|
+
end
|
1808
|
+
end
|
1809
|
+
|
1810
|
+
end # unlessVR_OLDCOMCTL
|
1811
|
+
|
1812
|
+
|
1813
|
+
# contribute files
|
1814
|
+
require VR_DIR+'contrib/toolbar'
|
1815
|
+
require VR_DIR+'contrib/vrlistviewex'
|
1816
|
+
|
1817
|
+
if VR_COMPATIBILITY_LEVEL then
|
1818
|
+
require VR_DIR + 'compat/vrcomctl.rb'
|
1819
|
+
end
|