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